mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-14 19:41:21 +01:00
Add command "/nocheat permlist" to display the effective permissions
of a certain player.
This commit is contained in:
parent
6f56ae77a8
commit
3895ff029f
11
plugin.yml
11
plugin.yml
@ -3,7 +3,14 @@ name: NoCheat
|
||||
author: Evenprime
|
||||
|
||||
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
||||
version: 2.07a
|
||||
version: 2.08
|
||||
|
||||
commands:
|
||||
nocheat:
|
||||
description: NoCheat command(s)
|
||||
permission: nocheat.admin.permlist
|
||||
usage: |
|
||||
/<command> permlist player [permission] to list the NoCheat relevant permissions of the player, optionally only those starting with [permission]
|
||||
|
||||
permissions:
|
||||
nocheat:
|
||||
@ -14,6 +21,8 @@ permissions:
|
||||
children:
|
||||
nocheat.admin.chatlog:
|
||||
description: Show log messages in the players chat
|
||||
nocheat.admin.permlist:
|
||||
description: allow use of the "nocheat permlist" command
|
||||
nocheat.checks:
|
||||
description: Allow the player to bypass all checks
|
||||
children:
|
||||
|
@ -1,9 +1,15 @@
|
||||
package cc.co.evenprime.bukkit.nocheat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@ -71,9 +77,8 @@ public class NoCheat extends JavaPlugin {
|
||||
// First set up logging
|
||||
this.log = new LogManager(this);
|
||||
|
||||
|
||||
log.logToConsole(LogLevel.LOW, "[NoCheat] This version is for CB #1185. It may break at any time and for any other version.");
|
||||
|
||||
|
||||
this.data = new DataManager();
|
||||
|
||||
this.action = new ActionManager(log);
|
||||
@ -186,4 +191,37 @@ public class NoCheat extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
|
||||
if(command.getName().equalsIgnoreCase("nocheat") && args.length > 0) {
|
||||
if(args[0].equalsIgnoreCase("permlist") && args.length >= 2) {
|
||||
// permlist command was used CORRECTLY
|
||||
// Get the player names
|
||||
Player player = this.getServer().getPlayerExact(args[1]);
|
||||
if(player == null) {
|
||||
sender.sendMessage("Unknown player: " + args[1]);
|
||||
return true;
|
||||
} else {
|
||||
String prefix = "";
|
||||
if(args.length == 3) {
|
||||
prefix = args[2];
|
||||
}
|
||||
// Make a copy to allow sorting
|
||||
List<Permission> perms = new LinkedList<Permission>(this.getDescription().getPermissions());
|
||||
Collections.reverse(perms);
|
||||
|
||||
sender.sendMessage("Player " + player.getName() + " has the permission(s):");
|
||||
for(Permission permission : perms) {
|
||||
if(permission.getName().startsWith(prefix)) {
|
||||
sender.sendMessage(permission.getName() + ": " + player.hasPermission(permission));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,9 @@ package cc.co.evenprime.bukkit.nocheat;
|
||||
*/
|
||||
public class Permissions {
|
||||
|
||||
private final static String NOCHEAT = "nocheat";
|
||||
private final static String ADMIN = NOCHEAT + ".admin";
|
||||
private final static String CHECKS = NOCHEAT + ".checks";
|
||||
private final static String NOCHEAT = "nocheat";
|
||||
private final static String ADMIN = NOCHEAT + ".admin";
|
||||
private final static String CHECKS = NOCHEAT + ".checks";
|
||||
|
||||
public final static String MOVE = CHECKS + ".moving";
|
||||
public final static String MOVE_RUNFLY = MOVE + ".runfly";
|
||||
@ -34,7 +34,7 @@ public class Permissions {
|
||||
|
||||
public final static String CHAT = CHECKS + ".chat";
|
||||
public final static String CHAT_SPAM = CHAT + ".spam";
|
||||
|
||||
|
||||
public final static String ADMIN_CHATLOG = ADMIN + ".chatlog";
|
||||
|
||||
private Permissions() {}
|
||||
|
Loading…
Reference in New Issue
Block a user