HardcoreState class

Пакет: com.hypixel.hytale.server.core.universe.hardcore

Файл: com/hypixel/hytale/server/core/universe/hardcore/HardcoreState.java

Поля (2)

МодификаторыТипИмя
final int UNSEEDED
int var2

Методы (4)

МодификаторыВозвратСигнатура
public int burnPoolLifeint burnPoolLife(int var1)
public int getPoolRemainingint getPoolRemaining(int var1)
public boolean isGameOverboolean isGameOver()
public boolean markGameOverboolean markGameOver()

Исходный код

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

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.server.core.modules.entity.EntityModule;
class="kw">import com.hypixel.hytale.server.core.universe.resources.UniverseResourceType;
class="kw">import java.util.concurrent.atomic.AtomicBoolean;
class="kw">import java.util.concurrent.atomic.AtomicInteger;
class="kw">import javax.annotation.Nonnull;

class="kw">public class HardcoreState {
   class="kw">private class="kw">static class="kw">final int UNSEEDED = Integer.MIN_VALUE;
   class="kw">public class="kw">static class="kw">final BuilderCodec<HardcoreState> CODEC = BuilderCodec.builder(HardcoreState.class, HardcoreState::new)
      .append(new KeyedCodec<>("PoolRemaining", Codec.INTEGER), (var0, var1) -> var0.poolRemaining.set(var1), var0 -> var0.poolRemaining.get())
      .add()
      .append(new KeyedCodec<>("GameOver", Codec.BOOLEAN), (var0, var1) -> var0.gameOver.set(var1), var0 -> var0.gameOver.get())
      .add()
      .build();
   @Nonnull
   class="kw">private class="kw">final AtomicInteger poolRemaining = new AtomicInteger(Integer.MIN_VALUE);
   @Nonnull
   class="kw">private class="kw">final AtomicBoolean gameOver = new AtomicBoolean();

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

   @Nonnull
   class="kw">public class="kw">static UniverseResourceType<HardcoreState> getResourceType() {
      class="kw">return EntityModule.get().getHardcoreStateResourceType();
   }

   class="kw">public int burnPoolLife(int var1) {
      class="kw">return this.poolRemaining.updateAndGet(var1x -> (var1x == Integer.MIN_VALUE ? var1 : var1x) - 1);
   }

   class="kw">public int getPoolRemaining(int var1) {
      int var2 = this.poolRemaining.get();
      class="kw">return var2 == Integer.MIN_VALUE ? var1 : Math.max(var2, 0);
   }

   class="kw">public boolean isGameOver() {
      class="kw">return this.gameOver.get();
   }

   class="kw">public boolean markGameOver() {
      class="kw">return this.gameOver.compareAndSet(false, true);
   }
}