mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-06 00:07:56 +01:00
56 lines
2.8 KiB
Diff
56 lines
2.8 KiB
Diff
--- 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 {
|
|
|
|
@@ -49,12 +53,18 @@
|
|
}
|
|
|
|
public static int setTime(CommandSourceStack source, int time) {
|
|
- Iterator iterator = source.getServer().getAllLevels().iterator();
|
|
+ Iterator iterator = io.papermc.paper.configuration.GlobalConfiguration.get().commands.timeCommandAffectsAllWorlds ? source.getServer().getAllLevels().iterator() : com.google.common.collect.Iterators.singletonIterator(source.getLevel()); // CraftBukkit - SPIGOT-6496: Only set the time for the world the command originates in // Paper - add config option for spigot's change
|
|
|
|
while (iterator.hasNext()) {
|
|
ServerLevel worldserver = (ServerLevel) iterator.next();
|
|
|
|
- worldserver.setDayTime((long) time);
|
|
+ // 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.getServer().forceTimeSynchronization();
|
|
@@ -65,12 +75,18 @@
|
|
}
|
|
|
|
public static int addTime(CommandSourceStack source, int time) {
|
|
- Iterator iterator = source.getServer().getAllLevels().iterator();
|
|
+ Iterator iterator = io.papermc.paper.configuration.GlobalConfiguration.get().commands.timeCommandAffectsAllWorlds ? source.getServer().getAllLevels().iterator() : com.google.common.collect.Iterators.singletonIterator(source.getLevel()); // CraftBukkit - SPIGOT-6496: Only set the time for the world the command originates in // Paper - add config option for spigot's change
|
|
|
|
while (iterator.hasNext()) {
|
|
ServerLevel worldserver = (ServerLevel) iterator.next();
|
|
|
|
- worldserver.setDayTime(worldserver.getDayTime() + (long) time);
|
|
+ // CraftBukkit start
|
|
+ TimeSkipEvent event = new TimeSkipEvent(worldserver.getWorld(), TimeSkipEvent.SkipReason.COMMAND, time);
|
|
+ Bukkit.getPluginManager().callEvent(event);
|
|
+ if (!event.isCancelled()) {
|
|
+ worldserver.setDayTime(worldserver.getDayTime() + event.getSkipAmount());
|
|
+ }
|
|
+ // CraftBukkit end
|
|
}
|
|
|
|
source.getServer().forceTimeSynchronization();
|