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

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


        if (cmd.length < 2) {
            Canary.help().getHelp(caller, "ban");
            return;
        }
        Ban ban = new Ban();
        Player p = Canary.getServer().matchPlayer(cmd[1]);
        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());
        if (p != null) {
            ban.setSubject(p.getName());
            Canary.bans().issueBan(ban);
            Canary.hooks().callHook(new BanHook(p, p.getIP(), null, reason, timestamp));
            caller.notice(Translator.translateAndFormat("ban banned", p.getName()));
            p.kick(reason);
        }
        else {
            ban.setSubject(cmd[1]);
            Canary.bans().issueBan(ban);
            Canary.hooks().callHook(new BanHook(null, "xxx.xxx.xxx.xxx", null, reason, timestamp));
View Full Code Here


        if (cmd.length < 2) {
            Canary.help().getHelp(caller, "ban");
            return;
        }
        Ban ban = new Ban();
        Player p = Canary.getServer().matchPlayer(cmd[1]);
        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());
        if (p != null) {
            ban.setSubject(p.getName());
            Canary.bans().issueBan(ban);
            Canary.hooks().callHook(new BanHook(p, p.getIP(), (caller instanceof Player) ? (Player)caller : null, reason, timestamp));
            caller.notice(Translator.translateAndFormat("ban banned", p.getName()));
            p.kick(reason);
        }
        else {
            ban.setSubject(cmd[1]);
            Canary.bans().issueBan(ban);
            Canary.hooks().callHook(new BanHook(null, "xxx.xxx.xxx.xxx", (caller instanceof Player) ? (Player)caller : null, reason, timestamp));
View Full Code Here

*/
public class PlayerInformation implements NativeCommand {

    @Override
    public void execute(MessageReceiver caller, String[] args) {
        Player subject = null;
        if (args.length == 2) {
            subject = Canary.getServer().matchPlayer(args[1]);
        }
        else if (caller instanceof Player) {
            subject = (Player) caller;
        }
        if (subject != null) {
            caller.message(TextFormat.GREEN + subject.getName() + "'s info:");
            sendData(caller, "First Joined: ", subject.getFirstJoined());
            sendData(caller, "Time Played: ", ToolBox.getTimeUntil(subject.getTimePlayed()));
            sendData(caller, "Muted: ", subject.isMuted());
            sendData(caller, "Prefix: ", subject.getPrefix());
            sendData(caller, "IP: ", subject.getIP());
            sendData(caller, "Primary Group: ", subject.getGroup().getName());
            sendData(caller, "Other Groups: ", subject.getPlayerGroups());
            sendData(caller, "Health: ", subject.getHealth());
            sendData(caller, "Mode: ", subject.getMode());
            sendData(caller, "Food Level: ", subject.getHunger());
            sendData(caller, "Food Exhaustion: ", String.format("%.2f", subject.getExhaustionLevel()));
            sendData(caller, "XP Level: ", subject.getLevel());
            sendData(caller, "XP Total: ", subject.getExperience());
            Location l = subject.getLocation();

            sendData(caller, "Position: ", String.format("X: %.2f Y: %.2f Z: %.2f Pitch: %.2f Yawn: %.2f", l.getX(), l.getY(), l.getZ(), l.getRotation(), l.getPitch()));
            sendData(caller, "World: ", subject.getWorld().getFqName());
            Warp home = Canary.warps().getHome(subject.getName());

            if (home != null) {
                l = home.getLocation();
                sendData(caller, "Home: ", String.format("X: %.2f Y: %.2f Z: %.2f", l.getX(), l.getY(), l.getZ()));
            }
View Full Code Here

            console(caller, parameters);
        }
    }

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

        if (target != null) {
            if (target.isMuted()) {
                target.setMuted(false);
                caller.notice(Translator.translateAndFormat("mute unmuted", target.getName()));
            }
            else {
                target.setMuted(true);
                caller.notice(Translator.translateAndFormat("mute muted", target.getName()));
            }
        }
        else {
            caller.notice(Translator.translateAndFormat("unknown player", args[1]));
        }
View Full Code Here

            caller.notice(Translator.translateAndFormat("unknown player", args[1]));
        }
    }

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

        if (target != null) {
            if (target.isMuted()) {
                target.setMuted(false);
                player.notice(Translator.translateAndFormat("mute unmuted", target.getName()));
            }
            else {
                target.setMuted(true);
                player.notice(Translator.translateAndFormat("mute muted", target.getName()));
            }
        }
        else {
            player.notice(Translator.translateAndFormat("unknown player", args[1]));
        }
