From ef8a5afd837b6eaddf2971fcc35817b94b9de2be Mon Sep 17 00:00:00 2001 From: Badbird-5907 Date: Thu, 26 Aug 2021 19:09:03 -0400 Subject: [PATCH 1/2] fix lava damage --- src/main/java/net/nuggetmc/tplus/bot/Bot.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/net/nuggetmc/tplus/bot/Bot.java b/src/main/java/net/nuggetmc/tplus/bot/Bot.java index 4c57d3b..11fa1c5 100644 --- a/src/main/java/net/nuggetmc/tplus/bot/Bot.java +++ b/src/main/java/net/nuggetmc/tplus/bot/Bot.java @@ -275,7 +275,7 @@ public class Bot extends EntityPlayer { if (noDamageTicks == 0) { if (lava) { damageEntity(DamageSource.LAVA, 4); - noDamageTicks = 12; + noDamageTicks = 20;//this used to be 12 ticks but that would cause the bot to take damage too quickly } else if (fireTicks > 1) { damageEntity(DamageSource.FIRE, 1); noDamageTicks = 20; From e8aaff4f064817136987c5220a8569a7a817c779 Mon Sep 17 00:00:00 2001 From: Badbird-5907 Date: Thu, 26 Aug 2021 19:13:52 -0400 Subject: [PATCH 2/2] fix mentioned ConcurrentModificationException --- src/main/java/net/nuggetmc/tplus/bot/Bot.java | 3 ++- src/main/java/net/nuggetmc/tplus/bot/BotManager.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) 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); }