From 51e0c1409b2f5515a3af383c508f7d8ac9009abc Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Fri, 17 Jun 2011 02:29:16 -0400 Subject: [PATCH] Added per player time support. Thanks eisental, Shamebot and needspeed10! By: EvilSeph --- .../org/bukkit/craftbukkit/CraftWorld.java | 2 +- .../craftbukkit/entity/CraftPlayer.java | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index 486d939e8a..3053937d31 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -424,7 +424,7 @@ public class CraftWorld implements World { // Forces the client to update to the new time immediately for (Player p: getPlayers()) { CraftPlayer cp = (CraftPlayer) p; - cp.getHandle().netServerHandler.sendPacket(new Packet4UpdateTime(time)); + cp.getHandle().netServerHandler.sendPacket(new Packet4UpdateTime(cp.getHandle().getPlayerTime())); } } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java index 20b539bd39..56f9f6ce27 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java @@ -297,4 +297,25 @@ public class CraftPlayer extends CraftHumanEntity implements Player { getHandle().netServerHandler.sendPacket(new Packet200Statistic(id, amount)); } + + public void setPlayerTime(long time, boolean relative) { + getHandle().timeOffset = time; + getHandle().relativeTime = relative; + } + + public long getPlayerTimeOffset() { + return getHandle().timeOffset; + } + + public long getPlayerTime() { + return getHandle().getPlayerTime(); + } + + public boolean isPlayerTimeRelative() { + return getHandle().relativeTime; + } + + public void resetPlayerTime() { + setPlayerTime(0, true); + } }