2/2 Player-specific TBMM battle config
Add support for custom stats per-player by player username.
This commit is contained in:
parent
2c369a125a
commit
6625a495ca
2 changed files with 237 additions and 78 deletions
|
@ -481,11 +481,15 @@ public class ClientProxy extends CommonProxy {
|
||||||
MutableComponent text = Component.literal("Edit what value? ");
|
MutableComponent text = Component.literal("Edit what value? ");
|
||||||
text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
|
text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
|
||||||
|
|
||||||
MutableComponent option = Component.literal("IgB");
|
MutableComponent option;
|
||||||
|
MutableComponent value;
|
||||||
|
|
||||||
|
if (pkt.getEntityInfo().playerName.isEmpty()) {
|
||||||
|
option = Component.literal("IgB");
|
||||||
// HoverEvent.Action.SHOW_TEXT is probably SHOW_TEXT
|
// HoverEvent.Action.SHOW_TEXT is probably SHOW_TEXT
|
||||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle"))
|
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit ignoreBattle"))
|
||||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("IgnoreBattle"))));
|
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("IgnoreBattle"))));
|
||||||
MutableComponent value = Component.literal("(" + pkt.getEntityInfo().ignoreBattle + ") ");
|
value = Component.literal("(" + pkt.getEntityInfo().ignoreBattle + ") ");
|
||||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||||
option.getSiblings().add(value);
|
option.getSiblings().add(value);
|
||||||
text.getSiblings().add(option);
|
text.getSiblings().add(option);
|
||||||
|
@ -497,6 +501,7 @@ public class ClientProxy extends CommonProxy {
|
||||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||||
option.getSiblings().add(value);
|
option.getSiblings().add(value);
|
||||||
text.getSiblings().add(option);
|
text.getSiblings().add(option);
|
||||||
|
}
|
||||||
|
|
||||||
option = Component.literal("APr");
|
option = Component.literal("APr");
|
||||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackProbability"))
|
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackProbability"))
|
||||||
|
@ -506,6 +511,7 @@ public class ClientProxy extends CommonProxy {
|
||||||
option.getSiblings().add(value);
|
option.getSiblings().add(value);
|
||||||
text.getSiblings().add(option);
|
text.getSiblings().add(option);
|
||||||
|
|
||||||
|
if (pkt.getEntityInfo().playerName.isEmpty()) {
|
||||||
option = Component.literal("AV");
|
option = Component.literal("AV");
|
||||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackVariance"))
|
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit attackVariance"))
|
||||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackVariance"))));
|
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("AttackVariance"))));
|
||||||
|
@ -545,6 +551,7 @@ public class ClientProxy extends CommonProxy {
|
||||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||||
option.getSiblings().add(value);
|
option.getSiblings().add(value);
|
||||||
text.getSiblings().add(option);
|
text.getSiblings().add(option);
|
||||||
|
}
|
||||||
|
|
||||||
option = Component.literal("E");
|
option = Component.literal("E");
|
||||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit evasion"))
|
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit evasion"))
|
||||||
|
@ -562,6 +569,23 @@ public class ClientProxy extends CommonProxy {
|
||||||
option.getSiblings().add(value);
|
option.getSiblings().add(value);
|
||||||
text.getSiblings().add(option);
|
text.getSiblings().add(option);
|
||||||
|
|
||||||
|
option = Component.literal("HS");
|
||||||
|
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit hasteSpeed"))
|
||||||
|
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("HasteSpeed"))));
|
||||||
|
value = Component.literal("(" + pkt.getEntityInfo().hasteSpeed + ") ");
|
||||||
|
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||||
|
option.getSiblings().add(value);
|
||||||
|
text.getSiblings().add(option);
|
||||||
|
|
||||||
|
option = Component.literal("SS");
|
||||||
|
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit slowSpeed"))
|
||||||
|
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("SlowSpeed"))));
|
||||||
|
value = Component.literal("(" + pkt.getEntityInfo().slowSpeed + ") ");
|
||||||
|
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||||
|
option.getSiblings().add(value);
|
||||||
|
text.getSiblings().add(option);
|
||||||
|
|
||||||
|
if (pkt.getEntityInfo().playerName.isEmpty()) {
|
||||||
option = Component.literal("C");
|
option = Component.literal("C");
|
||||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category"))
|
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit category"))
|
||||||
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("Category"))));
|
.withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("Category"))));
|
||||||
|
@ -593,6 +617,7 @@ public class ClientProxy extends CommonProxy {
|
||||||
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
value.setStyle(value.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)));
|
||||||
option.getSiblings().add(value);
|
option.getSiblings().add(value);
|
||||||
text.getSiblings().add(option);
|
text.getSiblings().add(option);
|
||||||
|
}
|
||||||
|
|
||||||
option = Component.literal("Finished Editing");
|
option = Component.literal("Finished Editing");
|
||||||
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit finish")));
|
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFF00FF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit finish")));
|
||||||
|
@ -1302,6 +1327,44 @@ public class ClientProxy extends CommonProxy {
|
||||||
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
|
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case EDIT_HASTE_SPEED: {
|
||||||
|
MutableComponent text = Component.literal("haste speed: ");
|
||||||
|
text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
|
||||||
|
|
||||||
|
for (int i = 0; i <= 100; i += 10) {
|
||||||
|
MutableComponent option = Component.literal(Integer.toString(i));
|
||||||
|
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit hasteSpeed " + Integer.toString(i))));
|
||||||
|
text.getSiblings().add(option);
|
||||||
|
if (i < 100) {
|
||||||
|
text.getSiblings().add(Component.literal(", "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
text.getSiblings().add(Component.literal(" (or use command \"/tbm-edit edit hasteSpeed <integer>\")"));
|
||||||
|
|
||||||
|
parentComponent.getSiblings().add(text);
|
||||||
|
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EDIT_SLOW_SPEED: {
|
||||||
|
MutableComponent text = Component.literal("slow speed: ");
|
||||||
|
text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
|
||||||
|
|
||||||
|
for (int i = 0; i <= 100; i += 10) {
|
||||||
|
MutableComponent option = Component.literal(Integer.toString(i));
|
||||||
|
option.setStyle(option.getStyle().withColor(TextColor.fromRgb(0xFFFFFF00)).withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/tbm-edit edit slowSpeed " + Integer.toString(i))));
|
||||||
|
text.getSiblings().add(option);
|
||||||
|
if (i < 100) {
|
||||||
|
text.getSiblings().add(Component.literal(", "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
text.getSiblings().add(Component.literal(" (or use command \"/tbm-edit edit slowSpeed <integer>\")"));
|
||||||
|
|
||||||
|
parentComponent.getSiblings().add(text);
|
||||||
|
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case EDIT_CATEGORY: {
|
case EDIT_CATEGORY: {
|
||||||
MutableComponent text = Component.literal("category: ");
|
MutableComponent text = Component.literal("category: ");
|
||||||
text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
|
text.setStyle(text.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
|
||||||
|
@ -1472,6 +1535,10 @@ public class ClientProxy extends CommonProxy {
|
||||||
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
|
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case PICK_PLAYER: {
|
||||||
|
TurnBasedMinecraftMod.proxy.displayString("Use \"/tbm-edit player <player_name>\"");
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,6 +267,30 @@ public class TurnBasedMinecraftMod {
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}))
|
}))
|
||||||
|
.then(Commands.literal("player")
|
||||||
|
.executes(c -> {
|
||||||
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
|
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_PLAYER));
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
.then(Commands.argument("playerName", StringArgumentType.greedyString()).executes(c -> {
|
||||||
|
String name = StringArgumentType.getString(c, "playerName");
|
||||||
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
|
PacketDistributor.sendToPlayer(player, new PacketGeneralMessage("Editing player \"" + name + "\""));
|
||||||
|
TurnBasedMinecraftMod.logger.info("Begin editing player \"" + name + "\"");
|
||||||
|
proxy.setEditingPlayer(player);
|
||||||
|
EditingInfo editInfo = proxy.getEditingInfo(player.getId());
|
||||||
|
editInfo.isEditingPlayer = true;
|
||||||
|
editInfo.entityInfo = TurnBasedMinecraftMod.proxy.getConfig().getPlayerInfo(name);
|
||||||
|
if (editInfo.entityInfo == null) {
|
||||||
|
editInfo.entityInfo = new EntityInfo();
|
||||||
|
}
|
||||||
|
editInfo.entityInfo.playerName = name;
|
||||||
|
editInfo.isPendingEntitySelection = false;
|
||||||
|
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editInfo.entityInfo));
|
||||||
|
return 1;
|
||||||
|
}))
|
||||||
|
)
|
||||||
.then(Commands.literal("edit")
|
.then(Commands.literal("edit")
|
||||||
.executes(c -> {
|
.executes(c -> {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
|
@ -623,6 +647,74 @@ public class TurnBasedMinecraftMod {
|
||||||
return 1;
|
return 1;
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
|
.then(Commands.literal("hasteSpeed")
|
||||||
|
.executes(c -> {
|
||||||
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
|
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_HASTE_SPEED));
|
||||||
|
} else if (editingInfo != null) {
|
||||||
|
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
|
} else {
|
||||||
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
.then(Commands.argument("hasteSpeed", IntegerArgumentType.integer())
|
||||||
|
.executes(c -> {
|
||||||
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
|
int hasteSpeed = IntegerArgumentType.getInteger(c, "hasteSpeed");
|
||||||
|
if (hasteSpeed < 0) {
|
||||||
|
hasteSpeed = 0;
|
||||||
|
}
|
||||||
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
|
editingInfo.entityInfo.hasteSpeed = hasteSpeed;
|
||||||
|
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
|
} else if (editingInfo != null) {
|
||||||
|
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
|
} else {
|
||||||
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}))
|
||||||
|
)
|
||||||
|
.then(Commands.literal("slowSpeed")
|
||||||
|
.executes(c -> {
|
||||||
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
|
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.EDIT_SLOW_SPEED));
|
||||||
|
} else if (editingInfo != null) {
|
||||||
|
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
|
} else {
|
||||||
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
})
|
||||||
|
.then(Commands.argument("slowSpeed", IntegerArgumentType.integer())
|
||||||
|
.executes(c -> {
|
||||||
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
|
EditingInfo editingInfo = TurnBasedMinecraftMod.proxy.getEditingInfo(player.getId());
|
||||||
|
int slowSpeed = IntegerArgumentType.getInteger(c, "slowSpeed");
|
||||||
|
if (slowSpeed < 0) {
|
||||||
|
slowSpeed = 0;
|
||||||
|
}
|
||||||
|
if (editingInfo != null && !editingInfo.isPendingEntitySelection) {
|
||||||
|
editingInfo.entityInfo.slowSpeed = slowSpeed;
|
||||||
|
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.PICK_EDIT, editingInfo.entityInfo));
|
||||||
|
} else if (editingInfo != null) {
|
||||||
|
PacketDistributor.sendToPlayer(player, new PacketEditingMessage(PacketEditingMessage.Type.ATTACK_ENTITY));
|
||||||
|
} else {
|
||||||
|
Message exceptionMessage = new LiteralMessage("Cannot edit entity without starting editing (use \"/tbm-edit\").");
|
||||||
|
throw new CommandSyntaxException(new SimpleCommandExceptionType(exceptionMessage), exceptionMessage);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}))
|
||||||
|
)
|
||||||
.then(Commands.literal("category")
|
.then(Commands.literal("category")
|
||||||
.executes(c -> {
|
.executes(c -> {
|
||||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||||
|
|
Loading…
Reference in a new issue