mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-09 11:44:19 +01:00
cc34358a3e
By: DerFrZocker <derrieple@gmail.com>
56 lines
2.5 KiB
Diff
56 lines
2.5 KiB
Diff
--- a/net/minecraft/server/commands/CommandTime.java
|
|
+++ b/net/minecraft/server/commands/CommandTime.java
|
|
@@ -9,6 +9,11 @@
|
|
import net.minecraft.network.chat.ChatMessage;
|
|
import net.minecraft.server.level.WorldServer;
|
|
|
|
+// CraftBukkit start
|
|
+import org.bukkit.Bukkit;
|
|
+import org.bukkit.event.world.TimeSkipEvent;
|
|
+// CraftBukkit end
|
|
+
|
|
public class CommandTime {
|
|
|
|
public CommandTime() {}
|
|
@@ -47,12 +52,18 @@
|
|
}
|
|
|
|
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
|
|
|
|
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
|
|
}
|
|
|
|
commandlistenerwrapper.sendSuccess(new ChatMessage("commands.time.set", new Object[]{i}), true);
|
|
@@ -60,12 +71,18 @@
|
|
}
|
|
|
|
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
|
|
|
|
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
|
|
}
|
|
|
|
int j = getDayTime(commandlistenerwrapper.getLevel());
|