Various fixes; Perm water & ice, reloadVariables

Removes reloadVariable() from all constructors
Fixes Surge perm ice and water
Removes Water Passive (extremely inefficient)
Alters playIceBendingSound() to make PhaseChange more bearable
Fixes NPE's in Flight
Fixes NPE in DisplayCommand
Light overall cleanup (Unused imports/dead code)
Fixes memory leak in ComboManager
This commit is contained in:
OmniCypher 2015-10-17 10:17:21 -07:00
parent 7729e2e9b4
commit 7669486103
36 changed files with 65 additions and 55 deletions

View file

@ -293,8 +293,6 @@ public class GeneralMethods {
return false; return false;
if (!bPlayer.isToggled()) if (!bPlayer.isToggled())
return false; return false;
if (p == null)
return false;
if (p.getGameMode() == GameMode.SPECTATOR) if (p.getGameMode() == GameMode.SPECTATOR)
return false; return false;
if (cooldowns.containsKey(p.getName())) { if (cooldowns.containsKey(p.getName())) {

View file

@ -1295,7 +1295,7 @@ public class PKListener implements Listener {
ComboManager.addComboAbility(player, ClickType.LEFT_CLICK); ComboManager.addComboAbility(player, ClickType.LEFT_CLICK);
if (Suffocate.isBreathbent(player)) { if (Suffocate.isBreathbent(player)) {
if (!GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirSwipe") || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("FireBlast") || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("EarthBlast") || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("WaterManipulation")) { if (GeneralMethods.getBoundAbility(player) != null || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("AirSwipe") || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("FireBlast") || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("EarthBlast") || !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("WaterManipulation")) {
event.setCancelled(true); event.setCancelled(true);
} }
} }

View file

@ -16,11 +16,10 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
public class ComboManager { public class ComboManager {
private static final long CLEANUP_DELAY = 20 * 60 * 60; private static final long CLEANUP_DELAY = 20 * 30;
public static ConcurrentHashMap<String, ArrayList<AbilityInformation>> recentlyUsedAbilities = new ConcurrentHashMap<String, ArrayList<AbilityInformation>>(); public static ConcurrentHashMap<String, ArrayList<AbilityInformation>> recentlyUsedAbilities = new ConcurrentHashMap<String, ArrayList<AbilityInformation>>();
public static HashMap<String, ComboAbility> comboAbilityList = new HashMap<String, ComboAbility>(); public static HashMap<String, ComboAbility> comboAbilityList = new HashMap<String, ComboAbility>();
public static HashMap<String, String> authors = new HashMap<String, String>(); public static HashMap<String, String> authors = new HashMap<String, String>();
@ -205,6 +204,7 @@ public class ComboManager {
list = new ArrayList<AbilityInformation>(); list = new ArrayList<AbilityInformation>();
list.add(info); list.add(info);
recentlyUsedAbilities.put(name, list); recentlyUsedAbilities.put(name, list);
//Bukkit.broadcastMessage("recentlyUsedAbilities: " + recentlyUsedAbilities.get(name).size());
} }
/** /**
@ -244,8 +244,11 @@ public class ComboManager {
Enumeration<String> keys = recentlyUsedAbilities.keys(); Enumeration<String> keys = recentlyUsedAbilities.keys();
while (keys.hasMoreElements()) { while (keys.hasMoreElements()) {
String name = keys.nextElement(); String name = keys.nextElement();
ArrayList<AbilityInformation> usedAbilities = recentlyUsedAbilities.get(name); //ArrayList<AbilityInformation> usedAbilities = recentlyUsedAbilities.get(name);
usedAbilities.clear(); if(recentlyUsedAbilities.get(name).size() > 75) {
recentlyUsedAbilities.get(name).clear();
//Bukkit.broadcastMessage(name + " recentlyUsed Cleared");
}
} }
} }
@ -293,6 +296,7 @@ public class ComboManager {
new BukkitRunnable() { new BukkitRunnable() {
public void run() { public void run() {
cleanupOldCombos(); cleanupOldCombos();
//Bukkit.broadcastMessage("Cleaned");
} }
}.runTaskTimer(ProjectKorra.plugin, 0, CLEANUP_DELAY); }.runTaskTimer(ProjectKorra.plugin, 0, CLEANUP_DELAY);
} }

View file

@ -76,7 +76,7 @@ public class AirBlast extends CoreAbility {
if (location.getBlock().isLiquid()) { if (location.getBlock().isLiquid()) {
return; return;
} }
reloadVariables(); //reloadVariables();
source = burst; source = burst;
this.player = player; this.player = player;

View file

@ -28,7 +28,7 @@ public class AirBubble extends CoreAbility {
private ConcurrentHashMap<Block, BlockState> waterorigins; private ConcurrentHashMap<Block, BlockState> waterorigins;
public AirBubble(Player player) { public AirBubble(Player player) {
reloadVariables(); //reloadVariables();
this.player = player; this.player = player;
waterorigins = new ConcurrentHashMap<Block, BlockState>(); waterorigins = new ConcurrentHashMap<Block, BlockState>();
//instances.put(uuid, this); //instances.put(uuid, this);

View file

@ -33,7 +33,7 @@ public class AirBurst extends CoreAbility {
private ArrayList<Entity> affectedentities = new ArrayList<Entity>(); private ArrayList<Entity> affectedentities = new ArrayList<Entity>();
public AirBurst() { public AirBurst() {
reloadVariables(); //reloadVariables();
} }
public AirBurst(Player player) { public AirBurst(Player player) {

View file

@ -79,6 +79,7 @@ public class AirCombo implements ConfigLoadable {
public AirCombo(Player player, String ability) { public AirCombo(Player player, String ability) {
/* Initial Checks */ /* Initial Checks */
if (!enabled) if (!enabled)
return; return;
if (Commands.isToggledForAll) if (Commands.isToggledForAll)
@ -94,7 +95,7 @@ public class AirCombo implements ConfigLoadable {
if (GeneralMethods.isRegionProtectedFromBuild(player, "AirBlast", player.getLocation())) if (GeneralMethods.isRegionProtectedFromBuild(player, "AirBlast", player.getLocation()))
return; return;
/* End Initial Checks */ /* End Initial Checks */
reloadVariables(); //reloadVariables();
time = System.currentTimeMillis(); time = System.currentTimeMillis();
this.player = player; this.player = player;
this.ability = ability; this.ability = ability;

View file

@ -36,7 +36,7 @@ public class AirScooter extends CoreAbility {
if (GeneralMethods.isSolid(player.getLocation().add(0, -.5, 0).getBlock())) if (GeneralMethods.isSolid(player.getLocation().add(0, -.5, 0).getBlock()))
return; return;
/* End Initial Check */ /* End Initial Check */
reloadVariables(); //reloadVariables();
this.player = player; this.player = player;
// wasflying = player.isFlying(); // wasflying = player.isFlying();
// canfly = player.getAllowFlight(); // canfly = player.getAllowFlight();
@ -49,6 +49,7 @@ public class AirScooter extends CoreAbility {
angles.add((double) (60 * i)); angles.add((double) (60 * i));
} }
//instances.put(uuid, this); //instances.put(uuid, this);
speed = configSpeed;
putInstance(player, this); putInstance(player, this);
progress(); progress();
} }

View file

@ -41,7 +41,7 @@ public class AirShield extends CoreAbility {
return; return;
} }
/* End Initial Check */ /* End Initial Check */
reloadVariables(); //reloadVariables();
this.player = player; this.player = player;
int angle = 0; int angle = 0;
int di = (int) (maxradius * 2 / numberOfStreams); int di = (int) (maxradius * 2 / numberOfStreams);

View file

@ -29,7 +29,7 @@ public class AirSpout extends CoreAbility {
return; return;
} }
/* End Initial Check */ /* End Initial Check */
reloadVariables(); //reloadVariables();
this.player = player; this.player = player;
time = System.currentTimeMillis(); time = System.currentTimeMillis();
new Flight(player); new Flight(player);

View file

@ -62,7 +62,7 @@ public class AirSuction extends CoreAbility {
if (AirSpout.getPlayers().contains(player.getUniqueId()) || WaterSpout.getPlayers().contains(player)) //TODO: UPDATE THIS LINE if (AirSpout.getPlayers().contains(player.getUniqueId()) || WaterSpout.getPlayers().contains(player)) //TODO: UPDATE THIS LINE
return; return;
/* End Initial Check */ /* End Initial Check */
reloadVariables(); //reloadVariables();
this.player = player; this.player = player;
if (origins.containsKey(player)) { if (origins.containsKey(player)) {
origin = origins.get(player); origin = origins.get(player);

View file

@ -76,7 +76,7 @@ public class AirSwipe extends CoreAbility {
return; return;
} }
/* End Initial Check */ /* End Initial Check */
reloadVariables(); //reloadVariables();
this.player = player; this.player = player;
this.charging = charging; this.charging = charging;
origin = player.getEyeLocation(); origin = player.getEyeLocation();

View file

@ -76,7 +76,7 @@ public class Suffocate extends CoreAbility {
tasks = new ArrayList<BukkitRunnable>(); tasks = new ArrayList<BukkitRunnable>();
time = System.currentTimeMillis(); time = System.currentTimeMillis();
reloadVariables(); //reloadVariables();
reqConstantAim = REQUIRE_CONSTANT_AIM; reqConstantAim = REQUIRE_CONSTANT_AIM;
canSuffUndead = CAN_SUFFOCATE_UNDEAD; canSuffUndead = CAN_SUFFOCATE_UNDEAD;
chargeTime = CHARGE_TIME; chargeTime = CHARGE_TIME;

View file

@ -43,7 +43,7 @@ public class Tornado extends CoreAbility {
// private boolean canfly; // private boolean canfly;
public Tornado(Player player) { public Tornado(Player player) {
reloadVariables(); //reloadVariables();
this.player = player; this.player = player;
// canfly = player.getAllowFlight(); // canfly = player.getAllowFlight();
// player.setAllowFlight(true); // player.setAllowFlight(true);

View file

@ -173,7 +173,7 @@ public class DisplayCommand extends PKCommand {
*/ */
private void displaySubElement(CommandSender sender, String element) { private void displaySubElement(CommandSender sender, String element) {
List<String> abilities = ProjectKorra.plugin.abManager.getAbilities(element); List<String> abilities = ProjectKorra.plugin.abManager.getAbilities(element);
if (abilities.isEmpty()) { if (abilities.isEmpty() && element != null) {
Element e = SubElement.getType(element.toLowerCase()).getMainElement(); Element e = SubElement.getType(element.toLowerCase()).getMainElement();
ChatColor color = GeneralMethods.getSubBendingColor(e); ChatColor color = GeneralMethods.getSubBendingColor(e);
sender.sendMessage(ChatColor.YELLOW + "There are no " + color + element + ChatColor.YELLOW + " abilities installed!"); sender.sendMessage(ChatColor.YELLOW + "There are no " + color + element + ChatColor.YELLOW + " abilities installed!");

View file

@ -38,7 +38,7 @@ public class Catapult extends CoreAbility {
if (bplayer.isOnCooldown("Catapult")) if (bplayer.isOnCooldown("Catapult"))
return; return;
/* End Initial Checks */ /* End Initial Checks */
reloadVariables(); //reloadVariables();
this.player = player; this.player = player;
origin = player.getEyeLocation().clone(); origin = player.getEyeLocation().clone();
direction = origin.getDirection().clone().normalize(); direction = origin.getDirection().clone().normalize();

View file

@ -24,7 +24,7 @@ public class ArcOfFire implements ConfigLoadable {
if (bPlayer.isOnCooldown("Blaze")) if (bPlayer.isOnCooldown("Blaze"))
return; return;
/* End Initial Checks */ /* End Initial Checks */
reloadVariables(); //reloadVariables();
Location location = player.getLocation(); Location location = player.getLocation();

View file

@ -53,7 +53,7 @@ public class Combustion extends CoreAbility {
if (bPlayer.isOnCooldown("Combustion")) if (bPlayer.isOnCooldown("Combustion"))
return; return;
/* End Initial Checks */ /* End Initial Checks */
reloadVariables(); //reloadVariables();
this.player = player; this.player = player;
starttime = System.currentTimeMillis(); starttime = System.currentTimeMillis();
origin = player.getEyeLocation(); origin = player.getEyeLocation();

View file

@ -27,7 +27,7 @@ public class Cook extends AddonAbility {
private long cooktime = COOK_TIME; private long cooktime = COOK_TIME;
public Cook(Player player) { public Cook(Player player) {
reloadVariables(); //reloadVariables();
this.player = player; this.player = player;
items = player.getItemInHand(); items = player.getItemInHand();
time = System.currentTimeMillis(); time = System.currentTimeMillis();

View file

@ -31,7 +31,7 @@ public class Extinguish implements ConfigLoadable {
if (bPlayer.isOnCooldown("HeatControl")) if (bPlayer.isOnCooldown("HeatControl"))
return; return;
/* End Initial Checks */ /* End Initial Checks */
reloadVariables(); //reloadVariables();
double range = FireMethods.getFirebendingDayAugment(defaultrange, player.getWorld()); double range = FireMethods.getFirebendingDayAugment(defaultrange, player.getWorld());
if (WaterMethods.isMeltable(player.getTargetBlock((HashSet<Material>) null, (int) range))) { if (WaterMethods.isMeltable(player.getTargetBlock((HashSet<Material>) null, (int) range))) {

View file

@ -68,7 +68,7 @@ public class FireBlast extends CoreAbility {
return; return;
} }
/* End Initial Checks */ /* End Initial Checks */
reloadVariables(); //reloadVariables();
safe = safeblocks; safe = safeblocks;
range = FireMethods.getFirebendingDayAugment(range, player.getWorld()); range = FireMethods.getFirebendingDayAugment(range, player.getWorld());
// timers.put(player, System.currentTimeMillis()); // timers.put(player, System.currentTimeMillis());

View file

@ -39,7 +39,7 @@ public class FireBurst extends CoreAbility {
if (containsPlayer(player, FireBurst.class)) if (containsPlayer(player, FireBurst.class))
return; return;
/* End Initial Checks */ /* End Initial Checks */
reloadVariables(); //reloadVariables();
starttime = System.currentTimeMillis(); starttime = System.currentTimeMillis();
if (FireMethods.isDay(player.getWorld())) { if (FireMethods.isDay(player.getWorld())) {

View file

@ -102,7 +102,7 @@ public class FireCombo implements ConfigLoadable {
return; return;
} }
/* End Initial Checks */ /* End Initial Checks */
reloadVariables(); //reloadVariables();
time = System.currentTimeMillis(); time = System.currentTimeMillis();
this.player = player; this.player = player;
this.ability = ability; this.ability = ability;

View file

@ -37,7 +37,7 @@ public class FireJet extends CoreAbility {
if (bPlayer.isOnCooldown("FireJet")) if (bPlayer.isOnCooldown("FireJet"))
return; return;
/* End Initial Checks */ /* End Initial Checks */
reloadVariables(); //reloadVariables();
factor = FireMethods.getFirebendingDayAugment(defaultfactor, player.getWorld()); factor = FireMethods.getFirebendingDayAugment(defaultfactor, player.getWorld());
GeneralMethods.invincible.add(this); GeneralMethods.invincible.add(this);

View file

@ -49,7 +49,7 @@ public class FireShield extends CoreAbility {
if (bPlayer.isOnCooldown("FireShield")) if (bPlayer.isOnCooldown("FireShield"))
return; return;
/* End Initial Checks */ /* End Initial Checks */
reloadVariables(); //reloadVariables();
this.player = player; this.player = player;
this.shield = shield; this.shield = shield;

View file

@ -56,7 +56,7 @@ public class Fireball extends AddonAbility {
private boolean damage_blocks; private boolean damage_blocks;
public Fireball(Player player) { public Fireball(Player player) {
reloadVariables(); //reloadVariables();
this.player = player; this.player = player;
time = System.currentTimeMillis(); time = System.currentTimeMillis();
starttime = time; starttime = time;

View file

@ -16,7 +16,7 @@ public class HeatMelt implements ConfigLoadable {
private static int radius = config.get().getInt("Abilities.Fire.HeatControl.Melt.Radius"); private static int radius = config.get().getInt("Abilities.Fire.HeatControl.Melt.Radius");
public HeatMelt(Player player) { public HeatMelt(Player player) {
reloadVariables(); //reloadVariables();
Location location = GeneralMethods.getTargetedLocation(player, (int) FireMethods.getFirebendingDayAugment(range, player.getWorld())); Location location = GeneralMethods.getTargetedLocation(player, (int) FireMethods.getFirebendingDayAugment(range, player.getWorld()));
for (Block block : GeneralMethods.getBlocksAroundPoint(location, (int) FireMethods.getFirebendingDayAugment(radius, player.getWorld()))) { for (Block block : GeneralMethods.getBlocksAroundPoint(location, (int) FireMethods.getFirebendingDayAugment(radius, player.getWorld()))) {
if (WaterMethods.isMeltable(block)) { if (WaterMethods.isMeltable(block)) {

View file

@ -33,7 +33,7 @@ public class Illumination extends CoreAbility {
if (containsPlayer(player, Illumination.class)) { if (containsPlayer(player, Illumination.class)) {
getAbilityFromPlayer(player, Illumination.class).remove(); getAbilityFromPlayer(player, Illumination.class).remove();
} else { } else {
reloadVariables(); //reloadVariables();
this.player = player; this.player = player;
set(); set();
//instances.put(player, this); //instances.put(player, this);

View file

@ -58,7 +58,7 @@ public class Lightning extends CoreAbility {
private double newY; private double newY;
public Lightning(Player player) { public Lightning(Player player) {
reloadVariables(); //reloadVariables();
this.player = player; this.player = player;
bplayer = GeneralMethods.getBendingPlayer(player.getName()); bplayer = GeneralMethods.getBendingPlayer(player.getName());
charged = false; charged = false;

View file

@ -19,7 +19,7 @@ public class RingOfFire implements ConfigLoadable {
if (bPlayer.isOnCooldown("Blaze")) if (bPlayer.isOnCooldown("Blaze"))
return; return;
/* End Initial Checks */ /* End Initial Checks */
reloadVariables(); //reloadVariables();
Location location = player.getLocation(); Location location = player.getLocation();
for (double degrees = 0; degrees < 360; degrees += 10) { for (double degrees = 0; degrees < 360; degrees += 10) {

View file

@ -135,21 +135,21 @@ public class Flight {
} }
public void remove() { public void remove() {
// if (player == null) { if (player == null) {
// for (Player player : instances.keySet()) { for (Player player : instances.keySet()) {
// if (instances.get(player).equals(this)) { if (instances.get(player).equals(this)) {
// instances.remove(player); instances.remove(player);
// } }
// } }
// return; return;
// } }
instances.remove(player); instances.remove(player);
} }
public void revert() { public void revert() {
// if (player == null) { if (player == null) {
// return; return;
// } }
player.setAllowFlight(couldFly); player.setAllowFlight(couldFly);
player.setFlying(wasFlying); player.setFlying(wasFlying);
} }

View file

@ -61,6 +61,7 @@ public class FreezeMelt {
return; return;
byte data = block.getData(); byte data = block.getData();
block.setType(Material.ICE); block.setType(Material.ICE);
if(frozenblocks.size() % 50 == 0)
WaterMethods.playIcebendingSound(block.getLocation()); WaterMethods.playIcebendingSound(block.getLocation());
frozenblocks.put(block, data); frozenblocks.put(block, data);
} }

View file

@ -425,7 +425,7 @@ public class WaterMethods {
public static void playIcebendingSound(Location loc) { public static void playIcebendingSound(Location loc) {
if (plugin.getConfig().getBoolean("Properties.Water.PlaySound")) { if (plugin.getConfig().getBoolean("Properties.Water.PlaySound")) {
loc.getWorld().playSound(loc, Sound.FIRE_IGNITE, 10, 4); loc.getWorld().playSound(loc, Sound.FIRE_IGNITE, 2, 10);
} }
} }

View file

@ -44,15 +44,15 @@ public class WaterPassive {
} }
} }
if (player.getLocation().getBlock().isLiquid()) { // if (player.getLocation().getBlock().isLiquid()) {
for (Block block : GeneralMethods.getBlocksAroundPoint(player.getLocation(), 2)) { // for (Block block : GeneralMethods.getBlocksAroundPoint(player.getLocation(), 2)) {
if (GeneralMethods.isAdjacentToThreeOrMoreSources(block) && WaterMethods.isWater(block)) { // if (GeneralMethods.isAdjacentToThreeOrMoreSources(block) && WaterMethods.isWater(block)) {
byte full = 0x0; // byte full = 0x0;
block.setType(Material.WATER); // block.setType(Material.WATER);
block.setData(full); // block.setData(full);
} // }
} // }
} // }
} }
} }
} }

View file

@ -259,6 +259,8 @@ public class WaterWall {
if (GeneralMethods.getBoundAbility(player) == null) { if (GeneralMethods.getBoundAbility(player) == null) {
unfocusBlock(); unfocusBlock();
breakBlock();
returnWater(location);
return false; return false;
} }
if (!progressing && !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("Surge")) { if (!progressing && !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("Surge")) {

View file

@ -191,6 +191,9 @@ public class Wave {
if (GeneralMethods.getBoundAbility(player) == null) { if (GeneralMethods.getBoundAbility(player) == null) {
unfocusBlock(); unfocusBlock();
thaw();
breakBlock();
returnWater(location);
return false; return false;
} }
if (!progressing && !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("Surge")) { if (!progressing && !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("Surge")) {