mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
Upstream has released updates that appear to apply and compile correctly Paper Changes:26c37d99d5create random seeds for features using SecureRandom589bf2f1bfUpgrade gson to 2.8.8 (Closes #6370)0a6103597bGet entity default attributes (#6449)40057019e0Correctly inflate villager activation bounding box (#6798)e5f9241d15Left handed API (#6775)40ee63496cAdd advancement display API (#6175)9d570042edAdd ItemFactory#getMonsterEgg API (#6772)55ca459515rename method to getSpawnEggbb397ba74cAdd critical damage API (#6275)f47aeafe00Add Horse Animation API (#5599)7a0886180fAT & Mapping fixes (#6809)5553432644docs: Update gradle instructions for Java 16 (#6811) [ci skip]a1f49e4c60Fix command suggestion leak (#6592)9472d38f3cFix method name for Critical damage (#6813)
79 lines
4.2 KiB
Diff
79 lines
4.2 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: William Blake Galbreath <Blake.Galbreath@GMail.com>
|
|
Date: Mon, 30 Nov 2020 03:12:04 -0600
|
|
Subject: [PATCH] Add demo command
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
|
index 47ee3e70021ce17beea4ee6ac967c3180045b804..376768b272f70d1eb45d483c51dec22d91c9d325 100644
|
|
--- a/src/main/java/net/minecraft/commands/Commands.java
|
|
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
|
@@ -198,6 +198,7 @@ public class Commands {
|
|
SetPlayerIdleTimeoutCommand.register(this.dispatcher);
|
|
StopCommand.register(this.dispatcher);
|
|
WhitelistCommand.register(this.dispatcher);
|
|
+ net.pl3x.purpur.command.DemoCommand.register(this.dispatcher); // Purpur
|
|
net.pl3x.purpur.command.PingCommand.register(this.dispatcher); // Purpur
|
|
}
|
|
|
|
diff --git a/src/main/java/net/pl3x/purpur/PurpurConfig.java b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
index 10a3bcd31f6cd2ec27c79c622fecc4a24fda9f17..196f57d3c7f1b9e57122c42c73de7157da477246 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
@@ -162,6 +162,7 @@ public class PurpurConfig {
|
|
public static String afkBroadcastBack = "<yellow><italic>%s is no longer AFK";
|
|
public static String afkTabListPrefix = "[AFK] ";
|
|
public static String afkTabListSuffix = "";
|
|
+ public static String demoCommandOutput = "<green>%s has been shown the demo screen";
|
|
public static String pingCommandOutput = "<green>%s's ping is %sms";
|
|
private static void messages() {
|
|
cannotRideMob = getString("settings.messages.cannot-ride-mob", cannotRideMob);
|
|
@@ -169,6 +170,7 @@ public class PurpurConfig {
|
|
afkBroadcastBack = getString("settings.messages.afk-broadcast-back", afkBroadcastBack);
|
|
afkTabListPrefix = getString("settings.messages.afk-tab-list-prefix", afkTabListPrefix);
|
|
afkTabListSuffix = getString("settings.messages.afk-tab-list-suffix", afkTabListSuffix);
|
|
+ demoCommandOutput = getString("settings.messages.demo-command-output", demoCommandOutput);
|
|
pingCommandOutput = getString("settings.messages.ping-command-output", pingCommandOutput);
|
|
}
|
|
|
|
diff --git a/src/main/java/net/pl3x/purpur/command/DemoCommand.java b/src/main/java/net/pl3x/purpur/command/DemoCommand.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..63686e55d169a81c0c225f8dfb47973075c1e491
|
|
--- /dev/null
|
|
+++ b/src/main/java/net/pl3x/purpur/command/DemoCommand.java
|
|
@@ -0,0 +1,34 @@
|
|
+package net.pl3x.purpur.command;
|
|
+
|
|
+import com.mojang.brigadier.CommandDispatcher;
|
|
+import net.minecraft.commands.CommandSourceStack;
|
|
+import net.minecraft.commands.Commands;
|
|
+import net.minecraft.commands.arguments.EntityArgument;
|
|
+import net.minecraft.network.protocol.game.ClientboundGameEventPacket;
|
|
+import net.minecraft.server.level.ServerPlayer;
|
|
+import net.pl3x.purpur.PurpurConfig;
|
|
+
|
|
+import java.util.Collection;
|
|
+import java.util.Collections;
|
|
+
|
|
+public class DemoCommand {
|
|
+ public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
|
|
+ dispatcher.register(Commands.literal("demo")
|
|
+ .requires((listener) -> listener.hasPermission(2))
|
|
+ .executes((context) -> execute(context.getSource(), Collections.singleton(context.getSource().getPlayerOrException())))
|
|
+ .then(Commands.argument("targets", EntityArgument.players())
|
|
+ .executes((context) -> execute(context.getSource(), EntityArgument.getPlayers(context, "targets")))
|
|
+ )
|
|
+ ).setPermission("bukkit.command.demo");
|
|
+ }
|
|
+
|
|
+ private static int execute(CommandSourceStack sender, Collection<ServerPlayer> targets) {
|
|
+ for (ServerPlayer player : targets) {
|
|
+ ClientboundGameEventPacket packet = new ClientboundGameEventPacket(ClientboundGameEventPacket.DEMO_EVENT, 0);
|
|
+ player.connection.send(packet);
|
|
+ String output = String.format(PurpurConfig.demoCommandOutput, player.getGameProfile().getName());
|
|
+ sender.sendSuccess(output, false);
|
|
+ }
|
|
+ return targets.size();
|
|
+ }
|
|
+}
|