WIP 1.18.3: Allow editing of server config in-game
This commit is contained in:
parent
607ca015b1
commit
bc598c41b7
8 changed files with 436 additions and 11 deletions
|
@ -1,5 +1,8 @@
|
|||
# Upcoming changes
|
||||
|
||||
The ability to change server-side config from within the game using
|
||||
"/tbm-server-edit".
|
||||
|
||||
# Version 1.18.2
|
||||
|
||||
The list of targets in the Battle GUI when selecting a target did not display
|
||||
|
|
|
@ -14,7 +14,7 @@ apply plugin: 'net.minecraftforge.gradle'
|
|||
//apply plugin: 'eclipse'
|
||||
//apply plugin: 'maven-publish'
|
||||
|
||||
version = "1.18.2"
|
||||
version = "1.18.3"
|
||||
group = "com.burnedkirby.TurnBasedMinecraft"
|
||||
archivesBaseName = "TurnBasedMinecraft"
|
||||
|
||||
|
|
|
@ -640,6 +640,159 @@ public class ClientProxy extends CommonProxy
|
|||
TurnBasedMinecraftMod.proxy.displayComponent(parentComponent);
|
||||
break;
|
||||
}
|
||||
case SERVER_EDIT:
|
||||
{
|
||||
TextComponent parent = new TextComponent("Edit what server value? ");
|
||||
parent.setStyle(parent.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
|
||||
|
||||
TextComponent sub = new TextComponent("leave_battle_cooldown ");
|
||||
sub.setStyle(sub.getStyle().withColor(0xFFFFFF00));
|
||||
|
||||
for (int i = 1; i <= 10; ++i) {
|
||||
TextComponent value = new TextComponent(String.valueOf(i) + ' ');
|
||||
value.setStyle(
|
||||
value.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit leave_battle_cooldown " + i)));
|
||||
sub.append(value);
|
||||
}
|
||||
|
||||
parent.append(sub);
|
||||
|
||||
sub = new TextComponent("aggro_start_battle_max_distance ");
|
||||
sub.setStyle(sub.getStyle().withColor(0xFFFFFF00));
|
||||
parent.append(sub);
|
||||
|
||||
sub = new TextComponent("5 ");
|
||||
sub.setStyle(
|
||||
sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit aggro_start_battle_max_distance 5")));
|
||||
parent.append(sub);
|
||||
|
||||
sub = new TextComponent("8 ");
|
||||
sub.setStyle(
|
||||
sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit aggro_start_battle_max_distance 8")));
|
||||
parent.append(sub);
|
||||
|
||||
for (int i = 10; i <= 50; i += 5) {
|
||||
sub = new TextComponent(String.valueOf(i) + ' ');
|
||||
sub.setStyle(
|
||||
sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit aggro_start_battle_max_distance " + String.valueOf(i))));
|
||||
parent.append(sub);
|
||||
}
|
||||
|
||||
sub = new TextComponent("old_battle_behavior ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(0xFFFFFF00)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("If enabled, battles only start on a hit, not including mobs targeting players"))));
|
||||
parent.append(sub);
|
||||
|
||||
sub = new TextComponent("true ");
|
||||
sub.setStyle(
|
||||
sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit old_battle_behavior true")));
|
||||
parent.append(sub);
|
||||
|
||||
sub = new TextComponent("false ");
|
||||
sub.setStyle(
|
||||
sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit old_battle_behavior false")));
|
||||
parent.append(sub);
|
||||
|
||||
sub = new TextComponent("anyone_can_disable_tbm_for_self ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(0xFFFFFF00)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("Allows use for /tbm-disable and /tbm-enable for all"))));
|
||||
parent.append(sub);
|
||||
|
||||
sub = new TextComponent("true ");
|
||||
sub.setStyle(
|
||||
sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit anyone_can_disable_tbm_for_self true")));
|
||||
parent.append(sub);
|
||||
|
||||
sub = new TextComponent("false ");
|
||||
sub.setStyle(
|
||||
sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit anyone_can_disable_tbm_for_self false")));
|
||||
parent.append(sub);
|
||||
|
||||
sub = new TextComponent("max_in_battle ");
|
||||
sub.setStyle(sub.getStyle().withColor(0xFFFFFF00));
|
||||
parent.append(sub);
|
||||
|
||||
sub = new TextComponent("2 ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit max_in_battle 2")));
|
||||
parent.append(sub);
|
||||
|
||||
for (int i = 5; i < 30; i += 5) {
|
||||
sub = new TextComponent(String.valueOf(i) + ' ');
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit max_in_battle " + String.valueOf(i))));
|
||||
parent.append(sub);
|
||||
}
|
||||
|
||||
sub = new TextComponent("freeze_battle_combatants ");
|
||||
sub.setStyle(sub.getStyle().withColor(0xFFFFFF00));
|
||||
parent.append(sub);
|
||||
|
||||
sub = new TextComponent("true ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit freeze_battle_combatants true"
|
||||
)));
|
||||
parent.append(sub);
|
||||
|
||||
sub = new TextComponent("false ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit freeze_battle_combatants false"
|
||||
)));
|
||||
parent.append(sub);
|
||||
|
||||
TurnBasedMinecraftMod.proxy.displayComponent(parent);
|
||||
break;
|
||||
}
|
||||
case EDIT_IGNORE_BATTLE:
|
||||
{
|
||||
TextComponent text = new TextComponent("ignoreBattle: ");
|
||||
|
|
|
@ -142,11 +142,7 @@ public class Config
|
|||
|
||||
private boolean parseConfig(File configFile) throws IOException
|
||||
{
|
||||
CommentedFileConfig conf = CommentedFileConfig
|
||||
.builder(configFile)
|
||||
.defaultResource(TurnBasedMinecraftMod.DEFAULT_CONFIG_FILE_PATH)
|
||||
.build();
|
||||
conf.load();
|
||||
CommentedFileConfig conf = getConfigObj(configFile);
|
||||
|
||||
// client config
|
||||
try {
|
||||
|
@ -1079,6 +1075,27 @@ public class Config
|
|||
return canOverwrite;
|
||||
}
|
||||
|
||||
private CommentedFileConfig getConfigObj(File configFile) {
|
||||
CommentedFileConfig conf = CommentedFileConfig
|
||||
.builder(configFile)
|
||||
.defaultResource(TurnBasedMinecraftMod.DEFAULT_CONFIG_FILE_PATH)
|
||||
.build();
|
||||
conf.load();
|
||||
|
||||
return conf;
|
||||
}
|
||||
|
||||
public boolean updateConfig(String path, Object value) {
|
||||
File configFile = new File(TurnBasedMinecraftMod.CONFIG_FILE_PATH);
|
||||
CommentedFileConfig conf = getConfigObj(configFile);
|
||||
|
||||
conf.set(path, value);
|
||||
conf.save();
|
||||
conf.close();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isIgnoreBattleType(String type)
|
||||
{
|
||||
return ignoreBattleTypes.contains(type);
|
||||
|
@ -1094,6 +1111,15 @@ public class Config
|
|||
return maxInBattle;
|
||||
}
|
||||
|
||||
public void setMaxInBattle(int maxInBattle) {
|
||||
if (maxInBattle < 2) {
|
||||
maxInBattle = 2;
|
||||
} else if (maxInBattle > 30) {
|
||||
maxInBattle = 30;
|
||||
}
|
||||
this.maxInBattle = maxInBattle;
|
||||
}
|
||||
|
||||
public boolean isBattleMusicType(String type)
|
||||
{
|
||||
return musicBattleTypes.contains(type.toLowerCase());
|
||||
|
@ -1109,6 +1135,10 @@ public class Config
|
|||
return freezeCombatantsInBattle;
|
||||
}
|
||||
|
||||
public void setFreezeCombatantsInBattle(boolean enabled) {
|
||||
freezeCombatantsInBattle = enabled;
|
||||
}
|
||||
|
||||
public int getSillyMusicThreshold()
|
||||
{
|
||||
return sillyMusicThreshold;
|
||||
|
@ -1154,6 +1184,10 @@ public class Config
|
|||
return onlyOPsSelfDisableTB;
|
||||
}
|
||||
|
||||
public void setIfOnlyOPsCanDisableTurnBasedForSelf(boolean enabled_for_only_ops) {
|
||||
onlyOPsSelfDisableTB = enabled_for_only_ops;
|
||||
}
|
||||
|
||||
protected void setBattleDisabledForAll(boolean isDisabled)
|
||||
{
|
||||
battleDisabledForAll = isDisabled;
|
||||
|
@ -1169,11 +1203,24 @@ public class Config
|
|||
return oldBattleBehaviorEnabled;
|
||||
}
|
||||
|
||||
public void setOldBattleBehavior(boolean enabled) {
|
||||
oldBattleBehaviorEnabled = enabled;
|
||||
}
|
||||
|
||||
public int getLeaveBattleCooldownSeconds()
|
||||
{
|
||||
return leaveBattleCooldownSeconds;
|
||||
}
|
||||
|
||||
public void setLeaveBattleCooldownSeconds(int seconds) {
|
||||
if (seconds < 1) {
|
||||
seconds = 1;
|
||||
} else if (seconds > 10) {
|
||||
seconds = 10;
|
||||
}
|
||||
leaveBattleCooldownSeconds = seconds;
|
||||
}
|
||||
|
||||
public long getLeaveBattleCooldownNanos()
|
||||
{
|
||||
return (long)leaveBattleCooldownSeconds * 1000000000L;
|
||||
|
@ -1184,6 +1231,15 @@ public class Config
|
|||
return aggroStartBattleDistance;
|
||||
}
|
||||
|
||||
public void setAggroStartBattleDistance(int distance) {
|
||||
if (distance < 5) {
|
||||
distance = 5;
|
||||
} else if (distance > 50) {
|
||||
distance = 50;
|
||||
}
|
||||
aggroStartBattleDistance = distance;
|
||||
}
|
||||
|
||||
public int getCreeperExplodeTurn() { return creeperExplodeTurn; }
|
||||
|
||||
public boolean getCreeperStopExplodeOnLeaveBattle() { return creeperStopExplodeOnLeaveBattle; }
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.apache.logging.log4j.Logger;
|
|||
public class TurnBasedMinecraftMod {
|
||||
public static final String MODID = "com_burnedkirby_turnbasedminecraft";
|
||||
public static final String NAME = "Turn Based Minecraft Mod";
|
||||
public static final String VERSION = "1.18.2";
|
||||
public static final String VERSION = "1.18.3";
|
||||
public static final String CONFIG_FILENAME = "TBM_Config.toml";
|
||||
public static final String DEFAULT_CONFIG_FILENAME = "TBM_Config_DEFAULT.toml";
|
||||
public static final String CONFIG_DIRECTORY = "config/TurnBasedMinecraft/";
|
||||
|
@ -773,10 +773,222 @@ public class TurnBasedMinecraftMod {
|
|||
)
|
||||
)
|
||||
);
|
||||
// tbm-server-edit
|
||||
event.getDispatcher().register(
|
||||
Commands.literal("tbm-server-edit")
|
||||
.requires(c -> c.hasPermission(2))
|
||||
.executes(c -> {
|
||||
ServerPlayer player = c.getSource().getPlayerOrException();
|
||||
getHandler().send(PacketDistributor.PLAYER.with(() -> player), new PacketEditingMessage(PacketEditingMessage.Type.SERVER_EDIT));
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.literal("leave_battle_cooldown").executes(c -> {
|
||||
TextComponent response = new TextComponent("leave_battle_cooldown requires an integer argument. ");
|
||||
TextComponent subResponse = new TextComponent("leave_battle_cooldown is currently: ");
|
||||
response.append(subResponse);
|
||||
subResponse = new TextComponent(String.valueOf(TurnBasedMinecraftMod.proxy.getConfig().getLeaveBattleCooldownSeconds()));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, false);
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.argument("cooldown_seconds", IntegerArgumentType.integer())
|
||||
.executes(c -> {
|
||||
int cooldown = IntegerArgumentType.getInteger(c, "cooldown_seconds");
|
||||
// setting cooldown validates the value. Set it, then fetch it again.
|
||||
TurnBasedMinecraftMod.proxy.getConfig().setLeaveBattleCooldownSeconds(cooldown);
|
||||
cooldown = TurnBasedMinecraftMod.proxy.getConfig().getLeaveBattleCooldownSeconds();
|
||||
if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig(
|
||||
"server_config.leave_battle_cooldown",
|
||||
cooldown)) {
|
||||
TurnBasedMinecraftMod.logger.warn(
|
||||
"Failed to set \"server_config.leave_battle_cooldown\" in config file!");
|
||||
c.getSource().sendFailure(new TextComponent("" +
|
||||
"Failed to set leave_battle_cooldown to \""
|
||||
+ cooldown
|
||||
+ "\" in config file!"));
|
||||
} else {
|
||||
TextComponent response = new TextComponent("Successfully set leave_battle_cooldown to: ");
|
||||
TextComponent subResponse = new TextComponent(String.valueOf(cooldown));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
return 1;
|
||||
})))
|
||||
.then(Commands.literal("aggro_start_battle_max_distance").executes(c -> {
|
||||
TextComponent response = new TextComponent("aggro_start_battle_max_distance requires an integer argument. ");
|
||||
TextComponent subResponse = new TextComponent("aggro_start_battle_max_distance is currently: ");
|
||||
response.append(subResponse);
|
||||
subResponse = new TextComponent(String.valueOf(
|
||||
TurnBasedMinecraftMod.proxy.getConfig().getAggroStartBattleDistance()));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, false);
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.argument("aggro_distance", IntegerArgumentType.integer())
|
||||
.executes(c -> {
|
||||
int distance = IntegerArgumentType.getInteger(c, "aggro_distance");
|
||||
// setDistance in Config validates the value. Set it, then fetch it again.
|
||||
TurnBasedMinecraftMod.proxy.getConfig().setAggroStartBattleDistance(distance);
|
||||
distance = TurnBasedMinecraftMod.proxy.getConfig().getAggroStartBattleDistance();
|
||||
if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig(
|
||||
"server_config.aggro_start_battle_max_distance",
|
||||
distance)) {
|
||||
TurnBasedMinecraftMod.logger.warn(
|
||||
"Failed to set \"server_config.aggro_start_battle_max_distance\" in config file!");
|
||||
c.getSource().sendFailure(new TextComponent(
|
||||
"Failed to set aggro_start_battle_max_distance to \""
|
||||
+ distance
|
||||
+ "\" in config file!"));
|
||||
} else {
|
||||
TextComponent response = new TextComponent("Successfully set aggro_start_battle_max_distance to: ");
|
||||
TextComponent subResponse = new TextComponent(String.valueOf(distance));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
return 1;
|
||||
})))
|
||||
.then(Commands.literal("old_battle_behavior").executes(c -> {
|
||||
TextComponent response = new TextComponent("old_battle_behavior requires a boolean argument. ");
|
||||
TextComponent subResponse = new TextComponent("old_battle_behavior is currently: ");
|
||||
response.append(subResponse);
|
||||
subResponse = new TextComponent(String.valueOf(
|
||||
TurnBasedMinecraftMod.proxy.getConfig().isOldBattleBehaviorEnabled()));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, false);
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.argument("old_battle_behavior_enabled", BoolArgumentType.bool())
|
||||
.executes(c -> {
|
||||
boolean enabled = BoolArgumentType.getBool(c, "old_battle_behavior_enabled");
|
||||
TurnBasedMinecraftMod.proxy.getConfig().setOldBattleBehavior(enabled);
|
||||
if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig(
|
||||
"server_config.old_battle_behavior",
|
||||
enabled)) {
|
||||
TurnBasedMinecraftMod.logger.warn(
|
||||
"Failed to set \"server_config.old_battle_behavior\" in config file!");
|
||||
c.getSource().sendFailure(new TextComponent(
|
||||
"Failed to set old_battle_behavior to \""
|
||||
+ enabled
|
||||
+ "\" in config file!"));
|
||||
} else {
|
||||
TextComponent response = new TextComponent("Successfully set old_battle_behavior to: ");
|
||||
TextComponent subResponse = new TextComponent(String.valueOf(enabled));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
return 1;
|
||||
})))
|
||||
.then(Commands.literal("anyone_can_disable_tbm_for_self").executes(c -> {
|
||||
TextComponent response = new TextComponent("anyone_can_disable_tbm_for_self requires a boolean argument. ");
|
||||
TextComponent subResponse = new TextComponent("anyone_can_disable_tbm_for_self is currently: ");
|
||||
response.append(subResponse);
|
||||
subResponse = new TextComponent(String.valueOf(
|
||||
!TurnBasedMinecraftMod.proxy.getConfig().getIfOnlyOPsCanDisableTurnBasedForSelf()));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, false);
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.argument("enabled_for_all", BoolArgumentType.bool())
|
||||
.executes(c -> {
|
||||
boolean enabled_for_all = BoolArgumentType.getBool(c, "enabled_for_all");
|
||||
TurnBasedMinecraftMod.proxy.getConfig().setIfOnlyOPsCanDisableTurnBasedForSelf(!enabled_for_all);
|
||||
if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig(
|
||||
"server_config.anyone_can_disable_tbm_for_self",
|
||||
enabled_for_all
|
||||
)) {
|
||||
TurnBasedMinecraftMod.logger.warn(
|
||||
"Failed to set \"server_config.anyone_can_disable_tbm_for_self\" in config file!");
|
||||
c.getSource().sendFailure(new TextComponent(
|
||||
"Failed to set anyone_can_disable_tbm_for_self to \""
|
||||
+ enabled_for_all
|
||||
+ "\" in config file!"));
|
||||
} else {
|
||||
TextComponent response = new TextComponent("Successfully set anyone_can_disable_tbm_for_self to: ");
|
||||
TextComponent subResponse = new TextComponent(String.valueOf(enabled_for_all));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
return 1;
|
||||
})))
|
||||
.then(Commands.literal("max_in_battle").executes(c -> {
|
||||
TextComponent response = new TextComponent("max_in_battle requires an integer argument. ");
|
||||
TextComponent subResponse = new TextComponent("max_in_battle is currently: ");
|
||||
response.append(subResponse);
|
||||
subResponse = new TextComponent(String.valueOf(
|
||||
TurnBasedMinecraftMod.proxy.getConfig().getMaxInBattle()));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, false);
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.argument("max_amount", IntegerArgumentType.integer())
|
||||
.executes(c -> {
|
||||
int max_amount = IntegerArgumentType.getInteger(c, "max_amount");
|
||||
// setMaxInBattle in Config validates the value. Set it, then fetch it again.
|
||||
TurnBasedMinecraftMod.proxy.getConfig().setMaxInBattle(max_amount);
|
||||
max_amount = TurnBasedMinecraftMod.proxy.getConfig().getMaxInBattle();
|
||||
if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig(
|
||||
"server_config.max_in_battle",
|
||||
max_amount)) {
|
||||
TurnBasedMinecraftMod.logger.warn(
|
||||
"Failed to set \"server_config.max_in_battle\" in config file!");
|
||||
c.getSource().sendFailure(new TextComponent(
|
||||
"Failed to set max_in_battle to \""
|
||||
+ max_amount
|
||||
+ "\" in config file!"));
|
||||
} else {
|
||||
TextComponent response = new TextComponent("Successfully set max_in_battle to: ");
|
||||
TextComponent subResponse = new TextComponent(String.valueOf(max_amount));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
return 1;
|
||||
})))
|
||||
.then(Commands.literal("freeze_battle_combatants").executes(c -> {
|
||||
TextComponent response = new TextComponent("freeze_battle_combatants requires a boolean argument. ");
|
||||
TextComponent subResponse = new TextComponent("freeze_battle_combatants is currently: ");
|
||||
response.append(subResponse);
|
||||
subResponse = new TextComponent(String.valueOf(
|
||||
!TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled()));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, false);
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.argument("freeze_enabled", BoolArgumentType.bool())
|
||||
.executes(c -> {
|
||||
boolean enabled = BoolArgumentType.getBool(c, "freeze_enabled");
|
||||
TurnBasedMinecraftMod.proxy.getConfig().setFreezeCombatantsInBattle(enabled);
|
||||
if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.freeze_battle_combatants", enabled)) {
|
||||
TurnBasedMinecraftMod.logger.warn(
|
||||
"Failed to set \"server_config.freeze_battle_combatants\" in config file!");
|
||||
c.getSource().sendFailure(new TextComponent(
|
||||
"Failed to set freeze_battle_combatants to \""
|
||||
+ enabled
|
||||
+ "\" in config file!"));
|
||||
} else {
|
||||
TextComponent response = new TextComponent("Successfully set freeze_battle_combatants to: ");
|
||||
TextComponent subResponse = new TextComponent(String.valueOf(enabled));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
return 1;
|
||||
})))
|
||||
);
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void serverStopping(ServerStoppingEvent event) {
|
||||
public void serverStopping(ServerStoppingEvent ignoredEvent) {
|
||||
logger.debug("About to cleanup BattleManager");
|
||||
if (proxy.cleanupBattleManager()) {
|
||||
logger.debug("Cleaned up BattleManager");
|
||||
|
|
|
@ -30,7 +30,8 @@ public class PacketEditingMessage
|
|||
EDIT_CATEGORY(12),
|
||||
EDIT_DECISION_ATTACK(13),
|
||||
EDIT_DECISION_DEFEND(14),
|
||||
EDIT_DECISION_FLEE(15);
|
||||
EDIT_DECISION_FLEE(15),
|
||||
SERVER_EDIT(16);
|
||||
|
||||
Type(int value)
|
||||
{
|
||||
|
|
|
@ -15,7 +15,7 @@ license="MIT"
|
|||
# The modid of the mod
|
||||
modId="com_burnedkirby_turnbasedminecraft" #mandatory
|
||||
# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
|
||||
version="1.18.2" #mandatory
|
||||
version="1.18.3" #mandatory
|
||||
# A display name for the mod
|
||||
displayName="TurnBasedMinecraftMod" #mandatory
|
||||
# A URL to query for updates for this mod. See the JSON update specification <here>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"modid": "com_burnedkirby_turnbasedminecraft",
|
||||
"name": "Turn Based Minecraft",
|
||||
"description": "Changes battles to be turn-based.",
|
||||
"version": "1.18.2",
|
||||
"version": "1.18.3",
|
||||
"mcversion": "1.18.2",
|
||||
"url": "",
|
||||
"updateUrl": "",
|
||||
|
|
Loading…
Reference in a new issue