当前位置: 首页>>代码示例>>Java>>正文


Java Player.safeHasPermission方法代码示例

本文整理汇总了Java中net.canarymod.api.entity.living.humanoid.Player.safeHasPermission方法的典型用法代码示例。如果您正苦于以下问题:Java Player.safeHasPermission方法的具体用法?Java Player.safeHasPermission怎么用?Java Player.safeHasPermission使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.canarymod.api.entity.living.humanoid.Player的用法示例。


在下文中一共展示了Player.safeHasPermission方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: renameZown

import net.canarymod.api.entity.living.humanoid.Player; //导入方法依赖的package包/类
@Override
public boolean renameZown(final World world, final String oldName, final String newName,
                          final Player player) {
    boolean renamed = false;
    final Map<String, Tree<Zown>> zownMap = zownMaps.get(world);
    if (zownMap != null && zownMap.containsKey(oldName) && !zownMap.containsKey(newName)) {
        final Tree<Zown> zownTree = zownMap.get(oldName);
        if (zownTree != null
                && player == null
                || player != null
                && (player.isOperator() || player.safeHasPermission("zown.admin.manage.rename") || zownTree
                .getData().isOwner(player))) {
            zownMap.remove(oldName);
            zownTree.getData().setName(newName);
            zownMap.put(newName, zownTree);
            renamed = true;

            try {
                dataManager.saveZown(world, zownTree, oldName);
            } catch (final Exception e) {
                ZownPlugin.LOG.error("Error saving zown", e);
            }
        }
    }
    return renamed;
}
 
开发者ID:toddharrison,项目名称:Zown,代码行数:27,代码来源:ZownManager.java

示例2: createZown

import net.canarymod.api.entity.living.humanoid.Player; //导入方法依赖的package包/类
@Override
public Tree<? extends IZown> createZown(final World world, final String name,
                                        final ITemplate template, final Point p1, final Point p2, final Player player) {
    Tree<Zown> zownTree = null;

    Map<String, Tree<Zown>> zownMap = zownMaps.get(world);
    if (zownMap == null) {
        getZown(world);
        zownMap = zownMaps.get(world);
    }

    if (!zownMap.containsKey(name)) {
        final Tree<Zown> rootTree = zownTrees.get(world);
        final Zown zown = new Zown(name, (Template) template, p1, p2);
        if (player != null) {
            zown.addOwner(player);
        }
        if (!intersectsExistingZown(rootTree, zown)) {
            final Tree<Zown> targetTree = getTargetContainingZown(rootTree, zown);

            final Boolean flag = targetTree.getData().getConfiguration()
                    .getFlag(Flag.playerclaim.name());
            if (player == null || player.isOperator()
                    || player.safeHasPermission("zown.admin.manage.create") || flag != null && flag) {
                zownTree = new Tree<Zown>(zown);
                targetTree.addChild(zownTree);
                zownMap.put(name, zownTree);

                try {
                    dataManager.saveZown(world, zownTree);
                } catch (final Exception e) {
                    ZownPlugin.LOG.error("Error saving zown", e);
                }
            }
        }
    }

    return zownTree;
}
 
开发者ID:toddharrison,项目名称:Zown,代码行数:40,代码来源:ZownManager.java

示例3: removeZown

import net.canarymod.api.entity.living.humanoid.Player; //导入方法依赖的package包/类
@Override
public boolean removeZown(final World world, final String name, final Player player) {
    boolean removed = false;
    final Map<String, Tree<Zown>> zownMap = zownMaps.get(world);
    if (zownMap != null && zownMap.containsKey(name)) {
        final Tree<Zown> zownTree = zownMap.remove(name);
        if (zownTree != null && player == null
                || player != null
                && (player.isOperator()
                    || player.safeHasPermission("zown.admin.manage.delete")
                    || (zownTree != null && zownTree.getData().isOwner(player)))) {
            removed = zownTree.removeParent();
            if (removed) {
                for (final Tree<Zown> t : zownTree) {
                    zownMap.remove(t.getData().getName());
                }

                try {
                    dataManager.removeZown(world, zownTree);
                } catch (final Exception e) {
                    ZownPlugin.LOG.error("Error saving zown", e);
                }
            }
        }
    }
    return removed;
}
 
开发者ID:toddharrison,项目名称:Zown,代码行数:28,代码来源:ZownManager.java

示例4: resizeZown

import net.canarymod.api.entity.living.humanoid.Player; //导入方法依赖的package包/类
@Override
public boolean resizeZown(final World world, final String name, final Point p1, final Point p2,
                          final Player player) {
    boolean resized = false;
    final Map<String, Tree<Zown>> zownMap = zownMaps.get(world);
    if (zownMap != null) {
        final Tree<Zown> zownTree = zownMap.get(name);
        if (zownTree != null
                && player == null
                || player != null
                && (player.isOperator() || player.safeHasPermission("zown.admin.manage.resize") || zownTree
                .getData().isOwner(player))) {
            final Tree<Zown> rootTree = zownTrees.get(world);
            if (!intersectsExistingZown(rootTree, p1, p2, zownTree)) {
                final Tree<Zown> targetTree = getTargetContainingZown(rootTree, p1, p2, zownTree);
                if (zownTree.getParent() == targetTree) {
                    zownTree.getData().setBounds(p1, p2);
                    resized = true;

                    try {
                        dataManager.saveZown(world, zownTree);
                    } catch (final Exception e) {
                        ZownPlugin.LOG.error("Error saving zown", e);
                    }
                } else {
                    ZownPlugin.LOG.error("Zown being moved outside current parent");
                }
            } else {
                ZownPlugin.LOG.error("Zown resize intersects another zown");
            }
        }
    }
    return resized;
}
 
开发者ID:toddharrison,项目名称:Zown,代码行数:35,代码来源:ZownManager.java

示例5: onBlockRightClick

import net.canarymod.api.entity.living.humanoid.Player; //导入方法依赖的package包/类
@HookHandler(priority = Priority.CRITICAL)
public void onBlockRightClick(final BlockRightClickHook hook) {
    final Player player = hook.getPlayer();
    final Block block = hook.getBlockClicked();

    final Item item = player.getItemHeld();
    final TileEntity tileEntity = block.getTileEntity();
    final BlockType type = block.getType();

    if (item == null || tileEntity != null || type == BlockType.AcaciaDoor
            || type == BlockType.AcaciaFenceGate || type == BlockType.Bed
            || type == BlockType.BirchDoor || type == BlockType.BirchFenceGate
            || type == BlockType.Cake || type == BlockType.Cauldron || type == BlockType.DarkOakDoor
            || type == BlockType.DarkOakFenceGate || type == BlockType.EndPortalFrame
            || type == BlockType.Farmland || type == BlockType.FenceGate || type == BlockType.Flowerpot
            || type == BlockType.JungleDoor || type == BlockType.JungleFenceGate
            || type == BlockType.Lever || type == BlockType.MobSpawner || type == BlockType.OakDoor
            || type == BlockType.RedstoneRepeaterOff || type == BlockType.RedstoneRepeaterOn
            || type == BlockType.SpruceDoor || type == BlockType.SpruceFenceGate
            || type == BlockType.StoneButton || type == BlockType.Trapdoor
            || type == BlockType.WoodenButton || type == BlockType.WoodenDoor) {
        if (!player.isOperator() && !player.safeHasPermission("zown.admin.mod")) {
            final Tree<? extends IZown> zownTree = zownManager.getZown(block.getLocation());
            if (!zownTree.getData().isOwnerOrMember(player)) {
                final Boolean flag = zownTree.getData().getConfiguration().getFlag(Flag.interact.name());
                if (flag != null) {
                    final boolean excluded = zownTree.getData().getConfiguration()
                            .hasBlockInteractExclusion(block.getType());
                    if (flag) {
                        if (excluded) {
                            hook.setCanceled();
                            closeDoor(block);
                        }
                    } else {
                        if (!excluded) {
                            hook.setCanceled();
                            closeDoor(block);
                        }
                    }
                }
            }
        }
    }
}
 
