aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower-stripped/net/minecraft/server/commands/TimeCommand.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower-stripped/net/minecraft/server/commands/TimeCommand.java.patch')
-rw-r--r--patch-remap/mache-spigotflower-stripped/net/minecraft/server/commands/TimeCommand.java.patch59
1 files changed, 59 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower-stripped/net/minecraft/server/commands/TimeCommand.java.patch b/patch-remap/mache-spigotflower-stripped/net/minecraft/server/commands/TimeCommand.java.patch
new file mode 100644
index 0000000000..ad1b09041f
--- /dev/null
+++ b/patch-remap/mache-spigotflower-stripped/net/minecraft/server/commands/TimeCommand.java.patch
@@ -0,0 +1,59 @@
+--- a/net/minecraft/server/commands/TimeCommand.java
++++ b/net/minecraft/server/commands/TimeCommand.java
+@@ -9,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 {
+
+@@ -49,13 +52,19 @@
+ return i;
+ }
+
+- public static int setTime(CommandSourceStack commandsourcestack, int i) {
+- Iterator iterator = commandsourcestack.getServer().getAllLevels().iterator();
++ public static int setTime(CommandSourceStack source, int 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 serverlevel = (ServerLevel) iterator.next();
+
+- serverlevel.setDayTime((long) i);
++ // 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
+ }
+
+ commandsourcestack.sendSuccess(() -> {
+@@ -64,13 +73,19 @@
+ return getDayTime(commandsourcestack.getLevel());
+ }
+
+- public static int addTime(CommandSourceStack commandsourcestack, int i) {
+- Iterator iterator = commandsourcestack.getServer().getAllLevels().iterator();
++ public static int addTime(CommandSourceStack source, int 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 serverlevel = (ServerLevel) iterator.next();
+
+- serverlevel.setDayTime(serverlevel.getDayTime() + (long) i);
++ // 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 j = getDayTime(commandsourcestack.getLevel());