Пример #1
0
 public void updateFileData(String type, LivingPet pet, ArrayList<PetData> list, boolean b) {
   ec.SPH.updateDatabase(pet.getOwner(), list, b, pet.isMount());
   String w = pet.getOwner().getWorld().getName();
   String path = type + "." + w + "." + pet.getOwner().getName();
   for (PetData pd : list) {
     ec.getPetConfig().set(path + ".pet.data." + pd.toString().toLowerCase(), b);
   }
   ec.getPetConfig().saveConfig();
 }
Пример #2
0
 public void removeAllPets() {
   Iterator<LivingPet> i = pets.listIterator();
   while (i.hasNext()) {
     LivingPet p = i.next();
     saveFileData("autosave", p);
     ec.SPH.saveToDatabase(p, false);
     p.removePet();
     i.remove();
   }
 }
Пример #3
0
 public LivingPet loadPets(
     Player p, boolean findDefault, boolean sendMessage, boolean checkWorldOverride) {
   EchoPet ec = EchoPet.getPluginInstance();
   if (ec.options.sqlOverride()) {
     LivingPet pet = ec.SPH.createPetFromDatabase(p);
     if (pet == null) {
       return null;
     } else {
       if (sendMessage) {
         Lang.sendTo(
             p,
             Lang.DATABASE_PET_LOAD.toString().replace("%petname%", pet.getPetName().toString()));
       }
     }
     return pet;
   } else if (ec.getPetConfig().get("default." + p.getName() + ".pet.type") != null
       && findDefault) {
     LivingPet pi = ec.PH.createPetFromFile("default", p);
     if (pi == null) {
       return null;
     } else {
       if (sendMessage) {
         Lang.sendTo(
             p, Lang.DEFAULT_PET_LOAD.toString().replace("%petname%", pi.getPetName().toString()));
       }
     }
     return pi;
   } else if ((checkWorldOverride
           && (Boolean) ec.options.getConfigOption("multiworldLoadOverride", true))
       || (Boolean) ec.options.getConfigOption("loadSavedPets", true)) {
     if (ec.getPetConfig().get("autosave." + p.getName() + ".pet.type") != null) {
       LivingPet pi = ec.PH.createPetFromFile("autosave", p);
       if (pi == null) {
         return null;
       } else {
         if (sendMessage) {
           Lang.sendTo(
               p,
               Lang.AUTOSAVE_PET_LOAD.toString().replace("%petname%", pi.getPetName().toString()));
         }
       }
       return pi;
     }
   }
   return null;
 }