diff --git a/Changelog.txt b/Changelog.txt index ece84ec19..2e0faee34 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -1,5 +1,7 @@ Version 2.2.028 - Fix stack overflow during ChunkUnloadEvent + Fixed a bug where you had to wait to summon another COTW summon if one or more of them had died or otherwise expired before their time limit + Fixed stack overflow during ChunkUnloadEvent + (API) Added McMMOPlayerMasterAnglerEvent (thanks bobcat4848) Version 2.2.027 Added Tridents / Crossbows to salvage.vanilla.yml config (see notes) diff --git a/src/main/java/com/gmail/nossr50/listeners/ChunkListener.java b/src/main/java/com/gmail/nossr50/listeners/ChunkListener.java index 1a6a146d7..000d3ca8c 100644 --- a/src/main/java/com/gmail/nossr50/listeners/ChunkListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/ChunkListener.java @@ -8,7 +8,6 @@ import org.bukkit.event.Listener; import org.bukkit.event.world.ChunkUnloadEvent; import java.util.Arrays; -import java.util.List; public class ChunkListener implements Listener { diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index ed0094a56..f93b1d61d 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -31,7 +31,6 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.enchantments.Enchantment; import org.bukkit.entity.*; -import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.meta.SkullMeta; diff --git a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java index e802e6bd2..104231f69 100644 --- a/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/taming/TamingManager.java @@ -475,7 +475,7 @@ public class TamingManager extends SkillManager { } private int getAmountCurrentlySummoned(@NotNull CallOfTheWildType callOfTheWildType) { - return mcMMO.getTransientEntityTracker().summonCountForPlayerOfType(getPlayer().getUniqueId(), callOfTheWildType); + return mcMMO.getTransientEntityTracker().getActiveSummonsForPlayerOfType(getPlayer().getUniqueId(), callOfTheWildType); } private void addToTracker(@NotNull LivingEntity livingEntity, @NotNull CallOfTheWildType callOfTheWildType) { diff --git a/src/main/java/com/gmail/nossr50/util/TransientEntityTracker.java b/src/main/java/com/gmail/nossr50/util/TransientEntityTracker.java index ed3b1c16b..fccff2664 100644 --- a/src/main/java/com/gmail/nossr50/util/TransientEntityTracker.java +++ b/src/main/java/com/gmail/nossr50/util/TransientEntityTracker.java @@ -35,8 +35,11 @@ public class TransientEntityTracker { cleanPlayer(player, player.getUniqueId()); } - public int summonCountForPlayerOfType(@NotNull UUID playerUUID, @NotNull CallOfTheWildType callOfTheWildType) { - return getTrackedEntities(playerUUID, callOfTheWildType).size(); + public int getActiveSummonsForPlayerOfType(@NotNull UUID playerUUID, @NotNull CallOfTheWildType callOfTheWildType) { + return getTrackedEntities(playerUUID, callOfTheWildType).stream() + .filter(tte -> tte.getLivingEntity().isValid()) + .mapToInt(tte -> 1) + .sum(); } public void addSummon(@NotNull UUID playerUUID, @NotNull TrackedTamingEntity trackedTamingEntity) { @@ -110,9 +113,10 @@ public class TransientEntityTracker { } public void removeSummonFromTracker(@NotNull UUID playerUUID, @NotNull TrackedTamingEntity trackedTamingEntity) { + entityLookupCache.remove(trackedTamingEntity.getLivingEntity()); + if (playerSummonedEntityTracker.containsKey(playerUUID)) { playerSummonedEntityTracker.get(playerUUID).remove(trackedTamingEntity); - entityLookupCache.remove(trackedTamingEntity.getLivingEntity()); } }