Package net.canarymod.api.entity.living.humanoid

Examples of net.canarymod.api.entity.living.humanoid.Player


* @author Chris (damagefilter)
*/
public class PlayerPermissionCheck implements NativeCommand {
    // groupmod permission add group value
    public void execute(MessageReceiver caller, String[] args) {
        Player player = Canary.getServer().matchPlayer(args[1]);
        PermissionNode node = PermissionNode.fromString(args[2]);
        boolean result;
        boolean hasPath;
        if (player == null) {
            OfflinePlayer oplayer = Canary.getServer().getOfflinePlayer(args[1]);
            result = oplayer.hasPermission(node.getName());
            hasPath = oplayer.getPermissionProvider().pathExists(node.getName());
        }
        else {
            result = player.hasPermission(node.getName());
            hasPath = player.getPermissionProvider().pathExists(node.getName());
        }
        if (hasPath) {
            if (result) {
                caller.message(Colors.LIGHT_GREEN + node.getName() + ": true");
            }
View Full Code Here


    public void execute(MessageReceiver caller, String[] args) {
        if (args[args.length - 1].equals("--help")) {
            Canary.help().getHelp(caller, "playermod group add");
            return;
        }
        Player target = Canary.getServer().matchPlayer(args[1]);
        Group group = Canary.usersAndGroups().getGroup(args[2]);
        if (group == null) {
            caller.notice(Translator.translateAndFormat("unknown group", args[2]));
            return;
        }
        if (target == null) {
            OfflinePlayer oplayer = Canary.getServer().getOfflinePlayer(args[1]);
            if (!oplayer.isInGroup(group, true)) {
                oplayer.addGroup(group);
                caller.message(Colors.YELLOW + Translator.translate("modify group add"));
            }
            return;
        }
        if (!target.isInGroup(group, true)) {
            target.addGroup(group);
            caller.message(Colors.YELLOW + Translator.translate("modify group add"));
        }
    }
View Full Code Here

* @author Chris (damagefilter)
*/
public class PlayerPermissionList implements NativeCommand {
    // groupmod permission add group value
    public void execute(MessageReceiver caller, String[] args) {
        Player player = Canary.getServer().matchPlayer(args[1]);
        if (player == null) {
            OfflinePlayer oplayer = Canary.getServer().getOfflinePlayer(args[1]);
            oplayer.getPermissionProvider().printPermissionsToCaller(caller);
            return;
        }
        player.getPermissionProvider().printPermissionsToCaller(caller);
    }
View Full Code Here

    public void execute(MessageReceiver caller, String[] args) {
        if (args[args.length - 1].equals("--help")) {
            Canary.help().getHelp(caller, "playermod remove");
            return;
        }
        Player target = Canary.getServer().matchPlayer(args[1]);
        if (target == null) {
            Canary.usersAndGroups().removeUserData(args[1]);
            caller.notice(Translator.translate("modify player removed"));
            return;
        }
        target.setGroup(Canary.usersAndGroups().getDefaultGroup());
        Canary.usersAndGroups().removeUserData(target.getName());
        caller.notice(Translator.translate("modify player removed"));
    }
View Full Code Here

        }
        String prefix = null;
        if (args.length >= 3) {
            prefix = StringUtils.joinString(args, " ", 2).replaceAll("&([A-FK-Oa-fk-oRr0-9])", "\u00A7$1");
        }
        Player target = Canary.getServer().matchPlayer(args[1]);
        if (target == null) {
            OfflinePlayer oplayer = Canary.getServer().getOfflinePlayer(args[1]);
            oplayer.setPrefix(prefix);
            caller.message(Colors.YELLOW + Translator.translate("modify prefix set"));
            return;
        }
        target.setPrefix(prefix);
        caller.message(Colors.YELLOW + Translator.translate("modify prefix set"));
    }
View Full Code Here

    public void execute(MessageReceiver caller, String[] args) {
        if (args[args.length - 1].equals("--help")) {
            Canary.help().getHelp(caller, "playermod group set");
            return;
        }
        Player target = Canary.getServer().matchPlayer(args[1]);
        Group group = Canary.usersAndGroups().getGroup(args[2]);
        if (group == null) {
            caller.notice(Translator.translateAndFormat("unknown group", args[2]));
            return;
        }
        if (target == null) {
            OfflinePlayer oplayer = Canary.getServer().getOfflinePlayer(args[1]);
            oplayer.setGroup(group);
            caller.message(Colors.YELLOW + Translator.translate("modify group set"));
            return;
        }
        target.setGroup(group);
        caller.message(Colors.YELLOW + Translator.translate("modify group set"));
    }
View Full Code Here

        if (item == null) {
            caller.notice(Translator.translateAndFormat("give invalid itemtype", args[1]));
            return;
        }
        item.setAmount(amount);
        Player target = Canary.getServer().matchPlayer(args[args.length - 1]);
        if (target == null) {
            caller.notice(Translator.translateAndFormat("unknown player", args[args.length - 1]));
            return;
        }
        target.giveItem(item);
        target.message(Colors.YELLOW + Translator.translateAndFormat("give received", item.getType().getDisplayName()));
        caller.notice(Translator.translateAndFormat("give success other", target.getName()));

    }
View Full Code Here

