Using time from config

Discussion in 'Plugin Development' started by Sneling, May 17, 2014.

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

    Sneling

    Hello,
    Soon i made a plugin wich includes a "Speed Between Messages" Value...
    So, in the config, per basic i put 100(for 100 ticks) but the thing is , there is almost no delay between the time I chat and the moment i can chat again...
    Code:java
    1. plugin.isWaitingForChat.add(p.getName());
    2. Bukkit.getServer().getScheduler().scheduleAsyncDelayedTask(plugin, new Runnable() {
    3. public void run() {
    4. p.sendMessage("l");
    5. plugin.isWaitingForChat.remove(p.getName());
    6. }
    7. }, plugin.getConfig().getInt("chat.speed-between-messages"));
    8. }


    Config:

    Code:
    chat:
     
    # Speed O Chat : the time between to messages. If you want there is a permission to bypass that : "adminutilities.bypass.speedchat"
    # Time is in Ticks!
    # Default : 0
     
    speed-between-messages: 100L
    Please help me out... i cannot figure from wheres it comes :(
     
  2. You need scheduleSyncRepeatingTask instead of scheduleAsyncDelayedTask
    And you need to add something to the end
    Code:java
    1.  
    2. Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
    3. public void run() {
    4. p.sendMessage("l");
    5. plugin.isWaitingForChat.remove(p.getName());
    6. }
    7. }, 0, plugin.getConfig().getInt("chat.speed-between-messages"));
    8.  
     
  3. Offline

    Sneling

    Bram0101 I'll test it, put answer in EDIT

    Bram0101 Ok... it is sending "l" instantly.. still. It is very strange....

    But still, thanks for helping me at this point ;)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  4. scheduleAsyncDelayedTask means that all the code in it or after it will be delayed for a certain time. scheduleSyncRepeatingTask means that it will repeat all the code inside with a certain delay.
     
  5. Offline

    Sneling

    Bram0101 yes... and i want to get the players moved out of list after a certain time... so it's why i need the DelayedTask:
    Code:
    Code:
    Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
                public void run() {
                    plugin.isWaitingForChat.remove(p.getName());
                    p.sendMessage("lol");
                }
            }, plugin.getConfig().getLong("chat.time-between-messages"));
    The "lol" is just to see the delayed time... and it's still not working thougth.. maybe the plugin.getConfig().getLong... etc is not working so well?

    EDIT : yep, after checking it's the getConfig() thing that is not working.. weird.
     
  6. If it works now, it's smart to set the thread to solved.
     
  7. Offline

    Sneling

    Bram0101 Nope, it's not working. The issue from the begin is that the getConfig()... etc, is not working. And i can't figure out from wheres it comes --"
     
  8. Maybe it's good to watch some tutorials
     
  9. Offline

    Sneling

    @Bram0101Yep, i'll do so. I'll let the thread as unsolved, if i found the solution, i'll do a new post w/ answer.

    But still, if anybody have a fix to this.. please help :)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  10. Offline

    TGRHavoc

    Sneling
    Try removing the "L" from the config...
     
  11. Offline

    Sneling

    TGRHavoc it's really strange... still not working.
     
  12. Offline

    Azubuso

    Sneling Try debugging to see if it's even reading that long from your config
     
Thread Status:
Not open for further replies.

Share This Page