Use API references
This commit is contained in:
parent
b608668cae
commit
259e806d59
|
|
@ -1,6 +1,5 @@
|
|||
package com.alttd.playershops.api;
|
||||
|
||||
import com.alttd.playershops.shop.AbstractShop;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
|
@ -18,7 +17,7 @@ public interface ShopHandler { // TODO finish docs
|
|||
* @param location Location of the shop
|
||||
* @return Shop at the given location or <b>null</b> if no shop is found there
|
||||
*/
|
||||
AbstractShop getShop(Location location);
|
||||
Shop getShop(Location location);
|
||||
|
||||
/**
|
||||
* Checks whether there is a shop at a given location
|
||||
|
|
@ -34,7 +33,7 @@ public interface ShopHandler { // TODO finish docs
|
|||
*
|
||||
* @return Read-only collection of all shops
|
||||
*/
|
||||
Collection<AbstractShop> getShops();
|
||||
Collection<Shop> getShops();
|
||||
|
||||
/**
|
||||
* Add a player's custom shop limit
|
||||
|
|
@ -66,7 +65,7 @@ public interface ShopHandler { // TODO finish docs
|
|||
* @param uuid The uuid linked to this player
|
||||
* @return List of shops this player owns
|
||||
*/
|
||||
List<AbstractShop> getShops(UUID uuid);
|
||||
List<Shop> getShops(UUID uuid);
|
||||
|
||||
ArrayList<Material> getShopMaterials();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.alttd.playershops.handler;
|
||||
|
||||
import com.alttd.playershops.PlayerShops;
|
||||
import com.alttd.playershops.api.Shop;
|
||||
import com.alttd.playershops.api.ShopHandler;
|
||||
import com.alttd.playershops.config.Config;
|
||||
import com.alttd.playershops.shop.AbstractShop;
|
||||
|
|
@ -22,7 +23,7 @@ public class ShopHandlerImpl implements ShopHandler {
|
|||
@Getter
|
||||
private final Object2IntMap<UUID> shopBuildLimits;
|
||||
@Getter
|
||||
private final Map<Location, AbstractShop> shopLocation;
|
||||
private final Map<Location, Shop> shopLocation;
|
||||
@Getter
|
||||
private final ArrayList<Material> shopMaterials;
|
||||
|
||||
|
|
@ -34,7 +35,7 @@ public class ShopHandlerImpl implements ShopHandler {
|
|||
shopMaterials = new ArrayList<>(); // TODO move into parent method where materials are loaded in.
|
||||
}
|
||||
|
||||
public AbstractShop getShop(Location location) {
|
||||
public Shop getShop(Location location) {
|
||||
Location newLocation = new Location(location.getWorld(), location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
|
||||
return shopLocation.get(newLocation);
|
||||
|
|
@ -44,7 +45,7 @@ public class ShopHandlerImpl implements ShopHandler {
|
|||
return getShop(location) != null;
|
||||
}
|
||||
|
||||
public Collection<AbstractShop> getShops() {
|
||||
public Collection<Shop> getShops() {
|
||||
return Collections.unmodifiableCollection(shopLocation.values());
|
||||
}
|
||||
|
||||
|
|
@ -67,24 +68,24 @@ public class ShopHandlerImpl implements ShopHandler {
|
|||
return shopMaterials.contains(block.getType());
|
||||
}
|
||||
|
||||
public List<AbstractShop> getShops(UUID uuid) {
|
||||
List<AbstractShop> shops = new ArrayList<>();
|
||||
for (AbstractShop shop : shopLocation.values()) {
|
||||
public List<Shop> getShops(UUID uuid) {
|
||||
List<Shop> shops = new ArrayList<>();
|
||||
for (Shop shop : shopLocation.values()) {
|
||||
if (shop.getOwnerUUID().equals(uuid))
|
||||
shops.add(shop);
|
||||
}
|
||||
return shops;
|
||||
}
|
||||
|
||||
public AbstractShop getShopBySignLocation(Location signLocation) {
|
||||
for (AbstractShop shop : shopLocation.values()) {
|
||||
public Shop getShopBySignLocation(Location signLocation) {
|
||||
for (Shop shop : shopLocation.values()) {
|
||||
if (shop.getSignLocation().equals(signLocation))
|
||||
return shop;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public AbstractShop getShopNearBlock(Block block) {
|
||||
public Shop getShopNearBlock(Block block) {
|
||||
BlockFace[] faces = {BlockFace.NORTH, BlockFace.SOUTH, BlockFace.EAST, BlockFace.WEST};
|
||||
for (BlockFace face : faces) {
|
||||
if (this.isShopMaterial(block.getRelative(face))) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.alttd.playershops.listener;
|
||||
|
||||
import com.alttd.playershops.PlayerShops;
|
||||
import com.alttd.playershops.api.Shop;
|
||||
import com.alttd.playershops.api.ShopHandler;
|
||||
import com.alttd.playershops.config.Config;
|
||||
import com.alttd.playershops.shop.AbstractShop;
|
||||
|
|
@ -59,7 +60,7 @@ public class PlayerListener extends EventListener {
|
|||
|
||||
if (!(block.getState() instanceof Sign)) return;
|
||||
|
||||
AbstractShop shop = plugin.getShopHandler().getShop(block.getLocation());
|
||||
Shop shop = plugin.getShopHandler().getShop(block.getLocation());
|
||||
if(shop == null) return;
|
||||
|
||||
if(shop.isInitialized()) event.setCancelled(true);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user