mirror of
https://github.com/BentoBoxWorld/Boxed.git
synced 2025-01-23 21:21:30 +01:00
Code smell reduction.
This commit is contained in:
parent
c9371ab859
commit
1e962f93d0
@ -231,7 +231,7 @@ public class Boxed extends GameModeAddon {
|
|||||||
if (id != null && id.equals("delete")) {
|
if (id != null && id.equals("delete")) {
|
||||||
return delChunks;
|
return delChunks;
|
||||||
}
|
}
|
||||||
return worldName.endsWith("_nether") ? netherChunkGenerator : chunkGenerator;
|
return worldName.endsWith(NETHER) ? netherChunkGenerator : chunkGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -25,7 +25,7 @@ import world.bentobox.boxed.Boxed;
|
|||||||
* @author tastybento
|
* @author tastybento
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractBoxedBiomeGenerator implements BiomeGenerator {
|
abstract class AbstractBoxedBiomeGenerator implements BiomeGenerator {
|
||||||
|
|
||||||
private static final Map<Environment, String> ENV_MAP;
|
private static final Map<Environment, String> ENV_MAP;
|
||||||
static {
|
static {
|
||||||
@ -77,24 +77,25 @@ public abstract class AbstractBoxedBiomeGenerator implements BiomeGenerator {
|
|||||||
|
|
||||||
private SortedMap<Double, Biome> loadQuad(YamlConfiguration config, String string) {
|
private SortedMap<Double, Biome> loadQuad(YamlConfiguration config, String string) {
|
||||||
SortedMap<Double, Biome> result = new TreeMap<>();
|
SortedMap<Double, Biome> result = new TreeMap<>();
|
||||||
if (config.contains(string)) {
|
if (!config.contains(string)) {
|
||||||
for (String ring : config.getStringList(string)) {
|
return result;
|
||||||
String[] split = ring.split(":");
|
}
|
||||||
if (split.length == 2 && NumberUtils.isNumber(split[0])) {
|
for (String ring : config.getStringList(string)) {
|
||||||
try {
|
String[] split = ring.split(":");
|
||||||
double d = Double.parseDouble(split[0]);
|
if (split.length == 2 && NumberUtils.isNumber(split[0])) {
|
||||||
Biome biome = Enums.getIfPresent(Biome.class, split[1].toUpperCase(Locale.ENGLISH)).orNull();
|
try {
|
||||||
if (biome == null) {
|
double d = Double.parseDouble(split[0]);
|
||||||
addon.logError(split[1].toUpperCase(Locale.ENGLISH) + " is an unknown biome on this server.");
|
Biome biome = Enums.getIfPresent(Biome.class, split[1].toUpperCase(Locale.ENGLISH)).orNull();
|
||||||
} else {
|
if (biome == null) {
|
||||||
result.put(d, biome);
|
addon.logError(split[1].toUpperCase(Locale.ENGLISH) + " is an unknown biome on this server.");
|
||||||
}
|
} else {
|
||||||
} catch(Exception e) {
|
result.put(d, biome);
|
||||||
addon.logError(string + ": " + split[0] + " does not seem to be a double. For integers add a .0 to the end");
|
|
||||||
}
|
}
|
||||||
} else {
|
} catch(Exception e) {
|
||||||
addon.logError(ring + " must be in the format ratio:biome where ratio is a double.");
|
addon.logError(string + ": " + split[0] + " does not seem to be a double. For integers add a .0 to the end");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
addon.logError(ring + " must be in the format ratio:biome where ratio is a double.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -23,7 +23,8 @@ import world.bentobox.boxed.Boxed;
|
|||||||
*/
|
*/
|
||||||
public class NetherGenerator implements BaseNoiseGenerator {
|
public class NetherGenerator implements BaseNoiseGenerator {
|
||||||
|
|
||||||
private final BiomeNoise DEFAULT_NOISE = new BiomeNoise(10D, 0D, 2D);
|
private static final String NETHER_BIOMES = "nether.biomes";
|
||||||
|
private final BiomeNoise defaultNoise = new BiomeNoise(10D, 0D, 2D);
|
||||||
private final NoiseGenerator mainNoiseGenerator;
|
private final NoiseGenerator mainNoiseGenerator;
|
||||||
private final Boxed addon;
|
private final Boxed addon;
|
||||||
private final YamlConfiguration config;
|
private final YamlConfiguration config;
|
||||||
@ -41,11 +42,11 @@ public class NetherGenerator implements BaseNoiseGenerator {
|
|||||||
}
|
}
|
||||||
config = YamlConfiguration.loadConfiguration(biomeFile);
|
config = YamlConfiguration.loadConfiguration(biomeFile);
|
||||||
biomeNoiseMap = new EnumMap<>(Biome.class);
|
biomeNoiseMap = new EnumMap<>(Biome.class);
|
||||||
if (config.isConfigurationSection("nether.biomes")) {
|
if (config.isConfigurationSection(NETHER_BIOMES)) {
|
||||||
for (String key : config.getConfigurationSection("nether.biomes").getKeys(false)) {
|
for (String key : config.getConfigurationSection(NETHER_BIOMES).getKeys(false)) {
|
||||||
double noiseScaleHorizontal = config.getDouble("nether.biomes." + key + ".scale", 10D);
|
double noiseScaleHorizontal = config.getDouble(NETHER_BIOMES + "." + key + ".scale", 10D);
|
||||||
double height = config.getDouble("nether.biomes." + key + ".height", 0D);
|
double height = config.getDouble(NETHER_BIOMES + "." + key + ".height", 0D);
|
||||||
double noiseScaleVertical = config.getDouble("nether.biomes." + key + ".vscale", 2D);
|
double noiseScaleVertical = config.getDouble(NETHER_BIOMES + "." + key + ".vscale", 2D);
|
||||||
Enums.getIfPresent(Biome.class, key).toJavaUtil()
|
Enums.getIfPresent(Biome.class, key).toJavaUtil()
|
||||||
.ifPresent(biome -> biomeNoiseMap.put(biome, new BiomeNoise(noiseScaleHorizontal, height, noiseScaleVertical)));
|
.ifPresent(biome -> biomeNoiseMap.put(biome, new BiomeNoise(noiseScaleHorizontal, height, noiseScaleVertical)));
|
||||||
}
|
}
|
||||||
@ -92,7 +93,7 @@ public class NetherGenerator implements BaseNoiseGenerator {
|
|||||||
// edge of island
|
// edge of island
|
||||||
biome = Biome.NETHER_WASTES;
|
biome = Biome.NETHER_WASTES;
|
||||||
}
|
}
|
||||||
BiomeNoise bm = this.biomeNoiseMap.getOrDefault(biome, DEFAULT_NOISE);
|
BiomeNoise bm = this.biomeNoiseMap.getOrDefault(biome, defaultNoise);
|
||||||
double x = ((((double)scaledX*4) % dist) / 4) / bm.noiseScaleHorizontal;
|
double x = ((((double)scaledX*4) % dist) / 4) / bm.noiseScaleHorizontal;
|
||||||
double z = ((((double)scaledZ*4) % dist) / 4) / bm.noiseScaleHorizontal;
|
double z = ((((double)scaledZ*4) % dist) / 4) / bm.noiseScaleHorizontal;
|
||||||
for (int y = 0; y < 16; y++) {
|
for (int y = 0; y < 16; y++) {
|
||||||
|
@ -235,6 +235,7 @@ public class AdvancementListener implements Listener {
|
|||||||
user.getPlayer().setStatistic(s, m, 0);
|
user.getPlayer().setStatistic(s, m, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case ITEM:
|
case ITEM:
|
||||||
for (Material m: Material.values()) {
|
for (Material m: Material.values()) {
|
||||||
if (m.isItem() && !m.isLegacy()) {
|
if (m.isItem() && !m.isLegacy()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user