Constants interface

Пакет: com.hypixel.hytale.server.worldgen.loader.cave

Файл: com/hypixel/hytale/server/worldgen/loader/cave/CaveNodeTypeStorage.java

Поля (3)

МодификаторыТипИмя
String ERROR_ALREADY_ADDED
String ERROR_LOADING_CAVE_NODE_TYPE
String FILE_SUFFIX

Исходный код

Показать/скрыть
class="kw">package com.hypixel.hytale.server.worldgen.loader.cave;

class="kw">import com.google.gson.JsonObject;
class="kw">import com.hypixel.hytale.common.util.PathUtil;
class="kw">import com.hypixel.hytale.procedurallib.file.FileIO;
class="kw">import com.hypixel.hytale.procedurallib.json.JsonLoader;
class="kw">import com.hypixel.hytale.procedurallib.json.SeedString;
class="kw">import com.hypixel.hytale.server.worldgen.SeedStringResource;
class="kw">import com.hypixel.hytale.server.worldgen.cave.CaveNodeType;
class="kw">import com.hypixel.hytale.server.worldgen.loader.context.ZoneFileContext;
class="kw">import java.io.File;
class="kw">import java.nio.file.Path;
class="kw">import java.util.HashMap;
class="kw">import java.util.Map;
class="kw">import javax.annotation.Nonnull;

class="kw">public class CaveNodeTypeStorage {
   class="kw">protected class="kw">final SeedString<SeedStringResource> seed;
   class="kw">protected class="kw">final Path dataFolder;
   class="kw">protected class="kw">final Path caveFolder;
   class="kw">protected class="kw">final ZoneFileContext zoneContext;
   @Nonnull
   class="kw">protected class="kw">final Map<String, CaveNodeType> caveNodeTypes;

   class="kw">public CaveNodeTypeStorage(SeedString<SeedStringResource> var1, Path var2, Path var3, ZoneFileContext var4) {
      this.seed = var1;
      this.dataFolder = var2;
      this.caveFolder = var3;
      this.zoneContext = var4;
      this.caveNodeTypes = new HashMap<>();
   }

   class="kw">public SeedString<SeedStringResource> getSeed() {
      class="kw">return this.seed;
   }

   class="kw">public void add(String var1, CaveNodeType var2) {
      if (this.caveNodeTypes.containsKey(var1)) {
         throw new Error(String.format("CaveNodeType (%s) has already been added to CaveNodeTypeStorage!", var1));
      }

      this.caveNodeTypes.put(var1, var2);
   }

   @Nonnull
   class="kw">public CaveNodeType getOrLoadCaveNodeType(@Nonnull String var1) {
      CaveNodeType var2 = this.getCaveNodeType(var1);
      if (var2 == null) {
         var2 = this.loadCaveNodeType(var1);
      }

      class="kw">return var2;
   }

   class="kw">public CaveNodeType getCaveNodeType(String var1) {
      class="kw">return this.caveNodeTypes.get(var1);
   }

   @Nonnull
   class="kw">public CaveNodeType loadCaveNodeType(@Nonnull String var1) {
      String var2 = String.format("%s.node.json", var1.replace(".", File.separator));
      Path var3 = PathUtil.resolvePathWithinDir(this.caveFolder, var2);
      if (var3 == null) {
         throw new Error(String.format("Invalid cave node type name: %s", var1));
      }

      try {
         JsonObject var4 = FileIO.load(var3, JsonLoader.JSON_OBJ_LOADER);
         class="kw">return this.loadCaveNodeType(var1, var4);
      } catch (Throwable var5) {
         throw new Error(String.format("Error while loading CaveNodeType %s for world generator from %s", var1, var3.toString()), var5);
      }
   }

   @Nonnull
   class="kw">public CaveNodeType loadCaveNodeType(@Nonnull String var1, @Nonnull JsonObject var2) {
      class="kw">return new CaveNodeTypeJsonLoader(this.seed, this.dataFolder, var2, var1, this, this.zoneContext).load();
   }

   class="kw">public class="kw">interface Constants {
      String ERROR_ALREADY_ADDED = "CaveNodeType (%s) has already been added to CaveNodeTypeStorage!";
      String ERROR_LOADING_CAVE_NODE_TYPE = "Error while loading CaveNodeType %s for world generator from %s";
      String FILE_SUFFIX = "%s.node.json";
   }
}