add getShopBySignLocation(Location signLocation) to api
This commit is contained in:
@@ -1,6 +1,15 @@
|
||||
package com.alttd.playershops.listener;
|
||||
|
||||
import com.alttd.playershops.PlayerShops;
|
||||
import com.alttd.playershops.api.Shop;
|
||||
import com.alttd.playershops.config.Config;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Tag;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
public class ShopListener extends EventListener {
|
||||
|
||||
@@ -10,4 +19,26 @@ public class ShopListener extends EventListener {
|
||||
this.plugin = plugin;
|
||||
this.register(this.plugin);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onEntityExplosion(EntityExplodeEvent event) {
|
||||
if(!this.isRegistered) return;
|
||||
|
||||
Iterator<Block> blockIterator = event.blockList().iterator();
|
||||
Shop shop = null;
|
||||
while (blockIterator.hasNext()) {
|
||||
|
||||
Block block = blockIterator.next();
|
||||
Location location = block.getLocation();
|
||||
if (Tag.WALL_SIGNS.isTagged(block.getType())) {
|
||||
shop = plugin.getShopHandler().getShopBySignLocation(location);
|
||||
} else if (plugin.getShopHandler().isShopMaterial(block)) {
|
||||
shop = plugin.getShopHandler().getShop(location);
|
||||
}
|
||||
|
||||
if (shop != null) {
|
||||
blockIterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user