ChoiceBasePage class

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

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

extends: InteractiveCustomUIPage<ChoiceBasePage.ChoicePageEventData>

Поля (9)

МодификаторыТипИмя
public static final BuilderCodec<ChoiceBasePage.ChoicePageEventData> CODEC
static final String ELEMENT_INDEX
private int index
private String indexStr
int var4
ChoiceElement var5
String var6
ChoiceInteraction[] var6
ChoiceElement var7

Методы (13)

МодификаторыВозвратСигнатура
public ChoicePageEventDatapublic ChoicePageEventData()
for for(int var5 = 0; var5 < this.elements.length; var5++)
for for(ChoiceInteraction var10 : var6)
public int getIndexpublic int getIndex()
public void handleDataEventvoid handleDataEvent(@Nonnull Ref<EntityStore> var1, @Nonnull Store<EntityStore> var2, @Nonnull ChoiceBasePage.ChoicePageEventData var3)
if if(this.elements != null && this.elements.length != 0)
if if(var7 != null)
if if(this.elements != null)
if if(var4 >= 0 && var4 < this.elements.length)
if if(var5 != null)
if if(var6 != null)
if if(var10 != null)
abstract super super(var1, CustomPageLifetime.CanDismiss, ChoiceBasePage.ChoicePageEventData.CODEC)

Исходный код

Показать/скрыть
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.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.protocol.packets.interface_.CustomPageLifetime;
class="kw">import com.hypixel.hytale.protocol.packets.interface_.CustomUIEventBindingType;
class="kw">import com.hypixel.hytale.server.core.entity.entities.player.pages.InteractiveCustomUIPage;
class="kw">import com.hypixel.hytale.server.core.ui.builder.EventData;
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">import javax.annotation.Nullable;

class="kw">public class="kw">abstract class ChoiceBasePage class="kw">extends InteractiveCustomUIPage<ChoiceBasePage.ChoicePageEventData> {
   @Nullable
   class="kw">private class="kw">final ChoiceElement[] elements;
   @Nonnull
   class="kw">private class="kw">final String pageLayout;

   class="kw">public ChoiceBasePage(@Nonnull PlayerRef var1, @Nullable ChoiceElement[] var2, @Nonnull String var3) {
      super(var1, CustomPageLifetime.CanDismiss, ChoiceBasePage.ChoicePageEventData.CODEC);
      this.elements = var2;
      this.pageLayout = var3;
   }

   @Nullable
   class="kw">protected ChoiceElement[] getElements() {
      class="kw">return this.elements;
   }

   @Nonnull
   class="kw">protected String getPageLayout() {
      class="kw">return this.pageLayout;
   }

   @Override
   class="kw">public void build(@Nonnull Ref<EntityStore> var1, @Nonnull UICommandBuilder var2, @Nonnull UIEventBuilder var3, @Nonnull Store<EntityStore> var4) {
      var2.append(this.pageLayout);
      var2.clear("#ElementList");
      if (this.elements != null && this.elements.length != 0) {
         for (int var5 = 0; var5 < this.elements.length; var5++) {
            String var6 = "#ElementList[" + var5 + "]";
            ChoiceElement var7 = this.elements[var5];
            if (var7 != null) {
               var7.addButton(var2, var3, var6, this.playerRef);
               var3.addEventBinding(CustomUIEventBindingType.Activating, var6, EventData.of("Index", Integer.toString(var5)), false);
            }
         }
      }
   }

   class="kw">public void handleDataEvent(@Nonnull Ref<EntityStore> var1, @Nonnull Store<EntityStore> var2, @Nonnull ChoiceBasePage.ChoicePageEventData var3) {
      if (this.elements != null) {
         int var4 = var3.getIndex();
         if (var4 >= 0 && var4 < this.elements.length) {
            ChoiceElement var5 = this.elements[var4];
            if (var5 != null) {
               if (var5.canFulfillRequirements(var2, var1, this.playerRef)) {
                  ChoiceInteraction[] var6 = var5.getInteractions();
                  if (var6 != null) {
                     for (ChoiceInteraction var10 : var6) {
                        if (var10 != null) {
                           var10.run(var2, var1, this.playerRef);
                        }
                     }
                  }
               }
            }
         }
      }
   }

   class="kw">public class="kw">static class ChoicePageEventData {
      class="kw">static class="kw">final String ELEMENT_INDEX = "Index";
      class="kw">public class="kw">static class="kw">final BuilderCodec<ChoiceBasePage.ChoicePageEventData> CODEC = BuilderCodec.builder(
            ChoiceBasePage.ChoicePageEventData.class, ChoiceBasePage.ChoicePageEventData::new
         )
         .append(new KeyedCodec<>("Index", Codec.STRING), (var0, var1) -> {
            var0.indexStr = var1;

            try {
               var0.index = Integer.parseInt(var1);
            } catch (NumberFormatException var3) {
               var0.index = -1;
            }
         }, var0 -> var0.indexStr)
         .add()
         .build();
      class="kw">private String indexStr;
      class="kw">private int index = -1;

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

      class="kw">public int getIndex() {
         class="kw">return this.index;
      }
   }
}