Search in sources :

Example 1 with AccessUser

use of com.builtbroken.mc.framework.access.AccessUser in project Engine by VoltzEngine-Project.

the class GSCList method handle.

@Override
public boolean handle(ICommandSender sender, AccessGroup group, String user, String[] args) {
    //TODO add page support, so we don't spam the console
    if (args != null && args.length >= 0) {
        if (args[0].equalsIgnoreCase("perms")) {
            if (group.getNodes() != null && group.getNodes().size() > 0) {
                sender.addChatMessage(new ChatComponentText("==== Permission Nodes ====="));
                for (String node : group.getNodes()) {
                    sender.addChatMessage(new ChatComponentText(node));
                }
                sender.addChatMessage(new ChatComponentText(""));
            } else {
                sender.addChatMessage(new ChatComponentText("No perms to list"));
            }
            return true;
        } else if (args[0].equalsIgnoreCase("users") || args[0].equalsIgnoreCase("members")) {
            if (group.getMembers() != null && group.getMembers().size() > 0) {
                sender.addChatMessage(new ChatComponentText("===== Members ====="));
                for (AccessUser u : group.getMembers()) {
                    sender.addChatMessage(new ChatComponentText(u.getName()));
                }
                sender.addChatMessage(new ChatComponentText(""));
            } else {
                sender.addChatMessage(new ChatComponentText("Group contains no members"));
            }
            return true;
        }
    }
    sender.addChatMessage(new ChatComponentText("Not sure what you want listed"));
    return true;
}
Also used : ChatComponentText(net.minecraft.util.ChatComponentText) AccessUser(com.builtbroken.mc.framework.access.AccessUser)

Example 2 with AccessUser

use of com.builtbroken.mc.framework.access.AccessUser in project Engine by VoltzEngine-Project.

the class GroupProfileHandler method canExecuteCommand.

public boolean canExecuteCommand(ICommandSender sender, ICommand command, String[] args) {
    if (sender instanceof EntityPlayer) {
        AccessUser user = getAccessProfile().getUserAccess((EntityPlayer) sender);
        String node = PermissionsRegistry.getNodeFor(command, args);
        return user.hasNode(node);
    }
    return command.canCommandSenderUseCommand(sender);
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) AccessUser(com.builtbroken.mc.framework.access.AccessUser)

Example 3 with AccessUser

use of com.builtbroken.mc.framework.access.AccessUser in project Engine by VoltzEngine-Project.

the class CommandUser method handleConsoleCommand.

@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
    if (isHelpCommand(args)) {
        handleHelp(sender, args);
    } else {
        String name = args[0];
        AccessUser user = GroupProfileHandler.GLOBAL.getAccessProfile().getUserAccess(name);
        if (user != null && user.getGroup() != null) {
            if (args.length > 1) {
                for (AbstractCommand command : subCommands) {
                    if (command instanceof UserSubCommand && command.getCommandName().equalsIgnoreCase(args[1])) {
                        if (((UserSubCommand) command).handle(sender, user, removeFront(args, 2))) {
                            return true;
                        }
                    }
                }
            }
            sender.addChatMessage(new ChatComponentText("Unknown user sub command"));
        } else {
            sender.addChatMessage(new ChatComponentText("User not found in permissions profile"));
        }
    }
    return true;
}
Also used : UserSubCommand(com.builtbroken.mc.core.commands.ext.UserSubCommand) AbstractCommand(com.builtbroken.mc.core.commands.prefab.AbstractCommand) ChatComponentText(net.minecraft.util.ChatComponentText) AccessUser(com.builtbroken.mc.framework.access.AccessUser)

Aggregations

AccessUser (com.builtbroken.mc.framework.access.AccessUser)3 ChatComponentText (net.minecraft.util.ChatComponentText)2 UserSubCommand (com.builtbroken.mc.core.commands.ext.UserSubCommand)1 AbstractCommand (com.builtbroken.mc.core.commands.prefab.AbstractCommand)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1