aboutsummaryrefslogtreecommitdiffhomepage
path: root/patch-remap/mache-spigotflower/net/minecraft/server/commands/TimeCommand.java.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patch-remap/mache-spigotflower/net/minecraft/server/commands/TimeCommand.java.patch')
-rw-r--r--patch-remap/mache-spigotflower/net/minecraft/server/commands/TimeCommand.java.patch127
1 files changed, 127 insertions, 0 deletions
diff --git a/patch-remap/mache-spigotflower/net/minecraft/server/commands/TimeCommand.java.patch b/patch-remap/mache-spigotflower/net/minecraft/server/commands/TimeCommand.java.patch
new file mode 100644
index 0000000000..b1383ee771
--- /dev/null
+++ b/patch-remap/mache-spigotflower/net/minecraft/server/commands/TimeCommand.java.patch
@@ -0,0 +1,127 @@
+--- a/net/minecraft/server/commands/TimeCommand.java
++++ b/net/minecraft/server/commands/TimeCommand.java
+@@ -5,77 +5,92 @@
+ import com.mojang.brigadier.builder.LiteralArgumentBuilder;
+ import java.util.Iterator;
+ import net.minecraft.commands.CommandSourceStack;
+-import net.minecraft.commands.Commands;
+ 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 {
+
+ public TimeCommand() {}
+
+- public static void register(CommandDispatcher<CommandSourceStack> commanddispatcher) {
+- commanddispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) Commands.literal("time").requires((commandsourcestack) -> {
+- return commandsourcestack.hasPermission(2);
+- })).then(((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) Commands.literal("set").then(Commands.literal("day").executes((commandcontext) -> {
++ public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
++ dispatcher.register((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("time").requires((commandlistenerwrapper) -> {
++ return commandlistenerwrapper.hasPermission(2);
++ })).then(((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) ((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("set").then(net.minecraft.commands.Commands.literal("day").executes((commandcontext) -> {
+ return setTime((CommandSourceStack) commandcontext.getSource(), 1000);
+- }))).then(Commands.literal("noon").executes((commandcontext) -> {
++ }))).then(net.minecraft.commands.Commands.literal("noon").executes((commandcontext) -> {
+ return setTime((CommandSourceStack) commandcontext.getSource(), 6000);
+- }))).then(Commands.literal("night").executes((commandcontext) -> {
++ }))).then(net.minecraft.commands.Commands.literal("night").executes((commandcontext) -> {
+ return setTime((CommandSourceStack) commandcontext.getSource(), 13000);
+- }))).then(Commands.literal("midnight").executes((commandcontext) -> {
++ }))).then(net.minecraft.commands.Commands.literal("midnight").executes((commandcontext) -> {
+ return setTime((CommandSourceStack) commandcontext.getSource(), 18000);
+- }))).then(Commands.argument("time", TimeArgument.time()).executes((commandcontext) -> {
++ }))).then(net.minecraft.commands.Commands.argument("time", TimeArgument.time()).executes((commandcontext) -> {
+ return setTime((CommandSourceStack) commandcontext.getSource(), IntegerArgumentType.getInteger(commandcontext, "time"));
+- })))).then(Commands.literal("add").then(Commands.argument("time", TimeArgument.time()).executes((commandcontext) -> {
++ })))).then(net.minecraft.commands.Commands.literal("add").then(net.minecraft.commands.Commands.argument("time", TimeArgument.time()).executes((commandcontext) -> {
+ return addTime((CommandSourceStack) commandcontext.getSource(), IntegerArgumentType.getInteger(commandcontext, "time"));
+- })))).then(((LiteralArgumentBuilder) ((LiteralArgumentBuilder) Commands.literal("query").then(Commands.literal("daytime").executes((commandcontext) -> {
++ })))).then(((LiteralArgumentBuilder) ((LiteralArgumentBuilder) net.minecraft.commands.Commands.literal("query").then(net.minecraft.commands.Commands.literal("daytime").executes((commandcontext) -> {
+ return queryTime((CommandSourceStack) commandcontext.getSource(), getDayTime(((CommandSourceStack) commandcontext.getSource()).getLevel()));
+- }))).then(Commands.literal("gametime").executes((commandcontext) -> {
++ }))).then(net.minecraft.commands.Commands.literal("gametime").executes((commandcontext) -> {
+ return queryTime((CommandSourceStack) commandcontext.getSource(), (int) (((CommandSourceStack) commandcontext.getSource()).getLevel().getGameTime() % 2147483647L));
+- }))).then(Commands.literal("day").executes((commandcontext) -> {
++ }))).then(net.minecraft.commands.Commands.literal("day").executes((commandcontext) -> {
+ return queryTime((CommandSourceStack) commandcontext.getSource(), (int) (((CommandSourceStack) commandcontext.getSource()).getLevel().getDayTime() / 24000L % 2147483647L));
+ }))));
+ }
+
+- private static int getDayTime(ServerLevel serverlevel) {
+- return (int) (serverlevel.getDayTime() % 24000L);
++ private static int getDayTime(ServerLevel level) {
++ return (int) (level.getDayTime() % 24000L);
+ }
+
+- private static int queryTime(CommandSourceStack commandsourcestack, int i) {
+- commandsourcestack.sendSuccess(() -> {
+- return Component.translatable("commands.time.query", i);
++ private static int queryTime(CommandSourceStack source, int time) {
++ source.sendSuccess(() -> {
++ return Component.translatable("commands.time.query", time);
+ }, false);
+- return i;
++ return time;
+ }
+
+- 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 worldserver = (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(() -> {
+- return Component.translatable("commands.time.set", i);
++ source.sendSuccess(() -> {
++ return Component.translatable("commands.time.set", time);
+ }, true);
+- return getDayTime(commandsourcestack.getLevel());
++ return getDayTime(source.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 worldserver = (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());
++ int j = getDayTime(source.getLevel());
+
+- commandsourcestack.sendSuccess(() -> {
++ source.sendSuccess(() -> {
+ return Component.translatable("commands.time.set", j);
+ }, true);
+ return j;