TreasureChestBlock class

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

Файл: com/hypixel/hytale/builtin/adventure/objectives/blockstates/TreasureChestBlock.java

implements: Component<ChunkStore>

Поля (3)

МодификаторыТипИмя
UUIDComponent var3
Objective var4
IEventDispatcher var4

Методы (8)

МодификаторыВозвратСигнатура
public boolean canDestroyboolean canDestroy(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2)
public boolean canOpenboolean canOpen(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2)
static ComponentType<ChunkStore, TreasureChestBlock> getComponentTypeComponentType<ChunkStore, TreasureChestBlock> getComponentType()
if if(!this.opened && this.objectiveUUID != null)
public boolean isOpenedboolean isOpened()
public void onOpenvoid onOpen(@Nonnull Ref<EntityStore> var1, @Nonnull World var2, @Nonnull Store<EntityStore> var3)
public void setObjectiveDatavoid setObjectiveData(UUID var1, UUID var2)
public void setOpenedvoid setOpened(boolean var1)

Исходный код

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

class="kw">import com.hypixel.hytale.builtin.adventure.objectives.Objective;
class="kw">import com.hypixel.hytale.builtin.adventure.objectives.ObjectivePlugin;
class="kw">import com.hypixel.hytale.builtin.adventure.objectives.events.TreasureChestOpeningEvent;
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.Component;
class="kw">import com.hypixel.hytale.component.ComponentAccessor;
class="kw">import com.hypixel.hytale.component.ComponentType;
class="kw">import com.hypixel.hytale.component.Ref;
class="kw">import com.hypixel.hytale.component.Store;
class="kw">import com.hypixel.hytale.event.IEventDispatcher;
class="kw">import com.hypixel.hytale.server.core.HytaleServer;
class="kw">import com.hypixel.hytale.server.core.entity.UUIDComponent;
class="kw">import com.hypixel.hytale.server.core.universe.world.World;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.ChunkStore;
class="kw">import com.hypixel.hytale.server.core.universe.world.storage.EntityStore;
class="kw">import java.util.UUID;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class TreasureChestBlock class="kw">implements Component<ChunkStore> {
   @Nonnull
   class="kw">public class="kw">static class="kw">final BuilderCodec<TreasureChestBlock> CODEC = BuilderCodec.builder(TreasureChestBlock.class, TreasureChestBlock::new)
      .append(new KeyedCodec<>("ObjectiveUUID", Codec.UUID_BINARY), (var0, var1) -> var0.objectiveUUID = var1, var0 -> var0.objectiveUUID)
      .add()
      .append(new KeyedCodec<>("ChestUUID", Codec.UUID_BINARY), (var0, var1) -> var0.chestUUID = var1, var0 -> var0.chestUUID)
      .add()
      .append(new KeyedCodec<>("Opened", Codec.BOOLEAN), (var0, var1) -> var0.opened = var1, var0 -> var0.opened)
      .add()
      .build();
   class="kw">protected UUID objectiveUUID;
   class="kw">protected UUID chestUUID;
   class="kw">protected boolean opened;

   class="kw">public class="kw">static ComponentType<ChunkStore, TreasureChestBlock> getComponentType() {
      class="kw">return ObjectivePlugin.get().getTreasureChestComponentType();
   }

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

   class="kw">public TreasureChestBlock(UUID var1, UUID var2, boolean var3) {
      this.objectiveUUID = var1;
      this.chestUUID = var2;
      this.opened = var3;
   }

   class="kw">public boolean canOpen(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
      if (!this.opened && this.objectiveUUID != null) {
         UUIDComponent var3 = var2.getComponent(var1, UUIDComponent.getComponentType());
         assert var3 != null;
         Objective var4 = ObjectivePlugin.get().getObjectiveDataStore().getObjective(this.objectiveUUID);
         class="kw">return var4 != null && var4.getActivePlayerUUIDs().contains(var3.getUuid());
      } else {
         class="kw">return true;
      }
   }

   class="kw">public boolean canDestroy(@Nonnull Ref<EntityStore> var1, @Nonnull ComponentAccessor<EntityStore> var2) {
      class="kw">return this.opened;
   }

   class="kw">public void onOpen(@Nonnull Ref<EntityStore> var1, @Nonnull World var2, @Nonnull Store<EntityStore> var3) {
      IEventDispatcher var4 = HytaleServer.get().getEventBus().dispatchFor(TreasureChestOpeningEvent.class, var2.getName());
      if (var4.hasListener() && this.objectiveUUID != null) {
         var4.dispatch(new TreasureChestOpeningEvent(this.objectiveUUID, this.chestUUID, var1, var3));
      }

      this.setOpened(true);
   }

   class="kw">public void setOpened(boolean var1) {
      this.opened = var1;
   }

   class="kw">public boolean isOpened() {
      class="kw">return this.opened;
   }

   class="kw">public void setObjectiveData(UUID var1, UUID var2) {
      this.objectiveUUID = var1;
      this.chestUUID = var2;
   }

   @Nullable
   @Override
   class="kw">public Component<ChunkStore> clone() {
      class="kw">return new TreasureChestBlock(this.objectiveUUID, this.chestUUID, this.opened);
   }
}