Paper/nms-patches/CommandTime.patch

44 lines
1.7 KiB
Diff
Raw Normal View History

2019-12-21 02:06:18 +01:00
--- a/net/minecraft/server/CommandTime.java
+++ b/net/minecraft/server/CommandTime.java
2020-06-25 02:00:00 +02:00
@@ -4,6 +4,10 @@
2019-12-21 02:06:18 +01:00
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
2020-06-25 02:00:00 +02:00
import java.util.Iterator;
2019-12-21 02:06:18 +01:00
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.event.world.TimeSkipEvent;
+// CrafBukkit end
public class CommandTime {
2020-06-25 02:00:00 +02:00
@@ -46,7 +50,13 @@
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
}
commandlistenerwrapper.sendMessage(new ChatMessage("commands.time.set", new Object[]{i}), true);
2020-06-25 02:00:00 +02:00
@@ -59,7 +69,13 @@
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
}
int j = a(commandlistenerwrapper.getWorld());