EnterBedSystem class

Пакет: com.hypixel.hytale.builtin.beds.sleep.systems.player

Файл: com/hypixel/hytale/builtin/beds/sleep/systems/player/EnterBedSystem.java

extends: RefChangeSystem<EntityStore, MountedComponent>

Поля (11)

МодификаторыТипИмя
long var1
Duration var10
Message var11
LocalTime var15
Message var16
World var3
long var3
CanSleepInWorld.Result var4
PlayerRef var5
long var5
String var7

Методы (8)

МодификаторыВозвратСигнатура
static void checkvoid check(@Nonnull Ref<EntityStore> var0, @Nonnull MountedComponent var1, @Nonnull Store<EntityStore> var2, @Nonnull ComponentType<EntityStore, PlayerRef> var3)
abstract check check(var1, var2, var3, this.playerRefComponentType)
abstract check check(var1, var3, var4, this.playerRefComponentType)
public void onComponentAddedvoid onComponentAdded(@Nonnull Ref<EntityStore> var1, @Nonnull MountedComponent var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4)
public void onComponentRemovedvoid onComponentRemoved(@Nonnull Ref<EntityStore> var1, @Nonnull MountedComponent var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4)
public void onComponentSetvoid onComponentSet(@Nonnull Ref<EntityStore> var1, @Nullable MountedComponent var2, @Nonnull MountedComponent var3, @Nonnull Store<EntityStore> var4, @Nonnull CommandBuffer<EntityStore> var5)
static void onEnterBedvoid onEnterBed(@Nonnull Ref<EntityStore> var0, @Nonnull Store<EntityStore> var1, @Nonnull ComponentType<EntityStore, PlayerRef> var2)
abstract onEnterBed onEnterBed(var0, var2, var3)

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.builtin.beds.sleep.systems.player;

class="kw">import com.hypixel.hytale.builtin.beds.sleep.systems.world.CanSleepInWorld;
class="kw">import com.hypixel.hytale.builtin.mounts.MountedComponent;
class="kw">import com.hypixel.hytale.component.CommandBuffer;
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.component.query.Query;
class="kw">import com.hypixel.hytale.component.system.RefChangeSystem;
class="kw">import com.hypixel.hytale.protocol.BlockMountType;
class="kw">import com.hypixel.hytale.protocol.SoundCategory;
class="kw">import com.hypixel.hytale.server.core.Message;
class="kw">import com.hypixel.hytale.server.core.asset.type.gameplay.sleep.SleepConfig;
class="kw">import com.hypixel.hytale.server.core.universe.PlayerRef;
class="kw">import com.hypixel.hytale.server.core.universe.world.SoundUtil;
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 java.time.Duration;
class="kw">import java.time.LocalDateTime;
class="kw">import java.time.LocalTime;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class EnterBedSystem class="kw">extends RefChangeSystem<EntityStore, MountedComponent> {
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_SERVER_INTERACTIONS_SLEEP_GAME_TIME_PAUSED = Message.translation("server.interactions.sleep.gameTimePaused");
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_SERVER_INTERACTIONS_SLEEP_NOT_WITHIN_HOURS = Message.translation("server.interactions.sleep.notWithinHours");
   @Nonnull
   class="kw">private class="kw">static class="kw">final Message MESSAGE_SERVER_INTERACTIONS_SLEEP_DISABLED = Message.translation("server.interactions.sleep.disabled");
   @Nonnull
   class="kw">private class="kw">final ComponentType<EntityStore, MountedComponent> mountedComponentType;
   @Nonnull
   class="kw">private class="kw">final ComponentType<EntityStore, PlayerRef> playerRefComponentType;
   @Nonnull
   class="kw">private class="kw">final Query<EntityStore> query;

   class="kw">public EnterBedSystem(@Nonnull ComponentType<EntityStore, MountedComponent> var1, @Nonnull ComponentType<EntityStore, PlayerRef> var2) {
      this.mountedComponentType = var1;
      this.playerRefComponentType = var2;
      this.query = Query.and(var1, var2);
   }

   @Nonnull
   @Override
   class="kw">public ComponentType<EntityStore, MountedComponent> componentType() {
      class="kw">return this.mountedComponentType;
   }

   @Nonnull
   @Override
   class="kw">public Query<EntityStore> getQuery() {
      class="kw">return this.query;
   }

   class="kw">public void onComponentAdded(
      @Nonnull Ref<EntityStore> var1, @Nonnull MountedComponent var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4
   ) {
      check(var1, var2, var3, this.playerRefComponentType);
   }

   class="kw">public void onComponentSet(
      @Nonnull Ref<EntityStore> var1,
      @Nullable MountedComponent var2,
      @Nonnull MountedComponent var3,
      @Nonnull Store<EntityStore> var4,
      @Nonnull CommandBuffer<EntityStore> var5
   ) {
      check(var1, var3, var4, this.playerRefComponentType);
   }

   class="kw">public void onComponentRemoved(
      @Nonnull Ref<EntityStore> var1, @Nonnull MountedComponent var2, @Nonnull Store<EntityStore> var3, @Nonnull CommandBuffer<EntityStore> var4
   ) {
   }

   class="kw">private class="kw">static void check(
      @Nonnull Ref<EntityStore> var0, @Nonnull MountedComponent var1, @Nonnull Store<EntityStore> var2, @Nonnull ComponentType<EntityStore, PlayerRef> var3
   ) {
      if (var1.getBlockMountType() == BlockMountType.Bed) {
         onEnterBed(var0, var2, var3);
      }
   }

