Search in sources :

Example 1 with AccessGroup

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

the class CommandRemoveGroup method handleConsoleCommand.

@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
    if (args.length > 0) {
        String name = args[0];
        if (GroupProfileHandler.GLOBAL.getAccessProfile().getGroup(name) != null) {
            AccessGroup group = new AccessGroup(name);
            if (GroupProfileHandler.GLOBAL.getAccessProfile().removeGroup(group) != null) {
                if (group.getExtendGroup() != null) {
                    int i = 0;
                    for (AccessGroup g : GroupProfileHandler.GLOBAL.getAccessProfile().getGroups()) {
                        if (g.getExtendGroup().getName().equalsIgnoreCase(group.getName())) {
                            i++;
                            g.setToExtend(group.getExtendGroup());
                        }
                    }
                    sender.addChatMessage(new ChatComponentText(i + " groups updated"));
                }
                sender.addChatMessage(new ChatComponentText("Group \'" + name + "\' removed"));
            } else {
                sender.addChatMessage(new ChatComponentText("Error removing group"));
            }
        } else {
            sender.addChatMessage(new ChatComponentText("Group \'" + name + "\' not found"));
        }
    } else {
        sender.addChatMessage(new ChatComponentText("Missing group name"));
    }
    return true;
}
Also used : AccessGroup(com.builtbroken.mc.framework.access.AccessGroup) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 2 with AccessGroup

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

the class GroupProfileHandler method generateNew.

public void generateNew() {
    profile = new AccessProfile();
    //Create owner group - Power to do everything, AKA /OP
    AccessGroup owner_group = new AccessGroup("Owner");
    owner_group.addNode(PermissionsRegistry.ALL);
    //Create admin group - Power to Ban, Make Regions, and adjust settings
    AccessGroup admin_group = new AccessGroup("Admin");
    admin_group.addNode("root.minecraft.difficulty");
    admin_group.addNode("root.minecraft.setworldspawn");
    admin_group.addNode("root.minecraft.give");
    admin_group.addNode("root.minecraft.gamemode");
    admin_group.addNode("root.minecraft.summon");
    admin_group.addNode("root.minecraft.spawnpoint");
    //Create mod group - Power to kick, temp-ban, and silence users
    AccessGroup mod_group = new AccessGroup("Moderator");
    mod_group.addNode("root.minecraft.whitelist");
    mod_group.addNode("root.minecraft.ban-ip");
    mod_group.addNode("root.minecraft.pardon-ip");
    mod_group.addNode("root.minecraft.time");
    mod_group.addNode("root.minecraft.save-all");
    mod_group.addNode("root.minecraft.pardon");
    mod_group.addNode("root.minecraft.ban");
    mod_group.addNode("root.minecraft.weather");
    mod_group.addNode("root.minecraft.toggledownfall");
    mod_group.addNode("root.minecraft.tp");
    //Create dev group - sub version of user just for show
    AccessGroup dev_group = new AccessGroup("Dev");
    dev_group.addNode("root.minecraft.debug");
    //Create media group - sub version of user just for show
    AccessGroup media_group = new AccessGroup("Media");
    media_group.addNode("root.minecraft.seed");
    //Create user group - default group
    AccessGroup user_group = new AccessGroup("User");
    user_group.addNode("root.minecraft.help");
    user_group.addNode("root.minecraft.me");
    user_group.addNode("root.minecraft.tell");
    //Extend groups
    owner_group.setToExtend(admin_group);
    admin_group.setToExtend(mod_group);
    mod_group.setToExtend(user_group);
    dev_group.setToExtend(user_group);
    media_group.setToExtend(user_group);
    //Add groups to profile
    profile.addGroup(owner_group);
    profile.addGroup(admin_group);
    profile.addGroup(mod_group);
    profile.addGroup(dev_group);
    profile.addGroup(user_group);
}
Also used : AccessGroup(com.builtbroken.mc.framework.access.AccessGroup) AccessProfile(com.builtbroken.mc.framework.access.AccessProfile)

Example 3 with AccessGroup

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

the class CommandGroups method handleConsoleCommand.

@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
    if (args[0].equalsIgnoreCase("list")) {
        sender.addChatMessage(new ChatComponentText("==== Groups ===="));
        for (AccessGroup group : GroupProfileHandler.GLOBAL.getAccessProfile().getGroups()) {
            sender.addChatMessage(new ChatComponentText("  Group[" + group.getName() + (group.getExtendGroupName() != null ? " extends " + group.getExtendGroupName() : "") + "]  Members: " + group.getMembers().size()));
        }
        sender.addChatMessage(new ChatComponentText("================"));
    }
    return true;
}
Also used : AccessGroup(com.builtbroken.mc.framework.access.AccessGroup) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 4 with AccessGroup

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

the class CommandNewGroup method handleConsoleCommand.

@Override
public boolean handleConsoleCommand(ICommandSender sender, String[] args) {
    if (args.length > 0) {
        String name = args[0];
        if (GroupProfileHandler.GLOBAL.getAccessProfile().getGroup(name) == null) {
            AccessGroup toExtend = null;
            if (args.length > 1 && args[1].equalsIgnoreCase("extend")) {
                if (args.length > 2) {
                    String extendName = args[2];
                    toExtend = GroupProfileHandler.GLOBAL.getAccessProfile().getGroup(extendName);
                }
                if (toExtend == null) {
                    sender.addChatMessage(new ChatComponentText("Error: Unknown group to extend"));
                    return true;
                }
            }
            AccessGroup group = new AccessGroup(name);
            if (toExtend != null) {
                group.setToExtend(toExtend);
            }
            if (GroupProfileHandler.GLOBAL.getAccessProfile().addGroup(group)) {
                sender.addChatMessage(new ChatComponentText("Group added"));
            } else {
                sender.addChatMessage(new ChatComponentText("Error adding group"));
            }
        } else {
            sender.addChatMessage(new ChatComponentText("A Group by that name already exists"));
        }
    } else {
        sender.addChatMessage(new ChatComponentText("Missing group name"));
    }
    return true;
}
Also used : AccessGroup(com.builtbroken.mc.framework.access.AccessGroup) ChatComponentText(net.minecraft.util.ChatComponentText)

Example 5 with AccessGroup

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

the class CommandGroup method handleConsoleCommand.

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

Aggregations

AccessGroup (com.builtbroken.mc.framework.access.AccessGroup)5 ChatComponentText (net.minecraft.util.ChatComponentText)4 GroupSubCommand (com.builtbroken.mc.core.commands.ext.GroupSubCommand)1 AbstractCommand (com.builtbroken.mc.core.commands.prefab.AbstractCommand)1 AccessProfile (com.builtbroken.mc.framework.access.AccessProfile)1