Brord icon

Mobs getting

Brord | PRO | 02/13/13 10:51:13 PM UTC | 0 ⭐ | 431 👁️ | Never ⏰ | []
Java 5 |

0 B

|

None

|

0 👍

/

0 👎

    /**
     * Spawns all the mobs for this isntance
     */
    public void spawnMobs(){
        Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(InstancesBase.plugin, new 
        Runnable(){
            @Override
            public void run() {
                List<String> spawns = getSpawns(getType());
                for (String type : spawns){
                    String[] data = spawns.get(spawns.indexOf(type)).split(":");
                    
                    EntityType mob = EntityType.fromName(data[0]);
                    
                    
                    World world = Bukkit.getServer().getWorld(instanceWorld);
                    double x = Double.parseDouble(data[1])+(getType().getID()*64);
                    double y = Double.parseDouble(data[2]);
                    double z = Double.parseDouble(data[3])+(getID()*64);
                    
                    Location loc = new Location(world, x, y, z);
                    Entity spawnedMob = world.spawnEntity(loc, mob);
                    
                    spawnedMob.setMetadata("instanceMob", new 
                        FixedMetadataValue(InstancesBase.plugin, getID()));
                    addMob(spawnedMob.getUniqueId());
                    
                }
            }
        }, 20l);
        
    }
 
    /**
     * Gets the entityType + spawn location
     * @param type instanceType to get hte thigns for
     * @return Hashmap key = EntityType, value = location
     */
    public List<String> getSpawns(instanceType type){
        List<String> mobs = new LinkedList<String>();
        for (String instanceSpawn : spawns){
            String[] data = instanceSpawn.split(":");
            if (data[0].equals(type.toString())){
                mobs.add(data[1] + ":" + data[2] + ":" + data[3] + ":" + data[4]);
            }
        }
        return mobs;
    }

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