@@ -55,23 +55,6 @@ public HashMap<UUID, Info> getActions() {
5555 public void createShop (Shop shop ) {
5656 Location loc = shop .getLocation ();
5757 ItemStack item = shop .getItem ();
58- Player player = Bukkit .getPlayer (shop .getOwner ());
59- if (player ==null || !player .isOnline ()) {
60- plugin .getLogger ().info ("Warning! Something wrong happed when createing shop,Canceling... (Code: Target player not online)" );
61- return ;
62- }
63- PlayerInteractEvent e = new PlayerInteractEvent (player , Action .LEFT_CLICK_BLOCK , item , shop .getLocation ().getBlock (), BlockFace .UP );
64- Bukkit .getPluginManager ().callEvent (e );
65- if (e .isCancelled ()) {
66- e .getPlayer ().sendMessage (MsgUtil .getMessage ("no-permission" ));
67- return ;
68- }
69- BlockBreakEvent be = new BlockBreakEvent (shop .getLocation ().getBlock (),player );
70- Bukkit .getPluginManager ().callEvent (be );
71- if (be .isCancelled ()) {
72- be .getPlayer ().sendMessage (MsgUtil .getMessage ("no-permission" ));
73- return ;
74- }
7558 try {
7659 // Write it to the database
7760 String q = "INSERT INTO shops (owner, price, itemConfig, x, y, z, world, unlimited, type) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)" ;
@@ -186,6 +169,12 @@ private void addShop(String world, Shop shop) {
186169 ShopChunk shopChunk = new ShopChunk (world , x , z );
187170 HashMap <Location , Shop > inChunk = inWorld .get (shopChunk );
188171 // That chunk data hasn't been created yet - Create it!
172+ BlockBreakEvent be = new BlockBreakEvent (shop .getLocation ().getBlock (),Bukkit .getPlayer (shop .getOwner ()));
173+ Bukkit .getPluginManager ().callEvent (be );
174+ if (be .isCancelled ()) {
175+ be .getPlayer ().sendMessage (MsgUtil .getMessage ("no-permission" ));
176+ return ;
177+ }
189178 if (inChunk == null ) {
190179 inChunk = new HashMap <Location , Shop >(1 );
191180 // Put it in the world
@@ -314,6 +303,12 @@ public void run() {
314303 if (info .getAction () == ShopAction .CREATE ) {
315304 try {
316305 // Checking the shop can be created
306+ BlockBreakEvent be = new BlockBreakEvent (info .getLocation ().getBlock (),p );
307+ Bukkit .getPluginManager ().callEvent (be );
308+ if (be .isCancelled ()) {
309+ be .getPlayer ().sendMessage (MsgUtil .getMessage ("no-permission" ));
310+ return ;
311+ }
317312 if (plugin .getShopManager ().getShop (info .getLocation ()) != null ) {
318313 p .sendMessage (MsgUtil .getMessage ("shop-already-owned" ));
319314 return ;
0 commit comments