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;
case "biome":
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;
case "profile":
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 UserDefinedBiome biome;
private String biomeID;
private String friendlyName;
private Map<OreConfig, Range> ores;
private Map<OreConfig, Range> oreHeights;
private Map<CarverConfig, Integer> carvers;
@ -62,11 +61,10 @@ public class BiomeConfig extends TerraConfigObject {
}
@Override
@SuppressWarnings("unchecked, rawtypes")
public void init() throws InvalidConfigurationException {
if(!contains("id")) throw new InvalidConfigurationException("Biome ID unspecified!");
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.");
AbstractBiomeConfig abstractBiome = null;
@ -103,18 +101,18 @@ public class BiomeConfig extends TerraConfigObject {
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));
} 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 {
try {
paletteMap.put((Integer) entry.getValue(), PaletteConfig.fromID((String) entry.getKey()).getPalette());
} 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) {
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());
carvers.put(c, (Integer) entry.getValue());
} 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) {
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"));
floraHeights.put(floraCustom, new Range((Integer) y.get("min"), (Integer) y.get("max")));
} 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) {
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<>();
@ -292,13 +290,13 @@ public class BiomeConfig extends TerraConfigObject {
try {
ocean = new RandomPalette<BlockData>(new Random(0)).add(new ProbabilityCollection<BlockData>().add(Bukkit.createBlockData(oceanPalette.substring(6)), 1), 1);
} 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 {
try {
ocean = PaletteConfig.fromID(oceanPalette).getPalette();
} 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;
@ -375,10 +373,6 @@ public class BiomeConfig extends TerraConfigObject {
return biomeID;
}
public String getFriendlyName() {
return friendlyName;
}
public Map<OreConfig, Range> getOres() {
return ores;
}
@ -407,7 +401,7 @@ public class BiomeConfig extends TerraConfigObject {
@Override
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) {

View File

@ -19,7 +19,6 @@ import java.util.Objects;
public class BiomeGridConfig extends TerraConfigObject {
private static final Map<String, BiomeGridConfig> biomeGrids = new HashMap<>();
private String gridID;
private String friendlyName;
private boolean isEnabled = false;
private UserDefinedBiome[][] gridRaw;
private int sizeX;
@ -34,8 +33,6 @@ public class BiomeGridConfig extends TerraConfigObject {
isEnabled = false;
if(!contains("id")) throw new InvalidConfigurationException("Grid ID unspecified!");
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!");
this.sizeX = Objects.requireNonNull(getList("grid")).size();
this.sizeZ = ((List<List<String>>) getList("grid")).get(0).size();
@ -46,7 +43,7 @@ public class BiomeGridConfig extends TerraConfigObject {
try {
gridRaw[x][z] = BiomeConfig.fromID(((List<List<String>>) getList("grid")).get(x).get(z)).getBiome();
} 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;
}
public String getFriendlyName() {
return friendlyName;
}
public UserDefinedBiome[][] getBiomeGrid() {
return gridRaw;
}
@ -88,7 +81,7 @@ public class BiomeGridConfig extends TerraConfigObject {
@Override
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() {

View File

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

View File

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

View File

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