   class="kw">private class="kw">static void onEnterBed(@Nonnull Ref<EntityStore> var0, @Nonnull Store<EntityStore> var1, @Nonnull ComponentType<EntityStore, PlayerRef> var2) {
      World var3 = var1.getExternalData().getWorld();
      CanSleepInWorld.Result var4 = CanSleepInWorld.check(var3);
      if (var4.isNegative()) {
         PlayerRef var5 = var1.getComponent(var0, var2);
         assert var5 != null;
         if (var4 class="kw">instanceof CanSleepInWorld.NotDuringSleepHoursRange(LocalDateTime var7, SleepConfig var8)) {
            LocalTime var15 = var8.getSleepStartTime();
            Duration var10 = var8.computeDurationUntilSleep(var7);
            Message var11 = Message.translation("server.interactions.sleep.sleepAtTheseHours")
               .param("timeValue", var15.toString())
               .param("until", formatDuration(var10));
            var5.sendMessage(var11.color("#F2D729"));
            SoundUtil.playSoundEvent2dToPlayer(var5, var8.getSounds().getFailIndex(), SoundCategory.UI);
         } else {
            Message var16 = getMessage(var4);
            var5.sendMessage(var16);
         }
      }
   }

   @Nonnull
   class="kw">private class="kw">static Message getMessage(@Nonnull CanSleepInWorld.Result param0) {
      // $VF: Couldn't be decompiled
      // Please report this to the Vineflower issue tracker, at https://github.com/Vineflower/vineflower/issues with a copy of the class file (if you have the rights to distribute it!)
      // java.lang.IllegalStateException: Invalid class="kw">switch case set: [[const(0)], [var0_1 class="kw">instanceof var3_1], [null]] for selector of type Lcom/hypixel/hytale/builtin/beds/sleep/systems/world/CanSleepInWorld$Result;
      //   at org.jetbrains.java.decompiler.modules.decompiler.exps.SwitchHeadExprent.checkExprTypeBounds(SwitchHeadExprent.java:63)
      //   at org.jetbrains.java.decompiler.modules.decompiler.vars.VarTypeProcessor.checkTypeExpr(VarTypeProcessor.java:156)
      //   at org.jetbrains.java.decompiler.modules.decompiler.vars.VarTypeProcessor.checkTypeExprent(VarTypeProcessor.java:137)
      //   at org.jetbrains.java.decompiler.modules.decompiler.vars.VarTypeProcessor.lambda$processVarTypes$2(VarTypeProcessor.java:125)
      //   at org.jetbrains.java.decompiler.modules.decompiler.flow.DirectGraph.iterateExprents(DirectGraph.java:114)
      //   at org.jetbrains.java.decompiler.modules.decompiler.vars.VarTypeProcessor.processVarTypes(VarTypeProcessor.java:125)
      //   at org.jetbrains.java.decompiler.modules.decompiler.vars.VarTypeProcessor.calculateVarTypes(VarTypeProcessor.java:44)
      //   at org.jetbrains.java.decompiler.modules.decompiler.vars.VarVersionsProcessor.setVarVersions(VarVersionsProcessor.java:68)
      //   at org.jetbrains.java.decompiler.modules.decompiler.vars.VarProcessor.setVarVersions(VarProcessor.java:47)
      //   at org.jetbrains.java.decompiler.main.rels.MethodProcessor.codeToJava(MethodProcessor.java:320)
      //
      // Bytecode:
      // 00: aload 0
      // 01: dup
      // 02: invokestatic java/util/Objects.requireNonNull (Ljava/lang/Object;)Ljava/lang/Object;
      // 05: pop
      // 06: astore 1
      // 07: bipush 0
      // 08: istore 2
      // 09: aload 1
      // 0a: iload 2
      // 0b: invokedynamic typeSwitch (Lcom/hypixel/hytale/builtin/beds/sleep/systems/world/CanSleepInWorld$Result;I)I bsm=java/lang/runtime/SwitchBootstraps.typeSwitch (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite; args=[ null.invoke Ljava/lang/Enum$EnumDesc;, com/hypixel/hytale/builtin/beds/sleep/systems/world/CanSleepInWorld$NotDuringSleepHoursRange ]
      // 10: lookupswitch 45 2 0 28 1 34
      // 2c: getstatic com/hypixel/hytale/builtin/beds/sleep/systems/player/EnterBedSystem.MESSAGE_SERVER_INTERACTIONS_SLEEP_GAME_TIME_PAUSED Lcom/hypixel/hytale/server/core/Message;
      // 2f: goto 40
      // 32: aload 1
      // 33: checkcast com/hypixel/hytale/builtin/beds/sleep/systems/world/CanSleepInWorld$NotDuringSleepHoursRange
      // 36: astore 3
      // 37: getstatic com/hypixel/hytale/builtin/beds/sleep/systems/player/EnterBedSystem.MESSAGE_SERVER_INTERACTIONS_SLEEP_NOT_WITHIN_HOURS Lcom/hypixel/hytale/server/core/Message;
      // 3a: goto 40
      // 3d: getstatic com/hypixel/hytale/builtin/beds/sleep/systems/player/EnterBedSystem.MESSAGE_SERVER_INTERACTIONS_SLEEP_DISABLED Lcom/hypixel/hytale/server/core/Message;
      // 40: areturn
   }

   @Nonnull
   class="kw">private class="kw">static Message formatDuration(@Nonnull Duration var0) {
      long var1 = var0.toMinutes();
      long var3 = var1 / 60L;
      long var5 = var1 % 60L;
      String var7 = var3 > 0L ? "server.interactions.sleep.durationHours" : "server.interactions.sleep.durationMins";
      class="kw">return Message.translation(var7).param("hours", var3).param("mins", var3 == 0L ? String.valueOf(var5) : String.format("%02d", var5));
   }
}