Thead.sleep

Discussion in 'Plugin Development' started by Clybzotik, Feb 11, 2019.

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

    Clybzotik

    Hi, how can I stop the code execution for a while? When using Tread.sleep, the server is "sleeping"
     
  2. Online

    timtower Ninja on the waves Moderator

    @Clybzotik Could you post the code that we are talking about?
     
  3. Offline

    Clybzotik

    I add a player name to HashMap:
    Code:
    enb.put(p.getName(), 1);
    
    And I need to remove it from there in 15 seconds:
    Code:
    enb.remove(p.getName());
    
    (I need a pause before deleting)
     
  4. Offline

    The_Spaceman

    Code:java
    1. Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), () -> {/*your code*/}, 15/*second*/*20/*ticks*/);
     
  5. Online

    timtower Ninja on the waves Moderator

    @Clybzotik new BukkitRunnable(){@Override
    public void run(){
    enb.remove(p.getName());
    }
    }).runTaskLater(plugin, time)
    Probably gonna complain about p being final though.
     
  6. Offline

    Clybzotik

    @timtower
    I try to add it, by I get this error Syntax error on token ")", delete this token in this string
    Code:
    }).runTaskLater(this, 15); 
     
  7. Online

    timtower Ninja on the waves Moderator

    @Clybzotik Then it probably is without the bracket, don't have an IDE right now.
     
Thread Status:
Not open for further replies.

Share This Page