开发者ID:toddharrison,项目名称:Zown,代码行数:45,代码来源:ModifyWorldListener.java

示例6: flagZown

import net.canarymod.api.entity.living.humanoid.Player; //导入方法依赖的package包/类
@Command(aliases = {
        "flag"
}, parent = "zown", description = "zown flag", permissions = {
        "zown.zown.flag"
}, toolTip = "/zown flag <zown> <flag>:<ALLOW | DENY>...")
public void flagZown(final MessageReceiver caller, final String[] parameters) {
    World world = null;
    String zown = null;
    int index = 0;

    Player player = null;

    if (caller instanceof Player) {
        player = caller.asPlayer();
        if (parameters.length >= 3) {
            world = player.getWorld();
            zown = parameters[1];
            index = 2;
        } else {
            sendMessage(caller, "Usage: /zown flag <zown> <flag>:<ALLOW | DENY>...");
        }
    } else {
        if (parameters.length >= 4) {
            world = worldManager.getWorld(parameters[1], false);
            zown = parameters[2];
            index = 3;
        } else {
            sendMessage(caller, "Usage: /zown flag <world> <zown> <flag>:<ALLOW | DENY>...");
        }
    }

    if (world != null && zown != null) {
        final Tree<? extends IZown> zownTree = zownManager.getZown(world, zown);
        if (zownTree == null) {
            sendMessage(caller, "Zown '" + zown + "' doesn't exist.");
        } else {

            if (!zownTree.getData().overridesConfiguration()) {
                // TODO put in zownManager
                zownTree.getData().setOverridesConfiguration(true);
                zownManager.saveZownConfiguration(world, zown);
            }

            boolean changed = false;
            final IConfiguration config = zownTree.getData().getConfiguration();
            for (int i = index; i < parameters.length; i++) {
                final String[] flag = parameters[i].split(":");
                if (flag.length == 2) {
                    if (player != null) {
                        if (player.isOperator() || player.safeHasPermission("zown.admin.flag")) {
                            config.setFlag(flag[0],
                                    "allow".equalsIgnoreCase(flag[1]) || "true".equalsIgnoreCase(flag[1]));
                            changed = true;
                        } else {
                            if (zownTree.getData().isOwner(player)
                                    && zownTree.getData().getConfiguration().hasOwnerPermission(flag[0])) {
                                config.setFlag(flag[0],
                                        "allow".equalsIgnoreCase(flag[1]) || "true".equalsIgnoreCase(flag[1]));
                                changed = true;
                            }
                        }
                    } else {
                        config.setFlag(flag[0], "allow".equalsIgnoreCase(flag[1]));
                        changed = true;
                    }
                } else {
                    sendMessage(caller, "Bad flag: " + parameters[i]);
                }
            }

            if (changed) {
                zownManager.saveZownConfiguration(world, zown);
                sendMessage(caller, "Added flags to zown '" + zown + "'.");
            } else {
                sendMessage(caller, "No flags set in zown '" + zown + "'.");
            }
        }
    }
}
 
开发者ID:toddharrison,项目名称:Zown,代码行数:80,代码来源:ZownCommand.java

示例7: zownMember

