finally add remove namespaces lmfaoooooooooooooooooo

This commit is contained in:
ChomeNS
2023-05-12 16:25:37 +07:00
parent e6e324a937
commit ab5052178d
3 changed files with 24 additions and 8 deletions

View File

@@ -96,5 +96,6 @@ public class Configuration {
@Getter @Setter public boolean useChat = false;
@Getter public boolean hasEssentials = true;
@Getter public int reconnectDelay = -1;
@Getter public boolean removeNamespaces = false;
}
}

View File

@@ -222,8 +222,21 @@ public class ChatPlugin extends Bot.Listener {
final String message = _queue.get(0);
if (message.startsWith("/")) {
String removedMessage = message.substring(1);
final String[] splittedSpace = removedMessage.split("\\s+"); // [minecraft:test, arg1, arg2, ...]
final String[] splittedColon = splittedSpace[0].split(":"); // [minecraft, test]
if (bot.options().removeNamespaces() && splittedColon.length >= 2) {
removedMessage = String.join(":", Arrays.copyOfRange(splittedColon, 1, splittedColon.length));
if (splittedSpace.length > 1) {
removedMessage += " ";
removedMessage += String.join(" ", Arrays.copyOfRange(splittedSpace, 1, splittedSpace.length));
}
}
bot.session().send(new ServerboundChatCommandPacket(
message.substring(1),
removedMessage,
Instant.now().toEpochMilli(),
0L,
Collections.emptyList(),