@Test public void testFromMinecraft1_12_2() { SuperflatPreset superflatPreset = SuperflatPreset.fromMinecraft1_12_2("3;minecraft:bedrock,59*minecraft:stone,3*minecraft:dirt,minecraft:grass;1;village,biome_1,decoration,stronghold,mineshaft,lake,lava_lake,dungeon"); SuperflatPreset expected = new SuperflatPreset(BIOME_PLAINS, ImmutableList.of(new Layer(MC_BEDROCK, 1), new Layer(MC_STONE, 59), new Layer(MC_DIRT, 3), new Layer(MC_GRASS, 1)), ImmutableMap.<Structure, Map<String, String>>builder() .put(VILLAGE, emptyMap()) .put(BIOME_1, emptyMap()) .put(DECORATION, emptyMap()) .put(STRONGHOLD, emptyMap()) .put(MINESHAFT, emptyMap()) .put(LAKE, emptyMap()) .put(LAVA_LAKE, emptyMap()) .put(DUNGEON, emptyMap()) .build()); Assert.assertEquals(expected, superflatPreset); }
public static SuperflatPreset fromMinecraft1_12_2(String str) { String[] tokens = str.split(";"); if ((tokens.length < 3) || (! tokens[0].equals("3"))) { throw new IllegalArgumentException("Invalid Superflat preset for Minecraft 1.12.2: " + str + " (too few tokens, or invalid version)"); } List<Layer> layers = stream(tokens[1].split(",")).map(layerDescriptor -> { int p = layerDescriptor.indexOf('*'); if (p == -1) { return new Layer(layerDescriptor, 1); } else { return new Layer(layerDescriptor.substring(p + 1), Integer.parseInt(layerDescriptor.substring(0, p))); } }).collect(toList()); int biome = Integer.parseInt(tokens[2]); Map<Structure, Map<String, String>> structures = new HashMap<>(); if (tokens[3] != null) { stream(tokens[3].split(",")).forEach(structure -> { int p = structure.indexOf('('); if (p == -1) { structures.put(Structure.valueOf(structure.toUpperCase()), emptyMap()); } else { Structure key = Structure.valueOf(structure.substring(0, p).toUpperCase()); Map<String, String> params = new HashMap<>(); for (String attr: structure.substring(p + 1, structure.length() - 1).split(" ")) { p = attr.indexOf('='); if (p == -1) { throw new IllegalArgumentException("Invalid Superflat preset for Minecraft 1.12.2: " + str + " (parameter missing =)"); } params.put(attr.substring(0, p), attr.substring(p + 1)); } structures.put(key, params); } }); } return new SuperflatPreset(biome, layers, structures); }
SuperflatPreset implements Serializable { public static SuperflatPreset fromMinecraft1_12_2(String str) { String[] tokens = str.split(";"); if ((tokens.length < 3) || (! tokens[0].equals("3"))) { throw new IllegalArgumentException("Invalid Superflat preset for Minecraft 1.12.2: " + str + " (too few tokens, or invalid version)"); } List<Layer> layers = stream(tokens[1].split(",")).map(layerDescriptor -> { int p = layerDescriptor.indexOf('*'); if (p == -1) { return new Layer(layerDescriptor, 1); } else { return new Layer(layerDescriptor.substring(p + 1), Integer.parseInt(layerDescriptor.substring(0, p))); } }).collect(toList()); int biome = Integer.parseInt(tokens[2]); Map<Structure, Map<String, String>> structures = new HashMap<>(); if (tokens[3] != null) { stream(tokens[3].split(",")).forEach(structure -> { int p = structure.indexOf('('); if (p == -1) { structures.put(Structure.valueOf(structure.toUpperCase()), emptyMap()); } else { Structure key = Structure.valueOf(structure.substring(0, p).toUpperCase()); Map<String, String> params = new HashMap<>(); for (String attr: structure.substring(p + 1, structure.length() - 1).split(" ")) { p = attr.indexOf('='); if (p == -1) { throw new IllegalArgumentException("Invalid Superflat preset for Minecraft 1.12.2: " + str + " (parameter missing =)"); } params.put(attr.substring(0, p), attr.substring(p + 1)); } structures.put(key, params); } }); } return new SuperflatPreset(biome, layers, structures); } }
SuperflatPreset implements Serializable { public static SuperflatPreset fromMinecraft1_12_2(String str) { String[] tokens = str.split(";"); if ((tokens.length < 3) || (! tokens[0].equals("3"))) { throw new IllegalArgumentException("Invalid Superflat preset for Minecraft 1.12.2: " + str + " (too few tokens, or invalid version)"); } List<Layer> layers = stream(tokens[1].split(",")).map(layerDescriptor -> { int p = layerDescriptor.indexOf('*'); if (p == -1) { return new Layer(layerDescriptor, 1); } else { return new Layer(layerDescriptor.substring(p + 1), Integer.parseInt(layerDescriptor.substring(0, p))); } }).collect(toList()); int biome = Integer.parseInt(tokens[2]); Map<Structure, Map<String, String>> structures = new HashMap<>(); if (tokens[3] != null) { stream(tokens[3].split(",")).forEach(structure -> { int p = structure.indexOf('('); if (p == -1) { structures.put(Structure.valueOf(structure.toUpperCase()), emptyMap()); } else { Structure key = Structure.valueOf(structure.substring(0, p).toUpperCase()); Map<String, String> params = new HashMap<>(); for (String attr: structure.substring(p + 1, structure.length() - 1).split(" ")) { p = attr.indexOf('='); if (p == -1) { throw new IllegalArgumentException("Invalid Superflat preset for Minecraft 1.12.2: " + str + " (parameter missing =)"); } params.put(attr.substring(0, p), attr.substring(p + 1)); } structures.put(key, params); } }); } return new SuperflatPreset(biome, layers, structures); } SuperflatPreset(int biome, List<Layer> layers, Map<Structure, Map<String, String>> structures); }
SuperflatPreset implements Serializable { public static SuperflatPreset fromMinecraft1_12_2(String str) { String[] tokens = str.split(";"); if ((tokens.length < 3) || (! tokens[0].equals("3"))) { throw new IllegalArgumentException("Invalid Superflat preset for Minecraft 1.12.2: " + str + " (too few tokens, or invalid version)"); } List<Layer> layers = stream(tokens[1].split(",")).map(layerDescriptor -> { int p = layerDescriptor.indexOf('*'); if (p == -1) { return new Layer(layerDescriptor, 1); } else { return new Layer(layerDescriptor.substring(p + 1), Integer.parseInt(layerDescriptor.substring(0, p))); } }).collect(toList()); int biome = Integer.parseInt(tokens[2]); Map<Structure, Map<String, String>> structures = new HashMap<>(); if (tokens[3] != null) { stream(tokens[3].split(",")).forEach(structure -> { int p = structure.indexOf('('); if (p == -1) { structures.put(Structure.valueOf(structure.toUpperCase()), emptyMap()); } else { Structure key = Structure.valueOf(structure.substring(0, p).toUpperCase()); Map<String, String> params = new HashMap<>(); for (String attr: structure.substring(p + 1, structure.length() - 1).split(" ")) { p = attr.indexOf('='); if (p == -1) { throw new IllegalArgumentException("Invalid Superflat preset for Minecraft 1.12.2: " + str + " (parameter missing =)"); } params.put(attr.substring(0, p), attr.substring(p + 1)); } structures.put(key, params); } }); } return new SuperflatPreset(biome, layers, structures); } SuperflatPreset(int biome, List<Layer> layers, Map<Structure, Map<String, String>> structures); int getBiome(); void setBiome(int biome); List<Layer> getLayers(); void setLayers(List<Layer> layers); Map<Structure, Map<String, String>> getStructures(); void setStructures(Map<Structure, Map<String, String>> structures); String toMinecraft1_12_2(); CompoundTag toMinecraft1_15_2(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static SuperflatPreset fromMinecraft1_12_2(String str); @SuppressWarnings("unchecked") // Guaranteed by Minecraft static SuperflatPreset fromMinecraft1_15_2(CompoundTag tag); static Builder builder(int biome, Structure... structures); }
SuperflatPreset implements Serializable { public static SuperflatPreset fromMinecraft1_12_2(String str) { String[] tokens = str.split(";"); if ((tokens.length < 3) || (! tokens[0].equals("3"))) { throw new IllegalArgumentException("Invalid Superflat preset for Minecraft 1.12.2: " + str + " (too few tokens, or invalid version)"); } List<Layer> layers = stream(tokens[1].split(",")).map(layerDescriptor -> { int p = layerDescriptor.indexOf('*'); if (p == -1) { return new Layer(layerDescriptor, 1); } else { return new Layer(layerDescriptor.substring(p + 1), Integer.parseInt(layerDescriptor.substring(0, p))); } }).collect(toList()); int biome = Integer.parseInt(tokens[2]); Map<Structure, Map<String, String>> structures = new HashMap<>(); if (tokens[3] != null) { stream(tokens[3].split(",")).forEach(structure -> { int p = structure.indexOf('('); if (p == -1) { structures.put(Structure.valueOf(structure.toUpperCase()), emptyMap()); } else { Structure key = Structure.valueOf(structure.substring(0, p).toUpperCase()); Map<String, String> params = new HashMap<>(); for (String attr: structure.substring(p + 1, structure.length() - 1).split(" ")) { p = attr.indexOf('='); if (p == -1) { throw new IllegalArgumentException("Invalid Superflat preset for Minecraft 1.12.2: " + str + " (parameter missing =)"); } params.put(attr.substring(0, p), attr.substring(p + 1)); } structures.put(key, params); } }); } return new SuperflatPreset(biome, layers, structures); } SuperflatPreset(int biome, List<Layer> layers, Map<Structure, Map<String, String>> structures); int getBiome(); void setBiome(int biome); List<Layer> getLayers(); void setLayers(List<Layer> layers); Map<Structure, Map<String, String>> getStructures(); void setStructures(Map<Structure, Map<String, String>> structures); String toMinecraft1_12_2(); CompoundTag toMinecraft1_15_2(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static SuperflatPreset fromMinecraft1_12_2(String str); @SuppressWarnings("unchecked") // Guaranteed by Minecraft static SuperflatPreset fromMinecraft1_15_2(CompoundTag tag); static Builder builder(int biome, Structure... structures);  }