if (!Config.getInstance().getEntityModsEnabled()) {
return;
}
File entityFile = new File(mcMMO.p.getDataFolder(), "mods" + File.separator + "entities.default.yml");
YamlConfiguration entitiesFile = YamlConfiguration.loadConfiguration(entityFile);
String entityName = entity.getType().toString();
String sanitizedEntityName = entityName.replace(".", "_");
if (entitiesFile.getKeys(false).contains(sanitizedEntityName)) {
return;
}
entitiesFile.set(sanitizedEntityName + ".XP_Multiplier", 1.0D);
entitiesFile.set(sanitizedEntityName + ".Tameable", false);
entitiesFile.set(sanitizedEntityName + ".Taming_XP", 0);
entitiesFile.set(sanitizedEntityName + ".CanBeSummoned", false);
entitiesFile.set(sanitizedEntityName + ".COTW_Material", "");
entitiesFile.set(sanitizedEntityName + ".COTW_Material_Data", 0);
entitiesFile.set(sanitizedEntityName + ".COTW_Material_Amount", 0);
String className = "";
try {
className = ((Class<?>) entity.getClass().getDeclaredField("entityClass").get(entity)).getName();
}
catch (Exception e) {
if (e instanceof NoSuchFieldException || e instanceof IllegalArgumentException || e instanceof IllegalAccessException) {
className = entity.getClass().getName();
}
else {
e.printStackTrace();
}
}
CustomEntity customEntity = new CustomEntity(1.0D, false, 0, false, null, 0);
customEntityTypeMap.put(entityName, customEntity);
customEntityClassMap.put(className, customEntity);
try {
entitiesFile.save(entityFile);
mcMMO.p.debug(entity.getType().toString() + " was added to the custom entities file!");
}
catch (Exception e) {
e.printStackTrace();
}