diff options
Diffstat (limited to 'patch-remap/mache-vineflower-stripped/net/minecraft/server/commands/TimeCommand.java.patch')
-rw-r--r-- | patch-remap/mache-vineflower-stripped/net/minecraft/server/commands/TimeCommand.java.patch | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/patch-remap/mache-vineflower-stripped/net/minecraft/server/commands/TimeCommand.java.patch b/patch-remap/mache-vineflower-stripped/net/minecraft/server/commands/TimeCommand.java.patch new file mode 100644 index 0000000000..2b1aacbdab --- /dev/null +++ b/patch-remap/mache-vineflower-stripped/net/minecraft/server/commands/TimeCommand.java.patch @@ -0,0 +1,55 @@ +--- a/net/minecraft/server/commands/TimeCommand.java ++++ b/net/minecraft/server/commands/TimeCommand.java +@@ -8,6 +8,10 @@ + import net.minecraft.commands.arguments.TimeArgument; + import net.minecraft.network.chat.Component; + import net.minecraft.server.level.ServerLevel; ++// CraftBukkit start ++import org.bukkit.Bukkit; ++import org.bukkit.event.world.TimeSkipEvent; ++// CraftBukkit end + + public class TimeCommand { + public static void register(CommandDispatcher<CommandSourceStack> dispatcher) { +@@ -57,8 +53,18 @@ + } + + public static int setTime(CommandSourceStack source, int time) { +- for (ServerLevel serverLevel : source.getServer().getAllLevels()) { +- serverLevel.setDayTime((long)time); ++ Iterator iterator = com.google.common.collect.Iterators.singletonIterator(source.getLevel()); // CraftBukkit - SPIGOT-6496: Only set the time for the world the command originates in ++ ++ while (iterator.hasNext()) { ++ ServerLevel worldserver = (ServerLevel) iterator.next(); ++ ++ // CraftBukkit start ++ TimeSkipEvent event = new TimeSkipEvent(worldserver.getWorld(), TimeSkipEvent.SkipReason.COMMAND, time - worldserver.getDayTime()); ++ Bukkit.getPluginManager().callEvent(event); ++ if (!event.isCancelled()) { ++ worldserver.setDayTime((long) worldserver.getDayTime() + event.getSkipAmount()); ++ } ++ // CraftBukkit end + } + + source.sendSuccess(() -> Component.translatable("commands.time.set", time), true); +@@ -66,8 +74,18 @@ + } + + public static int addTime(CommandSourceStack source, int amount) { +- for (ServerLevel serverLevel : source.getServer().getAllLevels()) { +- serverLevel.setDayTime(serverLevel.getDayTime() + (long)amount); ++ Iterator iterator = com.google.common.collect.Iterators.singletonIterator(source.getLevel()); // CraftBukkit - SPIGOT-6496: Only set the time for the world the command originates in ++ ++ while (iterator.hasNext()) { ++ ServerLevel worldserver = (ServerLevel) iterator.next(); ++ ++ // CraftBukkit start ++ TimeSkipEvent event = new TimeSkipEvent(worldserver.getWorld(), TimeSkipEvent.SkipReason.COMMAND, amount); ++ Bukkit.getPluginManager().callEvent(event); ++ if (!event.isCancelled()) { ++ worldserver.setDayTime(worldserver.getDayTime() + event.getSkipAmount()); ++ } ++ // CraftBukkit end + } + + int dayTime = getDayTime(source.getLevel()); |