From b0e8fedf6f5a94c8de58f2c40ac8fbeec0f723f2 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Tue, 25 Aug 2020 14:10:53 -0700 Subject: [PATCH] Fixed a taming NPE --- Changelog.txt | 6 ++++++ pom.xml | 2 +- .../com/gmail/nossr50/listeners/InventoryListener.java | 2 ++ .../gmail/nossr50/util/compat/CompatibilityManager.java | 8 ++++---- ...DataLayer.java => SpigotPersistentDataLayer_1_13.java} | 2 +- ...DataLayer.java => SpigotPersistentDataLayer_1_14.java} | 2 +- .../java/com/gmail/nossr50/util/skills/CombatUtils.java | 4 ++++ 7 files changed, 19 insertions(+), 7 deletions(-) rename src/main/java/com/gmail/nossr50/util/compat/layers/persistentdata/{SpigotTemporaryDataLayer.java => SpigotPersistentDataLayer_1_13.java} (97%) rename src/main/java/com/gmail/nossr50/util/compat/layers/persistentdata/{SpigotPersistentDataLayer.java => SpigotPersistentDataLayer_1_14.java} (98%) diff --git a/Changelog.txt b/Changelog.txt index 17778b4fb..6fedacf3f 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,3 +1,9 @@ +Version 2.1.144 + Fixed a NPE that would happen involving taming in combat processing + Updated hu_HU locale (thanks andris155) + + + Version 2.1.143 mcMMO now tracks super ability boosted items through persistent metadata mcMMO no longer relies on lore to tell if an item has been modified by a super ability diff --git a/pom.xml b/pom.xml index 4093a28f6..71b784cd8 100755 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.gmail.nossr50.mcMMO mcMMO - 2.1.143 + 2.1.144-SNAPSHOT mcMMO https://github.com/mcMMO-Dev/mcMMO diff --git a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java index f068e8fab..464d83631 100644 --- a/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/InventoryListener.java @@ -72,7 +72,9 @@ public class InventoryListener implements Listener { return; } + Bukkit.broadcastMessage("Debug: Modifying burn time from - "+event.getBurnTime()); event.setBurnTime(UserManager.getPlayer(player).getSmeltingManager().fuelEfficiency(event.getBurnTime())); + Bukkit.broadcastMessage("Debug: New burn time "+event.getBurnTime()); } } diff --git a/src/main/java/com/gmail/nossr50/util/compat/CompatibilityManager.java b/src/main/java/com/gmail/nossr50/util/compat/CompatibilityManager.java index 51720245f..a95b14b54 100644 --- a/src/main/java/com/gmail/nossr50/util/compat/CompatibilityManager.java +++ b/src/main/java/com/gmail/nossr50/util/compat/CompatibilityManager.java @@ -5,8 +5,8 @@ import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.util.StringUtils; import com.gmail.nossr50.util.compat.layers.attackcooldown.PlayerAttackCooldownExploitPreventionLayer; import com.gmail.nossr50.util.compat.layers.persistentdata.AbstractPersistentDataLayer; -import com.gmail.nossr50.util.compat.layers.persistentdata.SpigotPersistentDataLayer; -import com.gmail.nossr50.util.compat.layers.persistentdata.SpigotTemporaryDataLayer; +import com.gmail.nossr50.util.compat.layers.persistentdata.SpigotPersistentDataLayer_1_14; +import com.gmail.nossr50.util.compat.layers.persistentdata.SpigotPersistentDataLayer_1_13; import com.gmail.nossr50.util.nms.NMSVersion; import com.gmail.nossr50.util.platform.MinecraftGameVersion; import org.bukkit.command.CommandSender; @@ -67,10 +67,10 @@ public class CompatibilityManager { private void initPersistentDataLayer() { if(minecraftGameVersion.getMinorVersion().asInt() >= 14 || minecraftGameVersion.getMajorVersion().asInt() >= 2) { - persistentDataLayer = new SpigotPersistentDataLayer(); + persistentDataLayer = new SpigotPersistentDataLayer_1_14(); } else { - persistentDataLayer = new SpigotTemporaryDataLayer(); + persistentDataLayer = new SpigotPersistentDataLayer_1_13(); } supportedLayers.put(CompatibilityType.PERSISTENT_DATA, true); diff --git a/src/main/java/com/gmail/nossr50/util/compat/layers/persistentdata/SpigotTemporaryDataLayer.java b/src/main/java/com/gmail/nossr50/util/compat/layers/persistentdata/SpigotPersistentDataLayer_1_13.java similarity index 97% rename from src/main/java/com/gmail/nossr50/util/compat/layers/persistentdata/SpigotTemporaryDataLayer.java rename to src/main/java/com/gmail/nossr50/util/compat/layers/persistentdata/SpigotPersistentDataLayer_1_13.java index c5b32138d..794aad916 100644 --- a/src/main/java/com/gmail/nossr50/util/compat/layers/persistentdata/SpigotTemporaryDataLayer.java +++ b/src/main/java/com/gmail/nossr50/util/compat/layers/persistentdata/SpigotPersistentDataLayer_1_13.java @@ -16,7 +16,7 @@ import java.util.UUID; /** * Persistent Data API is unavailable */ -public class SpigotTemporaryDataLayer extends AbstractPersistentDataLayer { +public class SpigotPersistentDataLayer_1_13 extends AbstractPersistentDataLayer { private final String FURNACE_OWNER_METADATA_KEY = "mcMMO_furnace_owner"; diff --git a/src/main/java/com/gmail/nossr50/util/compat/layers/persistentdata/SpigotPersistentDataLayer.java b/src/main/java/com/gmail/nossr50/util/compat/layers/persistentdata/SpigotPersistentDataLayer_1_14.java similarity index 98% rename from src/main/java/com/gmail/nossr50/util/compat/layers/persistentdata/SpigotPersistentDataLayer.java rename to src/main/java/com/gmail/nossr50/util/compat/layers/persistentdata/SpigotPersistentDataLayer_1_14.java index 4297b3f70..f7e8401df 100644 --- a/src/main/java/com/gmail/nossr50/util/compat/layers/persistentdata/SpigotPersistentDataLayer.java +++ b/src/main/java/com/gmail/nossr50/util/compat/layers/persistentdata/SpigotPersistentDataLayer_1_14.java @@ -14,7 +14,7 @@ import org.jetbrains.annotations.Nullable; import java.util.UUID; -public class SpigotPersistentDataLayer extends AbstractPersistentDataLayer { +public class SpigotPersistentDataLayer_1_14 extends AbstractPersistentDataLayer { /* * Don't modify these keys diff --git a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java index 994e8dfe7..16bbd0c4f 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/CombatUtils.java @@ -414,6 +414,10 @@ public final class CombatUtils { if (target.getType() != EntityType.CREEPER && !Misc.isNPCEntityExcludingVillagers(player) && PrimarySkillType.TAMING.getPermissions(player)) { McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player); + + if(mcMMOPlayer == null) + return; + TamingManager tamingManager = mcMMOPlayer.getTamingManager(); tamingManager.attackTarget(target); }