Fixed memory leak with IceSpike (#713)

This commit is contained in:
Sobki 2017-01-30 17:18:20 +10:00 committed by Christopher Martin
parent 4743fdc829
commit f10abf5020

View file

@ -1,12 +1,9 @@
package com.projectkorra.projectkorra.waterbending.ice;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.ability.IceAbility;
import com.projectkorra.projectkorra.ability.WaterAbility;
import com.projectkorra.projectkorra.util.DamageHandler;
import com.projectkorra.projectkorra.util.TempBlock;
import com.projectkorra.projectkorra.util.TempPotionEffect;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import org.bukkit.Location;
import org.bukkit.Material;
@ -19,14 +16,17 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.ability.IceAbility;
import com.projectkorra.projectkorra.ability.WaterAbility;
import com.projectkorra.projectkorra.util.DamageHandler;
import com.projectkorra.projectkorra.util.TempBlock;
import com.projectkorra.projectkorra.util.TempPotionEffect;
public class IceSpikePillar extends IceAbility {
/**The list of blocks IceSpike uses*/
/** The list of blocks IceSpike uses */
private Map<Block, TempBlock> ice_blocks = new HashMap<Block, TempBlock>();
private int height;
@ -138,6 +138,7 @@ public class IceSpikePillar extends IceAbility {
/**
* Reverts the block if it's part of IceSpike
*
* @param block The Block
* @return If the block was removed or not
*/
@ -152,8 +153,10 @@ public class IceSpikePillar extends IceAbility {
return false;
}
/**Checks to see if this move can start. Checks things like if there is enough space to form, if the source isn't
* a TempBlock, etc.*/
/**
* Checks to see if this move can start. Checks things like if there is
* enough space to form, if the source isn't a TempBlock, etc.
*/
private boolean canInstantiate() {
if (!isIcebendable(source_block.getType())) {
return false;
@ -195,7 +198,8 @@ public class IceSpikePillar extends IceAbility {
/**
* Makes the pillar rise by 1 block.
*
* @return If the block was placed successfully.*/
* @return If the block was placed successfully.
*/
private boolean risePillar() {
progress++;
Block affectedBlock = location.clone().add(direction).getBlock();
@ -212,7 +216,7 @@ public class IceSpikePillar extends IceAbility {
}
}
TempBlock b = new TempBlock(affectedBlock, Material.ICE, (byte)0);
TempBlock b = new TempBlock(affectedBlock, Material.ICE, (byte) 0);
ice_blocks.put(affectedBlock, b);
if (!inField || new Random().nextInt((int) ((height + 1) * 1.5)) == 0) {
@ -240,9 +244,11 @@ public class IceSpikePillar extends IceAbility {
AirAbility.breakBreathbendingHold(entity);
}
/**The reverse of risePillar(). Makes the pillar sink
/**
* The reverse of risePillar(). Makes the pillar sink
*
* @return If the move should continue progressing.*/
* @return If the move should continue progressing.
*/
public boolean sinkPillar() {
Vector direction = this.direction.clone().multiply(-1);
if (ice_blocks.containsKey(location.getBlock())) {
@ -250,7 +256,7 @@ public class IceSpikePillar extends IceAbility {
ice_blocks.remove(location.getBlock());
location.add(direction);
if (source_block == location.getBlock()) {
if (source_block.equals(location.getBlock())) {
return false;
}
}