2021-03-15 23:00:00 +01:00
--- a/net/minecraft/server/commands/CommandTime.java
+++ b/net/minecraft/server/commands/CommandTime.java
2021-11-21 23:00:00 +01:00
@@ -9,6 +9,11 @@
2022-06-07 18:00:00 +02:00
import net.minecraft.network.chat.IChatBaseComponent;
2021-03-15 23:00:00 +01:00
import net.minecraft.server.level.WorldServer;
2021-03-08 22:47:33 +01:00
2019-12-21 02:06:18 +01:00
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.event.world.TimeSkipEvent;
2021-03-08 22:47:33 +01:00
+// CraftBukkit end
+
2019-12-21 02:06:18 +01:00
public class CommandTime {
2020-06-25 02:00:00 +02:00
2021-06-11 07:00:00 +02:00
public CommandTime() {}
2023-06-07 17:30:00 +02:00
@@ -49,12 +54,18 @@
2022-01-02 22:29:31 +01:00
}
public static int setTime(CommandListenerWrapper commandlistenerwrapper, int i) {
- Iterator iterator = commandlistenerwrapper.getServer().getAllLevels().iterator();
+ Iterator iterator = com.google.common.collect.Iterators.singletonIterator(commandlistenerwrapper.getLevel()); // CraftBukkit - SPIGOT-6496: Only set the time for the world the command originates in
2019-12-21 02:06:18 +01:00
while (iterator.hasNext()) {
WorldServer worldserver = (WorldServer) iterator.next();
- worldserver.setDayTime((long) i);
+ // CraftBukkit start
+ TimeSkipEvent event = new TimeSkipEvent(worldserver.getWorld(), TimeSkipEvent.SkipReason.COMMAND, i - worldserver.getDayTime());
+ Bukkit.getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ worldserver.setDayTime((long) worldserver.getDayTime() + event.getSkipAmount());
+ }
+ // CraftBukkit end
}
2023-06-07 17:30:00 +02:00
commandlistenerwrapper.sendSuccess(() -> {
@@ -64,12 +75,18 @@
2022-01-02 22:29:31 +01:00
}
public static int addTime(CommandListenerWrapper commandlistenerwrapper, int i) {
- Iterator iterator = commandlistenerwrapper.getServer().getAllLevels().iterator();
+ Iterator iterator = com.google.common.collect.Iterators.singletonIterator(commandlistenerwrapper.getLevel()); // CraftBukkit - SPIGOT-6496: Only set the time for the world the command originates in
2019-12-21 02:06:18 +01:00
while (iterator.hasNext()) {
WorldServer worldserver = (WorldServer) iterator.next();
- worldserver.setDayTime(worldserver.getDayTime() + (long) i);
+ // CraftBukkit start
+ TimeSkipEvent event = new TimeSkipEvent(worldserver.getWorld(), TimeSkipEvent.SkipReason.COMMAND, i);
+ Bukkit.getPluginManager().callEvent(event);
+ if (!event.isCancelled()) {
+ worldserver.setDayTime(worldserver.getDayTime() + event.getSkipAmount());
+ }
+ // CraftBukkit end
}
2021-11-21 23:00:00 +01:00
int j = getDayTime(commandlistenerwrapper.getLevel());