From 9a300c9cec499ab5acb69f93457589875cc2a739 Mon Sep 17 00:00:00 2001 From: dfsek Date: Thu, 1 Oct 2020 00:45:00 -0700 Subject: [PATCH] Cleanup, remove "Friendly Name" because it's pointless --- .../java/com/dfsek/terra/TerraCommand.java | 2 +- .../terra/config/genconfig/BiomeConfig.java | 28 ++++++++----------- .../config/genconfig/BiomeGridConfig.java | 11 ++------ .../terra/config/genconfig/FloraConfig.java | 12 +------- .../terra/config/genconfig/OreConfig.java | 9 +----- .../terra/config/genconfig/PaletteConfig.java | 19 ++----------- 6 files changed, 18 insertions(+), 63 deletions(-) diff --git a/src/main/java/com/dfsek/terra/TerraCommand.java b/src/main/java/com/dfsek/terra/TerraCommand.java index f0ebaea5e..735815729 100644 --- a/src/main/java/com/dfsek/terra/TerraCommand.java +++ b/src/main/java/com/dfsek/terra/TerraCommand.java @@ -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)) { diff --git a/src/main/java/com/dfsek/terra/config/genconfig/BiomeConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/BiomeConfig.java index 95a6df468..ed72d9a54 100644 --- a/src/main/java/com/dfsek/terra/config/genconfig/BiomeConfig.java +++ b/src/main/java/com/dfsek/terra/config/genconfig/BiomeConfig.java @@ -41,7 +41,6 @@ public class BiomeConfig extends TerraConfigObject { private static final Palette oceanDefault = new RandomPalette(new Random(0)).add(Material.WATER.createBlockData(), 1); private UserDefinedBiome biome; private String biomeID; - private String friendlyName; private Map ores; private Map oreHeights; private Map 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(new Random(0)).add(new ProbabilityCollection().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(new Random(0)).add(new ProbabilityCollection().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 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) { diff --git a/src/main/java/com/dfsek/terra/config/genconfig/BiomeGridConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/BiomeGridConfig.java index 33badafdd..f42b410fa 100644 --- a/src/main/java/com/dfsek/terra/config/genconfig/BiomeGridConfig.java +++ b/src/main/java/com/dfsek/terra/config/genconfig/BiomeGridConfig.java @@ -19,7 +19,6 @@ import java.util.Objects; public class BiomeGridConfig extends TerraConfigObject { private static final Map 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>) getList("grid")).get(0).size(); @@ -46,7 +43,7 @@ public class BiomeGridConfig extends TerraConfigObject { try { gridRaw[x][z] = BiomeConfig.fromID(((List>) 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>) getList("grid")).get(x).get(z)); + throw new InvalidConfigurationException("SEVERE configuration error for BiomeGrid ID: " + getID() + "\n\nNo such biome " + ((List>) 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 getBiomeGrids() { diff --git a/src/main/java/com/dfsek/terra/config/genconfig/FloraConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/FloraConfig.java index dc01c32ef..acd3f5714 100644 --- a/src/main/java/com/dfsek/terra/config/genconfig/FloraConfig.java +++ b/src/main/java/com/dfsek/terra/config/genconfig/FloraConfig.java @@ -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 floraConfig = new HashMap<>(); private Palette floraPalette; private String id; - private String friendlyName; Set spawnable; Set 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) { diff --git a/src/main/java/com/dfsek/terra/config/genconfig/OreConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/OreConfig.java index 722cdeae5..96ad689ee 100644 --- a/src/main/java/com/dfsek/terra/config/genconfig/OreConfig.java +++ b/src/main/java/com/dfsek/terra/config/genconfig/OreConfig.java @@ -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 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); } diff --git a/src/main/java/com/dfsek/terra/config/genconfig/PaletteConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/PaletteConfig.java index f9c4ff50f..03490166e 100644 --- a/src/main/java/com/dfsek/terra/config/genconfig/PaletteConfig.java +++ b/src/main/java/com/dfsek/terra/config/genconfig/PaletteConfig.java @@ -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 palettes = new HashMap<>(); private Palette 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) {