mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-04 03:10:27 +02:00
Spaces, formatting.
This commit is contained in:
parent
7ab21d9e72
commit
25e1e392a0
|
@ -18,53 +18,60 @@ import fr.neatmonster.nocheatplus.utilities.StringUtil;
|
||||||
|
|
||||||
public class ExemptCommand extends BaseCommand {
|
public class ExemptCommand extends BaseCommand {
|
||||||
|
|
||||||
public ExemptCommand(JavaPlugin plugin) {
|
public ExemptCommand(JavaPlugin plugin) {
|
||||||
super(plugin, "exempt", Permissions.COMMAND_EXEMPT);
|
super(plugin, "exempt", Permissions.COMMAND_EXEMPT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command,
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
String label, String[] args) {
|
// TODO: Reduce copy and paste by introducing some super class.
|
||||||
// TODO: Reduce copy and paste by introducing some super class.
|
if (args.length < 2 || args.length > 3) {
|
||||||
if (args.length < 2 || args.length > 3) return false;
|
return false;
|
||||||
String playerName = args[1];
|
}
|
||||||
final CheckType checkType;
|
String playerName = args[1];
|
||||||
if (args.length == 3){
|
final CheckType checkType;
|
||||||
try{
|
if (args.length == 3){
|
||||||
checkType = CheckType.valueOf(args[2].toUpperCase().replace('-', '_').replace('.', '_'));
|
try{
|
||||||
} catch (Exception e){
|
checkType = CheckType.valueOf(args[2].toUpperCase().replace('-', '_').replace('.', '_'));
|
||||||
sender.sendMessage(TAG + "Could not interpret: " + args[2]);
|
} catch (Exception e){
|
||||||
sender.sendMessage(TAG + "Check type should be one of: " + StringUtil.join(Arrays.asList(CheckType.values()), " | "));
|
sender.sendMessage(TAG + "Could not interpret: " + args[2]);
|
||||||
return true;
|
sender.sendMessage(TAG + "Check type should be one of: " + StringUtil.join(Arrays.asList(CheckType.values()), " | "));
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
else checkType = CheckType.ALL;
|
}
|
||||||
|
else {
|
||||||
final Player player = DataManager.getPlayer(playerName);
|
checkType = CheckType.ALL;
|
||||||
if (player == null){
|
}
|
||||||
sender.sendMessage(TAG + "Player not online: " + playerName);
|
|
||||||
return true;
|
final Player player = DataManager.getPlayer(playerName);
|
||||||
}
|
if (player == null){
|
||||||
else playerName = player.getName();
|
sender.sendMessage(TAG + "Player not online: " + playerName);
|
||||||
NCPExemptionManager.exemptPermanently(player, checkType);
|
return true;
|
||||||
sender.sendMessage(TAG + "Player " + playerName + " is now exempted from: " + checkType);
|
}
|
||||||
return true;
|
else {
|
||||||
}
|
playerName = player.getName();
|
||||||
|
}
|
||||||
@Override
|
NCPExemptionManager.exemptPermanently(player, checkType);
|
||||||
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args)
|
sender.sendMessage(TAG + "Player " + playerName + " is now exempted from: " + checkType);
|
||||||
{
|
return true;
|
||||||
// At least complete CheckType
|
}
|
||||||
if (args.length == 3) return CommandUtil.getCheckTypeTabMatches(args[2]);
|
|
||||||
return null;
|
@Override
|
||||||
}
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args)
|
||||||
|
{
|
||||||
/* (non-Javadoc)
|
// At least complete CheckType
|
||||||
* @see fr.neatmonster.nocheatplus.command.AbstractCommand#testPermission(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
if (args.length == 3) {
|
||||||
*/
|
return CommandUtil.getCheckTypeTabMatches(args[2]);
|
||||||
@Override
|
}
|
||||||
public boolean testPermission(CommandSender sender, Command command, String alias, String[] args) {
|
return null;
|
||||||
return super.testPermission(sender, command, alias, args) || args.length >= 2 && args[1].trim().equalsIgnoreCase(sender.getName()) && sender.hasPermission(permission + ".self");
|
}
|
||||||
}
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see fr.neatmonster.nocheatplus.command.AbstractCommand#testPermission(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean testPermission(CommandSender sender, Command command, String alias, String[] args) {
|
||||||
|
return super.testPermission(sender, command, alias, args) || args.length >= 2 && args[1].trim().equalsIgnoreCase(sender.getName()) && sender.hasPermission(permission + ".self");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user