1
0
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:
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) {
for (BlockOwnerShip ship : blockOwnerShipsMaterial.values()) {
BlockOwnerShip ship = blockOwnerShipsMaterial.get(CMIMaterial.get(block));
if (ship != null)
ship.remove(block);
}
}
/**

View File

@ -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;
}