Solved Schedulers?

Discussion in 'Plugin Development' started by SirMonkeyFood, Nov 11, 2015.

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

    SirMonkeyFood

    I've used schedulers before, and I'm not an extreme noob at java, but I am learning. Basically, I'm attempting to run two commands with a scheduler, (It's set to every minute so that I can ensure it's working) that will reset the server's map. I've only got one class:

    Code:
    package me.SirMonkeyFood.SMDailyReset;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.potion.PotionEffect;
    import org.bukkit.potion.PotionEffectType;
    
    public class Main extends JavaPlugin {
        public void onEnable() {
            Bukkit.getServer().getScheduler()
                    .scheduleSyncRepeatingTask(this, new Runnable() {
                        public void run() {
                            Bukkit.getServer()
                                    .dispatchCommand(
                                            Bukkit.getServer().getConsoleSender(),
                                            "kickall Arena Is Resetting! Join Back In A Minute Or Two!");
                            Bukkit.getServer().dispatchCommand(
                                    Bukkit.getServer().getConsoleSender(),
                                    "wr rebuild BuildPvp Reset");
                        }
                    }, 0, 1200);
        }
    }
    
    
    The commands are correct, but they only seem to run when the server is rebooted, not when one minute has passed. Console is pretty clean, so I'm lost. If any kind bukkit wizard could lend a hand, it'd be most appreciated ;D
     
    Last edited: Nov 11, 2015
  2. Offline

    CraftCreeper6

    @SirMonkeyFood
    You realise the timer will reset everytime you reload / restart the server?
    Not to mention that 1728000 is certainly not 1 minute.
     
  3. Offline

    SirMonkeyFood

    Yup, I waited ample time. Also, whoops ;3. I guess I must've changed it to a day. The problem is still the same though with a minute(I tested with a minute too). *Casually changes the 1728000 to 1200*
     
  4. Offline

    CraftCreeper6

    @SirMonkeyFood
    I *highly* recommend restarting the server after resetting.

    Do you not get kicked, does the map not reset?

    EDIT: Is kickall a command of your own? Or?
     
  5. Offline

    SirMonkeyFood

    I'll give the restart a shot. As for the kicking and reset, both work great when I reload (and thereby reset the timer), but they don't repeat.

    *EDIT* I think the kickall is either a bukkit command or essentials.
     
  6. Offline

    CraftCreeper6

    @SirMonkeyFood
    What do you mean they don't repeat? You should restart, not reload.
     
  7. Offline

    SirMonkeyFood

    I'm restarting right now, I was just referring to a few minutes ago when I reloaded. The commands don't launch every minute, as I'm trying to get them to.
     
  8. Offline

    CraftCreeper6

    @SirMonkeyFood
    -Have you thought of using a Bukkit Runnable?-

    Ignore that, I'm trying to think of alternatives now. Let me run it in my IDEA.

    EDIT: If you haven't fixed it by tomorrow I'll be here. I need to sleep. It's late.
     
  9. Offline

    SirMonkeyFood

    To be honest, I've only used schedulers a few times, so I'm not too familiar with BukkitRunnable. I see there's a place to read up on this website, under the BukkitRunnable section, but the links all seem broken. Is there somewhere you'd recommend reading up on it at?

    http://wiki.bukkit.org/Scheduler_Programming

    Alright, night. I'll try to find some sort of substitute in the meantime. Thanks for the help.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 12, 2015
  10. Offline

    SirMonkeyFood

    I think I'm going to just... kinda... side-step this whole thing and use the on enable method for the plugin to just reset the world whenever the server boots up, and then install a plugin that reboots the server once/day. So, I'll just mark the thread as solved. Thanks for the help @CraftCreeper6
     
Thread Status:
Not open for further replies.

Share This Page