Implement command namespace restriction.
This commit is contained in:
parent
15b04de3c4
commit
9263c57326
4 changed files with 20 additions and 0 deletions
|
@ -82,4 +82,7 @@ public enum LanguageString {
|
|||
|
||||
// Event for chat messages
|
||||
CHATMESSAGE_SERVER,
|
||||
|
||||
// Event for chat commands
|
||||
CHATCOMMAND_ERROR_NAMESPACE
|
||||
}
|
||||
|
|
|
@ -51,4 +51,17 @@ public final class ChatListener implements Listener {
|
|||
).append(MiniMessage.miniMessage().deserialize(MiniMessage.miniMessage().serialize(event.originalMessage()).replace("\\<", "<")))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles chat commands.
|
||||
*
|
||||
* @since v1-release0
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
|
||||
public void handleChatCommand(@NotNull PlayerCommandPreprocessEvent event) {
|
||||
if (event.getMessage().split(" ")[0].contains(":")) {
|
||||
event.setCancelled(true);
|
||||
event.getPlayer().sendRichMessage(TranslationManager.get(LanguageString.CHATCOMMAND_ERROR_NAMESPACE, event.getPlayer(), true));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,4 +30,6 @@
|
|||
"HOME_NORESPAWN": "<error>Du hast keinen gültigen Respawnpunkt.</error>\n<error>Stelle sicher, dass dein Bett oder Respawn Anker nicht abgebaut oder behindert ist.</error>",
|
||||
|
||||
"TOGGLEDOWNFALL": "Niederschlag umgestellt",
|
||||
|
||||
"CHATCOMMAND_ERROR_NAMESPACE": "<error>Namespaces zu verwenden ist nicht erlaubt, da es verwendet werden kann um Sicherheitsmaßnahmen zu umgehen.</error>"
|
||||
}
|
||||
|
|
|
@ -45,4 +45,6 @@
|
|||
"TOGGLEDOWNFALL": "Toggled downfall",
|
||||
|
||||
"CHATMESSAGE_SERVER": "<mention>%sender%</mention> <#d60532>»</#d60532> ",
|
||||
|
||||
"CHATCOMMAND_ERROR_NAMESPACE": "<error>Using namespaces is not allowed, as it may be used to circumvent security measures.</error>"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue