ShopElement class

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

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

extends: ChoiceElement

Исходный код

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

class="kw">import com.hypixel.hytale.codec.Codec;
class="kw">import com.hypixel.hytale.codec.KeyedCodec;
class="kw">import com.hypixel.hytale.codec.builder.BuilderCodec;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.server.core.entity.entities.player.pages.choices.ChoiceElement;
class="kw">import com.hypixel.hytale.server.core.ui.LocalizableString;
class="kw">import com.hypixel.hytale.server.core.ui.builder.UICommandBuilder;
class="kw">import com.hypixel.hytale.server.core.ui.builder.UIEventBuilder;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;

class="kw">public class ShopElement class="kw">extends ChoiceElement {
   @Nonnull
   class="kw">public class="kw">static class="kw">final BuilderCodec<ShopElement> CODEC = BuilderCodec.builder(ShopElement.class, ShopElement::new, ChoiceElement.BASE_CODEC)
      .append(new KeyedCodec<>("Cost", Codec.INTEGER), (var0, var1) -> var0.cost = var1, var0 -> var0.cost)
      .addValidator(Validators.greaterThanOrEqual(0))
      .add()
      .append(new KeyedCodec<>("Icon", Codec.STRING), (var0, var1) -> var0.iconPath = var1, var0 -> var0.iconPath)
      .add()
      .build();
   class="kw">protected int cost;
   class="kw">protected String iconPath;

   class="kw">public ShopElement() {
   }

   @Override
   class="kw">public void addButton(@Nonnull UICommandBuilder var1, UIEventBuilder var2, String var3, PlayerRef var4) {
      var1.append("#ElementList", "Pages/ShopElementButton.ui");
      var1.set(var3 + " #Icon.Background", this.iconPath);
      var1.setObject(var3 + " #Name.Text", LocalizableString.fromMessageId(this.displayNameKey));
      var1.setObject(var3 + " #Description.Text", LocalizableString.fromMessageId(this.descriptionKey));
      var1.set(var3 + " #Cost.Text", this.cost + "");
   }

   @Override
   class="kw">public boolean canFulfillRequirements(@Nonnull Store<EntityStore> var1, @Nonnull Ref<EntityStore> var2, @Nonnull PlayerRef var3) {
      class="kw">return super.canFulfillRequirements(var1, var2, var3);
   }
}