Created
July 2, 2014 11:53
-
-
Save NeatMonster/e5bb10940d31e06debc9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package fr.neatmonster.commandlater; | |
import org.bukkit.Bukkit; | |
import org.bukkit.plugin.java.JavaPlugin; | |
import org.bukkit.scheduler.BukkitRunnable; | |
public class CommandLater extends JavaPlugin { | |
public static class CommandRunnable extends BukkitRunnable { | |
private final String command; | |
public CommandRunnable(final String command) { | |
this.command = command; | |
} | |
@Override | |
public void run() { | |
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command); | |
} | |
} | |
@Override | |
public void onEnable() { | |
for (final String path : getConfig().getKeys(false)) | |
try { | |
final long time = Long.valueOf(path); | |
if (getConfig().isString(path) && System.currentTimeMillis() < time) | |
new CommandRunnable(getConfig().getString(path)).runTaskLater(this, | |
(time - System.currentTimeMillis()) / 50L); | |
} catch (final NumberFormatException e) {} | |
} | |
@Override | |
public void onDisable() { | |
getServer().getScheduler().cancelTasks(this); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CommandLater | |
version: 1.0 | |
author: NeatMonster | |
main: fr.neatmonster.commandlater.CommandLater |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment