1.8.8 Update item stack because of player count

Discussion in 'Spigot Plugin Development' started by letzYassineTvYT, Mar 31, 2020.

  1. Hello, my pproblem is that i want to update the player count on. first i the playercount as the amount but the problem is that the item is only updateing when i restart the server
    and my questin is how do i update the player count every 2 seconds?
    Teleportlistener : https://hastebin.com/bubonucuyu.java
    im doing the Player count with the Reformcloud-API and it also has a methode if the players count changes but i dont understand it and i only want that the item updates every 2 seconds
    Thx for all answers
     
  2. i did a Repeatingtask but the Itemstack wont update :(
    ```
    public void invopen(PlayerInventory e) {
    Bukkit.getScheduler().scheduleSyncRepeatingTask((Plugin) this, new Runnable() {
    @Override
    public void run() {
    for (Player p : Bukkit.getOnlinePlayers()) {
    p.updateInventory();
    }
    }
    },80,80);
    }
    ```
     
  3. Why are you casting "Plugin" to the class you're passing into the method? You should be passing an instance of your main class, no casting required. Also, your method is currently delayed by 4 seconds (20 ticks per second * 4 = 80) and runs every 4 seconds.
     
  4. Can you send me a Code i dont understand it im new
     
  5. If i dont cast the plugin than i have an Error
     
  6. public void invopen(PlayerInventory e) {
    Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.getInstance(), new Runnable() {
    @Override
    public void run() {
    for (Player p : Bukkit.getOnlinePlayers()) {
    p.updateInventory();
    }
    }
    },40,40);
    this?
     
  7. I could answer your question, however you have to understand the purpose of something:
    The users on this forum aren't here to provide you code and do it for you. That's your job.

    Try your change yourself, don't ask us if it works.
    As far as the error goes, google / search for it - see if there is a solution already online.
     
  8. Its not working, the itemstack wont update :ccc