示例#1
0
  // Force all data specified in config file and notify player.
  public void forceAllValidData(LivingPet pi) {
    ArrayList<PetData> tempData = new ArrayList<PetData>();
    for (PetData data : PetData.values()) {
      if (ec.options.forceData(pi.getPetType(), data)) {
        tempData.add(data);
      }
    }
    setData(pi, tempData.toArray(new PetData[tempData.size()]), true);

    ArrayList<PetData> tempMountData = new ArrayList<PetData>();
    if (pi.getMount() != null) {
      for (PetData data : PetData.values()) {
        if (ec.options.forceData(pi.getPetType(), data)) {
          tempMountData.add(data);
        }
      }
      setData(pi.getMount(), tempMountData.toArray(new PetData[tempData.size()]), true);
    }

    if ((Boolean) ec.options.getConfigOption("sendForceMessage", true)) {
      String dataToString = " ";
      if (!tempMountData.isEmpty()) {
        dataToString = StringUtil.dataToString(tempData);
      } else {
        dataToString = StringUtil.dataToString(tempData, tempMountData);
      }
      if (dataToString != " ") {
        Lang.sendTo(
            pi.getOwner(), Lang.DATA_FORCE_MESSAGE.toString().replace("%data%", dataToString));
      }
    }
  }
示例#2
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();
  }
示例#3
0
 public LivingPet getPet(Entity pet) {
   for (LivingPet pi : pets) {
     if (pi.getEntityPet().equals(pet) || pi.getMount().getEntityPet().equals(pet)) {
       return pi;
     }
     if (pi.getCraftPet().equals(pet) || pi.getMount().getCraftPet().equals(pet)) {
       return pi;
     }
   }
   return null;
 }