Пример #1
0
  public void saveFileData(String type, LivingPet pi) {
    clearFileData(type, pi);
    try {
      String oName = pi.getOwner().getName();
      String path = type + "." + oName;
      PetType petType = pi.getPetType();

      ec.getPetConfig().set(path + ".pet.type", petType.toString());
      ec.getPetConfig().set(path + ".pet.name", pi.getNameToString());

      for (PetData pd : pi.getActiveData()) {
        ec.getPetConfig().set(path + ".pet.data." + pd.toString().toLowerCase(), true);
      }

      if (pi.getMount() != null) {
        PetType mountType = pi.getMount().getPetType();

        ec.getPetConfig().set(path + ".mount.type", mountType.toString());
        ec.getPetConfig().set(path + ".mount.name", pi.getMount().getNameToString());
        for (PetData pd : pi.getMount().getActiveData()) {
          ec.getPetConfig().set(path + ".mount.data." + pd.toString().toLowerCase(), true);
        }
      }
    } catch (Exception e) {
    }
    ec.getPetConfig().saveConfig();
  }
Пример #2
0
 public LivingPet createPet(
     Player owner, PetType petType, PetType mountType, boolean sendFailMessage) {
   removePets(owner);
   if (!WorldUtil.allowPets(owner.getLocation())) {
     if (sendFailMessage) {
       Lang.sendTo(
           owner,
           Lang.PETS_DISABLED_HERE
               .toString()
               .replace("%world%", StringUtil.capitalise(owner.getWorld().getName())));
     }
     return null;
   }
   if (!ec.options.allowPetType(petType)) {
     if (sendFailMessage) {
       Lang.sendTo(
           owner,
           Lang.PET_TYPE_DISABLED
               .toString()
               .replace("%type%", StringUtil.capitalise(petType.toString())));
     }
     return null;
   }
   LivingPet pi = petType.getNewPetInstance(owner, petType);
   // Pet pi = new Pet(owner, petType);
   pi.createMount(mountType, true);
   forceAllValidData(pi);
   pets.add(pi);
   // saveFileData("autosave", pi);
   // ec.SPH.saveToDatabase(pi, false);
   return pi;
 }
Пример #3
0
  public void saveFileData(
      String type, String name, UnorganisedPetData UPD, UnorganisedPetData UMD) {
    clearFileData(type, name);
    PetType pt = UPD.petType;
    PetData[] data = UPD.petDataList.toArray(new PetData[UPD.petDataList.size()]);
    String petName = UPD.petName;
    if (UPD.petName == null || UPD.petName.equalsIgnoreCase("")) {
      petName = pt.getDefaultName(name);
    }
    PetType mountType = UMD.petType;
    PetData[] mountData = UMD.petDataList.toArray(new PetData[UMD.petDataList.size()]);
    String mountName = UMD.petName;
    if (UMD.petName == null || UMD.petName.equalsIgnoreCase("")) {
      mountName = pt.getDefaultName(name);
    }

    String path = type + "." + name;
    try {
      ec.getPetConfig().set(path + ".pet.type", pt.toString());
      ec.getPetConfig().set(path + ".pet.name", petName);

      for (PetData pd : data) {
        ec.getPetConfig().set(path + ".pet.data." + pd.toString().toLowerCase(), true);
      }

      if (mountData != null && mountType != null) {
        ec.getPetConfig().set(path + ".mount.type", mountType.toString());
        ec.getPetConfig().set(path + ".mount.name", mountName);
        for (PetData pd : mountData) {
          ec.getPetConfig().set(path + ".mount.data." + pd.toString().toLowerCase(), true);
        }
      }
    } catch (Exception e) {
    }
    ec.getPetConfig().saveConfig();
  }
Пример #4
0
  public void saveFileData(String type, String name, UnorganisedPetData UPD) {
    clearFileData(type, name);
    PetType pt = UPD.petType;
    PetData[] data = UPD.petDataList.toArray(new PetData[UPD.petDataList.size()]);
    String petName = UPD.petName;

    String path = type + "." + name;
    try {
      ec.getPetConfig().set(path + ".pet.type", pt.toString());
      ec.getPetConfig().set(path + ".pet.name", petName);

      for (PetData pd : data) {
        ec.getPetConfig().set(path + ".pet.data." + pd.toString().toLowerCase(), true);
      }

    } catch (Exception e) {
    }
    ec.getPetConfig().saveConfig();
  }