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

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


    public void execute(MessageReceiver caller, String[] args) {
        if (caller instanceof Server || caller instanceof CommandBlock) {
            caller.notice(Translator.translate("setwarp console"));
        }
        else {
            Player player = (Player) caller;
            if (Canary.warps().warpExists(args[1]) && !player.hasPermission("canary.command.warp.setwarp.admin")) {
                player.notice(Translator.translate("setwarp failed"));
                return;
            }
            // SET PUBLIC WARP
            if (args.length == 2 && player.hasPermission("canary.command.warp.set.public")) {
                Warp newWarp = new Warp(player.getLocation(), args[1]);

                Canary.warps().addWarp(newWarp);
                player.message(Colors.YELLOW + Translator.translateAndFormat("setwarp success", args[1]));
            }
            else if (args.length > 3) {
                // SET GROUP SPECIFIC WARP
                if (args[2].equalsIgnoreCase("G") && player.hasPermission("canary.command.warp.set.group")) {
                    Group[] groups = new Group[args.length - 3];

                    for (int i = 0; i < groups.length; i++) {
                        groups[i] = Canary.usersAndGroups().getGroup(args[i + 3]);
                    }
                    Warp newWarp = new Warp(player.getLocation(), groups, args[1]);

                    Canary.warps().addWarp(newWarp);
                    player.message(Colors.YELLOW + Translator.translateAndFormat("setwarp success group", args[1]));
                    return;
                }
                // SET PRIVATE WARP
                if (args[2].equalsIgnoreCase("P") && player.hasPermission("canary.command.warp.set.private")) {
                    Warp newWarp = new Warp(player.getLocation(), args[1], args[3], false);

                    Canary.warps().addWarp(newWarp);
                    player.message(Colors.YELLOW + Translator.translateAndFormat("setwarp success private", args[1]));
                }
                else {
                    Canary.help().getHelp(player, "setwarp");
                }
            }
View Full Code Here


    private void console(MessageReceiver caller) {
        caller.notice(Translator.translate("tp console"));
    }

    private void player(Player player, String[] args) {
        Player target = Canary.getServer().matchPlayer(args[1]);
        if (args.length == 2) {
            if (target != null) {
                player.teleportTo(target.getLocation(), TeleportHook.TeleportCause.COMMAND);
                player.message(Colors.YELLOW + Translator.translateAndFormat("tp success other", target.getName()));
            }
            else {
                World w = Canary.getServer().getWorldManager().getWorld(args[1], player.hasPermission("canary.command.teleport.self.world.load"));
                if (w == null) {
                    player.notice(Translator.translateAndFormat("unknown player", args[1]));
                    return;
                }
                if (player.hasPermission("canary.command.teleport.self.world")) {
                    player.teleportTo(w.getSpawnLocation());
                }
            }
        }
        else if (args.length > 3) { // is it X Y Z?
            try {
                double x = Double.parseDouble(args[1]), y = Double.parseDouble(args[2]), z = Double.parseDouble(args[3]);
                if (args.length > 4 && player.hasPermission("canary.command.teleport.self.world")) {
                    try {
                        String dTypeName = args[4].replaceAll("(\\w+)(_(\\w+)$)", "$3");
                        DimensionType dType = DimensionType.fromName(dTypeName);
                        String correctedName = dType == null ? args[4] : args[4].replaceAll("_(\\w+)$", "");
                        if (dType == null) {
                            dType = DimensionType.fromName("NORMAL");
                        }
                        World world = Canary.getServer().getWorldManager().getWorld(correctedName, dType, args.length > 5 && player.hasPermission("canary.command.teleport.self.world.load") ? Boolean.valueOf(args[5]) : false);
                        if (world != null) {
                            player.teleportTo(x, y, z, world);
                        }
                        else {
                            player.notice("world not found");
                        }
                    }
                    catch (UnknownWorldException uwex) {
                        player.notice("world not found");
                    }
                }
                else {
                    player.teleportTo(x, y, z);
                }
            }
            catch (NumberFormatException nfex) {
                player.notice(Translator.translateAndFormat("bad coordinates"));
            }
        }
        else if (target != null) {
            player.teleportTo(target.getLocation(), TeleportHook.TeleportCause.COMMAND);
            player.message(Colors.YELLOW + Translator.translateAndFormat("tp success", target.getName()));
        }
        else {
            player.notice(Translator.translateAndFormat("unknown player", args[1]));
        }
    }
View Full Code Here

    public void execute(MessageReceiver caller, String[] args) {
        if (caller instanceof Server || caller instanceof CommandBlock) {
            caller.notice(Translator.translate("warp console"));
        }
        else {
            Player player = (Player) caller;
            Warp target = Canary.warps().getWarp(args[1]);

            if (target != null) {
                if (target.warp(player)) {
                    player.message(Colors.YELLOW + Translator.translateAndFormat("warp success", target.getName()));
                    return;
                }
                else {
                    player.message(Colors.YELLOW + Translator.translateAndFormat("warp not allowed", target.getName()));
                    return;
                }
            }
            player.notice(Translator.translateAndFormat("warp unknown", args[1]));
        }
    }
View Full Code Here

    private void console(MessageReceiver caller, String[] args) {
        if (args.length < 3) {
            caller.notice(Translator.translate("spawn failed console"));
        }
        else {
            Player player = Canary.getServer().matchPlayer(args[2]);
            World w = Canary.getServer().getWorld(args[1]);

            if (player != null && w != null) {
                player.teleportTo(w.getSpawnLocation());
                caller.notice(Translator.translateAndFormat("spawn success other", player.getName()));
            }
            else {
                caller.notice(Translator.translate("spawn failed console"));
            }
        }
View Full Code Here

            else {
                Canary.logInfo(Translator.translate("no warps"));
            }
        }
        else {
            Player player = (Player) caller;
            player.message(Colors.YELLOW + Translator.translate("warps available"));

            List<Warp> warps = Canary.warps().getAllWarps();
            StringBuilder warpList = new StringBuilder();

            for (Warp w : warps) {
                if (w.getOwner() != null) {
                    if (w.isPlayerHome() && w.getOwner().equals(player.getName())) {
                        warpList.append(Colors.LIGHT_GREEN).append("(").append(Translator.translate("your home")).append(")").append(Colors.WHITE).append(", ");
                    }
                    else if (!w.isPlayerHome() && w.getOwner().equals(player.getName()) || (player.isAdmin())) {
                        warpList.append(Colors.ORANGE).append(w.getName()).append("(").append(Translator.translate("private")).append(")").append(Colors.WHITE).append(", ");
                    }
                }
                else if (w.isGroupRestricted() && w.isGroupAllowed(player.getGroup())) {
                    warpList.append(Colors.YELLOW).append(w.getName()).append("(").append(Translator.translate("group")).append(")").append(Colors.WHITE).append(", ");
                }
                else if (!w.isGroupRestricted()) {
                    warpList.append(w.getName()).append(", ");
                }
            }

            if (warpList.length() > 0) {
                warpList.deleteCharAt(warpList.length() - 1);
                player.message(warpList.toString().trim());
            }
            else {
                player.notice(Translator.translate("no warps"));
            }
        }
    }
View Full Code Here

                player.message(Colors.YELLOW + Translator.translate("spawn success"));
            }
        }
        else {
            World w = Canary.getServer().getWorld(args[1]);
            Player target = Canary.getServer().matchPlayer(args[2]);

            if (target != null && w != null) {
                target.teleportTo(w.getSpawnLocation());
                player.message(Colors.YELLOW + Translator.translateAndFormat("spawn success other", player.getName()));
            }
        }
    }
