Cleanup, remove "Friendly Name" because it's pointless

This commit is contained in:
dfsek 2020-10-01 00:45:00 -07:00
parent d239358afe
commit 9a300c9cec
6 changed files with 18 additions and 63 deletions

View File

@ -45,7 +45,7 @@ public class TerraCommand implements CommandExecutor, TabExecutor {
return true; return true;
case "biome": case "biome":
if(! (sender instanceof Player)) return false; if(! (sender instanceof Player)) return false;
sender.sendMessage("You are in " + BiomeConfig.fromBiome((UserDefinedBiome) TerraBiomeGrid.fromWorld(((Player) sender).getWorld()).getBiome(((Player) sender).getLocation(), GenerationPhase.POPULATE)).getFriendlyName()); sender.sendMessage("You are in " + BiomeConfig.fromBiome((UserDefinedBiome) TerraBiomeGrid.fromWorld(((Player) sender).getWorld()).getBiome(((Player) sender).getLocation(), GenerationPhase.POPULATE)).getID());
return true; return true;
case "profile": case "profile":
if(! (sender instanceof Player)) { if(! (sender instanceof Player)) {

View File

@ -41,7 +41,6 @@ public class BiomeConfig extends TerraConfigObject {
private static final Palette<BlockData> oceanDefault = new RandomPalette<BlockData>(new Random(0)).add(Material.WATER.createBlockData(), 1); private static final Palette<BlockData> oceanDefault = new RandomPalette<BlockData>(new Random(0)).add(Material.WATER.createBlockData(), 1);
private UserDefinedBiome biome; private UserDefinedBiome biome;
private String biomeID; private String biomeID;
private String friendlyName;
private Map<OreConfig, Range> ores; private Map<OreConfig, Range> ores;
private Map<OreConfig, Range> oreHeights; private Map<OreConfig, Range> oreHeights;
private Map<CarverConfig, Integer> carvers; private Map<CarverConfig, Integer> carvers;
@ -62,11 +61,10 @@ public class BiomeConfig extends TerraConfigObject {
} }
@Override @Override
@SuppressWarnings("unchecked, rawtypes")
public void init() throws InvalidConfigurationException { public void init() throws InvalidConfigurationException {
if(!contains("id")) throw new InvalidConfigurationException("Biome ID unspecified!"); if(!contains("id")) throw new InvalidConfigurationException("Biome ID unspecified!");
this.biomeID = getString("id"); this.biomeID = getString("id");
if(!contains("name")) throw new InvalidConfigurationException("Biome Name unspecified!");
this.friendlyName = getString("name");
if(!contains("noise-equation") && !contains("extends")) throw new InvalidConfigurationException("Biomes must either include noise equation or extend biome containing an equation."); if(!contains("noise-equation") && !contains("extends")) throw new InvalidConfigurationException("Biomes must either include noise equation or extend biome containing an equation.");
AbstractBiomeConfig abstractBiome = null; AbstractBiomeConfig abstractBiome = null;
@ -103,18 +101,18 @@ public class BiomeConfig extends TerraConfigObject {
try { try {
paletteMap.put((Integer) entry.getValue(), new RandomPalette<BlockData>(new Random(0)).add(new ProbabilityCollection<BlockData>().add(Bukkit.createBlockData(((String) entry.getKey()).substring(6)), 1), 1)); paletteMap.put((Integer) entry.getValue(), new RandomPalette<BlockData>(new Random(0)).add(new ProbabilityCollection<BlockData>().add(Bukkit.createBlockData(((String) entry.getKey()).substring(6)), 1), 1));
} catch(IllegalArgumentException ex) { } catch(IllegalArgumentException ex) {
throw new InvalidConfigurationException("SEVERE configuration error for Palettes in biome " + getFriendlyName() + ", ID: " + biomeID + ". BlockData " + entry.getKey() + " is invalid!"); throw new InvalidConfigurationException("SEVERE configuration error for Palettes in biome ID: " + biomeID + ". BlockData " + entry.getKey() + " is invalid!");
} }
} }
else { else {
try { try {
paletteMap.put((Integer) entry.getValue(), PaletteConfig.fromID((String) entry.getKey()).getPalette()); paletteMap.put((Integer) entry.getValue(), PaletteConfig.fromID((String) entry.getKey()).getPalette());
} catch(NullPointerException ex) { } catch(NullPointerException ex) {
throw new InvalidConfigurationException("SEVERE configuration error for Palettes in biome " + getFriendlyName() + ", ID: " + biomeID + "\n\nPalette " + entry.getKey() + " cannot be found!"); throw new InvalidConfigurationException("SEVERE configuration error for Palettes in biome ID: " + biomeID + "\n\nPalette " + entry.getKey() + " cannot be found!");
} }
} }
} catch(ClassCastException ex) { } catch(ClassCastException ex) {
throw new InvalidConfigurationException("SEVERE configuration error for Palettes in biome " + getFriendlyName() + ", ID: " + biomeID); throw new InvalidConfigurationException("SEVERE configuration error for Palettes in biome ID: " + biomeID);
} }
} }
} }
@ -140,9 +138,9 @@ public class BiomeConfig extends TerraConfigObject {
Bukkit.getLogger().info("Got carver " + c + ". Adding with weight " + entry.getValue()); Bukkit.getLogger().info("Got carver " + c + ". Adding with weight " + entry.getValue());
carvers.put(c, (Integer) entry.getValue()); carvers.put(c, (Integer) entry.getValue());
} catch(ClassCastException ex) { } catch(ClassCastException ex) {
throw new InvalidConfigurationException("SEVERE configuration error for Carvers in biome " + getFriendlyName() + ", ID: " + biomeID); throw new InvalidConfigurationException("SEVERE configuration error for Carvers in biome ID: " + biomeID);
} catch(NullPointerException ex) { } catch(NullPointerException ex) {
throw new InvalidConfigurationException("SEVERE configuration error for Carvers in biome " + getFriendlyName() + ", ID: " + biomeID + "\n\n" + "No such carver " + entry.getKey()); throw new InvalidConfigurationException("SEVERE configuration error for Carvers in biome ID: " + biomeID + "\n\n" + "No such carver " + entry.getKey());
} }
} }
} }
@ -212,13 +210,13 @@ public class BiomeConfig extends TerraConfigObject {
flora.add(floraCustom, (Integer) val.get("weight")); flora.add(floraCustom, (Integer) val.get("weight"));
floraHeights.put(floraCustom, new Range((Integer) y.get("min"), (Integer) y.get("max"))); floraHeights.put(floraCustom, new Range((Integer) y.get("min"), (Integer) y.get("max")));
} catch(NullPointerException ex2) { } catch(NullPointerException ex2) {
throw new InvalidConfigurationException("SEVERE configuration error for flora in biome " + getFriendlyName() + ", ID " + getID() + "\n\nFlora with ID " + e.getKey() + " cannot be found!"); throw new InvalidConfigurationException("SEVERE configuration error for flora in biome ID " + getID() + "\n\nFlora with ID " + e.getKey() + " cannot be found!");
} }
} }
} }
} catch(ClassCastException e) { } catch(ClassCastException e) {
if(ConfigUtil.debug) e.printStackTrace(); if(ConfigUtil.debug) e.printStackTrace();
throw new InvalidConfigurationException("SEVERE configuration error for flora in biome " + getFriendlyName() + ", ID " + getID()); throw new InvalidConfigurationException("SEVERE configuration error for flora in biome ID " + getID());
} }
} else flora = new ProbabilityCollection<>(); } else flora = new ProbabilityCollection<>();
@ -292,13 +290,13 @@ public class BiomeConfig extends TerraConfigObject {
try { try {
ocean = new RandomPalette<BlockData>(new Random(0)).add(new ProbabilityCollection<BlockData>().add(Bukkit.createBlockData(oceanPalette.substring(6)), 1), 1); ocean = new RandomPalette<BlockData>(new Random(0)).add(new ProbabilityCollection<BlockData>().add(Bukkit.createBlockData(oceanPalette.substring(6)), 1), 1);
} catch(IllegalArgumentException ex) { } catch(IllegalArgumentException ex) {
throw new InvalidConfigurationException("SEVERE configuration error for Ocean Palette in biome " + getFriendlyName() + ", ID: " + biomeID + ". BlockData " + oceanPalette + " is invalid!"); throw new InvalidConfigurationException("SEVERE configuration error for Ocean Palette in biome ID: " + biomeID + ". BlockData " + oceanPalette + " is invalid!");
} }
} else { } else {
try { try {
ocean = PaletteConfig.fromID(oceanPalette).getPalette(); ocean = PaletteConfig.fromID(oceanPalette).getPalette();
} catch(NullPointerException ex) { } catch(NullPointerException ex) {
throw new InvalidConfigurationException("SEVERE configuration error for Ocean Palette in biome " + getFriendlyName() + ", ID: " + biomeID + "\n\nPalette " + oceanPalette + " cannot be found!"); throw new InvalidConfigurationException("SEVERE configuration error for Ocean Palette in biome ID: " + biomeID + "\n\nPalette " + oceanPalette + " cannot be found!");
} }
} }
} else ocean = oceanDefault; } else ocean = oceanDefault;
@ -375,10 +373,6 @@ public class BiomeConfig extends TerraConfigObject {
return biomeID; return biomeID;
} }
public String getFriendlyName() {
return friendlyName;
}
public Map<OreConfig, Range> getOres() { public Map<OreConfig, Range> getOres() {
return ores; return ores;
} }
@ -407,7 +401,7 @@ public class BiomeConfig extends TerraConfigObject {
@Override @Override
public String toString() { public String toString() {
return "Biome with name " + getFriendlyName() + ", ID " + getID() + " and noise equation " + eq; return "Biome with ID " + getID() + " and noise equation " + eq;
} }
public int getCarverChance(UserDefinedCarver c) { public int getCarverChance(UserDefinedCarver c) {

View File

@ -19,7 +19,6 @@ import java.util.Objects;
public class BiomeGridConfig extends TerraConfigObject { public class BiomeGridConfig extends TerraConfigObject {
private static final Map<String, BiomeGridConfig> biomeGrids = new HashMap<>(); private static final Map<String, BiomeGridConfig> biomeGrids = new HashMap<>();
private String gridID; private String gridID;
private String friendlyName;
private boolean isEnabled = false; private boolean isEnabled = false;
private UserDefinedBiome[][] gridRaw; private UserDefinedBiome[][] gridRaw;
private int sizeX; private int sizeX;
@ -34,8 +33,6 @@ public class BiomeGridConfig extends TerraConfigObject {
isEnabled = false; isEnabled = false;
if(!contains("id")) throw new InvalidConfigurationException("Grid ID unspecified!"); if(!contains("id")) throw new InvalidConfigurationException("Grid ID unspecified!");
this.gridID = getString("id"); this.gridID = getString("id");
if(!contains("name")) throw new InvalidConfigurationException("Grid Name unspecified!");
this.friendlyName = getString("name");
if(!contains("grid")) throw new InvalidConfigurationException("Grid not found!"); if(!contains("grid")) throw new InvalidConfigurationException("Grid not found!");
this.sizeX = Objects.requireNonNull(getList("grid")).size(); this.sizeX = Objects.requireNonNull(getList("grid")).size();
this.sizeZ = ((List<List<String>>) getList("grid")).get(0).size(); this.sizeZ = ((List<List<String>>) getList("grid")).get(0).size();
@ -46,7 +43,7 @@ public class BiomeGridConfig extends TerraConfigObject {
try { try {
gridRaw[x][z] = BiomeConfig.fromID(((List<List<String>>) getList("grid")).get(x).get(z)).getBiome(); gridRaw[x][z] = BiomeConfig.fromID(((List<List<String>>) getList("grid")).get(x).get(z)).getBiome();
} catch(NullPointerException e) { } catch(NullPointerException e) {
throw new InvalidConfigurationException("SEVERE configuration error for BiomeGrid " + getFriendlyName() + ", ID: " + getID() + "\n\nNo such biome " + ((List<List<String>>) getList("grid")).get(x).get(z)); throw new InvalidConfigurationException("SEVERE configuration error for BiomeGrid ID: " + getID() + "\n\nNo such biome " + ((List<List<String>>) getList("grid")).get(x).get(z));
} }
} }
} }
@ -65,10 +62,6 @@ public class BiomeGridConfig extends TerraConfigObject {
return sizeZ; return sizeZ;
} }
public String getFriendlyName() {
return friendlyName;
}
public UserDefinedBiome[][] getBiomeGrid() { public UserDefinedBiome[][] getBiomeGrid() {
return gridRaw; return gridRaw;
} }
@ -88,7 +81,7 @@ public class BiomeGridConfig extends TerraConfigObject {
@Override @Override
public String toString() { public String toString() {
return "BiomeGrid with ID " + getID() + ", name " + getFriendlyName() + ", dimensions " + getSizeX() + ":" + getSizeZ(); return "BiomeGrid with ID " + getID() + ", dimensions " + getSizeX() + ":" + getSizeZ();
} }
public static Map<String, BiomeGridConfig> getBiomeGrids() { public static Map<String, BiomeGridConfig> getBiomeGrids() {

View File

@ -1,16 +1,13 @@
package com.dfsek.terra.config.genconfig; package com.dfsek.terra.config.genconfig;
import com.dfsek.terra.config.ConfigUtil;
import com.dfsek.terra.config.TerraConfigObject; import com.dfsek.terra.config.TerraConfigObject;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Chunk; import org.bukkit.Chunk;
import org.bukkit.ChunkSnapshot;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.util.Vector;
import org.polydev.gaea.math.Range; import org.polydev.gaea.math.Range;
import org.polydev.gaea.world.Flora; import org.polydev.gaea.world.Flora;
import org.polydev.gaea.world.palette.Palette; import org.polydev.gaea.world.palette.Palette;
@ -30,7 +27,6 @@ public class FloraConfig extends TerraConfigObject implements Flora {
private static final Map<String, FloraConfig> floraConfig = new HashMap<>(); private static final Map<String, FloraConfig> floraConfig = new HashMap<>();
private Palette<BlockData> floraPalette; private Palette<BlockData> floraPalette;
private String id; private String id;
private String friendlyName;
Set<Material> spawnable; Set<Material> spawnable;
Set<Material> replaceable; Set<Material> replaceable;
@ -71,15 +67,9 @@ public class FloraConfig extends TerraConfigObject implements Flora {
floraPalette = PaletteConfig.getPalette(getMapList("blocks"), p); floraPalette = PaletteConfig.getPalette(getMapList("blocks"), p);
if(!contains("id")) throw new InvalidConfigurationException("Flora ID unspecified!"); if(!contains("id")) throw new InvalidConfigurationException("Flora ID unspecified!");
this.id = getString("id"); this.id = getString("id");
if(!contains("name")) throw new InvalidConfigurationException("Flora Name unspecified!");
this.friendlyName = getString("name");
floraConfig.put(id, this); floraConfig.put(id, this);
} }
public String getFriendlyName() {
return friendlyName;
}
public String getID() { public String getID() {
return id; return id;
} }
@ -110,7 +100,7 @@ public class FloraConfig extends TerraConfigObject implements Flora {
@Override @Override
public String toString() { public String toString() {
return "Flora with name " + getFriendlyName() + ", ID " + getID(); return "Flora with name ID " + getID();
} }
public static FloraConfig fromID(String id) { public static FloraConfig fromID(String id) {

View File

@ -27,8 +27,6 @@ public class OreConfig extends TerraConfigObject {
private double deform; private double deform;
private double deformFrequency; private double deformFrequency;
private String id; private String id;
private String friendlyName;
private int h;
List<Material> replaceable; List<Material> replaceable;
public OreConfig(File file) throws IOException, InvalidConfigurationException { public OreConfig(File file) throws IOException, InvalidConfigurationException {
super(file); super(file);
@ -42,7 +40,6 @@ public class OreConfig extends TerraConfigObject {
if(!contains("replace")) throw new InvalidConfigurationException("Ore replaceable materials not found!"); if(!contains("replace")) throw new InvalidConfigurationException("Ore replaceable materials not found!");
min = getInt("radius.min", 1); min = getInt("radius.min", 1);
max = getInt("radius.max", 1); max = getInt("radius.max", 1);
h = 2;
deform = getDouble("deform"); deform = getDouble("deform");
deformFrequency = getDouble("deform-frequency"); deformFrequency = getDouble("deform-frequency");
this.id = getString("id"); this.id = getString("id");
@ -86,17 +83,13 @@ public class OreConfig extends TerraConfigObject {
@Override @Override
public String toString() { public String toString() {
return "Ore with name " + getFriendlyName() + ", ID " + getID(); return "Ore with ID " + getID();
} }
public String getID() { public String getID() {
return id; return id;
} }
public String getFriendlyName() {
return friendlyName;
}
public static OreConfig fromID(String id) { public static OreConfig fromID(String id) {
return ores.get(id); return ores.get(id);
} }

View File

@ -1,11 +1,9 @@
package com.dfsek.terra.config.genconfig; package com.dfsek.terra.config.genconfig;
import com.dfsek.terra.config.ConfigLoader;
import com.dfsek.terra.config.TerraConfigObject; import com.dfsek.terra.config.TerraConfigObject;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.plugin.java.JavaPlugin;
import org.polydev.gaea.math.FastNoise; import org.polydev.gaea.math.FastNoise;
import org.polydev.gaea.math.ProbabilityCollection; import org.polydev.gaea.math.ProbabilityCollection;
import org.polydev.gaea.world.palette.Palette; import org.polydev.gaea.world.palette.Palette;
@ -23,8 +21,6 @@ public class PaletteConfig extends TerraConfigObject {
private static final Map<String, PaletteConfig> palettes = new HashMap<>(); private static final Map<String, PaletteConfig> palettes = new HashMap<>();
private Palette<BlockData> palette; private Palette<BlockData> palette;
private String paletteID; private String paletteID;
private boolean isEnabled = false;
private String friendlyName;
private boolean useNoise = false; private boolean useNoise = false;
public PaletteConfig(File file) throws IOException, InvalidConfigurationException { public PaletteConfig(File file) throws IOException, InvalidConfigurationException {
super(file); super(file);
@ -42,11 +38,8 @@ public class PaletteConfig extends TerraConfigObject {
pal = new SimplexPalette<>(pNoise); pal = new SimplexPalette<>(pNoise);
} else pal = new RandomPalette<>(new Random(getInt("seed", 3))); } else pal = new RandomPalette<>(new Random(getInt("seed", 3)));
palette = getPalette(getMapList("blocks"), pal); palette = getPalette(getMapList("blocks"), pal);
if(!contains("id")) throw new InvalidConfigurationException("Grid ID unspecified!"); if(!contains("id")) throw new InvalidConfigurationException("Palette ID unspecified!");
this.paletteID = getString("id"); this.paletteID = getString("id");
if(!contains("name")) throw new InvalidConfigurationException("Grid Name unspecified!");
this.friendlyName = getString("name");
isEnabled = true;
palettes.put(paletteID, this); palettes.put(paletteID, this);
} }
@ -54,14 +47,6 @@ public class PaletteConfig extends TerraConfigObject {
return palette; return palette;
} }
public boolean isEnabled() {
return isEnabled;
}
public String getFriendlyName() {
return friendlyName;
}
public String getID() { public String getID() {
return paletteID; return paletteID;
} }
@ -97,7 +82,7 @@ public class PaletteConfig extends TerraConfigObject {
@Override @Override
public String toString() { public String toString() {
return "Palette with name: " + getFriendlyName() + ", ID " + getID() + " with " + getPalette().getSize() + " layers, using Simplex: " + useNoise; return "Palette with ID " + getID() + " with " + getPalette().getSize() + " layers, using Simplex: " + useNoise;
} }
public static PaletteConfig fromID(String id) { public static PaletteConfig fromID(String id) {