refactor: chomens mod don't hardcode run command prefix
This commit is contained in:
@@ -1 +1 @@
|
||||
3646
|
||||
3647
|
||||
@@ -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
|
||||
);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user