import net.canarymod.api.entity.living.humanoid.Player; //导入方法依赖的package包/类
@Command(aliases = {
        "member"
}, parent = "zown", description = "zown member", permissions = {
        "zown.zown.player.member"
}, toolTip = "/zown member <zown> <add | remove> <player>")
public void zownMember(final MessageReceiver caller, final String[] parameters) {
    World world = null;
    String zown = null;
    String action = null;
    String playerName = null;

    Player callingPlayer = null;

    if (caller instanceof Player) {
        callingPlayer = caller.asPlayer();
        switch (parameters.length) {
            case 4:
                world = callingPlayer.getWorld();
                zown = parameters[1];
                action = parameters[2];
                playerName = parameters[3];
                break;
            default:
                sendMessage(caller, "Usage: /zown member <zown> <add | remove> <player>");
        }
    } else {
        switch (parameters.length) {
            case 5:
                world = worldManager.getWorld(parameters[1], false);
                zown = parameters[2];
                action = parameters[3];
                playerName = parameters[4];
                break;
            default:
                sendMessage(caller, "Usage: /zown member <world> <zown> <add | remove> <player>");
        }
    }

    if (world != null && zown != null && action != null && playerName != null) {
        final Tree<? extends IZown> zownTree = zownManager.getZown(world, zown);
        final Player player = Canary.getServer().getPlayer(playerName);
        if (zownTree == null) {
            sendMessage(caller, "No zown '" + zown + "' exists.");
        } else if (player == null) {
            sendMessage(caller, "No player '" + playerName + "' is online.");
        } else {
            if (callingPlayer == null || callingPlayer.isOperator()
                    || player.safeHasPermission("zown.admin.player.member")
                    || zownTree.getData().isOwner(callingPlayer)) {
                if ("add".equalsIgnoreCase(action)) {
                    if (zownTree.getData().addMember(player)) {
                        sendMessage(caller, "Added member '" + playerName + "' to zown '" + zown + "'.");
                        zownManager.saveZownConfiguration(world, zown);
                    } else {
                        sendMessage(caller, "Member '" + playerName + "' already exists on zown.");
                    }
                } else if ("remove".equalsIgnoreCase(action)) {
                    if (zownTree.getData().removeMember(player)) {
                        sendMessage(caller, "Removed member '" + playerName + "' from zown '" + zown + "'.");
                        zownManager.saveZownConfiguration(world, zown);
                    } else {
                        sendMessage(caller, "Member '" + playerName + "' does not exist on zown.");
                    }
                } else {
                    sendMessage(caller, "Unrecognized action '" + action + "' must be <add | remove>.");
                }
            } else {
                sendMessage(caller, "You are not an owner of this zown");
            }
        }
    }
}
 
开发者ID:toddharrison,项目名称:Zown,代码行数:73,代码来源:ZownCommand.java

示例8: zownOwner

import net.canarymod.api.entity.living.humanoid.Player; //导入方法依赖的package包/类
@Command(aliases = {
        "owner"
}, parent = "zown", description = "zown owner", permissions = {
        "zown.zown.player.owner"
}, toolTip = "/zown owner <zown> <add | remove> <player>")
public void zownOwner(final MessageReceiver caller, final String[] parameters) {
    World world = null;
    String zown = null;
    String action = null;
    String playerName = null;

    Player callingPlayer = null;

    if (caller instanceof Player) {
        callingPlayer = caller.asPlayer();
        switch (parameters.length) {
            case 4:
                world = callingPlayer.getWorld();
                zown = parameters[1];
                action = parameters[2];
                playerName = parameters[3];
                break;
            default:
                sendMessage(caller, "Usage: /zown owner <zown> <add | remove> <player>");
        }
    } else {
        switch (parameters.length) {
            case 5:
                world = worldManager.getWorld(parameters[1], false);
                zown = parameters[2];
                action = parameters[3];
                playerName = parameters[4];
                break;
            default:
                sendMessage(caller, "Usage: /zown owner <world> <zown> <add | remove> <player>");
        }
    }

    if (world != null && zown != null && action != null && playerName != null) {
        final Tree<? extends IZown> zownTree = zownManager.getZown(world, zown);
        final Player player = Canary.getServer().getPlayer(playerName);
        if (zownTree == null) {
            sendMessage(caller, "No zown '" + zown + "' exists.");
        } else if (player == null) {
            sendMessage(caller, "No player '" + playerName + "' is online.");
        } else {
            if (callingPlayer == null || callingPlayer.isOperator()
                    || player.safeHasPermission("zown.admin.player.owner")
                    || zownTree.getData().isOwner(callingPlayer)) {
                if ("add".equalsIgnoreCase(action)) {
                    if (zownTree.getData().addOwner(player)) {
                        sendMessage(caller, "Added owner '" + playerName + "' to zown '" + zown + "'.");
                        zownManager.saveZownConfiguration(world, zown);
                    } else {
                        sendMessage(caller, "Owner '" + playerName + "' already exists on zown.");
                    }
                } else if ("remove".equalsIgnoreCase(action)) {
                    if (zownTree.getData().removeOwner(player)) {
                        sendMessage(caller, "Removed owner '" + playerName + "' from zown '" + zown + "'.");
                        zownManager.saveZownConfiguration(world, zown);
                    } else {
                        sendMessage(caller, "Owner '" + playerName + "' does not exist on zown.");
                    }
                } else {
                    sendMessage(caller, "Unrecognized action '" + action + "' must be <add | remove>.");
                }
            } else {
                sendMessage(caller, "You are not an owner of this zown");
            }
        }
    }
}
 
