ChoiceElement class

Пакет: com.hypixel.hytale.server.core.entity.entities.player.pages.choices

Файл: com/hypixel/hytale/server/core/entity/entities/player/pages/choices/ChoiceElement.java

Поля (1)

МодификаторыТипИмя
final CodecMapCodec<ChoiceElement> CODEC

Методы (8)

МодификаторыВозвратСигнатура
abstract abstract void addButtonvoid addButton(UICommandBuilder var1, UIEventBuilder var2, String var3, PlayerRef var4)
public boolean canFulfillRequirementsboolean canFulfillRequirements(@Nonnull Store<EntityStore> var1, @Nonnull Ref<EntityStore> var2, @Nonnull PlayerRef var3)
for for(ChoiceRequirement var7 : this.requirements)
public String getDescriptionKeyString getDescriptionKey()
public String getDisplayNameKeyString getDisplayNameKey()
public ChoiceInteraction[] getInteractionsChoiceInteraction[] getInteractions()
public ChoiceRequirement[] getRequirementsChoiceRequirement[] getRequirements()
if if(this.requirements == null)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.entity.entities.player.pages.choices;

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.codecs.array.ArrayCodec;
class="kw">import com.hypixel.hytale.codec.lookup.CodecMapCodec;
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.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 java.util.Arrays;
class="kw">import javax.annotation.Nonnull;

class="kw">public class="kw">abstract class ChoiceElement {
   class="kw">public class="kw">static class="kw">final CodecMapCodec<ChoiceElement> CODEC = new CodecMapCodec<>("Type");
   class="kw">public class="kw">static class="kw">final BuilderCodec<ChoiceElement> BASE_CODEC = BuilderCodec.abstractBuilder(ChoiceElement.class)
      .append(new KeyedCodec<>("DisplayNameKey", Codec.STRING), (var0, var1) -> var0.displayNameKey = var1, var0 -> var0.displayNameKey)
      .addValidator(Validators.nonEmptyString())
      .add()
      .<String>append(new KeyedCodec<>("DescriptionKey", Codec.STRING), (var0, var1) -> var0.descriptionKey = var1, var0 -> var0.descriptionKey)
      .addValidator(Validators.nonEmptyString())
      .add()
      .<ChoiceInteraction[]>append(
         new KeyedCodec<>("Interactions", new ArrayCodec<>(ChoiceInteraction.CODEC, ChoiceInteraction[]::new)),
         (var0, var1) -> var0.interactions = var1,
         var0 -> var0.interactions
      )
      .addValidator(Validators.nonEmptyArray())
      .add()
      .append(
         new KeyedCodec<>("Requirements", new ArrayCodec<>(ChoiceRequirement.CODEC, ChoiceRequirement[]::new)),
         (var0, var1) -> var0.requirements = var1,
         var0 -> var0.requirements
      )
      .add()
      .build();
   class="kw">protected String displayNameKey;
   class="kw">protected String descriptionKey;
   class="kw">protected ChoiceInteraction[] interactions;
   class="kw">protected ChoiceRequirement[] requirements;

   class="kw">public ChoiceElement(String var1, String var2, ChoiceInteraction[] var3, ChoiceRequirement[] var4) {
      this.displayNameKey = var1;
      this.descriptionKey = var2;
      this.interactions = var3;
      this.requirements = var4;
   }

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

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

   class="kw">public String getDescriptionKey() {
      class="kw">return this.descriptionKey;
   }

   class="kw">public ChoiceInteraction[] getInteractions() {
      class="kw">return this.interactions;
   }

   class="kw">public ChoiceRequirement[] getRequirements() {
      class="kw">return this.requirements;
   }

   class="kw">public class="kw">abstract void addButton(UICommandBuilder var1, UIEventBuilder var2, String var3, PlayerRef var4);

   class="kw">public boolean canFulfillRequirements(@Nonnull Store<EntityStore> var1, @Nonnull Ref<EntityStore> var2, @Nonnull PlayerRef var3) {
      if (this.requirements == null) {
         class="kw">return true;
      }

      for (ChoiceRequirement var7 : this.requirements) {
         if (!var7.canFulfillRequirement(var1, var2, var3)) {
            class="kw">return false;
         }
      }

      class="kw">return true;
   }

   @Nonnull
   @Override
   class="kw">public String toString() {
      class="kw">return "ChoiceElement{displayNameKey='"
         + this.displayNameKey
         + "', descriptionKey='"
         + this.descriptionKey
         + "', interactions="
         + Arrays.toString(this.interactions)
         + ", requirements="
         + Arrays.toString(this.requirements)
         + "}";
   }
}