Search in sources :

Example 1 with UserSubCommand

use of com.builtbroken.mc.core.commands.ext.UserSubCommand 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.prefab.commands.AbstractCommand) ChatComponentText(net.minecraft.util.ChatComponentText) AccessUser(com.builtbroken.mc.lib.access.AccessUser)

Aggregations

UserSubCommand (com.builtbroken.mc.core.commands.ext.UserSubCommand)1 AccessUser (com.builtbroken.mc.lib.access.AccessUser)1 AbstractCommand (com.builtbroken.mc.prefab.commands.AbstractCommand)1 ChatComponentText (net.minecraft.util.ChatComponentText)1