Advertisement
Brord

Mobs getting

Feb 13th, 2013
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.45 KB | None | 0 0
  1.     /**
  2.      * Spawns all the mobs for this isntance
  3.      */
  4.     public void spawnMobs(){
  5.         Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(InstancesBase.plugin, new
  6.         Runnable(){
  7.             @Override
  8.             public void run() {
  9.                 List<String> spawns = getSpawns(getType());
  10.                 for (String type : spawns){
  11.                     String[] data = spawns.get(spawns.indexOf(type)).split(":");
  12.                    
  13.                     EntityType mob = EntityType.fromName(data[0]);
  14.                    
  15.                    
  16.                     World world = Bukkit.getServer().getWorld(instanceWorld);
  17.                     double x = Double.parseDouble(data[1])+(getType().getID()*64);
  18.                     double y = Double.parseDouble(data[2]);
  19.                     double z = Double.parseDouble(data[3])+(getID()*64);
  20.                    
  21.                     Location loc = new Location(world, x, y, z);
  22.                     Entity spawnedMob = world.spawnEntity(loc, mob);
  23.                    
  24.                     spawnedMob.setMetadata("instanceMob", new
  25.                         FixedMetadataValue(InstancesBase.plugin, getID()));
  26.                     addMob(spawnedMob.getUniqueId());
  27.                    
  28.                 }
  29.             }
  30.         }, 20l);
  31.        
  32.     }
  33.  
  34.     /**
  35.      * Gets the entityType + spawn location
  36.      * @param type instanceType to get hte thigns for
  37.      * @return Hashmap key = EntityType, value = location
  38.      */
  39.     public List<String> getSpawns(instanceType type){
  40.         List<String> mobs = new LinkedList<String>();
  41.         for (String instanceSpawn : spawns){
  42.             String[] data = instanceSpawn.split(":");
  43.             if (data[0].equals(type.toString())){
  44.                 mobs.add(data[1] + ":" + data[2] + ":" + data[3] + ":" + data[4]);
  45.             }
  46.         }
  47.         return mobs;
  48.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement