diff --git a/src/main/java/net/nuggetmc/tplus/bot/Bot.java b/src/main/java/net/nuggetmc/tplus/bot/Bot.java index 11fa1c5..dafd74c 100644 --- a/src/main/java/net/nuggetmc/tplus/bot/Bot.java +++ b/src/main/java/net/nuggetmc/tplus/bot/Bot.java @@ -498,7 +498,8 @@ public class Bot extends EntityPlayer { private void dieCheck() { if (removeOnDeath) { - scheduler.runTask(plugin, () -> plugin.getManager().remove(this)); // maybe making this later will fix the concurrentmodificationexception? + //scheduler.runTask(plugin, () -> plugin.getManager().remove(this)); // maybe making this later will fix the concurrentmodificationexception? + plugin.getManager().remove(this); //I replaced HashSet with ConcurrentHashMap.newKeySet which creates a "ConcurrentHashSet" scheduler.runTaskLater(plugin, this::setDead, 30); this.removeTab(); diff --git a/src/main/java/net/nuggetmc/tplus/bot/BotManager.java b/src/main/java/net/nuggetmc/tplus/bot/BotManager.java index a3c74b3..2f152d1 100644 --- a/src/main/java/net/nuggetmc/tplus/bot/BotManager.java +++ b/src/main/java/net/nuggetmc/tplus/bot/BotManager.java @@ -18,6 +18,7 @@ import org.bukkit.util.Vector; import java.text.NumberFormat; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; public class BotManager implements Listener { @@ -30,7 +31,7 @@ public class BotManager implements Listener { public BotManager() { this.agent = new LegacyAgent(this); - this.bots = new HashSet<>(); + this.bots = ConcurrentHashMap.newKeySet(); //should fix concurrentmodificationexception this.numberFormat = NumberFormat.getInstance(Locale.US); }