|
@@ -2,6 +2,7 @@ package me.km.overrides;
|
|
|
|
|
|
import com.mojang.authlib.GameProfile;
|
|
|
import java.util.HashMap;
|
|
|
+import me.hammerle.snuviscript.code.ISnuviScheduler;
|
|
|
import me.km.Server;
|
|
|
import net.minecraft.entity.player.ServerPlayerEntity;
|
|
|
import net.minecraft.network.play.server.SPlayerListItemPacket;
|
|
@@ -19,6 +20,8 @@ public class ModEntityPlayerMP extends ServerPlayerEntity
|
|
|
private final HashMap<String, Object> data;
|
|
|
private StringTextComponent tabDisplayName = null;
|
|
|
|
|
|
+ private boolean isIterating = false;
|
|
|
+
|
|
|
public ModEntityPlayerMP(MinecraftServer ms, ServerWorld w, GameProfile gp, PlayerInteractionManager pim)
|
|
|
{
|
|
|
super(ms, w, gp, pim);
|
|
@@ -74,6 +77,7 @@ public class ModEntityPlayerMP extends ServerPlayerEntity
|
|
|
|
|
|
private void tickData()
|
|
|
{
|
|
|
+ isIterating = true;
|
|
|
timedData.entrySet().removeIf(entry ->
|
|
|
{
|
|
|
int time = entry.getValue() - 1;
|
|
@@ -88,6 +92,7 @@ public class ModEntityPlayerMP extends ServerPlayerEntity
|
|
|
entry.setValue(time);
|
|
|
return false;
|
|
|
});
|
|
|
+ isIterating = false;
|
|
|
}
|
|
|
|
|
|
public void setVar(String varname, Object value)
|
|
@@ -100,9 +105,16 @@ public class ModEntityPlayerMP extends ServerPlayerEntity
|
|
|
return data.get(varname);
|
|
|
}
|
|
|
|
|
|
- public void setTimer(String varname, int time)
|
|
|
+ public void setTimer(String varname, int time, ISnuviScheduler scheduler)
|
|
|
{
|
|
|
- timedData.put(varname, time);
|
|
|
+ if(isIterating)
|
|
|
+ {
|
|
|
+ scheduler.scheduleTask(() -> timedData.put(varname, time));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ timedData.put(varname, time);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public int getTimer(String varname)
|
|
@@ -110,9 +122,16 @@ public class ModEntityPlayerMP extends ServerPlayerEntity
|
|
|
return timedData.getOrDefault(varname, -1);
|
|
|
}
|
|
|
|
|
|
- public void clearData()
|
|
|
+ public void clearData(ISnuviScheduler scheduler)
|
|
|
{
|
|
|
- timedData.clear();
|
|
|
+ if(isIterating)
|
|
|
+ {
|
|
|
+ scheduler.scheduleTask(() -> timedData.clear());
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ timedData.clear();
|
|
|
+ }
|
|
|
data.clear();
|
|
|
}
|
|
|
|