From 657913faeb2843d54002a3a4b8237d205ad8cad5 Mon Sep 17 00:00:00 2001 From: Dinnerbone Date: Tue, 1 Feb 2011 14:53:39 +0000 Subject: [PATCH] Dinner time! --- .../org/bukkit/craftbukkit/CraftServer.java | 6 ++++-- .../org/bukkit/craftbukkit/CraftWorld.java | 20 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java index bf7dba69c3..004a6a6e6c 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java @@ -142,12 +142,14 @@ public final class CraftServer implements Server { return new World[]{console.e.getWorld()}; } + @Deprecated public long getTime() { - return console.e.e; + return getWorlds()[0].getFullTime(); } + @Deprecated public void setTime(long time) { - console.e.e = time; + getWorlds()[0].setFullTime(time); } public ServerConfigurationManager getHandle() { diff --git a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java index a0b324c8aa..9414cc0400 100644 --- a/src/main/java/org/bukkit/craftbukkit/CraftWorld.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftWorld.java @@ -243,6 +243,26 @@ public class CraftWorld implements World { return "CraftWorld"; } + public long getTime() { + long time = getFullTime() % 24000; + if (time < 0) time += 24000; + return time; + } + + public void setTime(long time) { + long margin = (time - getFullTime()) % 24000; + if (margin < 0) margin += 24000; + setFullTime(getFullTime() + margin); + } + + public long getFullTime() { + return world.e; + } + + public void setFullTime(long time) { + world.e = time; + } + private final class ChunkCoordinate { public final int x; public final int z;