SHARE
TWEET

Untitled

a guest Nov 20th, 2012 37 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. protected void loadEntities() {
  2.         this.checkFile(new File(this.getDataFolder(), "npcs.yml"));
  3.         YamlConfiguration c = YamlConfiguration.loadConfiguration(new File(this.getDataFolder(), "npcs.yml"));
  4.         for(String npc : c.getConfigurationSection("").getKeys(false)){
  5.             int entityID = Integer.parseInt(npc);
  6.             World w = this.getServer().getWorld(c.getString(npc + ".location.world"));
  7.             if(w == null){
  8.                 //TODO
  9.             }
  10.             Location loc = new Location(w,
  11.                     c.getDouble(npc + ".location.x"),
  12.                     c.getDouble(npc + ".location.y"),
  13.                     c.getDouble(npc + ".location.z"));
  14.             loc.setPitch(c.getLong(npc + ".location.pitch"));
  15.             loc.setYaw(c.getLong(npc + ".location.yaw"));
  16.             try {
  17.                 String name = c.getString(npc + ".name");
  18.                 RemoteEntity ent;
  19.                 if(name == null){
  20.                     ent = this.getEntityManager().createEntity(RemoteEntityType.valueOf(c.getString(npc + ".type")), loc);
  21.                 }else{
  22.                     ent = this.getEntityManager().createNamedEntity(RemoteEntityType.valueOf(c.getString(npc + ".type")), loc, name);
  23.                 }
  24.                 if(c.getString(npc + ".name") != null){
  25.                     ((Nameable)ent).setName(c.getString(npc + ".name"));
  26.                 }
  27.                 NPCWrapper wrapper = this.getNPCManager().getNPCWrapper(entityID);
  28.                 for(String s : c.getStringList(npc + ".texts")){
  29.                     wrapper.addText(s);
  30.                 }
  31.                 ent.setMaxHealth(c.getInt(npc + ".maxhealth"));
  32.                 ent.setPushable(c.getBoolean(npc + ".pushable"));
  33.                 ent.setSpeed(c.getLong(npc + ".speed"));
  34.                 ent.setStationary(c.getBoolean(npc + ".stationary"));
  35.                 this.getEntityManager().removeEntity(ent.getID()); //remove the one the LIB put in the hashmap
  36.                 this.getEntityManager().addRemoteEntity(entityID, ent); //add the one I want in the hashmap
  37.             } catch (NoNameException ex) {
  38.                 Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
  39.             }
  40.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top