mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-22 21:26:46 +01:00
Do not allow additions of timer tasks while iterating
Follow up on:
e4d980b135
Should help debug #4019 (and let us know when this actually occurs)
This commit is contained in:
parent
4246f59d44
commit
bb7989449e
@ -22,9 +22,11 @@ import java.util.Map.Entry;
|
|||||||
|
|
||||||
public class BleedTimerTask extends BukkitRunnable {
|
public class BleedTimerTask extends BukkitRunnable {
|
||||||
private static Map<LivingEntity, BleedContainer> bleedList = new HashMap<LivingEntity, BleedContainer>();
|
private static Map<LivingEntity, BleedContainer> bleedList = new HashMap<LivingEntity, BleedContainer>();
|
||||||
|
private static boolean isIterating = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
isIterating = true;
|
||||||
Iterator<Entry<LivingEntity, BleedContainer>> bleedIterator = bleedList.entrySet().iterator();
|
Iterator<Entry<LivingEntity, BleedContainer>> bleedIterator = bleedList.entrySet().iterator();
|
||||||
|
|
||||||
while (bleedIterator.hasNext()) {
|
while (bleedIterator.hasNext()) {
|
||||||
@ -136,6 +138,7 @@ public class BleedTimerTask extends BukkitRunnable {
|
|||||||
|
|
||||||
// Bukkit.broadcastMessage(debugMessage);
|
// Bukkit.broadcastMessage(debugMessage);
|
||||||
}
|
}
|
||||||
|
isIterating = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BleedContainer copyContainer(BleedContainer container)
|
public static BleedContainer copyContainer(BleedContainer container)
|
||||||
@ -176,6 +179,8 @@ public class BleedTimerTask extends BukkitRunnable {
|
|||||||
throw new IllegalStateException("Cannot add bleed task async!");
|
throw new IllegalStateException("Cannot add bleed task async!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (isIterating) throw new IllegalStateException("Cannot add task while iterating timers!");
|
||||||
|
|
||||||
if(toolTier < 4)
|
if(toolTier < 4)
|
||||||
ticks = Math.max(1, (ticks / 3));
|
ticks = Math.max(1, (ticks / 3));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user