Add more listeners and events to listen to
This commit is contained in:
@@ -12,7 +12,10 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.DoubleChest;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@@ -95,10 +98,12 @@ public class ShopHandler {
|
||||
}
|
||||
|
||||
public boolean isShopMaterial(Block block) {
|
||||
if (Tag.SHULKER_BOXES.isTagged(block.getType())) {
|
||||
return true;
|
||||
}
|
||||
return shopMaterials.contains(block.getType());
|
||||
// if (Tag.SHULKER_BOXES.isTagged(block.getType())) {
|
||||
// return true;
|
||||
// }
|
||||
// return shopMaterials.contains(block.getType());
|
||||
// TODO make a cache of this somehow?
|
||||
return block.getState() instanceof InventoryHolder inventoryHolder && !(inventoryHolder.getInventory().getHolder() instanceof DoubleChest);
|
||||
}
|
||||
|
||||
public List<PlayerShop> getShops(UUID uuid) {
|
||||
@@ -116,6 +121,19 @@ public class ShopHandler {
|
||||
return shopSignLocation.get(newLocation);
|
||||
}
|
||||
|
||||
public PlayerShop getShopsNear(Block block) {
|
||||
BlockFace[] faces = {BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST};
|
||||
for (BlockFace face : faces) {
|
||||
if (this.isShopMaterial(block.getRelative(face))) {
|
||||
Block shopChest = block.getRelative(face);
|
||||
PlayerShop shop = getShop(shopChest.getLocation());
|
||||
if (shop != null)
|
||||
return shop;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addShop(PlayerShop shop) {
|
||||
shopLocation.put(shop.getShopLocation(), shop);
|
||||
shopSignLocation.put(shop.getSignLocation(), shop);
|
||||
|
||||
Reference in New Issue
Block a user