mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-30 21:07:48 +01:00
Optimizing block ownership removal
This commit is contained in:
parent
be88eee903
commit
8cd3f4fbbe
@ -234,9 +234,9 @@ public final class Jobs extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void removeBlockOwnerShip(org.bukkit.block.Block block) {
|
||||
for (BlockOwnerShip ship : blockOwnerShipsMaterial.values()) {
|
||||
BlockOwnerShip ship = blockOwnerShipsMaterial.get(CMIMaterial.get(block));
|
||||
if (ship != null)
|
||||
ship.remove(block);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,24 +170,25 @@ public class BlockOwnerShip {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (uuid == null) {
|
||||
return false;
|
||||
}
|
||||
return remove(uuid, block);
|
||||
}
|
||||
|
||||
public boolean remove(UUID uuid, Block block) {
|
||||
if (uuid == null) {
|
||||
return false;
|
||||
}
|
||||
HashMap<String, blockLoc> ls = blockOwnerShips.getOrDefault(uuid, new HashMap<String, blockLoc>());
|
||||
String blockLoc = CMILocation.toString(block.getLocation(), ":", true, true);
|
||||
|
||||
com.gamingmesh.jobs.stuff.blockLoc removed = ls.remove(blockLoc);
|
||||
if (removed != null) {
|
||||
block.removeMetadata(metadataName, plugin);
|
||||
|
||||
Map<String, UUID> oldRecord = ownerMapByLocation.get(block.getLocation().getWorld().getName());
|
||||
if (oldRecord != null)
|
||||
oldRecord.remove(block.getLocation().getBlockX() + ":" + block.getLocation().getBlockY() + ":" + block.getLocation().getBlockZ());
|
||||
|
||||
}
|
||||
|
||||
return removed != null;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user