Package org.bukkit

Examples of org.bukkit.Location


    }
   
    private void setPoint(RegionPoint point, Location l) {
        // Lower and upper locations
        RegionPoint r1, r2;
        Location lower, upper;

        /* Initialize the bounds.
         *
         * To allow users to set a region point without paying attention to
         * the 'fixed' points, we continuously store the previously stored
         * location for the given point. These location references are only
         * ever overwritten when using the set commands, and remain fully
         * decoupled from the 'fixed' points.
         *
         * Effectively, the config-file and region store 'fixed' locations
         * that allow fast membership tests, but the region also stores the
         * 'unfixed' locations for a more intuitive setup process.
         */
        switch (point) {
            case P1:
                lastP1 = l.clone();
                lower = lastP1.clone();
                upper = (lastP2 != null ? lastP2.clone() : p2);
                r1 = RegionPoint.P1; r2 = RegionPoint.P2;
                break;
            case P2:
                lastP2 = l.clone();
                lower = (lastP1 != null ? lastP1.clone() : p1);
                upper = lastP2.clone();
                r1 = RegionPoint.P1; r2 = RegionPoint.P2;
                break;
            case L1:
                lastL1 = l.clone();
                lower = lastL1.clone();
                upper = (lastL2 != null ? lastL2.clone() : l2);
                r1 = RegionPoint.L1; r2 = RegionPoint.L2;
                break;
            case L2:
                lastL2 = l.clone();
                lower = (lastL1 != null ? lastL1.clone() : l1);
                upper = lastL2.clone();
                r1 = RegionPoint.L1; r2 = RegionPoint.L2;
                break;
            default:
                lower = upper = null;
                r1    = r2    = null;
        }
       
        // Min-max if both locations are non-null
        if (lower != null && upper != null) {
            double tmp;
            if (lower.getX() > upper.getX()) {
                tmp = lower.getX();
                lower.setX(upper.getX());
                upper.setX(tmp);
            }
            if (lower.getY() > upper.getY()) {
                tmp = lower.getY();
                lower.setY(upper.getY());
                upper.setY(tmp);
            }
            if (lower.getZ() > upper.getZ()) {
                tmp = lower.getZ();
                lower.setZ(upper.getZ());
                upper.setZ(tmp);
            }
        }
       
        // Set the coords and save
View Full Code Here


        }

        // Notify the player
        Messenger.tell(p, "The following points cover your location:");
        for (Map.Entry<String,Location> entry : map.entrySet()) {
            Location l = entry.getValue();
            String coords = l.getBlockX() + "," + l.getBlockY() + "," + l.getBlockZ();
            p.sendMessage(ChatColor.AQUA + entry.getKey() + ChatColor.WHITE + " :  " + coords);
        }

        // And show the blocks
        showBlocks(p, map.values());
