Skip to content

Commit

Permalink
Merge pull request #311 from lokka30/3.2-dev
Browse files Browse the repository at this point in the history
3.2 dev
  • Loading branch information
lokka30 authored Oct 18, 2021
2 parents bc6d356 + 8710b7b commit d6ad63e
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 38 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<groupId>me.lokka30</groupId>
<artifactId>LevelledMobs</artifactId>
<version>3.2.1 b536</version>
<version>3.2.2 b538</version>
<packaging>jar</packaging>

<name>LevelledMobs</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,22 @@ public void parseSubcommand(final LevelledMobs main, final @NotNull CommandSende
return;
}

if (args.length < 3 || !"create".equalsIgnoreCase(args[1]) && !"confirm".equalsIgnoreCase(args[2])){
sender.sendMessage(MessageUtils.colorizeAll("&fBuild Debug Files&r\n" +
"If you're running this command, that means a LM Developer asked you to.\n" +
"We need copies of your LevelledMobs files, as well as a list of your current plugins, your current server build and version, " +
"and your current and maximum player count. Confirming this command will create a .ZIP file containing the above mentioned information, " +
"to be shared with a LM Developer. &fAbsolutely NOTHING&r within the .ZIP would contain private or personal information, and you can verify " +
"the contents of the .ZIP file prior to sending.\n" +
"If you are satisfied, please confirm by typing &b/lm debug create confirm"));

return;
if (args.length == 3 && "create".equalsIgnoreCase(args[1]) && "confirm".equalsIgnoreCase(args[2]))
DebugCreator.createDebug(main, sender);
else{
sender.sendMessage(MessageUtils.colorizeAll("&b&nCreate a Debugging ZIP\n" +
"&7You should only run this command if a LevelledMobs developer has asked you to. It is used to assist users who are experiencing issues with the plugin.\n" +
"&r\n" +
"&7This command will generate a ZIP file containing the following required data:\n" +
"&8 &m->&b Plugins list\n" +
"&8 &m->&b Server version\n" +
"&8 &m->&b Current and maximum online player count\n" +
"&8 &m->&b The latest.log file&7 &8(/logs/latest.log)\n" +
"&r\n" +
"&7LevelledMobs developers will not redistribute or retain the data beyond the purpose of resolving any issue you may be experiencing. You may also verify the contents prior to sending the file.\n" +
"&7To proceed in creating the ZIP file, please run:\n" +
"&b/lm debug create confirm&7"));
}

DebugCreator.createDebug(main, sender);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ public PlayerDeathListener(final LevelledMobs main){
public void onPlayerDeath(@NotNull final PlayerDeathEvent event) {
final LivingEntityWrapper lmEntity = getPlayersKiller(event);

if (lmEntity == null){
main.placeholderApiIntegration.putPlayerOrMobDeath(event.getEntity(), null);
if (main.placeholderApiIntegration != null){
main.placeholderApiIntegration.putPlayerOrMobDeath(event.getEntity(), lmEntity);
return;
}

main.placeholderApiIntegration.putPlayerOrMobDeath(event.getEntity(), lmEntity);
lmEntity.free();
if (lmEntity != null)
lmEntity.free();
}

@Nullable
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/me/lokka30/levelledmobs/managers/LevelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,8 @@ else if (levellableState == LevellableState.ALLOWED)
for (final LivingEntityWrapper lmEntity : entityToPlayer.keySet()) {
if (entityToPlayer.containsKey(lmEntity))
checkEntityForPlayerLevelling(lmEntity, entityToPlayer.get(lmEntity));

lmEntity.free();
}
}

Expand All @@ -742,10 +744,9 @@ private void checkEntityForPlayerLevelling(final @NotNull LivingEntityWrapper lm
break;
}

if (closestPlayer == null) {
lmEntity.free();
if (closestPlayer == null)
return;
}

if (doesMobNeedRelevelling(mob, closestPlayer)) {

synchronized (mob.getPersistentDataContainer()) {
Expand All @@ -756,7 +757,6 @@ private void checkEntityForPlayerLevelling(final @NotNull LivingEntityWrapper lm
lmEntity.reEvaluateLevel = true;
main._mobsQueueManager.addToQueue(new QueueItem(lmEntity, null));
}
lmEntity.free();
}

private void checkLevelledEntity(@NotNull final LivingEntityWrapper lmEntity, @NotNull final Player player){
Expand All @@ -772,7 +772,7 @@ private void checkLevelledEntity(@NotNull final LivingEntityWrapper lmEntity, @N
} else {
if (!main.helperSettings.getBoolean(main.settingsCfg, "use-customname-for-mob-nametags", false) &&
location.getWorld() != null &&
location.getWorld().getName().equals(lmEntity.getWorld().getName()) &&
location.getWorld().equals(lmEntity.getWorld()) &&
lmEntity.getLocation().distanceSquared(location) <= maxDistance) {
//if within distance, update nametag.
main.nametagQueueManager_.addToQueue(new QueueItem(lmEntity, main.levelManager.getNametag(lmEntity, false), Collections.singletonList(player)));
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/me/lokka30/levelledmobs/misc/DebugCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public class DebugCreator {
public static void createDebug(final @NotNull LevelledMobs main, final CommandSender sender){
final String pluginDir = main.getDataFolder().getAbsolutePath();
final List<String> srcFiles = List.of(
"serverinfo.txt", "rules.yml", "settings.yml", "messages.yml", "customdrops.yml");
"serverinfo.txt", "rules.yml", "settings.yml", "messages.yml", "customdrops.yml",
Bukkit.getWorldContainer().getAbsolutePath().substring(0, Bukkit.getWorldContainer().getAbsolutePath().length() - 1) + "logs" + File.separator + "latest.log");
final File serverInfoFile = new File(pluginDir, "serverinfo.txt");
try{
Files.writeString(serverInfoFile.toPath(), generateSystemInfo(main), StandardCharsets.UTF_8);
Expand All @@ -43,7 +44,9 @@ public static void createDebug(final @NotNull LevelledMobs main, final CommandSe
zipOut = new ZipOutputStream(fos);

for (String srcFile : srcFiles) {
final File fileToZip = new File(pluginDir, srcFile);
final File fileToZip = srcFile.contains(File.separator) ?
new File(srcFile) : new File(pluginDir, srcFile);

fis = new FileInputStream(fileToZip);
final ZipEntry zipEntry = new ZipEntry(fileToZip.getName());
zipOut.putNextEntry(zipEntry);
Expand All @@ -70,6 +73,9 @@ public static void createDebug(final @NotNull LevelledMobs main, final CommandSe
catch (Exception ignored) {}
}

final File serverInfo = new File(pluginDir, "serverinfo.txt");
if (serverInfo.exists()) serverInfo.delete();

if (result)
sender.sendMessage("Created file: " + zipFile.getAbsolutePath());
}
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/predefined/rules_easy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ presets:
item-drop: 3
xp-drop: 5
# Special Multipliers (0.0 Min - 1.0 Max)
armor-bonus: 1.0
armor-toughness: 0.5
armor-bonus: 0.3
armor-toughness: 0.3
attack-knockback: 0.5
knockback-resistance: 0.5
zombie-spawn-reinforcements: 0.45
Expand Down Expand Up @@ -229,8 +229,8 @@ presets:
item-drop: 3
xp-drop: 5
# Special Multipliers (0.0 Min - 1.0 Max)
armor-bonus: 0.5
armor-toughness: 0.2
armor-bonus: 0.2
armor-toughness: 0.15
attack-knockback: 0.25
knockback-resistance: 0.2
zombie-spawn-reinforcements: 0.25
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/predefined/rules_hard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ presets:
item-drop: 3
xp-drop: 5
# Special Multipliers (0.0 Min - 1.0 Max)
armor-bonus: 1.0
armor-toughness: 0.5
armor-bonus: 0.3
armor-toughness: 0.3
attack-knockback: 0.5
knockback-resistance: 0.5
zombie-spawn-reinforcements: 0.45
Expand Down Expand Up @@ -229,8 +229,8 @@ presets:
item-drop: 3
xp-drop: 5
# Special Multipliers (0.0 Min - 1.0 Max)
armor-bonus: 0.5
armor-toughness: 0.2
armor-bonus: 0.2
armor-toughness: 0.15
attack-knockback: 0.25
knockback-resistance: 0.2
zombie-spawn-reinforcements: 0.25
Expand Down
12 changes: 6 additions & 6 deletions src/main/resources/rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@ presets:
item-drop: 3
xp-drop: 5
# Special Multipliers (0.0 Min - 1.0 Max)
armor-bonus: 0.7
armor-toughness: 0.4
armor-bonus: 0.3
armor-toughness: 0.3
attack-knockback: 0.5
knockback-resistance: 0.5
zombie-spawn-reinforcements: 0.45
Expand Down Expand Up @@ -229,8 +229,8 @@ presets:
item-drop: 3
xp-drop: 5
# Special Multipliers (0.0 Min - 1.0 Max)
armor-bonus: 0.5
armor-toughness: 0.2
armor-bonus: 0.2
armor-toughness: 0.15
attack-knockback: 0.25
knockback-resistance: 0.2
zombie-spawn-reinforcements: 0.25
Expand Down Expand Up @@ -264,8 +264,8 @@ presets:
item-drop: 3
xp-drop: 5
# Special Multipliers (0.0 Min - 1.0 Max)
armor-bonus: 0.4
armor-toughness: 0.2
armor-bonus: 0.1
armor-toughness: 0.0
attack-knockback: 0.1
knockback-resistance: 0.15
zombie-spawn-reinforcements: 0.1
Expand Down

0 comments on commit d6ad63e

Please sign in to comment.