DeathConfig class

Пакет: com.hypixel.hytale.server.core.asset.type.gameplay

Файл: com/hypixel/hytale/server/core/asset/type/gameplay/DeathConfig.java

Поля (2)

МодификаторыТипИмя
NONE, ALL, CONFIGURED
final EnumCodec<DeathConfig.ItemsLossMode> LOSS_MODE_CODEC

Методы (4)

МодификаторыВозвратСигнатура
ItemsLossMode ItemsLossMode()
public double getItemsAmountLossPercentagedouble getItemsAmountLossPercentage()
public double getItemsDurabilityLossPercentagedouble getItemsDurabilityLossPercentage()
public DeathConfig.ItemsLossMode getItemsLossModeDeathConfig.ItemsLossMode getItemsLossMode()

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.core.asset.type.gameplay;

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.codec.codecs.EnumCodec;
class="kw">import com.hypixel.hytale.codec.validation.Validators;
class="kw">import com.hypixel.hytale.server.core.asset.type.gamemode.GameModeType;
class="kw">import com.hypixel.hytale.server.core.asset.type.gameplay.respawn.HomeOrSpawnPoint;
class="kw">import com.hypixel.hytale.server.core.asset.type.gameplay.respawn.RespawnController;
class="kw">import javax.annotation.Nonnull;
class="kw">import javax.annotation.Nullable;

class="kw">public class DeathConfig {
   class="kw">public class="kw">static class="kw">final EnumCodec<DeathConfig.ItemsLossMode> LOSS_MODE_CODEC = new EnumCodec<>(DeathConfig.ItemsLossMode.class);
   @Nonnull
   class="kw">public class="kw">static class="kw">final BuilderCodec<DeathConfig> CODEC = BuilderCodec.builder(DeathConfig.class, DeathConfig::new)
      .appendInherited(
         new KeyedCodec<>("RespawnController", RespawnController.CODEC),
         (var0, var1) -> var0.respawnController = var1,
         var0 -> var0.respawnController,
         (var0, var1) -> var0.respawnController = var1.respawnController
      )
      .addValidator(Validators.nonNull())
      .documentation("The respawn controller that determines where the player respawns.")
      .add()
      .<DeathConfig.ItemsLossMode>appendInherited(
         new KeyedCodec<>("ItemsLossMode", LOSS_MODE_CODEC),
         (var0, var1) -> var0.itemsLossMode = var1,
         var0 -> var0.itemsLossMode,
         (var0, var1) -> var0.itemsLossMode = var1.itemsLossMode
      )
      .documentation("The mode used to compute what the entity will lose upon death.")
      .add()
      .<Double>appendInherited(
         new KeyedCodec<>("ItemsAmountLossPercentage", Codec.DOUBLE),
         (var0, var1) -> var0.itemsAmountLossPercentage = var1,
         var0 -> var0.itemsAmountLossPercentage,
         (var0, var1) -> var0.itemsAmountLossPercentage = var1.itemsAmountLossPercentage
      )
      .addValidator(Validators.range(0.0, 100.0))
      .documentation(
         "The amount (in %) of items lost for an ItemStack upon death (applied to the entire inventory). Used ONLY if `ItemsLossMode` is set to 'Configured` and applied to items that have `DropOnDeath` set to `true`."
      )
      .add()
      .<Double>appendInherited(
         new KeyedCodec<>("ItemsDurabilityLossPercentage", Codec.DOUBLE),
         (var0, var1) -> var0.itemsDurabilityLossPercentage = var1,
         var0 -> var0.itemsDurabilityLossPercentage,
         (var0, var1) -> var0.itemsDurabilityLossPercentage = var1.itemsDurabilityLossPercentage
      )
      .addValidator(Validators.range(0.0, 100.0))
      .documentation("The amount of durability (in %) items lose upon death (applied to the entire inventory).")
      .add()
      .<String>appendInherited(
         new KeyedCodec<>("GameModeTypeOnDeath", Codec.STRING),
         (var0, var1) -> var0.gameModeTypeOnDeath = var1,
         var0 -> var0.gameModeTypeOnDeath,
         (var0, var1) -> var0.gameModeTypeOnDeath = var1.gameModeTypeOnDeath
      )
      .addValidatorLate(() -> GameModeType.VALIDATOR_CACHE.getValidator().late())
      .documentation(
         "When set, dying players skip the respawn screen, respawn in place, and enter this GameModeType. When unset, normal death behavior applies."
      )
      .add()
      .build();
   @Nonnull
   class="kw">protected RespawnController respawnController = HomeOrSpawnPoint.INSTANCE;
   class="kw">protected DeathConfig.ItemsLossMode itemsLossMode = DeathConfig.ItemsLossMode.NONE;
   class="kw">protected double itemsAmountLossPercentage = 10.0;
   class="kw">protected double itemsDurabilityLossPercentage = 10.0;
   @Nullable
   class="kw">protected String gameModeTypeOnDeath;

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

   @Nonnull
   class="kw">public RespawnController getRespawnController() {
      class="kw">return this.respawnController;
   }

   class="kw">public DeathConfig.ItemsLossMode getItemsLossMode() {
      class="kw">return this.itemsLossMode;
   }

   class="kw">public double getItemsAmountLossPercentage() {
      class="kw">return this.itemsAmountLossPercentage;
   }

   class="kw">public double getItemsDurabilityLossPercentage() {
      class="kw">return this.itemsDurabilityLossPercentage;
   }

   @Nullable
   class="kw">public String getGameModeTypeOnDeath() {
      class="kw">return this.gameModeTypeOnDeath;
   }

   class="kw">public enum ItemsLossMode {
      NONE,
      ALL,
      CONFIGURED;

      ItemsLossMode() {
      }
   }
}