mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-23 00:15:05 +00:00
Fix memory leak in EarthColumn
Unnecessary variables were being used to store raised blocks to prevent them from being raised again. Removed the variables and added a check that blocks couldn't be raised if there was air beneath them, accomplishing the same thing.
This commit is contained in:
parent
7f0c258311
commit
e2e0493253
4 changed files with 2 additions and 41 deletions
|
@ -77,9 +77,6 @@ public class CompactColumn {
|
|||
|
||||
if (distance != 0) {
|
||||
if (canInstantiate()) {
|
||||
for (Block blocki : affectedblocks.keySet()) {
|
||||
EarthColumn.resetBlock(blocki);
|
||||
}
|
||||
id = ID;
|
||||
instances.put(id, this);
|
||||
if (ID >= Integer.MAX_VALUE) {
|
||||
|
@ -144,9 +141,6 @@ public class CompactColumn {
|
|||
if (System.currentTimeMillis() - time >= interval) {
|
||||
time = System.currentTimeMillis();
|
||||
if (!moveEarth()) {
|
||||
for (Block blocki : affectedblocks.keySet()) {
|
||||
EarthColumn.resetBlock(blocki);
|
||||
}
|
||||
instances.remove(id);
|
||||
// for (Block block : affectedblocks.keySet()) {
|
||||
// alreadydoneblocks.put(block, block);
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.projectkorra.projectkorra.util.BlockSource;
|
|||
import com.projectkorra.projectkorra.util.ClickType;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.Vector;
|
||||
|
@ -17,8 +18,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||
public class EarthColumn {
|
||||
|
||||
public static ConcurrentHashMap<Integer, EarthColumn> instances = new ConcurrentHashMap<Integer, EarthColumn>();
|
||||
private static ConcurrentHashMap<Block, Block> alreadydoneblocks = new ConcurrentHashMap<Block, Block>();
|
||||
private static ConcurrentHashMap<Block, Integer> baseblocks = new ConcurrentHashMap<Block, Integer>();
|
||||
|
||||
public static final int standardheight = ProjectKorra.plugin.getConfig().getInt("Abilities.Earth.RaiseEarth.Column.Height");
|
||||
private static int ID = Integer.MIN_VALUE;
|
||||
|
@ -158,7 +157,7 @@ public class EarthColumn {
|
|||
|
||||
private boolean canInstantiate() {
|
||||
for (Block block : affectedblocks.keySet()) {
|
||||
if (blockInAllAffectedBlocks(block) || alreadydoneblocks.containsKey(block)) {
|
||||
if (blockInAllAffectedBlocks(block) || block.getType()==Material.AIR) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -176,10 +175,6 @@ public class EarthColumn {
|
|||
time = System.currentTimeMillis();
|
||||
if (!moveEarth()) {
|
||||
instances.remove(id);
|
||||
for (Block block : affectedblocks.keySet()) {
|
||||
alreadydoneblocks.put(block, block);
|
||||
}
|
||||
baseblocks.put(location.clone().add(direction.clone().multiply(-1 * (distance - 1))).getBlock(), (distance - 1));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -200,34 +195,12 @@ public class EarthColumn {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static boolean blockIsBase(Block block) {
|
||||
if (baseblocks.containsKey(block)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void removeBlockBase(Block block) {
|
||||
if (baseblocks.containsKey(block)) {
|
||||
baseblocks.remove(block);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void removeAll() {
|
||||
for (int id : instances.keySet()) {
|
||||
instances.remove(id);
|
||||
}
|
||||
}
|
||||
|
||||
public static void resetBlock(Block block) {
|
||||
|
||||
if (alreadydoneblocks.containsKey(block)) {
|
||||
alreadydoneblocks.remove(block);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static String getDescription() {
|
||||
return "To use, simply left-click on an earthbendable block. " + "A column of earth will shoot upwards from that location. " + "Anything in the way of the column will be brought up with it, " + "leaving talented benders the ability to trap brainless entities up there. " + "Additionally, simply sneak (default shift) looking at an earthbendable block. " + "A wall of earth will shoot upwards from that location. " + "Anything in the way of the wall will be brought up with it. ";
|
||||
}
|
||||
|
|
|
@ -535,8 +535,6 @@ public class EarthMethods {
|
|||
if (EarthColumn.blockInAllAffectedBlocks(block))
|
||||
EarthColumn.revertBlock(block);
|
||||
|
||||
EarthColumn.resetBlock(block);
|
||||
|
||||
movedearth.remove(block);
|
||||
}
|
||||
}
|
||||
|
@ -587,8 +585,6 @@ public class EarthMethods {
|
|||
EarthColumn.revertBlock(sourceblock);
|
||||
if (EarthColumn.blockInAllAffectedBlocks(block))
|
||||
EarthColumn.revertBlock(block);
|
||||
EarthColumn.resetBlock(sourceblock);
|
||||
EarthColumn.resetBlock(block);
|
||||
movedearth.remove(block);
|
||||
return true;
|
||||
}
|
||||
|
@ -616,8 +612,6 @@ public class EarthMethods {
|
|||
EarthColumn.revertBlock(sourceblock);
|
||||
if (EarthColumn.blockInAllAffectedBlocks(block))
|
||||
EarthColumn.revertBlock(block);
|
||||
EarthColumn.resetBlock(sourceblock);
|
||||
EarthColumn.resetBlock(block);
|
||||
movedearth.remove(block);
|
||||
}
|
||||
return true;
|
||||
|
|
Binary file not shown.
Loading…
Reference in a new issue