开发者ID:toddharrison,项目名称:Zown,代码行数:73,代码来源:ZownCommand.java

示例9: zownMessage

import net.canarymod.api.entity.living.humanoid.Player; //导入方法依赖的package包/类
@Command(aliases = {
        "message"
}, parent = "zown", description = "zown message", permissions = {
        "zown.zown.message"
}, toolTip = "/zown message <zown> <welcome | farewell | restrictentry> \"<message>\"")
public void zownMessage(final MessageReceiver caller, final String[] parameters) {
    World world = null;
    String zown = null;
    String type = null;
    String message = null;

    Player player = null;

    if (caller instanceof Player) {
        player = caller.asPlayer();
        if (parameters.length > 3) {
            world = player.getWorld();
            zown = parameters[1];
            type = parameters[2];
            message = parseMessage(parameters, 3);
        } else {
            sendMessage(caller,
                    "Usage: /zown message <zown> <welcome | farewell | restrictentry> \"<message>\"");
        }
    } else {
        if (parameters.length > 4) {
            world = worldManager.getWorld(parameters[1], false);
            zown = parameters[2];
            type = parameters[3];
            message = parseMessage(parameters, 4);
        } else {
            sendMessage(caller,
                    "Usage: /zown message <world> <zown> <welcome | farewell | restrictentry> \"<message>\"");
        }
    }

    if (world != null && zown != null && type != null) {
        if (message == null) {
            sendMessage(caller, "Bad message specified.");
        } else {
            final Tree<? extends IZown> zownTree = zownManager.getZown(world, zown);
            if (zownTree == null) {
                sendMessage(caller, "No zown '" + zown + "' exists.");
            } else {
                if (player == null || player.isOperator()
                        || player.safeHasPermission("zown.admin.message")
                        || zownTree.getData().isOwner(player)) {
                    if ("welcome".equalsIgnoreCase(type)) {
                        zownTree.getData().setWelcomeMessage(message);
                        sendMessage(caller, "Added welcome message to zown '" + zown + "'.");
                        zownManager.saveZownConfiguration(world, zown);
                    } else if ("farewell".equalsIgnoreCase(type)) {
                        zownTree.getData().setFarewellMessage(message);
                        sendMessage(caller, "Added farewell message to zown '" + zown + "'.");
                        zownManager.saveZownConfiguration(world, zown);
                    } else if ("restrictentry".equalsIgnoreCase(type)) {
                        // TODO Add support for restrictentry message
                        throw new UnsupportedOperationException("Do not yet support restrictentry messages");
                    } else {
                        sendMessage(caller, "Unrecognized message type '" + type
                                + "' must be <welcome | farewell | restrictentry>.");
                    }
                } else {
                    sendMessage(caller, "You are not an owner of this zown");
                }
            }
        }
    }
}
 
开发者ID:toddharrison,项目名称:Zown,代码行数:70,代码来源:ZownCommand.java


注:本文中的net.canarymod.api.entity.living.humanoid.Player.safeHasPermission方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。