QoL/src/main/java/xyz/etztech/qol/commands/MainCommand.java

67 lines
2.1 KiB
Java

package xyz.etztech.qol.commands;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import xyz.etztech.qol.QoL;
import xyz.etztech.qol.EtzTechUtil;
import xyz.etztech.qol.Lang;
public class MainCommand implements CommandExecutor {
QoL plugin;
public MainCommand(QoL paramQoL)
{
this.plugin = paramQoL;
}
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
if (!commandSender.hasPermission("qol.admin")) {
EtzTechUtil.sms(commandSender, Lang.NO_PERMISSION.getDef());
return true;
}
if (args.length == 0) {
help(commandSender);
} else {
switch (args[0]) {
case "help":
help(commandSender);
break;
case "reload":
reload(commandSender);
break;
default:
EtzTechUtil.sms(commandSender, ChatColor.RED + "Command not recognized.");
break;
}
}
return true;
}
private void help(CommandSender commandSender) {
FileConfiguration config = this.plugin.getConfig();
String version = Bukkit.getPluginManager().getPlugin("QoL").getDescription().getVersion();
StringBuilder message = new StringBuilder(ChatColor.GOLD + "===== QoL v" + version + "=====");
message.append("\n" + ChatColor.YELLOW + "/makeme");
message.append("\n" + ChatColor.YELLOW + "/names");
message.append("\n" + ChatColor.YELLOW + "/portal");
message.append("\n" + ChatColor.YELLOW + "/sudo");
message.append("\n" + ChatColor.YELLOW + "/uuid");
EtzTechUtil.sms(commandSender, message.toString());
}
private void reload(CommandSender commandSender) {
this.plugin.reloadConfig();
EtzTechUtil.sms(commandSender, ChatColor.GREEN + "QoL reloaded.");
}
}