コード例 #1
0
  private void saveToBackend(Lot lot) {

    UUID uuid = lot.getUuid();
    String uuidString = uuid.toString();
    ItemStack item = lot.getItem();
    boolean started = lot.isStarted();
    double price = lot.getPrice();
    String lastBidPlayerName = lot.getLastBidPlayerName();
    UUID lastBidPlayerUuid = lot.getLastBidPlayerUuid();
    double lastBidPrice = lot.getLastBidPrice();
    double minimumIncrement = lot.getMinimumIncrement();
    long preserveTimeExpire = lot.getPreserveTimeExpire();
    long auctionDurationExpire = lot.getAuctionDurationExpire();

    String sectionPath = "lots." + uuidString;
    ConfigurationSection singleLotSection =
        data.getYamlConfig().getConfigurationSection(sectionPath);
    if (null == singleLotSection) {
      singleLotSection = data.getYamlConfig().createSection(sectionPath);
    }

    singleLotSection.set("item", item);
    singleLotSection.set("started", started);
    singleLotSection.set("price", price);
    singleLotSection.set("lastBidPlayerName", lastBidPlayerName);
    singleLotSection.set(
        "lastBidPlayerUuid", null == lastBidPlayerUuid ? null : lastBidPlayerUuid.toString());
    singleLotSection.set("lastBidPrice", lastBidPrice);
    singleLotSection.set("minimumIncrement", minimumIncrement);
    singleLotSection.set("preserveTimeExpire", preserveTimeExpire);
    singleLotSection.set("auctionDurationExpire", auctionDurationExpire);
  }
コード例 #2
0
 public void addDeposit(Lot lot, Player p, double deposit) {
   String depositPath =
       new StringBuilder(86)
           .append("lots.")
           .append(lot.getUuid())
           .append(".deposit.")
           .append(p.getUniqueId())
           .toString();
   data.set(depositPath, data.getYamlConfig().getDouble(depositPath, 0) + deposit);
 }
コード例 #3
0
 public double getDepositInVault(UUID uuid) {
   String path =
       new StringBuilder(51)
           .append("vaults.")
           .append(uuid.toString())
           .append('.')
           .append("deposit")
           .toString();
   return data.getYamlConfig().getDouble(path, 0);
 }
コード例 #4
0
 public long getLastBid(Player p, Lot lot) {
   String lastBidPath =
       new StringBuilder(90)
           .append("lots.")
           .append(lot.getUuid())
           .append(".bid.lastBid.")
           .append(p.getUniqueId())
           .toString();
   return data.getYamlConfig().getLong(lastBidPath);
 }
コード例 #5
0
 public void addDepositToVault(UUID uuid, double deposit) {
   String path =
       new StringBuilder(51)
           .append("vaults.")
           .append(uuid.toString())
           .append('.')
           .append("deposit")
           .toString();
   double original = data.getYamlConfig().getDouble(path, 0);
   data.set(path, original + deposit);
 }
コード例 #6
0
 public void removeDepositFromVault(UUID uuid, double deposit) {
   String path =
       new StringBuilder(51)
           .append("vaults.")
           .append(uuid.toString())
           .append('.')
           .append("deposit")
           .toString();
   double original = data.getYamlConfig().getDouble(path, 0);
   double newDeposit = original - deposit;
   if (newDeposit <= 0) {
     data.set(path, null);
   } else {
     data.set(path, newDeposit);
   }
 }
コード例 #7
0
  private void save() {

    for (Lot lot : lots) {
      this.saveToBackend(lot);
    }

    // Vaults section cleanup
    ConfigurationSection vaultsSection = data.getYamlConfig().getConfigurationSection("vaults");
    if (vaultsSection != null) {
      for (Entry<String, Object> e : vaultsSection.getValues(false).entrySet()) {

        Object v = e.getValue();
        if (!(v instanceof ConfigurationSection)) continue;

        ConfigurationSection singleVaultSection = (ConfigurationSection) v;
        int size = singleVaultSection.getKeys(false).size();

        if (size == 0 || (size == 1 && singleVaultSection.getInt("itemCount", -1) == 0)) {
          vaultsSection.set(e.getKey(), null);
        }
      }
    }
  }