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