Fixed COTW summon bug

This commit is contained in:
nossr50 2024-11-16 16:10:05 -08:00
parent 19bf96ab33
commit 91ab569b81
5 changed files with 11 additions and 7 deletions

View File

@ -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)

View File

@ -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 {

View File

@ -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;

View File

@ -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) {

View File

@ -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());
}
}