View Full Code Here

                            return;
                        }

                        // Send block "restore" events.
                        for (Map.Entry<Location,BlockState> entry : blocks.entrySet()) {
                            Location l   = entry.getKey();
                            BlockState b = entry.getValue();
                            int id       = b.getTypeId();
                            byte data    = b.getRawData();

                            p.sendBlockChange(l, id, data);
View Full Code Here

                if (monsterManager.getMonsters().size() >= monsterLimit) {
                    return;
                }

                // Grab a spawnpoint
                Location spawnpoint = spawnpoints.get(index % totalSpawnpoints);

                // Spawn the monster
                LivingEntity e = entry.getKey().spawn(arena, world, spawnpoint);

                // Add it to the arena.
View Full Code Here

        int lz1 = z1;
        int lz2 = z1 + 6;
       
        // Save the precious patch
        HashMap<EntityPosition,Integer> preciousPatch = new HashMap<EntityPosition,Integer>();
        Location lo;
        int id;
        for (int i = x1; i <= x2; i++)
        {
            for (int j = ly1; j <= y2; j++)
            {
                for (int k = z1; k <= z2; k++)
                {
                    lo = world.getBlockAt(i,j,k).getLocation();
                    id = world.getBlockAt(i,j,k).getTypeId();
                    preciousPatch.put(new EntityPosition(lo),id);
                }
            }
        }
        try
        {
            new File("plugins" + sep + "MobArena" + sep + "agbackup").mkdir();
            FileOutputStream fos = new FileOutputStream("plugins" + sep + "MobArena" + sep + "agbackup" + sep + name + ".tmp");
            ObjectOutputStream oos = new ObjectOutputStream(fos);
            oos.writeObject(preciousPatch);
            oos.close();
        }
        catch (Exception e)
        {
            e.printStackTrace();
            Messenger.warning("Couldn't create backup file. Aborting auto-generate...");
            return false;
        }
       
        // Build some monster walls.
        for (int i = x1; i <= x2; i++)
        {
            for (int j = y1; j <= y2; j++)
            {
                world.getBlockAt(i,j,z1).setTypeId(24);
                world.getBlockAt(i,j,z2).setTypeId(24);
            }
        }
        for (int k = z1; k <= z2; k++)
        {
            for (int j = y1; j <= y2; j++)
            {
                world.getBlockAt(x1,j,k).setTypeId(24);
                world.getBlockAt(x2,j,k).setTypeId(24);
            }
        }
       
        // Add some hippie light.
        for (int i = x1; i <= x2; i++)
        {
            world.getBlockAt(i,y1+2,z1).setTypeId(89);
            world.getBlockAt(i,y1+2,z2).setTypeId(89);
        }
        for (int k = z1; k <= z2; k++)
        {
            world.getBlockAt(x1,y1+2,k).setTypeId(89);
            world.getBlockAt(x2,y1+2,k).setTypeId(89);
        }
       
        // Build a monster floor, and some Obsidian foundation.
        for (int i = x1; i <= x2; i++)
        {
            for (int k = z1; k <= z2; k++)
            {
                world.getBlockAt(i,y1,k).setTypeId(24);
                world.getBlockAt(i,y1-1,k).setTypeId(49);
            }
        }
       
        // Make a hippie roof.
        for (int i = x1; i <= x2; i++)
        {
            for (int k = z1; k <= z2; k++)
                world.getBlockAt(i,y2,k).setTypeId(20);
        }
       
        // Monster bulldoze
        for (int i = x1+1; i < x2; i++)
            for (int j = y1+1; j < y2; j++)
                for (int k = z1+1; k < z2; k++)
                    world.getBlockAt(i,j,k).setTypeId(0);
       
        // Build a hippie lobby
        for (int i = lx1; i <= lx2; i++) // Walls
        {
            for (int j = ly1; j <= ly2; j++)
            {
                world.getBlockAt(i,j,lz1).setTypeId(24);
                world.getBlockAt(i,j,lz2).setTypeId(24);
            }
        }
        for (int k = lz1; k <= lz2; k++) // Walls
        {
            for (int j = ly1; j <= ly2; j++)
            {
                world.getBlockAt(lx1,j,k).setTypeId(24);
                world.getBlockAt(lx2,j,k).setTypeId(24);
            }
        }
        for (int k = lz1; k <= lz2; k++) // Lights
        {
            world.getBlockAt(lx1,ly1+2,k).setTypeId(89);
            world.getBlockAt(lx2,ly1+2,k).setTypeId(89);
            world.getBlockAt(lx1,ly1+3,k).setTypeId(89);
            world.getBlockAt(lx2,ly1+3,k).setTypeId(89);
        }
        for (int i = lx1; i <= lx2; i++) // Floor
        {
            for (int k = lz1; k <= lz2; k++)
                world.getBlockAt(i,ly1,k).setTypeId(24);
        }
        for (int i = x1+1; i < lx2; i++) // Bulldoze
            for (int j = ly1+1; j <= ly2; j++)
                for (int k = lz1+1; k < lz2; k++)
                    world.getBlockAt(i,j,k).setTypeId(0);
       
        // Place the hippie signs
        //Iterator<String> iterator = am.getClasses().iterator();
        Iterator<String> iterator = am.getClasses().keySet().iterator();
        for (int i = lx1+2; i <= lx2-2; i++) // Signs
        {
            world.getBlockAt(i,ly1+1,lz2-1).setTypeIdAndData(63, (byte)0x8, false);
            Sign sign = (Sign) world.getBlockAt(i,ly1+1,lz2-1).getState();
            sign.setLine(0, TextUtils.camelCase((String)iterator.next()));
            sign.update();
        }
        world.getBlockAt(lx2-2,ly1+1,lz1+2).setType(Material.IRON_BLOCK);
       
        // Set up the monster points.
        ArenaRegion region = arena.getRegion();
        region.set("p1", new Location(world, x1, ly1, z1));
        region.set("p2", new Location(world, x2, y2+1, z2));
       
        region.set("arena", new Location(world, loc.getX(), y1+1, loc.getZ()));
        region.set("lobby", new Location(world, x1+2, ly1+1, z1+2));
        region.set("spectator", new Location(world, loc.getX(), y2+1, loc.getZ()));
       
        region.addSpawn("s1", new Location(world, x1+3, y1+2, z1+3));
        region.addSpawn("s2", new Location(world, x1+3, y1+2, z2-3));
        region.addSpawn("s3", new Location(world, x2-3, y1+2, z1+3));
        region.addSpawn("s4", new Location(world, x2-3, y1+2, z2-3));
        region.save();
       
        am.reloadConfig();
        return true;
    }
