Merge pull request #26 from Badbird-5907/concurrency
fix ConcurrentModificationException
This commit is contained in:
@@ -498,7 +498,8 @@ public class Bot extends EntityPlayer {
|
|||||||
|
|
||||||
private void dieCheck() {
|
private void dieCheck() {
|
||||||
if (removeOnDeath) {
|
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); //this should fix the concurrentmodificationexception mentioned above, I used the ConcurrentHashMap.newKeySet to make a "ConcurrentHashSet"
|
||||||
scheduler.runTaskLater(plugin, this::setDead, 30);
|
scheduler.runTaskLater(plugin, this::setDead, 30);
|
||||||
|
|
||||||
this.removeTab();
|
this.removeTab();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ import org.bukkit.util.Vector;
|
|||||||
|
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class BotManager implements Listener {
|
public class BotManager implements Listener {
|
||||||
@@ -30,7 +31,7 @@ public class BotManager implements Listener {
|
|||||||
|
|
||||||
public BotManager() {
|
public BotManager() {
|
||||||
this.agent = new LegacyAgent(this);
|
this.agent = new LegacyAgent(this);
|
||||||
this.bots = new HashSet<>();
|
this.bots = ConcurrentHashMap.newKeySet();
|
||||||
this.numberFormat = NumberFormat.getInstance(Locale.US);
|
this.numberFormat = NumberFormat.getInstance(Locale.US);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user