How to get entity Player on BukkitRunnable class?

Discussion in 'Plugin Development' started by PlayFriik, Dec 10, 2014.

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

    PlayFriik

    I am trying to make Timer and I would like to give players some stuff every x minutes, but how I would add Player to it?

    I can't just use Player player = e.getPlayer(); methods..
     
  2. Offline

    Skionz

    @PlayFriik Why would you be able to use 'e.getPlayer()?' You have to store the Player somehow. You could use Maps/Lists or iterate through all the online players. There are plenty of ways to do it.
     
    AdamQpzm likes this.
  3. Offline

    PlayFriik

    That was just an example what I can not do.
     
  4. Offline

    Skionz

    @PlayFriik What exactly is the runnable for? I can't really help you without much more information.
     
  5. Offline

    leon3001

    @PlayFriik Thank God (or James Gosling) there are constructors. *hint hint*
     
  6. Offline

    PlayFriik

    Basically it gives a player 1 diamond in every 15 minutes..
     
  7. Offline

    Skionz

    @PlayFriik When the player logins add them to a Map with the current time. Create a scheduler that goes off every minute which iterated through this Map and check if the current time is 15 minutes or more then the time saved in the Map. If they pass then give them the diamond and update the time that is saved in the Map. When they leave the server make sure to remove them from the Map.
     
    leon3001 likes this.
  8. Offline

    teej107

    You could, loop through the online players every 15 minutes.

    EDIT: Or make your own subclass of BukkitRunnable that stores the Player.
     
Thread Status:
Not open for further replies.

Share This Page