View Full Code Here

        expandL1(amount, amount);
        expandL2(amount, amount);
    }

    private void setSaveReload(ConfigurationSection section, String key, World w, double x, double y, double z) {
        Location loc = new Location(w, x, y, z);
        setLocation(section, key, loc);
        save();
        reloadRegion();
    }
View Full Code Here

    }

    @Override
    public void movePlayerToEntry(Player p)
    {
        Location entry = playerData.get(p).entry();
        if (entry == null || p.isDead()) return;
       
        p.teleport(entry);
        timeStrategy.resetPlayerTime(p);
       
View Full Code Here

    @Override
    public void execute(Arena arena, MABoss boss) {
        LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), RANDOM);
        if (target == null) return;

        Location bLoc = boss.getEntity().getLocation();
        Location loc  = target.getLocation();
        Vector v      = new Vector(loc.getX() - bLoc.getX(), 0, loc.getZ() - bLoc.getZ());
       
        target.setVelocity(v.normalize().setY(0.8));
    }
View Full Code Here

     */
    private final int RADIUS = 5;
   
    @Override
    public void execute(Arena arena, MABoss boss) {
        Location bLoc = boss.getEntity().getLocation();
       
        for (Player p : AbilityUtils.getNearbyPlayers(arena, boss.getEntity(), RADIUS)) {
            p.teleport(bLoc);
        }
    }
View Full Code Here

    @Override
    public void execute(Arena arena, MABoss boss) {
        LivingEntity target = AbilityUtils.getTarget(arena, boss.getEntity(), RANDOM);
        if (target == null) return;
       
        Location loc  = target.getLocation();
        Location bLoc = boss.getEntity().getLocation();
        Vector v      = new Vector(bLoc.getX() - loc.getX(), 0, bLoc.getZ() - loc.getZ());
       
        double a = Math.abs(bLoc.getX() - loc.getX());
        double b = Math.abs(bLoc.getZ() - loc.getZ());
        double c = Math.sqrt((a*a + b*b));
       
        target.setVelocity(v.normalize().multiply(c*0.3).setY(0.8));
    }
View Full Code Here

TOP

Related Classes of org.bukkit.Location

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.