From b87d4544aa0610b9511adfed9525555ff91cd027 Mon Sep 17 00:00:00 2001 From: stumper66 Date: Sun, 17 Oct 2021 09:50:16 -0500 Subject: [PATCH 1/4] 3.2.2 b537 * fixed exception relating to Placeholder API when it is not installed and a player dies * fix for potential exception: java.lang.NullPointerException: Cannot invoke "org.bukkit.entity.LivingEntity.getType()" because "this.livingEntity" is null * updated armor-bonus and armor-toughness defaults in rules.yml --- pom.xml | 2 +- .../commands/subcommands/DebugSubcommand.java | 8 +++----- .../levelledmobs/listeners/PlayerDeathListener.java | 8 ++++---- .../lokka30/levelledmobs/managers/LevelManager.java | 10 +++++----- src/main/resources/predefined/rules_easy.yml | 8 ++++---- src/main/resources/predefined/rules_hard.yml | 8 ++++---- src/main/resources/rules.yml | 12 ++++++------ 7 files changed, 27 insertions(+), 29 deletions(-) diff --git a/pom.xml b/pom.xml index df7eceada..79fc0fd8e 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ me.lokka30 LevelledMobs - 3.2.1 b536 + 3.2.2 b536 jar LevelledMobs diff --git a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/DebugSubcommand.java b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/DebugSubcommand.java index 50b8ff713..deaaa982c 100644 --- a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/DebugSubcommand.java +++ b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/DebugSubcommand.java @@ -18,7 +18,9 @@ public void parseSubcommand(final LevelledMobs main, final @NotNull CommandSende return; } - if (args.length < 3 || !"create".equalsIgnoreCase(args[1]) && !"confirm".equalsIgnoreCase(args[2])){ + if (args.length == 3 && "create".equalsIgnoreCase(args[1]) && "confirm".equalsIgnoreCase(args[2])) + DebugCreator.createDebug(main, sender); + else{ 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, " + @@ -26,11 +28,7 @@ public void parseSubcommand(final LevelledMobs main, final @NotNull CommandSende "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; } - - DebugCreator.createDebug(main, sender); } @Override diff --git a/src/main/java/me/lokka30/levelledmobs/listeners/PlayerDeathListener.java b/src/main/java/me/lokka30/levelledmobs/listeners/PlayerDeathListener.java index c1063da0e..6bf568980 100644 --- a/src/main/java/me/lokka30/levelledmobs/listeners/PlayerDeathListener.java +++ b/src/main/java/me/lokka30/levelledmobs/listeners/PlayerDeathListener.java @@ -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 diff --git a/src/main/java/me/lokka30/levelledmobs/managers/LevelManager.java b/src/main/java/me/lokka30/levelledmobs/managers/LevelManager.java index ab9efa703..369995e2e 100644 --- a/src/main/java/me/lokka30/levelledmobs/managers/LevelManager.java +++ b/src/main/java/me/lokka30/levelledmobs/managers/LevelManager.java @@ -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(); } } @@ -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()) { @@ -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){ @@ -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))); diff --git a/src/main/resources/predefined/rules_easy.yml b/src/main/resources/predefined/rules_easy.yml index 7f6683882..b08639ced 100644 --- a/src/main/resources/predefined/rules_easy.yml +++ b/src/main/resources/predefined/rules_easy.yml @@ -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 @@ -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 diff --git a/src/main/resources/predefined/rules_hard.yml b/src/main/resources/predefined/rules_hard.yml index 2210d9691..35f426e20 100644 --- a/src/main/resources/predefined/rules_hard.yml +++ b/src/main/resources/predefined/rules_hard.yml @@ -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 @@ -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 diff --git a/src/main/resources/rules.yml b/src/main/resources/rules.yml index 1d8bb7a3f..cf015e172 100644 --- a/src/main/resources/rules.yml +++ b/src/main/resources/rules.yml @@ -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 @@ -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 @@ -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 From 8fafb2c4fe2f19c2c332ada666f508a35675ffef Mon Sep 17 00:00:00 2001 From: stumper66 Date: Sun, 17 Oct 2021 18:54:39 -0500 Subject: [PATCH 2/4] 3.2.2 b538 * /lm debug command now includes latest.log --- pom.xml | 2 +- .../commands/subcommands/DebugSubcommand.java | 18 +++++++++++------- .../levelledmobs/misc/DebugCreator.java | 7 +++++-- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/pom.xml b/pom.xml index 79fc0fd8e..789039d06 100644 --- a/pom.xml +++ b/pom.xml @@ -10,7 +10,7 @@ me.lokka30 LevelledMobs - 3.2.2 b536 + 3.2.2 b538 jar LevelledMobs diff --git a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/DebugSubcommand.java b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/DebugSubcommand.java index deaaa982c..e11063e97 100644 --- a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/DebugSubcommand.java +++ b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/DebugSubcommand.java @@ -21,13 +21,17 @@ public void parseSubcommand(final LevelledMobs main, final @NotNull CommandSende if (args.length == 3 && "create".equalsIgnoreCase(args[1]) && "confirm".equalsIgnoreCase(args[2])) DebugCreator.createDebug(main, sender); else{ - 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")); + 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->&7 The &blatest.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 &b/lm debug create confirm&7.")); } } diff --git a/src/main/java/me/lokka30/levelledmobs/misc/DebugCreator.java b/src/main/java/me/lokka30/levelledmobs/misc/DebugCreator.java index 768d052e2..1743817c2 100644 --- a/src/main/java/me/lokka30/levelledmobs/misc/DebugCreator.java +++ b/src/main/java/me/lokka30/levelledmobs/misc/DebugCreator.java @@ -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 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); @@ -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); From 493cc411d2861f54c235215b8fbacfe5e2122e73 Mon Sep 17 00:00:00 2001 From: stumper66 Date: Sun, 17 Oct 2021 18:59:22 -0500 Subject: [PATCH 3/4] 3.2.2 b538 small message revision --- .../levelledmobs/commands/subcommands/DebugSubcommand.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/DebugSubcommand.java b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/DebugSubcommand.java index e11063e97..6bd03cd50 100644 --- a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/DebugSubcommand.java +++ b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/DebugSubcommand.java @@ -31,7 +31,8 @@ public void parseSubcommand(final LevelledMobs main, final @NotNull CommandSende "&8 &m->&7 The &blatest.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 &b/lm debug create confirm&7.")); + "&7To proceed in creating the ZIP file, please run:\n" + + "&b/lm debug create confirm&7.")); } } From 8710b7bfe991feb262a4c390acedfdb5a5da6f8a Mon Sep 17 00:00:00 2001 From: stumper66 Date: Sun, 17 Oct 2021 19:20:55 -0500 Subject: [PATCH 4/4] 3.2.2 b538 * /lm debug command now includes latest.log and deletes serverinfo.txt when done --- .../levelledmobs/commands/subcommands/DebugSubcommand.java | 4 ++-- src/main/java/me/lokka30/levelledmobs/misc/DebugCreator.java | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/DebugSubcommand.java b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/DebugSubcommand.java index 6bd03cd50..dcfb160e2 100644 --- a/src/main/java/me/lokka30/levelledmobs/commands/subcommands/DebugSubcommand.java +++ b/src/main/java/me/lokka30/levelledmobs/commands/subcommands/DebugSubcommand.java @@ -28,11 +28,11 @@ public void parseSubcommand(final LevelledMobs main, final @NotNull CommandSende "&8 &m->&b Plugins list\n" + "&8 &m->&b Server version\n" + "&8 &m->&b Current and maximum online player count\n" + - "&8 &m->&7 The &blatest.log file&7 &8(/logs/latest.log)\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.")); + "&b/lm debug create confirm&7")); } } diff --git a/src/main/java/me/lokka30/levelledmobs/misc/DebugCreator.java b/src/main/java/me/lokka30/levelledmobs/misc/DebugCreator.java index 1743817c2..7556a05d9 100644 --- a/src/main/java/me/lokka30/levelledmobs/misc/DebugCreator.java +++ b/src/main/java/me/lokka30/levelledmobs/misc/DebugCreator.java @@ -73,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()); }