mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 04:35:03 +00:00
Fixed timers on the server-side.
This commit is contained in:
1 parent
d1c4adf371
commit
a29058d696
3 files changed
+5
-29
No files matched your search
@@ -63,11 +63,12 @@ public class ScriptPlayerEventHandler {
|
||||
if(event.side == Side.SERVER && event.phase == TickEvent.Phase.START) {
|
||||
EntityPlayer player = event.player;
|
||||
PlayerData data = PlayerData.get(player);
|
||||
//if(player.ticksExisted % 10 == 0) {
|
||||
EventHooks.onPlayerTick(data.scriptData);
|
||||
//}
|
||||
|
||||
data.timers.update();
|
||||
if(PlayerDataController.instance != null) {
|
||||
PlayerDataController.instance.getPlayerData(player).scriptData = data.scriptData;
|
||||
PlayerDataController.instance.getPlayerData(player).timers.update();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -25,29 +25,16 @@ public class DataTimers implements ITimers {
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
private void saveNbt() {
|
||||
if(parent instanceof PlayerData) {
|
||||
PlayerData playerData = (PlayerData) parent;
|
||||
playerData.saveNBTData(null);
|
||||
}
|
||||
else if(parent instanceof PlayerData) {
|
||||
PlayerData playerData = (PlayerData) parent;
|
||||
playerData.saveNBTData(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void start(int id, int ticks, boolean repeat) {
|
||||
if(this.timers.containsKey(Integer.valueOf(id))) {
|
||||
throw new CustomNPCsException("There is already a timer with id: " + id, new Object[0]);
|
||||
} else {
|
||||
this.timers.put(Integer.valueOf(id), new DataTimers.Timer(id, ticks, repeat));
|
||||
saveNbt();
|
||||
}
|
||||
}
|
||||
|
||||
public void forceStart(int id, int ticks, boolean repeat) {
|
||||
this.timers.put(Integer.valueOf(id), new DataTimers.Timer(id, ticks, repeat));
|
||||
saveNbt();
|
||||
}
|
||||
|
||||
public boolean has(int id) {
|
||||
@@ -56,7 +43,6 @@ public class DataTimers implements ITimers {
|
||||
|
||||
public boolean stop(int id) {
|
||||
boolean remove = this.timers.remove(Integer.valueOf(id)) != null;
|
||||
saveNbt();
|
||||
return remove;
|
||||
}
|
||||
|
||||
@@ -66,7 +52,6 @@ public class DataTimers implements ITimers {
|
||||
throw new CustomNPCsException("There is no timer with id: " + id, new Object[0]);
|
||||
} else {
|
||||
timer.ticks = 0;
|
||||
saveNbt();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,12 +93,10 @@ public class DataTimers implements ITimers {
|
||||
DataTimers.Timer timer = (DataTimers.Timer)var1.next();
|
||||
timer.update();
|
||||
}
|
||||
saveNbt();
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
this.timers = new HashMap();
|
||||
saveNbt();
|
||||
}
|
||||
|
||||
class Timer {
|
||||
|
||||
@@ -354,15 +354,7 @@ public class ScriptPlayer<T extends EntityPlayerMP> extends ScriptLivingBase<T>
|
||||
return new ScriptPixelmonPlayerData(player);
|
||||
}
|
||||
|
||||
private PlayerData getData() {
|
||||
if (this.data == null) {
|
||||
this.data = PlayerData.get(player);
|
||||
}
|
||||
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public ITimers getTimers() {
|
||||
return this.getData().timers;
|
||||
return PlayerDataController.instance.getPlayerData(player).timers;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user