mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-02-16 20:41:56 +01:00
Remove all of the obsolete and commented out code in WaveUtils.
This commit is contained in:
parent
13e3c180e5
commit
beb4269525
@ -79,366 +79,6 @@ public class WaveUtils
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Grab and process all the waves in the config-file for the arena.
|
||||
*/
|
||||
/*public static TreeSet<Wave> getWaves(Arena arena, Config config, WaveBranch branch)
|
||||
{
|
||||
MobArena plugin = arena.getPlugin();
|
||||
// Determine the branch type of the wave, and grab the appropriate comparator
|
||||
String b = branch.toString().toLowerCase();
|
||||
TreeSet<Wave> result = new TreeSet<Wave>(getComparator(branch));
|
||||
|
||||
// Grab the waves from the config-file
|
||||
String path = "arenas." + arena.configName() + ".waves." + b; // waves.yml, change to either "waves." + b, or simply b
|
||||
Set<String> waves = config.getKeys(path);
|
||||
|
||||
// If there are any waves, process them
|
||||
if (waves != null)
|
||||
{
|
||||
Wave wave;
|
||||
for (String w : waves)
|
||||
{
|
||||
// ---------- path ----------- -- w --
|
||||
// path argument becomes: "arenas.<arena>.waves.<branch>.<wave>."
|
||||
wave = getWave(arena, config, path + "." + w + ".", w, branch);
|
||||
if (wave != null)
|
||||
result.add(wave);
|
||||
else plugin.warning("Wave '" + w + "' in " + path + " was not added!");
|
||||
}
|
||||
}
|
||||
|
||||
// If there are no waves and the type is 'recurrent', add a couple of auto-generated waves.
|
||||
if (branch == WaveBranch.RECURRENT && (result.isEmpty() || waves == null))
|
||||
{
|
||||
plugin.info("No valid recurrent waves detected for arena '" + arena.configName() + "'. Using defaults...");
|
||||
DefaultWave def = new DefaultWave(arena, "DEF_WAVE_AUTO", 1, 1, 1, config, path + ".DEF_WAVE_AUTO.");
|
||||
SpecialWave spec = new SpecialWave(arena, "SPEC_WAVE_AUTO", 4, 4, 2, config, path + ".SPEC_WAVE_AUTO.");
|
||||
result.add(def);
|
||||
result.add(spec);
|
||||
}
|
||||
|
||||
return result;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Get a single wave based on the config-file, the path, and branch
|
||||
* @return A Wave object if it is well defined, null otherwise.
|
||||
*/
|
||||
/*private static Wave getWave(Arena arena, Config config, String path, String name, WaveBranch branch)
|
||||
{
|
||||
MobArena plugin = arena.getPlugin();
|
||||
|
||||
// Grab the wave type, if null or not well defined, return null
|
||||
WaveType type = WaveType.fromString(config.getString(path + "type"));
|
||||
if (type == null || !isWaveWellDefined(plugin, config, path, branch, type))
|
||||
return null;
|
||||
|
||||
Wave result = null;
|
||||
if (branch == WaveBranch.RECURRENT)
|
||||
{
|
||||
int frequency = config.getInt(path + "frequency", 0);
|
||||
int priority = config.getInt(path + "priority", 0);
|
||||
int wave = MAUtils.getInt(config, path + "wave");
|
||||
|
||||
if (type == WaveType.DEFAULT)
|
||||
result = new DefaultWave(arena, name, wave, frequency, priority, config, path);
|
||||
else if (type == WaveType.SPECIAL)
|
||||
result = new SpecialWave(arena, name, wave, frequency, priority, config, path);
|
||||
else if (type == WaveType.SWARM)
|
||||
result = new SwarmWave(arena, name, wave, frequency, priority, config, path);
|
||||
else if (type == WaveType.BOSS)
|
||||
result = new BossWave(arena, name, wave, frequency, priority, config, path);
|
||||
}
|
||||
else
|
||||
{
|
||||
int wave = MAUtils.getInt(config, path + "wave");
|
||||
|
||||
if (type == WaveType.DEFAULT)
|
||||
result = new DefaultWave(arena, name, wave, config, path);
|
||||
else if (type == WaveType.SPECIAL)
|
||||
result = new SpecialWave(arena, name, wave, config, path);
|
||||
else if (type == WaveType.SWARM)
|
||||
result = new SwarmWave(arena, name, wave, config, path);
|
||||
else if (type == WaveType.BOSS)
|
||||
result = new BossWave(arena, name, wave, config, path);
|
||||
}
|
||||
return result;
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
/*////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Well definedness checks
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
/**
|
||||
* Check if a wave in the config-file is well-defined.
|
||||
* The method first checks if the wave is well-defined according to
|
||||
* the branch-specific requirements. Recurrent waves must have the
|
||||
* two nodes 'priority' and 'frequency', and single waves must have
|
||||
* the node 'wave'.
|
||||
* Any other requirements are type-specific, and thus we check if the
|
||||
* type is well-defined.
|
||||
* @param config Config-file Config
|
||||
* @param path The absolute path of the wave
|
||||
* @param branch The branch of the wave
|
||||
* @param type The wave type
|
||||
* @return true, only if the entire wave-node is well-defined.
|
||||
*/
|
||||
/*private static boolean isWaveWellDefined(MobArena plugin, Config config, String path, WaveBranch branch, WaveType type)
|
||||
{
|
||||
// This boolean is used in the "leaf methods"
|
||||
boolean wellDefined = true;
|
||||
|
||||
// OPTIONAL: Health multiplier
|
||||
int hMulti = MAUtils.getInt(config, path + "health-multiplier");
|
||||
if (hMulti < 0)
|
||||
{
|
||||
plugin.warning("Invalid health multiplier '" + hMulti + "' in " + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
|
||||
// OPTIONAL: Amount multiplier
|
||||
int aMulti = MAUtils.getInt(config, path + "amount-multiplier");
|
||||
if (aMulti < 0)
|
||||
{
|
||||
plugin.warning("Invalid amount multiplier '" + aMulti + "' in " + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
|
||||
// Branch-specific nodes.
|
||||
if (branch == WaveBranch.RECURRENT)
|
||||
{
|
||||
// REQUIRED: Priority and frequency
|
||||
int priority = config.getInt(path + "priority", 0);
|
||||
int frequency = config.getInt(path + "frequency", 0);
|
||||
if (priority == 0)
|
||||
{
|
||||
plugin.warning("Missing 'priority'-node in " + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
if (frequency == 0)
|
||||
{
|
||||
plugin.warning("Missing 'frequency'-node in " + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
|
||||
// OPTIONAL: Wave
|
||||
int wave = MAUtils.getInt(config, path + "wave");
|
||||
if (wave < 0)
|
||||
{
|
||||
plugin.warning("'wave' must be greater than 0 in " + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
}
|
||||
else if (branch == WaveBranch.SINGLE)
|
||||
{
|
||||
// REQUIRED: Wave number
|
||||
int wave = MAUtils.getInt(config, path + "wave");
|
||||
if (wave == 0)
|
||||
{
|
||||
plugin.warning("Missing 'wave'-node in " + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
else if (wave < 0)
|
||||
{
|
||||
plugin.warning("'wave' must be greater than 0 in " + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
}
|
||||
else wellDefined = false;
|
||||
|
||||
// Passed branch-checks; check type
|
||||
return isTypeWellDefined(plugin, config, path, type, wellDefined);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Check if a wave type in the config-file is well-defined.
|
||||
* The method calls the appropriate sub-method to check if the type
|
||||
* is well-defined.
|
||||
* @param config Config-file Config
|
||||
* @param path The absolute path of the wave
|
||||
* @param type The wave type
|
||||
* @param wellDefined Pass-through boolean for "leaf methods".
|
||||
* @return true, only if the entire wave-node is well-defined.
|
||||
*/
|
||||
/*private static boolean isTypeWellDefined(MobArena plugin, Config config, String path, WaveType type, boolean wellDefined)
|
||||
{
|
||||
if (type == WaveType.DEFAULT)
|
||||
return isDefaultWaveWellDefined(plugin, config, path, wellDefined);
|
||||
else if (type == WaveType.SPECIAL)
|
||||
return isSpecialWaveWellDefined(plugin, config, path, wellDefined);
|
||||
else if (type == WaveType.BOSS)
|
||||
return isBossWaveWellDefined(plugin, config, path, wellDefined);
|
||||
else if (type == WaveType.SWARM)
|
||||
return isSwarmWaveWellDefined(plugin, config, path, wellDefined);
|
||||
|
||||
return false;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Check if a default wave is well-defined.
|
||||
* The default waves have an optional wave growth node. Otherwise,
|
||||
* they share nodes with special waves.
|
||||
* @param config Config-file Config
|
||||
* @param path The absolute path of the wave
|
||||
* @param wellDefined Pass-through boolean for "leaf methods".
|
||||
* @return true, only if the entire wave-node is well-defined.
|
||||
*/
|
||||
/*private static boolean isDefaultWaveWellDefined(MobArena plugin, Config config, String path, boolean wellDefined)
|
||||
{
|
||||
// OPTIONAL: Wave growth
|
||||
String growth = config.getString(path + "growth");
|
||||
if (growth != null && WaveGrowth.fromString(growth) == null)
|
||||
{
|
||||
plugin.warning("Invalid wave growth '" + growth + "' in " + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
|
||||
return isNormalWaveWellDefined(plugin, config, path, wellDefined);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Check if a special wave is well-defined.
|
||||
* The special waves have no unique nodes.
|
||||
* @param config Config-file Config
|
||||
* @param path The absolute path of the wave
|
||||
* @param wellDefined Pass-through boolean for "leaf methods".
|
||||
* @return true, only if the entire wave-node is well-defined.
|
||||
*/
|
||||
/*private static boolean isSpecialWaveWellDefined(MobArena plugin, Config config, String path, boolean wellDefined)
|
||||
{
|
||||
return isNormalWaveWellDefined(plugin, config, path, wellDefined);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Check if a default or special wave is well-defined.
|
||||
* There are no REQUIRED nodes for default or special wave types, besides
|
||||
* the ones for the branch they belong to.
|
||||
* The only OPTIONAL node is (currently) 'monsters'
|
||||
* @param config Config-file Config
|
||||
* @param path The absolute path of the wave
|
||||
* @param wellDefined Pass-through boolean for "leaf methods".
|
||||
* @return true, wellDefined is true.
|
||||
*/
|
||||
/*private static boolean isNormalWaveWellDefined(MobArena plugin, Config config, String path, boolean wellDefined)
|
||||
{
|
||||
// OPTIONAL: Monsters
|
||||
Set<String> monsters = config.getKeys(path + "monsters");
|
||||
if (monsters != null)
|
||||
{
|
||||
for (String monster : monsters)
|
||||
{
|
||||
if (MACreature.fromString(monster) != null)
|
||||
continue;
|
||||
|
||||
plugin.warning("Invalid monster type '" + monster + "' in " + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
}
|
||||
else plugin.info("No monsters listed in " + path + ", using defaults...");
|
||||
|
||||
return wellDefined;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Check if a swarm wave is well defined
|
||||
* @param config Config-file Config
|
||||
* @param path The absolute path of the wave
|
||||
* @param wellDefined Pass-through boolean for "leaf methods".
|
||||
* @return true, wellDefined is true.
|
||||
*/
|
||||
/*private static boolean isSwarmWaveWellDefined(MobArena plugin, Config config, String path, boolean wellDefined)
|
||||
{
|
||||
// REQUIRED: Monster type
|
||||
String monster = config.getString(path + "monster");
|
||||
if (monster == null)
|
||||
{
|
||||
plugin.warning("Missing monster type in '" + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
else if (MACreature.fromString(monster) == null)
|
||||
{
|
||||
plugin.warning("Invalid monster type '" + monster + "' in " + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
|
||||
// OPTIONAL: Amount
|
||||
String amount = config.getString(path + "amount");
|
||||
if (amount != null && SwarmAmount.fromString(amount) == null)
|
||||
{
|
||||
plugin.warning("Invalid swarm amount '" + amount + "' in " + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
|
||||
return wellDefined;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Check if a boss wave is well defined.
|
||||
* @param config Config-file Config
|
||||
* @param path The absolute path of the wave
|
||||
* @param wellDefined Pass-through boolean for "leaf methods".
|
||||
* @return true, wellDefined is true.
|
||||
*/
|
||||
/*private static boolean isBossWaveWellDefined(MobArena plugin, Config config, String path, boolean wellDefined)
|
||||
{
|
||||
// REQUIRED: Monster type
|
||||
String monster = config.getString(path + "monster");
|
||||
if (monster == null)
|
||||
{
|
||||
plugin.warning("Missing monster type in '" + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
else if (MACreature.fromString(monster) == null)
|
||||
{
|
||||
plugin.warning("Invalid monster type '" + monster + "' in " + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
|
||||
// OPTIONAL: Abilities
|
||||
String abilities = config.getString(path + "abilities");
|
||||
if (abilities != null)
|
||||
{
|
||||
for (String ability : abilities.split(","))
|
||||
{
|
||||
if (BossAbility.fromString(ability.trim()) != null)
|
||||
continue;
|
||||
|
||||
plugin.warning("Invalid boss ability '" + ability + "' in " + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
}
|
||||
|
||||
// OPTIONAL: Ability-interval
|
||||
int abilityDelay = config.getInt(path + "ability-interval", 3);
|
||||
if (abilityDelay <= 0)
|
||||
{
|
||||
plugin.warning("Boss ability-delay must be greater than 0, " + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
|
||||
// OPTIONAL: Ability-announce
|
||||
|
||||
// TODO: OPTIONAL: Adds
|
||||
// Unsure about config-file implementation...
|
||||
|
||||
// OPTIONAL: Health
|
||||
String health = config.getString(path + "health");
|
||||
if (health != null && BossHealth.fromString(health) == null)
|
||||
{
|
||||
plugin.warning("Invalid boss health '" + health + "' in " + path);
|
||||
wellDefined = false;
|
||||
}
|
||||
|
||||
return wellDefined;
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
/*////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Comparators
|
||||
@ -499,60 +139,4 @@ public class WaveUtils
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Misc - Perhaps move into MAUtils?
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////*/
|
||||
|
||||
/**
|
||||
* Get the num value of a string, def if it doesn't exist.
|
||||
*/
|
||||
public static <T extends Enum<T>> T getEnumFromString(Class<T> c, String string, T def)
|
||||
{
|
||||
if (c != null && string != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Enum.valueOf(c, string.trim().toUpperCase());
|
||||
}
|
||||
catch (IllegalArgumentException ex) { }
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the enum value of a string, null if it doesn't exist.
|
||||
*/
|
||||
public static <T extends Enum<T>> T getEnumFromString(Class<T> c, String string)
|
||||
{
|
||||
if(c != null && string != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Enum.valueOf(c, string.trim().toUpperCase());
|
||||
}
|
||||
catch(IllegalArgumentException ex) { }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the enum value of a string, null if it doesn't exist.
|
||||
*/
|
||||
public static <T extends Enum<T>> T getEnumFromStringCaseSensitive(Class<T> c, String string)
|
||||
{
|
||||
if(c != null && string != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Enum.valueOf(c, string);
|
||||
}
|
||||
catch(IllegalArgumentException ex) { }
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user