-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configurable unknown command message
- Loading branch information
1 parent
b5e6aa5
commit f316aff
Showing
15 changed files
with
82 additions
and
2 deletions.
There are no files selected for viewing
80 changes: 80 additions & 0 deletions
80
patches/server/0080-Configurable-unknown-command-message.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Dreeam <61569423+Dreeam-qwq@users.noreply.github.com> | ||
Date: Wed, 7 Aug 2024 18:54:01 +0800 | ||
Subject: [PATCH] Configurable unknown command message | ||
|
||
|
||
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java | ||
index 94bb40c9932b0b7dd9fb8af680b63d139ae18e3a..f5446158a83d5ccd79988ab71f2c4df220b39167 100644 | ||
--- a/src/main/java/net/minecraft/commands/Commands.java | ||
+++ b/src/main/java/net/minecraft/commands/Commands.java | ||
@@ -388,7 +388,14 @@ public class Commands { | ||
// Paper start - Add UnknownCommandEvent | ||
final net.kyori.adventure.text.TextComponent.Builder builder = net.kyori.adventure.text.Component.text(); | ||
// commandlistenerwrapper.sendFailure(ComponentUtils.fromMessage(commandsyntaxexception.getRawMessage())); | ||
+ // Leaf start - Configurable unknown command message | ||
+ if (!"default".equals(org.dreeam.leaf.config.modules.misc.UnknownCommandMessage.unknownCommandMessage)) { | ||
+ net.kyori.adventure.text.Component message = net.kyori.adventure.text.minimessage.MiniMessage.miniMessage().deserialize(org.dreeam.leaf.config.modules.misc.UnknownCommandMessage.unknownCommandMessage); | ||
+ builder.append(message); | ||
+ } else { | ||
builder.color(net.kyori.adventure.text.format.NamedTextColor.RED).append(io.papermc.paper.brigadier.PaperBrigadier.componentFromMessage(commandsyntaxexception.getRawMessage())); | ||
+ } | ||
+ // Leaf end - Configurable unknown command message | ||
// Paper end - Add UnknownCommandEvent | ||
if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) { | ||
int i = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor()); | ||
@@ -414,7 +421,7 @@ public class Commands { | ||
.append(net.kyori.adventure.text.Component.newline()) | ||
.append(io.papermc.paper.adventure.PaperAdventure.asAdventure(ichatmutablecomponent)); | ||
} | ||
- org.bukkit.event.command.UnknownCommandEvent event = new org.bukkit.event.command.UnknownCommandEvent(commandlistenerwrapper.getBukkitSender(), s, org.spigotmc.SpigotConfig.unknownCommandMessage.isEmpty() ? null : builder.build()); | ||
+ org.bukkit.event.command.UnknownCommandEvent event = new org.bukkit.event.command.UnknownCommandEvent(commandlistenerwrapper.getBukkitSender(), s, builder.build()); // Leaf - Configurable unknown command message | ||
org.bukkit.Bukkit.getServer().getPluginManager().callEvent(event); | ||
if (event.message() != null) { | ||
commandlistenerwrapper.sendFailure(io.papermc.paper.adventure.PaperAdventure.asVanilla(event.message()), false); | ||
diff --git a/src/main/java/org/dreeam/leaf/config/modules/misc/UnknownCommandMessage.java b/src/main/java/org/dreeam/leaf/config/modules/misc/UnknownCommandMessage.java | ||
new file mode 100644 | ||
index 0000000000000000000000000000000000000000..cfa68915552899ce6ec0b202e1d6cf8a1ca0a777 | ||
--- /dev/null | ||
+++ b/src/main/java/org/dreeam/leaf/config/modules/misc/UnknownCommandMessage.java | ||
@@ -0,0 +1,20 @@ | ||
+package org.dreeam.leaf.config.modules.misc; | ||
+ | ||
+import org.dreeam.leaf.config.ConfigModules; | ||
+import org.dreeam.leaf.config.EnumConfigCategory; | ||
+ | ||
+public class UnknownCommandMessage extends ConfigModules { | ||
+ | ||
+ public String getBasePath() { | ||
+ return EnumConfigCategory.MISC.getBaseKeyName() + ".message"; | ||
+ } | ||
+ | ||
+ public static String unknownCommandMessage = "<red><lang:command.unknown.command>"; | ||
+ | ||
+ @Override | ||
+ public void onLoaded() { | ||
+ unknownCommandMessage = config.getString(getBasePath() + ".unknown-command", unknownCommandMessage, """ | ||
+ Unknown command message, using MiniMessage format, set to "default" to use vanilla message. | ||
+ """); | ||
+ } | ||
+} | ||
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java | ||
index 4dbb109d0526afee99b9190fc256585121aac9b5..3de9968bc87b3dc024e423b382eb611135bf1b2c 100644 | ||
--- a/src/main/java/org/spigotmc/SpigotConfig.java | ||
+++ b/src/main/java/org/spigotmc/SpigotConfig.java | ||
@@ -191,7 +191,6 @@ public class SpigotConfig | ||
} | ||
|
||
public static String whitelistMessage; | ||
- public static String unknownCommandMessage; | ||
public static String serverFullMessage; | ||
public static String outdatedClientMessage = "Outdated client! Please use {0}"; | ||
public static String outdatedServerMessage = "Outdated server! I\'m still on {0}"; | ||
@@ -208,7 +207,6 @@ public class SpigotConfig | ||
} | ||
|
||
SpigotConfig.whitelistMessage = SpigotConfig.transform( SpigotConfig.getString( "messages.whitelist", "You are not whitelisted on this server!" ) ); | ||
- SpigotConfig.unknownCommandMessage = SpigotConfig.transform( SpigotConfig.getString( "messages.unknown-command", "Unknown command. Type \"/help\" for help." ) ); | ||
SpigotConfig.serverFullMessage = SpigotConfig.transform( SpigotConfig.getString( "messages.server-full", "The server is full!" ) ); | ||
SpigotConfig.outdatedClientMessage = SpigotConfig.transform( SpigotConfig.getString( "messages.outdated-client", SpigotConfig.outdatedClientMessage ) ); | ||
SpigotConfig.outdatedServerMessage = SpigotConfig.transform( SpigotConfig.getString( "messages.outdated-server", SpigotConfig.outdatedServerMessage ) ); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.