mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-07 08:02:13 +01:00
Added /version and /reload commands
By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
parent
f0ab429e01
commit
396f22f816
@ -88,4 +88,9 @@ public interface Server {
|
|||||||
* @param time The time to set the in-game time to (in hours*1000)
|
* @param time The time to set the in-game time to (in hours*1000)
|
||||||
*/
|
*/
|
||||||
public void setTime(long time);
|
public void setTime(long time);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reloads the server, refreshing settings and plugin information
|
||||||
|
*/
|
||||||
|
public void reload();
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,39 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public final class SimpleCommandMap implements CommandMap {
|
public final class SimpleCommandMap implements CommandMap {
|
||||||
private final Map<String, Command> knownCommands = new HashMap<String, Command>();
|
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.
|
* Registers multiple commands. Returns name of first command for which fallback had to be used if any.
|
||||||
* @param plugin
|
* @param plugin
|
||||||
|
Loading…
Reference in New Issue
Block a user