Window class
Пакет: com.hypixel.hytale.server.core.entity.entities.player.windows
Файл: com/hypixel/hytale/server/core/entity/entities/player/windows/Window.java
Поля (3)
| Модификаторы | Тип | Имя |
|---|---|---|
|
int |
var1 |
|
|
var1 |
|
Window |
var2 |
Методы (16)
| Модификаторы | Возврат | Сигнатура |
|---|---|---|
|
public |
WindowCloseEventpublic WindowCloseEvent() |
public |
void |
closevoid close(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) |
protected |
boolean |
consumeIsDirtyboolean consumeIsDirty() |
protected |
void |
consumeNeedRebuildvoid consumeNeedRebuild() |
public |
int |
getIdint getId() |
public |
void |
handleActionvoid handleAction(@Nonnull Ref<EntityStore> var1, @Nonnull Store<EntityStore> var2, @Nonnull WindowAction var3) |
|
|
if if(this == var1) |
|
|
if if(this.id != var2.id) |
public |
void |
initvoid init(@Nonnull PlayerRef var1, @Nonnull WindowManager var2) |
protected |
void |
invalidatevoid invalidate() |
protected |
void |
onClosevoid onClose(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) |
abstract abstract |
void |
onClose0void onClose0(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) |
protected |
boolean |
onOpenboolean onOpen(@Nonnull Ref<EntityStore> var1, @Nonnull Store<EntityStore> var2) |
abstract abstract |
boolean |
onOpen0boolean onOpen0(@Nonnull Ref<EntityStore> var1, @Nonnull Store<EntityStore> var2) |
public |
void |
setIdvoid setId(int var1) |
protected |
void |
setNeedRebuildvoid setNeedRebuild() |
Исходный код
Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.entity.entities.player.windows;
class="kw">import com.google.gson.JsonObject;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.event.EventPriority;
class="kw">import com.hypixel.hytale.event.EventRegistration;
class="kw">import com.hypixel.hytale.event.IEvent;
class="kw">import com.hypixel.hytale.event.SyncEventBusRegistry;
class="kw">import com.hypixel.hytale.logger.HytaleLogger;
class="kw">import com.hypixel.hytale.protocol.packets.window.WindowAction;
class="kw">import com.hypixel.hytale.protocol.packets.window.WindowType;
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.Map;
class="kw">import java.util.Objects;
class="kw">import java.util.concurrent.ConcurrentHashMap;
class="kw">import java.util.concurrent.atomic.AtomicBoolean;
class="kw">import java.util.function.Consumer;
class="kw">import java.util.function.Supplier;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;
class="kw">public class="kw">abstract class Window {
class="kw">public class="kw">static class="kw">final Map<WindowType, Supplier<? class="kw">extends Window>> CLIENT_REQUESTABLE_WINDOW_TYPES = new ConcurrentHashMap<>();
@Nonnull
class="kw">protected class="kw">static class="kw">final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
@Nonnull
class="kw">protected class="kw">final SyncEventBusRegistry<Void, Window.WindowCloseEvent> closeEventRegistry = new SyncEventBusRegistry<>(LOGGER, Window.WindowCloseEvent.class);
@Nonnull
class="kw">protected class="kw">final WindowType windowType;
@Nonnull
class="kw">protected class="kw">final AtomicBoolean isDirty = new AtomicBoolean();
@Nonnull
class="kw">protected class="kw">final AtomicBoolean needRebuild = new AtomicBoolean();
class="kw">private int id;
@Nullable
class="kw">private WindowManager manager;
@Nullable
class="kw">private PlayerRef playerRef;
class="kw">public Window(@Nonnull WindowType var1) {
this.windowType = var1;
}
class="kw">public void init(@Nonnull PlayerRef var1, @Nonnull WindowManager var2) {
this.playerRef = var1;
this.manager = var2;
}
@Nonnull
class="kw">public class="kw">abstract JsonObject getData();
class="kw">protected boolean onOpen(@Nonnull Ref<EntityStore> var1, @Nonnull Store<EntityStore> var2) {
class="kw">return this.onOpen0(var1, var2);
}
class="kw">protected class="kw">abstract boolean onOpen0(@Nonnull Ref<EntityStore> var1, @Nonnull Store<EntityStore> var2);
class="kw">protected void onClose(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
try {
this.onClose0(var1, var2);
} class="kw">finally {
this.closeEventRegistry.dispatchFor(null).dispatch(new Window.WindowCloseEvent());
}
}
class="kw">protected class="kw">abstract void onClose0(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2);
class="kw">public void handleAction(@Nonnull Ref<EntityStore> var1, @Nonnull Store<EntityStore> var2, @Nonnull WindowAction var3) {
}
@Nonnull
class="kw">public WindowType getType() {
class="kw">return this.windowType;
}
class="kw">public void setId(int var1) {
this.id = var1;
}
class="kw">public int getId() {
class="kw">return this.id;
}
@Nullable
class="kw">public PlayerRef getPlayerRef() {
class="kw">return this.playerRef;
}
class="kw">public void close(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
assert this.manager != null;
this.manager.closeWindow(var1, this.id, var2);
}
class="kw">protected void invalidate() {
this.isDirty.set(true);
}
class="kw">protected void setNeedRebuild() {
this.needRebuild.set(true);
this.getData().addProperty("needRebuild", Boolean.TRUE);
}
class="kw">protected boolean consumeIsDirty() {
class="kw">return this.isDirty.getAndSet(false);
}
class="kw">protected void consumeNeedRebuild() {
if (this.needRebuild.get()) {
this.getData().remove("needRebuild");
this.needRebuild.set(false);
}
}
@Nonnull
class="kw">public EventRegistration registerCloseEvent(@Nonnull Consumer<Window.WindowCloseEvent> var1) {
class="kw">return this.closeEventRegistry.register((short)0, null, var1);
}
@Nonnull
class="kw">public EventRegistration registerCloseEvent(short var1, @Nonnull Consumer<Window.WindowCloseEvent> var2) {
class="kw">return this.closeEventRegistry.register(var1, null, var2);
}
@Nonnull
class="kw">public EventRegistration registerCloseEvent(@Nonnull EventPriority var1, @Nonnull Consumer<Window.WindowCloseEvent> var2) {
class="kw">return this.closeEventRegistry.register(var1.getValue(), null, var2);
}
@Override
class="kw">public boolean equals(@Nullable Object var1) {
if (this == var1) {
class="kw">return true;
}
if (var1 != null && this.getClass() == var1.getClass()) {
Window var2 = (Window)var1;
if (this.id != var2.id) {
class="kw">return false;
} else {
class="kw">return !Objects.equals(this.windowType, var2.windowType) ? false : Objects.equals(this.playerRef, var2.playerRef);
}
} else {
class="kw">return false;
}
}
@Override
class="kw">public int hashCode() {
int var1 = this.windowType.hashCode();
var1 = 31 * var1 + this.id;
class="kw">return 31 * var1 + (this.playerRef != null ? this.playerRef.hashCode() : 0);
}
class="kw">public class="kw">static class WindowCloseEvent class="kw">implements IEvent<Void> {
class="kw">public WindowCloseEvent() {
}
}
}