Added /version and /reload commands

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot 2011-01-20 03:53:27 +00:00
parent f0ab429e01
commit 396f22f816
2 changed files with 32 additions and 0 deletions

View File

@ -88,4 +88,9 @@ public interface Server {
* @param time The time to set the in-game time to (in hours*1000)
*/
public void setTime(long time);
/**
* Reloads the server, refreshing settings and plugin information
*/
public void reload();
}

View File

@ -4,12 +4,39 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.Server;
import org.bukkit.entity.Player;
public final class SimpleCommandMap implements CommandMap {
private final Map<String, Command> knownCommands = new HashMap<String, Command>();
public SimpleCommandMap(final Server server) {
register("version", "bukkit", new Command("version") {
@Override
public boolean execute(Player player, String currentAlias, String[] args) {
player.sendMessage("This server is using some funky dev build of Bukkit!");
return true;
}
});
register("reload", "bukkit", new Command("reload") {
@Override
public boolean execute(Player player, String currentAlias, String[] args) {
if (player.isOp()) {
server.reload();
player.sendMessage(ChatColor.GREEN + "Reload complete.");
} else {
player.sendMessage(ChatColor.RED + "You do not have sufficient access"
+ " to reload this server.");
}
return true;
}
});
}
/**
* Registers multiple commands. Returns name of first command for which fallback had to be used if any.
* @param plugin