View Full Code Here

* @author Chris (damagefilter)
*/
public class PrivateMessage implements NativeCommand {

    public void execute(MessageReceiver caller, String[] parameters) {
        Player target = Canary.getServer().matchPlayer(parameters[1]);
        String prefix = Colors.BLUE;
        if (caller instanceof Player) {
            prefix = ((Player) caller).getPrefix();
        }
        if (target != null) {
            caller.message(Colors.LIGHT_GRAY + "-> " + target.getPrefix() + target.getName() + Colors.WHITE + ": " + StringUtils.joinString(parameters, " ", 2));
            target.message(Colors.LIGHT_GRAY + "(MSG) " + prefix + caller.getName() + Colors.WHITE + ": " + StringUtils.joinString(parameters, " ", 2));
        }
        else {
            caller.notice(Translator.translateAndFormat("unknown player", parameters[1]));
        }
    }
View Full Code Here

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

            if (target != null) {
                int mode = Integer.parseInt(args[1]);

                target.setModeId(mode);
                caller.notice(Translator.translateAndFormat("mode set other", target.getName(), GameMode.fromId(mode).name()));
            }
            else {
                caller.notice(Translator.translateAndFormat("unknown player", args[2]));
            }
View Full Code Here

    private void player(Player player, String[] args) {
        int mode = Integer.parseInt(args[1]);

        if (args.length == 3) {
            Player receiver = Canary.getServer().matchPlayer(args[2]);

            if (receiver == null) {
                player.notice(Translator.translateAndFormat("unknown player", args[2]));
            }
            else {
                receiver.setModeId(mode);
                player.notice(Translator.translateAndFormat("mode set other", receiver.getName(), GameMode.fromId(mode).name()));
            }
        }
        else {
            player.setModeId(mode);
        }
View Full Code Here

*/
public class ClearInventoryCommand implements NativeCommand {

    public void execute(MessageReceiver caller, String[] args) {
        if (args.length > 1) {
            Player target = Canary.getServer().matchPlayer(args[1]);
            if (target == null) {
                caller.notice(Translator.translateAndFormat("unknown player", args[1]));
            }
            else {
                target.getInventory().clearContents();
                caller.notice(Translator.translateAndFormat("clearinventory success other", target.getName()));
            }
        }
        else {
            if (!(caller instanceof Player)) {
                caller.notice(Translator.translate("clearinventory console"));
            }
            else {
                Player player = (Player) caller;
                player.getInventory().clearContents();
                caller.notice(Translator.translate("clearinventory success"));
            }
        }
    }
View Full Code Here

* @author Brian (WWOL)
*/
public class Kick implements NativeCommand {

    public void execute(MessageReceiver caller, String[] parameters) {
        Player target = Canary.getServer().matchPlayer(parameters[1]);
        if (target != null) {
            String reason = Translator.translateAndFormat("kick message", caller.getName());
            if (parameters.length > 2) {
                reason = StringUtils.joinString(parameters, " ", 2);
            }
            new KickHook(target, caller, reason).call(); // Call KickHook here to pass the caller that is actually doing the kicking
            target.kickNoHook(reason); // Don't call the hook again
            caller.notice(Translator.translateAndFormat("kick kicked", target.getName()));
        }
        else {
            caller.notice(Translator.translate("kick failed") + " " + Translator.translateAndFormat("unknown player", parameters[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.