how to bukkitrun is stop?

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

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

    haderss

    Code:
    public void openShop(Player player, StockMData shop)
    
        {
           
            Gui gui = new Gui(this, shop, stockM);
            gui.setPlayer(player);
            if(data.isTransaction()){
                runnablesetting(player, gui);
                runnable.runTaskTimerAsynchronously(stockM, 0, 100);
            }
            else {
                player.openInventory(gui.getInventory());
            }
        }
       
        public void runnablesetting(Player player, Gui gui){
            runnable = (BukkitRunnable) new BukkitRunnable() {
               
                @Override
                public void run() {
                    System.out.println("S");
                    PDate = new Date();
                    player.openInventory(gui.getInventory());
                }
            };
        }
    Refresh the inventory every second. By the way, I want to stop this timer when I close the inventory, but what is it?
    InventoryCloseEvent used, but timer only operates twice.
     
  2. Offline

    timtower Administrator Administrator Moderator

    @haderss 1. Don't cast a BukkitRunnable to a BukkitRunnable.
    2. Do not start it async.
    3. What is happening in this code? Where do all those variables come from?
     
Thread Status:
Not open for further replies.

Share This Page