finally add remove namespaces lmfaoooooooooooooooooo

This commit is contained in:
Chayapak 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(),

View file

@ -77,13 +77,14 @@ bots:
# username, kaboom, useCore, useChat, hasEssentials and reconnectDelay are optional.
# more info:
# for username if it doesn't exist it will default to random username
# for kaboom it will just default to `false`
# for serverName name it whatever you like, it will be used as server name in trusted broadcast and in console
# for useCore it just sends the command using chat instead of using core. recommended to enable useChat too when this is enabled
# for useChat when the bot sends output (tellraw) it will chat instead of using the core to run tellraw
# for hasEssentials it is self-explanatory. if the server has essentials plugin just set it to true
# for reconnectDelay if not specified it will just default to the global reconnectDelay
# username - if it doesn't exist it will default to random username
# kaboom - it will just default to `false`
# serverName - name it whatever you like, it will be used as server name in trusted broadcast and in console
# useCore - it just sends the command using chat instead of using core. recommended to enable useChat too when this is enabled
# useChat - when the bot sends output (tellraw) it will chat instead of using the core to run tellraw
# hasEssentials - if the server has essentials plugin just set it to true!! ! !!31
# reconnectDelay - if not specified it will just default to the global reconnectDelay
# removeNamespaces - when the bot sends a command it will remove like `minecraft:` for example if set to true
- host: 'localhost'
port: 25565
@ -94,3 +95,4 @@ bots:
useChat: false
hasEssentials: false
reconnectDelay: 2000
removeNamespaces: false