From 185c432eca39a70e106b22260b650bc387f83f3e Mon Sep 17 00:00:00 2001 From: Alexander Meech Date: Thu, 15 Aug 2019 10:01:22 -0400 Subject: [PATCH] Port water abilities to new configuration system & slightly improve the new system --- .../projectkorra/GeneralMethods.java | 38 +++---- .../projectkorra/ProjectKorra.java | 4 +- .../projectkorra/ability/ComboAbility.java | 11 +- .../projectkorra/ability/WaterAbility.java | 17 --- .../airbending/combo/AirStream.java | 7 +- .../airbending/combo/AirSweep.java | 7 +- .../airbending/combo/Twister.java | 7 +- .../chiblocking/combo/Immobilize.java | 7 +- .../configuration/better/ConfigManager.java | 55 ++++----- .../configs/abilities/EmptyAbilityConfig.java | 19 ++++ .../abilities/air/AirAgilityConfig.java | 2 +- .../abilities/air/AirSaturationConfig.java | 2 +- .../abilities/air/AirShieldConfig.java | 2 +- .../configs/abilities/air/AirSpoutConfig.java | 2 +- .../abilities/air/AirStreamConfig.java | 2 +- .../abilities/air/AirSuctionConfig.java | 2 +- .../configs/abilities/air/AirSweepConfig.java | 2 +- .../configs/abilities/air/AirSwipeConfig.java | 2 +- .../configs/abilities/air/FlightConfig.java | 2 +- .../abilities/air/GracefulDescentConfig.java | 2 +- .../abilities/air/SuffocateConfig.java | 2 +- .../configs/abilities/air/TornadoConfig.java | 2 +- .../configs/abilities/air/TwisterConfig.java | 2 +- .../abilities/chi/AcrobaticsConfig.java | 2 +- .../abilities/chi/ChiAgilityConfig.java | 2 +- .../abilities/chi/ChiSaturationConfig.java | 2 +- .../abilities/water/BloodbendingConfig.java | 31 +++++ .../abilities/water/FastSwimConfig.java | 25 +++++ .../abilities/water/HealingWatersConfig.java | 29 +++++ .../abilities/water/HydroSinkConfig.java | 21 ++++ .../abilities/water/IceBlastConfig.java | 33 ++++++ .../abilities/water/IceBulletConfig.java | 32 ++++++ .../abilities/water/IceSpikeConfig.java | 79 +++++++++++++ .../abilities/water/IceWaveConfig.java | 30 +++++ .../abilities/water/OctopusFormConfig.java | 37 ++++++ .../abilities/water/PhaseChangeConfig.java | 45 ++++++++ .../configs/abilities/water/SurgeConfig.java | 53 +++++++++ .../abilities/water/TorrentConfig.java | 56 +++++++++ .../abilities/water/WaterArmsConfig.java | 106 ++++++++++++++++++ .../abilities/water/WaterBubbleConfig.java | 26 +++++ .../water/WaterManipulationConfig.java | 15 ++- .../abilities/water/WaterSpoutConfig.java | 47 ++++++++ .../properties/GeneralPropertiesConfig.java | 56 ++++++--- .../properties/WaterPropertiesConfig.java | 5 + .../projectkorra/storage/DBConnection.java | 12 +- .../waterbending/OctopusForm.java | 56 ++++----- .../projectkorra/waterbending/SurgeWall.java | 38 +++---- .../projectkorra/waterbending/SurgeWave.java | 34 +++--- .../projectkorra/waterbending/Torrent.java | 59 +++++----- .../waterbending/TorrentWave.java | 24 ++-- .../waterbending/WaterBubble.java | 16 +-- .../waterbending/WaterManipulation.java | 34 +++--- .../projectkorra/waterbending/WaterSpout.java | 24 ++-- .../waterbending/WaterSpoutWave.java | 64 +++++++---- .../waterbending/blood/Bloodbending.java | 29 ++--- .../waterbending/combo/IceBullet.java | 35 +++--- .../waterbending/combo/IceWave.java | 15 +-- .../waterbending/healing/HealingWaters.java | 22 ++-- .../waterbending/ice/IceBlast.java | 27 ++--- .../waterbending/ice/IceSpikeBlast.java | 53 +++++---- .../waterbending/ice/IceSpikePillar.java | 43 +++---- .../waterbending/ice/IceSpikePillarField.java | 21 ++-- .../waterbending/ice/PhaseChange.java | 48 ++++---- .../multiabilities/WaterArms.java | 53 ++++----- .../multiabilities/WaterArmsFreeze.java | 15 +-- .../multiabilities/WaterArmsSpear.java | 42 +++---- .../multiabilities/WaterArmsWhip.java | 41 +++---- .../waterbending/passive/FastSwim.java | 17 +-- .../waterbending/passive/HydroSink.java | 12 +- .../waterbending/plant/PlantRegrowth.java | 9 +- .../waterbending/util/WaterReturn.java | 6 +- .../waterbending/util/WaterSourceGrabber.java | 1 + 72 files changed, 1259 insertions(+), 521 deletions(-) create mode 100644 src/com/projectkorra/projectkorra/configuration/better/configs/abilities/EmptyAbilityConfig.java create mode 100644 src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/BloodbendingConfig.java create mode 100644 src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/FastSwimConfig.java create mode 100644 src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/HealingWatersConfig.java create mode 100644 src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/HydroSinkConfig.java create mode 100644 src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/IceBlastConfig.java create mode 100644 src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/IceBulletConfig.java create mode 100644 src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/IceSpikeConfig.java create mode 100644 src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/IceWaveConfig.java create mode 100644 src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/OctopusFormConfig.java create mode 100644 src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/PhaseChangeConfig.java create mode 100644 src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/SurgeConfig.java create mode 100644 src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/TorrentConfig.java create mode 100644 src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/WaterArmsConfig.java create mode 100644 src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/WaterBubbleConfig.java create mode 100644 src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/WaterSpoutConfig.java diff --git a/src/com/projectkorra/projectkorra/GeneralMethods.java b/src/com/projectkorra/projectkorra/GeneralMethods.java index 27a552f3..804f38a1 100644 --- a/src/com/projectkorra/projectkorra/GeneralMethods.java +++ b/src/com/projectkorra/projectkorra/GeneralMethods.java @@ -1438,10 +1438,10 @@ public class GeneralMethods { isHarmless = coreAbil.isHarmlessAbility(); } - if (ability == null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_AllowHarmlessAbilities) { + if (ability == null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.AllowHarmlessAbilities) { return false; } - if (isHarmless && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_AllowHarmlessAbilities) { + if (isHarmless && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.AllowHarmlessAbilities) { return false; } @@ -1459,7 +1459,7 @@ public class GeneralMethods { for (final Location location : new Location[] { loc, player.getLocation() }) { final World world = location.getWorld(); - if (lwc != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectLWC) { + if (lwc != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.RespectLWC) { final LWCPlugin lwcp = (LWCPlugin) lwc; final LWC lwc2 = lwcp.getLWC(); final Protection protection = lwc2.getProtectionCache().getProtection(location.getBlock()); @@ -1469,7 +1469,7 @@ public class GeneralMethods { } } } - if (wgp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectWorldGuard && !player.hasPermission("worldguard.region.bypass." + world.getName())) { + if (wgp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.RespectWorldGuard && !player.hasPermission("worldguard.region.bypass." + world.getName())) { final WorldGuard wg = WorldGuard.getInstance(); if (!player.isOnline()) { return true; @@ -1507,7 +1507,7 @@ public class GeneralMethods { } } - if (facsfw != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectFactions) { + if (facsfw != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.RespectFactions) { final FPlayer fPlayer = FPlayers.getBySender(player); final Faction faction = Factions.getFactionAt(location); final Rel relation = fPlayer.getRelationTo(faction); @@ -1517,7 +1517,7 @@ public class GeneralMethods { } } - if (twnp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectTowny) { + if (twnp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.RespectTowny) { final Towny twn = (Towny) twnp; WorldCoord worldCoord; @@ -1553,7 +1553,7 @@ public class GeneralMethods { } } - if (gpp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectGriefPrevention) { + if (gpp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.RespectGriefPrevention) { Material type = player.getWorld().getBlockAt(location).getType(); if (type == null) { type = Material.AIR; @@ -1567,18 +1567,18 @@ public class GeneralMethods { } } - if (residence != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectResidence) { + if (residence != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.RespectResidence) { final ResidenceInterface res = Residence.getInstance().getResidenceManagerAPI(); final ClaimedResidence claim = res.getByLoc(location); if (claim != null) { final ResidencePermissions perms = claim.getPermissions(); - if (!perms.hasApplicableFlag(player.getName(), ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_ResidenceFlag)) { + if (!perms.hasApplicableFlag(player.getName(), ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.ResidenceFlag)) { return true; } } } - if (kingdoms != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectKingdoms) { + if (kingdoms != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.RespectKingdoms) { final KingdomPlayer kPlayer = GameManagement.getPlayerManager().getOfflineKingdomPlayer(player).getKingdomPlayer(); if (kPlayer.getKingdom() != null) { final SimpleChunkLocation chunkLocation = new SimpleChunkLocation(location.getChunk()); @@ -1593,7 +1593,7 @@ public class GeneralMethods { } - if (redprotect != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectRedProtect) { + if (redprotect != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.RespectRedProtect) { final RedProtectAPI api = RedProtect.get().getAPI(); final Region region = api.getRegion(location); if (!(region != null && region.canBuild(player))) { @@ -1875,28 +1875,28 @@ public class GeneralMethods { final Plugin kingdoms = pm.getPlugin("Kingdoms"); final Plugin redprotect = pm.getPlugin("RedProtect"); - if (wgp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectWorldGuard) { + if (wgp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.RespectWorldGuard) { writeToDebug("WorldGuard v" + wgp.getDescription().getVersion()); } - if (fcp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectFactions) { + if (fcp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.RespectFactions) { writeToDebug("FactionsFramework v" + fcp.getDescription().getVersion()); } - if (twnp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectTowny) { + if (twnp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.RespectTowny) { writeToDebug("Towny v" + twnp.getDescription().getVersion()); } - if (gpp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectGriefPrevention) { + if (gpp != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.RespectGriefPrevention) { writeToDebug("GriefPrevention v" + gpp.getDescription().getVersion()); } - if (lwc != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectLWC) { + if (lwc != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.RespectLWC) { writeToDebug("LWC v" + lwc.getDescription().getVersion()); } - if (residence != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectResidence) { + if (residence != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.RespectResidence) { writeToDebug("Residence v" + residence.getDescription().getVersion()); } - if (kingdoms != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectKingdoms) { + if (kingdoms != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.RespectKingdoms) { writeToDebug("Kingdoms v" + kingdoms.getDescription().getVersion()); } - if (redprotect != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection_RespectRedProtect) { + if (redprotect != null && ConfigManager.getConfig(GeneralPropertiesConfig.class).RegionProtection.RespectRedProtect) { writeToDebug("RedProtect v" + redprotect.getDescription().getVersion()); } diff --git a/src/com/projectkorra/projectkorra/ProjectKorra.java b/src/com/projectkorra/projectkorra/ProjectKorra.java index f0c79fee..934be73d 100644 --- a/src/com/projectkorra/projectkorra/ProjectKorra.java +++ b/src/com/projectkorra/projectkorra/ProjectKorra.java @@ -141,11 +141,11 @@ public class ProjectKorra extends JavaPlugin { }); if (Bukkit.getPluginManager().getPlugin("Residence") != null) { - FlagPermissions.addFlag(GENERAL_PROPERTIES.RegionProtection_ResidenceFlag); + FlagPermissions.addFlag(GENERAL_PROPERTIES.RegionProtection.ResidenceFlag); } GeneralMethods.deserializeFile(); - GeneralMethods.startCacheCleaner(GENERAL_PROPERTIES.RegionProtection_CacheBlockTime); + GeneralMethods.startCacheCleaner(GENERAL_PROPERTIES.RegionProtection.CacheBlockTime); if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) { new PlaceholderAPIHook(this).register(); diff --git a/src/com/projectkorra/projectkorra/ability/ComboAbility.java b/src/com/projectkorra/projectkorra/ability/ComboAbility.java index 1c6c98eb..adb5957d 100644 --- a/src/com/projectkorra/projectkorra/ability/ComboAbility.java +++ b/src/com/projectkorra/projectkorra/ability/ComboAbility.java @@ -5,16 +5,11 @@ import java.util.ArrayList; import org.bukkit.entity.Player; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig; -public interface ComboAbility { +public interface ComboAbility { - /** - * Accessor Method to get the instructions for using this combo. - * - * @return The steps for the combo. - */ - - public abstract Object createNewComboInstance(Player player); + public abstract Object createNewComboInstance(C config, Player player); /** * Returns the list of abilities which constitute the combo. diff --git a/src/com/projectkorra/projectkorra/ability/WaterAbility.java b/src/com/projectkorra/projectkorra/ability/WaterAbility.java index 4478a37e..d215f54a 100644 --- a/src/com/projectkorra/projectkorra/ability/WaterAbility.java +++ b/src/com/projectkorra/projectkorra/ability/WaterAbility.java @@ -19,7 +19,6 @@ import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.configuration.better.ConfigManager; import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig; -import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.SourcedWaterAbilityConfig; import com.projectkorra.projectkorra.configuration.better.configs.properties.WaterPropertiesConfig; import com.projectkorra.projectkorra.firebending.HeatControl; import com.projectkorra.projectkorra.util.BlockSource; @@ -38,22 +37,6 @@ public abstract class WaterAbility extends ElementalAbi super(config, player); } - public boolean canAutoSource() { - if (config instanceof SourcedWaterAbilityConfig) { - return ((SourcedWaterAbilityConfig) config).CanAutoSource; - } - - return false; - } - - public boolean canDynamicSource() { - if (config instanceof SourcedWaterAbilityConfig) { - return ((SourcedWaterAbilityConfig) config).CanDynamicSource; - } - - return false; - } - @Override public Element getElement() { return Element.WATER; diff --git a/src/com/projectkorra/projectkorra/airbending/combo/AirStream.java b/src/com/projectkorra/projectkorra/airbending/combo/AirStream.java index e0602098..49ca97f5 100644 --- a/src/com/projectkorra/projectkorra/airbending/combo/AirStream.java +++ b/src/com/projectkorra/projectkorra/airbending/combo/AirStream.java @@ -15,11 +15,10 @@ import com.projectkorra.projectkorra.ability.ComboAbility; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; -import com.projectkorra.projectkorra.configuration.better.ConfigManager; import com.projectkorra.projectkorra.configuration.better.configs.abilities.air.AirStreamConfig; import com.projectkorra.projectkorra.util.ClickType; -public class AirStream extends AirAbility implements ComboAbility { +public class AirStream extends AirAbility implements ComboAbility { @Attribute(Attribute.COOLDOWN) private long cooldown; @@ -201,8 +200,8 @@ public class AirStream extends AirAbility implements ComboAbili } @Override - public Object createNewComboInstance(final Player player) { - return new AirStream(ConfigManager.getConfig(AirStreamConfig.class), player); + public Object createNewComboInstance(final AirStreamConfig config, final Player player) { + return new AirStream(config, player); } @Override diff --git a/src/com/projectkorra/projectkorra/airbending/combo/AirSweep.java b/src/com/projectkorra/projectkorra/airbending/combo/AirSweep.java index 49579227..9cbbb099 100644 --- a/src/com/projectkorra/projectkorra/airbending/combo/AirSweep.java +++ b/src/com/projectkorra/projectkorra/airbending/combo/AirSweep.java @@ -18,13 +18,12 @@ import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; -import com.projectkorra.projectkorra.configuration.better.ConfigManager; import com.projectkorra.projectkorra.configuration.better.configs.abilities.air.AirSweepConfig; import com.projectkorra.projectkorra.firebending.combo.FireComboStream; import com.projectkorra.projectkorra.util.ClickType; import com.projectkorra.projectkorra.util.DamageHandler; -public class AirSweep extends AirAbility implements ComboAbility { +public class AirSweep extends AirAbility implements ComboAbility { private int progressCounter; @Attribute(Attribute.COOLDOWN) @@ -243,8 +242,8 @@ public class AirSweep extends AirAbility implements ComboAbility } @Override - public Object createNewComboInstance(final Player player) { - return new AirSweep(ConfigManager.getConfig(AirSweepConfig.class), player); + public Object createNewComboInstance(final AirSweepConfig config, final Player player) { + return new AirSweep(config, player); } @Override diff --git a/src/com/projectkorra/projectkorra/airbending/combo/Twister.java b/src/com/projectkorra/projectkorra/airbending/combo/Twister.java index f77302c4..bd77eb8b 100644 --- a/src/com/projectkorra/projectkorra/airbending/combo/Twister.java +++ b/src/com/projectkorra/projectkorra/airbending/combo/Twister.java @@ -14,11 +14,10 @@ import com.projectkorra.projectkorra.ability.ComboAbility; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; -import com.projectkorra.projectkorra.configuration.better.ConfigManager; import com.projectkorra.projectkorra.configuration.better.configs.abilities.air.TwisterConfig; import com.projectkorra.projectkorra.util.ClickType; -public class Twister extends AirAbility implements ComboAbility { +public class Twister extends AirAbility implements ComboAbility { public static enum AbilityState { TWISTER_MOVING, TWISTER_STATIONARY @@ -181,8 +180,8 @@ public class Twister extends AirAbility implements ComboAbility { } @Override - public Object createNewComboInstance(final Player player) { - return new Twister(ConfigManager.getConfig(TwisterConfig.class), player); + public Object createNewComboInstance(final TwisterConfig config, final Player player) { + return new Twister(config, player); } @Override diff --git a/src/com/projectkorra/projectkorra/chiblocking/combo/Immobilize.java b/src/com/projectkorra/projectkorra/chiblocking/combo/Immobilize.java index 30448936..b5c0164f 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/combo/Immobilize.java +++ b/src/com/projectkorra/projectkorra/chiblocking/combo/Immobilize.java @@ -15,12 +15,11 @@ import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; -import com.projectkorra.projectkorra.configuration.better.ConfigManager; import com.projectkorra.projectkorra.configuration.better.configs.abilities.chi.ImmobilizeConfig; import com.projectkorra.projectkorra.util.ClickType; import com.projectkorra.projectkorra.util.MovementHandler; -public class Immobilize extends ChiAbility implements ComboAbility { +public class Immobilize extends ChiAbility implements ComboAbility { @Attribute(Attribute.DURATION) private long duration; @@ -90,8 +89,8 @@ public class Immobilize extends ChiAbility implements ComboAbi } @Override - public Object createNewComboInstance(final Player player) { - return new Immobilize(ConfigManager.getConfig(ImmobilizeConfig.class), player); + public Object createNewComboInstance(final ImmobilizeConfig config, final Player player) { + return new Immobilize(config, player); } @Override diff --git a/src/com/projectkorra/projectkorra/configuration/better/ConfigManager.java b/src/com/projectkorra/projectkorra/configuration/better/ConfigManager.java index 2b37e486..d6a37288 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/ConfigManager.java +++ b/src/com/projectkorra/projectkorra/configuration/better/ConfigManager.java @@ -50,34 +50,37 @@ public class ConfigManager { try { C defaultConfig = clazz.newInstance(); - CONFIG_CACHE.put(clazz, defaultConfig); - File file = new File(JavaPlugin.getPlugin(ProjectKorra.class).getDataFolder(), "config"); - file.mkdirs(); - - for (String parent : defaultConfig.getParents()) { - file = new File(file, parent); - file.mkdir(); - } - - file = new File(file, defaultConfig.getName() + ".json"); - - if (file.exists()) { - try { - C config = loadConfig(file, clazz); - - CONFIG_CACHE.put(clazz, config); - return config; - } catch (IOException e) { - e.printStackTrace(); - - return defaultConfig; + if (defaultConfig.getName() != null && defaultConfig.getParents() != null) { + CONFIG_CACHE.put(clazz, defaultConfig); + + File file = new File(JavaPlugin.getPlugin(ProjectKorra.class).getDataFolder(), "config"); + file.mkdirs(); + + for (String parent : defaultConfig.getParents()) { + file = new File(file, parent); + file.mkdir(); } - } else { - try { - saveConfig(file, defaultConfig); - } catch (IOException e) { - e.printStackTrace(); + + file = new File(file, defaultConfig.getName() + ".json"); + + if (file.exists()) { + try { + C config = loadConfig(file, clazz); + + CONFIG_CACHE.put(clazz, config); + return config; + } catch (IOException e) { + e.printStackTrace(); + + return defaultConfig; + } + } else { + try { + saveConfig(file, defaultConfig); + } catch (IOException e) { + e.printStackTrace(); + } } } diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/EmptyAbilityConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/EmptyAbilityConfig.java new file mode 100644 index 00000000..96f555ca --- /dev/null +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/EmptyAbilityConfig.java @@ -0,0 +1,19 @@ +package com.projectkorra.projectkorra.configuration.better.configs.abilities; + +public class EmptyAbilityConfig extends AbilityConfig { + + public EmptyAbilityConfig() { + super(true, null, null); + } + + @Override + public String getName() { + return null; + } + + @Override + public String[] getParents() { + return null; + } + +} diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirAgilityConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirAgilityConfig.java index 0d183eeb..99702b37 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirAgilityConfig.java +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirAgilityConfig.java @@ -8,7 +8,7 @@ public class AirAgilityConfig extends AbilityConfig { public final int SpeedPower = 0; public AirAgilityConfig() { - super(true, "", ""); + super(true, "", null); } @Override diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSaturationConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSaturationConfig.java index de7473d9..51ddcd92 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSaturationConfig.java +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSaturationConfig.java @@ -7,7 +7,7 @@ public class AirSaturationConfig extends AbilityConfig { public final double ExhaustionFactor = 0; public AirSaturationConfig() { - super(true, "", ""); + super(true, "", null); } @Override diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirShieldConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirShieldConfig.java index 5c09564f..4da7646e 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirShieldConfig.java +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirShieldConfig.java @@ -4,6 +4,7 @@ import com.projectkorra.projectkorra.configuration.better.configs.abilities.Abil public class AirShieldConfig extends AbilityConfig { + public final long Cooldown = 0; public final double MaxRadius = 0; public final double InitialRadius = 0; public final long Duration = 0; @@ -11,7 +12,6 @@ public class AirShieldConfig extends AbilityConfig { public final int Streams = 0; public final int AnimationParticleAmount = 0; public final boolean DynamicCooldown = true; - public final long Cooldown = 0; public final boolean AvatarState_Toggle = true; diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSpoutConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSpoutConfig.java index 13325fa6..a4c41d48 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSpoutConfig.java +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSpoutConfig.java @@ -4,10 +4,10 @@ import com.projectkorra.projectkorra.configuration.better.configs.abilities.Abil public class AirSpoutConfig extends AbilityConfig { + public final long Cooldown = 0; public final long Duration = 0; public final long Interval = 0; public final double Height = 0; - public final long Cooldown = 0; public final double AvatarState_Height = 0; diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirStreamConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirStreamConfig.java index 5b5f3066..f759c8c4 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirStreamConfig.java +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirStreamConfig.java @@ -4,9 +4,9 @@ import com.projectkorra.projectkorra.configuration.better.configs.abilities.Abil public class AirStreamConfig extends AbilityConfig { + public final long Cooldown = 0; public final double Range = 0; public final double Speed = 0; - public final long Cooldown = 0; public final double EntityCarryHeight = 0; public final long EntityCarryDuration = 0; diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSuctionConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSuctionConfig.java index ddfe4ebd..1a8a8111 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSuctionConfig.java +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSuctionConfig.java @@ -4,6 +4,7 @@ import com.projectkorra.projectkorra.configuration.better.configs.abilities.Abil public class AirSuctionConfig extends AbilityConfig { + public final long Cooldown = 0; public final int AnimationParticleAmount = 0; public final int SelectionParticleAmount = 0; public final double PushFactor = 0; @@ -11,7 +12,6 @@ public class AirSuctionConfig extends AbilityConfig { public final double Range = 0; public final double SelectionRange = 0; public final double Radius = 0; - public final long Cooldown = 0; public final double AvatarState_PushFactor = 0; diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSweepConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSweepConfig.java index c92bfd4e..f34a223e 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSweepConfig.java +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSweepConfig.java @@ -4,11 +4,11 @@ import com.projectkorra.projectkorra.configuration.better.configs.abilities.Abil public class AirSweepConfig extends AbilityConfig { + public final long Cooldown = 0; public final double Damage = 0; public final double Range = 0; public final double Speed = 0; public final double Knockback = 0; - public final long Cooldown = 0; public final double AvatarState_Damage = 0; public final double AvatarState_Range = 0; diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSwipeConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSwipeConfig.java index d1d05ab7..32e1a2b4 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSwipeConfig.java +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/AirSwipeConfig.java @@ -4,6 +4,7 @@ import com.projectkorra.projectkorra.configuration.better.configs.abilities.Abil public class AirSwipeConfig extends AbilityConfig { + public final long Cooldown = 0; public final int AnimationParticleAmount = 0; public final int Arc = 0; public final int StepSize = 0; @@ -14,7 +15,6 @@ public class AirSwipeConfig extends AbilityConfig { public final double Range = 0; public final double Radius = 0; public final double MaxChargeFactor = 0; - public final long Cooldown = 0; public final long AvatarState_Cooldown = 0; public final double AvatarState_Damage = 0; diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/FlightConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/FlightConfig.java index c269872c..a03a7cda 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/FlightConfig.java +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/FlightConfig.java @@ -4,8 +4,8 @@ import com.projectkorra.projectkorra.configuration.better.configs.abilities.Abil public class FlightConfig extends AbilityConfig { - public final long Duration = 0; public final long Cooldown = 0; + public final long Duration = 0; public final double BaseSpeed = 0; public FlightConfig() { diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/GracefulDescentConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/GracefulDescentConfig.java index 2059c854..1275687c 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/GracefulDescentConfig.java +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/GracefulDescentConfig.java @@ -5,7 +5,7 @@ import com.projectkorra.projectkorra.configuration.better.configs.abilities.Abil public class GracefulDescentConfig extends AbilityConfig { public GracefulDescentConfig() { - super(true, "", ""); + super(true, "", null); } @Override diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/SuffocateConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/SuffocateConfig.java index 73b52969..3293b7a5 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/SuffocateConfig.java +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/SuffocateConfig.java @@ -4,6 +4,7 @@ import com.projectkorra.projectkorra.configuration.better.configs.abilities.Abil public class SuffocateConfig extends AbilityConfig { + public final long Cooldown = 0; public final boolean RequireConstantAim = true; public final double ConstantAimRadius = 0; public final boolean CanSuffocateUndead = false; @@ -12,7 +13,6 @@ public class SuffocateConfig extends AbilityConfig { public final long ChargeTime = 0; public final double Range = 0; public final double AnimationRadius = 0; - public final long Cooldown = 0; public final double Damage = 0; public final double DamageInitialDelay = 0; public final double DamageInterval = 0; diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/TornadoConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/TornadoConfig.java index 31482370..4e997237 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/TornadoConfig.java +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/TornadoConfig.java @@ -4,6 +4,7 @@ import com.projectkorra.projectkorra.configuration.better.configs.abilities.Abil public class TornadoConfig extends AbilityConfig { + public final long Cooldown = 0; public final long Duration = 0; public final double Range = 0; public final double Height = 0; @@ -11,7 +12,6 @@ public class TornadoConfig extends AbilityConfig { public final double NpcPushFactor = 0; public final double Radius = 0; public final double Speed = 0; - public final long Cooldown = 0; public TornadoConfig() { super(true, "", ""); diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/TwisterConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/TwisterConfig.java index 805833ba..3b17485b 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/TwisterConfig.java +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/air/TwisterConfig.java @@ -4,9 +4,9 @@ import com.projectkorra.projectkorra.configuration.better.configs.abilities.Abil public class TwisterConfig extends AbilityConfig { + public final long Cooldown = 0; public final double Range = 0; public final double Speed = 0; - public final long Cooldown = 0; public final double Height = 0; public final double Radius = 0; public final double DegreesPerParticle = 0; diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/chi/AcrobaticsConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/chi/AcrobaticsConfig.java index a1400edd..fb127172 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/chi/AcrobaticsConfig.java +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/chi/AcrobaticsConfig.java @@ -7,7 +7,7 @@ public class AcrobaticsConfig extends AbilityConfig { public final double FallReductionFactor = 0; public AcrobaticsConfig() { - super(true, "", ""); + super(true, "", null); } @Override diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/chi/ChiAgilityConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/chi/ChiAgilityConfig.java index 8834afb9..ec0103ab 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/chi/ChiAgilityConfig.java +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/chi/ChiAgilityConfig.java @@ -8,7 +8,7 @@ public class ChiAgilityConfig extends AbilityConfig { public final int SpeedPower = 0; public ChiAgilityConfig() { - super(true, "", ""); + super(true, "", null); } @Override diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/chi/ChiSaturationConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/chi/ChiSaturationConfig.java index 121e7ae9..b2008e37 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/chi/ChiSaturationConfig.java +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/chi/ChiSaturationConfig.java @@ -7,7 +7,7 @@ public class ChiSaturationConfig extends AbilityConfig { public final double ExhaustionFactor = 0; public ChiSaturationConfig() { - super(true, "", ""); + super(true, "", null); } @Override diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/BloodbendingConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/BloodbendingConfig.java new file mode 100644 index 00000000..6fac8909 --- /dev/null +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/BloodbendingConfig.java @@ -0,0 +1,31 @@ +package com.projectkorra.projectkorra.configuration.better.configs.abilities.water; + +import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig; + +public class BloodbendingConfig extends AbilityConfig { + + public final long Cooldown = 0; + public final long Duration = 0; + public final double Range = 0; + public final double Knockback = 0; + + public final boolean CanOnlyBeUsedAtNight = true; + public final boolean CanBeUsedOnUndeadMobs = false; + public final boolean CanOnlyBeUsedDuringFullMoon = true; + public final boolean CanBloodbendOtherBloodbenders = false; + + public BloodbendingConfig() { + super(true, "", ""); + } + + @Override + public String getName() { + return "Bloodbending"; + } + + @Override + public String[] getParents() { + return new String[] { "Abilities", "Water" }; + } + +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/FastSwimConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/FastSwimConfig.java new file mode 100644 index 00000000..aad90935 --- /dev/null +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/FastSwimConfig.java @@ -0,0 +1,25 @@ +package com.projectkorra.projectkorra.configuration.better.configs.abilities.water; + +import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig; + +public class FastSwimConfig extends AbilityConfig { + + public final long Cooldown = 0; + public final long Duration = 0; + public final double SpeedFactor = 0; + + public FastSwimConfig() { + super(true, "", null); + } + + @Override + public String getName() { + return "FastSwim"; + } + + @Override + public String[] getParents() { + return new String[] { "Abilities", "Water", "Passives" }; + } + +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/HealingWatersConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/HealingWatersConfig.java new file mode 100644 index 00000000..618ef24e --- /dev/null +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/HealingWatersConfig.java @@ -0,0 +1,29 @@ +package com.projectkorra.projectkorra.configuration.better.configs.abilities.water; + +import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig; + +public class HealingWatersConfig extends AbilityConfig { + + public final long Cooldown = 0; + public final long Duration = 0; + public final long Interval = 0; + public final long ChargeTime = 0; + public final double Range = 0; + public final int PotionPotency = 0; + public final boolean EnableParticles = true; + + public HealingWatersConfig() { + super(true, "", ""); + } + + @Override + public String getName() { + return "HealingWaters"; + } + + @Override + public String[] getParents() { + return new String[] { "Abilities", "Water" }; + } + +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/HydroSinkConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/HydroSinkConfig.java new file mode 100644 index 00000000..ca481d0b --- /dev/null +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/HydroSinkConfig.java @@ -0,0 +1,21 @@ +package com.projectkorra.projectkorra.configuration.better.configs.abilities.water; + +import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig; + +public class HydroSinkConfig extends AbilityConfig { + + public HydroSinkConfig() { + super(true, "", null); + } + + @Override + public String getName() { + return "HydroSink"; + } + + @Override + public String[] getParents() { + return new String[] { "Abilities", "Water", "Passives" }; + } + +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/IceBlastConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/IceBlastConfig.java new file mode 100644 index 00000000..e4361390 --- /dev/null +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/IceBlastConfig.java @@ -0,0 +1,33 @@ +package com.projectkorra.projectkorra.configuration.better.configs.abilities.water; + +import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig; + +public class IceBlastConfig extends AbilityConfig { + + public final long Cooldown = 0; + public final long Interval = 0; + public final double CollisionRadius = 0; + public final double Range = 0; + public final double Damage = 0; + public final double DeflectRange = 0; + public final boolean AllowSnow = true; + + public final long AvatarState_Cooldown = 0; + public final double AvatarState_Damage = 0; + public final double AvatarState_Range = 0; + + public IceBlastConfig() { + super(true, "", ""); + } + + @Override + public String getName() { + return "IceBlast"; + } + + @Override + public String[] getParents() { + return new String[] { "Abilities", "Water" }; + } + +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/IceBulletConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/IceBulletConfig.java new file mode 100644 index 00000000..f72d3679 --- /dev/null +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/IceBulletConfig.java @@ -0,0 +1,32 @@ +package com.projectkorra.projectkorra.configuration.better.configs.abilities.water; + +import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig; + +public class IceBulletConfig extends AbilityConfig { + + public final long Cooldown = 0; + public final long ShotCooldown = 0; + public final long ShootTime = 0; + public final double Range = 0; + public final double Radius = 0; + public final double Damage = 0; + public final int MaxShots = 0; + public final double AnimationSpeed = 0; + + public final long AvatarState_Cooldown = 0; + + public IceBulletConfig() { + super(true, "", ""); + } + + @Override + public String getName() { + return "IceBullet"; + } + + @Override + public String[] getParents() { + return new String[] { "Abilities", "Water", "Combos" }; + } + +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/IceSpikeConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/IceSpikeConfig.java new file mode 100644 index 00000000..e8d36134 --- /dev/null +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/IceSpikeConfig.java @@ -0,0 +1,79 @@ +package com.projectkorra.projectkorra.configuration.better.configs.abilities.water; + +import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig; + +public class IceSpikeConfig extends AbilityConfig { + + public final long Cooldown = 0;// + public final int Height = 0;// + public final double Damage = 0;// + public final double Range = 0;// + public final double Speed = 0;// + public final double Push = 0;// + + public final long SlowCooldown = 0; + public final int SlowPower = 0; + public final int SlowDuration = 0; + + public final double AvatarState_Damage = 0; + public final double AvatarState_Range = 0; + public final int AvatarState_Height = 0; + public final double AvatarState_Push = 0; + + public final int AvatarState_SlowPower = 0; + public final int AvatarState_SlowDuration = 0; + + public final BlastConfig BlastConfig = new BlastConfig(); + + public final FieldConfig FieldConfig = new FieldConfig(); + + public static class BlastConfig { + + public final long Cooldown = 0; + public final long Interval = 0; + public final double Damage = 0; + public final double Range = 0; + public final double CollisionRadius = 0; + public final double DeflectRange = 0; + + public final double ProjectileRange = 0; + + public final long SlowCooldown = 0; + public final int SlowPotency = 0; + public final int SlowDuration = 0; + + public final double AvatarState_Damage = 0; + public final double AvatarState_Range = 0; + + public final int AvatarState_SlowPotency = 0; + public final int AvatarState_SlowDuration = 0; + + } + + public static class FieldConfig { + + public final long Cooldown = 0; + public final double Damage = 0; + public final double Radius = 0; + public final double Knockup = 0; + + public final double AvatarState_Damage = 0; + public final double AvatarState_Radius = 0; + + } + + public IceSpikeConfig() { + super(true, "", ""); + } + + @Override + public String getName() { + return "IceSpike"; + } + + @Override + public String[] getParents() { + return new String[] { "Abilities", "Water" }; + } + +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/IceWaveConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/IceWaveConfig.java new file mode 100644 index 00000000..8b11b89d --- /dev/null +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/IceWaveConfig.java @@ -0,0 +1,30 @@ +package com.projectkorra.projectkorra.configuration.better.configs.abilities.water; + +import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig; + +public class IceWaveConfig extends AbilityConfig { + + public final long Cooldown = 0; + + public final double ThawRadius = 0; + public final double Damage = 0; + public final boolean RevertSphere = true; + public final long RevertSphereTime = 0; + + public final double AvatarState_Damage = 0; + + public IceWaveConfig() { + super(true, "", ""); + } + + @Override + public String getName() { + return "IceWave"; + } + + @Override + public String[] getParents() { + return new String[] { "Abilities", "Water", "Combos" }; + } + +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/OctopusFormConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/OctopusFormConfig.java new file mode 100644 index 00000000..8574274a --- /dev/null +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/OctopusFormConfig.java @@ -0,0 +1,37 @@ +package com.projectkorra.projectkorra.configuration.better.configs.abilities.water; + +import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig; + +public class OctopusFormConfig extends AbilityConfig { + + public final long Cooldown = 0; + public final long Duration = 0; + public final long FormDelay = 0; + public final double SelectionRange = 0; + public final double Damage = 0; + public final double AttackRange = 0; + public final long UsageCooldown = 0; + public final double Knockback = 0; + public final double Radius = 0; + public final double AngleIncrement = 0; + + public final double AvatarState_Damage = 0; + public final double AvatarState_AttackRange = 0; + public final double AvatarState_Knockback = 0; + public final double AvatarState_Radius = 0; + + public OctopusFormConfig() { + super(true, "", ""); + } + + @Override + public String getName() { + return "OctopusForm"; + } + + @Override + public String[] getParents() { + return new String[] { "Abilities", "Water" }; + } + +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/PhaseChangeConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/PhaseChangeConfig.java new file mode 100644 index 00000000..05a59715 --- /dev/null +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/PhaseChangeConfig.java @@ -0,0 +1,45 @@ +package com.projectkorra.projectkorra.configuration.better.configs.abilities.water; + +import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig; + +public class PhaseChangeConfig extends AbilityConfig { + + public final double SourceRange = 0; + + public final FreezeConfig FreezeConfig = new FreezeConfig(); + + public final MeltConfig MeltConfig = new MeltConfig(); + + public static class FreezeConfig { + + public final long Cooldown = 0; + public final int Depth = 0; + public final double ControlRadius = 0; + public final int Radius = 0; + + } + + public static class MeltConfig { + + public final long Cooldown = 0; + public final double Speed = 0; + public final int Radius = 0; + public final boolean AllowFlow = true; + + } + + public PhaseChangeConfig() { + super(true, "", ""); + } + + @Override + public String getName() { + return "PhaseChange"; + } + + @Override + public String[] getParents() { + return new String[] { "Abilities", "Water" }; + } + +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/SurgeConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/SurgeConfig.java new file mode 100644 index 00000000..dbd624f9 --- /dev/null +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/SurgeConfig.java @@ -0,0 +1,53 @@ +package com.projectkorra.projectkorra.configuration.better.configs.abilities.water; + +import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig; + +public class SurgeConfig extends AbilityConfig { + + public final SurgeWaveConfig WaveConfig = new SurgeWaveConfig(); + + public final SurgeWallConfig WallConfig = new SurgeWallConfig(); + + public static class SurgeWaveConfig { + + public final long Cooldown = 0; + public final long Interval = 0; + public final double Radius = 0; + public final double Knockback = 0; + public final double Knockup = 0; + public final double MaxFreezeRadius = 0; + public final long IceRevertTime = 0; + public final double Range = 0; + public final double SelectRange = 0; + + public final double AvatarState_Radius = 0; + + } + + public static class SurgeWallConfig { + + public final long Cooldown = 0; + public final long Interval = 0; + public final long Duration = 0; + public final double Range = 0; + public final double Radius = 0; + + public final double AvatarState_Radius = 0; + + } + + public SurgeConfig() { + super(true, "", ""); + } + + @Override + public String getName() { + return "Surge"; + } + + @Override + public String[] getParents() { + return new String[] { "Abilities", "Water" }; + } + +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/TorrentConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/TorrentConfig.java new file mode 100644 index 00000000..3c042ad2 --- /dev/null +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/TorrentConfig.java @@ -0,0 +1,56 @@ +package com.projectkorra.projectkorra.configuration.better.configs.abilities.water; + +import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig; + +public class TorrentConfig extends AbilityConfig { + + public final long Cooldown = 0; + public final int MaxLayer = 0; + public final double Knockback = 0; + public final double Angle = 0; + public final double Radius = 0; + public final double Knockup = 0; + public final long Interval = 0; + public final double InitialDamage = 0; + public final double SuccessiveDamage = 0; + public final int MaxHits = 0; + public final double DeflectDamage = 0; + public final double Range = 0; + public final double SelectRange = 0; + + public final boolean Revert = true; + public final long RevertTime = 0; + + public final double AvatarState_Knockback = 0; + public final double AvatarState_InitialDamage = 0; + public final double AvatarState_SuccessiveDamage = 0; + public final int AvatarState_MaxHits = 0; + + public final TorrentWaveConfig WaveConfig = new TorrentWaveConfig(); + + public static class TorrentWaveConfig { + + public final long Cooldown = 0; + public final long Interval = 0; + public final double Height = 0; + public final double Radius = 0; + public final double Knockback = 0; + public final double GrowSpeed = 0; + + } + + public TorrentConfig() { + super(true, "", ""); + } + + @Override + public String getName() { + return "Torrent"; + } + + @Override + public String[] getParents() { + return new String[] { "Abilities", "Water" }; + } + +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/WaterArmsConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/WaterArmsConfig.java new file mode 100644 index 00000000..5558829f --- /dev/null +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/WaterArmsConfig.java @@ -0,0 +1,106 @@ +package com.projectkorra.projectkorra.configuration.better.configs.abilities.water; + +import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig; + +public class WaterArmsConfig extends AbilityConfig { + + public final long Cooldown = 0; + public final int InitialLength = 0; + public final double SourceGrabRange = 0; + public final boolean AllowPlantSource = true; + public final int MaxAttacks = 0; + public final int MaxIceShots = 0; + public final int MaxAlternateUsage = 0; + + public final boolean LightningVulnerability = true; + public final boolean LightningInstaKill = true; + public final double LightningDamage = 0; + + public final String SneakMessage = ""; + + public final FreezeConfig FreezeConfig = new FreezeConfig(); + + public final SpearConfig SpearConfig = new SpearConfig(); + + public final WhipConfig WhipConfig = new WhipConfig(); + + public static class FreezeConfig { + + public final long UsageCooldown = 0; + public final boolean UsageCooldownEnabled = true; + + public final int Range = 0; + public final double Damage = 0; + + } + + public static class SpearConfig { + + public final long UsageCooldown = 0; + public final boolean UsageCooldownEnabled = true; + + public final int Length = 0; + + public final double Damage = 0; + public final boolean DamageEnabled = true; + + public final int RangeDay = 0; + public final int RangeNight = 0; + public final int RangeFullMoon = 0; + + public final int SphereRadiusDay = 0; + public final int SphereRadiusNight = 0; + public final int SphereRadiusFullMoon = 0; + + public final long DurationDay = 0; + public final long DurationNight = 0; + public final long DurationFullMoon = 0; + + } + + public static class WhipConfig { + + public final boolean UsageCooldownEnabled = true; + + public final int MaxLengthDay = 0; + public final int MaxLengthWeak = 0; + public final int MaxLengthNight = 0; + public final int MaxLengthFullMoon = 0; + + public final long UsageCooldownPunch = 0; + + public final int PunchLengthDay = 0; + public final int PunchLengthNight = 0; + public final int PunchLengthFullMoon = 0; + + public final double PunchDamage = 0; + + public final long UsageCooldownGrab = 0; + + public final long GrabDuration = 0; + + public final long UsageCooldownPull = 0; + + public final double PullFactor = 0; + + public final long UsageCooldownGrapple = 0; + + public final boolean GrappleRespectRegions = true; + + } + + public WaterArmsConfig() { + super(true, "", ""); + } + + @Override + public String getName() { + return "WaterArms"; + } + + @Override + public String[] getParents() { + return new String[] { "Abilities", "Water" }; + } + +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/WaterBubbleConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/WaterBubbleConfig.java new file mode 100644 index 00000000..2be5e9cd --- /dev/null +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/WaterBubbleConfig.java @@ -0,0 +1,26 @@ +package com.projectkorra.projectkorra.configuration.better.configs.abilities.water; + +import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig; + +public class WaterBubbleConfig extends AbilityConfig { + + public final long ClickDuration = 0; + public final double Radius = 0; + public final double Speed = 0; + public final boolean MustStartAboveWater = true; + + public WaterBubbleConfig() { + super(true, "", ""); + } + + @Override + public String getName() { + return "WaterBubble"; + } + + @Override + public String[] getParents() { + return new String[] { "Abilities", "Water" }; + } + +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/WaterManipulationConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/WaterManipulationConfig.java index 0c1182a3..61519600 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/WaterManipulationConfig.java +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/WaterManipulationConfig.java @@ -1,11 +1,22 @@ package com.projectkorra.projectkorra.configuration.better.configs.abilities.water; -public class WaterManipulationConfig extends SourcedWaterAbilityConfig { +import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig; +public class WaterManipulationConfig extends AbilityConfig { + + public final long Cooldown = 0; public final double SelectRange = 0; + public final double CollisionRadius = 0; + public final double Range = 0; + public final double Knockback = 0; + public final double Damage = 0; + public final double Speed = 0; + public final double DeflectRange = 0; + + public final double AvatarState_Damage = 0; public WaterManipulationConfig() { - super(true, "", "", true, true); + super(true, "", ""); } @Override diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/WaterSpoutConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/WaterSpoutConfig.java new file mode 100644 index 00000000..3a2c1fb4 --- /dev/null +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/abilities/water/WaterSpoutConfig.java @@ -0,0 +1,47 @@ +package com.projectkorra.projectkorra.configuration.better.configs.abilities.water; + +import com.projectkorra.projectkorra.configuration.better.configs.abilities.AbilityConfig; + +public class WaterSpoutConfig extends AbilityConfig { + + public final long Cooldown = 0; + public final boolean UseParticles = true; + public final boolean EnableBlockSpiral = true; + public final double Height = 0; + public final long Duration = 0; + public final long Interval = 0; + + public final WaterSpoutWaveConfig WaveConfig = new WaterSpoutWaveConfig(); + + public static class WaterSpoutWaveConfig { + + public final boolean Enabled = true; + public final long Cooldown = 0; + public final boolean AllowPlantSource = true; + public final double Radius = 0; + public final double WaveRadius = 0; + public final double AnimationSpeed = 0; + public final double SelectRange = 0; + public final double Speed = 0; + public final long ChargeTime = 0; + public final long FlightDuration = 0; + + public final long AvatarState_FlightDuration = 0; + + } + + public WaterSpoutConfig() { + super(true, "", ""); + } + + @Override + public String getName() { + return "WaterSpout"; + } + + @Override + public String[] getParents() { + return new String[] { "Abilities", "Water" }; + } + +} \ No newline at end of file diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/properties/GeneralPropertiesConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/properties/GeneralPropertiesConfig.java index 32c51c49..3a886cb1 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/configs/properties/GeneralPropertiesConfig.java +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/properties/GeneralPropertiesConfig.java @@ -6,28 +6,13 @@ public class GeneralPropertiesConfig implements Config { public final boolean UpdateChecker = true; - public final double RegionProtection_CacheBlockTime = 0; - public final boolean RegionProtection_RespectResidence = true; - public final String RegionProtection_ResidenceFlag = ""; - public final boolean RegionProtection_AllowHarmlessAbilities = true; - public final boolean RegionProtection_RespectWorldGuard = true; - public final boolean RegionProtection_RespectFactions = true; - public final boolean RegionProtection_RespectTowny = true; - public final boolean RegionProtection_RespectGriefPrevention = true; - public final boolean RegionProtection_RespectLWC = true; - public final boolean RegionProtection_RespectKingdoms = true; - public final boolean RegionProtection_RespectRedProtect = true; + public final RegionProtectionConfig RegionProtection = new RegionProtectionConfig(); public final boolean Statistics = true; public final boolean DatabaseCooldowns = true; - public final boolean UseMySQL = false; - public final String MySQL_Host = ""; - public final int MySQL_Port = 3306; - public final String MySQL_User = ""; - public final String MySQL_Password = ""; - public final String MySQL_Database = ""; + public final MySQLConfig MySQL = new MySQLConfig(); public final boolean BendingPreview = true; @@ -51,6 +36,43 @@ public class GeneralPropertiesConfig implements Config { public final String[] DisabledWorlds = {}; + public static final class RegionProtectionConfig { + + public final double CacheBlockTime = 0; + + public final boolean RespectResidence = true; + public final String ResidenceFlag = ""; + + public final boolean AllowHarmlessAbilities = true; + + public final boolean RespectWorldGuard = true; + + public final boolean RespectFactions = true; + + public final boolean RespectTowny = true; + + public final boolean RespectGriefPrevention = true; + + public final boolean RespectLWC = true; + + public final boolean RespectKingdoms = true; + + public final boolean RespectRedProtect = true; + + } + + public static final class MySQLConfig { + + public final boolean Enabled = false; + + public final String Host = ""; + public final int Port = 3306; + public final String Username = ""; + public final String Password = ""; + public final String Database = ""; + + } + @Override public String getName() { return "General"; diff --git a/src/com/projectkorra/projectkorra/configuration/better/configs/properties/WaterPropertiesConfig.java b/src/com/projectkorra/projectkorra/configuration/better/configs/properties/WaterPropertiesConfig.java index 40d021f5..89791fc7 100644 --- a/src/com/projectkorra/projectkorra/configuration/better/configs/properties/WaterPropertiesConfig.java +++ b/src/com/projectkorra/projectkorra/configuration/better/configs/properties/WaterPropertiesConfig.java @@ -18,6 +18,8 @@ public class WaterPropertiesConfig implements Config { public final double MaxSelectRange = 0; + public final long PlantRegrowTime = 0; + public final boolean PlaySound = true; public final Sound SoundType = Sound.BLOCK_WATER_AMBIENT; public final float SoundVolume = 0; @@ -25,6 +27,9 @@ public class WaterPropertiesConfig implements Config { public final Material[] IceBlocks = {}; + public final boolean FreezePlayerHead = true; + public final boolean FreezePlayerFeet = true; + public final Sound IceSoundType = Sound.ITEM_FLINTANDSTEEL_USE; public final float IceSoundVolume = 0; public final float IceSoundPitch = 0; diff --git a/src/com/projectkorra/projectkorra/storage/DBConnection.java b/src/com/projectkorra/projectkorra/storage/DBConnection.java index 8de4e949..161f0f52 100644 --- a/src/com/projectkorra/projectkorra/storage/DBConnection.java +++ b/src/com/projectkorra/projectkorra/storage/DBConnection.java @@ -21,12 +21,12 @@ public class DBConnection { public static void init() { GeneralPropertiesConfig config = ConfigManager.getConfig(GeneralPropertiesConfig.class); - DBConnection.host = config.MySQL_Host; - DBConnection.port = config.MySQL_Port; - DBConnection.pass = config.MySQL_Password; - DBConnection.db = config.MySQL_Database; - DBConnection.user = config.MySQL_User; - if (config.UseMySQL) { + DBConnection.host = config.MySQL.Host; + DBConnection.port = config.MySQL.Port; + DBConnection.pass = config.MySQL.Password; + DBConnection.db = config.MySQL.Database; + DBConnection.user = config.MySQL.Username; + if (config.MySQL.Enabled) { sql = new MySQL(ProjectKorra.log, "Establishing MySQL Connection...", host, port, user, pass, db); if (((MySQL) sql).open() == null) { ProjectKorra.log.severe("Disabling due to database error"); diff --git a/src/com/projectkorra/projectkorra/waterbending/OctopusForm.java b/src/com/projectkorra/projectkorra/waterbending/OctopusForm.java index 99f0ff26..e0efd7a8 100644 --- a/src/com/projectkorra/projectkorra/waterbending/OctopusForm.java +++ b/src/com/projectkorra/projectkorra/waterbending/OctopusForm.java @@ -19,6 +19,9 @@ import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.ability.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.avatar.AvatarState; +import com.projectkorra.projectkorra.configuration.better.ConfigManager; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.OctopusFormConfig; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.PhaseChangeConfig; import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.ClickType; import com.projectkorra.projectkorra.util.DamageHandler; @@ -29,16 +32,17 @@ import com.projectkorra.projectkorra.waterbending.ice.PhaseChange.PhaseChangeTyp import com.projectkorra.projectkorra.waterbending.plant.PlantRegrowth; import com.projectkorra.projectkorra.waterbending.util.WaterReturn; -public class OctopusForm extends WaterAbility { +@SuppressWarnings("deprecation") +public class OctopusForm extends WaterAbility { private boolean sourceSelected; private boolean settingUp; private boolean forming; private boolean formed; @Attribute(Attribute.RANGE) - private int range; + private double range; @Attribute(Attribute.DAMAGE) - private int damage; + private double damage; private int currentAnimationStep; private int stepCounter; private int totalStepCount; @@ -68,8 +72,8 @@ public class OctopusForm extends WaterAbility { private ArrayList newBlocks; private PhaseChange pc; - public OctopusForm(final Player player) { - super(player); + public OctopusForm(final OctopusFormConfig config, final Player player) { + super(config, player); final OctopusForm oldOctopus = getAbility(player, OctopusForm.class); if (oldOctopus != null) { @@ -95,30 +99,30 @@ public class OctopusForm extends WaterAbility { this.currentAnimationStep = 1; this.stepCounter = 1; this.totalStepCount = 3; - this.range = getConfig().getInt("Abilities.Water.OctopusForm.Range"); - this.damage = getConfig().getInt("Abilities.Water.OctopusForm.Damage"); - this.interval = getConfig().getLong("Abilities.Water.OctopusForm.FormDelay"); - this.attackRange = getConfig().getInt("Abilities.Water.OctopusForm.AttackRange"); - this.usageCooldown = getConfig().getInt("Abilities.Water.OctopusForm.UsageCooldown"); - this.knockback = getConfig().getDouble("Abilities.Water.OctopusForm.Knockback"); - this.radius = getConfig().getDouble("Abilities.Water.OctopusForm.Radius"); - this.cooldown = getConfig().getLong("Abilities.Water.OctopusForm.Cooldown"); - this.duration = getConfig().getLong("Abilities.Water.OctopusForm.Duration"); - this.angleIncrement = getConfig().getDouble("Abilities.Water.OctopusForm.AngleIncrement"); + this.range = config.SelectionRange; + this.damage = config.Damage; + this.interval = config.FormDelay; + this.attackRange = config.AttackRange; + this.usageCooldown = config.UsageCooldown; + this.knockback = config.Knockback; + this.radius = config.Radius; + this.cooldown = config.Cooldown; + this.duration = config.Duration; + this.angleIncrement = config.AngleIncrement; this.currentFormHeight = 0; this.blocks = new ArrayList(); this.newBlocks = new ArrayList(); if (hasAbility(player, PhaseChange.class)) { this.pc = getAbility(player, PhaseChange.class); } else { - this.pc = new PhaseChange(player, PhaseChangeType.CUSTOM); + this.pc = new PhaseChange(ConfigManager.getConfig(PhaseChangeConfig.class), player, PhaseChangeType.CUSTOM); } if (this.bPlayer.isAvatarState()) { - this.damage = getConfig().getInt("Abilities.Avatar.AvatarState.Water.OctopusForm.Damage"); - this.attackRange = getConfig().getInt("Abilities.Avatar.AvatarState.Water.OctopusForm.AttackRange"); - this.knockback = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.OctopusForm.Knockback"); - this.radius = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.OctopusForm.Radius"); + this.damage = config.AvatarState_Damage; + this.attackRange = config.AvatarState_AttackRange; + this.knockback = config.AvatarState_Knockback; + this.radius = config.AvatarState_Radius; } this.time = System.currentTimeMillis(); this.startTime = System.currentTimeMillis(); @@ -146,7 +150,7 @@ public class OctopusForm extends WaterAbility { } } - public static void form(final Player player) { + public static void form(final OctopusFormConfig config, final Player player) { final OctopusForm oldForm = getAbility(player, OctopusForm.class); if (oldForm != null) { @@ -158,7 +162,7 @@ public class OctopusForm extends WaterAbility { if (isTransparent(player, block) && isTransparent(player, eyeLoc.getBlock())) { block.setType(Material.WATER); block.setBlockData(GeneralMethods.getWaterData(0)); - final OctopusForm form = new OctopusForm(player); + final OctopusForm form = new OctopusForm(config, player); form.setSourceBlock(block); form.form(); @@ -564,19 +568,19 @@ public class OctopusForm extends WaterAbility { this.formed = formed; } - public int getRange() { + public double getRange() { return this.range; } - public void setRange(final int range) { + public void setRange(final double range) { this.range = range; } - public int getDamage() { + public double getDamage() { return this.damage; } - public void setDamage(final int damage) { + public void setDamage(final double damage) { this.damage = damage; } diff --git a/src/com/projectkorra/projectkorra/waterbending/SurgeWall.java b/src/com/projectkorra/projectkorra/waterbending/SurgeWall.java index 5f9f8614..af6bb11b 100644 --- a/src/com/projectkorra/projectkorra/waterbending/SurgeWall.java +++ b/src/com/projectkorra/projectkorra/waterbending/SurgeWall.java @@ -19,6 +19,7 @@ import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.ElementalAbility; import com.projectkorra.projectkorra.ability.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.SurgeConfig; import com.projectkorra.projectkorra.firebending.FireBlast; import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.ClickType; @@ -27,9 +28,9 @@ import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.waterbending.plant.PlantRegrowth; import com.projectkorra.projectkorra.waterbending.util.WaterReturn; -public class SurgeWall extends WaterAbility { +@SuppressWarnings("deprecation") +public class SurgeWall extends WaterAbility { - private static final String RANGE_CONFIG = "Abilities.Water.Surge.Wall.Range"; private static final Map AFFECTED_BLOCKS = new ConcurrentHashMap<>(); private static final Map WALL_BLOCKS = new ConcurrentHashMap<>(); public static final List SOURCE_BLOCKS = new ArrayList<>(); @@ -57,14 +58,14 @@ public class SurgeWall extends WaterAbility { private Vector targetDirection; private Map oldTemps; - public SurgeWall(final Player player) { - super(player); + public SurgeWall(final SurgeConfig config, final Player player) { + super(config, player); - this.interval = getConfig().getLong("Abilities.Water.Surge.Wall.Interval"); - this.cooldown = getConfig().getLong("Abilities.Water.Surge.Wall.Cooldown"); - this.duration = getConfig().getLong("Abilities.Water.Surge.Wall.Duration"); - this.range = getConfig().getDouble(RANGE_CONFIG); - this.radius = getConfig().getDouble("Abilities.Water.Surge.Wall.Radius"); + this.interval = config.WallConfig.Interval; + this.cooldown = config.WallConfig.Cooldown; + this.duration = config.WallConfig.Duration; + this.range = config.WallConfig.Range; + this.radius = config.WallConfig.Radius; this.locations = new ArrayList<>(); this.oldTemps = new HashMap<>(); @@ -75,7 +76,7 @@ public class SurgeWall extends WaterAbility { } if (this.bPlayer.isAvatarState()) { - this.radius = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.Surge.Wall.Radius"); + this.radius = config.WallConfig.AvatarState_Radius; } final SurgeWall wall = getAbility(player, SurgeWall.class); @@ -104,7 +105,7 @@ public class SurgeWall extends WaterAbility { final TempBlock tempBlock = new TempBlock(block, Material.WATER, GeneralMethods.getWaterData(0)); SOURCE_BLOCKS.add(tempBlock); - wave = new SurgeWave(player); + wave = new SurgeWave(config, player); wave.setCanHitSelf(false); wave.moveWater(); @@ -411,20 +412,19 @@ public class SurgeWall extends WaterAbility { return false; } - public static void form(final Player player) { + public static void form(final SurgeConfig config, final Player player) { final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); if (bPlayer == null) { return; } - final int range = getConfig().getInt(RANGE_CONFIG); SurgeWall wall = getAbility(player, SurgeWall.class); SurgeWave wave = getAbility(player, SurgeWave.class); if (wave != null) { if (wave.isProgressing() && !wave.isFreezing()) { // Freeze the wave. - new SurgeWave(player); + new SurgeWave(config, player); } else if (wave.isActivateFreeze()) { wave.remove(); return; @@ -432,7 +432,7 @@ public class SurgeWall extends WaterAbility { } if (wall == null) { - final Block source = BlockSource.getWaterSourceBlock(player, range, ClickType.SHIFT_DOWN, true, true, bPlayer.canPlantbend()); + final Block source = BlockSource.getWaterSourceBlock(player, config.WallConfig.Range, ClickType.SHIFT_DOWN, true, true, bPlayer.canPlantbend()); if (wave == null && source == null && WaterReturn.hasWaterBottle(player)) { if (bPlayer.isOnCooldown("SurgeWall")) { @@ -446,7 +446,7 @@ public class SurgeWall extends WaterAbility { final TempBlock tempBlock = new TempBlock(block, Material.WATER, GeneralMethods.getWaterData(0)); SOURCE_BLOCKS.add(tempBlock); - wall = new SurgeWall(player); + wall = new SurgeWall(config, player); wall.moveWater(); if (!wall.progressing) { @@ -465,12 +465,12 @@ public class SurgeWall extends WaterAbility { // If SurgeWall isn't being created, then try to source SurgeWave. if (!bPlayer.isOnCooldown("SurgeWave")) { - wave = new SurgeWave(player); + wave = new SurgeWave(config, player); } return; } else { - if (isWaterbendable(player, null, player.getTargetBlock((HashSet) null, range))) { - wave = new SurgeWave(player); + if (isWaterbendable(player, null, player.getTargetBlock((HashSet) null, (int) config.WallConfig.Range))) { + wave = new SurgeWave(config, player); return; } } diff --git a/src/com/projectkorra/projectkorra/waterbending/SurgeWave.java b/src/com/projectkorra/projectkorra/waterbending/SurgeWave.java index 90611298..8320cece 100644 --- a/src/com/projectkorra/projectkorra/waterbending/SurgeWave.java +++ b/src/com/projectkorra/projectkorra/waterbending/SurgeWave.java @@ -22,6 +22,9 @@ import com.projectkorra.projectkorra.ability.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.command.Commands; +import com.projectkorra.projectkorra.configuration.better.ConfigManager; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.SurgeConfig; +import com.projectkorra.projectkorra.configuration.better.configs.properties.WaterPropertiesConfig; import com.projectkorra.projectkorra.firebending.FireBlast; import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.ClickType; @@ -30,7 +33,8 @@ import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.waterbending.plant.PlantRegrowth; import com.projectkorra.projectkorra.waterbending.util.WaterReturn; -public class SurgeWave extends WaterAbility { +@SuppressWarnings({ "deprecation", "unused" }) +public class SurgeWave extends WaterAbility { private boolean freezing; private boolean activateFreeze; @@ -63,8 +67,8 @@ public class SurgeWave extends WaterAbility { private Map waveBlocks; private Map frozenBlocks; - public SurgeWave(final Player player) { - super(player); + public SurgeWave(final SurgeConfig config, final Player player) { + super(config, player); SurgeWave wave = getAbility(player, SurgeWave.class); if (wave != null) { @@ -76,20 +80,20 @@ public class SurgeWave extends WaterAbility { this.canHitSelf = true; this.currentRadius = 1; - this.cooldown = getConfig().getLong("Abilities.Water.Surge.Wave.Cooldown"); - this.interval = getConfig().getLong("Abilities.Water.Surge.Wave.Interval"); - this.maxRadius = getConfig().getDouble("Abilities.Water.Surge.Wave.Radius"); - this.knockback = getConfig().getDouble("Abilities.Water.Surge.Wave.Knockback"); - this.knockup = getConfig().getDouble("Abilities.Water.Surge.Wave.Knockup"); - this.maxFreezeRadius = getConfig().getDouble("Abilities.Water.Surge.Wave.MaxFreezeRadius"); - this.iceRevertTime = getConfig().getLong("Abilities.Water.Surge.Wave.IceRevertTime"); - this.range = getConfig().getDouble("Abilities.Water.Surge.Wave.Range"); - this.selectRange = getConfig().getDouble("Abilities.Water.Surge.Wave.SelectRange"); + this.cooldown = config.WaveConfig.Cooldown; + this.interval = config.WaveConfig.Interval; + this.maxRadius = config.WaveConfig.Radius; + this.knockback = config.WaveConfig.Knockback; + this.knockup = config.WaveConfig.Knockup; + this.maxFreezeRadius = config.WaveConfig.MaxFreezeRadius; + this.iceRevertTime = config.WaveConfig.IceRevertTime; + this.range = config.WaveConfig.Range; + this.selectRange = config.WaveConfig.SelectRange; this.waveBlocks = new ConcurrentHashMap<>(); this.frozenBlocks = new ConcurrentHashMap<>(); if (this.bPlayer.isAvatarState()) { - this.maxRadius = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.Surge.Wave.Radius"); + this.maxRadius = config.WaveConfig.AvatarState_Radius; } this.maxRadius = this.getNightFactor(this.maxRadius); @@ -160,10 +164,10 @@ public class SurgeWave extends WaterAbility { if (Commands.invincible.contains(((Player) entity).getName())) { return; } - if (!getConfig().getBoolean("Properties.Water.FreezePlayerHead") && GeneralMethods.playerHeadIsInBlock((Player) entity, block)) { + if (!ConfigManager.getConfig(WaterPropertiesConfig.class).FreezePlayerHead && GeneralMethods.playerHeadIsInBlock((Player) entity, block)) { continue ICE_SETTING; } - if (!getConfig().getBoolean("Properties.Water.FreezePlayerFeet") && GeneralMethods.playerFeetIsInBlock((Player) entity, block)) { + if (!ConfigManager.getConfig(WaterPropertiesConfig.class).FreezePlayerFeet && GeneralMethods.playerFeetIsInBlock((Player) entity, block)) { continue ICE_SETTING; } } diff --git a/src/com/projectkorra/projectkorra/waterbending/Torrent.java b/src/com/projectkorra/projectkorra/waterbending/Torrent.java index 582621bd..a2b1b5ed 100644 --- a/src/com/projectkorra/projectkorra/waterbending/Torrent.java +++ b/src/com/projectkorra/projectkorra/waterbending/Torrent.java @@ -8,7 +8,6 @@ import java.util.Random; import java.util.concurrent.ConcurrentHashMap; import org.apache.commons.lang3.tuple.Pair; - import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.block.Block; @@ -24,6 +23,9 @@ import com.projectkorra.projectkorra.ability.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.avatar.AvatarState; import com.projectkorra.projectkorra.command.Commands; +import com.projectkorra.projectkorra.configuration.better.ConfigManager; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.TorrentConfig; +import com.projectkorra.projectkorra.configuration.better.configs.properties.WaterPropertiesConfig; import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.ClickType; import com.projectkorra.projectkorra.util.DamageHandler; @@ -32,7 +34,8 @@ import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.waterbending.plant.PlantRegrowth; import com.projectkorra.projectkorra.waterbending.util.WaterReturn; -public class Torrent extends WaterAbility { +@SuppressWarnings({ "deprecation", "unused" }) +public class Torrent extends WaterAbility { private static final double CLEANUP_RANGE = 50; private static final Map> FROZEN_BLOCKS = new ConcurrentHashMap<>(); @@ -79,26 +82,26 @@ public class Torrent extends WaterAbility { private ArrayList launchedBlocks; private ArrayList hurtEntities; - public Torrent(final Player player) { - super(player); + public Torrent(final TorrentConfig config, final Player player) { + super(config, player); this.layer = 0; this.startAngle = 0; - this.maxLayer = getConfig().getInt("Abilities.Water.Torrent.MaxLayer"); - this.knockback = getConfig().getDouble("Abilities.Water.Torrent.Knockback"); - this.angle = getConfig().getDouble("Abilities.Water.Torrent.Angle"); - this.radius = getConfig().getDouble("Abilities.Water.Torrent.Radius"); - this.knockup = getConfig().getDouble("Abilities.Water.Torrent.Knockup"); - this.interval = getConfig().getLong("Abilities.Water.Torrent.Interval"); - this.damage = getConfig().getDouble("Abilities.Water.Torrent.InitialDamage"); - this.successiveDamage = getConfig().getDouble("Abilities.Water.Torrent.SuccessiveDamage"); - this.maxHits = getConfig().getInt("Abilities.Water.Torrent.MaxHits"); - this.deflectDamage = getConfig().getDouble("Abilities.Water.Torrent.DeflectDamage"); - this.range = getConfig().getDouble("Abilities.Water.Torrent.Range"); - this.selectRange = getConfig().getDouble("Abilities.Water.Torrent.SelectRange"); - this.cooldown = getConfig().getLong("Abilities.Water.Torrent.Cooldown"); - this.revert = getConfig().getBoolean("Abilities.Water.Torrent.Revert"); - this.revertTime = getConfig().getLong("Abilities.Water.Torrent.RevertTime"); + this.maxLayer = config.MaxLayer; + this.knockback = config.Knockback; + this.angle = config.Angle; + this.radius = config.Radius; + this.knockup = config.Knockup; + this.interval = config.Interval; + this.damage = config.InitialDamage; + this.successiveDamage = config.SuccessiveDamage; + this.maxHits = config.MaxHits; + this.deflectDamage = config.DeflectDamage; + this.range = config.Range; + this.selectRange = config.SelectRange; + this.cooldown = config.Cooldown; + this.revert = config.Revert; + this.revertTime = config.RevertTime; this.blocks = new ArrayList<>(); this.launchedBlocks = new ArrayList<>(); this.hurtEntities = new ArrayList<>(); @@ -119,10 +122,10 @@ public class Torrent extends WaterAbility { } if (this.bPlayer.isAvatarState()) { - this.knockback = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.Torrent.Push"); - this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.Torrent.InitialDamage"); - this.successiveDamage = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.Torrent.SuccessiveDamage"); - this.maxHits = getConfig().getInt("Abilities.Avatar.AvatarState.Water.Torrent.MaxHits"); + this.knockback = config.AvatarState_Knockback; + this.damage = config.AvatarState_InitialDamage; + this.successiveDamage = config.AvatarState_SuccessiveDamage; + this.maxHits = config.AvatarState_MaxHits; } this.time = System.currentTimeMillis(); @@ -148,10 +151,10 @@ public class Torrent extends WaterAbility { if (Commands.invincible.contains(((Player) entity).getName())) { return; } - if (!getConfig().getBoolean("Properties.Water.FreezePlayerHead") && GeneralMethods.playerHeadIsInBlock((Player) entity, block)) { + if (!ConfigManager.getConfig(WaterPropertiesConfig.class).FreezePlayerHead && GeneralMethods.playerHeadIsInBlock((Player) entity, block)) { continue ICE_SETTING; } - if (!getConfig().getBoolean("Properties.Water.FreezePlayerFeet") && GeneralMethods.playerFeetIsInBlock((Player) entity, block)) { + if (!ConfigManager.getConfig(WaterPropertiesConfig.class).FreezePlayerFeet && GeneralMethods.playerFeetIsInBlock((Player) entity, block)) { continue ICE_SETTING; } } @@ -302,7 +305,7 @@ public class Torrent extends WaterAbility { } if (this.formed && !this.player.isSneaking() && !this.launch) { - new TorrentWave(this.player, this.radius); + new TorrentWave(config, this.player, this.radius); this.remove(); return; } @@ -531,7 +534,7 @@ public class Torrent extends WaterAbility { new WaterReturn(this.player, location.getBlock()); } - public static void create(final Player player) { + public static void create(final TorrentConfig config, final Player player) { if (hasAbility(player, Torrent.class)) { return; } @@ -544,7 +547,7 @@ public class Torrent extends WaterAbility { block.setType(Material.WATER); block.setBlockData(GeneralMethods.getWaterData(0)); } - final Torrent tor = new Torrent(player); + final Torrent tor = new Torrent(config, player); if (tor.sourceSelected || tor.settingUp) { WaterReturn.emptyWaterBottle(player); diff --git a/src/com/projectkorra/projectkorra/waterbending/TorrentWave.java b/src/com/projectkorra/projectkorra/waterbending/TorrentWave.java index 3f38645d..4e9d86d2 100644 --- a/src/com/projectkorra/projectkorra/waterbending/TorrentWave.java +++ b/src/com/projectkorra/projectkorra/waterbending/TorrentWave.java @@ -17,10 +17,12 @@ import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.TorrentConfig; import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.waterbending.util.WaterReturn; -public class TorrentWave extends WaterAbility { +@SuppressWarnings("deprecation") +public class TorrentWave extends WaterAbility { private long time; private long interval; @@ -40,24 +42,24 @@ public class TorrentWave extends WaterAbility { private ArrayList affectedEntities; private Map> heights; - public TorrentWave(final Player player, final double radius) { - this(player, player.getEyeLocation(), radius); + public TorrentWave(final TorrentConfig config, final Player player, final double radius) { + this(config, player, player.getEyeLocation(), radius); } - public TorrentWave(final Player player, final Location location, final double radius) { - super(player); + public TorrentWave(final TorrentConfig config, final Player player, final Location location, final double radius) { + super(config, player); if (this.bPlayer.isOnCooldown("TorrentWave")) { return; } this.radius = radius; - this.interval = getConfig().getLong("Abilities.Water.Torrent.Wave.Interval"); - this.maxHeight = getConfig().getDouble("Abilities.Water.Torrent.Wave.Height"); - this.maxRadius = getConfig().getDouble("Abilities.Water.Torrent.Wave.Radius"); - this.knockback = getConfig().getDouble("Abilities.Water.Torrent.Wave.Knockback"); - this.cooldown = getConfig().getLong("Abilities.Water.Torrent.Wave.Cooldown"); - this.growSpeed = getConfig().getDouble("Abilities.Water.Torrent.Wave.GrowSpeed"); + this.interval = config.WaveConfig.Interval; + this.maxHeight = config.WaveConfig.Height; + this.maxRadius = config.WaveConfig.Radius; + this.knockback = config.WaveConfig.Knockback; + this.cooldown = config.WaveConfig.Cooldown; + this.growSpeed = config.WaveConfig.GrowSpeed; this.origin = location.clone(); this.time = System.currentTimeMillis(); this.heights = new ConcurrentHashMap<>(); diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterBubble.java b/src/com/projectkorra/projectkorra/waterbending/WaterBubble.java index e81ecddd..8cdc5f00 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterBubble.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterBubble.java @@ -18,10 +18,10 @@ import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.ability.ElementalAbility; import com.projectkorra.projectkorra.ability.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; -import com.projectkorra.projectkorra.configuration.ConfigManager; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.WaterBubbleConfig; import com.projectkorra.projectkorra.util.TempBlock; -public class WaterBubble extends WaterAbility { +public class WaterBubble extends WaterAbility { @Attribute("Click" + Attribute.DURATION) private long clickDuration; @@ -39,8 +39,8 @@ public class WaterBubble extends WaterAbility { private Location location; private long lastActivation; // When the last click happened. - public WaterBubble(final Player player, final boolean isShift) { - super(player); + public WaterBubble(final WaterBubbleConfig config, final Player player, final boolean isShift) { + super(config, player); this.setFields(); @@ -77,10 +77,10 @@ public class WaterBubble extends WaterAbility { } public void setFields() { - this.clickDuration = ConfigManager.defaultConfig.get().getLong("Abilities.Water.WaterBubble.ClickDuration"); - this.maxRadius = ConfigManager.defaultConfig.get().getDouble("Abilities.Water.WaterBubble.Radius"); - this.speed = ConfigManager.defaultConfig.get().getDouble("Abilities.Water.WaterBubble.Speed"); - this.requireAir = ConfigManager.defaultConfig.get().getBoolean("Abilities.Water.WaterBubble.MustStartAboveWater"); + this.clickDuration = config.ClickDuration; + this.maxRadius = config.Radius; + this.speed = config.Speed; + this.requireAir = config.MustStartAboveWater; } @Override diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterManipulation.java b/src/com/projectkorra/projectkorra/waterbending/WaterManipulation.java index 11c7b197..f5353d57 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterManipulation.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterManipulation.java @@ -21,6 +21,7 @@ import com.projectkorra.projectkorra.ability.WaterAbility; import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.WaterManipulationConfig; import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.ClickType; import com.projectkorra.projectkorra.util.DamageHandler; @@ -30,7 +31,8 @@ import com.projectkorra.projectkorra.waterbending.ice.PhaseChange; import com.projectkorra.projectkorra.waterbending.plant.PlantRegrowth; import com.projectkorra.projectkorra.waterbending.util.WaterReturn; -public class WaterManipulation extends WaterAbility { +@SuppressWarnings("deprecation") +public class WaterManipulation extends WaterAbility { private static final Map AFFECTED_BLOCKS = new ConcurrentHashMap<>(); @@ -67,25 +69,25 @@ public class WaterManipulation extends WaterAbility { private Vector targetDirection; private final HashSet waterTypes; - public WaterManipulation(final Player player) { - this(player, prepare(player, getConfig().getDouble("Abilities.Water.WaterManipulation.SelectRange"))); + public WaterManipulation(final WaterManipulationConfig config, final Player player) { + this(config, player, prepare(player, config.SelectRange)); } - public WaterManipulation(final Player player, final Block source) { - super(player); + public WaterManipulation(final WaterManipulationConfig config, final Player player, final Block source) { + super(config, player); this.progressing = false; this.falling = false; this.settingUp = false; this.displacing = false; - this.collisionRadius = getConfig().getDouble("Abilities.Water.WaterManipulation.CollisionRadius"); - this.cooldown = getConfig().getLong("Abilities.Water.WaterManipulation.Cooldown"); - this.selectRange = getConfig().getDouble("Abilities.Water.WaterManipulation.SelectRange"); - this.range = getConfig().getDouble("Abilities.Water.WaterManipulation.Range"); - this.knockback = getConfig().getDouble("Abilities.Water.WaterManipulation.Knockback"); - this.damage = getConfig().getDouble("Abilities.Water.WaterManipulation.Damage"); - this.speed = getConfig().getDouble("Abilities.Water.WaterManipulation.Speed"); - this.deflectRange = getConfig().getDouble("Abilities.Water.WaterManipulation.DeflectRange"); + this.collisionRadius = config.CollisionRadius; + this.cooldown = config.Cooldown; + this.selectRange = config.SelectRange; + this.range = config.Range; + this.knockback = config.Knockback; + this.damage = config.Damage; + this.speed = config.Speed; + this.deflectRange = config.DeflectRange; this.waterTypes = new HashSet(); this.interval = (long) (1000. / this.speed); @@ -286,7 +288,7 @@ public class WaterManipulation extends WaterAbility { entity.setVelocity(vector.normalize().multiply(this.knockback)); if (this.bPlayer.isAvatarState()) { - this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.WaterManipulation.Damage"); + this.damage = config.AvatarState_Damage; } this.damage = this.getNightFactor(this.damage); DamageHandler.damageEntity(entity, this.damage, this); @@ -465,7 +467,7 @@ public class WaterManipulation extends WaterAbility { return location; } - public static void moveWater(final Player player) { + public static void moveWater(final WaterManipulationConfig config, final Player player) { final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); if (bPlayer == null) { return; @@ -502,7 +504,7 @@ public class WaterManipulation extends WaterAbility { if (getTargetLocation(player, range).distanceSquared(block.getLocation()) > 1) { final TempBlock tb = new TempBlock(block, Material.WATER, GeneralMethods.getWaterData(0)); - final WaterManipulation waterManip = new WaterManipulation(player, block); + final WaterManipulation waterManip = new WaterManipulation(config, player, block); waterManip.moveWater(); if (!waterManip.progressing) { block.setType(Material.AIR); diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterSpout.java b/src/com/projectkorra/projectkorra/waterbending/WaterSpout.java index 52629a45..687b2204 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterSpout.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterSpout.java @@ -17,10 +17,12 @@ import com.projectkorra.projectkorra.ability.ElementalAbility; import com.projectkorra.projectkorra.ability.WaterAbility; import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.attribute.Attribute; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.WaterSpoutConfig; import com.projectkorra.projectkorra.util.ParticleEffect; import com.projectkorra.projectkorra.util.TempBlock; -public class WaterSpout extends WaterAbility { +@SuppressWarnings("deprecation") +public class WaterSpout extends WaterAbility { private static final Map AFFECTED_BLOCKS = new ConcurrentHashMap(); private final List blocks = new ArrayList(); @@ -44,8 +46,8 @@ public class WaterSpout extends WaterAbility { private Block base; private TempBlock baseBlock; - public WaterSpout(final Player player) { - super(player); + public WaterSpout(final WaterSpoutConfig config, final Player player) { + super(config, player); final WaterSpout oldSpout = getAbility(player, WaterSpout.class); if (oldSpout != null) { @@ -53,17 +55,17 @@ public class WaterSpout extends WaterAbility { return; } - this.canBendOnPackedIce = getConfig().getStringList("Properties.Water.IceBlocks").contains(Material.PACKED_ICE.toString()); - this.useParticles = getConfig().getBoolean("Abilities.Water.WaterSpout.Particles"); - this.useBlockSpiral = getConfig().getBoolean("Abilities.Water.WaterSpout.BlockSpiral"); - this.cooldown = getConfig().getLong("Abilities.Water.WaterSpout.Cooldown"); - this.height = getConfig().getDouble("Abilities.Water.WaterSpout.Height"); - this.interval = getConfig().getLong("Abilities.Water.WaterSpout.Interval"); - this.duration = getConfig().getLong("Abilities.Water.WaterSpout.Duration"); + this.canBendOnPackedIce = isIce(Material.PACKED_ICE); + this.useParticles = config.UseParticles; + this.useBlockSpiral = config.EnableBlockSpiral; + this.cooldown = config.Cooldown; + this.height = config.Height; + this.interval = config.Interval; + this.duration = config.Duration; this.startTime = System.currentTimeMillis(); this.maxHeight = this.getNightFactor(this.height); - final WaterSpoutWave spoutWave = new WaterSpoutWave(player, WaterSpoutWave.AbilityType.CLICK); + final WaterSpoutWave spoutWave = new WaterSpoutWave(config, player, WaterSpoutWave.AbilityType.CLICK); if (spoutWave.isStarted() && !spoutWave.isRemoved()) { return; } diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterSpoutWave.java b/src/com/projectkorra/projectkorra/waterbending/WaterSpoutWave.java index 1184b6c4..dcac56a8 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterSpoutWave.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterSpoutWave.java @@ -26,12 +26,18 @@ import com.projectkorra.projectkorra.ability.ElementalAbility; import com.projectkorra.projectkorra.ability.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; +import com.projectkorra.projectkorra.configuration.better.ConfigManager; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.IceWaveConfig; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.WaterSpoutConfig; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.WaterSpoutConfig.WaterSpoutWaveConfig; +import com.projectkorra.projectkorra.configuration.better.configs.properties.WaterPropertiesConfig; import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.waterbending.combo.IceWave; import com.projectkorra.projectkorra.waterbending.plant.PlantRegrowth; -public class WaterSpoutWave extends WaterAbility { +@SuppressWarnings({ "deprecation", "unused" }) +public class WaterSpoutWave extends WaterAbility { public static enum AbilityType { CLICK, SHIFT, RELEASE @@ -81,26 +87,26 @@ public class WaterSpoutWave extends WaterAbility { private ArrayList tasks; private ConcurrentHashMap affectedBlocks; - public WaterSpoutWave(final Player player, final AbilityType type) { - super(player); + public WaterSpoutWave(final WaterSpoutConfig config, final Player player, final AbilityType type) { + super(config, player); this.charging = false; this.iceWave = false; this.iceOnly = false; this.collidable = false; - this.plant = getConfig().getBoolean("Abilities.Water.WaterSpout.Wave.AllowPlantSource"); - this.radius = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.Radius"); - this.waveRadius = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.WaveRadius"); - this.thawRadius = getConfig().getDouble("Abilities.Water.IceWave.ThawRadius"); - this.animationSpeed = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.AnimationSpeed"); - this.selectRange = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.SelectRange"); - this.speed = getConfig().getDouble("Abilities.Water.WaterSpout.Wave.Speed"); - this.damage = getConfig().getDouble("Abilities.Water.IceWave.Damage"); - this.chargeTime = getConfig().getLong("Abilities.Water.WaterSpout.Wave.ChargeTime"); - this.flightDuration = getConfig().getLong("Abilities.Water.WaterSpout.Wave.FlightDuration"); - this.cooldown = getConfig().getLong("Abilities.Water.WaterSpout.Wave.Cooldown"); - this.revertSphereTime = getConfig().getLong("Abilities.Water.IceWave.RevertSphereTime"); - this.revertIceSphere = getConfig().getBoolean("Abilities.Water.IceWave.RevertSphere"); + this.plant = config.WaveConfig.AllowPlantSource; + this.radius = config.WaveConfig.Radius; + this.waveRadius = config.WaveConfig.WaveRadius; + this.thawRadius = 0; + this.animationSpeed = config.WaveConfig.AnimationSpeed; + this.selectRange = config.WaveConfig.SelectRange; + this.speed = config.WaveConfig.Speed; + this.damage = 0; + this.chargeTime = config.WaveConfig.ChargeTime; + this.flightDuration = config.WaveConfig.FlightDuration; + this.cooldown = config.WaveConfig.Cooldown; + this.revertSphereTime = 0; + this.revertIceSphere = false; this.affectedBlocks = new ConcurrentHashMap<>(); this.affectedEntities = new ArrayList<>(); this.tasks = new ArrayList<>(); @@ -113,8 +119,7 @@ public class WaterSpoutWave extends WaterAbility { if (this.bPlayer.isAvatarState()) { this.chargeTime = 0; - this.flightDuration = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.WaterWave.FlightDuration"); - this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceWave.Damage"); + this.flightDuration = config.WaveConfig.AvatarState_FlightDuration; this.cooldown = 0; } @@ -429,10 +434,10 @@ public class WaterSpoutWave extends WaterAbility { if (Commands.invincible.contains(((Player) entity).getName())) { return; } - if (!getConfig().getBoolean("Properties.Water.FreezePlayerHead") && GeneralMethods.playerHeadIsInBlock((Player) entity, block)) { + if (!ConfigManager.getConfig(WaterPropertiesConfig.class).FreezePlayerHead && GeneralMethods.playerHeadIsInBlock((Player) entity, block)) { continue; } - if (!getConfig().getBoolean("Properties.Water.FreezePlayerFeet") && GeneralMethods.playerFeetIsInBlock((Player) entity, block)) { + if (!ConfigManager.getConfig(WaterPropertiesConfig.class).FreezePlayerFeet && GeneralMethods.playerFeetIsInBlock((Player) entity, block)) { continue; } } @@ -579,8 +584,19 @@ public class WaterSpoutWave extends WaterAbility { return this.iceWave; } - public void setIceWave(final boolean iceWave) { - this.iceWave = iceWave; + public void setIceWave(final IceWaveConfig iceConfig) { + this.iceWave = iceConfig != null; + + if (iceConfig != null) { + this.thawRadius = iceConfig.ThawRadius; + this.damage = iceConfig.Damage; + this.revertSphereTime = iceConfig.RevertSphereTime; + this.revertIceSphere = iceConfig.RevertSphere; + + if (this.bPlayer.isAvatarState()) { + this.damage = iceConfig.AvatarState_Damage; + } + } } public boolean isIceOnly() { @@ -590,10 +606,10 @@ public class WaterSpoutWave extends WaterAbility { public void setIceOnly(final boolean iceOnly) { this.iceOnly = iceOnly; } - + @Override public boolean isEnabled() { - return getConfig().getBoolean("Abilities.Water.WaterSpout.Wave.Enabled"); + return config.WaveConfig.Enabled; } public boolean isMoving() { diff --git a/src/com/projectkorra/projectkorra/waterbending/blood/Bloodbending.java b/src/com/projectkorra/projectkorra/waterbending/blood/Bloodbending.java index fc203eec..46228deb 100644 --- a/src/com/projectkorra/projectkorra/waterbending/blood/Bloodbending.java +++ b/src/com/projectkorra/projectkorra/waterbending/blood/Bloodbending.java @@ -22,11 +22,12 @@ import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.ability.BloodAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.avatar.AvatarState; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.BloodbendingConfig; import com.projectkorra.projectkorra.object.HorizontalVelocityTracker; import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.TempPotionEffect; -public class Bloodbending extends BloodAbility { +public class Bloodbending extends BloodAbility { private static final Map TARGETED_ENTITIES = new ConcurrentHashMap(); @@ -37,7 +38,7 @@ public class Bloodbending extends BloodAbility { @Attribute("CanBloodbendOtherBloodbenders") private boolean canBloodbendOtherBloodbenders; @Attribute(Attribute.RANGE) - private int range; + private double range; private long time; @Attribute(Attribute.DURATION) private long duration; @@ -48,8 +49,8 @@ public class Bloodbending extends BloodAbility { private Entity target; private Vector vector; - public Bloodbending(final Player player) { - super(player); + public Bloodbending(final BloodbendingConfig config, final Player player) { + super(config, player); final Bloodbending ability = getAbility(player, Bloodbending.class); if (ability != null) { @@ -57,14 +58,14 @@ public class Bloodbending extends BloodAbility { return; } - this.canOnlyBeUsedAtNight = getConfig().getBoolean("Abilities.Water.Bloodbending.CanOnlyBeUsedAtNight"); - this.canBeUsedOnUndeadMobs = getConfig().getBoolean("Abilities.Water.Bloodbending.CanBeUsedOnUndeadMobs"); - this.onlyUsableDuringMoon = getConfig().getBoolean("Abilities.Water.Bloodbending.CanOnlyBeUsedDuringFullMoon"); - this.canBloodbendOtherBloodbenders = getConfig().getBoolean("Abilities.Water.Bloodbending.CanBloodbendOtherBloodbenders"); - this.range = getConfig().getInt("Abilities.Water.Bloodbending.Range"); - this.duration = getConfig().getInt("Abilities.Water.Bloodbending.Duration"); - this.cooldown = getConfig().getInt("Abilities.Water.Bloodbending.Cooldown"); - this.knockback = getConfig().getDouble("Abilities.Water.Bloodbending.Knockback"); + this.canOnlyBeUsedAtNight = config.CanOnlyBeUsedAtNight; + this.canBeUsedOnUndeadMobs = config.CanBeUsedOnUndeadMobs; + this.onlyUsableDuringMoon = config.CanOnlyBeUsedDuringFullMoon; + this.canBloodbendOtherBloodbenders = config.CanBloodbendOtherBloodbenders; + this.range = config.Range; + this.duration = config.Duration; + this.cooldown = config.Cooldown; + this.knockback = config.Knockback; this.vector = new Vector(0, 0, 0); if (this.canOnlyBeUsedAtNight && !isNight(player.getWorld()) && !this.bPlayer.canBloodbendAtAnytime()) { @@ -404,11 +405,11 @@ public class Bloodbending extends BloodAbility { this.canBloodbendOtherBloodbenders = canBloodbendOtherBloodbenders; } - public int getRange() { + public double getRange() { return this.range; } - public void setRange(final int range) { + public void setRange(final double range) { this.range = range; } diff --git a/src/com/projectkorra/projectkorra/waterbending/combo/IceBullet.java b/src/com/projectkorra/projectkorra/waterbending/combo/IceBullet.java index be954f76..67317824 100644 --- a/src/com/projectkorra/projectkorra/waterbending/combo/IceBullet.java +++ b/src/com/projectkorra/projectkorra/waterbending/combo/IceBullet.java @@ -25,6 +25,7 @@ import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.avatar.AvatarState; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.IceBulletConfig; import com.projectkorra.projectkorra.firebending.combo.FireComboStream; import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.ClickType; @@ -33,7 +34,8 @@ import com.projectkorra.projectkorra.util.ParticleEffect; import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.waterbending.util.WaterSourceGrabber; -public class IceBullet extends IceAbility implements ComboAbility { +@SuppressWarnings("deprecation") +public class IceBullet extends IceAbility implements ComboAbility { public static enum AbilityState { ICE_PILLAR_RISING, ICE_BULLET_FORMING @@ -58,7 +60,6 @@ public class IceBullet extends IceAbility implements ComboAbility { private long cooldown; private long shotcooldown; private long time; - private String name; private AbilityState state; private Location origin; private Location location; @@ -67,8 +68,8 @@ public class IceBullet extends IceAbility implements ComboAbility { private ArrayList tasks; private ConcurrentHashMap affectedBlocks; - public IceBullet(final Player player) { - super(player); + public IceBullet(final IceBulletConfig config, final Player player) { + super(config, player); this.time = System.currentTimeMillis(); this.tasks = new ArrayList<>(); @@ -78,16 +79,15 @@ public class IceBullet extends IceAbility implements ComboAbility { return; } - this.damage = getConfig().getDouble("Abilities.Water.IceBullet.Damage"); - this.range = getConfig().getDouble("Abilities.Water.IceBullet.Range"); - this.radius = getConfig().getDouble("Abilities.Water.IceBullet.Radius"); - this.cooldown = getConfig().getLong("Abilities.Water.IceBullet.Cooldown"); - this.shotcooldown = getConfig().getLong("Abilities.Water.IceBullet.ShotCooldown"); - this.shootTime = getConfig().getLong("Abilities.Water.IceBullet.ShootTime"); - this.maxShots = getConfig().getInt("Abilities.Water.IceBullet.MaxShots"); - this.animationSpeed = getConfig().getDouble("Abilities.Water.IceBullet.AnimationSpeed"); + this.damage = config.Damage; + this.range = config.Range; + this.radius = config.Radius; + this.cooldown = config.Cooldown; + this.shotcooldown = config.ShotCooldown; + this.shootTime = config.ShootTime; + this.maxShots = config.MaxShots; + this.animationSpeed = config.AnimationSpeed; this.speed = 1; - this.name = this.getName(); double aug = getNightFactor(player.getWorld()); if (aug > 1) { @@ -101,7 +101,7 @@ public class IceBullet extends IceAbility implements ComboAbility { this.radius *= aug; if (this.bPlayer.isAvatarState()) { - this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Water.IceBullet.Cooldown"); + this.cooldown = config.AvatarState_Cooldown; this.damage = AvatarState.getValue(this.damage); this.range = AvatarState.getValue(this.range); this.shootTime = AvatarState.getValue(this.shootTime); @@ -343,8 +343,8 @@ public class IceBullet extends IceAbility implements ComboAbility { } @Override - public Object createNewComboInstance(final Player player) { - return new IceBullet(player); + public Object createNewComboInstance(final IceBulletConfig config, final Player player) { + return new IceBullet(config, player); } @Override @@ -520,7 +520,4 @@ public class IceBullet extends IceAbility implements ComboAbility { this.location = location; } - public void setName(final String name) { - this.name = name; - } } diff --git a/src/com/projectkorra/projectkorra/waterbending/combo/IceWave.java b/src/com/projectkorra/projectkorra/waterbending/combo/IceWave.java index ef29923d..f6fb978e 100644 --- a/src/com/projectkorra/projectkorra/waterbending/combo/IceWave.java +++ b/src/com/projectkorra/projectkorra/waterbending/combo/IceWave.java @@ -12,11 +12,12 @@ import com.projectkorra.projectkorra.ability.ComboAbility; import com.projectkorra.projectkorra.ability.IceAbility; import com.projectkorra.projectkorra.ability.util.ComboManager.AbilityInformation; import com.projectkorra.projectkorra.attribute.Attribute; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.IceWaveConfig; import com.projectkorra.projectkorra.util.ClickType; import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.waterbending.WaterSpoutWave; -public class IceWave extends IceAbility implements ComboAbility { +public class IceWave extends IceAbility implements ComboAbility { private static final Map FROZEN_BLOCKS = new ConcurrentHashMap<>(); @@ -24,8 +25,8 @@ public class IceWave extends IceAbility implements ComboAbility { private long cooldown; private Location origin; - public IceWave(final Player player) { - super(player); + public IceWave(final IceWaveConfig config, final Player player) { + super(config, player); if (!this.bPlayer.canBendIgnoreBindsCooldowns(this)) { return; @@ -36,7 +37,7 @@ public class IceWave extends IceAbility implements ComboAbility { return; } - this.cooldown = getConfig().getLong("Abilities.Water.IceWave.Cooldown"); + this.cooldown = config.Cooldown; if (this.bPlayer.isAvatarState()) { this.cooldown = 0; @@ -62,7 +63,7 @@ public class IceWave extends IceAbility implements ComboAbility { this.origin = this.player.getLocation(); final WaterSpoutWave wave = WaterSpoutWave.getType(this.player, WaterSpoutWave.AbilityType.RELEASE).get(0); - wave.setIceWave(true); + wave.setIceWave(config); } else if (!WaterSpoutWave.containsType(this.player, WaterSpoutWave.AbilityType.RELEASE)) { this.remove(); return; @@ -114,8 +115,8 @@ public class IceWave extends IceAbility implements ComboAbility { } @Override - public Object createNewComboInstance(final Player player) { - return new IceWave(player); + public Object createNewComboInstance(final IceWaveConfig config, final Player player) { + return new IceWave(config, player); } @Override diff --git a/src/com/projectkorra/projectkorra/waterbending/healing/HealingWaters.java b/src/com/projectkorra/projectkorra/waterbending/healing/HealingWaters.java index d9328624..5c74e26d 100644 --- a/src/com/projectkorra/projectkorra/waterbending/healing/HealingWaters.java +++ b/src/com/projectkorra/projectkorra/waterbending/healing/HealingWaters.java @@ -20,10 +20,12 @@ import com.projectkorra.projectkorra.ability.ElementalAbility; import com.projectkorra.projectkorra.ability.HealingAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.chiblocking.Smokescreen; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.HealingWatersConfig; import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.waterbending.util.WaterReturn; -public class HealingWaters extends HealingAbility { +@SuppressWarnings("deprecation") +public class HealingWaters extends HealingAbility { // Configurable Variables. @Attribute(Attribute.COOLDOWN) @@ -55,8 +57,8 @@ public class HealingWaters extends HealingAbility { private boolean hasReached = false; private String hex; - public HealingWaters(final Player player) { - super(player); + public HealingWaters(final HealingWatersConfig config, final Player player) { + super(config, player); if (!this.bPlayer.canBend(this)) { this.remove(); @@ -77,13 +79,13 @@ public class HealingWaters extends HealingAbility { public void setFields() { - this.cooldown = getConfig().getLong("Abilities.Water.HealingWaters.Cooldown"); - this.range = getConfig().getDouble("Abilities.Water.HealingWaters.Range"); - this.interval = getConfig().getLong("Abilities.Water.HealingWaters.Interval"); - this.chargeTime = getConfig().getLong("Abilities.Water.HealingWaters.ChargeTime"); - this.potionPotency = getConfig().getInt("Abilities.Water.HealingWaters.PotionPotency"); - this.duration = getConfig().getLong("Abilities.Water.HealingWaters.Duration"); - this.enableParticles = getConfig().getBoolean("Abilities.Water.HealingWaters.EnableParticles"); + this.cooldown = config.Cooldown; + this.range = config.Range; + this.interval = config.Interval; + this.chargeTime = config.ChargeTime; + this.potionPotency = config.PotionPotency; + this.duration = config.Duration; + this.enableParticles = config.EnableParticles; this.hex = "00ffff"; } diff --git a/src/com/projectkorra/projectkorra/waterbending/ice/IceBlast.java b/src/com/projectkorra/projectkorra/waterbending/ice/IceBlast.java index cefee2f2..f70ef4d6 100644 --- a/src/com/projectkorra/projectkorra/waterbending/ice/IceBlast.java +++ b/src/com/projectkorra/projectkorra/waterbending/ice/IceBlast.java @@ -20,6 +20,7 @@ import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.ability.IceAbility; import com.projectkorra.projectkorra.attribute.Attribute; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.IceBlastConfig; import com.projectkorra.projectkorra.util.BlockSource; import com.projectkorra.projectkorra.util.ClickType; import com.projectkorra.projectkorra.util.DamageHandler; @@ -28,7 +29,7 @@ import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.util.TempPotionEffect; import com.projectkorra.projectkorra.waterbending.util.WaterReturn; -public class IceBlast extends IceAbility { +public class IceBlast extends IceAbility { private boolean prepared; private boolean settingUp; @@ -52,17 +53,17 @@ public class IceBlast extends IceAbility { private boolean allowSnow; public TempBlock source; - public IceBlast(final Player player) { - super(player); + public IceBlast(final IceBlastConfig config, final Player player) { + super(config, player); this.data = 0; - this.interval = getConfig().getLong("Abilities.Water.IceBlast.Interval"); - this.collisionRadius = getConfig().getDouble("Abilities.Water.IceBlast.CollisionRadius"); - this.deflectRange = getConfig().getDouble("Abilities.Water.IceBlast.DeflectRange"); - this.range = getConfig().getDouble("Abilities.Water.IceBlast.Range"); - this.damage = getConfig().getInt("Abilities.Water.IceBlast.Damage"); - this.cooldown = getConfig().getInt("Abilities.Water.IceBlast.Cooldown"); - this.allowSnow = getConfig().getBoolean("Abilities.Water.IceBlast.AllowSnow"); + this.interval = config.Interval; + this.collisionRadius = config.CollisionRadius; + this.deflectRange = config.DeflectRange; + this.range = config.Range; + this.damage = config.Damage; + this.cooldown = config.Cooldown; + this.allowSnow = config.AllowSnow; this.damage = getNightFactor(this.damage, player.getWorld()); @@ -71,9 +72,9 @@ public class IceBlast extends IceAbility { } if (this.bPlayer.isAvatarState()) { - this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Water.IceBlast.Cooldown"); - this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceBlast.Range"); - this.damage = getConfig().getInt("Abilities.Avatar.AvatarState.Water.IceBlast.Damage"); + this.cooldown = config.AvatarState_Cooldown; + this.range = config.AvatarState_Range; + this.damage = config.AvatarState_Damage; } block(player); diff --git a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java index 29eea0e4..75db2945 100644 --- a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java +++ b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java @@ -18,13 +18,14 @@ import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.ability.IceAbility; import com.projectkorra.projectkorra.attribute.Attribute; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.IceSpikeConfig; import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.util.TempPotionEffect; import com.projectkorra.projectkorra.waterbending.plant.PlantRegrowth; import com.projectkorra.projectkorra.waterbending.util.WaterReturn; -public class IceSpikeBlast extends IceAbility { +public class IceSpikeBlast extends IceAbility { private boolean prepared; private boolean settingUp; @@ -54,23 +55,23 @@ public class IceSpikeBlast extends IceAbility { private TempBlock source; private Material sourceType; - public IceSpikeBlast(final Player player) { - super(player); + public IceSpikeBlast(final IceSpikeConfig config, final Player player) { + super(config, player); if (this.bPlayer.isOnCooldown("IceSpikeBlast")) { return; } this.data = 0; - this.interval = getConfig().getLong("Abilities.Water.IceSpike.Blast.Interval"); - this.slowCooldown = getConfig().getLong("Abilities.Water.IceSpike.Blast.SlowCooldown"); - this.collisionRadius = getConfig().getDouble("Abilities.Water.IceSpike.Blast.CollisionRadius"); - this.deflectRange = getConfig().getDouble("Abilities.Water.IceSpike.Blast.DeflectRange"); - this.range = getConfig().getDouble("Abilities.Water.IceSpike.Blast.Range"); - this.damage = getConfig().getDouble("Abilities.Water.IceSpike.Blast.Damage"); - this.cooldown = getConfig().getLong("Abilities.Water.IceSpike.Blast.Cooldown"); - this.slowPotency = getConfig().getInt("Abilities.Water.IceSpike.Blast.SlowPotency"); - this.slowDuration = getConfig().getInt("Abilities.Water.IceSpike.Blast.SlowDuration"); + this.interval = config.BlastConfig.Interval; + this.slowCooldown = config.BlastConfig.SlowCooldown; + this.collisionRadius = config.BlastConfig.CollisionRadius; + this.deflectRange = config.BlastConfig.DeflectRange; + this.range = config.BlastConfig.Range; + this.damage = config.BlastConfig.Damage; + this.cooldown = config.BlastConfig.Cooldown; + this.slowPotency = config.BlastConfig.SlowPotency; + this.slowDuration = config.BlastConfig.SlowDuration; if (!this.bPlayer.canBend(this) || !this.bPlayer.canIcebend()) { return; @@ -79,10 +80,10 @@ public class IceSpikeBlast extends IceAbility { if (this.bPlayer.isAvatarState()) { this.cooldown = 0; this.slowCooldown = 0; - this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceSpike.Blast.Range"); - this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceSpike.Blast.Damage"); - this.slowPotency = getConfig().getInt("Abilities.Avatar.AvatarState.Water.IceSpike.Blast.SlowPotency"); - this.slowDuration = getConfig().getInt("Abilities.Avatar.AvatarState.Water.IceSpike.Blast.SlowDuration"); + this.range = config.BlastConfig.AvatarState_Range; + this.damage = config.BlastConfig.AvatarState_Damage; + this.slowPotency = config.BlastConfig.AvatarState_SlowPotency; + this.slowDuration = config.BlastConfig.AvatarState_SlowDuration; } block(player); @@ -95,7 +96,7 @@ public class IceSpikeBlast extends IceAbility { } if (this.sourceBlock == null) { - new IceSpikePillarField(player); + new IceSpikePillarField(config, player); } else if (GeneralMethods.isRegionProtectedFromBuild(this, this.sourceBlock.getLocation())) { return; } else { @@ -295,7 +296,7 @@ public class IceSpikeBlast extends IceAbility { } } - public static void activate(final Player player) { + public static void activate(final IceSpikeConfig config, final Player player) { redirect(player); boolean activate = false; final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); @@ -317,9 +318,9 @@ public class IceSpikeBlast extends IceAbility { } if (!activate && !getPlayers(IceSpikeBlast.class).contains(player)) { - final IceSpikePillar spike = new IceSpikePillar(player); + final IceSpikePillar spike = new IceSpikePillar(config, player); if (!spike.isStarted()) { - waterBottle(player); + waterBottle(config, player); } } } @@ -387,21 +388,19 @@ public class IceSpikeBlast extends IceAbility { } } - private static void waterBottle(final Player player) { - final long range = getConfig().getLong("Abilities.Water.IceSpike.Projectile.Range"); - + private static void waterBottle(final IceSpikeConfig config, final Player player) { if (WaterReturn.hasWaterBottle(player)) { final Location eyeLoc = player.getEyeLocation(); final Block block = eyeLoc.add(eyeLoc.getDirection().normalize()).getBlock(); if (isTransparent(player, block) && isTransparent(player, eyeLoc.getBlock())) { - final LivingEntity target = (LivingEntity) GeneralMethods.getTargetedEntity(player, range); + final LivingEntity target = (LivingEntity) GeneralMethods.getTargetedEntity(player, config.BlastConfig.ProjectileRange); Location destination; if (target == null) { - destination = GeneralMethods.getTargetedLocation(player, range, getTransparentMaterials()); + destination = GeneralMethods.getTargetedLocation(player, config.BlastConfig.ProjectileRange, getTransparentMaterials()); } else { - destination = GeneralMethods.getPointOnLine(player.getEyeLocation(), target.getEyeLocation(), range); + destination = GeneralMethods.getPointOnLine(player.getEyeLocation(), target.getEyeLocation(), config.BlastConfig.ProjectileRange); } if (destination.distanceSquared(block.getLocation()) < 1) { @@ -411,7 +410,7 @@ public class IceSpikeBlast extends IceAbility { final BlockState state = block.getState(); block.setType(Material.WATER); block.setBlockData(GeneralMethods.getWaterData(0)); - final IceSpikeBlast iceSpike = new IceSpikeBlast(player); + final IceSpikeBlast iceSpike = new IceSpikeBlast(config, player); iceSpike.throwIce(); iceSpike.sourceBlock = null; diff --git a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillar.java b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillar.java index 55a497fc..8c809517 100644 --- a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillar.java +++ b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillar.java @@ -22,14 +22,15 @@ import com.projectkorra.projectkorra.ability.ElementalAbility; import com.projectkorra.projectkorra.ability.IceAbility; import com.projectkorra.projectkorra.ability.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.IceSpikeConfig; import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.util.TempPotionEffect; -public class IceSpikePillar extends IceAbility { +public class IceSpikePillar extends IceAbility { /** The list of blocks IceSpike uses */ - private final Map ice_blocks = new HashMap(); + private final Map ice_blocks = new HashMap<>(); @Attribute(Attribute.HEIGHT) private int height; @@ -62,8 +63,8 @@ public class IceSpikePillar extends IceAbility { private ArrayList damaged; protected boolean inField = false; // If it's part of a field or not. - public IceSpikePillar(final Player player) { - super(player); + public IceSpikePillar(final IceSpikeConfig config, final Player player) { + super(config, player); this.setFields(); if (this.bPlayer.isOnCooldown("IceSpikePillar")) { @@ -110,8 +111,8 @@ public class IceSpikePillar extends IceAbility { } } - public IceSpikePillar(final Player player, final Location origin, final int damage, final Vector throwing, final long aoecooldown) { - super(player); + public IceSpikePillar(final IceSpikeConfig config, final Player player, final Location origin, final int damage, final Vector throwing, final long aoecooldown) { + super(config, player); this.setFields(); this.cooldown = aoecooldown; @@ -132,26 +133,26 @@ public class IceSpikePillar extends IceAbility { private void setFields() { this.direction = new Vector(0, 1, 0); - this.speed = getConfig().getDouble("Abilities.Water.IceSpike.Speed"); - this.slowCooldown = getConfig().getLong("Abilities.Water.IceSpike.SlowCooldown"); - this.slowPower = getConfig().getInt("Abilities.Water.IceSpike.SlowPower"); - this.slowDuration = getConfig().getInt("Abilities.Water.IceSpike.SlowDuration"); - this.damage = getConfig().getDouble("Abilities.Water.IceSpike.Damage"); - this.range = getConfig().getDouble("Abilities.Water.IceSpike.Range"); - this.cooldown = getConfig().getLong("Abilities.Water.IceSpike.Cooldown"); - this.height = getConfig().getInt("Abilities.Water.IceSpike.Height"); - this.thrownForce = new Vector(0, getConfig().getDouble("Abilities.Water.IceSpike.Push"), 0); + this.speed = config.Speed; + this.slowCooldown = config.SlowCooldown; + this.slowPower = config.SlowPower; + this.slowDuration = config.SlowDuration; + this.damage = config.Damage; + this.range = config.Range; + this.cooldown = config.Cooldown; + this.height = config.Height; + this.thrownForce = new Vector(0, config.Push, 0); this.damaged = new ArrayList<>(); this.interval = (long) (1000. / this.speed); if (this.bPlayer.isAvatarState()) { - this.slowPower = getConfig().getInt("Abilities.Avatar.AvatarState.Water.IceSpike.SlowPower"); - this.slowDuration = getConfig().getInt("Abilities.Avatar.AvatarState.Water.IceSpike.SlowDuration"); - this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceSpike.Damage"); - this.range = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceSpike.Range"); - this.height = getConfig().getInt("Abilities.Avatar.AvatarState.Water.IceSpike.Height"); - this.thrownForce = new Vector(0, getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceSpike.Push"), 0); + this.slowPower = config.AvatarState_SlowPower; + this.slowDuration = config.AvatarState_SlowDuration; + this.damage = config.AvatarState_Damage; + this.range = config.AvatarState_Range; + this.height = config.AvatarState_Height; + this.thrownForce.setY(config.AvatarState_Push); } } diff --git a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillarField.java b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillarField.java index bed947b3..626aa588 100644 --- a/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillarField.java +++ b/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikePillarField.java @@ -18,9 +18,10 @@ import com.projectkorra.projectkorra.ability.ElementalAbility; import com.projectkorra.projectkorra.ability.IceAbility; import com.projectkorra.projectkorra.ability.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.IceSpikeConfig; import com.projectkorra.projectkorra.util.TempBlock; -public class IceSpikePillarField extends IceAbility { +public class IceSpikePillarField extends IceAbility { @Attribute(Attribute.DAMAGE) private double damage; @@ -34,21 +35,21 @@ public class IceSpikePillarField extends IceAbility { private double knockup; private Vector thrownForce; - public IceSpikePillarField(final Player player) { - super(player); + public IceSpikePillarField(final IceSpikeConfig config, final Player player) { + super(config, player); if (this.bPlayer.isOnCooldown("IceSpikePillarField")) { return; } - this.damage = getConfig().getDouble("Abilities.Water.IceSpike.Field.Damage"); - this.radius = getConfig().getDouble("Abilities.Water.IceSpike.Field.Radius"); - this.cooldown = getConfig().getLong("Abilities.Water.IceSpike.Field.Cooldown"); - this.knockup = getConfig().getDouble("Abilities.Water.IceSpike.Field.Knockup"); + this.damage = config.FieldConfig.Damage; + this.radius = config.FieldConfig.Radius; + this.cooldown = config.FieldConfig.Cooldown; + this.knockup = config.FieldConfig.Knockup; if (this.bPlayer.isAvatarState()) { - this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceSpike.Field.Damage"); - this.radius = getConfig().getDouble("Abilities.Avatar.AvatarState.Water.IceSpike.Field.Radius"); + this.damage = config.FieldConfig.AvatarState_Damage; + this.radius = config.FieldConfig.AvatarState_Radius; } this.numberOfSpikes = (int) (((this.radius) * (this.radius)) / 4); @@ -118,7 +119,7 @@ public class IceSpikePillarField extends IceAbility { } if (targetBlock.getRelative(BlockFace.UP).getType() != Material.ICE) { - final IceSpikePillar pillar = new IceSpikePillar(this.player, targetBlock.getLocation(), (int) this.damage, this.thrownForce, this.cooldown); + final IceSpikePillar pillar = new IceSpikePillar(config, this.player, targetBlock.getLocation(), (int) this.damage, this.thrownForce, this.cooldown); pillar.inField = true; iceBlocks.remove(targetBlock); } else { diff --git a/src/com/projectkorra/projectkorra/waterbending/ice/PhaseChange.java b/src/com/projectkorra/projectkorra/waterbending/ice/PhaseChange.java index 2fa55db1..25cdb046 100644 --- a/src/com/projectkorra/projectkorra/waterbending/ice/PhaseChange.java +++ b/src/com/projectkorra/projectkorra/waterbending/ice/PhaseChange.java @@ -19,6 +19,7 @@ import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.ElementalAbility; import com.projectkorra.projectkorra.ability.IceAbility; import com.projectkorra.projectkorra.attribute.Attribute; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.PhaseChangeConfig; import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.waterbending.SurgeWall; import com.projectkorra.projectkorra.waterbending.SurgeWave; @@ -26,7 +27,8 @@ import com.projectkorra.projectkorra.waterbending.Torrent; import com.projectkorra.projectkorra.waterbending.WaterSpoutWave; import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArmsSpear; -public class PhaseChange extends IceAbility { +@SuppressWarnings("deprecation") +public class PhaseChange extends IceAbility { public static enum PhaseChangeType { FREEZE, MELT, CUSTOM; @@ -50,7 +52,7 @@ public class PhaseChange extends IceAbility { private final Random r = new Random(); @Attribute(Attribute.SELECT_RANGE) - private int sourceRange = 8; + private double sourceRange = 8; // Freeze Variables. @Attribute("Freeze" + Attribute.COOLDOWN) @@ -75,8 +77,8 @@ public class PhaseChange extends IceAbility { private boolean allowMeltFlow; private final CopyOnWriteArrayList melted_blocks = new CopyOnWriteArrayList<>(); - public PhaseChange(final Player player, final PhaseChangeType type) { - super(player); + public PhaseChange(final PhaseChangeConfig config, final Player player, final PhaseChangeType type) { + super(config, player); this.startNewType(type); this.start(); } @@ -158,33 +160,33 @@ public class PhaseChange extends IceAbility { if (isNight(this.player.getWorld())) { night = (int) Math.round(getNightFactor()); } - this.sourceRange = night * getConfig().getInt("Abilities.Water.PhaseChange.SourceRange"); + this.sourceRange = night * config.SourceRange; switch (type) { case FREEZE: - this.depth = night * getConfig().getInt("Abilities.Water.PhaseChange.Freeze.Depth"); - this.controlRadius = night * getConfig().getDouble("Abilities.Water.PhaseChange.Freeze.ControlRadius"); - this.freezeCooldown = getConfig().getLong("Abilities.Water.PhaseChange.Freeze.Cooldown"); - this.freezeRadius = night * getConfig().getInt("Abilities.Water.PhaseChange.Freeze.Radius"); + this.depth = night * config.FreezeConfig.Depth; + this.controlRadius = night * config.FreezeConfig.ControlRadius; + this.freezeCooldown = config.FreezeConfig.Cooldown; + this.freezeRadius = night * config.FreezeConfig.Radius; this.freezeArea(GeneralMethods.getTargetedLocation(this.player, this.sourceRange)); case MELT: this.meltRadius = 1; - this.meltCooldown = getConfig().getLong("Abilities.Water.PhaseChange.Melt.Cooldown"); - this.meltSpeed = getConfig().getDouble("Abilities.Water.PhaseChange.Melt.Speed") * night; - this.meltMaxRadius = night * getConfig().getInt("Abilities.Water.PhaseChange.Melt.Radius"); - this.allowMeltFlow = getConfig().getBoolean("Abilities.Water.PhaseChange.Melt.AllowFlow"); + this.meltCooldown = config.MeltConfig.Cooldown; + this.meltSpeed = config.MeltConfig.Speed * night; + this.meltMaxRadius = night * config.MeltConfig.Radius; + this.allowMeltFlow = config.MeltConfig.AllowFlow; case CUSTOM: - this.depth = night * getConfig().getInt("Abilities.Water.PhaseChange.Freeze.Depth"); - this.controlRadius = night * getConfig().getDouble("Abilities.Water.PhaseChange.Freeze.ControlRadius"); - this.freezeCooldown = getConfig().getLong("Abilities.Water.PhaseChange.Freeze.Cooldown"); - this.freezeRadius = night * getConfig().getInt("Abilities.Water.PhaseChange.Freeze.Radius"); + this.depth = night * config.FreezeConfig.Depth; + this.controlRadius = night * config.FreezeConfig.ControlRadius; + this.freezeCooldown = config.FreezeConfig.Cooldown; + this.freezeRadius = night * config.FreezeConfig.Radius; this.meltRadius = 1; - this.meltCooldown = getConfig().getLong("Abilities.Water.PhaseChange.Melt.Cooldown"); - this.meltSpeed = getConfig().getDouble("Abilities.Water.PhaseChange.Melt.Speed") * night; - this.meltMaxRadius = night * getConfig().getInt("Abilities.Water.PhaseChange.Melt.Radius"); - this.allowMeltFlow = getConfig().getBoolean("Abilities.Water.PhaseChange.Melt.AllowFlow"); + this.meltCooldown = config.MeltConfig.Cooldown; + this.meltSpeed = config.MeltConfig.Speed * night; + this.meltMaxRadius = night * config.MeltConfig.Radius; + this.allowMeltFlow = config.MeltConfig.AllowFlow; } } @@ -532,11 +534,11 @@ public class PhaseChange extends IceAbility { this.depth = value; } - public int getSourceRange() { + public double getSourceRange() { return this.sourceRange; } - public void setSourceRange(final int value) { + public void setSourceRange(final double value) { this.sourceRange = value; } diff --git a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArms.java b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArms.java index da9ab596..065d0900 100644 --- a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArms.java +++ b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArms.java @@ -20,7 +20,7 @@ import com.projectkorra.projectkorra.ability.FireAbility; import com.projectkorra.projectkorra.ability.WaterAbility; import com.projectkorra.projectkorra.ability.util.MultiAbilityManager; import com.projectkorra.projectkorra.attribute.Attribute; -import com.projectkorra.projectkorra.configuration.ConfigManager; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.WaterArmsConfig; import com.projectkorra.projectkorra.firebending.lightning.Lightning; import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.ParticleEffect; @@ -29,7 +29,8 @@ import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArmsWhip.W import com.projectkorra.projectkorra.waterbending.plant.PlantRegrowth; import com.projectkorra.projectkorra.waterbending.util.WaterReturn; -public class WaterArms extends WaterAbility { +@SuppressWarnings("deprecation") +public class WaterArms extends WaterAbility { /** * Arm Enum value for deciding which arm is being used. @@ -53,7 +54,7 @@ public class WaterArms extends WaterAbility { @Attribute("InitialLength") private int initLength; @Attribute(Attribute.SELECT_RANGE) - private int sourceGrabRange; + private double sourceGrabRange; @Attribute("MaxPunches") private int maxPunches; @Attribute("MaxIceBlasts") @@ -73,23 +74,23 @@ public class WaterArms extends WaterAbility { private List right, left; private Set external; - public WaterArms(final Player player) { - super(player); + public WaterArms(final WaterArmsConfig config, final Player player) { + super(config, player); this.fullSource = true; this.leftArmConsumed = false; this.rightArmConsumed = false; - this.canUsePlantSource = getConfig().getBoolean("Abilities.Water.WaterArms.Arms.AllowPlantSource"); - this.lightningEnabled = getConfig().getBoolean("Abilities.Water.WaterArms.Arms.Lightning.Enabled"); - this.lightningKill = getConfig().getBoolean("Abilities.Water.WaterArms.Arms.Lightning.KillUser"); - this.initLength = getConfig().getInt("Abilities.Water.WaterArms.Arms.InitialLength"); - this.sourceGrabRange = getConfig().getInt("Abilities.Water.WaterArms.Arms.SourceGrabRange"); - this.maxPunches = getConfig().getInt("Abilities.Water.WaterArms.Arms.MaxAttacks"); - this.maxIceBlasts = getConfig().getInt("Abilities.Water.WaterArms.Arms.MaxIceShots"); - this.maxUses = getConfig().getInt("Abilities.Water.WaterArms.Arms.MaxAlternateUsage"); - this.cooldown = getConfig().getLong("Abilities.Water.WaterArms.Arms.Cooldown"); - this.lightningDamage = getConfig().getDouble("Abilities.Water.WaterArms.Arms.Lightning.Damage"); - this.sneakMsg = ConfigManager.languageConfig.get().getString("Abilities.Water.WaterArms.SneakMessage"); + this.canUsePlantSource = config.AllowPlantSource; + this.lightningEnabled = config.LightningVulnerability; + this.lightningKill = config.LightningInstaKill; + this.initLength = config.InitialLength; + this.sourceGrabRange = config.SourceGrabRange; + this.maxPunches = config.MaxAttacks; + this.maxIceBlasts = config.MaxIceShots; + this.maxUses = config.MaxAlternateUsage; + this.cooldown = config.Cooldown; + this.lightningDamage = config.LightningDamage; + this.sneakMsg = config.SneakMessage; this.lengthReduction = 0; this.selectedSlot = 0; this.freezeSlot = 4; @@ -109,35 +110,35 @@ public class WaterArms extends WaterAbility { switch (player.getInventory().getHeldItemSlot()) { case 0: if (player.hasPermission("bending.ability.WaterArms.Pull")) { - new WaterArmsWhip(player, Whip.PULL); + new WaterArmsWhip(config, player, Whip.PULL); } break; case 1: if (player.hasPermission("bending.ability.WaterArms.Punch")) { - new WaterArmsWhip(player, Whip.PUNCH); + new WaterArmsWhip(config, player, Whip.PUNCH); } break; case 2: if (player.hasPermission("bending.ability.WaterArms.Grapple")) { - new WaterArmsWhip(player, Whip.GRAPPLE); + new WaterArmsWhip(config, player, Whip.GRAPPLE); } break; case 3: if (player.hasPermission("bending.ability.WaterArms.Grab")) { - new WaterArmsWhip(player, Whip.GRAB); + new WaterArmsWhip(config, player, Whip.GRAB); } break; case 4: if (player.hasPermission("bending.ability.WaterArms.Freeze") && this.bPlayer.canIcebend()) { - new WaterArmsFreeze(player); + new WaterArmsFreeze(config, player); } break; case 5: if (player.hasPermission("bending.ability.WaterArms.Spear")) { if (this.bPlayer.canIcebend()) { - new WaterArmsSpear(player, true); + new WaterArmsSpear(config, player, true); } else { - new WaterArmsSpear(player, false); + new WaterArmsSpear(config, player, false); } } break; @@ -403,7 +404,7 @@ public class WaterArms extends WaterAbility { FireAbility.playLightningbendingParticle(l1); } if (this.lightningKill) { - DamageHandler.damageEntity(this.player, 60D, lightning); + DamageHandler.damageEntity(this.player, this.player.getMaxHealth() * 3, lightning); } else { DamageHandler.damageEntity(this.player, this.lightningDamage, lightning); } @@ -695,11 +696,11 @@ public class WaterArms extends WaterAbility { this.initLength = initLength; } - public int getSourceGrabRange() { + public double getSourceGrabRange() { return this.sourceGrabRange; } - public void setSourceGrabRange(final int sourceGrabRange) { + public void setSourceGrabRange(final double sourceGrabRange) { this.sourceGrabRange = sourceGrabRange; } diff --git a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsFreeze.java b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsFreeze.java index 4003d103..6c30437b 100644 --- a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsFreeze.java +++ b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsFreeze.java @@ -15,13 +15,14 @@ import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.IceAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.WaterArmsConfig; import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.ParticleEffect; import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.util.TempPotionEffect; import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArms.Arm; -public class WaterArmsFreeze extends IceAbility { +public class WaterArmsFreeze extends IceAbility { private boolean cancelled; private boolean usageCooldownEnabled; @@ -37,13 +38,13 @@ public class WaterArmsFreeze extends IceAbility { private Vector direction; private WaterArms waterArms; - public WaterArmsFreeze(final Player player) { - super(player); + public WaterArmsFreeze(final WaterArmsConfig config, final Player player) { + super(config, player); - this.usageCooldownEnabled = getConfig().getBoolean("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldown.Enabled"); - this.iceRange = getConfig().getInt("Abilities.Water.WaterArms.Freeze.Range"); - this.iceDamage = getConfig().getInt("Abilities.Water.WaterArms.Freeze.Damage"); - this.usageCooldown = getConfig().getLong("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldown.Freeze"); + this.usageCooldownEnabled = config.FreezeConfig.UsageCooldownEnabled; + this.iceRange = config.FreezeConfig.Range; + this.iceDamage = config.FreezeConfig.Damage; + this.usageCooldown = config.FreezeConfig.UsageCooldown; this.direction = player.getEyeLocation().getDirection(); this.createInstance(); diff --git a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsSpear.java b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsSpear.java index 861510cb..ba78dc43 100644 --- a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsSpear.java +++ b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsSpear.java @@ -19,11 +19,15 @@ import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.WaterAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; +import com.projectkorra.projectkorra.configuration.better.ConfigManager; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.WaterArmsConfig; +import com.projectkorra.projectkorra.configuration.better.configs.properties.WaterPropertiesConfig; import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArms.Arm; -public class WaterArmsSpear extends WaterAbility { +@SuppressWarnings({ "deprecation", "unused" }) +public class WaterArmsSpear extends WaterAbility { private static final Map ICE_BLOCKS = new ConcurrentHashMap(); @@ -57,24 +61,24 @@ public class WaterArmsSpear extends WaterAbility { private WaterArms waterArms; private final List spearLocations; - public WaterArmsSpear(final Player player, final boolean freeze) { - super(player); + public WaterArmsSpear(final WaterArmsConfig config, final Player player, final boolean freeze) { + super(config, player); this.canFreeze = freeze; - this.usageCooldownEnabled = getConfig().getBoolean("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldown.Enabled"); - this.spearDamageEnabled = getConfig().getBoolean("Abilities.Water.WaterArms.Spear.DamageEnabled"); - this.spearLength = getConfig().getInt("Abilities.Water.WaterArms.Spear.Length"); - this.spearRange = getConfig().getInt("Abilities.Water.WaterArms.Spear.Range"); - this.spearRangeNight = getConfig().getInt("Abilities.Water.WaterArms.Spear.NightAugments.Range.Normal"); - this.spearRangeFullMoon = getConfig().getInt("Abilities.Water.WaterArms.Spear.NightAugments.Range.FullMoon"); - this.spearSphereRadius = getConfig().getInt("Abilities.Water.WaterArms.Spear.SphereRadius"); - this.spearSphereNight = getConfig().getInt("Abilities.Water.WaterArms.Spear.NightAugments.Sphere.Normal"); - this.spearSphereFullMoon = getConfig().getInt("Abilities.Water.WaterArms.Spear.NightAugments.Sphere.FullMoon"); - this.spearDuration = getConfig().getLong("Abilities.Water.WaterArms.Spear.Duration"); - this.spearDurationNight = getConfig().getLong("Abilities.Water.WaterArms.Spear.NightAugments.Duration.Normal"); - this.spearDurationFullMoon = getConfig().getLong("Abilities.Water.WaterArms.Spear.NightAugments.Duration.FullMoon"); - this.usageCooldown = getConfig().getLong("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldown.Spear"); - this.spearDamage = getConfig().getDouble("Abilities.Water.WaterArms.Spear.Damage"); + this.usageCooldownEnabled = config.SpearConfig.UsageCooldownEnabled; + this.spearDamageEnabled = config.SpearConfig.DamageEnabled; + this.spearLength = config.SpearConfig.Length; + this.spearRange = config.SpearConfig.RangeDay; + this.spearRangeNight = config.SpearConfig.RangeNight; + this.spearRangeFullMoon = config.SpearConfig.RangeFullMoon; + this.spearSphereRadius = config.SpearConfig.SphereRadiusDay; + this.spearSphereNight = config.SpearConfig.SphereRadiusNight; + this.spearSphereFullMoon = config.SpearConfig.SphereRadiusFullMoon; + this.spearDuration = config.SpearConfig.DurationDay; + this.spearDurationNight = config.SpearConfig.DurationNight; + this.spearDurationFullMoon = config.SpearConfig.DurationFullMoon; + this.usageCooldown = config.SpearConfig.UsageCooldown; + this.spearDamage = config.SpearConfig.Damage; this.spearLocations = new ArrayList<>(); this.getNightAugments(); @@ -238,10 +242,10 @@ public class WaterArmsSpear extends WaterAbility { if (Commands.invincible.contains(((Player) entity).getName())) { return; } - if (!getConfig().getBoolean("Properties.Water.FreezePlayerHead") && GeneralMethods.playerHeadIsInBlock((Player) entity, block, true)) { + if (!ConfigManager.getConfig(WaterPropertiesConfig.class).FreezePlayerHead && GeneralMethods.playerHeadIsInBlock((Player) entity, block, true)) { continue ICE_SETTING; } - if (!getConfig().getBoolean("Properties.Water.FreezePlayerFeet") && GeneralMethods.playerFeetIsInBlock((Player) entity, block, true)) { + if (!ConfigManager.getConfig(WaterPropertiesConfig.class).FreezePlayerFeet && GeneralMethods.playerFeetIsInBlock((Player) entity, block, true)) { continue ICE_SETTING; } } diff --git a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsWhip.java b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsWhip.java index 1bf79d3d..33765605 100644 --- a/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsWhip.java +++ b/src/com/projectkorra/projectkorra/waterbending/multiabilities/WaterArmsWhip.java @@ -17,11 +17,12 @@ import com.projectkorra.projectkorra.ability.WaterAbility; import com.projectkorra.projectkorra.ability.util.MultiAbilityManager; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.WaterArmsConfig; import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArms.Arm; -public class WaterArmsWhip extends WaterAbility { +public class WaterArmsWhip extends WaterAbility { /** * Whip Enum value for deciding what ability should be executed. @@ -67,42 +68,42 @@ public class WaterArmsWhip extends WaterAbility { private Location end; private WaterArms waterArms; - public WaterArmsWhip(final Player player, final Whip ability) { - super(player); + public WaterArmsWhip(final WaterArmsConfig config, final Player player, final Whip ability) { + super(config, player); this.ability = ability; this.reverting = false; this.hasDamaged = false; this.grappled = false; this.grabbed = false; - this.grappleRespectRegions = getConfig().getBoolean("Abilities.Water.WaterArms.Whip.Grapple.RespectRegions"); - this.usageCooldownEnabled = getConfig().getBoolean("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldown.Enabled"); - this.whipLength = getConfig().getInt("Abilities.Water.WaterArms.Whip.MaxLength"); - this.whipLengthWeak = getConfig().getInt("Abilities.Water.WaterArms.Whip.MaxLengthWeak"); - this.whipLengthNight = getConfig().getInt("Abilities.Water.WaterArms.Whip.NightAugments.MaxLength.Normal"); - this.whipLengthFullMoon = getConfig().getInt("Abilities.Water.WaterArms.Whip.NightAugments.MaxLength.FullMoon"); - this.initLength = getConfig().getInt("Abilities.Water.WaterArms.Arms.InitialLength"); - this.punchLength = getConfig().getInt("Abilities.Water.WaterArms.Whip.Punch.MaxLength"); - this.punchLengthNight = getConfig().getInt("Abilities.Water.WaterArms.Whip.Punch.NightAugments.MaxLength.Normal"); - this.punchLengthFullMoon = getConfig().getInt("Abilities.Water.WaterArms.Whip.Punch.NightAugments.MaxLength.FullMoon"); + this.grappleRespectRegions = config.WhipConfig.GrappleRespectRegions; + this.usageCooldownEnabled = config.WhipConfig.UsageCooldownEnabled; + this.whipLength = config.WhipConfig.MaxLengthDay; + this.whipLengthWeak = config.WhipConfig.MaxLengthWeak; + this.whipLengthNight = config.WhipConfig.MaxLengthNight; + this.whipLengthFullMoon = config.WhipConfig.MaxLengthFullMoon; + this.initLength = config.InitialLength; + this.punchLength = config.WhipConfig.PunchLengthDay; + this.punchLengthNight = config.WhipConfig.PunchLengthNight; + this.punchLengthFullMoon = config.WhipConfig.PunchLengthFullMoon; this.activeLength = this.initLength; this.whipSpeed = 1; - this.grabDuration = getConfig().getLong("Abilities.Water.WaterArms.Whip.Grab.Duration"); - this.pullMultiplier = getConfig().getDouble("Abilities.Water.WaterArms.Whip.Pull.Multiplier"); - this.punchDamage = getConfig().getDouble("Abilities.Water.WaterArms.Whip.Punch.Damage"); + this.grabDuration = config.WhipConfig.GrabDuration; + this.pullMultiplier = config.WhipConfig.PullFactor; + this.punchDamage = config.WhipConfig.PunchDamage; switch (ability) { case PULL: - this.usageCooldown = getConfig().getLong("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldown.Pull"); + this.usageCooldown = config.WhipConfig.UsageCooldownPull; break; case PUNCH: - this.usageCooldown = getConfig().getLong("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldown.Punch"); + this.usageCooldown = config.WhipConfig.UsageCooldownPunch; break; case GRAPPLE: - this.usageCooldown = getConfig().getLong("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldown.Grapple"); + this.usageCooldown = config.WhipConfig.UsageCooldownGrapple; break; case GRAB: - this.usageCooldown = getConfig().getLong("Abilities.Water.WaterArms.Arms.Cooldowns.UsageCooldown.Grab"); + this.usageCooldown = config.WhipConfig.UsageCooldownGrab; break; default: this.usageCooldown = 200; diff --git a/src/com/projectkorra/projectkorra/waterbending/passive/FastSwim.java b/src/com/projectkorra/projectkorra/waterbending/passive/FastSwim.java index eba89961..3d0ec100 100644 --- a/src/com/projectkorra/projectkorra/waterbending/passive/FastSwim.java +++ b/src/com/projectkorra/projectkorra/waterbending/passive/FastSwim.java @@ -6,19 +6,20 @@ import org.bukkit.entity.Player; import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.ability.PassiveAbility; import com.projectkorra.projectkorra.ability.WaterAbility; -import com.projectkorra.projectkorra.configuration.ConfigManager; +import com.projectkorra.projectkorra.configuration.better.ConfigManager; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.FastSwimConfig; import com.projectkorra.projectkorra.earthbending.EarthArmor; import com.projectkorra.projectkorra.waterbending.WaterSpout; import com.projectkorra.projectkorra.waterbending.multiabilities.WaterArms; -public class FastSwim extends WaterAbility implements PassiveAbility { +public class FastSwim extends WaterAbility implements PassiveAbility { private long cooldown; private double swimSpeed; private long duration; - public FastSwim(final Player player) { - super(player); + public FastSwim(final FastSwimConfig config, final Player player) { + super(config, player); if (this.bPlayer.isOnCooldown(this)) { return; } @@ -27,9 +28,9 @@ public class FastSwim extends WaterAbility implements PassiveAbility { return; } - this.cooldown = ConfigManager.getConfig().getLong("Abilities.Water.Passive.FastSwim.Cooldown"); - this.swimSpeed = ConfigManager.getConfig().getDouble("Abilities.Water.Passive.FastSwim.SpeedFactor"); - this.duration = ConfigManager.getConfig().getLong("Abilities.Water.Passive.FastSwim.Duration"); + this.cooldown = config.Cooldown; + this.swimSpeed = config.SpeedFactor; + this.duration = config.Duration; this.start(); } @@ -60,7 +61,7 @@ public class FastSwim extends WaterAbility implements PassiveAbility { } public static double getSwimSpeed() { - return ConfigManager.getConfig().getDouble("Abilities.Water.Passive.FastSwim.SpeedFactor"); + return ConfigManager.getConfig(FastSwimConfig.class).SpeedFactor; } @Override diff --git a/src/com/projectkorra/projectkorra/waterbending/passive/HydroSink.java b/src/com/projectkorra/projectkorra/waterbending/passive/HydroSink.java index 8b6f10a5..abdd2fed 100644 --- a/src/com/projectkorra/projectkorra/waterbending/passive/HydroSink.java +++ b/src/com/projectkorra/projectkorra/waterbending/passive/HydroSink.java @@ -10,16 +10,18 @@ import com.projectkorra.projectkorra.ability.ElementalAbility; import com.projectkorra.projectkorra.ability.PassiveAbility; import com.projectkorra.projectkorra.ability.WaterAbility; import com.projectkorra.projectkorra.command.Commands; -import com.projectkorra.projectkorra.configuration.ConfigManager; +import com.projectkorra.projectkorra.configuration.better.ConfigManager; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.water.HydroSinkConfig; +import com.projectkorra.projectkorra.configuration.better.configs.properties.GeneralPropertiesConfig; import com.projectkorra.projectkorra.util.TempBlock; -public class HydroSink extends WaterAbility implements PassiveAbility { - public HydroSink(final Player player) { - super(player); +public class HydroSink extends WaterAbility implements PassiveAbility { + public HydroSink(final HydroSinkConfig config, final Player player) { + super(config, player); } public static boolean applyNoFall(final Player player) { - if (Commands.isToggledForAll && ConfigManager.defaultConfig.get().getBoolean("Properties.TogglePassivesWithAllBending")) { + if (Commands.isToggledForAll && ConfigManager.getConfig(GeneralPropertiesConfig.class).TogglePassivesWithAllBending) { return false; } diff --git a/src/com/projectkorra/projectkorra/waterbending/plant/PlantRegrowth.java b/src/com/projectkorra/projectkorra/waterbending/plant/PlantRegrowth.java index 8a3a5174..e3fc46a3 100644 --- a/src/com/projectkorra/projectkorra/waterbending/plant/PlantRegrowth.java +++ b/src/com/projectkorra/projectkorra/waterbending/plant/PlantRegrowth.java @@ -10,8 +10,11 @@ import org.bukkit.entity.Player; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.ElementalAbility; import com.projectkorra.projectkorra.ability.PlantAbility; +import com.projectkorra.projectkorra.configuration.better.ConfigManager; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.EmptyAbilityConfig; +import com.projectkorra.projectkorra.configuration.better.configs.properties.WaterPropertiesConfig; -public class PlantRegrowth extends PlantAbility { +public class PlantRegrowth extends PlantAbility { private BlockData data; private long time; @@ -20,9 +23,9 @@ public class PlantRegrowth extends PlantAbility { private Block block; public PlantRegrowth(final Player player, final Block block) { - super(player); + super(new EmptyAbilityConfig(), player); - this.regrowTime = getConfig().getLong("Abilities.Water.Plantbending.RegrowTime"); + this.regrowTime = ConfigManager.getConfig(WaterPropertiesConfig.class).PlantRegrowTime; if (this.regrowTime != 0) { this.block = block; this.type = block.getType(); diff --git a/src/com/projectkorra/projectkorra/waterbending/util/WaterReturn.java b/src/com/projectkorra/projectkorra/waterbending/util/WaterReturn.java index bcdb7bec..80bafc92 100644 --- a/src/com/projectkorra/projectkorra/waterbending/util/WaterReturn.java +++ b/src/com/projectkorra/projectkorra/waterbending/util/WaterReturn.java @@ -15,6 +15,7 @@ import org.bukkit.util.Vector; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.WaterAbility; +import com.projectkorra.projectkorra.configuration.better.configs.abilities.EmptyAbilityConfig; import com.projectkorra.projectkorra.util.ParticleEffect; import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.waterbending.OctopusForm; @@ -22,7 +23,8 @@ import com.projectkorra.projectkorra.waterbending.SurgeWall; import com.projectkorra.projectkorra.waterbending.WaterManipulation; import com.projectkorra.projectkorra.waterbending.ice.IceSpikeBlast; -public class WaterReturn extends WaterAbility { +@SuppressWarnings("deprecation") +public class WaterReturn extends WaterAbility { private long time; private long interval; @@ -31,7 +33,7 @@ public class WaterReturn extends WaterAbility { private TempBlock block; public WaterReturn(final Player player, final Block block) { - super(player); + super(new EmptyAbilityConfig(), player); if (hasAbility(player, WaterReturn.class)) { return; } diff --git a/src/com/projectkorra/projectkorra/waterbending/util/WaterSourceGrabber.java b/src/com/projectkorra/projectkorra/waterbending/util/WaterSourceGrabber.java index cec2f76b..6bd08cca 100644 --- a/src/com/projectkorra/projectkorra/waterbending/util/WaterSourceGrabber.java +++ b/src/com/projectkorra/projectkorra/waterbending/util/WaterSourceGrabber.java @@ -17,6 +17,7 @@ import com.projectkorra.projectkorra.ability.ElementalAbility; import com.projectkorra.projectkorra.ability.WaterAbility; import com.projectkorra.projectkorra.util.TempBlock; +@SuppressWarnings("deprecation") public class WaterSourceGrabber { /*