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: 12dec20 Bump paerweight to 1.1.7 e33ed89 Get short commit ref using a more proper method 7d6147d Remove now unneeded patch due to paperweight 1.1.7 e72fa41 Update task dependency for includeMappings so the new task isn't skipped 0ad5526 Trim whitspace off of git hash (oops) Tuinity Changes: e878ba9 Update paper 2bd2849 Bring back fix codec spam patch
80 lines
4.4 KiB
Diff
80 lines
4.4 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Encode42 <me@encode42.dev>
|
|
Date: Fri, 30 Apr 2021 14:03:06 -0400
|
|
Subject: [PATCH] Add credits command
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
|
index 9cbaaf4cd138e6c1d2d51afcef24a81a3f2973c5..f164106a957c24bdb71bde85d82948a64613fd91 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.CreditsCommand.register(this.dispatcher); // Purpur
|
|
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 4eccccee09c8bcb9daa264b10116f7253a737f3c..49c1be11f0e1d00a9bdaaf4cca7348d0dddbfc05 100644
|
|
--- a/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
+++ b/src/main/java/net/pl3x/purpur/PurpurConfig.java
|
|
@@ -133,6 +133,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 creditsCommandOutput = "<green>%s has been shown the end credits";
|
|
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() {
|
|
@@ -141,6 +142,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);
|
|
+ creditsCommandOutput = getString("settings.messages.credits-command-output", creditsCommandOutput);
|
|
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/CreditsCommand.java b/src/main/java/net/pl3x/purpur/command/CreditsCommand.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..282be3e0e0cb3137829a88bd40fa18772dc344c2
|
|
--- /dev/null
|
|
+++ b/src/main/java/net/pl3x/purpur/command/CreditsCommand.java
|
|
@@ -0,0 +1,35 @@
|
|
+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 CreditsCommand {
|
|
+ public static void register(CommandDispatcher<CommandSourceStack> dispatcher) {
|
|
+ dispatcher.register(Commands.literal("credits")
|
|
+ .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.credits");
|
|
+ }
|
|
+
|
|
+ private static int execute(CommandSourceStack sender, Collection<ServerPlayer> targets) {
|
|
+ for (ServerPlayer player : targets) {
|
|
+ ClientboundGameEventPacket packet = new ClientboundGameEventPacket(ClientboundGameEventPacket.WIN_GAME, 1F);
|
|
+ player.wonGame = true;
|
|
+ player.connection.send(packet);
|
|
+ String output = String.format(PurpurConfig.creditsCommandOutput, player.getGameProfile().getName());
|
|
+ sender.sendSuccess(output, false);
|
|
+ }
|
|
+ return targets.size();
|
|
+ }
|
|
+}
|