Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void loadEntities() {
- this.checkFile(new File(this.getDataFolder(), "npcs.yml"));
- YamlConfiguration c = YamlConfiguration.loadConfiguration(new File(this.getDataFolder(), "npcs.yml"));
- for(String npc : c.getConfigurationSection("").getKeys(false)){
- int entityID = Integer.parseInt(npc);
- World w = this.getServer().getWorld(c.getString(npc + ".location.world"));
- if(w == null){
- //TODO
- }
- Location loc = new Location(w,
- c.getDouble(npc + ".location.x"),
- c.getDouble(npc + ".location.y"),
- c.getDouble(npc + ".location.z"));
- loc.setPitch(c.getLong(npc + ".location.pitch"));
- loc.setYaw(c.getLong(npc + ".location.yaw"));
- try {
- String name = c.getString(npc + ".name");
- RemoteEntity ent;
- if(name == null){
- ent = this.getEntityManager().createEntity(RemoteEntityType.valueOf(c.getString(npc + ".type")), loc);
- }else{
- ent = this.getEntityManager().createNamedEntity(RemoteEntityType.valueOf(c.getString(npc + ".type")), loc, name);
- }
- if(c.getString(npc + ".name") != null){
- ((Nameable)ent).setName(c.getString(npc + ".name"));
- }
- NPCWrapper wrapper = this.getNPCManager().getNPCWrapper(entityID);
- for(String s : c.getStringList(npc + ".texts")){
- wrapper.addText(s);
- }
- ent.setMaxHealth(c.getInt(npc + ".maxhealth"));
- ent.setPushable(c.getBoolean(npc + ".pushable"));
- ent.setSpeed(c.getLong(npc + ".speed"));
- ent.setStationary(c.getBoolean(npc + ".stationary"));
- this.getEntityManager().removeEntity(ent.getID()); //remove the one the LIB put in the hashmap
- this.getEntityManager().addRemoteEntity(entityID, ent); //add the one I want in the hashmap
- } catch (NoNameException ex) {
- Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement