BarterShopAsset class

Пакет: com.hypixel.hytale.builtin.adventure.shop.barter

Файл: com/hypixel/hytale/builtin/adventure/shop/barter/BarterShopAsset.java

implements: JsonAssetWithMap<String, DefaultAssetMap<String, BarterShopAsset>>

Поля (1)

МодификаторыТипИмя
ASSET_STORE

Методы (8)

МодификаторыВозвратСигнатура
static DefaultAssetMap<String, BarterShopAsset> getAssetMapDefaultAssetMap<String, BarterShopAsset> getAssetMap()
public String getDisplayNameKeyString getDisplayNameKey()
public String getIdString getId()
public RefreshInterval getRefreshIntervalRefreshInterval getRefreshInterval()
public int getRestockHourint getRestockHour()
public BarterTrade[] getTradesBarterTrade[] getTrades()
public boolean hasTradeSlotsboolean hasTradeSlots()
if if(ASSET_STORE == null)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.adventure.shop.barter;

class="kw">import com.hypixel.hytale.assetstore.AssetExtraInfo;
class="kw">import com.hypixel.hytale.assetstore.AssetKeyValidator;
class="kw">import com.hypixel.hytale.assetstore.AssetRegistry;
class="kw">import com.hypixel.hytale.assetstore.AssetStore;
class="kw">import com.hypixel.hytale.assetstore.codec.AssetBuilderCodec;
class="kw">import com.hypixel.hytale.assetstore.map.DefaultAssetMap;
class="kw">import com.hypixel.hytale.assetstore.map.JsonAssetWithMap;
class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.codecs.array.ArrayCodec;
class="kw">import com.hypixel.hytale.codec.validation.ValidatorCache;
class="kw">import java.util.Arrays;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class BarterShopAsset class="kw">implements JsonAssetWithMap<String, DefaultAssetMap<String, BarterShopAsset>> {
   @Nonnull
   class="kw">public class="kw">static class="kw">final AssetBuilderCodec<String, BarterShopAsset> CODEC = AssetBuilderCodec.builder(
         BarterShopAsset.class,
         BarterShopAsset::new,
         Codec.STRING,
         (var0, var1) -> var0.id = var1,
         var0 -> var0.id,
         (var0, var1) -> var0.extraData = var1,
         var0 -> var0.extraData
      )
      .append(new KeyedCodec<>("DisplayNameKey", Codec.STRING), (var0, var1) -> var0.displayNameKey = var1, var0 -> var0.displayNameKey)
      .add()
      .append(new KeyedCodec<>("RefreshInterval", RefreshInterval.CODEC), (var0, var1) -> var0.refreshInterval = var1, var0 -> var0.refreshInterval)
      .add()
      .append(new KeyedCodec<>("Trades", new ArrayCodec<>(BarterTrade.CODEC, BarterTrade[]::new)), (var0, var1) -> var0.trades = var1, var0 -> var0.trades)
      .add()
      .append(
         new KeyedCodec<>("TradeSlots", new ArrayCodec<>(TradeSlot.CODEC, TradeSlot[]::new)), (var0, var1) -> var0.tradeSlots = var1, var0 -> var0.tradeSlots
      )
      .add()
      .append(new KeyedCodec<>("RestockHour", Codec.INTEGER, true), (var0, var1) -> var0.restockHour = var1, var0 -> var0.restockHour)
      .add()
      .build();
   @Nonnull
   class="kw">public class="kw">static class="kw">final ValidatorCache<String> VALIDATOR_CACHE = new ValidatorCache<>(new AssetKeyValidator<>(BarterShopAsset::getAssetStore));
   class="kw">private class="kw">static AssetStore<String, BarterShopAsset, DefaultAssetMap<String, BarterShopAsset>> ASSET_STORE;
   class="kw">protected AssetExtraInfo.Data extraData;
   class="kw">public class="kw">static class="kw">final int DEFAULT_RESTOCK_HOUR = 7;
   class="kw">protected String id;
   class="kw">protected String displayNameKey;
   class="kw">protected RefreshInterval refreshInterval;
   class="kw">protected BarterTrade[] trades;
   class="kw">protected TradeSlot[] tradeSlots;
   @Nullable
   class="kw">protected Integer restockHour;

   @Nonnull
   class="kw">public class="kw">static AssetStore<String, BarterShopAsset, DefaultAssetMap<String, BarterShopAsset>> getAssetStore() {
      if (ASSET_STORE == null) {
         ASSET_STORE = AssetRegistry.getAssetStore(BarterShopAsset.class);
      }

      class="kw">return ASSET_STORE;
   }

   class="kw">public class="kw">static DefaultAssetMap<String, BarterShopAsset> getAssetMap() {
      class="kw">return (DefaultAssetMap<String, BarterShopAsset>)getAssetStore().getAssetMap();
   }

   class="kw">public BarterShopAsset(String var1, String var2, RefreshInterval var3, BarterTrade[] var4, TradeSlot[] var5, @Nullable Integer var6) {
      this.id = var1;
      this.displayNameKey = var2;
      this.refreshInterval = var3;
      this.trades = var4;
      this.tradeSlots = var5;
      this.restockHour = var6;
   }

   class="kw">protected BarterShopAsset() {
   }

   class="kw">public String getId() {
      class="kw">return this.id;
   }

   class="kw">public String getDisplayNameKey() {
      class="kw">return this.displayNameKey;
   }

   class="kw">public RefreshInterval getRefreshInterval() {
      class="kw">return this.refreshInterval;
   }

   class="kw">public BarterTrade[] getTrades() {
      class="kw">return this.trades;
   }

   @Nullable
   class="kw">public TradeSlot[] getTradeSlots() {
      class="kw">return this.tradeSlots;
   }

   class="kw">public boolean hasTradeSlots() {
      class="kw">return this.tradeSlots != null && this.tradeSlots.length > 0;
   }

   class="kw">public int getRestockHour() {
      class="kw">return this.restockHour != null ? this.restockHour : 7;
   }

   @Nonnull
   @Override
   class="kw">public String toString() {
      class="kw">return "BarterShopAsset{id='"
         + this.id
         + "', displayNameKey='"
         + this.displayNameKey
         + "', refreshInterval="
         + this.refreshInterval
         + ", restockHour="
         + this.getRestockHour()
         + ", trades="
         + Arrays.toString(this.trades)
         + ", tradeSlots="
         + Arrays.toString(this.tradeSlots)
         + "}";
   }
}