refactor: chomens mod don't hardcode run command prefix

This commit is contained in:
ChomeNS
2025-08-28 20:43:27 +07:00
parent 1b4f1419c0
commit e4bac5a9dd
4 changed files with 11 additions and 5 deletions

View File

@@ -1 +1 @@
3646
3647

View File

@@ -51,10 +51,12 @@ public class PacketHandler {
}
private void handlePacket (final PlayerEntry player, final ServerboundRunCommandPacket packet) {
final String input = packet.input; // the input is raw, no prefix included
final String prefix = packet.prefix;
final String input = packet.input;
final ChomeNSModCommandContext context = new ChomeNSModCommandContext(
bot,
prefix,
player
);

View File

@@ -5,13 +5,16 @@ import me.chayapak1.chomens_bot.chomeNSMod.Packet;
import me.chayapak1.chomens_bot.chomeNSMod.Types;
public class ServerboundRunCommandPacket implements Packet {
public final String prefix;
public final String input;
public ServerboundRunCommandPacket (final String input) {
public ServerboundRunCommandPacket (final String prefix, final String input) {
this.prefix = prefix;
this.input = input;
}
public ServerboundRunCommandPacket (final ByteBuf buf) {
this.prefix = Types.readString(buf);
this.input = Types.readString(buf);
}
@@ -22,6 +25,7 @@ public class ServerboundRunCommandPacket implements Packet {
@Override
public void serialize (final ByteBuf buf) {
Types.writeString(buf, this.prefix);
Types.writeString(buf, this.input);
}
}

View File

@@ -8,10 +8,10 @@ import me.chayapak1.chomens_bot.util.I18nUtilities;
import net.kyori.adventure.text.Component;
public class ChomeNSModCommandContext extends CommandContext {
public ChomeNSModCommandContext (final Bot bot, final PlayerEntry sender) {
public ChomeNSModCommandContext (final Bot bot, final String prefix, final PlayerEntry sender) {
super(
bot,
".cbot ", // intentionally hardcoded
prefix + "cbot ",
sender,
true
);