PageData class
Пакет: com.hypixel.hytale.builtin.buildertools.prefabeditor.ui
Файл: com/hypixel/hytale/builtin/buildertools/prefabeditor/ui/PrefabEditorLoadOptionsPage.java
Поля (2)
| Модификаторы | Тип | Имя |
|---|---|---|
|
public static final BuilderCodec<PrefabEditorLoadOptionsPage.PageData> |
CODEC |
|
public PrefabEditorLoadOptionsPage.Action |
action |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.buildertools.prefabeditor.ui;
class="kw">import com.hypixel.hytale.builtin.buildertools.BuilderToolsPlugin;
class="kw">import com.hypixel.hytale.builtin.buildertools.prefabeditor.PrefabEditSessionManager;
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.EnumCodec;
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.protocol.packets.interface_.Page;
class="kw">import com.hypixel.hytale.server.core.Message;
class="kw">import com.hypixel.hytale.server.core.entity.entities.Player;
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.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import javax.annotation.Nonnull;
class="kw">public class PrefabEditorLoadOptionsPage class="kw">extends InteractiveCustomUIPage<PrefabEditorLoadOptionsPage.PageData> {
@Nonnull
class="kw">private class="kw">final World world;
class="kw">public PrefabEditorLoadOptionsPage(@Nonnull PlayerRef var1, @Nonnull World var2) {
super(var1, CustomPageLifetime.CanDismissOrCloseThroughInteraction, PrefabEditorLoadOptionsPage.PageData.CODEC);
this.world = var2;
}
@Override
class="kw">public void build(@Nonnull Ref<EntityStore> var1, @Nonnull UICommandBuilder var2, @Nonnull UIEventBuilder var3, @Nonnull Store<EntityStore> var4) {
var2.append("Pages/PrefabEditorLoadOptions.ui");
var2.set("#WarningTitle.TextSpans", Message.translation("server.commands.editprefab.prefabEditorLoadOptions.title"));
var2.set("#WarningMessage.TextSpans", Message.translation("server.commands.editprefab.prefabEditorLoadOptions.message"));
var3.addEventBinding(
CustomUIEventBindingType.Activating,
"#LoadExistingSessionButton",
new EventData().append("Action", PrefabEditorLoadOptionsPage.Action.LoadExisting.name())
);
var3.addEventBinding(
CustomUIEventBindingType.Activating, "#CancelButton", new EventData().append("Action", PrefabEditorLoadOptionsPage.Action.Cancel.name())
);
var3.addEventBinding(
CustomUIEventBindingType.Activating, "#CreateNewSessionButton", new EventData().append("Action", PrefabEditorLoadOptionsPage.Action.CreateNew.name())
);
}
class="kw">public void handleDataEvent(@Nonnull Ref<EntityStore> var1, @Nonnull Store<EntityStore> var2, @Nonnull PrefabEditorLoadOptionsPage.PageData var3) {
Player var4 = var2.getComponent(var1, Player.getComponentType());
assert var4 != null;
PrefabEditSessionManager var5 = BuilderToolsPlugin.get().getPrefabEditSessionManager();
class="kw">switch (var3.action) {
case LoadExisting:
var4.getPageManager().setPage(var1, var2, Page.None);
var5.sendToEditWorld(var1, this.world, this.playerRef);
break;
case Cancel:
var4.getPageManager().setPage(var1, var2, Page.None);
break;
case CreateNew:
var5.exitEditSession(var1, this.world, this.playerRef, var2)
.thenRun(() -> var4.getPageManager().openCustomPage(var1, var2, new PrefabEditorLoadSettingsPage(this.playerRef)));
}
}
class="kw">public enum Action {
LoadExisting,
Cancel,
CreateNew;
Action() {
}
}
class="kw">protected class="kw">static class PageData {
class="kw">public class="kw">static class="kw">final BuilderCodec<PrefabEditorLoadOptionsPage.PageData> CODEC = BuilderCodec.builder(
PrefabEditorLoadOptionsPage.PageData.class, PrefabEditorLoadOptionsPage.PageData::new
)
.append(
new KeyedCodec<>("Action", new EnumCodec<>(PrefabEditorLoadOptionsPage.Action.class, EnumCodec.EnumStyle.LEGACY)),
(var0, var1) -> var0.action = var1,
var0 -> var0.action
)
.add()
.build();
class="kw">public PrefabEditorLoadOptionsPage.Action action;
class="kw">public PageData() {
}
}
}