VulnerabilityPatcher/src/main/java/me/cooljwb/vulnerabilitypatcher/commands/CommandVulnerabilityPatcher.java
2019-01-20 01:33:46 +01:00

73 lines
2.7 KiB
Java

package me.cooljwb.vulnerabilitypatcher.commands;
import me.cooljwb.vulnerabilitypatcher.SMG;
import me.cooljwb.vulnerabilitypatcher.VulnerabilityPatcher;
import me.cooljwb.vulnerabilitypatcher.patches.Patches;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
/*
* Copyright 2019 CoolJWB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @author CoolJWB
*/
public class CommandVulnerabilityPatcher extends Patches implements CommandExecutor {
public static String vulnerabilitypatcher = "vulnerabilitypatcher";
private VulnerabilityPatcher main;
public CommandVulnerabilityPatcher(VulnerabilityPatcher main) {
this.main = main;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(cmd.getName().equalsIgnoreCase(vulnerabilitypatcher)) {
if(args.length == 0 || args[0].equalsIgnoreCase("help")) {
if(sender.hasPermission(main.getConfig().getString("Commands.Help.Permission")))
msg(sender, SMG.VULNERABILITYPATCHER_HELP.msg);
else
msg(sender, SMG.NO_PERMISSION.msg);
}
else if(args[0].equalsIgnoreCase("version")) {
if(sender.hasPermission(main.getConfig().getString("Commands.Version.Permission")))
msg(sender, SMG.VULNERABILITYPATCHER.msg + ChatColor.GRAY + String.format("Server is running " + ChatColor.GREEN + main.getName() + "-" + main.getDescription().getVersion()));
else
msg(sender, SMG.NO_PERMISSION.msg);
}
else if(args[0].equalsIgnoreCase("reload") || args[0].equalsIgnoreCase("rl")) {
if(sender.hasPermission(main.getConfig().getString("Commands.Reload.Permission"))) {
main.reloadPlugin();
msg(sender, SMG.VULNERABILITYPATCHER.msg + ChatColor.GREEN + "Reloaded the config.");
}
else
msg(sender, SMG.NO_PERMISSION.msg);
}
else
msg(sender, SMG.UNKNOWN_ARGUMENT.msg);
}
return true;
}
}