2018-09-03 06:19:33 +00:00
|
|
|
package com.seodisparate.TurnBasedMinecraft.common;
|
|
|
|
|
2018-10-20 08:54:32 +00:00
|
|
|
import java.io.*;
|
2018-09-07 07:41:22 +00:00
|
|
|
import java.time.LocalDateTime;
|
2018-09-03 06:19:33 +00:00
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashSet;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
2018-10-20 08:54:32 +00:00
|
|
|
import java.util.regex.Matcher;
|
|
|
|
import java.util.regex.Pattern;
|
2018-09-03 06:19:33 +00:00
|
|
|
|
2018-10-20 08:54:32 +00:00
|
|
|
import net.consensys.cava.toml.*;
|
2018-09-03 06:19:33 +00:00
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
|
|
|
public class Config
|
|
|
|
{
|
2018-09-28 08:45:32 +00:00
|
|
|
public static final long BATTLE_DECISION_DURATION_NANO_MIN = 5000000000L;
|
|
|
|
public static final long BATTLE_DECISION_DURATION_NANO_MAX = 60000000000L;
|
|
|
|
public static final long BATTLE_DECISION_DURATION_NANO_DEFAULT = 15000000000L;
|
|
|
|
private long battleDecisionDurationNanos = BATTLE_DECISION_DURATION_NANO_DEFAULT;
|
2018-09-04 06:21:49 +00:00
|
|
|
private Map<String, EntityInfo> entityInfoMap;
|
2018-09-13 05:12:04 +00:00
|
|
|
private Set<String> ignoreBattleTypes;
|
2018-09-03 06:19:33 +00:00
|
|
|
private Logger logger;
|
2018-09-06 08:08:36 +00:00
|
|
|
private int playerSpeed = 50;
|
|
|
|
private int playerHasteSpeed = 80;
|
|
|
|
private int playerSlowSpeed = 20;
|
2018-09-05 06:54:06 +00:00
|
|
|
private int playerAttackProbability = 100;
|
|
|
|
private int playerEvasion = 10;
|
|
|
|
private int defenseDuration = 1;
|
|
|
|
private int fleeGoodProbability = 90;
|
2018-10-20 08:54:32 +00:00
|
|
|
private int fleeBadProbability = 35;
|
|
|
|
private int minimumHitPercentage = 4;
|
2018-09-14 03:44:45 +00:00
|
|
|
private int maxInBattle = 8;
|
2018-09-14 05:14:10 +00:00
|
|
|
private Set<String> musicBattleTypes;
|
|
|
|
private Set<String> musicSillyTypes;
|
2018-09-18 06:56:06 +00:00
|
|
|
private boolean freezeCombatantsInBattle = false;
|
2018-09-28 03:02:39 +00:00
|
|
|
private int sillyMusicThreshold = 40;
|
2018-09-28 08:45:32 +00:00
|
|
|
private int configVersion = 0;
|
2018-10-16 05:02:44 +00:00
|
|
|
private Set<Integer> battleIgnoringPlayers = null;
|
|
|
|
private boolean onlyOPsSelfDisableTB = true;
|
2018-10-17 03:19:16 +00:00
|
|
|
private boolean battleDisabledForAll = false;
|
2018-10-17 08:15:23 +00:00
|
|
|
private boolean oldBattleBehaviorEnabled = false;
|
2018-10-17 09:28:47 +00:00
|
|
|
private int leaveBattleCooldownSeconds = 5;
|
2018-10-18 07:26:09 +00:00
|
|
|
private int aggroStartBattleDistance = 8;
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-03 06:19:33 +00:00
|
|
|
public Config(Logger logger)
|
|
|
|
{
|
2018-09-04 06:21:49 +00:00
|
|
|
entityInfoMap = new HashMap<String, EntityInfo>();
|
2018-09-13 05:12:04 +00:00
|
|
|
ignoreBattleTypes = new HashSet<String>();
|
2018-09-03 06:19:33 +00:00
|
|
|
this.logger = logger;
|
2018-09-14 05:14:10 +00:00
|
|
|
musicBattleTypes = new HashSet<String>();
|
|
|
|
musicSillyTypes = new HashSet<String>();
|
2018-10-16 05:02:44 +00:00
|
|
|
battleIgnoringPlayers = new HashSet<Integer>();
|
2018-10-20 08:54:32 +00:00
|
|
|
|
|
|
|
int internalVersion = getConfigFileVersion(getClass().getResourceAsStream(TurnBasedMinecraftMod.CONFIG_INTERNAL_PATH));
|
|
|
|
|
2018-09-07 07:41:22 +00:00
|
|
|
if(internalVersion == 0)
|
|
|
|
{
|
|
|
|
logger.error("Failed to check version of internal config file");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-28 08:45:32 +00:00
|
|
|
configVersion = internalVersion;
|
2018-09-07 07:41:22 +00:00
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-03 06:19:33 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
File testLoad = new File(TurnBasedMinecraftMod.CONFIG_FILE_PATH);
|
|
|
|
if(!testLoad.exists())
|
|
|
|
{
|
|
|
|
writeConfig();
|
|
|
|
}
|
|
|
|
}
|
2018-09-25 05:55:24 +00:00
|
|
|
catch (Throwable t)
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
|
|
|
logger.error("Failed to check/create-new config file");
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
|
|
|
// parse config
|
2018-09-03 06:19:33 +00:00
|
|
|
File configFile = new File(TurnBasedMinecraftMod.CONFIG_FILE_PATH);
|
|
|
|
if(!configFile.exists() || !configFile.canRead())
|
|
|
|
{
|
|
|
|
logger.error("Failed to read/parse config file " + TurnBasedMinecraftMod.CONFIG_FILE_PATH);
|
|
|
|
return;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-07 07:41:22 +00:00
|
|
|
int configVersion = getConfigFileVersion(configFile);
|
2018-09-28 08:45:32 +00:00
|
|
|
if(configVersion < this.configVersion)
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
2018-09-07 07:41:22 +00:00
|
|
|
logger.warn("Config file " + TurnBasedMinecraftMod.CONFIG_FILENAME + " is older version, renaming...");
|
|
|
|
moveOldConfig();
|
|
|
|
try
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
|
|
|
writeConfig();
|
2018-09-25 05:55:24 +00:00
|
|
|
} catch (Throwable t)
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
2018-09-07 07:41:22 +00:00
|
|
|
logger.error("Failed to write config file!");
|
2018-09-03 06:19:33 +00:00
|
|
|
}
|
2018-09-07 07:41:22 +00:00
|
|
|
}
|
|
|
|
try
|
|
|
|
{
|
|
|
|
parseConfig(configFile);
|
2018-09-25 05:55:24 +00:00
|
|
|
} catch (Throwable t)
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
2018-09-07 07:41:22 +00:00
|
|
|
logger.error("Failed to parse config file!");
|
2018-09-03 06:19:33 +00:00
|
|
|
}
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-03 06:19:33 +00:00
|
|
|
private void writeConfig() throws IOException
|
|
|
|
{
|
|
|
|
File configFile = new File(TurnBasedMinecraftMod.CONFIG_FILE_PATH);
|
|
|
|
File dirs = configFile.getParentFile();
|
|
|
|
dirs.mkdirs();
|
2018-09-07 07:41:22 +00:00
|
|
|
InputStream configStream = this.getClass().getResourceAsStream(TurnBasedMinecraftMod.CONFIG_INTERNAL_PATH);
|
2018-09-03 06:19:33 +00:00
|
|
|
FileOutputStream configOutput = new FileOutputStream(configFile);
|
|
|
|
byte[] buf = new byte[4096];
|
|
|
|
int read = 0;
|
|
|
|
while(read != -1)
|
|
|
|
{
|
|
|
|
read = configStream.read(buf);
|
|
|
|
if(read > 0)
|
|
|
|
{
|
|
|
|
configOutput.write(buf, 0, read);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
configStream.close();
|
|
|
|
configOutput.close();
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-03 06:19:33 +00:00
|
|
|
private void moveOldConfig()
|
|
|
|
{
|
|
|
|
File configFile = new File(TurnBasedMinecraftMod.CONFIG_FILE_PATH);
|
|
|
|
if(configFile.exists())
|
|
|
|
{
|
2018-09-04 06:21:49 +00:00
|
|
|
configFile.renameTo(new File(TurnBasedMinecraftMod.CONFIG_DIRECTORY
|
|
|
|
+ "TBM_Config_"
|
2018-09-07 07:41:22 +00:00
|
|
|
+ DateTimeFormatter.ISO_LOCAL_DATE_TIME.format(LocalDateTime.now())
|
2018-10-20 08:54:32 +00:00
|
|
|
+ ".toml"));
|
2018-09-03 06:19:33 +00:00
|
|
|
}
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
|
|
|
private boolean parseConfig(File configFile) throws IOException
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
TomlParseResult parseResult = Toml.parse(configFile.toPath(), TomlVersion.V0_5_0);
|
|
|
|
|
|
|
|
// client_config
|
|
|
|
{
|
|
|
|
TomlArray battleMusicCategories = parseResult.getArray("client_config.battle_music");
|
|
|
|
if(battleMusicCategories != null)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < battleMusicCategories.size(); ++i)
|
|
|
|
{
|
|
|
|
musicBattleTypes.add(battleMusicCategories.getString(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
musicBattleTypes.add("monster");
|
|
|
|
musicBattleTypes.add("animal");
|
|
|
|
musicBattleTypes.add("boss");
|
|
|
|
musicBattleTypes.add("player");
|
|
|
|
logNotFound("client_config.battle_music");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
TomlArray sillyMusicCategories = parseResult.getArray("client_config.silly_music");
|
|
|
|
if(sillyMusicCategories != null)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < sillyMusicCategories.size(); ++i)
|
|
|
|
{
|
|
|
|
musicSillyTypes.add(sillyMusicCategories.getString(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
musicSillyTypes.add("passive");
|
|
|
|
logNotFound("client_config.silly_music");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
sillyMusicThreshold = parseResult.getLong("client_config.silly_music_threshold").intValue();
|
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
sillyMusicThreshold = 40;
|
|
|
|
logNotFound("client_config.silly_music_threshold", "40");
|
|
|
|
}
|
|
|
|
|
|
|
|
// server_config
|
|
|
|
try
|
|
|
|
{
|
|
|
|
leaveBattleCooldownSeconds = parseResult.getLong("server_config.leave_battle_cooldown").intValue();
|
|
|
|
if (leaveBattleCooldownSeconds < 1)
|
|
|
|
{
|
|
|
|
leaveBattleCooldownSeconds = 1;
|
|
|
|
} else if (leaveBattleCooldownSeconds > 10)
|
|
|
|
{
|
|
|
|
leaveBattleCooldownSeconds = 10;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
leaveBattleCooldownSeconds = 5;
|
|
|
|
logNotFound("server_config.leave_battle_cooldown", "5");
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
aggroStartBattleDistance = parseResult.getLong("server_config.aggro_start_battle_max_distance").intValue();
|
|
|
|
if (aggroStartBattleDistance < 5)
|
|
|
|
{
|
|
|
|
aggroStartBattleDistance = 5;
|
|
|
|
} else if (aggroStartBattleDistance > 50)
|
|
|
|
{
|
|
|
|
aggroStartBattleDistance = 50;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
aggroStartBattleDistance = 8;
|
|
|
|
logNotFound("server_config.aggro_start_battle_max_distance", "8");
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
oldBattleBehaviorEnabled = parseResult.getBoolean("server_config.old_battle_behavior");
|
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
oldBattleBehaviorEnabled = false;
|
|
|
|
logNotFound("server_config.old_battle_behavior", "false");
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
onlyOPsSelfDisableTB = !parseResult.getBoolean("server_config.anyone_can_disable_tbm_for_self");
|
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
onlyOPsSelfDisableTB = true;
|
|
|
|
logNotFound("server_config.anyone_can_disable_tbm_for_self", "false");
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
maxInBattle = parseResult.getLong("server_config.max_in_battle").intValue();
|
|
|
|
if (maxInBattle < 2)
|
|
|
|
{
|
|
|
|
maxInBattle = 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
maxInBattle = 8;
|
|
|
|
logNotFound("server_config.max_in_battle", "8");
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
freezeCombatantsInBattle = parseResult.getBoolean("server_config.freeze_battle_combatants");
|
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
freezeCombatantsInBattle = false;
|
|
|
|
logNotFound("server_config.freeze_battle_combatants", "false");
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
TomlArray ignoreTypes = parseResult.getArray("server_config.ignore_battle_types");
|
|
|
|
for(int i = 0; i < ignoreTypes.size(); ++i)
|
|
|
|
{
|
|
|
|
ignoreBattleTypes.add(ignoreTypes.getString(i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
ignoreBattleTypes.add("passive");
|
|
|
|
ignoreBattleTypes.add("boss");
|
|
|
|
logNotFound("server_config.ignore_battle_types");
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
playerSpeed = parseResult.getLong("server_config.player_speed").intValue();
|
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
playerSpeed = 50;
|
|
|
|
logNotFound("server_config.player_speed", "50");
|
|
|
|
}
|
|
|
|
try
|
|
|
|
{
|
|
|
|
playerHasteSpeed = parseResult.getLong("server_config.player_haste_speed").intValue();
|
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
playerHasteSpeed = 80;
|
|
|
|
logNotFound("server_config.player_haste_speed", "80");
|
|
|
|
}
|
|
|
|
try
|
|
|
|
{
|
|
|
|
playerSlowSpeed = parseResult.getLong("server_config.player_slow_speed").intValue();
|
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
playerSlowSpeed = 20;
|
|
|
|
logNotFound("server_config.player_slow_speed", "20");
|
|
|
|
}
|
|
|
|
try
|
|
|
|
{
|
|
|
|
playerAttackProbability = parseResult.getLong("server_config.player_attack_probability").intValue();
|
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
playerAttackProbability = 90;
|
|
|
|
logNotFound("server_config.player_attack_probability", "90");
|
|
|
|
}
|
|
|
|
try
|
|
|
|
{
|
|
|
|
playerEvasion = parseResult.getLong("server_config.player_evasion").intValue();
|
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
playerEvasion = 10;
|
|
|
|
logNotFound("server_config.player_evasion", "10");
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
defenseDuration = parseResult.getLong("server_config.defense_duration").intValue();
|
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
defenseDuration = 1;
|
|
|
|
logNotFound("server_config.defense_duration", "1");
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
fleeGoodProbability = parseResult.getLong("server_config.flee_good_probability").intValue();
|
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
fleeGoodProbability = 90;
|
|
|
|
logNotFound("server_config.flee_good_probability", "90");
|
|
|
|
}
|
|
|
|
try
|
|
|
|
{
|
|
|
|
fleeBadProbability = parseResult.getLong("server_config.flee_bad_probability").intValue();
|
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
fleeBadProbability = 35;
|
|
|
|
logNotFound("server_config.flee_bad_probability", "35");
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
minimumHitPercentage = parseResult.getLong("server_config.minimum_hit_percentage").intValue();
|
|
|
|
if (minimumHitPercentage < 1)
|
|
|
|
{
|
|
|
|
minimumHitPercentage = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
minimumHitPercentage = 4;
|
|
|
|
logNotFound("server_config.minimum_hit_percentage", "4");
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
battleDecisionDurationNanos = parseResult.getLong("server_config.battle_turn_time_seconds") * 1000000000L;
|
|
|
|
if(battleDecisionDurationNanos < BATTLE_DECISION_DURATION_NANO_MIN)
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
battleDecisionDurationNanos = BATTLE_DECISION_DURATION_NANO_MIN;
|
|
|
|
logger.warn("Config \"server_config.battle_turn_time_seconds\" too low, defaulting to minimum \"5\"");
|
|
|
|
}
|
|
|
|
else if(battleDecisionDurationNanos > BATTLE_DECISION_DURATION_NANO_MAX)
|
|
|
|
{
|
|
|
|
battleDecisionDurationNanos = BATTLE_DECISION_DURATION_NANO_MAX;
|
|
|
|
logger.warn("Config \"server_config.battle_turn_time_seconds\" too high, defaulting to maximum \"60\"");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
battleDecisionDurationNanos = BATTLE_DECISION_DURATION_NANO_DEFAULT;
|
|
|
|
logNotFound("server_config.battle_turn_time_seconds", "15");
|
|
|
|
}
|
|
|
|
|
|
|
|
// entities
|
|
|
|
TomlArray entityArray = parseResult.getArray("server_config.entity");
|
|
|
|
if(entityArray != null)
|
|
|
|
{
|
|
|
|
for(int i = 0; i < entityArray.size(); ++i)
|
|
|
|
{
|
|
|
|
TomlTable entity = entityArray.getTable(i);
|
|
|
|
EntityInfo eInfo = new EntityInfo();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
eInfo.classType = Class.forName(entity.getString("name"));
|
|
|
|
}
|
|
|
|
catch (ClassNotFoundException e)
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
logger.error("Entity with class name \"" + entity.getString("name") + "\" not found, skipping...");
|
2018-09-03 06:19:33 +00:00
|
|
|
continue;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
catch (NullPointerException e)
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
logger.error("Entity does not have \"name\", skipping...");
|
2018-09-03 06:19:33 +00:00
|
|
|
continue;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
|
|
|
try
|
2018-10-17 09:28:47 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
eInfo.attackPower = entity.getLong("attack_power").intValue();
|
|
|
|
if(eInfo.attackPower < 0)
|
2018-10-17 09:28:47 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
eInfo.attackPower = 0;
|
|
|
|
logEntityInvalidValue("attack_power", eInfo.classType.getName(), "0");
|
2018-10-17 09:28:47 +00:00
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
logEntityMissingRequiredValue("attack_power", eInfo.classType.getName());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
eInfo.attackProbability = entity.getLong("attack_probability").intValue();
|
|
|
|
if(eInfo.attackProbability < 0 || eInfo.attackProbability > 100)
|
2018-10-17 09:28:47 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
eInfo.attackProbability = 35;
|
|
|
|
logEntityInvalidValue("attack_probability", eInfo.classType.getName(), "35");
|
2018-10-17 09:28:47 +00:00
|
|
|
}
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
logEntityMissingRequiredValue("attack_probability", eInfo.classType.getName());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
2018-10-18 07:26:09 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
eInfo.attackEffect = EntityInfo.Effect.fromString(entity.getString("attack_effect"));
|
|
|
|
if(eInfo.attackEffect != EntityInfo.Effect.UNKNOWN)
|
2018-10-18 07:26:09 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
eInfo.attackEffectProbability = entity.getLong("attack_effect_probability").intValue();
|
|
|
|
if(eInfo.attackEffectProbability < 0 || eInfo.attackEffectProbability > 100)
|
|
|
|
{
|
|
|
|
eInfo.attackEffectProbability = 35;
|
|
|
|
logEntityInvalidValue("attack_effect", eInfo.classType.getName(), "35");
|
|
|
|
}
|
2018-10-18 07:26:09 +00:00
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
eInfo.attackEffect = EntityInfo.Effect.UNKNOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
eInfo.attackVariance = entity.getLong("attack_variance").intValue();
|
|
|
|
if(eInfo.attackVariance < 0)
|
2018-10-18 07:26:09 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
eInfo.attackVariance = 0;
|
|
|
|
logEntityInvalidValue("attack_variance", eInfo.classType.getName(), "0");
|
2018-10-18 07:26:09 +00:00
|
|
|
}
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
eInfo.attackVariance = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
2018-10-17 08:15:23 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
eInfo.defenseDamage = entity.getLong("defense_damage").intValue();
|
|
|
|
if(eInfo.defenseDamage < 0)
|
2018-10-17 08:15:23 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
eInfo.defenseDamage = 0;
|
|
|
|
logEntityInvalidValue("defense_damage", eInfo.classType.getName(), "0");
|
2018-10-17 08:15:23 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
eInfo.defenseDamageProbability = entity.getLong("defense_damage_probability").intValue();
|
|
|
|
if(eInfo.defenseDamageProbability < 0 || eInfo.defenseDamageProbability > 100)
|
|
|
|
{
|
|
|
|
eInfo.defenseDamageProbability = 35;
|
|
|
|
logEntityInvalidValue("defense_damage_probability", eInfo.classType.getName(), "35");
|
|
|
|
}
|
2018-10-17 08:15:23 +00:00
|
|
|
}
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
catch (NullPointerException e)
|
2018-10-16 05:02:44 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
eInfo.defenseDamage = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
eInfo.evasion = entity.getLong("evasion").intValue();
|
|
|
|
if(eInfo.evasion < 0 || eInfo.evasion > 100)
|
2018-10-16 05:02:44 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
eInfo.evasion = 20;
|
|
|
|
logEntityInvalidValue("evasion", eInfo.classType.getName(), "20");
|
2018-10-16 05:02:44 +00:00
|
|
|
}
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
catch (NullPointerException e)
|
2018-09-14 03:44:45 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
logEntityMissingRequiredValue("evasion", eInfo.classType.getName());
|
|
|
|
continue;
|
2018-09-14 03:44:45 +00:00
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
|
|
|
try
|
2018-09-18 06:56:06 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
eInfo.speed = entity.getLong("speed").intValue();
|
2018-09-18 06:56:06 +00:00
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
catch (NullPointerException e)
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
logEntityMissingRequiredValue("speed", eInfo.classType.getName());
|
2018-09-03 06:19:33 +00:00
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
|
|
|
try
|
2018-09-14 05:14:10 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
eInfo.ignoreBattle = entity.getBoolean("ignore_battle");
|
2018-09-14 05:14:10 +00:00
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
catch (NullPointerException e)
|
2018-09-04 06:21:49 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
eInfo.ignoreBattle = false;
|
2018-09-04 06:21:49 +00:00
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
|
|
|
eInfo.category = entity.getString("category");
|
|
|
|
if(eInfo.category == null)
|
2018-09-05 06:54:06 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
logEntityMissingRequiredValue("category", eInfo.classType.getName());
|
|
|
|
continue;
|
2018-09-05 06:54:06 +00:00
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
|
|
|
try
|
2018-09-05 06:54:06 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
eInfo.decisionAttack = entity.getLong("decision_attack_probability").intValue();
|
2018-09-05 06:54:06 +00:00
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
catch (NullPointerException e)
|
2018-09-05 06:54:06 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
logEntityMissingRequiredValue("decision_attack_probability", eInfo.classType.getName());
|
|
|
|
continue;
|
2018-09-05 06:54:06 +00:00
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
|
|
|
try
|
2018-09-13 05:52:48 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
eInfo.decisionDefend = entity.getLong("decision_defend_probability").intValue();
|
2018-09-13 05:52:48 +00:00
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
catch (NullPointerException e)
|
2018-09-25 05:55:24 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
logEntityMissingRequiredValue("decision_defend_probability", eInfo.classType.getName());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
eInfo.decisionFlee = entity.getLong("decision_flee_probability").intValue();
|
|
|
|
}
|
|
|
|
catch (NullPointerException e)
|
|
|
|
{
|
|
|
|
logEntityMissingRequiredValue("decision_flee_probability", eInfo.classType.getName());
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
entityInfoMap.put(eInfo.classType.getName(), eInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void logNotFound(String option)
|
|
|
|
{
|
|
|
|
logger.warn("Config option \"" + option + "\" not found, setting defaults");
|
|
|
|
}
|
|
|
|
|
|
|
|
private void logNotFound(String option, String defaultValue)
|
|
|
|
{
|
|
|
|
logger.warn("Config option \"" + option + "\" not found, defaulting to \"" + defaultValue + "\"");
|
|
|
|
}
|
|
|
|
|
|
|
|
private void logEntityInvalidValue(String option, String name, String defaultValue)
|
|
|
|
{
|
|
|
|
logger.warn("Invalid \"" + option + "\" for \"" + name + "\", defaulting to " + defaultValue);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void logEntityMissingRequiredValue(String option, String name)
|
|
|
|
{
|
|
|
|
logger.error("Entity \"" + name + "\" does not have option \"" + option + "\", skipping...");
|
|
|
|
}
|
|
|
|
|
|
|
|
private String getRegexEntityName(String name)
|
|
|
|
{
|
|
|
|
String regex = "^\\s*name\\s*=\\s*";
|
|
|
|
regex += "(\"" + name + "\"";
|
|
|
|
regex += "|'" + name + "')";
|
|
|
|
return regex;
|
|
|
|
}
|
|
|
|
|
|
|
|
private boolean addEntityEntry(EntityInfo eInfo)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
File config = new File(TurnBasedMinecraftMod.CONFIG_FILE_PATH);
|
|
|
|
FileWriter fw = new FileWriter(config, true);
|
|
|
|
fw.write("[[server_config.entity]]\n");
|
|
|
|
fw.write("name = \"" + eInfo.classType.getName() + "\"\n");
|
|
|
|
fw.write("attack_power = " + eInfo.attackPower + "\n");
|
|
|
|
fw.write("attack_probability = " + eInfo.attackProbability + "\n");
|
|
|
|
if(eInfo.attackVariance > 0)
|
|
|
|
{
|
|
|
|
fw.write("attack_variance = " + eInfo.attackVariance + "\n");
|
|
|
|
}
|
|
|
|
if(eInfo.attackEffect != EntityInfo.Effect.UNKNOWN && eInfo.attackEffectProbability > 0)
|
|
|
|
{
|
|
|
|
fw.write("attack_effect = \"" + eInfo.attackEffect.toString() + "\"\n");
|
|
|
|
fw.write("attack_effect_probability = " + eInfo.attackEffectProbability + "\n");
|
|
|
|
}
|
|
|
|
if(eInfo.defenseDamage > 0 && eInfo.defenseDamageProbability > 0)
|
|
|
|
{
|
|
|
|
fw.write("defense_damage = " + eInfo.defenseDamage + "\n");
|
|
|
|
fw.write("defense_damage_probability = " + eInfo.defenseDamageProbability + "\n");
|
|
|
|
}
|
|
|
|
fw.write("evasion = " + eInfo.evasion + "\n");
|
|
|
|
fw.write("speed = " + eInfo.speed + "\n");
|
|
|
|
if(eInfo.ignoreBattle)
|
|
|
|
{
|
|
|
|
fw.write("ignoreBattle = true\n");
|
|
|
|
}
|
|
|
|
fw.write("category = \"" + eInfo.category + "\"\n");
|
|
|
|
fw.write("decision_attack_probability = " + eInfo.decisionAttack + "\n");
|
|
|
|
fw.write("decision_defend_probability = " + eInfo.decisionDefend + "\n");
|
|
|
|
fw.write("decision_flee_probability = " + eInfo.decisionFlee + "\n");
|
|
|
|
fw.close();
|
|
|
|
|
|
|
|
entityInfoMap.put(eInfo.classType.getName(), eInfo);
|
|
|
|
}
|
|
|
|
catch (Throwable t)
|
|
|
|
{
|
|
|
|
logger.error("Failed to add entity entry (name = \"" + eInfo.classType.getName() + "\")");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected boolean editEntityEntry(EntityInfo eInfo)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
String cached = new String();
|
|
|
|
char buf[] = new char[1024];
|
|
|
|
int read = 0;
|
|
|
|
File config = new File(TurnBasedMinecraftMod.CONFIG_FILE_PATH);
|
|
|
|
{
|
|
|
|
FileReader fr = new FileReader(config);
|
|
|
|
read = fr.read(buf);
|
|
|
|
while (read != -1)
|
|
|
|
{
|
|
|
|
cached += String.valueOf(buf, 0, read);
|
|
|
|
read = fr.read(buf);
|
|
|
|
}
|
|
|
|
fr.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
int nameIndex = -1;
|
|
|
|
{
|
|
|
|
Pattern p = Pattern.compile(getRegexEntityName(eInfo.classType.getName()), Pattern.MULTILINE);
|
|
|
|
Matcher m = p.matcher(cached);
|
|
|
|
if(m.find())
|
|
|
|
{
|
|
|
|
nameIndex = m.start();
|
2018-09-25 05:55:24 +00:00
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
}
|
|
|
|
int entryIndex = -1;
|
|
|
|
int nextIndex = -1;
|
|
|
|
if(nameIndex != -1)
|
|
|
|
{
|
2018-09-28 03:02:39 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
Pattern p = Pattern.compile("^\\s*\\[\\[\\s*server_config\\s*\\.\\s*entity\\s*]]", Pattern.MULTILINE);
|
|
|
|
Matcher m = p.matcher(cached.substring(0, nameIndex));
|
|
|
|
while(m.find())
|
2018-09-28 03:02:39 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
entryIndex = m.start();
|
2018-09-28 03:02:39 +00:00
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
if(entryIndex == -1)
|
2018-09-28 03:02:39 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
logger.warn("editEntityEntry: could not find header for entry \"" + eInfo.classType.getName() + "\", skipping to adding it...");
|
|
|
|
return addEntityEntry(eInfo);
|
2018-09-28 03:02:39 +00:00
|
|
|
}
|
|
|
|
}
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
Pattern p = Pattern.compile("^\\s*\\[", Pattern.MULTILINE);
|
|
|
|
Matcher m = p.matcher(cached.substring(nameIndex));
|
|
|
|
if(m.find())
|
2018-09-03 06:19:33 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
nextIndex = m.start() + nameIndex;
|
2018-09-20 06:36:31 +00:00
|
|
|
}
|
2018-09-03 06:19:33 +00:00
|
|
|
}
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
logger.warn("editEntityEntry: could not find entry for \"" + eInfo.classType.getName() + "\", skipping to adding it...");
|
|
|
|
return addEntityEntry(eInfo);
|
|
|
|
}
|
|
|
|
|
|
|
|
String cut = null;
|
|
|
|
if(nextIndex != -1)
|
|
|
|
{
|
|
|
|
cut = cached.substring(0, entryIndex) + cached.substring(nextIndex);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
cut = cached.substring(0, entryIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
FileWriter fw = new FileWriter(config);
|
|
|
|
fw.write(cut);
|
|
|
|
fw.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
return addEntityEntry(eInfo);
|
|
|
|
}
|
|
|
|
catch (Throwable t)
|
|
|
|
{
|
|
|
|
return false;
|
2018-09-03 06:19:33 +00:00
|
|
|
}
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-04 06:21:49 +00:00
|
|
|
public int getPlayerSpeed()
|
|
|
|
{
|
|
|
|
return playerSpeed;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getPlayerHasteSpeed()
|
|
|
|
{
|
|
|
|
return playerHasteSpeed;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getPlayerSlowSpeed()
|
|
|
|
{
|
|
|
|
return playerSlowSpeed;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-05 06:54:06 +00:00
|
|
|
public int getPlayerAttackProbability()
|
|
|
|
{
|
|
|
|
return playerAttackProbability;
|
|
|
|
}
|
2018-09-04 06:21:49 +00:00
|
|
|
|
2018-09-05 06:54:06 +00:00
|
|
|
public int getPlayerEvasion()
|
|
|
|
{
|
|
|
|
return playerEvasion;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-05 06:54:06 +00:00
|
|
|
public int getDefenseDuration()
|
|
|
|
{
|
|
|
|
return defenseDuration;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-05 06:54:06 +00:00
|
|
|
public int getFleeGoodProbability()
|
|
|
|
{
|
|
|
|
return fleeGoodProbability;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-05 06:54:06 +00:00
|
|
|
public int getFleeBadProbability()
|
|
|
|
{
|
|
|
|
return fleeBadProbability;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-04 06:21:49 +00:00
|
|
|
/**
|
|
|
|
* Returns a clone of an EntityInfo (to prevent editing it).
|
|
|
|
* @param classFullName
|
|
|
|
* @return a clone of the stored EntityInfo or null if invalid String
|
|
|
|
*/
|
|
|
|
public EntityInfo getEntityInfo(String classFullName)
|
|
|
|
{
|
|
|
|
return entityInfoMap.get(classFullName).clone();
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-04 06:21:49 +00:00
|
|
|
protected EntityInfo getEntityInfoReference(String classFullName)
|
|
|
|
{
|
|
|
|
return entityInfoMap.get(classFullName);
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-04 06:21:49 +00:00
|
|
|
protected EntityInfo getMatchingEntityInfo(Object entity)
|
|
|
|
{
|
2018-09-06 08:08:36 +00:00
|
|
|
if(entity == null)
|
|
|
|
{
|
|
|
|
return null;
|
|
|
|
}
|
2018-09-04 06:21:49 +00:00
|
|
|
EntityInfo matching = entityInfoMap.get(entity.getClass().getName());
|
2018-09-12 05:43:59 +00:00
|
|
|
if(matching != null && matching.classType.isInstance(entity))
|
2018-09-04 06:21:49 +00:00
|
|
|
{
|
|
|
|
return matching;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
|
|
|
private int getConfigFileVersion(InputStream io)
|
2018-09-07 07:41:22 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
int version = 0;
|
2018-09-07 07:41:22 +00:00
|
|
|
try
|
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
TomlParseResult result = Toml.parse(io, TomlVersion.V0_5_0);
|
|
|
|
version = result.getLong("version").intValue();
|
|
|
|
}
|
|
|
|
catch (Throwable t)
|
2018-09-07 07:41:22 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
// ignored
|
2018-09-07 07:41:22 +00:00
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
return version;
|
2018-09-07 07:41:22 +00:00
|
|
|
}
|
|
|
|
|
2018-10-20 08:54:32 +00:00
|
|
|
private int getConfigFileVersion(File configFile)
|
|
|
|
{
|
|
|
|
int version = 0;
|
2018-09-07 07:41:22 +00:00
|
|
|
try
|
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
TomlParseResult result = Toml.parse(configFile.toPath(), TomlVersion.V0_5_0);
|
|
|
|
version = result.getLong("version").intValue();
|
|
|
|
}
|
|
|
|
catch (Throwable t)
|
2018-09-07 07:41:22 +00:00
|
|
|
{
|
2018-10-20 08:54:32 +00:00
|
|
|
// ignored
|
2018-09-07 07:41:22 +00:00
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
return version;
|
2018-09-07 07:41:22 +00:00
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-13 05:12:04 +00:00
|
|
|
public boolean isIgnoreBattleType(String type)
|
2018-09-12 05:43:59 +00:00
|
|
|
{
|
|
|
|
return ignoreBattleTypes.contains(type);
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-13 05:52:48 +00:00
|
|
|
public int getMinimumHitPercentage()
|
|
|
|
{
|
|
|
|
return minimumHitPercentage;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-14 03:44:45 +00:00
|
|
|
public int getMaxInBattle()
|
|
|
|
{
|
|
|
|
return maxInBattle;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-14 05:14:10 +00:00
|
|
|
public boolean isBattleMusicType(String type)
|
|
|
|
{
|
|
|
|
return musicBattleTypes.contains(type.toLowerCase());
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-14 05:14:10 +00:00
|
|
|
public boolean isSillyMusicType(String type)
|
|
|
|
{
|
|
|
|
return musicSillyTypes.contains(type.toLowerCase());
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-18 06:56:06 +00:00
|
|
|
public boolean isFreezeCombatantsEnabled()
|
|
|
|
{
|
|
|
|
return freezeCombatantsInBattle;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-28 03:02:39 +00:00
|
|
|
public int getSillyMusicThreshold()
|
|
|
|
{
|
|
|
|
return sillyMusicThreshold;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-28 08:45:32 +00:00
|
|
|
public int getConfigVersion()
|
|
|
|
{
|
|
|
|
return configVersion;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-28 08:45:32 +00:00
|
|
|
public long getDecisionDurationNanos()
|
|
|
|
{
|
|
|
|
return battleDecisionDurationNanos;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-09-28 08:45:32 +00:00
|
|
|
public int getDecisionDurationSeconds()
|
|
|
|
{
|
|
|
|
return (int)(battleDecisionDurationNanos / 1000000000L);
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-10-16 05:02:44 +00:00
|
|
|
protected void addBattleIgnoringPlayer(int id)
|
|
|
|
{
|
|
|
|
battleIgnoringPlayers.add(id);
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-10-16 05:02:44 +00:00
|
|
|
protected void removeBattleIgnoringPlayer(int id)
|
|
|
|
{
|
|
|
|
battleIgnoringPlayers.remove(id);
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-10-16 05:02:44 +00:00
|
|
|
protected void clearBattleIgnoringPlayers()
|
|
|
|
{
|
|
|
|
battleIgnoringPlayers.clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected Set<Integer> getBattleIgnoringPlayers()
|
|
|
|
{
|
|
|
|
return battleIgnoringPlayers;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-10-16 05:02:44 +00:00
|
|
|
public boolean getIfOnlyOPsCanDisableTurnBasedForSelf()
|
|
|
|
{
|
|
|
|
return onlyOPsSelfDisableTB;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-10-17 03:19:16 +00:00
|
|
|
protected void setBattleDisabledForAll(boolean isDisabled)
|
|
|
|
{
|
|
|
|
battleDisabledForAll = isDisabled;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-10-17 03:19:16 +00:00
|
|
|
protected boolean getBattleDisabledForAll()
|
|
|
|
{
|
|
|
|
return battleDisabledForAll;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-10-17 08:15:23 +00:00
|
|
|
public boolean isOldBattleBehaviorEnabled()
|
|
|
|
{
|
|
|
|
return oldBattleBehaviorEnabled;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-10-17 09:28:47 +00:00
|
|
|
public int getLeaveBattleCooldownSeconds()
|
|
|
|
{
|
|
|
|
return leaveBattleCooldownSeconds;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-10-17 09:28:47 +00:00
|
|
|
public long getLeaveBattleCooldownNanos()
|
|
|
|
{
|
|
|
|
return (long)leaveBattleCooldownSeconds * 1000000000L;
|
|
|
|
}
|
2018-10-20 08:54:32 +00:00
|
|
|
|
2018-10-18 07:26:09 +00:00
|
|
|
public int getAggroStartBattleDistance()
|
|
|
|
{
|
|
|
|
return aggroStartBattleDistance;
|
|
|
|
}
|
2018-09-03 06:19:33 +00:00
|
|
|
}
|