mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2025-02-15 05:17:53 +00:00
Increase performance in RevertChecker
This commit is contained in:
parent
eb9d7f9cbf
commit
de560d598c
1 changed files with 14 additions and 14 deletions
|
@ -12,9 +12,10 @@ import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
public class RevertChecker implements Runnable {
|
public class RevertChecker implements Runnable {
|
||||||
|
@ -23,11 +24,10 @@ public class RevertChecker implements Runnable {
|
||||||
|
|
||||||
private static final FileConfiguration config = ConfigManager.defaultConfig.get();
|
private static final FileConfiguration config = ConfigManager.defaultConfig.get();
|
||||||
private static final boolean safeRevert = config.getBoolean("Properties.Earth.SafeRevert");
|
private static final boolean safeRevert = config.getBoolean("Properties.Earth.SafeRevert");
|
||||||
public static ConcurrentHashMap<Block, Block> earthRevertQueue = new ConcurrentHashMap<Block, Block>();
|
public static Set<Block> earthRevertQueue = new HashSet<>();
|
||||||
static ConcurrentHashMap<Integer, Integer> airRevertQueue = new ConcurrentHashMap<Integer, Integer>();
|
static Set<Integer> airRevertQueue = new HashSet<>();
|
||||||
static ConcurrentHashMap<Chunk, Chunk> chunks = new ConcurrentHashMap<Chunk, Chunk>();
|
//static ConcurrentHashMap<Chunk, Chunk> chunks = new ConcurrentHashMap<Chunk, Chunk>();
|
||||||
// static ConcurrentHashMap<Block, Material> movedEarthQueue = new
|
// static ConcurrentHashMap<Block, Material> movedEarthQueue = new ConcurrentHashMap<Block, Material>();
|
||||||
// ConcurrentHashMap<Block, Material>();
|
|
||||||
|
|
||||||
private long time;
|
private long time;
|
||||||
|
|
||||||
|
@ -36,14 +36,14 @@ public class RevertChecker implements Runnable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void revertAirBlocks() {
|
public static void revertAirBlocks() {
|
||||||
for (int ID : airRevertQueue.keySet()) {
|
for (int ID : airRevertQueue) {
|
||||||
EarthMethods.revertAirBlock(ID);
|
EarthMethods.revertAirBlock(ID);
|
||||||
RevertChecker.airRevertQueue.remove(ID);
|
RevertChecker.airRevertQueue.remove(ID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void revertEarthBlocks() {
|
public static void revertEarthBlocks() {
|
||||||
for (Block block : earthRevertQueue.keySet()) {
|
for (Block block : earthRevertQueue) {
|
||||||
EarthMethods.revertBlock(block);
|
EarthMethods.revertBlock(block);
|
||||||
earthRevertQueue.remove(block);
|
earthRevertQueue.remove(block);
|
||||||
}
|
}
|
||||||
|
@ -58,14 +58,14 @@ public class RevertChecker implements Runnable {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
private void addToAirRevertQueue(int i) {
|
private void addToAirRevertQueue(int i) {
|
||||||
if (!airRevertQueue.containsKey(i))
|
if (!airRevertQueue.contains(i))
|
||||||
airRevertQueue.put(i, i);
|
airRevertQueue.add(i);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToRevertQueue(Block block) {
|
private void addToRevertQueue(Block block) {
|
||||||
if (!earthRevertQueue.containsKey(block))
|
if (!earthRevertQueue.contains(block))
|
||||||
earthRevertQueue.put(block, block);
|
earthRevertQueue.add(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -81,7 +81,7 @@ public class RevertChecker implements Runnable {
|
||||||
earth.putAll(EarthMethods.movedearth);
|
earth.putAll(EarthMethods.movedearth);
|
||||||
|
|
||||||
for (Block block : earth.keySet()) {
|
for (Block block : earth.keySet()) {
|
||||||
if (earthRevertQueue.containsKey(block))
|
if (earthRevertQueue.contains(block))
|
||||||
continue;
|
continue;
|
||||||
boolean remove = true;
|
boolean remove = true;
|
||||||
Information info = earth.get(block);
|
Information info = earth.get(block);
|
||||||
|
@ -97,7 +97,7 @@ public class RevertChecker implements Runnable {
|
||||||
air.putAll(EarthMethods.tempair);
|
air.putAll(EarthMethods.tempair);
|
||||||
|
|
||||||
for (Integer i : air.keySet()) {
|
for (Integer i : air.keySet()) {
|
||||||
if (airRevertQueue.containsKey(i))
|
if (airRevertQueue.contains(i))
|
||||||
continue;
|
continue;
|
||||||
boolean remove = true;
|
boolean remove = true;
|
||||||
Information info = air.get(i);
|
Information info = air.get(i);
|
||||||
|
|
Loading…
Reference in a new issue