Package net.canarymod

Examples of net.canarymod.LineTracer


        caller.notice(Translator.translate("mobspawn console"));
    }

    private void player(Player player, String[] args) {
        if (args.length == 2) {
            LineTracer tracer = new LineTracer(player);
            Block b = tracer.getTargetBlock();
            // Spawn a mob with Rider
            if (b != null) {
                b.setY(b.getY() + 1);
                try {
                    Entity mob = Canary.factory().getEntityFactory().newEntity(EntityType.valueOf(args[1].toUpperCase()), b.getLocation());
                    if (mob.spawn()) {
                        player.message(Colors.YELLOW + Translator.translateAndFormat("mobspawn spawned", args[1]));
                    }
                    else {
                        player.notice("mobspawn failed");
                    }
                }
                catch (IllegalArgumentException e) {
                    player.notice("mobspawn failed");
                }
            }
            else {
                player.notice("mobspawn failed");
            }
        }

        if (args.length == 3) {
            if (args[2].matches("^[0-9]+$")) {
                // Spawn X amount of entities
                int amount = Integer.parseInt(args[2]);
                LineTracer tracer = new LineTracer(player);
                Block b = tracer.getTargetBlock();
                if (b == null) {
                    player.notice(Translator.translate("mobspawn failed"));
                    return;
                }
                b.setY(b.getY() + 1);
                boolean spawnSuccess = true;
                for (int i = 0; i < amount; ++i) {
                    try {
                        Entity e = Canary.factory().getEntityFactory().newEntity(EntityType.valueOf(args[1].toUpperCase()), b.getLocation());
                        spawnSuccess &= e.spawn();
                    }
                    catch (IllegalArgumentException e) {
                        player.notice(Translator.translate("mobspawn failed"));
                    }
                }
                if (spawnSuccess) {
                    player.message(Colors.YELLOW + Translator.translateAndFormat("mobspawn spawned", args[1]));
                }
                else {
                    player.notice(Translator.translate("mobspawn failed"));
                }
            }
            else {
                LineTracer tracer = new LineTracer(player);
                Block b = tracer.getTargetBlock();
                if (b == null) {
                    player.notice(Translator.translate("mobspawn failed"));
                    return;
                }
                b.setY(b.getY() + 1);
                // Spawn a mob with Rider
                try {
                    Entity mob = Canary.factory().getEntityFactory().newEntity(EntityType.valueOf(args[1].toUpperCase()), b.getLocation());
                    Entity rider = Canary.factory().getEntityFactory().newEntity(EntityType.valueOf(args[2].toUpperCase()));
                    mob.spawn(rider);
                    player.message(Colors.YELLOW + Translator.translateAndFormat("mobspawn spawned rider", args[1], args[2]));
                }
                catch (IllegalArgumentException e) {
                    player.notice(Translator.translate("mobspawn failed"));
                }
            }
        }
        if (args.length == 4) {
            if (!args[3].matches("^[0-9]+$")) {
                player.notice(Translator.translate("mobspawn failed"));
                Canary.help().getHelp(player, "mobspawn");
                return;
            }
            // Spawn X amount of entities
            int amount = Integer.parseInt(args[3]);
            LineTracer tracer = new LineTracer(player);
            Block b = tracer.getTargetBlock();
            if (b == null) {
                player.notice(Translator.translate("mobspawn failed"));
                return;
            }
            b.setY(b.getY() + 1);
View Full Code Here

TOP

Related Classes of net.canarymod.LineTracer

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.