コード例 #1
0
  public boolean isVaultAvailable(Player p) {

    String vaultPath = new StringBuilder(43).append("vaults.").append(p.getUniqueId()).toString();
    ConfigurationSection singlePlayerVaultSection = data.getConfigurationSection(vaultPath);

    return singlePlayerVaultSection.getInt("itemCount", 0) < auctionConfig.getVaultCapacity(p);
  }
コード例 #2
0
  public void unoccupyVault(UUID uuid) {

    String vaultPath = new StringBuilder(43).append("vaults.").append(uuid).toString();
    ConfigurationSection singlePlayerVaultSection = data.getConfigurationSection(vaultPath);
    int itemCount = singlePlayerVaultSection.getInt("itemCount", 0);

    if (itemCount <= 0) return;

    singlePlayerVaultSection.set("itemCount", --itemCount);
  }
コード例 #3
0
  public boolean occupyVault(Player p) {

    String vaultPath = new StringBuilder(43).append("vaults.").append(p.getUniqueId()).toString();
    ConfigurationSection singlePlayerVaultSection = data.getConfigurationSection(vaultPath);
    int itemCount = singlePlayerVaultSection.getInt("itemCount", 0);

    if (itemCount < auctionConfig.getVaultCapacity(p)) {
      singlePlayerVaultSection.set("itemCount", ++itemCount);
      return true;
    } else {
      return false;
    }
  }
コード例 #4
0
  public boolean removeVaultItem(Player p, UUID lotUuid) {

    String vaultPath = new StringBuilder(43).append("vaults.").append(p.getUniqueId()).toString();
    ConfigurationSection singlePlayerVaultSection = data.getConfigurationSection(vaultPath);
    String uuidString = lotUuid.toString();

    if (singlePlayerVaultSection.isSet(uuidString)) {
      singlePlayerVaultSection.set(uuidString, null);
      unoccupyVault(p.getUniqueId());
      return true;
    } else {
      return false;
    }
  }
コード例 #5
0
  public Map<UUID, Double> getDeposit(Lot lot) {

    HashMap<UUID, Double> result = new HashMap<>();

    String path =
        new StringBuilder(49).append("lots.").append(lot.getUuid()).append(".deposit").toString();
    ConfigurationSection singleLotDepositSection = data.getConfigurationSection(path);

    for (String uuidString : singleLotDepositSection.getKeys(false)) {

      UUID uuid = UUID.fromString(uuidString);
      result.put(uuid, singleLotDepositSection.getDouble(uuidString));
    }

    return result;
  }
コード例 #6
0
  public Map<UUID, ItemStack> getVaultContents(Player p) {

    String vaultPath = new StringBuilder(43).append("vaults.").append(p.getUniqueId()).toString();
    ConfigurationSection singlePlayerVaultSection = data.getConfigurationSection(vaultPath);

    HashMap<UUID, ItemStack> result = new HashMap<>();

    for (String lotUuidString : singlePlayerVaultSection.getKeys(false)) {

      if (lotUuidString.length() != 36) continue; // There is an itemCount field

      result.put(
          UUID.fromString(lotUuidString), singlePlayerVaultSection.getItemStack(lotUuidString));
    }

    return result;
  }
コード例 #7
0
  private void load() {

    ConfigurationSection lotsSection = data.getConfigurationSection("lots");

    for (String uuidString : lotsSection.getKeys(false)) {

      ConfigurationSection singleLotSection = lotsSection.getConfigurationSection(uuidString);

      ItemStack item = singleLotSection.getItemStack("item");
      boolean started = singleLotSection.getBoolean("started");
      double price = singleLotSection.getDouble("price");
      String lastBidPlayerName = singleLotSection.getString("lastBidPlayerName");
      UUID lastBidPlayerUuid =
          singleLotSection.isSet("lastBidPlayerUuid")
              ? UUID.fromString(singleLotSection.getString("lastBidPlayerUuid"))
              : null;
      double lastBidPrice = singleLotSection.getDouble("lastBidPrice");
      double minimumIncrement = singleLotSection.getDouble("minimumIncrement");
      long preserveTimeExpire = singleLotSection.getLong("preserveTimeExpire");
      long auctionDurationExpire = singleLotSection.getLong("auctionDurationExpire");

      Lot lot =
          new Lot(
              UUID.fromString(uuidString),
              item,
              started,
              price,
              lastBidPlayerName,
              lastBidPlayerUuid,
              lastBidPrice,
              minimumIncrement,
              preserveTimeExpire,
              auctionDurationExpire);
      lots.add(lot);
    }
  }