mirror of
https://github.com/Zrips/Jobs.git
synced 2024-11-26 04:25:15 +01:00
parent
4d5a8563e1
commit
11b6f8f140
@ -19,15 +19,15 @@ public class BlockProtectionManager {
|
||||
private ConcurrentHashMap<World, ConcurrentHashMap<String, BlockProtection>> tempCache = new ConcurrentHashMap<>();
|
||||
|
||||
public HashMap<World, HashMap<String, HashMap<String, HashMap<String, BlockProtection>>>> getMap() {
|
||||
return this.map;
|
||||
return map;
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
int i = 0;
|
||||
for (Entry<World, HashMap<String, HashMap<String, HashMap<String, BlockProtection>>>> worlds : map.entrySet()) {
|
||||
for (Entry<String, HashMap<String, HashMap<String, BlockProtection>>> regions : worlds.getValue().entrySet()) {
|
||||
for (Entry<String, HashMap<String, BlockProtection>> chunks : regions.getValue().entrySet()) {
|
||||
i += chunks.getValue().size();
|
||||
for (HashMap<String, HashMap<String, HashMap<String, BlockProtection>>> worlds : map.values()) {
|
||||
for (HashMap<String, HashMap<String, BlockProtection>> regions : worlds.values()) {
|
||||
for (HashMap<String, BlockProtection> chunks : regions.values()) {
|
||||
i += chunks.size();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -89,7 +89,7 @@ public class BlockProtectionManager {
|
||||
String v = loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ();
|
||||
ConcurrentHashMap<String, BlockProtection> locations = tempCache.get(loc.getWorld());
|
||||
if (locations == null) {
|
||||
locations = new ConcurrentHashMap<String, BlockProtection>();
|
||||
locations = new ConcurrentHashMap<>();
|
||||
tempCache.put(loc.getWorld(), locations);
|
||||
}
|
||||
|
||||
@ -137,9 +137,7 @@ public class BlockProtectionManager {
|
||||
|
||||
public Long getTime(Location loc) {
|
||||
BlockProtection Bp = getBp(loc);
|
||||
if (Bp == null)
|
||||
return null;
|
||||
return Bp.getTime();
|
||||
return Bp == null ? null : Bp.getTime();
|
||||
}
|
||||
|
||||
public BlockProtection getBp(Location loc) {
|
||||
@ -179,6 +177,6 @@ public class BlockProtectionManager {
|
||||
}
|
||||
|
||||
public boolean isInBp(Block block) {
|
||||
return Jobs.getRestrictedBlockManager().restrictedBlocksTimer.get(CMIMaterial.get(block)) != null;
|
||||
return Jobs.getRestrictedBlockManager().restrictedBlocksTimer.containsKey(CMIMaterial.get(block));
|
||||
}
|
||||
}
|
||||
|
@ -28,17 +28,17 @@ public class PistonProtectionListener implements Listener {
|
||||
return;
|
||||
|
||||
BlockFace dir = event.getDirection();
|
||||
|
||||
int x = dir.getModX(),
|
||||
y = dir.getModY(),
|
||||
z = dir.getModZ();
|
||||
|
||||
for (int i = event.getBlocks().size() - 1; i >= 0; i--) {
|
||||
Block one = event.getBlocks().get(i);
|
||||
Location oldLoc = one.getLocation();
|
||||
Location newLoc = oldLoc.clone().add(x, y, z);
|
||||
Long bp = Jobs.getBpManager().getTime(oldLoc);
|
||||
if (bp != null) {
|
||||
Jobs.getBpManager().addP(newLoc, bp, true, true);
|
||||
Jobs.getBpManager().addP(newLoc, bp, false, true);
|
||||
Jobs.getBpManager().remove(oldLoc);
|
||||
}
|
||||
}
|
||||
@ -57,10 +57,10 @@ public class PistonProtectionListener implements Listener {
|
||||
return;
|
||||
|
||||
BlockFace dir = event.getDirection();
|
||||
|
||||
int x = dir.getModX(),
|
||||
y = dir.getModY(),
|
||||
z = dir.getModZ();
|
||||
|
||||
List<Block> blocks = Jobs.getNms().getPistonRetractBlocks(event);
|
||||
for (int i = blocks.size() - 1; i >= 0; i--) {
|
||||
Block one = blocks.get(i);
|
||||
@ -68,7 +68,7 @@ public class PistonProtectionListener implements Listener {
|
||||
Location newLoc = oldLoc.clone().add(x, y, z);
|
||||
Long bp = Jobs.getBpManager().getTime(oldLoc);
|
||||
if (bp != null) {
|
||||
Jobs.getBpManager().addP(newLoc, bp, true, true);
|
||||
Jobs.getBpManager().addP(newLoc, bp, false, true);
|
||||
Jobs.getBpManager().remove(oldLoc);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user