helped gui refresh

Discussion in 'Plugin Development' started by haderss, Nov 21, 2017.

Thread Status:
Not open for further replies.
  1. Offline

    haderss

    Attempt to refresh the inventory created by the plug-in.
    I'm trying to refresh every second.
    Every second, I open the inventory using Repu, and I don't get any inventory, and I can't do anything because the server is closed and I can't do anything.
    Code:
    public void openShop(Player player, StockMData shop)
        {
            PDate = new Date();
            Gui gui = new Gui(this, shop);
            gui.setPlayer(player);
            if(getData().isTransaction()){
                while (true) {
                    player.openInventory(gui.getInventory());
                    if(player.getInventory() == null){
                        break;
                    }
                }
            }
        }
     
  2. Offline

    timtower Administrator Administrator Moderator

    @haderss Don't use that while true loop, it will crash your server.
    Use a BukkitRunnable instead.
     
  3. Offline

    haderss

    Then, can I just put the method that opens the inventory in the ‘ run ’ function?
     
  4. Offline

    timtower Administrator Administrator Moderator

    @haderss Yes
    And getInventory() will never be null.
     
  5. Offline

    haderss

    @timtower
    How do I end my inventory if it is not null?
     
  6. Offline

    timtower Administrator Administrator Moderator

    @haderss Why would you need a timer for it anyways?
    Just open it.
     
  7. Offline

    haderss

    @timtower
    Using the timer to vary the price of the store.
     
  8. Offline

    timtower Administrator Administrator Moderator

    @haderss Then you go through the players that gave it open and update it.
     
  9. Offline

    Blares

    Shouldn't you just update every click they do?
    Instead of GUI use this: Inventory I = Bukkit. createInventory (null, (size), "title"); to open this inventory p.openInventory(I);
    Code:
    to update inventory
    @EventHandler
    public void onClick(InventoryClickEvent e) {
    
         
         Player p = (Player) e.getWhoClicked();
    
         if (p.getInventory().getTitle().equalsIgnoreCase("title of inventory") {
         p.updateInventory();
    } 
    
    
    
         }
    }
     
Thread Status:
Not open for further replies.

Share This Page