Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@NeatMonster
Created July 2, 2014 11:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save NeatMonster/e5bb10940d31e06debc9 to your computer and use it in GitHub Desktop.
Save NeatMonster/e5bb10940d31e06debc9 to your computer and use it in GitHub Desktop.
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);
}
}
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