mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-14 12:57:55 +00:00
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:
parent
7729e2e9b4
commit
7669486103
36 changed files with 65 additions and 55 deletions
|
@ -293,8 +293,6 @@ public class GeneralMethods {
|
|||
return false;
|
||||
if (!bPlayer.isToggled())
|
||||
return false;
|
||||
if (p == null)
|
||||
return false;
|
||||
if (p.getGameMode() == GameMode.SPECTATOR)
|
||||
return false;
|
||||
if (cooldowns.containsKey(p.getName())) {
|
||||
|
|
|
@ -1295,7 +1295,7 @@ public class PKListener implements Listener {
|
|||
ComboManager.addComboAbility(player, ClickType.LEFT_CLICK);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,11 +16,10 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
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 HashMap<String, ComboAbility> comboAbilityList = new HashMap<String, ComboAbility>();
|
||||
public static HashMap<String, String> authors = new HashMap<String, String>();
|
||||
|
@ -205,6 +204,7 @@ public class ComboManager {
|
|||
list = new ArrayList<AbilityInformation>();
|
||||
list.add(info);
|
||||
recentlyUsedAbilities.put(name, list);
|
||||
//Bukkit.broadcastMessage("recentlyUsedAbilities: " + recentlyUsedAbilities.get(name).size());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -244,8 +244,11 @@ public class ComboManager {
|
|||
Enumeration<String> keys = recentlyUsedAbilities.keys();
|
||||
while (keys.hasMoreElements()) {
|
||||
String name = keys.nextElement();
|
||||
ArrayList<AbilityInformation> usedAbilities = recentlyUsedAbilities.get(name);
|
||||
usedAbilities.clear();
|
||||
//ArrayList<AbilityInformation> usedAbilities = recentlyUsedAbilities.get(name);
|
||||
if(recentlyUsedAbilities.get(name).size() > 75) {
|
||||
recentlyUsedAbilities.get(name).clear();
|
||||
//Bukkit.broadcastMessage(name + " recentlyUsed Cleared");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -293,6 +296,7 @@ public class ComboManager {
|
|||
new BukkitRunnable() {
|
||||
public void run() {
|
||||
cleanupOldCombos();
|
||||
//Bukkit.broadcastMessage("Cleaned");
|
||||
}
|
||||
}.runTaskTimer(ProjectKorra.plugin, 0, CLEANUP_DELAY);
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ public class AirBlast extends CoreAbility {
|
|||
if (location.getBlock().isLiquid()) {
|
||||
return;
|
||||
}
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
source = burst;
|
||||
|
||||
this.player = player;
|
||||
|
|
|
@ -28,7 +28,7 @@ public class AirBubble extends CoreAbility {
|
|||
private ConcurrentHashMap<Block, BlockState> waterorigins;
|
||||
|
||||
public AirBubble(Player player) {
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
this.player = player;
|
||||
waterorigins = new ConcurrentHashMap<Block, BlockState>();
|
||||
//instances.put(uuid, this);
|
||||
|
|
|
@ -33,7 +33,7 @@ public class AirBurst extends CoreAbility {
|
|||
private ArrayList<Entity> affectedentities = new ArrayList<Entity>();
|
||||
|
||||
public AirBurst() {
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
}
|
||||
|
||||
public AirBurst(Player player) {
|
||||
|
|
|
@ -79,6 +79,7 @@ public class AirCombo implements ConfigLoadable {
|
|||
|
||||
public AirCombo(Player player, String ability) {
|
||||
/* Initial Checks */
|
||||
|
||||
if (!enabled)
|
||||
return;
|
||||
if (Commands.isToggledForAll)
|
||||
|
@ -94,7 +95,7 @@ public class AirCombo implements ConfigLoadable {
|
|||
if (GeneralMethods.isRegionProtectedFromBuild(player, "AirBlast", player.getLocation()))
|
||||
return;
|
||||
/* End Initial Checks */
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
time = System.currentTimeMillis();
|
||||
this.player = player;
|
||||
this.ability = ability;
|
||||
|
|
|
@ -36,7 +36,7 @@ public class AirScooter extends CoreAbility {
|
|||
if (GeneralMethods.isSolid(player.getLocation().add(0, -.5, 0).getBlock()))
|
||||
return;
|
||||
/* End Initial Check */
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
this.player = player;
|
||||
// wasflying = player.isFlying();
|
||||
// canfly = player.getAllowFlight();
|
||||
|
@ -49,6 +49,7 @@ public class AirScooter extends CoreAbility {
|
|||
angles.add((double) (60 * i));
|
||||
}
|
||||
//instances.put(uuid, this);
|
||||
speed = configSpeed;
|
||||
putInstance(player, this);
|
||||
progress();
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ public class AirShield extends CoreAbility {
|
|||
return;
|
||||
}
|
||||
/* End Initial Check */
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
this.player = player;
|
||||
int angle = 0;
|
||||
int di = (int) (maxradius * 2 / numberOfStreams);
|
||||
|
|
|
@ -29,7 +29,7 @@ public class AirSpout extends CoreAbility {
|
|||
return;
|
||||
}
|
||||
/* End Initial Check */
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
this.player = player;
|
||||
time = System.currentTimeMillis();
|
||||
new Flight(player);
|
||||
|
|
|
@ -62,7 +62,7 @@ public class AirSuction extends CoreAbility {
|
|||
if (AirSpout.getPlayers().contains(player.getUniqueId()) || WaterSpout.getPlayers().contains(player)) //TODO: UPDATE THIS LINE
|
||||
return;
|
||||
/* End Initial Check */
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
this.player = player;
|
||||
if (origins.containsKey(player)) {
|
||||
origin = origins.get(player);
|
||||
|
|
|
@ -76,7 +76,7 @@ public class AirSwipe extends CoreAbility {
|
|||
return;
|
||||
}
|
||||
/* End Initial Check */
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
this.player = player;
|
||||
this.charging = charging;
|
||||
origin = player.getEyeLocation();
|
||||
|
|
|
@ -76,7 +76,7 @@ public class Suffocate extends CoreAbility {
|
|||
tasks = new ArrayList<BukkitRunnable>();
|
||||
time = System.currentTimeMillis();
|
||||
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
reqConstantAim = REQUIRE_CONSTANT_AIM;
|
||||
canSuffUndead = CAN_SUFFOCATE_UNDEAD;
|
||||
chargeTime = CHARGE_TIME;
|
||||
|
|
|
@ -43,7 +43,7 @@ public class Tornado extends CoreAbility {
|
|||
// private boolean canfly;
|
||||
|
||||
public Tornado(Player player) {
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
this.player = player;
|
||||
// canfly = player.getAllowFlight();
|
||||
// player.setAllowFlight(true);
|
||||
|
|
|
@ -173,7 +173,7 @@ public class DisplayCommand extends PKCommand {
|
|||
*/
|
||||
private void displaySubElement(CommandSender sender, String element) {
|
||||
List<String> abilities = ProjectKorra.plugin.abManager.getAbilities(element);
|
||||
if (abilities.isEmpty()) {
|
||||
if (abilities.isEmpty() && element != null) {
|
||||
Element e = SubElement.getType(element.toLowerCase()).getMainElement();
|
||||
ChatColor color = GeneralMethods.getSubBendingColor(e);
|
||||
sender.sendMessage(ChatColor.YELLOW + "There are no " + color + element + ChatColor.YELLOW + " abilities installed!");
|
||||
|
|
|
@ -38,7 +38,7 @@ public class Catapult extends CoreAbility {
|
|||
if (bplayer.isOnCooldown("Catapult"))
|
||||
return;
|
||||
/* End Initial Checks */
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
this.player = player;
|
||||
origin = player.getEyeLocation().clone();
|
||||
direction = origin.getDirection().clone().normalize();
|
||||
|
|
|
@ -24,7 +24,7 @@ public class ArcOfFire implements ConfigLoadable {
|
|||
if (bPlayer.isOnCooldown("Blaze"))
|
||||
return;
|
||||
/* End Initial Checks */
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
|
||||
Location location = player.getLocation();
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ public class Combustion extends CoreAbility {
|
|||
if (bPlayer.isOnCooldown("Combustion"))
|
||||
return;
|
||||
/* End Initial Checks */
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
this.player = player;
|
||||
starttime = System.currentTimeMillis();
|
||||
origin = player.getEyeLocation();
|
||||
|
|
|
@ -27,7 +27,7 @@ public class Cook extends AddonAbility {
|
|||
private long cooktime = COOK_TIME;
|
||||
|
||||
public Cook(Player player) {
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
this.player = player;
|
||||
items = player.getItemInHand();
|
||||
time = System.currentTimeMillis();
|
||||
|
|
|
@ -31,7 +31,7 @@ public class Extinguish implements ConfigLoadable {
|
|||
if (bPlayer.isOnCooldown("HeatControl"))
|
||||
return;
|
||||
/* End Initial Checks */
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
|
||||
double range = FireMethods.getFirebendingDayAugment(defaultrange, player.getWorld());
|
||||
if (WaterMethods.isMeltable(player.getTargetBlock((HashSet<Material>) null, (int) range))) {
|
||||
|
|
|
@ -68,7 +68,7 @@ public class FireBlast extends CoreAbility {
|
|||
return;
|
||||
}
|
||||
/* End Initial Checks */
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
safe = safeblocks;
|
||||
range = FireMethods.getFirebendingDayAugment(range, player.getWorld());
|
||||
// timers.put(player, System.currentTimeMillis());
|
||||
|
|
|
@ -39,7 +39,7 @@ public class FireBurst extends CoreAbility {
|
|||
if (containsPlayer(player, FireBurst.class))
|
||||
return;
|
||||
/* End Initial Checks */
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
|
||||
starttime = System.currentTimeMillis();
|
||||
if (FireMethods.isDay(player.getWorld())) {
|
||||
|
|
|
@ -102,7 +102,7 @@ public class FireCombo implements ConfigLoadable {
|
|||
return;
|
||||
}
|
||||
/* End Initial Checks */
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
time = System.currentTimeMillis();
|
||||
this.player = player;
|
||||
this.ability = ability;
|
||||
|
|
|
@ -37,7 +37,7 @@ public class FireJet extends CoreAbility {
|
|||
if (bPlayer.isOnCooldown("FireJet"))
|
||||
return;
|
||||
/* End Initial Checks */
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
|
||||
factor = FireMethods.getFirebendingDayAugment(defaultfactor, player.getWorld());
|
||||
GeneralMethods.invincible.add(this);
|
||||
|
|
|
@ -49,7 +49,7 @@ public class FireShield extends CoreAbility {
|
|||
if (bPlayer.isOnCooldown("FireShield"))
|
||||
return;
|
||||
/* End Initial Checks */
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
this.player = player;
|
||||
this.shield = shield;
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ public class Fireball extends AddonAbility {
|
|||
private boolean damage_blocks;
|
||||
|
||||
public Fireball(Player player) {
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
this.player = player;
|
||||
time = System.currentTimeMillis();
|
||||
starttime = time;
|
||||
|
|
|
@ -16,7 +16,7 @@ public class HeatMelt implements ConfigLoadable {
|
|||
private static int radius = config.get().getInt("Abilities.Fire.HeatControl.Melt.Radius");
|
||||
|
||||
public HeatMelt(Player player) {
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
Location location = GeneralMethods.getTargetedLocation(player, (int) FireMethods.getFirebendingDayAugment(range, player.getWorld()));
|
||||
for (Block block : GeneralMethods.getBlocksAroundPoint(location, (int) FireMethods.getFirebendingDayAugment(radius, player.getWorld()))) {
|
||||
if (WaterMethods.isMeltable(block)) {
|
||||
|
|
|
@ -33,7 +33,7 @@ public class Illumination extends CoreAbility {
|
|||
if (containsPlayer(player, Illumination.class)) {
|
||||
getAbilityFromPlayer(player, Illumination.class).remove();
|
||||
} else {
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
this.player = player;
|
||||
set();
|
||||
//instances.put(player, this);
|
||||
|
|
|
@ -58,7 +58,7 @@ public class Lightning extends CoreAbility {
|
|||
private double newY;
|
||||
|
||||
public Lightning(Player player) {
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
this.player = player;
|
||||
bplayer = GeneralMethods.getBendingPlayer(player.getName());
|
||||
charged = false;
|
||||
|
|
|
@ -19,7 +19,7 @@ public class RingOfFire implements ConfigLoadable {
|
|||
if (bPlayer.isOnCooldown("Blaze"))
|
||||
return;
|
||||
/* End Initial Checks */
|
||||
reloadVariables();
|
||||
//reloadVariables();
|
||||
Location location = player.getLocation();
|
||||
|
||||
for (double degrees = 0; degrees < 360; degrees += 10) {
|
||||
|
|
|
@ -135,21 +135,21 @@ public class Flight {
|
|||
}
|
||||
|
||||
public void remove() {
|
||||
// if (player == null) {
|
||||
// for (Player player : instances.keySet()) {
|
||||
// if (instances.get(player).equals(this)) {
|
||||
// instances.remove(player);
|
||||
// }
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
if (player == null) {
|
||||
for (Player player : instances.keySet()) {
|
||||
if (instances.get(player).equals(this)) {
|
||||
instances.remove(player);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
instances.remove(player);
|
||||
}
|
||||
|
||||
public void revert() {
|
||||
// if (player == null) {
|
||||
// return;
|
||||
// }
|
||||
if (player == null) {
|
||||
return;
|
||||
}
|
||||
player.setAllowFlight(couldFly);
|
||||
player.setFlying(wasFlying);
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ public class FreezeMelt {
|
|||
return;
|
||||
byte data = block.getData();
|
||||
block.setType(Material.ICE);
|
||||
if(frozenblocks.size() % 50 == 0)
|
||||
WaterMethods.playIcebendingSound(block.getLocation());
|
||||
frozenblocks.put(block, data);
|
||||
}
|
||||
|
|
|
@ -425,7 +425,7 @@ public class WaterMethods {
|
|||
|
||||
public static void playIcebendingSound(Location loc) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -44,15 +44,15 @@ public class WaterPassive {
|
|||
}
|
||||
}
|
||||
|
||||
if (player.getLocation().getBlock().isLiquid()) {
|
||||
for (Block block : GeneralMethods.getBlocksAroundPoint(player.getLocation(), 2)) {
|
||||
if (GeneralMethods.isAdjacentToThreeOrMoreSources(block) && WaterMethods.isWater(block)) {
|
||||
byte full = 0x0;
|
||||
block.setType(Material.WATER);
|
||||
block.setData(full);
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (player.getLocation().getBlock().isLiquid()) {
|
||||
// for (Block block : GeneralMethods.getBlocksAroundPoint(player.getLocation(), 2)) {
|
||||
// if (GeneralMethods.isAdjacentToThreeOrMoreSources(block) && WaterMethods.isWater(block)) {
|
||||
// byte full = 0x0;
|
||||
// block.setType(Material.WATER);
|
||||
// block.setData(full);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -259,6 +259,8 @@ public class WaterWall {
|
|||
|
||||
if (GeneralMethods.getBoundAbility(player) == null) {
|
||||
unfocusBlock();
|
||||
breakBlock();
|
||||
returnWater(location);
|
||||
return false;
|
||||
}
|
||||
if (!progressing && !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("Surge")) {
|
||||
|
|
|
@ -191,6 +191,9 @@ public class Wave {
|
|||
|
||||
if (GeneralMethods.getBoundAbility(player) == null) {
|
||||
unfocusBlock();
|
||||
thaw();
|
||||
breakBlock();
|
||||
returnWater(location);
|
||||
return false;
|
||||
}
|
||||
if (!progressing && !GeneralMethods.getBoundAbility(player).equalsIgnoreCase("Surge")) {
|
||||
|
|
Loading…
Reference in a new issue