Refactor/rework

This commit is contained in:
Len
2022-08-22 00:21:36 +02:00
parent 658837814a
commit 3aa8414c5b
17 changed files with 885 additions and 12 deletions
@@ -22,12 +22,14 @@ public class ShopHandler {
private final Object2IntMap<UUID> shopBuildLimits;
@Getter
private final Map<Location, PlayerShop> shopLocation;
private final Map<Location, PlayerShop> shopSignLocation;
@Getter
private final ArrayList<Material> shopMaterials;
public ShopHandler(PlayerShops instance) {
plugin = instance;
shopLocation = new ConcurrentHashMap<>();
shopSignLocation = new ConcurrentHashMap<>();
shopBuildLimits = new Object2IntOpenHashMap<>();
shopBuildLimits.defaultReturnValue(Config.shopLimit);
shopMaterials = new ArrayList<>(); // TODO move into parent method where materials are loaded in.
@@ -58,6 +60,7 @@ public class ShopHandler {
public void removeShops() {
shopLocation.clear();
shopSignLocation.clear();
}
public boolean isShopMaterial(Block block) {
@@ -77,18 +80,22 @@ public class ShopHandler {
}
public PlayerShop getShopBySignLocation(Location signLocation) {
for (PlayerShop shop : shopLocation.values()) {
if (shop.getSignLocation().equals(signLocation))
return shop;
}
return null;
Location newLocation = new Location(signLocation.getWorld(), signLocation.getBlockX(), signLocation.getBlockY(), signLocation.getBlockZ());
return shopSignLocation.get(newLocation);
}
public void addShop(PlayerShop shop) {
shopLocation.put(shop.getShopLocation(), shop);
shopSignLocation.put(shop.getSignLocation(), shop);
}
public boolean canPlayerBreakShop(Player player, PlayerShop shop) {
public void removeShop(PlayerShop shop) {
shopLocation.remove(shop.getShopLocation());
shopSignLocation.remove(shop.getSignLocation());
}
public boolean canPlayerBreakShop(Player player, PlayerShop shop) { // TODO move to util?
if (player.getUniqueId().equals(shop.getOwnerUUID()) && player.hasPermission("playershops.shop.break"))
return true;