From ff64cf9ca24376f449ec34dfc63bbfe0e6d682e0 Mon Sep 17 00:00:00 2001 From: StrangeOne101 Date: Thu, 30 Jun 2016 08:12:45 +1200 Subject: [PATCH] Some changes and fixes (#510) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Various Fixes • Added Java version to debug.txt file • Added Probending to the debug.txt file (and added PB methods) • Changed layout of debug.txt file • Fixed AddonAbilities with the same name as Stock abilities always being disabled • Fixed AcrobatStance and WarriorStance effects still being applied when the user is no longer a chiblocker * Changed all ConcurrentHashMaps to use generic map types • As the title says, it's an attempt to fix a Java 7/8 error in ConcurrentHashMaps. All Maps are still concurrent but their type is just a generic map, not a concurrent one. • Fixed FireBlast damage being slightly off * Fixed Java 7 Compile Errors --- .../projectkorra/BendingPlayer.java | 11 ++- .../projectkorra/GeneralMethods.java | 99 +++++++++++-------- .../projectkorra/ability/CoreAbility.java | 25 +++-- .../projectkorra/ability/EarthAbility.java | 11 ++- .../projectkorra/ability/FireAbility.java | 3 +- .../ability/util/ComboManager.java | 3 +- .../ability/util/MultiAbilityManager.java | 7 +- .../projectkorra/airbending/AirBlast.java | 10 +- .../projectkorra/airbending/AirBubble.java | 5 +- .../projectkorra/airbending/AirSuction.java | 7 +- .../projectkorra/airbending/AirSwipe.java | 7 +- .../projectkorra/airbending/Tornado.java | 5 +- .../chiblocking/AcrobatStance.java | 3 +- .../projectkorra/chiblocking/ChiCombo.java | 5 +- .../projectkorra/chiblocking/Paralyze.java | 9 +- .../projectkorra/chiblocking/Smokescreen.java | 13 +-- .../chiblocking/WarriorStance.java | 3 +- .../configuration/ConfigManager.java | 10 +- .../projectkorra/earthbending/Collapse.java | 5 +- .../earthbending/EarthPassive.java | 11 ++- .../projectkorra/earthbending/LavaFlow.java | 17 ++-- .../projectkorra/earthbending/LavaSurge.java | 5 +- .../projectkorra/earthbending/MetalClips.java | 9 +- .../projectkorra/earthbending/Ripple.java | 5 +- .../earthbending/Tremorsense.java | 5 +- .../projectkorra/firebending/FireBlast.java | 2 +- .../firebending/Illumination.java | 5 +- .../object/HorizontalVelocityTracker.java | 3 +- .../projectkorra/object/Preset.java | 3 +- .../projectkorra/util/Flight.java | 5 +- .../projectkorra/util/TempBlock.java | 5 +- .../projectkorra/util/TempPotionEffect.java | 7 +- .../waterbending/Bloodbending.java | 3 +- .../projectkorra/waterbending/Torrent.java | 5 +- .../projectkorra/waterbending/WaterArms.java | 5 +- .../waterbending/WaterArmsSpear.java | 5 +- .../waterbending/WaterManipulation.java | 5 +- .../projectkorra/waterbending/WaterSpout.java | 5 +- 38 files changed, 201 insertions(+), 150 deletions(-) diff --git a/src/com/projectkorra/projectkorra/BendingPlayer.java b/src/com/projectkorra/projectkorra/BendingPlayer.java index 30cc1082..0546adb4 100644 --- a/src/com/projectkorra/projectkorra/BendingPlayer.java +++ b/src/com/projectkorra/projectkorra/BendingPlayer.java @@ -3,6 +3,7 @@ package com.projectkorra.projectkorra; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -40,7 +41,7 @@ public class BendingPlayer { /** * ConcurrentHashMap that contains all instances of BendingPlayer, with UUID key. */ - private static final ConcurrentHashMap PLAYERS = new ConcurrentHashMap<>(); + private static final Map PLAYERS = new ConcurrentHashMap<>(); private boolean permaRemoved; private boolean toggled; @@ -54,8 +55,8 @@ public class BendingPlayer { private ArrayList elements; private ArrayList subelements; private HashMap abilities; - private ConcurrentHashMap cooldowns; - private ConcurrentHashMap toggledElements; + private Map cooldowns; + private Map toggledElements; /** * Creates a new {@link BendingPlayer}. @@ -423,7 +424,7 @@ public class BendingPlayer { * * @return map of cooldowns */ - public ConcurrentHashMap getCooldowns() { + public Map getCooldowns() { return cooldowns; } @@ -735,7 +736,7 @@ public class BendingPlayer { * * @return {@link #PLAYERS} */ - public static ConcurrentHashMap getPlayers() { + public static Map getPlayers() { return PLAYERS; } } diff --git a/src/com/projectkorra/projectkorra/GeneralMethods.java b/src/com/projectkorra/projectkorra/GeneralMethods.java index 338e45bd..17c61987 100644 --- a/src/com/projectkorra/projectkorra/GeneralMethods.java +++ b/src/com/projectkorra/projectkorra/GeneralMethods.java @@ -136,7 +136,7 @@ public class GeneralMethods { Material.WOOD_BUTTON, Material.WOOD_DOOR, Material.WORKBENCH }; // Represents PlayerName, previously checked blocks, and whether they were true or false - private static final ConcurrentHashMap> BLOCK_CACHE = new ConcurrentHashMap<>(); + private static final Map> BLOCK_CACHE = new ConcurrentHashMap<>(); private static final ArrayList INVINCIBLE = new ArrayList<>(); private static ProjectKorra plugin; @@ -892,7 +892,14 @@ public class GeneralMethods { float angle = location.getYaw() / 60; return location.clone().subtract(new Vector(Math.cos(angle), 0, Math.sin(angle)).normalize().multiply(distance)); } - + + public static Plugin getProbending() { + if (hasProbending()) { + return Bukkit.getServer().getPluginManager().getPlugin("Probending"); + } + return null; + } + public static Plugin getRPG() { if (hasRPG()) { return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraRPG"); @@ -1003,6 +1010,10 @@ public class GeneralMethods { public static boolean hasItems() { return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraItems") != null; } + + public static boolean hasProbending() { + return Bukkit.getServer().getPluginManager().getPlugin("Probending") != null; + } public static boolean hasRPG() { return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraRPG") != null; @@ -1073,7 +1084,7 @@ public class GeneralMethods { BLOCK_CACHE.put(player.getName(), new ConcurrentHashMap()); } - ConcurrentHashMap blockMap = BLOCK_CACHE.get(player.getName()); + Map blockMap = BLOCK_CACHE.get(player.getName()); Block block = loc.getBlock(); if (blockMap.containsKey(block)) { BlockCacheElement elem = blockMap.get(block); @@ -1425,57 +1436,35 @@ public class GeneralMethods { writeToDebug(""); writeToDebug(""); writeToDebug("Date Created: " + getCurrentDate()); + writeToDebug("Java Version: " + Runtime.class.getPackage().getImplementationVersion()); writeToDebug("Bukkit Version: " + Bukkit.getServer().getVersion()); writeToDebug(""); writeToDebug("ProjectKorra (Core) Information"); writeToDebug("===================="); writeToDebug("Version: " + plugin.getDescription().getVersion()); writeToDebug("Author: " + plugin.getDescription().getAuthors()); + List officialSidePlugins = new ArrayList(); if (hasRPG()) { - writeToDebug(""); - writeToDebug("ProjectKorra (RPG) Information"); - writeToDebug("===================="); - writeToDebug("Version: " + getRPG().getDescription().getVersion()); - writeToDebug("Author: " + getRPG().getDescription().getAuthors()); + officialSidePlugins.add("ProjectKorra RPG v" + getRPG().getDescription().getVersion()); } if (hasItems()) { - writeToDebug(""); - writeToDebug("ProjectKorra (Items) Information"); - writeToDebug("===================="); - writeToDebug("Version: " + getItems().getDescription().getVersion()); - writeToDebug("Author: " + getItems().getDescription().getAuthors()); + officialSidePlugins.add("ProjectKorra Items v" + getItems().getDescription().getVersion()); } if (hasSpirits()) { + officialSidePlugins.add("ProjectKorra Spirits v" + getSpirits().getDescription().getVersion()); + } + if (hasProbending()) { + officialSidePlugins.add("Probending v" + getProbending().getDescription().getVersion()); + } + if (!officialSidePlugins.isEmpty()) { writeToDebug(""); - writeToDebug("ProjectKorra (Spirits) Information"); + writeToDebug("ProjectKorra (Side Plugin) Information"); writeToDebug("===================="); - writeToDebug("Version: " + getSpirits().getDescription().getVersion()); - writeToDebug("Author: " + getSpirits().getDescription().getAuthors()); - } - writeToDebug(""); - writeToDebug("Ability Information"); - writeToDebug("===================="); - ArrayList stockAbils = new ArrayList(); - ArrayList unofficialAbils = new ArrayList(); - for (CoreAbility ability : CoreAbility.getAbilities()) { - if (ability.getClass().getPackage().getName().startsWith("com.projectkorra")) { - stockAbils.add(ability.getName()); - } else { - unofficialAbils.add(ability.getName()); - } - } - if (!stockAbils.isEmpty()) { - Collections.sort(stockAbils); - for (String ability : stockAbils) { - writeToDebug(ability + " - STOCK"); - } - } - if (!unofficialAbils.isEmpty()) { - Collections.sort(unofficialAbils); - for (String ability : unofficialAbils) { - writeToDebug(ability + " - UNOFFICAL"); + for (String line : officialSidePlugins) { + writeToDebug(line); } } + writeToDebug(""); writeToDebug("Supported Plugins"); writeToDebug("===================="); @@ -1527,6 +1516,31 @@ public class GeneralMethods { } } + writeToDebug(""); + writeToDebug("Ability Information"); + writeToDebug("===================="); + ArrayList stockAbils = new ArrayList(); + ArrayList unofficialAbils = new ArrayList(); + for (CoreAbility ability : CoreAbility.getAbilities()) { + if (ability.getClass().getPackage().getName().startsWith("com.projectkorra")) { + stockAbils.add(ability.getName()); + } else { + unofficialAbils.add(ability.getName()); + } + } + if (!stockAbils.isEmpty()) { + Collections.sort(stockAbils); + for (String ability : stockAbils) { + writeToDebug(ability + " - STOCK"); + } + } + if (!unofficialAbils.isEmpty()) { + Collections.sort(unofficialAbils); + for (String ability : unofficialAbils) { + writeToDebug(ability + " - UNOFFICAL"); + } + } + writeToDebug(""); writeToDebug("Collection Sizes"); writeToDebug("===================="); @@ -1558,7 +1572,10 @@ public class GeneralMethods { writeToDebug(""); writeToDebug("CoreAbility Debugger"); writeToDebug("===================="); - writeToDebug(CoreAbility.getDebugString()); + for (String line : CoreAbility.getDebugString().split("\\n")) { + writeToDebug(line); + } + } public static void saveAbility(BendingPlayer bPlayer, int slot, String ability) { @@ -1717,7 +1734,7 @@ public class GeneralMethods { new BukkitRunnable() { @Override public void run() { - for (ConcurrentHashMap map : BLOCK_CACHE.values()) { + for (Map map : BLOCK_CACHE.values()) { for (Iterator i = map.keySet().iterator(); i.hasNext();) { Block key = i.next(); BlockCacheElement value = map.get(key); diff --git a/src/com/projectkorra/projectkorra/ability/CoreAbility.java b/src/com/projectkorra/projectkorra/ability/CoreAbility.java index 5bcd0882..d3f8ae58 100644 --- a/src/com/projectkorra/projectkorra/ability/CoreAbility.java +++ b/src/com/projectkorra/projectkorra/ability/CoreAbility.java @@ -10,6 +10,7 @@ import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -51,9 +52,9 @@ import sun.reflect.ReflectionFactory; */ public abstract class CoreAbility implements Ability { - private static final ConcurrentHashMap, ConcurrentHashMap>> INSTANCES = new ConcurrentHashMap<>(); - private static final ConcurrentHashMap, Set> INSTANCES_BY_CLASS = new ConcurrentHashMap<>(); - private static final ConcurrentSkipListMap ABILITIES_BY_NAME = new ConcurrentSkipListMap<>(); + private static final Map, Map>> INSTANCES = new ConcurrentHashMap<>(); + private static final Map, Set> INSTANCES_BY_CLASS = new ConcurrentHashMap<>(); + private static final Map ABILITIES_BY_NAME = new ConcurrentSkipListMap<>(); private static int idCounter; @@ -129,7 +130,7 @@ public abstract class CoreAbility implements Ability { UUID uuid = player.getUniqueId(); if (!INSTANCES.containsKey(clazz)) { - INSTANCES.put(clazz, new ConcurrentHashMap>()); + INSTANCES.put(clazz, new ConcurrentHashMap>()); } if (!INSTANCES.get(clazz).containsKey(uuid)) { INSTANCES.get(clazz).put(uuid, new ConcurrentHashMap()); @@ -159,9 +160,9 @@ public abstract class CoreAbility implements Ability { Bukkit.getServer().getPluginManager().callEvent(new AbilityEndEvent(this)); removed = true; - ConcurrentHashMap> classMap = INSTANCES.get(getClass()); + Map> classMap = INSTANCES.get(getClass()); if (classMap != null) { - ConcurrentHashMap playerMap = classMap.get(player.getUniqueId()); + Map playerMap = classMap.get(player.getUniqueId()); if (playerMap != null) { playerMap.remove(this.id); if (playerMap.size() == 0) { @@ -324,7 +325,7 @@ public abstract class CoreAbility implements Ability { public static Set getPlayers(Class clazz) { HashSet players = new HashSet<>(); if (clazz != null) { - ConcurrentHashMap> uuidMap = INSTANCES.get(clazz); + Map> uuidMap = INSTANCES.get(clazz); if (uuidMap != null) { for (UUID uuid : uuidMap.keySet()) { Player uuidPlayer = Bukkit.getPlayer(uuid); @@ -478,7 +479,7 @@ public abstract class CoreAbility implements Ability { plugin.getLogger().warning("The ability " + coreAbil.getName() + " was not able to load, if this message shows again please remove it!"); e.printStackTrace(); addon.stop(); - ABILITIES_BY_NAME.remove(coreAbil.getName(), coreAbil); + ABILITIES_BY_NAME.remove(name.toLowerCase()); } } } @@ -510,6 +511,10 @@ public abstract class CoreAbility implements Ability { @Override public boolean isEnabled() { + if (this instanceof AddonAbility) { + return true; + } + String elementName = getElement().getName(); if (getElement() instanceof SubElement) { elementName = ((SubElement) getElement()).getParentElement().getName(); @@ -566,9 +571,9 @@ public abstract class CoreAbility implements Ability { int playerCounter = 0; HashMap classCounter = new HashMap<>(); - for (ConcurrentHashMap> map1 : INSTANCES.values()) { + for (Map> map1 : INSTANCES.values()) { playerCounter++; - for (ConcurrentHashMap map2 : map1.values()) { + for (Map map2 : map1.values()) { for (CoreAbility coreAbil : map2.values()) { String simpleName = coreAbil.getClass().getSimpleName(); diff --git a/src/com/projectkorra/projectkorra/ability/EarthAbility.java b/src/com/projectkorra/projectkorra/ability/EarthAbility.java index 5df4bae8..1bed9949 100644 --- a/src/com/projectkorra/projectkorra/ability/EarthAbility.java +++ b/src/com/projectkorra/projectkorra/ability/EarthAbility.java @@ -2,6 +2,7 @@ package com.projectkorra.projectkorra.ability; import java.util.ArrayList; import java.util.HashSet; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.bukkit.ChatColor; @@ -32,8 +33,8 @@ import com.projectkorra.projectkorra.util.TempBlock; public abstract class EarthAbility extends ElementalAbility { private static final HashSet PREVENT_EARTHBENDING = new HashSet(); - private static final ConcurrentHashMap MOVED_EARTH = new ConcurrentHashMap(); - private static final ConcurrentHashMap TEMP_AIR_LOCATIONS = new ConcurrentHashMap(); + private static final Map MOVED_EARTH = new ConcurrentHashMap(); + private static final Map TEMP_AIR_LOCATIONS = new ConcurrentHashMap(); private static final ArrayList PREVENT_PHYSICS = new ArrayList(); public EarthAbility(Player player) { @@ -352,7 +353,7 @@ public abstract class EarthAbility extends ElementalAbility { return value * getConfig().getDouble("Properties.Earth.MetalPowerFactor"); } - public static ConcurrentHashMap getMovedEarth() { + public static Map getMovedEarth() { return MOVED_EARTH; } @@ -403,7 +404,7 @@ public abstract class EarthAbility extends ElementalAbility { return player.getTargetBlock(getTransparentMaterialSet(), range); } - public static ConcurrentHashMap getTempAirLocations() { + public static Map getTempAirLocations() { return TEMP_AIR_LOCATIONS; } @@ -431,7 +432,7 @@ public abstract class EarthAbility extends ElementalAbility { byte full = 0x0; if (TempBlock.isTempBlock(block)) { TempBlock tblock = TempBlock.instances.get(block); - if (tblock == null || !LavaFlow.getTempLavaBlocks().contains(tblock)) { + if (tblock == null || !LavaFlow.getTempLavaBlocks().values().contains(tblock)) { return false; } } diff --git a/src/com/projectkorra/projectkorra/ability/FireAbility.java b/src/com/projectkorra/projectkorra/ability/FireAbility.java index 00c382eb..8b8a5dfe 100644 --- a/src/com/projectkorra/projectkorra/ability/FireAbility.java +++ b/src/com/projectkorra/projectkorra/ability/FireAbility.java @@ -21,12 +21,13 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; +import java.util.Map; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; public abstract class FireAbility extends ElementalAbility { - private static final ConcurrentHashMap TEMP_FIRE = new ConcurrentHashMap(); + private static final Map TEMP_FIRE = new ConcurrentHashMap(); private static final Material[] IGNITABLE_MATERIALS = { Material.BEDROCK, Material.BOOKSHELF, Material.BRICK, Material.CLAY, Material.CLAY_BRICK, Material.COAL_ORE, Material.COBBLESTONE, Material.DIAMOND_ORE, Material.DIAMOND_BLOCK, Material.DIRT, Material.ENDER_STONE, Material.GLOWING_REDSTONE_ORE, Material.GOLD_BLOCK, Material.GRAVEL, Material.GRASS, diff --git a/src/com/projectkorra/projectkorra/ability/util/ComboManager.java b/src/com/projectkorra/projectkorra/ability/util/ComboManager.java index c8506149..249d74b2 100644 --- a/src/com/projectkorra/projectkorra/ability/util/ComboManager.java +++ b/src/com/projectkorra/projectkorra/ability/util/ComboManager.java @@ -3,6 +3,7 @@ package com.projectkorra.projectkorra.ability.util; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.bukkit.entity.Player; @@ -24,7 +25,7 @@ import com.projectkorra.projectkorra.waterbending.WaterCombo; public class ComboManager { private static final long CLEANUP_DELAY = 20 * 600; - private static final ConcurrentHashMap> RECENTLY_USED = new ConcurrentHashMap<>(); + private static final Map> RECENTLY_USED = new ConcurrentHashMap<>(); private static final HashMap COMBO_ABILITIES = new HashMap<>(); private static final HashMap AUTHORS = new HashMap<>(); private static final HashMap DESCRIPTIONS = new HashMap<>(); diff --git a/src/com/projectkorra/projectkorra/ability/util/MultiAbilityManager.java b/src/com/projectkorra/projectkorra/ability/util/MultiAbilityManager.java index 9ff115c7..23035363 100644 --- a/src/com/projectkorra/projectkorra/ability/util/MultiAbilityManager.java +++ b/src/com/projectkorra/projectkorra/ability/util/MultiAbilityManager.java @@ -14,13 +14,14 @@ import org.bukkit.scheduler.BukkitRunnable; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class MultiAbilityManager { - public static ConcurrentHashMap> playerAbilities = new ConcurrentHashMap<>(); - public static ConcurrentHashMap playerSlot = new ConcurrentHashMap<>(); - public static ConcurrentHashMap playerBoundAbility = new ConcurrentHashMap<>(); + public static Map> playerAbilities = new ConcurrentHashMap<>(); + public static Map playerSlot = new ConcurrentHashMap<>(); + public static Map playerBoundAbility = new ConcurrentHashMap<>(); public static ArrayList multiAbilityList = new ArrayList(); public MultiAbilityManager() { diff --git a/src/com/projectkorra/projectkorra/airbending/AirBlast.java b/src/com/projectkorra/projectkorra/airbending/AirBlast.java index 974c3415..a6d8ef1d 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirBlast.java +++ b/src/com/projectkorra/projectkorra/airbending/AirBlast.java @@ -2,6 +2,7 @@ package com.projectkorra.projectkorra.airbending; import java.util.ArrayList; import java.util.Arrays; +import java.util.Map; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; @@ -34,7 +35,7 @@ import com.projectkorra.projectkorra.util.Flight; public class AirBlast extends AirAbility { private static final int MAX_TICKS = 10000; - private static final ConcurrentHashMap ORIGINS = new ConcurrentHashMap<>(); + private static final Map ORIGINS = new ConcurrentHashMap<>(); private boolean canFlickLevers; private boolean canOpenDoors; @@ -170,11 +171,8 @@ public class AirBlast extends AirAbility { return; } - if (ORIGINS.containsKey(player)) { - ORIGINS.replace(player, location); - } else { - ORIGINS.put(player, location); - } + ORIGINS.put(player, location); + } private void advanceLocation() { diff --git a/src/com/projectkorra/projectkorra/airbending/AirBubble.java b/src/com/projectkorra/projectkorra/airbending/AirBubble.java index 8f24d3ed..fdad0ff0 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirBubble.java +++ b/src/com/projectkorra/projectkorra/airbending/AirBubble.java @@ -14,6 +14,7 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.Player; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class AirBubble extends AirAbility { @@ -22,7 +23,7 @@ public class AirBubble extends AirAbility { private double radius; private double airRadius; private double waterRadius; - private ConcurrentHashMap waterOrigins; + private Map waterOrigins; public AirBubble(Player player) { super(player); @@ -200,7 +201,7 @@ public class AirBubble extends AirAbility { this.waterRadius = waterRadius; } - public ConcurrentHashMap getWaterOrigins() { + public Map getWaterOrigins() { return waterOrigins; } diff --git a/src/com/projectkorra/projectkorra/airbending/AirSuction.java b/src/com/projectkorra/projectkorra/airbending/AirSuction.java index b468c5c9..06689a36 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirSuction.java +++ b/src/com/projectkorra/projectkorra/airbending/AirSuction.java @@ -1,5 +1,6 @@ package com.projectkorra.projectkorra.airbending; +import java.util.Map; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; @@ -22,7 +23,7 @@ import com.projectkorra.projectkorra.waterbending.WaterSpout; public class AirSuction extends AirAbility { private static final int MAX_TICKS = 10000; - private static final ConcurrentHashMap ORIGINS = new ConcurrentHashMap<>(); + private static final Map ORIGINS = new ConcurrentHashMap<>(); private boolean hasOtherOrigin; private int ticks; @@ -114,8 +115,6 @@ public class AirSuction extends AirAbility { return; } else if (GeneralMethods.isRegionProtectedFromBuild(player, "AirSuction", location)) { return; - } else if (ORIGINS.containsKey(player)) { - ORIGINS.replace(player, location); } else { ORIGINS.put(player, location); } @@ -335,7 +334,7 @@ public class AirSuction extends AirAbility { this.cooldown = cooldown; } - public static ConcurrentHashMap getOrigins() { + public static Map getOrigins() { return ORIGINS; } diff --git a/src/com/projectkorra/projectkorra/airbending/AirSwipe.java b/src/com/projectkorra/projectkorra/airbending/AirSwipe.java index 31d6b58e..d21c86b7 100644 --- a/src/com/projectkorra/projectkorra/airbending/AirSwipe.java +++ b/src/com/projectkorra/projectkorra/airbending/AirSwipe.java @@ -26,6 +26,7 @@ import org.bukkit.util.Vector; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; @@ -50,7 +51,7 @@ public class AirSwipe extends AirAbility { private Location origin; private Random random; private AirSwipe ability; - private ConcurrentHashMap elements; + private Map elements; private ArrayList affectedEntities; public AirSwipe(Player player) { @@ -117,7 +118,7 @@ public class AirSwipe extends AirAbility { Location location = elements.get(direction); if (direction != null && location != null) { location = location.clone().add(direction.clone().multiply(speed)); - elements.replace(direction, location); + elements.put(direction, location); if (location.distanceSquared(origin) > range * range || GeneralMethods.isRegionProtectedFromBuild(this, location)) { @@ -409,7 +410,7 @@ public class AirSwipe extends AirAbility { this.maxChargeFactor = maxChargeFactor; } - public ConcurrentHashMap getElements() { + public Map getElements() { return elements; } diff --git a/src/com/projectkorra/projectkorra/airbending/Tornado.java b/src/com/projectkorra/projectkorra/airbending/Tornado.java index 759d3508..3ba4260e 100644 --- a/src/com/projectkorra/projectkorra/airbending/Tornado.java +++ b/src/com/projectkorra/projectkorra/airbending/Tornado.java @@ -12,6 +12,7 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; import java.util.HashSet; +import java.util.Map; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; @@ -31,7 +32,7 @@ public class Tornado extends AirAbility { private Flight flight; private Location origin; private Random random; - private ConcurrentHashMap angles; + private Map angles; public Tornado(Player player) { super(player); @@ -297,7 +298,7 @@ public class Tornado extends AirAbility { this.currentRadius = currentRadius; } - public ConcurrentHashMap getAngles() { + public Map getAngles() { return angles; } } diff --git a/src/com/projectkorra/projectkorra/chiblocking/AcrobatStance.java b/src/com/projectkorra/projectkorra/chiblocking/AcrobatStance.java index 818f42e7..d2741c0f 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/AcrobatStance.java +++ b/src/com/projectkorra/projectkorra/chiblocking/AcrobatStance.java @@ -1,5 +1,6 @@ package com.projectkorra.projectkorra.chiblocking; +import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.ability.ChiAbility; import org.bukkit.Location; @@ -39,7 +40,7 @@ public class AcrobatStance extends ChiAbility { @Override public void progress() { - if (!bPlayer.canBendIgnoreBindsCooldowns(this)) { + if (!bPlayer.canBendIgnoreBindsCooldowns(this) || !bPlayer.hasElement(Element.CHI)) { remove(); return; } diff --git a/src/com/projectkorra/projectkorra/chiblocking/ChiCombo.java b/src/com/projectkorra/projectkorra/chiblocking/ChiCombo.java index 4b6ae3c6..7a521b06 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/ChiCombo.java +++ b/src/com/projectkorra/projectkorra/chiblocking/ChiCombo.java @@ -10,6 +10,7 @@ import org.bukkit.entity.Entity; import org.bukkit.entity.Player; import java.util.ArrayList; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; /* @@ -23,7 +24,7 @@ public class ChiCombo extends ChiAbility implements ComboAbility { * a Map containing every entity which is paralyzed, and the time in * milliseconds at which they will be unparalyzed. */ - private static final ConcurrentHashMap PARALYZED_ENTITIES = new ConcurrentHashMap<>(); + private static final Map PARALYZED_ENTITIES = new ConcurrentHashMap<>(); private long duration; private long cooldown; @@ -177,7 +178,7 @@ public class ChiCombo extends ChiAbility implements ComboAbility { this.target = target; } - public static ConcurrentHashMap getParalyzedEntities() { + public static Map getParalyzedEntities() { return PARALYZED_ENTITIES; } diff --git a/src/com/projectkorra/projectkorra/chiblocking/Paralyze.java b/src/com/projectkorra/projectkorra/chiblocking/Paralyze.java index a4f9dce1..43f41f5c 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/Paralyze.java +++ b/src/com/projectkorra/projectkorra/chiblocking/Paralyze.java @@ -10,12 +10,13 @@ import org.bukkit.entity.Creature; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class Paralyze extends ChiAbility { - private static final ConcurrentHashMap ENTITIES = new ConcurrentHashMap<>(); - private static final ConcurrentHashMap COOLDOWNS = new ConcurrentHashMap<>(); + private static final Map ENTITIES = new ConcurrentHashMap<>(); + private static final Map COOLDOWNS = new ConcurrentHashMap<>(); private long cooldown; private Entity target; @@ -121,11 +122,11 @@ public class Paralyze extends ChiAbility { this.target = target; } - public static ConcurrentHashMap getEntities() { + public static Map getEntities() { return ENTITIES; } - public static ConcurrentHashMap getCooldowns() { + public static Map getCooldowns() { return COOLDOWNS; } diff --git a/src/com/projectkorra/projectkorra/chiblocking/Smokescreen.java b/src/com/projectkorra/projectkorra/chiblocking/Smokescreen.java index f0a4c052..7f42a21f 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/Smokescreen.java +++ b/src/com/projectkorra/projectkorra/chiblocking/Smokescreen.java @@ -12,13 +12,14 @@ import org.bukkit.entity.Snowball; import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffectType; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class Smokescreen extends ChiAbility { - private static final ConcurrentHashMap SNOWBALLS = new ConcurrentHashMap<>(); - private static final ConcurrentHashMap BLINDED_TIMES = new ConcurrentHashMap<>(); - private static final ConcurrentHashMap BLINDED_TO_ABILITY = new ConcurrentHashMap<>(); + private static final Map SNOWBALLS = new ConcurrentHashMap<>(); + private static final Map BLINDED_TIMES = new ConcurrentHashMap<>(); + private static final Map BLINDED_TO_ABILITY = new ConcurrentHashMap<>(); private int duration; private long cooldown; @@ -136,15 +137,15 @@ public class Smokescreen extends ChiAbility { this.radius = radius; } - public static ConcurrentHashMap getSnowballs() { + public static Map getSnowballs() { return SNOWBALLS; } - public static ConcurrentHashMap getBlindedTimes() { + public static Map getBlindedTimes() { return BLINDED_TIMES; } - public static ConcurrentHashMap getBlindedToAbility() { + public static Map getBlindedToAbility() { return BLINDED_TO_ABILITY; } diff --git a/src/com/projectkorra/projectkorra/chiblocking/WarriorStance.java b/src/com/projectkorra/projectkorra/chiblocking/WarriorStance.java index 66ba4d79..e9bced9f 100644 --- a/src/com/projectkorra/projectkorra/chiblocking/WarriorStance.java +++ b/src/com/projectkorra/projectkorra/chiblocking/WarriorStance.java @@ -1,5 +1,6 @@ package com.projectkorra.projectkorra.chiblocking; +import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.ability.ChiAbility; import org.bukkit.Location; @@ -34,7 +35,7 @@ public class WarriorStance extends ChiAbility { @Override public void progress() { - if (!bPlayer.canBendIgnoreBindsCooldowns(this)) { + if (!bPlayer.canBendIgnoreBindsCooldowns(this) || !bPlayer.hasElement(Element.CHI)) { remove(); return; } diff --git a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java index 610a9425..e78d922a 100644 --- a/src/com/projectkorra/projectkorra/configuration/ConfigManager.java +++ b/src/com/projectkorra/projectkorra/configuration/ConfigManager.java @@ -212,7 +212,7 @@ public class ConfigManager { config.addDefault("Abilities.Avatar.AvatarState.Description", "The signature ability of the Avatar, this is a toggle. Click to activate to become " + "nearly unstoppable. While in the Avatar State, the user takes severely reduced damage from " + "all sources, regenerates health rapidly, and is granted extreme speed. Nearly all abilities " + "are incredibly amplified in this state. Additionally, AirShield and FireJet become toggle-able " + "abilities and last until you deactivate them or the Avatar State. Click again with the Avatar " + "State selected to deactivate it."); - config.addDefault("Commands.Help.Elements.Air", "Air is the element of freedom. Airbenders are natural pacifists and great explorers. There is nothing stopping them from scaling the tallest of mountains and walls easily. They specialize in redirection, from blasting things away with gusts of winds, to forming a shield around them to prevent damage. Easy to get across flat terrains, such as oceans, there is practically no terrain off limits to Airbenders. They lack much raw damage output, but make up for it with with their ridiculous amounts of utility and speed.\nAirbenders can chain their abilities into combos, type /b help AirCombos for more information."); + config.addDefault("Abilities.Air.Description", "Air is the element of freedom. Airbenders are natural pacifists and great explorers. There is nothing stopping them from scaling the tallest of mountains and walls easily. They specialize in redirection, from blasting things away with gusts of winds, to forming a shield around them to prevent damage. Easy to get across flat terrains, such as oceans, there is practically no terrain off limits to Airbenders. They lack much raw damage output, but make up for it with with their ridiculous amounts of utility and speed.\nAirbenders can chain their abilities into combos, type /b help AirCombos for more information."); config.addDefault("Abilities.Air.AirBlast.Description", "AirBlast is the most fundamental bending technique of an airbender." + " To use, simply left-click in a direction. A gust of wind will be" + " created at your fingertips, launching anything in its path harmlessly back." + " A gust of air can extinguish fires on the ground or on a player, can cool lava, and " + "can flip levers and activate buttons. Additionally, tapping sneak will change the " + "origin of your next AirBlast to your targeted location."); config.addDefault("Abilities.Air.AirBlast.DeathMessage", "{victim} was flung by {attacker}'s {ability}"); config.addDefault("Abilities.Air.AirBlast.HorizontalVelocityDeath","{victim} experienced kinetic damage by {attacker}'s {ability}"); @@ -236,7 +236,7 @@ public class ConfigManager { config.addDefault("Abilities.Air.Combo.AirSweep.Description", "Sweep the air in front of you hitting multiple enemies, causing moderate damage and a large knockback. The radius and direction of AirSweep is controlled by moving your mouse in a sweeping motion. For example, if you want to AirSweep upward, then move your mouse upward right after you left click AirBurst"); config.addDefault("Abilities.Air.Combo.AirSweep.DeathMessage", "{victim} was swept away by {attacker}'s {ability}"); - config.addDefault("Commands.Help.Elements.Water", "Water is the element of change. Waterbending focuses on using your opponents own force against them. Using redirection and various dodging tactics, you can be made practically untouchable by an opponent. Waterbending provides agility, along with strong offensive skills while in or near water.\nWaterbenders can chain their abilities into combos, type /b help WaterCombos for more information."); + config.addDefault("Abilities.Water.Description", "Water is the element of change. Waterbending focuses on using your opponents own force against them. Using redirection and various dodging tactics, you can be made practically untouchable by an opponent. Waterbending provides agility, along with strong offensive skills while in or near water.\nWaterbenders can chain their abilities into combos, type /b help WaterCombos for more information."); config.addDefault("Abilities.Water.Bloodbending.Description", "This ability was made illegal for a reason. With this ability selected, sneak while " + "targetting something and you will bloodbend that target. Bloodbent targets cannot move, " + "bend or attack. You are free to control their actions by looking elsewhere - they will " + "be forced to move in that direction. Additionally, clicking while bloodbending will " + "launch that target off in the direction you're looking. " + "People who are capable of bloodbending are immune to your technique, and you are immune to theirs."); config.addDefault("Abilities.Water.Bloodbending.DeathMessage", "{victim} was destroyed by {attacker}'s {ability}"); config.addDefault("Abilities.Water.Bloodbending.HorizontalVelocityDeath","{victim} experienced kinetic damage by {attacker}'s {ability}"); @@ -266,7 +266,7 @@ public class ConfigManager { config.addDefault("Abilities.Water.Combo.IceWave.Description", "PhaseChange your WaterWave into an IceWave that freezes and damages enemies."); config.addDefault("Abilities.Water.Combo.IceWave.DeathMessage", "{victim} was frozen solid by {attacker}'s {ability}"); - config.addDefault("Commands.Help.Elements.Earth", "Earth is the element of substance. Earthbenders share many of the same fundamental techniques as Waterbenders, but their domain is quite different and more readily accessible. Earthbenders dominate the ground and subterranean, having abilities to pull columns of rock straight up from the earth or drill their way through the mountain. They can also launch themselves through the air using pillars of rock, and will not hurt themselves assuming they land on something they can bend. The more skilled Earthbenders can even bend metal."); + config.addDefault("Abilities.Earth.Description", "Earth is the element of substance. Earthbenders share many of the same fundamental techniques as Waterbenders, but their domain is quite different and more readily accessible. Earthbenders dominate the ground and subterranean, having abilities to pull columns of rock straight up from the earth or drill their way through the mountain. They can also launch themselves through the air using pillars of rock, and will not hurt themselves assuming they land on something they can bend. The more skilled Earthbenders can even bend metal."); config.addDefault("Abilities.Earth.Catapult.Description", "To use, left-click while looking in the direction you want to be launched. " + "A pillar of earth will jut up from under you and launch you in that direction - " + "if and only if there is enough earth behind where you're looking to launch you. " + "Skillful use of this ability takes much time and work, and it does result in the " + "death of certain gung-ho earthbenders. If you plan to use this ability, be sure " + "you've read about your passive ability you innately have as an earthbender."); config.addDefault("Abilities.Earth.Collapse.Description", " To use, simply left-click on an earthbendable block. " + "That block and the earthbendable blocks above it will be shoved " + "back into the earth below them, if they can. " + "This ability does have the capacity to trap something inside of it, " + "although it is incredibly difficult to do so. " + "Additionally, press sneak with this ability to affect an area around your targetted location - " + "all earth that can be moved downwards will be moved downwards. " + "This ability is especially risky or deadly in caves, depending on the " + "earthbender's goal and technique."); config.addDefault("Abilities.Earth.Collapse.DeathMessage", "{victim} was suffocated by {attacker}'s {ability}"); @@ -288,7 +288,7 @@ public class ConfigManager { config.addDefault("Abilities.Earth.SandSpout.Description", "SandSpout is a core move for travelling, evasion, and mobility for sandbenders. To use, simply left click while over sand or sandstone, and a column of sand will form at your feet, enabling you to levitate. Any mobs or players that touch your column will receive damage and be blinded. Beware, as the spout will stop working when no longer over sand!"); config.addDefault("Abilities.Earth.Tremorsense.Description", "This is a pure utility ability for earthbenders. If you are in an area of low-light and are standing on top of an earthbendable block, this ability will automatically turn that block into glowstone, visible *only by you*. If you lose contact with a bendable block, the light will go out as you have lost contact with the earth and cannot 'see' until you can touch earth again. Additionally, if you click with this ability selected, smoke will appear above nearby earth with pockets of air beneath them."); - config.addDefault("Commands.Help.Elements.Fire", "Fire is the element of power. Firebenders focus on destruction and incineration. Their abilities are pretty straight forward: set things on fire. They do have a bit of utility however, being able to make themselves un-ignitable, extinguish large areas, cook food in their hands, extinguish large areas, small bursts of flight, and then comes the abilities to shoot fire from your hands.\nFirebenders can chain their abilities into combos, type /b help FireCombos for more information."); + config.addDefault("Abilities.Fire.Description", "Fire is the element of power. Firebenders focus on destruction and incineration. Their abilities are pretty straight forward: set things on fire. They do have a bit of utility however, being able to make themselves un-ignitable, extinguish large areas, cook food in their hands, extinguish large areas, small bursts of flight, and then comes the abilities to shoot fire from your hands.\nFirebenders can chain their abilities into combos, type /b help FireCombos for more information."); config.addDefault("Abilities.Fire.Blaze.Description", "To use, simply left-click in any direction. An arc of fire will flow from your location, igniting anything in its path. Additionally, tap sneak to engulf the area around you in roaring flames."); config.addDefault("Abilities.Fire.Blaze.DeathMessage", "{victim} was burned alive by {attacker}'s {ability}"); config.addDefault("Abilities.Fire.Combustion.Description", "Combustion is a powerful ability only known by a few skilled Firebenders. It allows the bender to Firebend with their mind, concentrating energy to create a powerful blast. To use, simply tap sneak (Default: Shift) to launch the blast. This technique is highly destructive and very effective, it also comes with a long cooldown."); @@ -316,7 +316,7 @@ public class ConfigManager { config.addDefault("Abilities.Fire.Combo.FireWheel.Description", "A high-speed wheel of fire that travels along the ground for long distances dealing high damage."); config.addDefault("Abilities.Fire.Combo.FireWheel.DeathMessage", "{victim} was incinerated by {attacker}'s {ability}"); - config.addDefault("Commands.Help.Elements.Chi", "Chiblockers focus on bare handed combat, utilizing their agility and speed to stop any bender right in their path. Although they lack the ability to bend any of the other elements, they are great in combat, and a serious threat to any bender. Chiblocking was first shown to be used by Ty Lee in Avatar: The Last Airbender, then later by members of the Equalists in The Legend of Korra.\nChiblockers can chain their abilities into combos, type /b help ChiCombos for more information."); + config.addDefault("Abilities.Chi.Description", "Chiblockers focus on bare handed combat, utilizing their agility and speed to stop any bender right in their path. Although they lack the ability to bend any of the other elements, they are great in combat, and a serious threat to any bender. Chiblocking was first shown to be used by Ty Lee in Avatar: The Last Airbender, then later by members of the Equalists in The Legend of Korra.\nChiblockers can chain their abilities into combos, type /b help ChiCombos for more information."); config.addDefault("Abilities.Chi.AcrobatStance.Description", "AcrobatStance gives a Chiblocker a higher probability of blocking a Bender's Chi while granting them a Speed and Jump Boost. It also increases the rate at which the hunger bar depletes. To use, simply left click. Left clicking again will de-activate the stance."); config.addDefault("Abilities.Chi.HighJump.Description", "To use this ability, simply click. You will jump quite high. This ability has a short cooldown."); config.addDefault("Abilities.Chi.Paralyze.Description", "Paralyzes the target, making them unable to do anything for a short " + "period of time. This ability has a long cooldown."); diff --git a/src/com/projectkorra/projectkorra/earthbending/Collapse.java b/src/com/projectkorra/projectkorra/earthbending/Collapse.java index 32e70d6d..a0c636d0 100644 --- a/src/com/projectkorra/projectkorra/earthbending/Collapse.java +++ b/src/com/projectkorra/projectkorra/earthbending/Collapse.java @@ -1,5 +1,6 @@ package com.projectkorra.projectkorra.earthbending; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Location; @@ -23,7 +24,7 @@ public class Collapse extends EarthAbility { private Location location; private Vector direction; private Block block; - private ConcurrentHashMap affectedBlocks; + private Map affectedBlocks; public Collapse(Player player) { super(player); @@ -219,7 +220,7 @@ public class Collapse extends EarthAbility { this.speed = speed; } - public ConcurrentHashMap getAffectedBlocks() { + public Map getAffectedBlocks() { return affectedBlocks; } diff --git a/src/com/projectkorra/projectkorra/earthbending/EarthPassive.java b/src/com/projectkorra/projectkorra/earthbending/EarthPassive.java index 0e6a46da..17f074bb 100644 --- a/src/com/projectkorra/projectkorra/earthbending/EarthPassive.java +++ b/src/com/projectkorra/projectkorra/earthbending/EarthPassive.java @@ -17,12 +17,13 @@ import org.bukkit.entity.Player; import org.bukkit.material.MaterialData; import java.util.HashSet; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class EarthPassive { - private static final ConcurrentHashMap SAND_BLOCKS = new ConcurrentHashMap<>(); - private static final ConcurrentHashMap SAND_ID_ENTITIES = new ConcurrentHashMap<>(); + private static final Map SAND_BLOCKS = new ConcurrentHashMap<>(); + private static final Map SAND_ID_ENTITIES = new ConcurrentHashMap<>(); @SuppressWarnings("deprecation") public static boolean softenLanding(Player player) { @@ -64,7 +65,7 @@ public class EarthPassive { affectedBlock.setType(Material.SAND); } if (!SAND_BLOCKS.containsKey(affectedBlock)) { - SAND_ID_ENTITIES.putIfAbsent(affectedBlock, type); + SAND_ID_ENTITIES.put(affectedBlock, type); SAND_BLOCKS.put(affectedBlock, System.currentTimeMillis()); } } @@ -171,11 +172,11 @@ public class EarthPassive { return true; } - public static ConcurrentHashMap getSandBlocks() { + public static Map getSandBlocks() { return SAND_BLOCKS; } - public static ConcurrentHashMap getSandIdEntities() { + public static Map getSandIdEntities() { return SAND_ID_ENTITIES; } diff --git a/src/com/projectkorra/projectkorra/earthbending/LavaFlow.java b/src/com/projectkorra/projectkorra/earthbending/LavaFlow.java index e0781fe4..02a63ce9 100644 --- a/src/com/projectkorra/projectkorra/earthbending/LavaFlow.java +++ b/src/com/projectkorra/projectkorra/earthbending/LavaFlow.java @@ -18,6 +18,7 @@ import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import java.util.ArrayList; +import java.util.Map; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; @@ -27,8 +28,8 @@ public class LavaFlow extends LavaAbility { SHIFT, CLICK } - private static final ConcurrentHashMap TEMP_LAVA_BLOCKS = new ConcurrentHashMap<>(); - private static final ConcurrentHashMap TEMP_LAND_BLOCKS = new ConcurrentHashMap<>(); + private static final Map TEMP_LAVA_BLOCKS = new ConcurrentHashMap<>(); + private static final Map TEMP_LAND_BLOCKS = new ConcurrentHashMap<>(); private boolean removing; private boolean makeLava; @@ -452,11 +453,11 @@ public class LavaFlow extends LavaAbility { } }.runTaskLater(ProjectKorra.plugin, (long) (i / shiftRemoveSpeed)); - if (TEMP_LAVA_BLOCKS.contains(tblock)) { + if (TEMP_LAVA_BLOCKS.values().contains(tblock)) { affectedBlocks.remove(tblock); TEMP_LAVA_BLOCKS.remove(tblock); } - if (TEMP_LAND_BLOCKS.contains(tblock)) { + if (TEMP_LAND_BLOCKS.values().contains(tblock)) { affectedBlocks.remove(tblock); TEMP_LAND_BLOCKS.remove(tblock); } @@ -476,11 +477,11 @@ public class LavaFlow extends LavaAbility { for (int i = affectedBlocks.size() - 1; i > -1; i--) { final TempBlock tblock = affectedBlocks.get(i); tblock.revertBlock(); - if (TEMP_LAVA_BLOCKS.contains(tblock)) { + if (TEMP_LAVA_BLOCKS.values().contains(tblock)) { affectedBlocks.remove(tblock); TEMP_LAVA_BLOCKS.remove(tblock); } - if (TEMP_LAND_BLOCKS.contains(tblock)) { + if (TEMP_LAND_BLOCKS.values().contains(tblock)) { affectedBlocks.remove(tblock); TEMP_LAND_BLOCKS.remove(tblock); } @@ -577,11 +578,11 @@ public class LavaFlow extends LavaAbility { return m; } - public static ConcurrentHashMap getTempLandBlocks() { + public static Map getTempLandBlocks() { return TEMP_LAND_BLOCKS; } - public static ConcurrentHashMap getTempLavaBlocks() { + public static Map getTempLavaBlocks() { return TEMP_LAVA_BLOCKS; } diff --git a/src/com/projectkorra/projectkorra/earthbending/LavaSurge.java b/src/com/projectkorra/projectkorra/earthbending/LavaSurge.java index 622e9d93..c872db18 100644 --- a/src/com/projectkorra/projectkorra/earthbending/LavaSurge.java +++ b/src/com/projectkorra/projectkorra/earthbending/LavaSurge.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.ListIterator; +import java.util.Map; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; @@ -51,7 +52,7 @@ public class LavaSurge extends LavaAbility { private ArrayList fracture; private ArrayList fractureTempBlocks; private ArrayList movingLava; - private ConcurrentHashMap lavaBlocks; + private Map lavaBlocks; private ListIterator listIterator; public LavaSurge(Player player) { @@ -457,7 +458,7 @@ public class LavaSurge extends LavaAbility { return movingLava; } - public ConcurrentHashMap getLavaBlocks() { + public Map getLavaBlocks() { return lavaBlocks; } diff --git a/src/com/projectkorra/projectkorra/earthbending/MetalClips.java b/src/com/projectkorra/projectkorra/earthbending/MetalClips.java index 0835b5b8..7d9eb528 100644 --- a/src/com/projectkorra/projectkorra/earthbending/MetalClips.java +++ b/src/com/projectkorra/projectkorra/earthbending/MetalClips.java @@ -19,12 +19,13 @@ import org.bukkit.util.Vector; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class MetalClips extends MetalAbility { - private static final ConcurrentHashMap ENTITY_CLIPS_COUNT = new ConcurrentHashMap<>(); - private static final ConcurrentHashMap TARGET_TO_ABILITY = new ConcurrentHashMap<>(); + private static final Map ENTITY_CLIPS_COUNT = new ConcurrentHashMap<>(); + private static final Map TARGET_TO_ABILITY = new ConcurrentHashMap<>(); private static final Material[] METAL_ITEMS = { Material.IRON_INGOT, Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_LEGGINGS, Material.IRON_BOOTS, Material.IRON_BLOCK, Material.IRON_AXE, Material.IRON_PICKAXE, @@ -458,11 +459,11 @@ public class MetalClips extends MetalAbility { return clips != null && player.isSneaking() && clips.targetEntity != null; } - public static ConcurrentHashMap getEntityClipsCount() { + public static Map getEntityClipsCount() { return ENTITY_CLIPS_COUNT; } - public static ConcurrentHashMap getTargetToAbility() { + public static Map getTargetToAbility() { return TARGET_TO_ABILITY; } diff --git a/src/com/projectkorra/projectkorra/earthbending/Ripple.java b/src/com/projectkorra/projectkorra/earthbending/Ripple.java index 3bc27bde..782e5e05 100644 --- a/src/com/projectkorra/projectkorra/earthbending/Ripple.java +++ b/src/com/projectkorra/projectkorra/earthbending/Ripple.java @@ -16,11 +16,12 @@ import org.bukkit.entity.Player; import org.bukkit.util.Vector; import java.util.ArrayList; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class Ripple extends EarthAbility { - private static final ConcurrentHashMap BLOCKS = new ConcurrentHashMap(); + private static final Map BLOCKS = new ConcurrentHashMap(); private int step; private int maxStep; @@ -297,7 +298,7 @@ public class Ripple extends EarthAbility { BLOCKS.clear(); } - public static ConcurrentHashMap getBlocks() { + public static Map getBlocks() { return BLOCKS; } diff --git a/src/com/projectkorra/projectkorra/earthbending/Tremorsense.java b/src/com/projectkorra/projectkorra/earthbending/Tremorsense.java index 36e53f0a..c8313618 100644 --- a/src/com/projectkorra/projectkorra/earthbending/Tremorsense.java +++ b/src/com/projectkorra/projectkorra/earthbending/Tremorsense.java @@ -12,11 +12,12 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class Tremorsense extends EarthAbility { - private static final ConcurrentHashMap BLOCKS = new ConcurrentHashMap(); + private static final Map BLOCKS = new ConcurrentHashMap(); private byte lightThreshold; private int maxDepth; @@ -139,7 +140,7 @@ public class Tremorsense extends EarthAbility { } } - public static ConcurrentHashMap getBlocks() { + public static Map getBlocks() { return BLOCKS; } diff --git a/src/com/projectkorra/projectkorra/firebending/FireBlast.java b/src/com/projectkorra/projectkorra/firebending/FireBlast.java index a41ecb1b..ac072b02 100644 --- a/src/com/projectkorra/projectkorra/firebending/FireBlast.java +++ b/src/com/projectkorra/projectkorra/firebending/FireBlast.java @@ -126,7 +126,7 @@ public class FireBlast extends FireAbility { } if (entity instanceof LivingEntity) { entity.setFireTicks((int) (fireTicks * 20)); - DamageHandler.damageEntity(entity, (int) getDayFactor(damage), this); + DamageHandler.damageEntity(entity, damage, this); AirAbility.breakBreathbendingHold(entity); new FireDamageTimer(entity, player); remove(); diff --git a/src/com/projectkorra/projectkorra/firebending/Illumination.java b/src/com/projectkorra/projectkorra/firebending/Illumination.java index 265aec14..a736df27 100644 --- a/src/com/projectkorra/projectkorra/firebending/Illumination.java +++ b/src/com/projectkorra/projectkorra/firebending/Illumination.java @@ -9,11 +9,12 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.entity.Player; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class Illumination extends FireAbility { - private static final ConcurrentHashMap BLOCKS = new ConcurrentHashMap<>(); + private static final Map BLOCKS = new ConcurrentHashMap<>(); private byte normalData; private long cooldown; @@ -162,7 +163,7 @@ public class Illumination extends FireAbility { this.block = block; } - public static ConcurrentHashMap getBlocks() { + public static Map getBlocks() { return BLOCKS; } diff --git a/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java b/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java index 226c9598..6ddd9db5 100644 --- a/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java +++ b/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java @@ -1,6 +1,7 @@ package com.projectkorra.projectkorra.object; import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Location; @@ -24,7 +25,7 @@ import com.projectkorra.projectkorra.event.HorizontalVelocityChangeEvent; */ public class HorizontalVelocityTracker { - public static ConcurrentHashMap instances = new ConcurrentHashMap(); + public static Map instances = new ConcurrentHashMap(); public boolean hasBeenDamaged = false; public boolean barrier = ConfigManager.defaultConfig.get().getBoolean("Properties.HorizontalCollisionPhysics.DamageOnBarrierBlock"); private long delay; diff --git a/src/com/projectkorra/projectkorra/object/Preset.java b/src/com/projectkorra/projectkorra/object/Preset.java index f6126f72..b4e7ede1 100644 --- a/src/com/projectkorra/projectkorra/object/Preset.java +++ b/src/com/projectkorra/projectkorra/object/Preset.java @@ -6,6 +6,7 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -31,7 +32,7 @@ public class Preset { * ConcurrentHashMap that stores a list of every Player's {@link Preset * presets}, keyed to their UUID */ - public static ConcurrentHashMap> presets = new ConcurrentHashMap>(); + public static Map> presets = new ConcurrentHashMap>(); public static FileConfiguration config = ConfigManager.presetConfig.get(); public static HashMap> externalPresets = new HashMap>(); static String loadQuery = "SELECT * FROM pk_presets WHERE uuid = ?"; diff --git a/src/com/projectkorra/projectkorra/util/Flight.java b/src/com/projectkorra/projectkorra/util/Flight.java index b20227dc..256c4c1d 100644 --- a/src/com/projectkorra/projectkorra/util/Flight.java +++ b/src/com/projectkorra/projectkorra/util/Flight.java @@ -1,6 +1,7 @@ package com.projectkorra.projectkorra.util; import java.util.ArrayList; +import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; @@ -19,7 +20,7 @@ import com.projectkorra.projectkorra.waterbending.WaterSpout; public class Flight { - private static ConcurrentHashMap instances = new ConcurrentHashMap(); + private static Map instances = new ConcurrentHashMap(); private static long duration = 5000; private Player player; @@ -125,7 +126,7 @@ public class Flight { private void refresh(Player source) { this.source = source; time = System.currentTimeMillis(); - instances.replace(player, this); + instances.put(player, this); } public void remove() { diff --git a/src/com/projectkorra/projectkorra/util/TempBlock.java b/src/com/projectkorra/projectkorra/util/TempBlock.java index 8a8c8465..375eae6c 100644 --- a/src/com/projectkorra/projectkorra/util/TempBlock.java +++ b/src/com/projectkorra/projectkorra/util/TempBlock.java @@ -8,11 +8,12 @@ import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.BlockState; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class TempBlock { - public static ConcurrentHashMap instances = new ConcurrentHashMap(); + public static Map instances = new ConcurrentHashMap(); private Block block; private Material newtype; @@ -35,7 +36,7 @@ public class TempBlock { temp.newdata = newdata; } state = temp.state; - instances.replace(block, temp); + instances.put(block, temp); } else { state = block.getState(); block.setType(newtype); diff --git a/src/com/projectkorra/projectkorra/util/TempPotionEffect.java b/src/com/projectkorra/projectkorra/util/TempPotionEffect.java index 0101dd0f..a7b08071 100644 --- a/src/com/projectkorra/projectkorra/util/TempPotionEffect.java +++ b/src/com/projectkorra/projectkorra/util/TempPotionEffect.java @@ -3,15 +3,16 @@ package com.projectkorra.projectkorra.util; import org.bukkit.entity.LivingEntity; import org.bukkit.potion.PotionEffect; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class TempPotionEffect { - private static ConcurrentHashMap instances = new ConcurrentHashMap(); + private static Map instances = new ConcurrentHashMap(); private static final long tick = 21; private int ID = Integer.MIN_VALUE; - private ConcurrentHashMap infos = new ConcurrentHashMap(); + private Map infos = new ConcurrentHashMap(); private LivingEntity entity; public TempPotionEffect(LivingEntity entity, PotionEffect effect) { @@ -24,7 +25,7 @@ public class TempPotionEffect { TempPotionEffect instance = instances.get(entity); instance.infos.put(instance.ID++, new PotionInfo(starttime, effect)); // instance.effects.put(starttime, effect); - instances.replace(entity, instance); + instances.put(entity, instance); } else { // effects.put(starttime, effect); infos.put(ID++, new PotionInfo(starttime, effect)); diff --git a/src/com/projectkorra/projectkorra/waterbending/Bloodbending.java b/src/com/projectkorra/projectkorra/waterbending/Bloodbending.java index 4f4a40af..6990febc 100644 --- a/src/com/projectkorra/projectkorra/waterbending/Bloodbending.java +++ b/src/com/projectkorra/projectkorra/waterbending/Bloodbending.java @@ -2,6 +2,7 @@ package com.projectkorra.projectkorra.waterbending; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Location; @@ -24,7 +25,7 @@ import com.projectkorra.projectkorra.util.TempPotionEffect; public class Bloodbending extends BloodAbility { - private static final ConcurrentHashMap TARGETED_ENTITIES = new ConcurrentHashMap(); + private static final Map TARGETED_ENTITIES = new ConcurrentHashMap(); private boolean canOnlyBeUsedAtNight; private boolean canBeUsedOnUndeadMobs; diff --git a/src/com/projectkorra/projectkorra/waterbending/Torrent.java b/src/com/projectkorra/projectkorra/waterbending/Torrent.java index 09668dbc..55145f11 100644 --- a/src/com/projectkorra/projectkorra/waterbending/Torrent.java +++ b/src/com/projectkorra/projectkorra/waterbending/Torrent.java @@ -21,13 +21,14 @@ import org.bukkit.util.Vector; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; public class Torrent extends WaterAbility { private static final double CLEANUP_RANGE = 50; - private static final ConcurrentHashMap FROZEN_BLOCKS = new ConcurrentHashMap<>(); + private static final Map FROZEN_BLOCKS = new ConcurrentHashMap<>(); private boolean sourceSelected; private boolean settingUp; @@ -831,7 +832,7 @@ public class Torrent extends WaterAbility { return CLEANUP_RANGE; } - public static ConcurrentHashMap getFrozenBlocks() { + public static Map getFrozenBlocks() { return FROZEN_BLOCKS; } diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterArms.java b/src/com/projectkorra/projectkorra/waterbending/WaterArms.java index 2017e17c..1fb2b805 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterArms.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterArms.java @@ -22,6 +22,7 @@ import org.bukkit.entity.Player; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class WaterArms extends WaterAbility { @@ -33,7 +34,7 @@ public class WaterArms extends WaterAbility { RIGHT, LEFT; } - private static final ConcurrentHashMap BLOCK_REVERT_TIMES = new ConcurrentHashMap(); + private static final Map BLOCK_REVERT_TIMES = new ConcurrentHashMap(); private static final Integer[] UNBREAKABLES = { 7, 8, 9, 10, 11, 49, 54, 90, 119, 120, 130, 146 }; private boolean cooldownLeft; @@ -720,7 +721,7 @@ public class WaterArms extends WaterAbility { this.sneakMsg = sneakMsg; } - public static ConcurrentHashMap getBlockRevertTimes() { + public static Map getBlockRevertTimes() { return BLOCK_REVERT_TIMES; } diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterArmsSpear.java b/src/com/projectkorra/projectkorra/waterbending/WaterArmsSpear.java index 1b977ca8..093e7e8b 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterArmsSpear.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterArmsSpear.java @@ -18,11 +18,12 @@ import org.bukkit.util.Vector; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.concurrent.ConcurrentHashMap; public class WaterArmsSpear extends WaterAbility { - private static final ConcurrentHashMap ICE_BLOCKS = new ConcurrentHashMap(); + private static final Map ICE_BLOCKS = new ConcurrentHashMap(); private boolean hitEntity; private boolean canFreeze; @@ -466,7 +467,7 @@ public class WaterArmsSpear extends WaterAbility { this.location = location; } - public static ConcurrentHashMap getIceBlocks() { + public static Map getIceBlocks() { return ICE_BLOCKS; } diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterManipulation.java b/src/com/projectkorra/projectkorra/waterbending/WaterManipulation.java index 45f9f871..e57f82ee 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterManipulation.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterManipulation.java @@ -2,6 +2,7 @@ package com.projectkorra.projectkorra.waterbending; import java.util.Collection; import java.util.HashSet; +import java.util.Map; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; @@ -30,7 +31,7 @@ import com.projectkorra.projectkorra.util.TempBlock; public class WaterManipulation extends WaterAbility { - private static final ConcurrentHashMap AFFECTED_BLOCKS = new ConcurrentHashMap<>(); + private static final Map AFFECTED_BLOCKS = new ConcurrentHashMap<>(); private boolean progressing; private boolean falling; @@ -761,7 +762,7 @@ public class WaterManipulation extends WaterAbility { this.targetDirection = targetDirection; } - public static ConcurrentHashMap getAffectedBlocks() { + public static Map getAffectedBlocks() { return AFFECTED_BLOCKS; } diff --git a/src/com/projectkorra/projectkorra/waterbending/WaterSpout.java b/src/com/projectkorra/projectkorra/waterbending/WaterSpout.java index 4bfb948f..05ffca51 100644 --- a/src/com/projectkorra/projectkorra/waterbending/WaterSpout.java +++ b/src/com/projectkorra/projectkorra/waterbending/WaterSpout.java @@ -15,12 +15,13 @@ import org.bukkit.potion.PotionEffectType; import java.util.ArrayList; import java.util.List; +import java.util.Map; import java.util.Random; import java.util.concurrent.ConcurrentHashMap; public class WaterSpout extends WaterAbility { - private static final ConcurrentHashMap AFFECTED_BLOCKS = new ConcurrentHashMap(); + private static final Map AFFECTED_BLOCKS = new ConcurrentHashMap(); private List blocks = new ArrayList(); private boolean canBendOnPackedIce; @@ -398,7 +399,7 @@ public class WaterSpout extends WaterAbility { this.baseBlock = baseBlock; } - public static ConcurrentHashMap getAffectedBlocks() { + public static Map getAffectedBlocks() { return AFFECTED_BLOCKS; }