            else {
                if (!player.hasPermission("canary.command.give.other")) {
                    player.notice(Translator.translate("give failed"));
                    return;
                }
                Player target = Canary.getServer().matchPlayer(args[2]);
                if (target == null) {
                    player.notice(Translator.translateAndFormat("unknown player", args[2]));
                    return;
                }
                Item item = makeItem(args[1], 1);
                if (item == null) { // NULL CHECK!
                    player.notice(Translator.translateAndFormat("give invalid itemtype", args[1]));
                    return;
                }
                target.giveItem(item);
                target.message(Colors.YELLOW + Translator.translateAndFormat("give received", item.getType().getDisplayName()));
                player.notice(Translator.translateAndFormat("give success other", target.getName()));
            }
        }
        // Give to other
        else if (args.length == 4) {
            if (!player.hasPermission("canary.command.give.other")) {
                player.notice(Translator.translate("give failed"));
                return;
            }
            int amount = 1;
            if (args[2].matches("\\d+")) {
                amount = Integer.parseInt(args[2]);
            }
            Item item = makeItem(args[1], amount);
            if (item == null) {
                player.notice(Translator.translateAndFormat("give invalid itemtype", args[1]));
                return;
            }
            Player target = Canary.getServer().matchPlayer(args[3]);
            if (target == null) {
                player.notice(Translator.translateAndFormat("unknown player", args[3]));
                return;
            }
            target.giveItem(item);
            target.message(Colors.YELLOW + Translator.translateAndFormat("give received", item.getType().getDisplayName()));
            player.notice(Translator.translateAndFormat("give success other", target.getName()));
        }
    }
View Full Code Here

            throw new CommandException("Unknown MessageReceiver: " + caller.getClass().getSimpleName());
        }
    }

    private void cmdblock(CommandBlock block, String[] args) {
        Player target = Canary.getServer().matchPlayer(args[1]);

        if (target != null) {
            Location l = block.getBlock().getLocation();
            l.setY(l.getY()+1);
            target.teleportTo(l, TeleportHook.TeleportCause.COMMAND);
            block.message(Colors.YELLOW + Translator.translateAndFormat("tphere success", target.getName()));
        }
        else {
            block.notice(Translator.translateAndFormat("unknown player", args[1]));
        }
    }
View Full Code Here

    private void console(Server caller) {
        caller.notice(Translator.translate("tphere console"));
    }

    private void player(Player player, String[] args) {
        Player target = Canary.getServer().matchPlayer(args[1]);

        if (target != null) {
            target.teleportTo(player.getLocation(), TeleportHook.TeleportCause.COMMAND);
            player.message(Colors.YELLOW + Translator.translateAndFormat("tphere success", target.getName()));
        }
        else {
            player.notice(Translator.translateAndFormat("unknown player", args[1]));
        }
    }
View Full Code Here

TOP

Related Classes of net.canarymod.api.entity.living.humanoid.Player

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.