Search in sources :

Example 1 with AccessUser

use of com.builtbroken.mc.lib.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.lib.access.AccessUser)

Example 2 with AccessUser

use of com.builtbroken.mc.lib.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.lib.access.AccessUser)

Example 3 with AccessUser

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

the class RegionController method onPlayerInteract.

@SubscribeEvent
public void onPlayerInteract(PlayerInteractEvent event) {
    if (!event.world.isRemote && event.world.provider.dimensionId == dim) {
        EntityPlayer player = event.entityPlayer;
        List<Region> regionList = getRegionsAtLocation(new Pos(event.x, event.y, event.z));
        if (regionList != null && regionList.size() > 0) {
            for (Region region : regionList) {
                AccessUser user = region.getAccessProfile().getUserAccess(player);
                if (event.action == PlayerInteractEvent.Action.LEFT_CLICK_BLOCK) {
                    if (!user.hasNode(RegionManager.leftClick.toString())) {
                        event.setCanceled(true);
                        player.addChatComponentMessage(new ChatComponentText("You do not have the permission to do that here!"));
                    }
                } else if (event.action == PlayerInteractEvent.Action.RIGHT_CLICK_BLOCK) {
                    if (!user.hasNode(RegionManager.rightClick.toString())) {
                        event.setCanceled(true);
                        player.addChatComponentMessage(new ChatComponentText("You do not have the permission to do that here!"));
                    }
                }
            }
        }
    }
}
Also used : Pos(com.builtbroken.mc.lib.transform.vector.Pos) EntityPlayer(net.minecraft.entity.player.EntityPlayer) ChatComponentText(net.minecraft.util.ChatComponentText) AccessUser(com.builtbroken.mc.lib.access.AccessUser) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent)

Example 4 with AccessUser

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

Aggregations

AccessUser (com.builtbroken.mc.lib.access.AccessUser)4 ChatComponentText (net.minecraft.util.ChatComponentText)3 EntityPlayer (net.minecraft.entity.player.EntityPlayer)2 UserSubCommand (com.builtbroken.mc.core.commands.ext.UserSubCommand)1 Pos (com.builtbroken.mc.lib.transform.vector.Pos)1 AbstractCommand (com.builtbroken.mc.prefab.commands.AbstractCommand)1 SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1