Refactor/rework
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user