Package net.minecraftforge.permissions

Examples of net.minecraftforge.permissions.PermissionContext


        }
    }

    private void parseGroupPrefixSuffix(String group, Zone zone, boolean isSuffix)
    {
        if (!tabCompleteMode && !PermissionsManager.checkPermission(new PermissionContext().setCommandSender(sender), PERM_GROUP_FIX))
        {
            OutputHandler.chatError(sender, FEPermissions.MSG_NO_COMMAND_PERM);
            return;
        }
        if (tabCompleteMode)
View Full Code Here


        }
    }

    private void parseGroupPermissions(String group, Zone zone, PermissionAction type)
    {
        if (!tabCompleteMode && !PermissionsManager.checkPermission(new PermissionContext().setCommandSender(sender), PERM_GROUP_PERMS))
        {
            OutputHandler.chatError(sender, FEPermissions.MSG_NO_COMMAND_PERM);
            return;
        }
        if (args.isEmpty())
View Full Code Here

        }
    }

    private void parseGroupSpawn(String group, Zone zone)
    {
        if (!tabCompleteMode && !PermissionsManager.checkPermission(new PermissionContext().setCommandSender(sender), PERM_GROUP_SPAWN))
        {
            OutputHandler.chatError(sender, FEPermissions.MSG_NO_COMMAND_PERM);
            return;
        }
        if (args.isEmpty())
View Full Code Here

        }
    }

    private void parseGroupPriority(String group)
    {
        if (!tabCompleteMode && !PermissionsManager.checkPermission(new PermissionContext().setCommandSender(sender), PERM_GROUP_PERMS))
        {
            OutputHandler.chatError(sender, FEPermissions.MSG_NO_COMMAND_PERM);
            return;
        }
        if (args.isEmpty())
View Full Code Here

        }
    }

    private void parseGroupInclude(String group)
    {
        if (!tabCompleteMode && !PermissionsManager.checkPermission(new PermissionContext().setCommandSender(sender), PERM_GROUP_PERMS))
        {
            OutputHandler.chatError(sender, FEPermissions.MSG_NO_COMMAND_PERM);
            return;
        }
View Full Code Here

        return worldZone.getAreaZone(arg);
    }

    private static void parseList(ICommandSender sender, WorldZone worldZone, Queue<String> args)
    {
        if (!PermissionsManager.checkPermission(new PermissionContext().setCommandSender(sender), PERM_LIST))
        {
            OutputHandler.chatError(sender, FEPermissions.MSG_NO_COMMAND_PERM);
            return;
        }
View Full Code Here

        }
    }

    private void parseDefine(ICommandSender sender, WorldZone worldZone, Queue<String> args, boolean redefine)
    {
        if (!PermissionsManager.checkPermission(new PermissionContext().setCommandSender(sender), PERM_DEFINE))
        {
            if (!redefine || !PermissionsManager.checkPermission(new PermissionContext().setCommandSender(sender), PERM_REDEFINE))
            {
                OutputHandler.chatError(sender, FEPermissions.MSG_NO_COMMAND_PERM);
                return;
            }
        }

        if (worldZone == null)
        {
            throw new CommandException("No world found");
        }
        if (args.isEmpty())
        {
            throw new CommandException("Missing arguments!");
        }
        if (tabCompleteMode)
        {
            if (!redefine)
                return;
            for (Zone z: APIRegistry.perms.getZones()) {
                if (z instanceof AreaZone) {
                    if (z.getName().startsWith(args.peek()))
                        tabComplete.add(z.getName());
                    if (Integer.toString(z.getId()).startsWith(args.peek()))
                        tabComplete.add(Integer.toString(z.getId()));
                }
            }
            return;
        }
        String zoneName = args.remove();
        AreaZone zone = getAreaZone(worldZone, zoneName);
        if (!redefine && zone != null)
        {
            throw new CommandException(String.format("Area \"%s\" already exists!", zoneName));
        }
        else if (redefine && zone == null)
        {
            throw new CommandException(String.format("Area \"%s\" does not exist!", zoneName));
        }

        if (args.isEmpty())
        {
            if (!(sender instanceof EntityPlayerMP))
            {
                throw new CommandException("Command not usable from console. Try /zone set <name> <coords> instead");
            }
           
            PlayerInfo info = PlayerInfo.getPlayerInfo((EntityPlayerMP) sender);
            AreaBase area = info.getSelection();
            if (area == null)
                throw new CommandException("No selection available. Please select a region first.");

            PermissionContext context = new PermissionContext();
            context.setCommandSender(sender);
            context.setTargetLocationStart(area.getLowPoint().toVec3());
            context.setTargetLocationEnd(area.getHighPoint().toVec3());
            if (!PermissionsManager.checkPermission(context, PERM_DEFINE))
            {
                throw new CommandException("You don't have the permission to define an area.");
            }
View Full Code Here

        }
    }

    private void parseDelete(ICommandSender sender, WorldZone worldZone, Queue<String> args)
    {
        if (!PermissionsManager.checkPermission(new PermissionContext().setCommandSender(sender), PERM_DELETE))
        {
            OutputHandler.chatError(sender, FEPermissions.MSG_NO_COMMAND_PERM);
            return;
        }
        if (worldZone == null)
View Full Code Here

        OutputHandler.chatConfirmation(sender, String.format("Area \"%s\" has been deleted.", zoneName));
    }

    private void parseEntryExitMessage(ICommandSender sender, WorldZone worldZone, Queue<String> args, boolean isEntry)
    {
        if (!PermissionsManager.checkPermission(new PermissionContext().setCommandSender(sender), PERM_SETTINGS))
        {
            OutputHandler.chatError(sender, FEPermissions.MSG_NO_COMMAND_PERM);
            return;
        }
View Full Code Here

    /**
     * Check, if the sender has permissions to use this command
     */
    public boolean checkCommandPermission(ICommandSender sender)
    {
        return PermissionsManager.checkPermission(new PermissionContext().setCommandSender(sender).setCommand(this), getPermissionNode());
    }
View Full Code Here

TOP

Related Classes of net.minecraftforge.permissions.PermissionContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.