WIP 1.18.3: Impl in-game server config editing
This commit is contained in:
parent
d9981da5fd
commit
bfd584ad69
3 changed files with 493 additions and 53 deletions
|
@ -7,6 +7,7 @@ import com.burnedkirby.TurnBasedMinecraft.common.TurnBasedMinecraftMod;
|
|||
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketBattleMessage;
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketEditingMessage;
|
||||
import com.burnedkirby.TurnBasedMinecraft.common.networking.PacketGeneralMessage;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.Options;
|
||||
import net.minecraft.network.chat.*;
|
||||
|
@ -581,29 +582,28 @@ public class ClientProxy extends CommonProxy {
|
|||
parent.setStyle(parent.getStyle().withColor(TextColor.fromRgb(0xFFFFFFFF)).withBold(false));
|
||||
|
||||
TextComponent sub = new TextComponent("leave_battle_cooldown ");
|
||||
sub.setStyle(sub.getStyle().withColor(0xFFFFFF00).withBold(true));
|
||||
sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW).withBold(true));
|
||||
parent.append(sub);
|
||||
|
||||
for (int i = 1; i <= 10; ++i) {
|
||||
TextComponent value = new TextComponent(String.valueOf(i) + ' ');
|
||||
value.setStyle(
|
||||
value.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
sub = new TextComponent(String.valueOf(i) + ' ');
|
||||
sub.setStyle(
|
||||
sub.getStyle()
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit leave_battle_cooldown " + i)));
|
||||
sub.append(value);
|
||||
parent.append(sub);
|
||||
}
|
||||
|
||||
parent.append(sub);
|
||||
|
||||
sub = new TextComponent("aggro_start_battle_max_distance ");
|
||||
sub.setStyle(sub.getStyle().withColor(0xFFFFFF00).withBold(true));
|
||||
sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW).withBold(true));
|
||||
parent.append(sub);
|
||||
|
||||
sub = new TextComponent("5 ");
|
||||
sub.setStyle(
|
||||
sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit aggro_start_battle_max_distance 5")));
|
||||
|
@ -612,7 +612,7 @@ public class ClientProxy extends CommonProxy {
|
|||
sub = new TextComponent("8 ");
|
||||
sub.setStyle(
|
||||
sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit aggro_start_battle_max_distance 8")));
|
||||
|
@ -622,7 +622,7 @@ public class ClientProxy extends CommonProxy {
|
|||
sub = new TextComponent(String.valueOf(i) + ' ');
|
||||
sub.setStyle(
|
||||
sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit aggro_start_battle_max_distance " + String.valueOf(i))));
|
||||
|
@ -631,7 +631,7 @@ public class ClientProxy extends CommonProxy {
|
|||
|
||||
sub = new TextComponent("old_battle_behavior ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(0xFFFFFF00)
|
||||
.withColor(ChatFormatting.YELLOW)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("If enabled, battles only start on a hit, not including mobs targeting players")))
|
||||
|
@ -641,7 +641,7 @@ public class ClientProxy extends CommonProxy {
|
|||
sub = new TextComponent("true ");
|
||||
sub.setStyle(
|
||||
sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit old_battle_behavior true")));
|
||||
|
@ -650,7 +650,7 @@ public class ClientProxy extends CommonProxy {
|
|||
sub = new TextComponent("false ");
|
||||
sub.setStyle(
|
||||
sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit old_battle_behavior false")));
|
||||
|
@ -658,7 +658,7 @@ public class ClientProxy extends CommonProxy {
|
|||
|
||||
sub = new TextComponent("anyone_can_disable_tbm_for_self ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(0xFFFFFF00)
|
||||
.withColor(ChatFormatting.YELLOW)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("Allows use for /tbm-disable and /tbm-enable for all")))
|
||||
|
@ -668,7 +668,7 @@ public class ClientProxy extends CommonProxy {
|
|||
sub = new TextComponent("true ");
|
||||
sub.setStyle(
|
||||
sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit anyone_can_disable_tbm_for_self true")));
|
||||
|
@ -677,19 +677,19 @@ public class ClientProxy extends CommonProxy {
|
|||
sub = new TextComponent("false ");
|
||||
sub.setStyle(
|
||||
sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.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).withBold(true));
|
||||
sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW).withBold(true));
|
||||
parent.append(sub);
|
||||
|
||||
sub = new TextComponent("2 ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit max_in_battle 2")));
|
||||
|
@ -698,7 +698,7 @@ public class ClientProxy extends CommonProxy {
|
|||
for (int i = 5; i < 30; i += 5) {
|
||||
sub = new TextComponent(String.valueOf(i) + ' ');
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit max_in_battle " + String.valueOf(i))));
|
||||
|
@ -706,12 +706,12 @@ public class ClientProxy extends CommonProxy {
|
|||
}
|
||||
|
||||
sub = new TextComponent("freeze_battle_combatants ");
|
||||
sub.setStyle(sub.getStyle().withColor(0xFFFFFF00).withBold(true));
|
||||
sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW).withBold(true));
|
||||
parent.append(sub);
|
||||
|
||||
sub = new TextComponent("true ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit freeze_battle_combatants true"
|
||||
|
@ -720,7 +720,7 @@ public class ClientProxy extends CommonProxy {
|
|||
|
||||
sub = new TextComponent("false ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit freeze_battle_combatants false"
|
||||
|
@ -729,7 +729,7 @@ public class ClientProxy extends CommonProxy {
|
|||
|
||||
sub = new TextComponent("ignore_battle_types ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withColor(ChatFormatting.DARK_GREEN)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit ignore_battle_types"))
|
||||
|
@ -742,7 +742,7 @@ public class ClientProxy extends CommonProxy {
|
|||
|
||||
sub = new TextComponent("player_speed ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(0xFFFFFF00)
|
||||
.withColor(ChatFormatting.YELLOW)
|
||||
.withBold(true)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
|
@ -752,7 +752,7 @@ public class ClientProxy extends CommonProxy {
|
|||
for (int i = 0; i <= 100; i += 5) {
|
||||
sub = new TextComponent(String.valueOf(i) + ' ');
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit player_speed " + i)));
|
||||
parent.append(sub);
|
||||
|
@ -760,7 +760,7 @@ public class ClientProxy extends CommonProxy {
|
|||
|
||||
sub = new TextComponent("player_haste_speed ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(0xFFFFFF00)
|
||||
.withColor(ChatFormatting.YELLOW)
|
||||
.withBold(true)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
|
@ -771,7 +771,7 @@ public class ClientProxy extends CommonProxy {
|
|||
for (int i = 0; i <= 100; i += 5) {
|
||||
sub = new TextComponent(String.valueOf(i) + ' ');
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit player_haste_speed " + i)));
|
||||
parent.append(sub);
|
||||
|
@ -779,7 +779,7 @@ public class ClientProxy extends CommonProxy {
|
|||
|
||||
sub = new TextComponent("player_slow_speed ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(0xFFFFFF00)
|
||||
.withColor(ChatFormatting.YELLOW)
|
||||
.withBold(true)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
|
@ -790,12 +790,177 @@ public class ClientProxy extends CommonProxy {
|
|||
for (int i = 0; i <= 100; i += 5) {
|
||||
sub = new TextComponent(String.valueOf(i) + ' ');
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit player_slow_speed " + i)));
|
||||
parent.append(sub);
|
||||
}
|
||||
|
||||
sub = new TextComponent("player_attack_probability ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(ChatFormatting.YELLOW)
|
||||
.withBold(true)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("Base Player attack probability in percentage")
|
||||
)));
|
||||
parent.append(sub);
|
||||
|
||||
for (int i = 0; i <= 100; i += 5) {
|
||||
if (i == 0) {
|
||||
sub = new TextComponent("1 ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit player_attack_probability 1")));
|
||||
} else {
|
||||
sub = new TextComponent(String.valueOf(i) + ' ');
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit player_attack_probability " + i)));
|
||||
}
|
||||
parent.append(sub);
|
||||
}
|
||||
|
||||
sub = new TextComponent("player_evasion ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(ChatFormatting.YELLOW)
|
||||
.withBold(true)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("Base Player evasion rate in percentage")
|
||||
)));
|
||||
parent.append(sub);
|
||||
|
||||
for (int i = 0; i <= 100; i += 5) {
|
||||
sub = new TextComponent(String.valueOf(i) + ' ');
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit player_evasion " + i)));
|
||||
parent.append(sub);
|
||||
}
|
||||
|
||||
sub = new TextComponent("defense_duration ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(ChatFormatting.YELLOW)
|
||||
.withBold(true)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("Number of attacks that a \"Defend\" move blocks (lasts until next action)")
|
||||
)));
|
||||
parent.append(sub);
|
||||
|
||||
for (int i = 0; i <= 5; ++i) {
|
||||
sub = new TextComponent(String.valueOf(i) + ' ');
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit defense_duration " + i)));
|
||||
parent.append(sub);
|
||||
}
|
||||
|
||||
sub = new TextComponent("flee_good_probability ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(ChatFormatting.YELLOW)
|
||||
.withBold(true)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("Probability of flee success when Player's speed is higher than the fastest opposing Entity")
|
||||
)));
|
||||
parent.append(sub);
|
||||
|
||||
for (int i = 0; i <= 100; i += 5) {
|
||||
if (i == 0) {
|
||||
sub = new TextComponent("1 ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit flee_good_probability 1")));
|
||||
} else {
|
||||
sub = new TextComponent(String.valueOf(i) + ' ');
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit flee_good_probability " + i)));
|
||||
}
|
||||
parent.append(sub);
|
||||
}
|
||||
|
||||
sub = new TextComponent("flee_bad_probability ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(ChatFormatting.YELLOW)
|
||||
.withBold(true)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("Probability of flee success when Player's speed is lower than the fastest opposing Entity")
|
||||
)));
|
||||
parent.append(sub);
|
||||
|
||||
for (int i = 0; i <= 100; i += 5) {
|
||||
if (i == 0) {
|
||||
sub = new TextComponent("1 ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit flee_bad_probability 1")));
|
||||
} else {
|
||||
sub = new TextComponent(String.valueOf(i) + ' ');
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit flee_bad_probability " + i)));
|
||||
}
|
||||
parent.append(sub);
|
||||
}
|
||||
|
||||
sub = new TextComponent("minimum_hit_percentage ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(ChatFormatting.YELLOW)
|
||||
.withBold(true)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("The minimum percentage possible when calculating hit percentage for any attacker")
|
||||
)));
|
||||
parent.append(sub);
|
||||
|
||||
for (int i = 0; i <= 100; i += 5) {
|
||||
if (i == 0) {
|
||||
sub = new TextComponent("1 ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit minimum_hit_percentage 1")));
|
||||
} else {
|
||||
sub = new TextComponent(String.valueOf(i) + ' ');
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit minimum_hit_percentage " + i)));
|
||||
}
|
||||
parent.append(sub);
|
||||
}
|
||||
|
||||
sub = new TextComponent("battle_turn_time_seconds ");
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(ChatFormatting.YELLOW)
|
||||
.withBold(true)
|
||||
.withHoverEvent(new HoverEvent(
|
||||
HoverEvent.Action.SHOW_TEXT,
|
||||
new TextComponent("The time in seconds to wait for all Players to choose their move")
|
||||
)));
|
||||
parent.append(sub);
|
||||
|
||||
for (int i = 5; i <= 60; i += 5) {
|
||||
sub = new TextComponent(String.valueOf(i) + ' ');
|
||||
sub.setStyle(sub.getStyle()
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit battle_turn_time_seconds " + i)));
|
||||
parent.append(sub);
|
||||
}
|
||||
|
||||
TurnBasedMinecraftMod.proxy.displayComponent(parent);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -981,26 +981,72 @@ public class Config
|
|||
return playerAttackProbability;
|
||||
}
|
||||
|
||||
public void setPlayerAttackProbability(int probability) {
|
||||
if (probability < 1) {
|
||||
probability = 1;
|
||||
} else if (probability > 100) {
|
||||
probability = 100;
|
||||
}
|
||||
playerAttackProbability = probability;
|
||||
}
|
||||
|
||||
public int getPlayerEvasion()
|
||||
{
|
||||
return playerEvasion;
|
||||
}
|
||||
|
||||
public void setPlayerEvasion(int evasion) {
|
||||
if (evasion < 0) {
|
||||
evasion = 0;
|
||||
} else if (evasion > 100) {
|
||||
evasion = 100;
|
||||
}
|
||||
playerEvasion = evasion;
|
||||
}
|
||||
|
||||
public int getDefenseDuration()
|
||||
{
|
||||
return defenseDuration;
|
||||
}
|
||||
|
||||
public void setDefenseDuration(int turns) {
|
||||
if (turns < 0) {
|
||||
turns = 0;
|
||||
} else if (turns > 5) {
|
||||
turns = 5;
|
||||
}
|
||||
|
||||
defenseDuration = turns;
|
||||
}
|
||||
|
||||
public int getFleeGoodProbability()
|
||||
{
|
||||
return fleeGoodProbability;
|
||||
}
|
||||
|
||||
public void setFleeGoodProbability(int probability) {
|
||||
if (probability < 1) {
|
||||
probability = 1;
|
||||
} else if (probability > 100) {
|
||||
probability = 100;
|
||||
}
|
||||
fleeGoodProbability = probability;
|
||||
}
|
||||
|
||||
public int getFleeBadProbability()
|
||||
{
|
||||
return fleeBadProbability;
|
||||
}
|
||||
|
||||
public void setFleeBadProbability(int probability) {
|
||||
if (probability < 1) {
|
||||
probability = 1;
|
||||
} else if (probability > 100) {
|
||||
probability = 100;
|
||||
}
|
||||
fleeBadProbability = probability;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a clone of an EntityInfo (to prevent editing it).
|
||||
* @param classFullName
|
||||
|
@ -1210,6 +1256,15 @@ public class Config
|
|||
return minimumHitPercentage;
|
||||
}
|
||||
|
||||
public void setMinimumHitPercentage(int percentage) {
|
||||
if (percentage < 1) {
|
||||
percentage = 1;
|
||||
} else if (percentage > 100) {
|
||||
percentage = 100;
|
||||
}
|
||||
minimumHitPercentage = percentage;
|
||||
}
|
||||
|
||||
public int getMaxInBattle()
|
||||
{
|
||||
return maxInBattle;
|
||||
|
@ -1263,6 +1318,15 @@ public class Config
|
|||
return (int)(battleDecisionDurationNanos / 1000000000L);
|
||||
}
|
||||
|
||||
public void setDecisionDurationSeconds(long seconds) {
|
||||
if (seconds < 5) {
|
||||
seconds = 5;
|
||||
} else if (seconds > 60) {
|
||||
seconds = 60;
|
||||
}
|
||||
battleDecisionDurationNanos = seconds * 1000000000L;
|
||||
}
|
||||
|
||||
protected void addBattleIgnoringPlayer(int id)
|
||||
{
|
||||
battleIgnoringPlayers.add(id);
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.mojang.brigadier.arguments.IntegerArgumentType;
|
|||
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.commands.Commands;
|
||||
import net.minecraft.commands.arguments.EntityArgument;
|
||||
import net.minecraft.network.chat.ClickEvent;
|
||||
|
@ -789,7 +790,7 @@ public class TurnBasedMinecraftMod {
|
|||
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));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, false);
|
||||
return 1;
|
||||
|
@ -812,7 +813,7 @@ public class TurnBasedMinecraftMod {
|
|||
} else {
|
||||
TextComponent response = new TextComponent("Successfully set leave_battle_cooldown to: ");
|
||||
TextComponent subResponse = new TextComponent(String.valueOf(cooldown));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
|
@ -824,7 +825,7 @@ public class TurnBasedMinecraftMod {
|
|||
response.append(subResponse);
|
||||
subResponse = new TextComponent(String.valueOf(
|
||||
TurnBasedMinecraftMod.proxy.getConfig().getAggroStartBattleDistance()));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, false);
|
||||
return 1;
|
||||
|
@ -847,7 +848,7 @@ public class TurnBasedMinecraftMod {
|
|||
} 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));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
|
@ -859,7 +860,7 @@ public class TurnBasedMinecraftMod {
|
|||
response.append(subResponse);
|
||||
subResponse = new TextComponent(String.valueOf(
|
||||
TurnBasedMinecraftMod.proxy.getConfig().isOldBattleBehaviorEnabled()));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, false);
|
||||
return 1;
|
||||
|
@ -880,7 +881,7 @@ public class TurnBasedMinecraftMod {
|
|||
} else {
|
||||
TextComponent response = new TextComponent("Successfully set old_battle_behavior to: ");
|
||||
TextComponent subResponse = new TextComponent(String.valueOf(enabled));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
|
@ -892,7 +893,7 @@ public class TurnBasedMinecraftMod {
|
|||
response.append(subResponse);
|
||||
subResponse = new TextComponent(String.valueOf(
|
||||
!TurnBasedMinecraftMod.proxy.getConfig().getIfOnlyOPsCanDisableTurnBasedForSelf()));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, false);
|
||||
return 1;
|
||||
|
@ -914,7 +915,7 @@ public class TurnBasedMinecraftMod {
|
|||
} 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));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
|
@ -926,7 +927,7 @@ public class TurnBasedMinecraftMod {
|
|||
response.append(subResponse);
|
||||
subResponse = new TextComponent(String.valueOf(
|
||||
TurnBasedMinecraftMod.proxy.getConfig().getMaxInBattle()));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, false);
|
||||
return 1;
|
||||
|
@ -949,7 +950,7 @@ public class TurnBasedMinecraftMod {
|
|||
} 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));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
|
@ -961,7 +962,7 @@ public class TurnBasedMinecraftMod {
|
|||
response.append(subResponse);
|
||||
subResponse = new TextComponent(String.valueOf(
|
||||
!TurnBasedMinecraftMod.proxy.getConfig().isFreezeCombatantsEnabled()));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, false);
|
||||
return 1;
|
||||
|
@ -980,7 +981,7 @@ public class TurnBasedMinecraftMod {
|
|||
} else {
|
||||
TextComponent response = new TextComponent("Successfully set freeze_battle_combatants to: ");
|
||||
TextComponent subResponse = new TextComponent(String.valueOf(enabled));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
|
@ -989,7 +990,7 @@ public class TurnBasedMinecraftMod {
|
|||
.then(Commands.literal("ignore_battle_types").executes(c -> {
|
||||
TextComponent response = new TextComponent("Use ");
|
||||
TextComponent subResponse = new TextComponent("/tbm-server-edit ignore_battle_types add/remove <category> ");
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFFFFFF00));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.YELLOW));
|
||||
response.append(subResponse);
|
||||
|
||||
subResponse = new TextComponent("ignore_battle_types is currently: [");
|
||||
|
@ -1002,7 +1003,7 @@ public class TurnBasedMinecraftMod {
|
|||
}
|
||||
subResponse = new TextComponent(category);
|
||||
subResponse.setStyle(subResponse.getStyle()
|
||||
.withColor(0xFF00FF00)
|
||||
.withColor(ChatFormatting.GREEN)
|
||||
.withClickEvent(new ClickEvent(
|
||||
ClickEvent.Action.RUN_COMMAND,
|
||||
"/tbm-server-edit ignore_battle_types remove " + category))
|
||||
|
@ -1027,7 +1028,7 @@ public class TurnBasedMinecraftMod {
|
|||
TextComponent response = new TextComponent("Successfully appended category \"");
|
||||
|
||||
TextComponent sub = new TextComponent(category);
|
||||
sub.setStyle(sub.getStyle().withColor(0xFF00FF00));
|
||||
sub.setStyle(sub.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(sub);
|
||||
|
||||
sub = new TextComponent("\" to ignore_battle_types");
|
||||
|
@ -1052,7 +1053,7 @@ public class TurnBasedMinecraftMod {
|
|||
TextComponent response = new TextComponent("Successfully removed category \"");
|
||||
|
||||
TextComponent sub = new TextComponent(category);
|
||||
sub.setStyle(sub.getStyle().withColor(0xFF00FF00));
|
||||
sub.setStyle(sub.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(sub);
|
||||
|
||||
sub = new TextComponent("\" from ignore_battle_types");
|
||||
|
@ -1069,7 +1070,7 @@ public class TurnBasedMinecraftMod {
|
|||
.then(Commands.literal("player_speed").executes(c -> {
|
||||
TextComponent parent = new TextComponent("Use ");
|
||||
TextComponent sub = new TextComponent("/tbm-server-edit player_speed <0-100>");
|
||||
sub.setStyle(sub.getStyle().withColor(0xFFFFFF00));
|
||||
sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW));
|
||||
parent.append(sub);
|
||||
|
||||
c.getSource().sendSuccess(parent, false);
|
||||
|
@ -1090,7 +1091,7 @@ public class TurnBasedMinecraftMod {
|
|||
} else {
|
||||
TextComponent response = new TextComponent("Successfully set player_speed to: ");
|
||||
TextComponent subResponse = new TextComponent(String.valueOf(speed));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
|
@ -1099,7 +1100,7 @@ public class TurnBasedMinecraftMod {
|
|||
.then(Commands.literal("player_haste_speed").executes(c -> {
|
||||
TextComponent parent = new TextComponent("Use ");
|
||||
TextComponent sub = new TextComponent("/tbm-server-edit player_haste_speed <0-100>");
|
||||
sub.setStyle(sub.getStyle().withColor(0xFFFFFF00));
|
||||
sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW));
|
||||
parent.append(sub);
|
||||
|
||||
c.getSource().sendSuccess(parent, false);
|
||||
|
@ -1120,7 +1121,7 @@ public class TurnBasedMinecraftMod {
|
|||
} else {
|
||||
TextComponent response = new TextComponent("Successfully set player_haste_speed to: ");
|
||||
TextComponent subResponse = new TextComponent(String.valueOf(haste_speed));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
|
@ -1129,7 +1130,7 @@ public class TurnBasedMinecraftMod {
|
|||
.then(Commands.literal("player_slow_speed").executes(c -> {
|
||||
TextComponent parent = new TextComponent("Use ");
|
||||
TextComponent sub = new TextComponent("/tbm-server-edit player_slow_speed <0-100>");
|
||||
sub.setStyle(sub.getStyle().withColor(0xFFFFFF00));
|
||||
sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW));
|
||||
parent.append(sub);
|
||||
|
||||
c.getSource().sendSuccess(parent, false);
|
||||
|
@ -1150,7 +1151,217 @@ public class TurnBasedMinecraftMod {
|
|||
} else {
|
||||
TextComponent response = new TextComponent("Successfully set player_slow_speed to: ");
|
||||
TextComponent subResponse = new TextComponent(String.valueOf(slow_speed));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(0xFF00FF00));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
return 1;
|
||||
})))
|
||||
.then(Commands.literal("player_attack_probability").executes(c -> {
|
||||
TextComponent parent = new TextComponent("Use ");
|
||||
TextComponent sub = new TextComponent("/tbm-server-edit player_attack_probability <1-100>");
|
||||
sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW));
|
||||
parent.append(sub);
|
||||
|
||||
c.getSource().sendSuccess(parent, false);
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.argument("probability", IntegerArgumentType.integer()).executes(c -> {
|
||||
int probability = IntegerArgumentType.getInteger(c, "probability");
|
||||
// setPlayerAttackProbability() in Config validates the value. Set it, then fetch it again.
|
||||
TurnBasedMinecraftMod.proxy.getConfig().setPlayerAttackProbability(probability);
|
||||
probability = TurnBasedMinecraftMod.proxy.getConfig().getPlayerAttackProbability();
|
||||
if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.player_attack_probability", probability)) {
|
||||
TurnBasedMinecraftMod.logger.warn(
|
||||
"Failed to set \"server_config.player_attack_probability\" in config file!");
|
||||
c.getSource().sendFailure(new TextComponent(
|
||||
"Failed to set player_attack_probability to \""
|
||||
+ probability
|
||||
+ "\" in config file!"));
|
||||
} else {
|
||||
TextComponent response = new TextComponent("Successfully set player_attack_probability to: ");
|
||||
TextComponent subResponse = new TextComponent(String.valueOf(probability));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
return 1;
|
||||
})))
|
||||
.then(Commands.literal("player_evasion").executes(c -> {
|
||||
TextComponent parent = new TextComponent("Use ");
|
||||
TextComponent sub = new TextComponent("/tbm-server-edit player_evasion <0-100>");
|
||||
sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW));
|
||||
parent.append(sub);
|
||||
|
||||
c.getSource().sendSuccess(parent, false);
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.argument("evasion", IntegerArgumentType.integer()).executes(c -> {
|
||||
int evasion = IntegerArgumentType.getInteger(c, "evasion");
|
||||
// setPlayerEvasion() in Config validates the value. Set it, then fetch it again.
|
||||
TurnBasedMinecraftMod.proxy.getConfig().setPlayerEvasion(evasion);
|
||||
evasion = TurnBasedMinecraftMod.proxy.getConfig().getPlayerEvasion();
|
||||
if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.player_evasion", evasion)) {
|
||||
TurnBasedMinecraftMod.logger.warn(
|
||||
"Failed to set \"server_config.player_evasion\" in config file!");
|
||||
c.getSource().sendFailure(new TextComponent(
|
||||
"Failed to set player_evasion to \""
|
||||
+ evasion
|
||||
+ "\" in config file!"));
|
||||
} else {
|
||||
TextComponent response = new TextComponent("Successfully set player_evasion to: ");
|
||||
TextComponent subResponse = new TextComponent(String.valueOf(evasion));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
return 1;
|
||||
})))
|
||||
.then(Commands.literal("defense_duration").executes(c -> {
|
||||
TextComponent parent = new TextComponent("Use ");
|
||||
TextComponent sub = new TextComponent("/tbm-server-edit defense_duration <0-5>");
|
||||
sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW));
|
||||
parent.append(sub);
|
||||
|
||||
c.getSource().sendSuccess(parent, false);
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.argument("defends", IntegerArgumentType.integer()).executes(c -> {
|
||||
int defends = IntegerArgumentType.getInteger(c, "defends");
|
||||
// setDefenseDuration() in Config validates the value. Set it, then fetch it again.
|
||||
TurnBasedMinecraftMod.proxy.getConfig().setDefenseDuration(defends);
|
||||
defends = TurnBasedMinecraftMod.proxy.getConfig().getDefenseDuration();
|
||||
if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.defense_duration", defends)) {
|
||||
TurnBasedMinecraftMod.logger.warn(
|
||||
"Failed to set \"server_config.defense_duration\" in config file!");
|
||||
c.getSource().sendFailure(new TextComponent(
|
||||
"Failed to set defense_druation to \""
|
||||
+ defends
|
||||
+ "\" in config file!"));
|
||||
} else {
|
||||
TextComponent response = new TextComponent("Successfully set defense_duration to: ");
|
||||
TextComponent subResponse = new TextComponent(String.valueOf(defends));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
return 1;
|
||||
})))
|
||||
.then(Commands.literal("flee_good_probability").executes(c -> {
|
||||
TextComponent parent = new TextComponent("Use ");
|
||||
TextComponent sub = new TextComponent("/tbm-server-edit flee_good_probability <1-100>");
|
||||
sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW));
|
||||
parent.append(sub);
|
||||
|
||||
c.getSource().sendSuccess(parent, false);
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.argument("probability", IntegerArgumentType.integer()).executes(c -> {
|
||||
int probability = IntegerArgumentType.getInteger(c, "probability");
|
||||
// setFleeGoodProbability() in Config validates the value. Set it, then fetch it again.
|
||||
TurnBasedMinecraftMod.proxy.getConfig().setFleeGoodProbability(probability);
|
||||
probability = TurnBasedMinecraftMod.proxy.getConfig().getFleeGoodProbability();
|
||||
if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.flee_good_probability", probability)) {
|
||||
TurnBasedMinecraftMod.logger.warn(
|
||||
"Failed to set \"server_config.flee_good_probability\" in config file!");
|
||||
c.getSource().sendFailure(new TextComponent(
|
||||
"Failed to set flee_good_probability to \""
|
||||
+ probability
|
||||
+ "\" in config file!"));
|
||||
} else {
|
||||
TextComponent response = new TextComponent("Successfully set flee_good_probability to: ");
|
||||
TextComponent subResponse = new TextComponent(String.valueOf(probability));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
return 1;
|
||||
})))
|
||||
.then(Commands.literal("flee_bad_probability").executes(c -> {
|
||||
TextComponent parent = new TextComponent("Use ");
|
||||
TextComponent sub = new TextComponent("/tbm-server-edit flee_bad_probability <1-100>");
|
||||
sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW));
|
||||
parent.append(sub);
|
||||
|
||||
c.getSource().sendSuccess(parent, false);
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.argument("probability", IntegerArgumentType.integer()).executes(c -> {
|
||||
int probability = IntegerArgumentType.getInteger(c, "probability");
|
||||
// setFleeBadProbability() in Config validates the value. Set it, then fetch it again.
|
||||
TurnBasedMinecraftMod.proxy.getConfig().setFleeBadProbability(probability);
|
||||
probability = TurnBasedMinecraftMod.proxy.getConfig().getFleeBadProbability();
|
||||
if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.flee_bad_probability", probability)) {
|
||||
TurnBasedMinecraftMod.logger.warn(
|
||||
"Failed to set \"server_config.flee_bad_probability\" in config file!");
|
||||
c.getSource().sendFailure(new TextComponent(
|
||||
"Failed to set flee_bad_probability to \""
|
||||
+ probability
|
||||
+ "\" in config file!"));
|
||||
} else {
|
||||
TextComponent response = new TextComponent("Successfully set flee_bad_probability to: ");
|
||||
TextComponent subResponse = new TextComponent(String.valueOf(probability));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
return 1;
|
||||
})))
|
||||
.then(Commands.literal("minimum_hit_percentage").executes(c -> {
|
||||
TextComponent parent = new TextComponent("Use ");
|
||||
TextComponent sub = new TextComponent("/tbm-server-edit minimum_hit_percentage <1-100>");
|
||||
sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW));
|
||||
parent.append(sub);
|
||||
|
||||
c.getSource().sendSuccess(parent, false);
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.argument("percentage", IntegerArgumentType.integer()).executes(c -> {
|
||||
int percentage = IntegerArgumentType.getInteger(c, "percentage");
|
||||
// setMinimumHitPercentage() in Config validates the value. Set it, then fetch it again.
|
||||
TurnBasedMinecraftMod.proxy.getConfig().setMinimumHitPercentage(percentage);
|
||||
percentage = TurnBasedMinecraftMod.proxy.getConfig().getMinimumHitPercentage();
|
||||
if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.minimum_hit_percentage", percentage)) {
|
||||
TurnBasedMinecraftMod.logger.warn(
|
||||
"Failed to set \"server_config.minimum_hit_percentage\" in config file!");
|
||||
c.getSource().sendFailure(new TextComponent(
|
||||
"Failed to set minimum_hit_percentage to \""
|
||||
+ percentage
|
||||
+ "\" in config file!"));
|
||||
} else {
|
||||
TextComponent response = new TextComponent("Successfully set minimum_hit_percentage to: ");
|
||||
TextComponent subResponse = new TextComponent(String.valueOf(percentage));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
return 1;
|
||||
})))
|
||||
.then(Commands.literal("battle_turn_time_seconds").executes(c -> {
|
||||
TextComponent parent = new TextComponent("Use ");
|
||||
TextComponent sub = new TextComponent("/tbm-server-edit battle_turn_time_seconds <5-60>");
|
||||
sub.setStyle(sub.getStyle().withColor(ChatFormatting.YELLOW));
|
||||
parent.append(sub);
|
||||
|
||||
c.getSource().sendSuccess(parent, false);
|
||||
return 1;
|
||||
})
|
||||
.then(Commands.argument("seconds", IntegerArgumentType.integer()).executes(c -> {
|
||||
int seconds = IntegerArgumentType.getInteger(c, "seconds");
|
||||
// setDecisionDurationSeconds() in Config validates the value. Set it, then fetch it again.
|
||||
TurnBasedMinecraftMod.proxy.getConfig().setDecisionDurationSeconds(seconds);
|
||||
seconds = TurnBasedMinecraftMod.proxy.getConfig().getDecisionDurationSeconds();
|
||||
if (!TurnBasedMinecraftMod.proxy.getConfig().updateConfig("server_config.battle_turn_time_seconds", seconds)) {
|
||||
TurnBasedMinecraftMod.logger.warn(
|
||||
"Failed to set \"server_config.battle_turn_time_seconds\" in config file!");
|
||||
c.getSource().sendFailure(new TextComponent(
|
||||
"Failed to set battle_turn_time_seconds to \""
|
||||
+ seconds
|
||||
+ "\" in config file!"));
|
||||
} else {
|
||||
TextComponent response = new TextComponent("Successfully set battle_turn_time_seconds to: ");
|
||||
TextComponent subResponse = new TextComponent(String.valueOf(seconds));
|
||||
subResponse.setStyle(subResponse.getStyle().withColor(ChatFormatting.GREEN));
|
||||
response.append(subResponse);
|
||||
c.getSource().sendSuccess(response, true);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue