Reformat again

This commit is contained in:
dfsek 2020-11-06 15:45:07 -07:00
parent 4f40550465
commit a362ed47ce
45 changed files with 192 additions and 113 deletions

View File

@ -210,7 +210,7 @@ ij_java_spaces_around_multiplicative_operators = true
ij_java_spaces_around_relational_operators = true ij_java_spaces_around_relational_operators = true
ij_java_spaces_around_shift_operators = true ij_java_spaces_around_shift_operators = true
ij_java_spaces_around_type_bounds_in_type_parameters = true ij_java_spaces_around_type_bounds_in_type_parameters = true
ij_java_spaces_around_unary_operator = true ij_java_spaces_around_unary_operator = false
ij_java_spaces_within_angle_brackets = false ij_java_spaces_within_angle_brackets = false
ij_java_spaces_within_annotation_parentheses = false ij_java_spaces_within_annotation_parentheses = false
ij_java_spaces_within_array_initializer_braces = false ij_java_spaces_within_array_initializer_braces = false
@ -246,6 +246,85 @@ ij_java_wrap_comments = false
ij_java_wrap_first_method_in_call_chain = false ij_java_wrap_first_method_in_call_chain = false
ij_java_wrap_long_lines = false ij_java_wrap_long_lines = false
[{*.gradle.kts,*.kt,*.kts,*.main.kts}]
ij_kotlin_align_in_columns_case_branch = false
ij_kotlin_align_multiline_binary_operation = false
ij_kotlin_align_multiline_extends_list = false
ij_kotlin_align_multiline_method_parentheses = false
ij_kotlin_align_multiline_parameters = true
ij_kotlin_align_multiline_parameters_in_calls = false
ij_kotlin_allow_trailing_comma = false
ij_kotlin_allow_trailing_comma_on_call_site = false
ij_kotlin_assignment_wrap = off
ij_kotlin_blank_lines_after_class_header = 0
ij_kotlin_blank_lines_around_block_when_branches = 0
ij_kotlin_blank_lines_before_declaration_with_comment_or_annotation_on_separate_line = 1
ij_kotlin_block_comment_at_first_column = true
ij_kotlin_call_parameters_new_line_after_left_paren = false
ij_kotlin_call_parameters_right_paren_on_new_line = false
ij_kotlin_call_parameters_wrap = off
ij_kotlin_catch_on_new_line = false
ij_kotlin_class_annotation_wrap = split_into_lines
ij_kotlin_continuation_indent_for_chained_calls = true
ij_kotlin_continuation_indent_for_expression_bodies = true
ij_kotlin_continuation_indent_in_argument_lists = true
ij_kotlin_continuation_indent_in_elvis = true
ij_kotlin_continuation_indent_in_if_conditions = true
ij_kotlin_continuation_indent_in_parameter_lists = true
ij_kotlin_continuation_indent_in_supertype_lists = true
ij_kotlin_else_on_new_line = false
ij_kotlin_enum_constants_wrap = off
ij_kotlin_extends_list_wrap = off
ij_kotlin_field_annotation_wrap = split_into_lines
ij_kotlin_finally_on_new_line = false
ij_kotlin_if_rparen_on_new_line = false
ij_kotlin_import_nested_classes = false
ij_kotlin_insert_whitespaces_in_simple_one_line_method = true
ij_kotlin_keep_blank_lines_before_right_brace = 2
ij_kotlin_keep_blank_lines_in_code = 2
ij_kotlin_keep_blank_lines_in_declarations = 2
ij_kotlin_keep_first_column_comment = true
ij_kotlin_keep_indents_on_empty_lines = false
ij_kotlin_keep_line_breaks = true
ij_kotlin_lbrace_on_next_line = false
ij_kotlin_line_comment_add_space = false
ij_kotlin_line_comment_at_first_column = true
ij_kotlin_method_annotation_wrap = split_into_lines
ij_kotlin_method_call_chain_wrap = off
ij_kotlin_method_parameters_new_line_after_left_paren = false
ij_kotlin_method_parameters_right_paren_on_new_line = false
ij_kotlin_method_parameters_wrap = off
ij_kotlin_name_count_to_use_star_import = 5
ij_kotlin_name_count_to_use_star_import_for_members = 3
ij_kotlin_parameter_annotation_wrap = off
ij_kotlin_space_after_comma = true
ij_kotlin_space_after_extend_colon = true
ij_kotlin_space_after_type_colon = true
ij_kotlin_space_before_catch_parentheses = true
ij_kotlin_space_before_comma = false
ij_kotlin_space_before_extend_colon = true
ij_kotlin_space_before_for_parentheses = true
ij_kotlin_space_before_if_parentheses = true
ij_kotlin_space_before_lambda_arrow = true
ij_kotlin_space_before_type_colon = false
ij_kotlin_space_before_when_parentheses = true
ij_kotlin_space_before_while_parentheses = true
ij_kotlin_spaces_around_additive_operators = true
ij_kotlin_spaces_around_assignment_operators = true
ij_kotlin_spaces_around_equality_operators = true
ij_kotlin_spaces_around_function_type_arrow = true
ij_kotlin_spaces_around_logical_operators = true
ij_kotlin_spaces_around_multiplicative_operators = true
ij_kotlin_spaces_around_range = false
ij_kotlin_spaces_around_relational_operators = true
ij_kotlin_spaces_around_unary_operator = false
ij_kotlin_spaces_around_when_arrow = true
ij_kotlin_variable_annotation_wrap = off
ij_kotlin_while_on_new_line = false
ij_kotlin_wrap_elvis_expressions = 1
ij_kotlin_wrap_expression_body_functions = 0
ij_kotlin_wrap_first_method_in_call_chain = false
[{*.har,*.jsb2,*.jsb3,*.json,.babelrc,.eslintrc,.stylelintrc,bowerrc,jest.config}] [{*.har,*.jsb2,*.jsb3,*.json,.babelrc,.eslintrc,.stylelintrc,bowerrc,jest.config}]
indent_size = 2 indent_size = 2
ij_json_keep_blank_lines_in_code = 0 ij_json_keep_blank_lines_in_code = 0

View File

@ -44,7 +44,7 @@ public class EventListener implements Listener {
@EventHandler @EventHandler
public void onCartographerChange(VillagerAcquireTradeEvent e) { public void onCartographerChange(VillagerAcquireTradeEvent e) {
if(! (e.getEntity() instanceof Villager)) return; if(!(e.getEntity() instanceof Villager)) return;
if(((Villager) e.getEntity()).getProfession().equals(Villager.Profession.CARTOGRAPHER)) if(((Villager) e.getEntity()).getProfession().equals(Villager.Profession.CARTOGRAPHER))
e.setCancelled(true); // Cancel leveling if the villager is a Cartographer, to prevent crashing server. e.setCancelled(true); // Cancel leveling if the villager is a Cartographer, to prevent crashing server.
} }

View File

@ -52,7 +52,7 @@ public class AsyncBiomeFinder implements Runnable {
else z--; else z--;
} }
run++; run++;
toggle = ! toggle; toggle = !toggle;
} }
if(p.isOnline()) { if(p.isOnline()) {
if(checkBiome(x, z).equals(target)) { if(checkBiome(x, z).equals(target)) {

View File

@ -74,7 +74,7 @@ public class AsyncStructureFinder implements Runnable {
else z -= 1; else z -= 1;
} }
run++; run++;
toggle = ! toggle; toggle = !toggle;
} }
final Vector finalSpawn = found ? spawn : null; final Vector finalSpawn = found ? spawn : null;
Bukkit.getScheduler().runTask(Terra.getInstance(), () -> callback.accept(finalSpawn)); Bukkit.getScheduler().runTask(Terra.getInstance(), () -> callback.accept(finalSpawn));
@ -89,15 +89,15 @@ public class AsyncStructureFinder implements Runnable {
*/ */
private boolean isValidSpawn(int x, int z) { private boolean isValidSpawn(int x, int z) {
Location spawn = target.getSpawn().getNearestSpawn(x, z, world.getSeed()).toLocation(world); Location spawn = target.getSpawn().getNearestSpawn(x, z, world.getSeed()).toLocation(world);
if(! TerraWorld.getWorld(world).getConfig().getBiome((UserDefinedBiome) grid.getBiome(spawn)).getStructures().contains(target)) if(!TerraWorld.getWorld(world).getConfig().getBiome((UserDefinedBiome) grid.getBiome(spawn)).getStructures().contains(target))
return false; return false;
Random r2 = new Random(spawn.hashCode()); Random r2 = new Random(spawn.hashCode());
Structure struc = target.getStructure(r2); Structure struc = target.getStructure(r2);
Structure.Rotation rotation = Structure.Rotation.fromDegrees(r2.nextInt(4) * 90); Structure.Rotation rotation = Structure.Rotation.fromDegrees(r2.nextInt(4) * 90);
for(int y = target.getSearchStart().get(r2); y > 0; y--) { for(int y = target.getSearchStart().get(r2); y > 0; y--) {
if(! target.getBound().isInRange(y)) return false; if(!target.getBound().isInRange(y)) return false;
spawn.setY(y); spawn.setY(y);
if(! struc.checkSpawns(spawn, rotation)) continue; if(!struc.checkSpawns(spawn, rotation)) continue;
return true; return true;
} }
return false; return false;

View File

@ -67,10 +67,10 @@ public class SimplexCarver extends Carver {
CarvingData.CarvingType type = CarvingData.CarvingType.BOTTOM; CarvingData.CarvingType type = CarvingData.CarvingType.BOTTOM;
double simplex = (Math.pow(mainNoise + root2inverse, 3) / 2 + columnNoise) * hc; double simplex = (Math.pow(mainNoise + root2inverse, 3) / 2 + columnNoise) * hc;
for(int y = 0; y < 64; y++) { for(int y = 0; y < 64; y++) {
double finalNoise = (- 0.05 * Math.abs(y - (heightNoise * 16 + 24)) + 1 - simplex) * hc; double finalNoise = (-0.05 * Math.abs(y - (heightNoise * 16 + 24)) + 1 - simplex) * hc;
if(finalNoise > 0.5) { if(finalNoise > 0.5) {
c.carve(x - ox, y, z - oz, type); c.carve(x - ox, y, z - oz, type);
double finalNoiseUp = (- 0.05 * Math.abs((y + 1) - (heightNoise * 16 + 24)) + 1 - simplex) * hc; double finalNoiseUp = (-0.05 * Math.abs((y + 1) - (heightNoise * 16 + 24)) + 1 - simplex) * hc;
if(finalNoiseUp > 0.5) { if(finalNoiseUp > 0.5) {
type = CarvingData.CarvingType.CENTER; type = CarvingData.CarvingType.CENTER;
} else type = CarvingData.CarvingType.TOP; } else type = CarvingData.CarvingType.TOP;

View File

@ -73,7 +73,7 @@ public class BiomeInfoCommand extends WorldCommand {
compHeight = i; compHeight = i;
} }
} }
if(! changed) { if(!changed) {
snowMessage.append("Y=0") snowMessage.append("Y=0")
.append("-255") .append("-255")
.append(": ") .append(": ")
@ -104,7 +104,7 @@ public class BiomeInfoCommand extends WorldCommand {
@Override @Override
public List<String> getTabCompletions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) { public List<String> getTabCompletions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) {
if(! (sender instanceof Player) || ! (((Player) sender).getWorld().getGenerator() instanceof TerraChunkGenerator)) if(!(sender instanceof Player) || !(((Player) sender).getWorld().getGenerator() instanceof TerraChunkGenerator))
return Collections.emptyList(); return Collections.emptyList();
List<String> ids = TerraWorld.getWorld(((Player) sender).getWorld()).getConfig().getBiomeIDs(); List<String> ids = TerraWorld.getWorld(((Player) sender).getWorld()).getConfig().getBiomeIDs();
if(args.length == 1) if(args.length == 1)

View File

@ -64,7 +64,7 @@ public class BiomeLocateCommand extends WorldCommand {
@Override @Override
public List<String> getTabCompletions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) { public List<String> getTabCompletions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) {
if(! (sender instanceof Player) || ! (((Player) sender).getWorld().getGenerator() instanceof TerraChunkGenerator)) if(!(sender instanceof Player) || !(((Player) sender).getWorld().getGenerator() instanceof TerraChunkGenerator))
return Collections.emptyList(); return Collections.emptyList();
List<String> ids = TerraWorld.getWorld(((Player) sender).getWorld()).getConfig().getBiomeIDs(); List<String> ids = TerraWorld.getWorld(((Player) sender).getWorld()).getConfig().getBiomeIDs();
if(args.length == 1) if(args.length == 1)

View File

@ -21,7 +21,7 @@ public class RawGUICommand extends WorldCommand {
@Override @Override
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) { public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
if(! ConfigUtil.debug) { if(!ConfigUtil.debug) {
LangUtil.send("command.image.gui.debug", sender); LangUtil.send("command.image.gui.debug", sender);
return true; return true;
} }

View File

@ -21,7 +21,7 @@ public class StepGUICommand extends WorldCommand {
@Override @Override
public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) { public boolean execute(@NotNull Player sender, @NotNull Command command, @NotNull String label, @NotNull String[] args, World world) {
if(! ConfigUtil.debug) { if(!ConfigUtil.debug) {
LangUtil.send("command.image.gui.debug", sender); LangUtil.send("command.image.gui.debug", sender);
return true; return true;
} }

View File

@ -77,7 +77,7 @@ public class LocateCommand extends WorldCommand {
@Override @Override
public List<String> getTabCompletions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) { public List<String> getTabCompletions(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) {
if(! (sender instanceof Player) || ! (((Player) sender).getWorld().getGenerator() instanceof TerraChunkGenerator)) if(!(sender instanceof Player) || !(((Player) sender).getWorld().getGenerator() instanceof TerraChunkGenerator))
return Collections.emptyList(); return Collections.emptyList();
List<String> ids = TerraWorld.getWorld(((Player) sender).getWorld()).getConfig().getStructureIDs(); List<String> ids = TerraWorld.getWorld(((Player) sender).getWorld()).getConfig().getStructureIDs();
if(args.length == 1) if(args.length == 1)

View File

@ -77,7 +77,7 @@ public class ConfigPack extends YamlConfiguration {
load(new File(file, "pack.yml")); load(new File(file, "pack.yml"));
dataFolder = file; dataFolder = file;
if(! contains("id")) throw new ConfigException("No ID specified!", "null"); if(!contains("id")) throw new ConfigException("No ID specified!", "null");
this.id = getString("id"); this.id = getString("id");
ores = ConfigLoader.load(new File(file, "ores").toPath(), this, OreConfig.class); ores = ConfigLoader.load(new File(file, "ores").toPath(), this, OreConfig.class);

View File

@ -47,7 +47,7 @@ public class WorldConfig {
if(configID == null || configID.equals("")) if(configID == null || configID.equals(""))
throw new ConfigException("Config pack unspecified in bukkit.yml!", worldID); throw new ConfigException("Config pack unspecified in bukkit.yml!", worldID);
File configFile = new File(main.getDataFolder() + File.separator + "worlds", worldID + ".yml"); File configFile = new File(main.getDataFolder() + File.separator + "worlds", worldID + ".yml");
if(! configFile.exists()) { if(!configFile.exists()) {
configFile.getParentFile().mkdirs(); configFile.getParentFile().mkdirs();
LangUtil.log("world-config.not-found", Level.WARNING, worldID); LangUtil.log("world-config.not-found", Level.WARNING, worldID);
FileUtils.copyInputStreamToFile(Objects.requireNonNull(main.getResource("world.yml")), configFile); FileUtils.copyInputStreamToFile(Objects.requireNonNull(main.getResource("world.yml")), configFile);

View File

@ -25,9 +25,9 @@ public class BiomeGridConfig extends TerraConfig {
public BiomeGridConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException { public BiomeGridConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
super(file, config); super(file, config);
load(file); load(file);
if(! contains("id")) throw new ConfigException("Grid ID unspecified!", "null"); if(!contains("id")) throw new ConfigException("Grid ID unspecified!", "null");
this.gridID = getString("id"); this.gridID = getString("id");
if(! contains("grid")) throw new ConfigException("Grid key not found!", getID()); if(!contains("grid")) throw new ConfigException("Grid key not found!", getID());
this.sizeX = Objects.requireNonNull(getList("grid")).size(); this.sizeX = Objects.requireNonNull(getList("grid")).size();
this.sizeZ = ((List<List<String>>) Objects.requireNonNull(getList("grid"))).get(0).size(); this.sizeZ = ((List<List<String>>) Objects.requireNonNull(getList("grid"))).get(0).size();
gridRaw = new UserDefinedBiome[sizeX][sizeZ]; gridRaw = new UserDefinedBiome[sizeX][sizeZ];

View File

@ -46,7 +46,7 @@ public class CarverConfig extends TerraConfig {
public CarverConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException { public CarverConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
super(file, config); super(file, config);
load(file); load(file);
if(! contains("id")) throw new ConfigException("No ID specified for Carver!", "null"); if(!contains("id")) throw new ConfigException("No ID specified for Carver!", "null");
id = getString("id"); id = getString("id");
inner = getBlocks("palette.inner.layers"); inner = getBlocks("palette.inner.layers");
@ -105,7 +105,7 @@ public class CarverConfig extends TerraConfig {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private Map<Integer, ProbabilityCollection<BlockData>> getBlocks(String key) throws InvalidConfigurationException { private Map<Integer, ProbabilityCollection<BlockData>> getBlocks(String key) throws InvalidConfigurationException {
if(! contains(key)) throw new ConfigException("Missing Carver Palette!", getID()); if(!contains(key)) throw new ConfigException("Missing Carver Palette!", getID());
Map<Integer, ProbabilityCollection<BlockData>> result = new TreeMap<>(); Map<Integer, ProbabilityCollection<BlockData>> result = new TreeMap<>();
for(Map<?, ?> m : getMapList(key)) { for(Map<?, ?> m : getMapList(key)) {
try { try {
@ -133,28 +133,28 @@ public class CarverConfig extends TerraConfig {
public boolean isReplaceableInner(Material m) { public boolean isReplaceableInner(Material m) {
if(replaceIsBlacklistInner) { if(replaceIsBlacklistInner) {
return ! replaceableInner.contains(m); return !replaceableInner.contains(m);
} }
return replaceableInner.contains(m); return replaceableInner.contains(m);
} }
public boolean isReplaceableOuter(Material m) { public boolean isReplaceableOuter(Material m) {
if(replaceIsBlacklistOuter) { if(replaceIsBlacklistOuter) {
return ! replaceableOuter.contains(m); return !replaceableOuter.contains(m);
} }
return replaceableOuter.contains(m); return replaceableOuter.contains(m);
} }
public boolean isReplaceableTop(Material m) { public boolean isReplaceableTop(Material m) {
if(replaceIsBlacklistTop) { if(replaceIsBlacklistTop) {
return ! replaceableTop.contains(m); return !replaceableTop.contains(m);
} }
return replaceableTop.contains(m); return replaceableTop.contains(m);
} }
public boolean isReplaceableBottom(Material m) { public boolean isReplaceableBottom(Material m) {
if(replaceIsBlacklistBottom) { if(replaceIsBlacklistBottom) {
return ! replaceableBottom.contains(m); return !replaceableBottom.contains(m);
} }
return replaceableBottom.contains(m); return replaceableBottom.contains(m);
} }

View File

@ -34,10 +34,10 @@ public class FloraConfig extends TerraConfig implements Flora {
public FloraConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException { public FloraConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
super(file, config); super(file, config);
load(file); load(file);
if(! contains("id")) throw new ConfigException("Flora ID unspecified!", "null"); if(!contains("id")) throw new ConfigException("Flora ID unspecified!", "null");
this.id = getString("id"); this.id = getString("id");
if(! contains("layers")) throw new ConfigException("No blocks defined in custom flora!", getID()); if(!contains("layers")) throw new ConfigException("No blocks defined in custom flora!", getID());
if(! contains("spawnable")) throw new ConfigException("Flora spawnable blocks unspecified!", getID()); if(!contains("spawnable")) throw new ConfigException("Flora spawnable blocks unspecified!", getID());
spawnable = ConfigUtil.toBlockData(getStringList("spawnable"), "spawnable", getID()); spawnable = ConfigUtil.toBlockData(getStringList("spawnable"), "spawnable", getID());
replaceable = ConfigUtil.toBlockData(getStringList("replaceable"), "replaceable", getID()); replaceable = ConfigUtil.toBlockData(getStringList("replaceable"), "replaceable", getID());
@ -78,10 +78,10 @@ public class FloraConfig extends TerraConfig implements Flora {
@Override @Override
public boolean plant(Location location) { public boolean plant(Location location) {
int size = floraPalette.getSize(); int size = floraPalette.getSize();
int c = ceiling ? - 1 : 1; int c = ceiling ? -1 : 1;
for(int i = 0; Math.abs(i) < size; i += c) { // Down if ceiling, up if floor for(int i = 0; Math.abs(i) < size; i += c) { // Down if ceiling, up if floor
if(i + 1 > 255) return false; if(i + 1 > 255) return false;
if(! replaceable.contains(location.clone().add(0, i + c, 0).getBlock().getType())) return false; if(!replaceable.contains(location.clone().add(0, i + c, 0).getBlock().getType())) return false;
} }
for(int i = 0; Math.abs(i) < size; i += c) { // Down if ceiling, up if floor for(int i = 0; Math.abs(i) < size; i += c) { // Down if ceiling, up if floor
int lvl = (Math.abs(i)); int lvl = (Math.abs(i));

View File

@ -36,11 +36,11 @@ public class OreConfig extends TerraConfig {
public OreConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException { public OreConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
super(file, config); super(file, config);
if(! contains("id")) throw new ConfigException("Ore ID not found!", "null"); if(!contains("id")) throw new ConfigException("Ore ID not found!", "null");
this.id = getString("id"); this.id = getString("id");
if(! contains("material")) throw new ConfigException("Ore material not found!", getID()); if(!contains("material")) throw new ConfigException("Ore material not found!", getID());
if(! contains("deform")) throw new ConfigException("Ore vein deformation not found!", getID()); if(!contains("deform")) throw new ConfigException("Ore vein deformation not found!", getID());
if(! contains("replace")) throw new ConfigException("Ore replaceable materials not found!", getID()); if(!contains("replace")) throw new ConfigException("Ore replaceable materials not found!", getID());
min = getInt("radius.min", 1); min = getInt("radius.min", 1);
max = getInt("radius.max", 1); max = getInt("radius.max", 1);
deform = getDouble("deform", 0.75); deform = getDouble("deform", 0.75);
@ -73,9 +73,9 @@ public class OreConfig extends TerraConfig {
Map<ChunkCoordinate, Chunk> chunks = new HashMap<>(); // Cache chunks to prevent re-loading chunks every time one is needed. Map<ChunkCoordinate, Chunk> chunks = new HashMap<>(); // Cache chunks to prevent re-loading chunks every time one is needed.
chunks.put(new ChunkCoordinate(chunk), chunk); chunks.put(new ChunkCoordinate(chunk), chunk);
Vector orig = new Vector(l.getBlockX() + (chunk.getX() << 4), l.getBlockY(), l.getBlockZ() + (chunk.getZ() << 4)); Vector orig = new Vector(l.getBlockX() + (chunk.getX() << 4), l.getBlockY(), l.getBlockZ() + (chunk.getZ() << 4));
for(int x = - rad; x <= rad; x++) { for(int x = -rad; x <= rad; x++) {
for(int y = - rad; y <= rad; y++) { for(int y = -rad; y <= rad; y++) {
for(int z = - rad; z <= rad; z++) { for(int z = -rad; z <= rad; z++) {
Vector oreLoc = orig.clone().add(new Vector(x, y, z)); Vector oreLoc = orig.clone().add(new Vector(x, y, z));
Vector source = l.clone().add(new Vector(x, y, z)); Vector source = l.clone().add(new Vector(x, y, z));
if(oreLoc.getBlockY() > 255 || oreLoc.getBlockY() < 0) continue; if(oreLoc.getBlockY() > 255 || oreLoc.getBlockY() < 0) continue;
@ -96,9 +96,9 @@ public class OreConfig extends TerraConfig {
ore.setNoiseType(FastNoiseLite.NoiseType.OpenSimplex2); ore.setNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);
ore.setFrequency(deformFrequency); ore.setFrequency(deformFrequency);
int rad = randomInRange(r); int rad = randomInRange(r);
for(int x = - rad; x <= rad; x++) { for(int x = -rad; x <= rad; x++) {
for(int y = - rad; y <= rad; y++) { for(int y = -rad; y <= rad; y++) {
for(int z = - rad; z <= rad; z++) { for(int z = -rad; z <= rad; z++) {
Vector oreLoc = l.clone().add(new Vector(x, y, z)); Vector oreLoc = l.clone().add(new Vector(x, y, z));
if(oreLoc.getBlockX() > 15 || oreLoc.getBlockZ() > 15 || oreLoc.getBlockY() > 255 || oreLoc.getBlockX() < 0 || oreLoc.getBlockZ() < 0 || oreLoc.getBlockY() < 0) if(oreLoc.getBlockX() > 15 || oreLoc.getBlockZ() > 15 || oreLoc.getBlockY() > 255 || oreLoc.getBlockX() < 0 || oreLoc.getBlockZ() < 0 || oreLoc.getBlockY() < 0)
continue; continue;

View File

@ -26,7 +26,7 @@ public class PaletteConfig extends TerraConfig {
public PaletteConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException { public PaletteConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
super(file, config); super(file, config);
if(! contains("id")) throw new ConfigException("Palette ID unspecified!", "null"); if(!contains("id")) throw new ConfigException("Palette ID unspecified!", "null");
this.paletteID = getString("id"); this.paletteID = getString("id");
Palette<BlockData> pal; Palette<BlockData> pal;
if(getBoolean("simplex", false)) { if(getBoolean("simplex", false)) {

View File

@ -31,9 +31,9 @@ public class TreeConfig extends TerraConfig implements Tree {
public TreeConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException { public TreeConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
super(file, config); super(file, config);
spawnable = ConfigUtil.toBlockData(getStringList("spawnable"), "spawnable", getID()); spawnable = ConfigUtil.toBlockData(getStringList("spawnable"), "spawnable", getID());
if(! contains("id")) throw new ConfigException("No ID specified!", "null"); if(!contains("id")) throw new ConfigException("No ID specified!", "null");
id = getString("id"); id = getString("id");
if(! contains("files")) throw new ConfigException("No files specified!", getID()); if(!contains("files")) throw new ConfigException("No files specified!", getID());
yOffset = getInt("y-offset", 0); yOffset = getInt("y-offset", 0);
try { try {
for(Map.Entry<String, Object> e : Objects.requireNonNull(getConfigurationSection("files")).getValues(false).entrySet()) { for(Map.Entry<String, Object> e : Objects.requireNonNull(getConfigurationSection("files")).getValues(false).entrySet()) {
@ -65,10 +65,10 @@ public class TreeConfig extends TerraConfig implements Tree {
public boolean plant(Location location, Random random, JavaPlugin javaPlugin) { public boolean plant(Location location, Random random, JavaPlugin javaPlugin) {
location.subtract(0, 1, 0); location.subtract(0, 1, 0);
Location mut = location.clone().subtract(0, yOffset, 0); Location mut = location.clone().subtract(0, yOffset, 0);
if(! spawnable.contains(location.getBlock().getType())) return false; if(!spawnable.contains(location.getBlock().getType())) return false;
Structure struc = structure.get(random); Structure struc = structure.get(random);
Structure.Rotation rotation = Structure.Rotation.fromDegrees(random.nextInt(4) * 90); Structure.Rotation rotation = Structure.Rotation.fromDegrees(random.nextInt(4) * 90);
if(! struc.checkSpawns(mut, rotation)) return false; if(!struc.checkSpawns(mut, rotation)) return false;
struc.paste(mut, rotation); struc.paste(mut, rotation);
return true; return true;
} }

View File

@ -26,7 +26,7 @@ public class AbstractBiomeConfig extends TerraConfig {
public AbstractBiomeConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException { public AbstractBiomeConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
super(file, config); super(file, config);
load(file); load(file);
if(! contains("id")) throw new ConfigException("Abstract Biome ID unspecified!", "null"); if(!contains("id")) throw new ConfigException("Abstract Biome ID unspecified!", "null");
this.biomeID = getString("id"); this.biomeID = getString("id");
equation = getString("noise-equation"); equation = getString("noise-equation");

View File

@ -42,7 +42,7 @@ public class BiomeConfig extends TerraConfig {
super(file, config); super(file, config);
load(file); load(file);
this.config = config; this.config = config;
if(! contains("id")) throw new ConfigException("Biome ID unspecified!", "null"); if(!contains("id")) throw new ConfigException("Biome ID unspecified!", "null");
this.biomeID = getString("id"); this.biomeID = getString("id");
AbstractBiomeConfig abstractBiome = null; AbstractBiomeConfig abstractBiome = null;
@ -69,7 +69,7 @@ public class BiomeConfig extends TerraConfig {
BiomePaletteConfig palette; BiomePaletteConfig palette;
// Check if biome is extending abstract biome, only use abstract biome's palette if palette is NOT defined for current biome. // Check if biome is extending abstract biome, only use abstract biome's palette if palette is NOT defined for current biome.
if(extending && abstractBiome.getPaletteData() != null && ! contains("palette")) { if(extending && abstractBiome.getPaletteData() != null && !contains("palette")) {
palette = abstractBiome.getPaletteData(); palette = abstractBiome.getPaletteData();
Debug.info("Using super palette"); Debug.info("Using super palette");
} else palette = new BiomePaletteConfig(this); } else palette = new BiomePaletteConfig(this);
@ -79,31 +79,31 @@ public class BiomeConfig extends TerraConfig {
throw new ConfigException("No Palette specified in biome or super biome.", getID()); throw new ConfigException("No Palette specified in biome or super biome.", getID());
// Check if carving should be handled by super biome. // Check if carving should be handled by super biome.
if(extending && abstractBiome.getCarving() != null && ! contains("carving")) { if(extending && abstractBiome.getCarving() != null && !contains("carving")) {
carver = abstractBiome.getCarving(); carver = abstractBiome.getCarving();
Debug.info("Using super carvers"); Debug.info("Using super carvers");
} else carver = new BiomeCarverConfig(this); } else carver = new BiomeCarverConfig(this);
// Check if flora should be handled by super biome. // Check if flora should be handled by super biome.
if(extending && abstractBiome.getFlora() != null && ! contains("flora")) { if(extending && abstractBiome.getFlora() != null && !contains("flora")) {
flora = abstractBiome.getFlora(); flora = abstractBiome.getFlora();
Debug.info("Using super flora (" + flora.getFlora().size() + " entries, " + flora.getFloraChance() + " % chance)"); Debug.info("Using super flora (" + flora.getFlora().size() + " entries, " + flora.getFloraChance() + " % chance)");
} else flora = new BiomeFloraConfig(this); } else flora = new BiomeFloraConfig(this);
// Check if trees should be handled by super biome. // Check if trees should be handled by super biome.
if(extending && abstractBiome.getTrees() != null && ! contains("trees")) { if(extending && abstractBiome.getTrees() != null && !contains("trees")) {
tree = abstractBiome.getTrees(); tree = abstractBiome.getTrees();
Debug.info("Using super trees"); Debug.info("Using super trees");
} else tree = new BiomeTreeConfig(this); } else tree = new BiomeTreeConfig(this);
// Check if ores should be handled by super biome. // Check if ores should be handled by super biome.
if(extending && abstractBiome.getOres() != null && ! contains("ores")) { if(extending && abstractBiome.getOres() != null && !contains("ores")) {
ore = abstractBiome.getOres(); ore = abstractBiome.getOres();
Debug.info("Using super ores"); Debug.info("Using super ores");
} else ore = new BiomeOreConfig(this); } else ore = new BiomeOreConfig(this);
// Get slab stuff // Get slab stuff
if(extending && abstractBiome.getSlabs() != null && ! contains("slabs")) { if(extending && abstractBiome.getSlabs() != null && !contains("slabs")) {
slab = abstractBiome.getSlabs(); slab = abstractBiome.getSlabs();
Debug.info("Using super slabs"); Debug.info("Using super slabs");
} else slab = new BiomeSlabConfig(this); } else slab = new BiomeSlabConfig(this);
@ -130,7 +130,7 @@ public class BiomeConfig extends TerraConfig {
// Get Vanilla biome, throw exception if it is invalid/unspecified. // Get Vanilla biome, throw exception if it is invalid/unspecified.
org.bukkit.block.Biome vanillaBiome; org.bukkit.block.Biome vanillaBiome;
try { try {
if(! contains("vanilla")) throw new ConfigException("Vanilla Biome unspecified!", getID()); if(!contains("vanilla")) throw new ConfigException("Vanilla Biome unspecified!", getID());
vanillaBiome = org.bukkit.block.Biome.valueOf(getString("vanilla")); vanillaBiome = org.bukkit.block.Biome.valueOf(getString("vanilla"));
} catch(IllegalArgumentException e) { } catch(IllegalArgumentException e) {
throw new ConfigException("Invalid Vanilla biome: \"" + getString("vanilla") + "\"", getID()); throw new ConfigException("Invalid Vanilla biome: \"" + getString("vanilla") + "\"", getID());
@ -172,7 +172,7 @@ public class BiomeConfig extends TerraConfig {
} }
public Range getFloraHeights(Flora f) { public Range getFloraHeights(Flora f) {
return flora.getFloraHeights().computeIfAbsent(f, input -> new Range(- 1, - 1)); return flora.getFloraHeights().computeIfAbsent(f, input -> new Range(-1, -1));
} }
@Override @Override
@ -201,7 +201,7 @@ public class BiomeConfig extends TerraConfig {
} }
public Range getTreeRange(Tree t) { public Range getTreeRange(Tree t) {
return tree.getTreeHeights().getOrDefault(t, new Range(- 1, - 1)); return tree.getTreeHeights().getOrDefault(t, new Range(-1, -1));
} }
public BiomeSnowConfig getSnow() { public BiomeSnowConfig getSnow() {

View File

@ -19,14 +19,14 @@ public class EntityFeatureConfig implements FeatureConfig {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public EntityFeatureConfig(Map<String, Object> items) throws InvalidConfigurationException { public EntityFeatureConfig(Map<String, Object> items) throws InvalidConfigurationException {
if(! items.containsKey("entity")) throw new ConfigException("No EntityType specified!", "EntityFeature"); if(!items.containsKey("entity")) throw new ConfigException("No EntityType specified!", "EntityFeature");
if(! items.containsKey("amount")) throw new ConfigException("No amount specified!", "EntityFeature"); if(!items.containsKey("amount")) throw new ConfigException("No amount specified!", "EntityFeature");
if(! items.containsKey("attempts")) throw new ConfigException("Attempts not specified!", "EntityFeature"); if(!items.containsKey("attempts")) throw new ConfigException("Attempts not specified!", "EntityFeature");
if(! items.containsKey("in-height")) if(!items.containsKey("in-height"))
throw new ConfigException("Spawn Checking Height not specified!", "EntityFeature"); throw new ConfigException("Spawn Checking Height not specified!", "EntityFeature");
if(! items.containsKey("spawnable-on")) if(!items.containsKey("spawnable-on"))
throw new ConfigException("No Spawnable-on materials specified!", "EntityFeature"); throw new ConfigException("No Spawnable-on materials specified!", "EntityFeature");
if(! items.containsKey("spawnable-in")) if(!items.containsKey("spawnable-in"))
throw new ConfigException("No Spawnable-in materials specified!", "EntityFeature"); throw new ConfigException("No Spawnable-in materials specified!", "EntityFeature");
EntityType type; EntityType type;

View File

@ -41,9 +41,9 @@ public class StructureConfig extends TerraConfig {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public StructureConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException { public StructureConfig(File file, ConfigPack config) throws IOException, InvalidConfigurationException {
super(file, config); super(file, config);
if(! contains("id")) throw new ConfigException("No ID specified!", "null"); if(!contains("id")) throw new ConfigException("No ID specified!", "null");
id = getString("id"); id = getString("id");
if(! contains("files")) throw new ConfigException("No files specified!", getID()); if(!contains("files")) throw new ConfigException("No files specified!", getID());
try { try {
for(Map.Entry<String, Object> e : Objects.requireNonNull(getConfigurationSection("files")).getValues(false).entrySet()) { for(Map.Entry<String, Object> e : Objects.requireNonNull(getConfigurationSection("files")).getValues(false).entrySet()) {
try { try {

View File

@ -31,7 +31,7 @@ public class DebugFrame extends JFrame implements ActionListener {
public void paint(Graphics g) { public void paint(Graphics g) {
super.paintComponents(g); super.paintComponents(g);
for(Player p : Bukkit.getOnlinePlayers()) { for(Player p : Bukkit.getOnlinePlayers()) {
if(! (p.getWorld().getGenerator() instanceof TerraChunkGenerator)) break; if(!(p.getWorld().getGenerator() instanceof TerraChunkGenerator)) break;
int xp = (int) (((double) Math.floorMod(p.getLocation().getBlockX() - (img.getWidth() / 2), x) / x) * getWidth()); int xp = (int) (((double) Math.floorMod(p.getLocation().getBlockX() - (img.getWidth() / 2), x) / x) * getWidth());
int zp = (int) (((double) Math.floorMod(p.getLocation().getBlockZ() - (img.getHeight() / 2), z) / z) * getHeight()); int zp = (int) (((double) Math.floorMod(p.getLocation().getBlockZ() - (img.getHeight() / 2), z) / z) * getHeight());
ImageLoader loader = TerraWorld.getWorld(p.getWorld()).getWorldConfig().imageLoader; ImageLoader loader = TerraWorld.getWorld(p.getWorld()).getWorldConfig().imageLoader;

View File

@ -69,7 +69,7 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
} }
public static synchronized void fixChunk(Chunk c) { public static synchronized void fixChunk(Chunk c) {
if(! (c.getWorld().getGenerator() instanceof TerraChunkGenerator)) throw new IllegalArgumentException(); if(!(c.getWorld().getGenerator() instanceof TerraChunkGenerator)) throw new IllegalArgumentException();
popMap.get(c.getWorld()).checkNeighbors(c.getX(), c.getZ(), c.getWorld()); popMap.get(c.getWorld()).checkNeighbors(c.getX(), c.getZ(), c.getWorld());
} }
@ -78,7 +78,7 @@ public class TerraChunkGenerator extends GaeaChunkGenerator {
if(needsLoad) load(world); // Load population data for world. if(needsLoad) load(world); // Load population data for world.
ChunkData chunk = createChunkData(world); ChunkData chunk = createChunkData(world);
TerraWorld tw = TerraWorld.getWorld(world); TerraWorld tw = TerraWorld.getWorld(world);
if(! tw.isSafe()) return chunk; if(!tw.isSafe()) return chunk;
ConfigPack config = tw.getConfig(); ConfigPack config = tw.getConfig();
int xOrig = (chunkX << 4); int xOrig = (chunkX << 4);
int zOrig = (chunkZ << 4); int zOrig = (chunkZ << 4);

View File

@ -25,7 +25,7 @@ public class ImageLoader {
} }
public static void debugWorld(boolean genStep, World w) { public static void debugWorld(boolean genStep, World w) {
if(! ConfigUtil.debug) return; if(!ConfigUtil.debug) return;
BufferedImage newImg = new WorldImageGenerator(w, 1024, 1024).drawWorld(0, 0).getDraw(); BufferedImage newImg = new WorldImageGenerator(w, 1024, 1024).drawWorld(0, 0).getDraw();
if(genStep) newImg = redrawStepped(newImg, w, Align.CENTER); if(genStep) newImg = redrawStepped(newImg, w, Align.CENTER);
DebugGUI debugGUI = new DebugGUI(newImg); DebugGUI debugGUI = new DebugGUI(newImg);
@ -77,7 +77,7 @@ public class ImageLoader {
} }
public void debug(boolean genStep, World w) { public void debug(boolean genStep, World w) {
if(! ConfigUtil.debug) return; if(!ConfigUtil.debug) return;
BufferedImage newImg = copyImage(image); BufferedImage newImg = copyImage(image);
if(genStep) { if(genStep) {
newImg = redrawStepped(image, w, align); newImg = redrawStepped(image, w, align);

View File

@ -33,7 +33,7 @@ public class CavePopulator extends BlockPopulator {
if(ConfigUtil.masterDisableCaves) return; if(ConfigUtil.masterDisableCaves) return;
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("CaveTime")) { try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("CaveTime")) {
TerraWorld tw = TerraWorld.getWorld(world); TerraWorld tw = TerraWorld.getWorld(world);
if(! tw.isSafe()) return; if(!tw.isSafe()) return;
ConfigPack config = tw.getConfig(); ConfigPack config = tw.getConfig();
for(CarverConfig c : config.getCarvers().values()) { for(CarverConfig c : config.getCarvers().values()) {

View File

@ -34,12 +34,12 @@ public class FloraPopulator extends GaeaBlockPopulator {
for(Block block : getValidTreeSpawnsAt(chunk, x, z, new Range(0, 254))) { for(Block block : getValidTreeSpawnsAt(chunk, x, z, new Range(0, 254))) {
Tree tree = biome.getDecorator().getTrees().get(random); Tree tree = biome.getDecorator().getTrees().get(random);
Range range = world.getConfig().getBiome(biome).getTreeRange(tree); Range range = world.getConfig().getBiome(biome).getTreeRange(tree);
if(! range.isInRange(block.getY())) continue; if(!range.isInRange(block.getY())) continue;
try { try {
Location l = block.getLocation(); Location l = block.getLocation();
TreeGenerateEvent event = new TreeGenerateEvent(world, l, tree); TreeGenerateEvent event = new TreeGenerateEvent(world, l, tree);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if(! event.isCancelled()) tree.plant(l, random, Terra.getInstance()); if(!event.isCancelled()) tree.plant(l, random, Terra.getInstance());
} catch(NullPointerException ignore) { } catch(NullPointerException ignore) {
} }
} }
@ -64,7 +64,7 @@ public class FloraPopulator extends GaeaBlockPopulator {
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) { public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("FloraTime")) { try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("FloraTime")) {
TerraWorld tw = TerraWorld.getWorld(world); TerraWorld tw = TerraWorld.getWorld(world);
if(! tw.isSafe()) return; if(!tw.isSafe()) return;
int originX = chunk.getX() << 4; int originX = chunk.getX() << 4;
int originZ = chunk.getZ() << 4; int originZ = chunk.getZ() << 4;
TerraBiomeGrid grid = tw.getGrid(); TerraBiomeGrid grid = tw.getGrid();

View File

@ -26,7 +26,7 @@ public class OrePopulator extends GaeaBlockPopulator {
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) { public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("OreTime")) { try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("OreTime")) {
TerraWorld tw = TerraWorld.getWorld(world); TerraWorld tw = TerraWorld.getWorld(world);
if(! tw.isSafe()) return; if(!tw.isSafe()) return;
ConfigPack config = tw.getConfig(); ConfigPack config = tw.getConfig();
Biome b = TerraWorld.getWorld(world).getGrid().getBiome((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8, GenerationPhase.POPULATE); Biome b = TerraWorld.getWorld(world).getGrid().getBiome((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8, GenerationPhase.POPULATE);
BiomeOreConfig ores = config.getBiome((UserDefinedBiome) b).getOres(); BiomeOreConfig ores = config.getBiome((UserDefinedBiome) b).getOres();
@ -42,7 +42,7 @@ public class OrePopulator extends GaeaBlockPopulator {
Vector v = new Vector(x, y, z); Vector v = new Vector(x, y, z);
OreVeinGenerateEvent event = new OreVeinGenerateEvent(tw, v.toLocation(world), ore); OreVeinGenerateEvent event = new OreVeinGenerateEvent(tw, v.toLocation(world), ore);
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
if(! event.isCancelled()) { if(!event.isCancelled()) {
if(ore.crossChunks()) ore.doVein(v, chunk, random); if(ore.crossChunks()) ore.doVein(v, chunk, random);
else ore.doVeinSingle(new Vector(x, y, z), chunk, random); else ore.doVeinSingle(new Vector(x, y, z), chunk, random);
} }

View File

@ -50,22 +50,22 @@ public class SnowPopulator extends GaeaBlockPopulator {
int origX = chunk.getX() << 4; int origX = chunk.getX() << 4;
int origZ = chunk.getZ() << 4; int origZ = chunk.getZ() << 4;
TerraWorld w = TerraWorld.getWorld(world); TerraWorld w = TerraWorld.getWorld(world);
if(! w.isSafe()) return; if(!w.isSafe()) return;
TerraBiomeGrid g = w.getGrid(); TerraBiomeGrid g = w.getGrid();
for(int x = 0; x < 16; x++) { for(int x = 0; x < 16; x++) {
for(int z = 0; z < 16; z++) { for(int z = 0; z < 16; z++) {
BiomeConfig biome = w.getConfig().getBiome((UserDefinedBiome) g.getBiome(origX + x, origZ + z, GenerationPhase.PALETTE_APPLY)); BiomeConfig biome = w.getConfig().getBiome((UserDefinedBiome) g.getBiome(origX + x, origZ + z, GenerationPhase.PALETTE_APPLY));
if(! biome.getSnow().doSnow()) continue; if(!biome.getSnow().doSnow()) continue;
int y; int y;
Block b = null; Block b = null;
for(y = 254; y > 0; y--) { for(y = 254; y > 0; y--) {
b = chunk.getBlock(x, y, z); b = chunk.getBlock(x, y, z);
if(! b.getType().isAir()) break; if(!b.getType().isAir()) break;
} }
if(random.nextInt(100) >= biome.getSnow().getSnowChance(y)) if(random.nextInt(100) >= biome.getSnow().getSnowChance(y))
continue; continue;
if(blacklistSpawn.contains(b.getType()) || b.isPassable()) continue; if(blacklistSpawn.contains(b.getType()) || b.isPassable()) continue;
chunk.getBlock(x, ++ y, z).setBlockData(DataUtil.SNOW); chunk.getBlock(x, ++y, z).setBlockData(DataUtil.SNOW);
} }
} }
} }

View File

@ -31,20 +31,20 @@ public class StructurePopulator extends BlockPopulator {
int cx = (chunk.getX() << 4); int cx = (chunk.getX() << 4);
int cz = (chunk.getZ() << 4); int cz = (chunk.getZ() << 4);
TerraWorld tw = TerraWorld.getWorld(world); TerraWorld tw = TerraWorld.getWorld(world);
if(! tw.isSafe()) return; if(!tw.isSafe()) return;
TerraBiomeGrid grid = tw.getGrid(); TerraBiomeGrid grid = tw.getGrid();
ConfigPack config = tw.getConfig(); ConfigPack config = tw.getConfig();
structure: structure:
for(StructureConfig conf : config.getAllStructures()) { for(StructureConfig conf : config.getAllStructures()) {
Location spawn = conf.getSpawn().getNearestSpawn(cx + 8, cz + 8, world.getSeed()).toLocation(world); Location spawn = conf.getSpawn().getNearestSpawn(cx + 8, cz + 8, world.getSeed()).toLocation(world);
if(! config.getBiome((UserDefinedBiome) grid.getBiome(spawn)).getStructures().contains(conf)) continue; if(!config.getBiome((UserDefinedBiome) grid.getBiome(spawn)).getStructures().contains(conf)) continue;
Random r2 = new Random(spawn.hashCode()); Random r2 = new Random(spawn.hashCode());
Structure struc = conf.getStructure(r2); Structure struc = conf.getStructure(r2);
Structure.Rotation rotation = Structure.Rotation.fromDegrees(r2.nextInt(4) * 90); Structure.Rotation rotation = Structure.Rotation.fromDegrees(r2.nextInt(4) * 90);
for(int y = conf.getSearchStart().get(r2); y > 0; y--) { for(int y = conf.getSearchStart().get(r2); y > 0; y--) {
if(! conf.getBound().isInRange(y)) continue structure; if(!conf.getBound().isInRange(y)) continue structure;
spawn.setY(y); spawn.setY(y);
if(! struc.checkSpawns(spawn, rotation)) continue; if(!struc.checkSpawns(spawn, rotation)) continue;
double horizontal = struc.getStructureInfo().getMaxHorizontal(); double horizontal = struc.getStructureInfo().getMaxHorizontal();
if(Math.abs((cx + 8) - spawn.getBlockX()) <= horizontal && Math.abs((cz + 8) - spawn.getBlockZ()) <= horizontal) { if(Math.abs((cx + 8) - spawn.getBlockX()) <= horizontal && Math.abs((cz + 8) - spawn.getBlockZ()) <= horizontal) {
try(ProfileFuture ignore = TerraProfiler.fromWorld(world).measure("StructurePasteTime")) { try(ProfileFuture ignore = TerraProfiler.fromWorld(world).measure("StructurePasteTime")) {

View File

@ -146,7 +146,7 @@ public class Vector2 implements Cloneable {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if(! (obj instanceof Vector2)) { if(!(obj instanceof Vector2)) {
return false; return false;
} }
Vector2 other = (Vector2) obj; Vector2 other = (Vector2) obj;

View File

@ -5,9 +5,9 @@ import org.polydev.gaea.math.FastNoiseLite;
public class DeformedSphere extends VoxelGeometry { public class DeformedSphere extends VoxelGeometry {
public DeformedSphere(Vector start, int rad, double deform, FastNoiseLite noise) { public DeformedSphere(Vector start, int rad, double deform, FastNoiseLite noise) {
for(int x = - rad; x <= rad; x++) { for(int x = -rad; x <= rad; x++) {
for(int y = - rad; y <= rad; y++) { for(int y = -rad; y <= rad; y++) {
for(int z = - rad; z <= rad; z++) { for(int z = -rad; z <= rad; z++) {
Vector c = new Vector(x, y, z); Vector c = new Vector(x, y, z);
if(c.length() < (rad + 0.5) * ((noise.getNoise(x, y, z) + 1) * deform)) { if(c.length() < (rad + 0.5) * ((noise.getNoise(x, y, z) + 1) * deform)) {
addVector(c.add(start)); addVector(c.add(start));

View File

@ -4,9 +4,9 @@ import org.bukkit.util.Vector;
public class Sphere extends VoxelGeometry { public class Sphere extends VoxelGeometry {
public Sphere(Vector start, int rad) { public Sphere(Vector start, int rad) {
for(int x = - rad; x <= rad; x++) { for(int x = -rad; x <= rad; x++) {
for(int y = - rad; y <= rad; y++) { for(int y = -rad; y <= rad; y++) {
for(int z = - rad; z <= rad; z++) { for(int z = -rad; z <= rad; z++) {
Vector c = new Vector(x, y, z); Vector c = new Vector(x, y, z);
if(c.length() < rad + 0.5) { if(c.length() < rad + 0.5) {
addVector(c.add(start)); addVector(c.add(start));

View File

@ -39,7 +39,7 @@ import java.util.function.Consumer;
import static com.dfsek.terra.util.structure.RotationUtil.*; import static com.dfsek.terra.util.structure.RotationUtil.*;
public class Structure implements Serializable { public class Structure implements Serializable {
public static final long serialVersionUID = - 6664585217063842035L; public static final long serialVersionUID = -6664585217063842035L;
private final StructureContainedBlock[][][] structure; private final StructureContainedBlock[][][] structure;
private final StructureInfo structureInfo; private final StructureInfo structureInfo;
private final String id; private final String id;
@ -48,7 +48,7 @@ public class Structure implements Serializable {
private final HashSet<StructureContainedInventory> inventories; private final HashSet<StructureContainedInventory> inventories;
public Structure(@NotNull Location l1, @NotNull Location l2, @NotNull String id) throws InitializationException { public Structure(@NotNull Location l1, @NotNull Location l2, @NotNull String id) throws InitializationException {
int centerX = - 1, centerZ = - 1; int centerX = -1, centerZ = -1;
this.id = id; this.id = id;
this.uuid = UUID.randomUUID(); this.uuid = UUID.randomUUID();
this.spawns = new HashSet<>(); this.spawns = new HashSet<>();
@ -108,7 +108,7 @@ public class Structure implements Serializable {
if(state instanceof BlockInventoryHolder) { if(state instanceof BlockInventoryHolder) {
inventories.add(new StructureContainedInventory(((BlockInventoryHolder) state).getInventory(), block)); inventories.add(new StructureContainedInventory(((BlockInventoryHolder) state).getInventory(), block));
} }
if(! requirement.equals(StructureSpawnRequirement.BLANK)) spawns.add(block); if(!requirement.equals(StructureSpawnRequirement.BLANK)) spawns.add(block);
structure[x][z][y] = block; structure[x][z][y] = block;
} }
} }
@ -181,7 +181,7 @@ public class Structure implements Serializable {
public boolean checkSpawns(Location origin, Rotation r) { public boolean checkSpawns(Location origin, Rotation r) {
for(StructureContainedBlock b : spawns) { for(StructureContainedBlock b : spawns) {
Vector2 rot = getRotatedCoords(new Vector2(b.getX() - structureInfo.getCenterX(), b.getZ() - structureInfo.getCenterZ()), r); Vector2 rot = getRotatedCoords(new Vector2(b.getX() - structureInfo.getCenterX(), b.getZ() - structureInfo.getCenterZ()), r);
if(! b.getRequirement().matches(origin.getWorld(), (int) rot.getX() + origin.getBlockX(), origin.getBlockY() + b.getY(), (int) rot.getZ() + origin.getBlockZ())) if(!b.getRequirement().matches(origin.getWorld(), (int) rot.getX() + origin.getBlockX(), origin.getBlockY() + b.getY(), (int) rot.getZ() + origin.getBlockZ()))
return false; return false;
} }
return true; return true;
@ -217,7 +217,7 @@ public class Structure implements Serializable {
*/ */
private void pasteBlock(StructureContainedBlock block, Location origin, Rotation r) { private void pasteBlock(StructureContainedBlock block, Location origin, Rotation r) {
BlockData data = block.getBlockData().clone(); BlockData data = block.getBlockData().clone();
if(! data.getMaterial().equals(Material.STRUCTURE_VOID)) { if(!data.getMaterial().equals(Material.STRUCTURE_VOID)) {
Location loc = origin.clone().add(block.getX(), block.getY(), block.getZ()); Location loc = origin.clone().add(block.getX(), block.getY(), block.getZ());
Block worldBlock = loc.getBlock(); Block worldBlock = loc.getBlock();

View File

@ -6,7 +6,7 @@ import org.bukkit.inventory.ItemStack;
import java.io.Serializable; import java.io.Serializable;
public class StructureContainedInventory implements Serializable { public class StructureContainedInventory implements Serializable {
public static final long serialVersionUID = - 175339605585943678L; public static final long serialVersionUID = -175339605585943678L;
private final int uid; private final int uid;
private final int x, y, z; private final int x, y, z;

View File

@ -5,7 +5,7 @@ import com.dfsek.terra.procgen.math.Vector2;
import java.io.Serializable; import java.io.Serializable;
public class StructureInfo implements Serializable { public class StructureInfo implements Serializable {
public static final long serialVersionUID = - 175639605885943678L; public static final long serialVersionUID = -175639605885943678L;
private final int sizeX; private final int sizeX;
private final int sizeY; private final int sizeY;
private final int sizeZ; private final int sizeZ;

View File

@ -46,7 +46,7 @@ public enum StructureSpawnRequirement implements Serializable {
return true; return true;
} }
}; };
private static final long serialVersionUID = - 175639605885943679L; private static final long serialVersionUID = -175639605885943679L;
private static final transient Map<World, FastNoiseLite> noiseMap = new HashMap<>(); private static final transient Map<World, FastNoiseLite> noiseMap = new HashMap<>();
public static void putNoise(World w, FastNoiseLite noise) { public static void putNoise(World w, FastNoiseLite noise) {

View File

@ -53,7 +53,7 @@ public class EntityFeature implements Feature {
for(int i = 0; i < amountSpawn && i < attempts; i++) { for(int i = 0; i < amountSpawn && i < attempts; i++) {
int yv = y.get(random); int yv = y.get(random);
Location attempt = l.clone().add(x.get(random) - cx, yv, z.get(random) - cz); Location attempt = l.clone().add(x.get(random) - cx, yv, z.get(random) - cz);
if(! isInChunk(chunk, attempt)) continue; // Don't attempt spawn if not in current chunk. if(!isInChunk(chunk, attempt)) continue; // Don't attempt spawn if not in current chunk.
boolean canSpawn = false; boolean canSpawn = false;
while(yv >= 0 && attempt.getBlockY() >= l.getBlockY()) { // Go down, see if valid spawns exist. while(yv >= 0 && attempt.getBlockY() >= l.getBlockY()) { // Go down, see if valid spawns exist.
@ -62,10 +62,10 @@ public class EntityFeature implements Feature {
attempt.subtract(0, 1, 0); attempt.subtract(0, 1, 0);
yv--; yv--;
if(! stand.contains(on.getType())) continue; if(!stand.contains(on.getType())) continue;
for(int j = 1; j < inSize + 1; j++) for(int j = 1; j < inSize + 1; j++)
if(! in.contains(on.getRelative(BlockFace.UP, j).getType())) canSpawn = false; if(!in.contains(on.getRelative(BlockFace.UP, j).getType())) canSpawn = false;
if(canSpawn) break; if(canSpawn) break;
} }
@ -99,10 +99,10 @@ public class EntityFeature implements Feature {
attempt.subtract(0, 1, 0); attempt.subtract(0, 1, 0);
yv--; yv--;
if(! stand.contains(on.getType())) continue; if(!stand.contains(on.getType())) continue;
for(int j = 1; j < inSize + 1; j++) for(int j = 1; j < inSize + 1; j++)
if(! in.contains(on.getRelative(BlockFace.UP, j).getType())) canSpawn = false; if(!in.contains(on.getRelative(BlockFace.UP, j).getType())) canSpawn = false;
if(canSpawn) break; if(canSpawn) break;
} }

View File

@ -22,7 +22,7 @@ public class SerializableBanner implements SerializableBlockState {
@Override @Override
public BlockState getState(BlockState orig) { public BlockState getState(BlockState orig) {
if(! (orig instanceof Banner)) throw new IllegalArgumentException("Provided BlockState is not a banner."); if(!(orig instanceof Banner)) throw new IllegalArgumentException("Provided BlockState is not a banner.");
Banner banner = (Banner) orig; Banner banner = (Banner) orig;
banner.setBaseColor(base); banner.setBaseColor(base);
for(Pattern pattern : patterns) { for(Pattern pattern : patterns) {

View File

@ -26,7 +26,7 @@ public class SerializableMonsterCage implements SerializableBlockState {
@Override @Override
public BlockState getState(BlockState orig) { public BlockState getState(BlockState orig) {
if(! (orig instanceof CreatureSpawner)) if(!(orig instanceof CreatureSpawner))
throw new IllegalArgumentException("BlockState is not a Monster Spawner!"); throw new IllegalArgumentException("BlockState is not a Monster Spawner!");
CreatureSpawner spawner = (CreatureSpawner) orig; CreatureSpawner spawner = (CreatureSpawner) orig;
spawner.setSpawnedType(type); spawner.setSpawnedType(type);

View File

@ -15,7 +15,7 @@ public class SerializableSign implements SerializableBlockState {
@Override @Override
public BlockState getState(BlockState orig) { public BlockState getState(BlockState orig) {
if(! (orig instanceof Sign)) throw new IllegalArgumentException("Provided BlockState is not a sign."); if(!(orig instanceof Sign)) throw new IllegalArgumentException("Provided BlockState is not a sign.");
Sign sign = (Sign) orig; Sign sign = (Sign) orig;
for(int i = 0; i < text.length; i++) { for(int i = 0; i < text.length; i++) {
sign.setLine(i, text[i]); sign.setLine(i, text[i]);

View File

@ -10,7 +10,7 @@ import java.util.logging.Level;
public final class PaperUtil { public final class PaperUtil {
public static void checkPaper(JavaPlugin main) { public static void checkPaper(JavaPlugin main) {
Bukkit.getScheduler().scheduleSyncDelayedTask(main, () -> { Bukkit.getScheduler().scheduleSyncDelayedTask(main, () -> {
if(! PaperLib.isPaper()) { if(!PaperLib.isPaper()) {
LangUtil.log("use-paper", Level.WARNING); LangUtil.log("use-paper", Level.WARNING);
} }
}, 100L); }, 100L);

View File

@ -17,13 +17,13 @@ public final class RotationUtil {
Vector2 copy = orig.clone(); Vector2 copy = orig.clone();
switch(r) { switch(r) {
case CW_90: case CW_90:
copy.setX(orig.getZ()).setZ(- orig.getX()); copy.setX(orig.getZ()).setZ(-orig.getX());
break; break;
case CCW_90: case CCW_90:
copy.setX(- orig.getZ()).setZ(orig.getX()); copy.setX(-orig.getZ()).setZ(orig.getX());
break; break;
case CW_180: case CW_180:
copy.multiply(- 1); copy.multiply(-1);
break; break;
} }
return copy; return copy;
@ -184,7 +184,7 @@ public final class RotationUtil {
case NORTH_NORTH_WEST: case NORTH_NORTH_WEST:
return 15; return 15;
default: default:
return - 1; return -1;
} }
} }

File diff suppressed because one or more lines are too long

View File

@ -91,7 +91,7 @@ public class LookupGenerator {
public static int normalize(double i, int n) { public static int normalize(double i, int n) {
i *= 1.42; // Magic simplex value (sqrt(2) plus a little) i *= 1.42; // Magic simplex value (sqrt(2) plus a little)
i = Math.min(Math.max(i, - 1), 1); i = Math.min(Math.max(i, -1), 1);
return Math.min((int) Math.floor((i + 1) * ((double) n / 2)), n - 1); return Math.min((int) Math.floor((i + 1) * ((double) n / 2)), n - 1);
} }