I just have a quick question. I currently have a custom shop GUI setup, it is working perfectly fine except for one small issue, when a player is dragging an item across the GUI and clicks to place it while still moving their mouse, it places the item in the GUI when the event should be cancelling it. I have been able to cancel every other way I have found to put/glitch items into the GUI, but I cannot find a solution for this issue. If what I said doesn't make sense, I might try and add a clip to show you guys. If what I said makes sense and you have ideas I'd be glad to hear them
Code (Text): @EventHandler public void shopCheck(InventoryClickEvent e) { Player p = (Player) e.getWhoClicked(); if (p.getOpenInventory().getTopInventory() == null) return; String shopName = p.getOpenInventory().getTopInventory().getTitle().toLowerCase(); if (!ShopAccessor.serverShops.containsKey(ChatColor.stripColor(shopName))) return; if (e.getClick().isShiftClick()) { e.setCancelled(true); return; } if (e.getClickedInventory() != p.getOpenInventory().getTopInventory()) return; e.setCancelled(true); ItemStack clickedItem = e.getCurrentItem(); if (clickedItem == null || clickedItem.getType() == Material.AIR) return; ServerShop shop = ShopAccessor.serverShops.get(ChatColor.stripColor(e.getClickedInventory().getName().toLowerCase())); shop.openCheckout(p, clickedItem); }
I will try out the dragEvent when I get home. I'm going to wait to mark it as solved until I know for sure or in case someone else has a different idea. Thanks though
Does anyone know how other (even premium) GUI plugins resolve this issue, or do they use InventoryDragEvent?
I've used the event before in GUIs and it is the intended way to stop someone from dragging an item to place it. I'm doubtful there even is another way to do it o.o
Well seeing as this was a first version of my plugin, and now that I have swapped over to IntelliJ. I am just remaking everything far more efficient and neat that I did before because I know what I want to do. So maybe, just maybe, when I finish recreating the plugin in a couple days here the event will work properly. If not you'll probably see me back here asking more questions.