KaiKikuchi / QuickShop

A shop plugin for Bukkit
47 stars 41 forks source link

Suggestion Auto signs update on refill chest :D #18

Closed FlashLight34 closed 8 years ago

FlashLight34 commented 8 years ago

i add this in my proprer version of your quickshop notlikeme :P

in playerlistener that detect when user refill there chest and update the quantity on the sign:

//Verifier le coffre et mettre a jour la panneau automatiquement
    @EventHandler(priority = EventPriority.NORMAL)
    public void fermeCoffreEvent(InventoryCloseEvent e){
        //plugin.getLogger().info("Teste listener: "+e.getInventory().getName());
        if(e.getInventory().getName().equalsIgnoreCase("container.chestDouble") || e.getInventory().getName().equalsIgnoreCase("container.chest")){     
            InventoryHolder holder = e.getInventory().getHolder();
            if (holder instanceof DoubleChest){
                DoubleChest chestD = (DoubleChest) holder;
                Location locD = chestD.getLocation();
                Shop shop = plugin.getShopManager().getShop(locD);
                if (shop != null) {
                    shop.setSignText();
                    return;
                }
                Block Otherchest = Util.getSecondHalf(locD.getBlock());
                if (Otherchest != null) {
                    Location oc = Otherchest.getLocation();
                    shop = plugin.getShopManager().getShop(oc);
                    if (shop != null) {
                        shop.setSignText();
                    }
                }
            }
            else if (holder instanceof Chest) {
                Chest chest = (Chest) holder;
                Location loc = chest.getLocation();
                Shop shop = plugin.getShopManager().getShop(loc);
                if (shop != null) {
                    shop.setSignText();
                }

            }
        }
    }   

its a good suggestion maybe ;)