1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-02 14:29:07 +01:00

Optimizing block ownership removal

This commit is contained in:
Zrips 2021-10-26 14:05:09 +03:00
parent be88eee903
commit 8cd3f4fbbe
2 changed files with 8 additions and 7 deletions

View File

@ -234,9 +234,9 @@ public final class Jobs extends JavaPlugin {
} }
public void removeBlockOwnerShip(org.bukkit.block.Block block) { 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); ship.remove(block);
}
} }
/** /**

View File

@ -170,24 +170,25 @@ public class BlockOwnerShip {
} }
} }
} }
if (uuid == null) { if (uuid == null) {
return false; 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>()); HashMap<String, blockLoc> ls = blockOwnerShips.getOrDefault(uuid, new HashMap<String, blockLoc>());
String blockLoc = CMILocation.toString(block.getLocation(), ":", true, true); String blockLoc = CMILocation.toString(block.getLocation(), ":", true, true);
com.gamingmesh.jobs.stuff.blockLoc removed = ls.remove(blockLoc); com.gamingmesh.jobs.stuff.blockLoc removed = ls.remove(blockLoc);
if (removed != null) { if (removed != null) {
block.removeMetadata(metadataName, plugin); block.removeMetadata(metadataName, plugin);
Map<String, UUID> oldRecord = ownerMapByLocation.get(block.getLocation().getWorld().getName()); Map<String, UUID> oldRecord = ownerMapByLocation.get(block.getLocation().getWorld().getName());
if (oldRecord != null) if (oldRecord != null)
oldRecord.remove(block.getLocation().getBlockX() + ":" + block.getLocation().getBlockY() + ":" + block.getLocation().getBlockZ()); oldRecord.remove(block.getLocation().getBlockX() + ":" + block.getLocation().getBlockY() + ":" + block.getLocation().getBlockZ());
} }
return removed != null; return removed != null;
} }