View Full Code Here

    private void console(MessageReceiver caller, String[] args) {
        if (args.length == 1) {
            caller.notice(Translator.translate("kill console"));
        }
        else {
            Player target = Canary.getServer().matchPlayer(args[1]);

            if (target != null) {
                target.kill();
                caller.notice(Translator.translateAndFormat("killed other", target.getName()));
            }
            else {
                caller.notice(Translator.translate("not killed") + " " + Translator.translateAndFormat("unknown player", args[1]));
            }
        }
View Full Code Here

            player.notice(Translator.translate("player suicide"));
            player.kill();
        }
        else {
            if (player.hasPermission("canary.command.player.kill.other")) {
                Player target = Canary.getServer().matchPlayer(args[1]);

                if (target != null) {
                    target.kill();
                    player.notice(Translator.translateAndFormat("killed other", target.getName()));
                }
                else {
                    player.notice(Translator.translate("not killed") + " " + Translator.translateAndFormat("unknown player", args[1]));
                }
            }
View Full Code Here

        if (cmd.length < 2) {
            Canary.help().getHelp(caller, "ipban");
            return;
        }

        Player p = Canary.getServer().matchPlayer(cmd[1]);
        if (p == null) {
            caller.notice(Translator.translate("ban failed") + " " + Translator.translateAndFormat("unknown player", cmd[1]));
            return;
        }
        Ban ban = new Ban();
        String reason = "Permanently Banned";
        long timestamp = -1L;

        if (cmd.length >= 3) {
            try {
                timestamp = ToolBox.parseTime(Long.parseLong(cmd[cmd.length - 2]), cmd[cmd.length - 1]);
                reason = StringUtils.joinString(cmd, " ", 2, cmd.length - 2);
            }
            catch (NumberFormatException e) {
                reason = StringUtils.joinString(cmd, " ", 2);
                timestamp = -1L;
            }
        }
        ban.setReason(reason);
        ban.setTimestamp(timestamp);
        ban.setBanningPlayer(caller.getName());
        ban.setSubject(p.getName());
        ban.setIp(p.getIP());
        ban.setIsIpBan(true);
        Canary.bans().issueBan(ban);
        Canary.hooks().callHook(new BanHook(p, p.getIP(), null, reason, timestamp));
        caller.notice(Translator.translateAndFormat("ipban banned", cmd[1]));
        p.kick(reason);
    }
View Full Code Here

        if (cmd.length < 2) {
            Canary.help().getHelp(caller, "ipban");
            return;
        }

        Player p = Canary.getServer().matchPlayer(cmd[1]);
        if (p == null) {
            caller.notice(Translator.translate("ban failed") + " " + Translator.translateAndFormat("unknown player", cmd[1]));
            return;
        }
        Ban ban = new Ban();
        String reason = "Permanently Banned";
        long timestamp = -1L;

        if (cmd.length >= 3) {
            try {
                timestamp = ToolBox.parseTime(Long.parseLong(cmd[cmd.length - 2]), cmd[cmd.length - 1]);
                reason = StringUtils.joinString(cmd, " ", 2, cmd.length - 2);
            }
            catch (NumberFormatException e) {
                reason = StringUtils.joinString(cmd, " ", 2);
                timestamp = -1L;
            }
        }
        ban.setReason(reason);
        ban.setTimestamp(timestamp);
        ban.setBanningPlayer(caller.getName());
        ban.setSubject(p.getName());
        ban.setIp(p.getIP());
        ban.setIsIpBan(true);
        Canary.bans().issueBan(ban);
        Canary.hooks().callHook(new BanHook(p, p.getIP(), caller, reason, timestamp));
        caller.notice(Translator.translateAndFormat("ipban banned", cmd[1]));
        p.kick(reason);
    }
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.