Package net.canarymod.api.world

Examples of net.canarymod.api.world.World


        return msgrec instanceof Player ? ((Player) msgrec).getWorld().getName() : Canary.getServer().getDefaultWorldName();
    }

    @MOTDKey(key = "{world.weather}")
    public final String worldWeather(MessageReceiver msgrec) {
        World world;
        if (msgrec instanceof Player) {
            world = ((Player) msgrec).getWorld();
        }
        else if (msgrec instanceof CommandBlock) {
            world = ((CommandBlock) msgrec).getWorld();
        }
        else {
            world = Canary.getServer().getDefaultWorld();
        }

        if (world.isThundering()) {
            return "thunderstorm";
        }
        else if (world.isRaining()) {
            return "raining";
        }
        else {
            return "sunny";
        }
View Full Code Here


            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");
View Full Code Here

        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

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

            if (w == null) {
                player.notice(Translator.translate("spawn failed"));
            }
            else {
                player.teleportTo(w.getSpawnLocation());
                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

        if (args.length == 4) { // Here we have world and group name
            // we have world and parent set!
            // We require this to get the real fqname of the world,
            // since a user could pass only the world group name which parseWorld
            // will evaluate as the NORMAL dimension.
            World world = ToolBox.parseWorld(args[3]);
            if (world == null) { // Whoops!
                caller.notice(Translator.translateAndFormat("group unknown world", args[3]));
                return;
            }
            worldName = world.getFqName();

            parent = Canary.usersAndGroups().getGroup(args[2]);
            if (parent == null) {
                caller.notice(Translator.translateAndFormat("group unknown parent", args[2]));
                return;
            }
            if (!parent.getWorldName().equals(worldName)) {
                caller.notice(Translator.translateAndFormat("group parent world mismatch", parent.getName(), parent.getWorldName(), worldName));
                return;
            }
        }
        if (args.length == 3) { // This can be only a world or a group name
            parent = Canary.usersAndGroups().getGroup(args[2]);
            if (parent == null) {
                caller.notice(Translator.translateAndFormat("group unknown parent", args[2]));
                return;
            }
            World world = ToolBox.parseWorld(args[2]);
            if (world == null) {
                caller.notice(Translator.translateAndFormat("group unknown world", args[3]));
                return;
            }
            else {
                worldName = world.getFqName();
            }
            String groupworld = parent.getWorldName();
            if (worldName != null && !(groupworld != null && groupworld.equals(worldName))) {
                //Cannot add a parent from another world
                caller.notice(Translator.translateAndFormat("group parent world mismatch", parent.getName(), parent.getWorldName(), worldName));
View Full Code Here

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

    private void cmdblock(CommandBlock block, String[] args) {
        World dim = block.getWorld();
        if (args[0].equals("/thetime")) {
            if (!block.hasPermission("canary.command.time.check")) {
                return;
            }
            block.message(Colors.YELLOW + Translator.translateAndFormat("time display", dim.getRelativeTime(), dim.getRawTime()));
            return;
        }

        if (args[1].equalsIgnoreCase("check")) {
            if (!block.hasPermission("canary.command.time.check")) {
                return;
            }
            block.message(Colors.YELLOW + Translator.translateAndFormat("time display", dim.getRelativeTime(), dim.getRawTime()));
        }
        else if (args[1].equalsIgnoreCase("day")) {
            if (!block.hasPermission("canary.command.time.set")) {
                return;
            }
            dim.setTime(0L);
            block.message(Colors.YELLOW + Translator.translate("time set day"));
        }
        else if (args[1].equalsIgnoreCase("night")) {
            if (!block.hasPermission("canary.command.time.set")) {
                return;
            }
            dim.setTime(13000L);
            block.message(Colors.YELLOW + Translator.translate("time set night"));
        }
        else if (args[1].matches("\\d+")) {
            if (!block.hasPermission("canary.command.time.set")) {
                return;
            }
            dim.setTime(Long.parseLong(args[1]));
            block.message(Colors.YELLOW + Translator.translate("time set"));
        }
        else {
            Canary.help().getHelp(block, "time");
        }
View Full Code Here

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

    private void player(Player player, String[] args) {
        World dim = player.getWorld();
        if (args[0].equals("/thetime")) {
            if (!player.hasPermission("canary.command.time.check")) {
                return;
            }
            player.message(Colors.YELLOW + Translator.translateAndFormat("time display", dim.getRelativeTime(), dim.getRawTime()));
            return;
        }

        if (args[1].equalsIgnoreCase("check")) {
            if (!player.hasPermission("canary.command.time.check")) {
                return;
            }
            player.message(Colors.YELLOW + Translator.translateAndFormat("time display", dim.getRelativeTime(), dim.getRawTime()));
        }
        else if (args[1].equalsIgnoreCase("day")) {
            if (!player.hasPermission("canary.command.time.set")) {
                return;
            }
            dim.setTime(0L);
            player.message(Colors.YELLOW + Translator.translate("time set day"));
        }
        else if (args[1].equalsIgnoreCase("night")) {
            if (!player.hasPermission("canary.command.time.set")) {
                return;
            }
            dim.setTime(13000L);
            player.message(Colors.YELLOW + Translator.translate("time set night"));
        }
        else if (args[1].matches("\\d+")) {
            if (!player.hasPermission("canary.command.time.set")) {
                return;
            }
            dim.setTime(Long.parseLong(args[1]));
            player.message(Colors.YELLOW + Translator.translate("time set"));
        }
        else {
            Canary.help().getHelp(player, "time");
        }
View Full Code Here

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

    private void cmdblock(CommandBlock block, String[] args) {
        World dim = block.getWorld();

        if (args[1].equalsIgnoreCase("check")) {
            if (!block.hasPermission("canary.command.weather.check")) {
                return;
            }
            String weather = dim.isRaining() ? dim.isThundering() ? "weather thundering" : "weather raining" : "weather sunny";
            block.message(Colors.YELLOW + Translator.translateAndFormat("weather check", weather));
            return;
        }
        if (args[1].equalsIgnoreCase("rain")) {
            if (!block.hasPermission("canary.command.weather.set")) {
                return;
            }
            dim.setRaining(true);
            dim.setRainTime(new Random().nextInt(15000));
            block.message(Colors.YELLOW + Translator.translate("weather set rain"));
            return;
        }
        if (args[1].equalsIgnoreCase("thunder")) {
            if (!block.hasPermission("canary.command.weather.set")) {
                return;
            }
            dim.setThundering(true);
            dim.setThunderTime(new Random().nextInt(15000));
            block.message(Colors.YELLOW + Translator.translate("weather set thunder"));
            return;
        }
        if (args[1].matches("clear")) {
            if (!block.hasPermission("canary.command.weather.set")) {
                return;
            }
            dim.setRaining(false);
            dim.setRainTime(0);
            dim.setThundering(false);
            dim.setThunderTime(0);
            block.message(Colors.YELLOW + Translator.translate("weather set clear"));
        }
        else {
            Canary.help().getHelp(block, "weather");
        }
View Full Code Here

            Canary.help().getHelp(block, "weather");
        }
    }

    private void player(Player player, String[] args) {
        World dim = player.getWorld();

        if (args[1].equalsIgnoreCase("check")) {
            if (!player.hasPermission("canary.command.weather.check")) {
                return;
            }
            String weather = dim.isRaining() ? dim.isThundering() ? "weather thundering" : "weather raining" : "weather sunny";
            player.message(Colors.YELLOW + Translator.translateAndFormat("weather check", weather));
            return;
        }
        if (args[1].equalsIgnoreCase("rain")) {
            if (!player.hasPermission("canary.command.weather.set")) {
                return;
            }
            dim.setRaining(true);
            dim.setRainTime(new Random().nextInt(15000));
            player.message(Colors.YELLOW + Translator.translate("weather set rain"));
            return;
        }
        if (args[1].equalsIgnoreCase("thunder")) {
            if (!player.hasPermission("canary.command.weather.set")) {
                return;
            }
            dim.setThundering(true);
            dim.setThunderTime(new Random().nextInt(15000));
            player.message(Colors.YELLOW + Translator.translate("weather set thunder"));
            return;
        }
        if (args[1].matches("clear")) {
            if (!player.hasPermission("canary.command.weather.set")) {
                return;
            }
            dim.setRaining(false);
            dim.setRainTime(0);
            dim.setThundering(false);
            dim.setThunderTime(0);
            player.message(Colors.YELLOW + Translator.translate("weather set clear"));
        }
        else {
            Canary.help().getHelp(player, "weather");
        }
View Full Code Here

TOP

Related Classes of net.canarymod.api.world.World

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.