diff --git a/pom.xml b/pom.xml index 4a18e8487..a44d5d864 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.maxgamer QuickShop - Reremake 1.2.0-beta7 + Reremake 1.2.0-beta8 diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java index 1e42892a9..9eeb91ca7 100644 --- a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java +++ b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java @@ -55,23 +55,6 @@ public class ShopManager { public void createShop(Shop shop) { Location loc = shop.getLocation(); ItemStack item = shop.getItem(); - Player player = Bukkit.getPlayer(shop.getOwner()); - if(player==null || !player.isOnline()) { - plugin.getLogger().info("Warning! Something wrong happed when createing shop,Canceling... (Code: Target player not online)"); - return; - } - PlayerInteractEvent e = new PlayerInteractEvent(player, Action.LEFT_CLICK_BLOCK, item, shop.getLocation().getBlock(), BlockFace.UP); - Bukkit.getPluginManager().callEvent(e); - if (e.isCancelled()) { - e.getPlayer().sendMessage(MsgUtil.getMessage("no-permission")); - return; - } - BlockBreakEvent be = new BlockBreakEvent(shop.getLocation().getBlock(),player); - Bukkit.getPluginManager().callEvent(be); - if (be.isCancelled()) { - be.getPlayer().sendMessage(MsgUtil.getMessage("no-permission")); - return; - } try { // Write it to the database String q = "INSERT INTO shops (owner, price, itemConfig, x, y, z, world, unlimited, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)"; @@ -186,6 +169,12 @@ public class ShopManager { ShopChunk shopChunk = new ShopChunk(world, x, z); HashMap inChunk = inWorld.get(shopChunk); // That chunk data hasn't been created yet - Create it! + BlockBreakEvent be = new BlockBreakEvent(shop.getLocation().getBlock(),Bukkit.getPlayer(shop.getOwner())); + Bukkit.getPluginManager().callEvent(be); + if (be.isCancelled()) { + be.getPlayer().sendMessage(MsgUtil.getMessage("no-permission")); + return; + } if (inChunk == null) { inChunk = new HashMap(1); // Put it in the world @@ -314,6 +303,12 @@ public class ShopManager { if (info.getAction() == ShopAction.CREATE) { try { // Checking the shop can be created + BlockBreakEvent be = new BlockBreakEvent(info.getLocation().getBlock(),p); + Bukkit.getPluginManager().callEvent(be); + if (be.isCancelled()) { + be.getPlayer().sendMessage(MsgUtil.getMessage("no-permission")); + return; + } if (plugin.getShopManager().getShop(info.getLocation()) != null) { p.sendMessage(MsgUtil.getMessage("shop-already-owned")); return;