diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/Utilities.java b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/GeneralUtilities.java similarity index 95% rename from src/main/java/ca/recrown/islandsurvivalcraft/Utilities.java rename to src/main/java/ca/recrown/islandsurvivalcraft/utilities/GeneralUtilities.java index 3138388..713e412 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/Utilities.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/GeneralUtilities.java @@ -1,4 +1,4 @@ -package ca.recrown.islandsurvivalcraft; +package ca.recrown.islandsurvivalcraft.utilities; import java.util.ArrayList; import java.util.HashMap; @@ -7,9 +7,9 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; -import ca.recrown.islandsurvivalcraft.datatypes.Point2; +import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2; -public class Utilities { +public class GeneralUtilities { public final static int CHUNK_SIZE = 16; public final static ExecutorService ISC_EXECUTOR_ALPHA = Executors.newFixedThreadPool(1, createThreadFactory("ALPHA", Thread.NORM_PRIORITY + 1)); public final static ExecutorService ISC_EXECUTOR_BETA = Executors.newFixedThreadPool(2, createThreadFactory("BETA", Thread.NORM_PRIORITY)); diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/caching/Cache.java b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/caching/Cache.java similarity index 97% rename from src/main/java/ca/recrown/islandsurvivalcraft/caching/Cache.java rename to src/main/java/ca/recrown/islandsurvivalcraft/utilities/caching/Cache.java index e8a1c97..bd5b0d6 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/caching/Cache.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/caching/Cache.java @@ -1,4 +1,4 @@ -package ca.recrown.islandsurvivalcraft.caching; +package ca.recrown.islandsurvivalcraft.utilities.caching; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.locks.ReentrantLock; diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/caching/CacheUsageStack.java b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/caching/CacheUsageStack.java similarity index 97% rename from src/main/java/ca/recrown/islandsurvivalcraft/caching/CacheUsageStack.java rename to src/main/java/ca/recrown/islandsurvivalcraft/utilities/caching/CacheUsageStack.java index 6b2d5f2..15a2d9b 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/caching/CacheUsageStack.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/caching/CacheUsageStack.java @@ -1,4 +1,4 @@ -package ca.recrown.islandsurvivalcraft.caching; +package ca.recrown.islandsurvivalcraft.utilities.caching; import java.util.concurrent.locks.ReentrantLock; diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/caching/CacheValue.java b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/caching/CacheValue.java similarity index 91% rename from src/main/java/ca/recrown/islandsurvivalcraft/caching/CacheValue.java rename to src/main/java/ca/recrown/islandsurvivalcraft/utilities/caching/CacheValue.java index 49b691e..01cf1a5 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/caching/CacheValue.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/caching/CacheValue.java @@ -1,4 +1,4 @@ -package ca.recrown.islandsurvivalcraft.caching; +package ca.recrown.islandsurvivalcraft.utilities.caching; class CacheValue { /** diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/datatypes/Point2.java b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/datatypes/Point2.java similarity index 92% rename from src/main/java/ca/recrown/islandsurvivalcraft/datatypes/Point2.java rename to src/main/java/ca/recrown/islandsurvivalcraft/utilities/datatypes/Point2.java index d460b6f..9303971 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/datatypes/Point2.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/datatypes/Point2.java @@ -1,4 +1,4 @@ -package ca.recrown.islandsurvivalcraft.datatypes; +package ca.recrown.islandsurvivalcraft.utilities.datatypes; import java.util.Objects; diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/datatypes/Point3.java b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/datatypes/Point3.java similarity index 93% rename from src/main/java/ca/recrown/islandsurvivalcraft/datatypes/Point3.java rename to src/main/java/ca/recrown/islandsurvivalcraft/utilities/datatypes/Point3.java index 3993398..d422f82 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/datatypes/Point3.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/datatypes/Point3.java @@ -1,4 +1,4 @@ -package ca.recrown.islandsurvivalcraft.datatypes; +package ca.recrown.islandsurvivalcraft.utilities.datatypes; import java.util.Objects; diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/datatypes/Vector3.java b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/datatypes/Vector3.java similarity index 93% rename from src/main/java/ca/recrown/islandsurvivalcraft/datatypes/Vector3.java rename to src/main/java/ca/recrown/islandsurvivalcraft/utilities/datatypes/Vector3.java index 685d97e..cfe8fbb 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/datatypes/Vector3.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/datatypes/Vector3.java @@ -1,4 +1,4 @@ -package ca.recrown.islandsurvivalcraft.datatypes; +package ca.recrown.islandsurvivalcraft.utilities.datatypes; import java.util.Objects; diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/floodfill/Floodable.java b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/floodfill/Floodable.java similarity index 72% rename from src/main/java/ca/recrown/islandsurvivalcraft/floodfill/Floodable.java rename to src/main/java/ca/recrown/islandsurvivalcraft/utilities/floodfill/Floodable.java index 73bbc7a..d066f8d 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/floodfill/Floodable.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/floodfill/Floodable.java @@ -1,6 +1,6 @@ -package ca.recrown.islandsurvivalcraft.floodfill; +package ca.recrown.islandsurvivalcraft.utilities.floodfill; -import ca.recrown.islandsurvivalcraft.datatypes.Point2; +import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2; public interface Floodable { /** diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/floodfill/Flooder.java b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/floodfill/Flooder.java similarity index 90% rename from src/main/java/ca/recrown/islandsurvivalcraft/floodfill/Flooder.java rename to src/main/java/ca/recrown/islandsurvivalcraft/utilities/floodfill/Flooder.java index e786a0e..14cb0f5 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/floodfill/Flooder.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/floodfill/Flooder.java @@ -1,9 +1,10 @@ -package ca.recrown.islandsurvivalcraft.floodfill; +package ca.recrown.islandsurvivalcraft.utilities.floodfill; + import java.util.HashSet; import java.util.LinkedList; -import ca.recrown.islandsurvivalcraft.datatypes.Point2; +import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2; public class Flooder { private final Point2 start; diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/pathfinding/CoordinateTargetValidatable.java b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/pathfinding/CoordinateTargetValidatable.java similarity index 83% rename from src/main/java/ca/recrown/islandsurvivalcraft/pathfinding/CoordinateTargetValidatable.java rename to src/main/java/ca/recrown/islandsurvivalcraft/utilities/pathfinding/CoordinateTargetValidatable.java index e838ee8..2264a17 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/pathfinding/CoordinateTargetValidatable.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/pathfinding/CoordinateTargetValidatable.java @@ -1,4 +1,4 @@ -package ca.recrown.islandsurvivalcraft.pathfinding; +package ca.recrown.islandsurvivalcraft.utilities.pathfinding; public interface CoordinateTargetValidatable { /** diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/pathfinding/CoordinateValidatable.java b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/pathfinding/CoordinateValidatable.java similarity index 58% rename from src/main/java/ca/recrown/islandsurvivalcraft/pathfinding/CoordinateValidatable.java rename to src/main/java/ca/recrown/islandsurvivalcraft/utilities/pathfinding/CoordinateValidatable.java index 2737439..3453587 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/pathfinding/CoordinateValidatable.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/pathfinding/CoordinateValidatable.java @@ -1,4 +1,4 @@ -package ca.recrown.islandsurvivalcraft.pathfinding; +package ca.recrown.islandsurvivalcraft.utilities.pathfinding; public interface CoordinateValidatable { public boolean validate(int x, int y); diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/pathfinding/DFSNode.java b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/pathfinding/DFSNode.java similarity index 92% rename from src/main/java/ca/recrown/islandsurvivalcraft/pathfinding/DFSNode.java rename to src/main/java/ca/recrown/islandsurvivalcraft/utilities/pathfinding/DFSNode.java index ab73efc..36a836f 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/pathfinding/DFSNode.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/pathfinding/DFSNode.java @@ -1,8 +1,8 @@ -package ca.recrown.islandsurvivalcraft.pathfinding; +package ca.recrown.islandsurvivalcraft.utilities.pathfinding; import java.util.Objects; -import ca.recrown.islandsurvivalcraft.datatypes.Point2; +import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2; public class DFSNode extends Point2 implements Comparable { private DFSNode goal; diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/pathfinding/DepthFirstSearch.java b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/pathfinding/DepthFirstSearch.java similarity index 97% rename from src/main/java/ca/recrown/islandsurvivalcraft/pathfinding/DepthFirstSearch.java rename to src/main/java/ca/recrown/islandsurvivalcraft/utilities/pathfinding/DepthFirstSearch.java index e453cf9..d28344e 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/pathfinding/DepthFirstSearch.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/utilities/pathfinding/DepthFirstSearch.java @@ -1,4 +1,4 @@ -package ca.recrown.islandsurvivalcraft.pathfinding; +package ca.recrown.islandsurvivalcraft.utilities.pathfinding; import java.util.HashSet; import java.util.PriorityQueue; @@ -6,7 +6,7 @@ import java.util.Queue; import org.apache.commons.lang.NullArgumentException; -import ca.recrown.islandsurvivalcraft.datatypes.Point2; +import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2; public class DepthFirstSearch { private Queue queue; diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/world/BiomeMap.java b/src/main/java/ca/recrown/islandsurvivalcraft/world/BiomeMap.java index 1b354b1..10a6525 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/BiomeMap.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/world/BiomeMap.java @@ -8,7 +8,7 @@ import java.util.Map.Entry; import org.bukkit.block.Biome; import org.bukkit.util.noise.SimplexOctaveGenerator; -import ca.recrown.islandsurvivalcraft.Utilities; +import ca.recrown.islandsurvivalcraft.utilities.GeneralUtilities; public class BiomeMap { private final SimplexOctaveGenerator noise; @@ -74,7 +74,7 @@ public class BiomeMap { landBiomeTemperatures.put(Biome.BADLANDS_PLATEAU, 2.0f); landBiomeTemperatures.put(Biome.MODIFIED_BADLANDS_PLATEAU, 2.0f); landBiomeTemperatures.put(Biome.SHATTERED_SAVANNA_PLATEAU, 1.0f); - temperaturesForLand = Utilities.invertHashMap(landBiomeTemperatures); + temperaturesForLand = GeneralUtilities.invertHashMap(landBiomeTemperatures); for (Entry> entry : temperaturesForLand.entrySet()) { if (entry.getKey() <= 0.05f) { @@ -95,7 +95,7 @@ public class BiomeMap { oceanBiomeTemperatures.put(Biome.OCEAN, 0.3f); oceanBiomeTemperatures.put(Biome.COLD_OCEAN, 0.3f); oceanBiomeTemperatures.put(Biome.FROZEN_OCEAN, 0f); - temperaturesForOcean = Utilities.invertHashMap(oceanBiomeTemperatures); + temperaturesForOcean = GeneralUtilities.invertHashMap(oceanBiomeTemperatures); for (Entry> entry : temperaturesForOcean.entrySet()) { if (entry.getKey() <= 0.00f) { temperaturePartitionedOceanBiomes.get(0.0f).addAll(entry.getValue()); diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/world/IslandWorldMap.java b/src/main/java/ca/recrown/islandsurvivalcraft/world/IslandWorldMap.java index e553846..4d8d06a 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/IslandWorldMap.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/world/IslandWorldMap.java @@ -4,10 +4,10 @@ import java.util.Random; import org.bukkit.util.noise.SimplexOctaveGenerator; -import ca.recrown.islandsurvivalcraft.datatypes.Point2; -import ca.recrown.islandsurvivalcraft.caching.Cache; -import ca.recrown.islandsurvivalcraft.pathfinding.CoordinateValidatable; -import ca.recrown.islandsurvivalcraft.pathfinding.DepthFirstSearch; +import ca.recrown.islandsurvivalcraft.utilities.caching.Cache; +import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2; +import ca.recrown.islandsurvivalcraft.utilities.pathfinding.CoordinateValidatable; +import ca.recrown.islandsurvivalcraft.utilities.pathfinding.DepthFirstSearch; public class IslandWorldMap implements CoordinateValidatable { private final Cache blockValueCache; diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/world/TemperatureMap.java b/src/main/java/ca/recrown/islandsurvivalcraft/world/TemperatureMap.java index d0fe020..95f93e9 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/TemperatureMap.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/world/TemperatureMap.java @@ -4,8 +4,8 @@ import java.util.Random; import org.bukkit.util.noise.SimplexOctaveGenerator; -import ca.recrown.islandsurvivalcraft.datatypes.Point2; -import ca.recrown.islandsurvivalcraft.caching.Cache; +import ca.recrown.islandsurvivalcraft.utilities.caching.Cache; +import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2; public class TemperatureMap { private final Cache temperatureCache; diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/BiomeGenerator.java b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/BiomeGenerator.java index 16af4cd..a1a7abd 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/BiomeGenerator.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/BiomeGenerator.java @@ -3,8 +3,8 @@ package ca.recrown.islandsurvivalcraft.world.generation.biomes; import org.bukkit.World; import org.bukkit.block.Biome; -import ca.recrown.islandsurvivalcraft.caching.Cache; -import ca.recrown.islandsurvivalcraft.datatypes.Point2; +import ca.recrown.islandsurvivalcraft.utilities.caching.Cache; +import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2; import ca.recrown.islandsurvivalcraft.world.BiomeMap; import ca.recrown.islandsurvivalcraft.world.IslandWorldMap; import ca.recrown.islandsurvivalcraft.world.TemperatureMap; diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/UniqueBiomeGenerator.java b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/UniqueBiomeGenerator.java index e5df05e..bc06b27 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/UniqueBiomeGenerator.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/UniqueBiomeGenerator.java @@ -3,13 +3,13 @@ package ca.recrown.islandsurvivalcraft.world.generation.biomes; import org.bukkit.World; import org.bukkit.block.Biome; -import ca.recrown.islandsurvivalcraft.Utilities; -import ca.recrown.islandsurvivalcraft.datatypes.Point2; -import ca.recrown.islandsurvivalcraft.caching.Cache; -import ca.recrown.islandsurvivalcraft.floodfill.Floodable; -import ca.recrown.islandsurvivalcraft.floodfill.Flooder; -import ca.recrown.islandsurvivalcraft.pathfinding.CoordinateTargetValidatable; -import ca.recrown.islandsurvivalcraft.pathfinding.DepthFirstSearch; +import ca.recrown.islandsurvivalcraft.utilities.GeneralUtilities; +import ca.recrown.islandsurvivalcraft.utilities.caching.Cache; +import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2; +import ca.recrown.islandsurvivalcraft.utilities.floodfill.Floodable; +import ca.recrown.islandsurvivalcraft.utilities.floodfill.Flooder; +import ca.recrown.islandsurvivalcraft.utilities.pathfinding.CoordinateTargetValidatable; +import ca.recrown.islandsurvivalcraft.utilities.pathfinding.DepthFirstSearch; import ca.recrown.islandsurvivalcraft.world.BiomeMap; import ca.recrown.islandsurvivalcraft.world.IslandWorldMap; import ca.recrown.islandsurvivalcraft.world.TemperatureMap; @@ -19,7 +19,7 @@ public class UniqueBiomeGenerator implements BiomeGenerator { public void generateBiomeColumn(Biome[][][] chunkBiomeSets, World world, int chunkX, int chunkZ, int localX, int localZ, IslandWorldMap mapper, BiomeMap biomeSelector, TemperatureMap tempGen, Cache biomeCache, Cache chunkGenCache) { int worldX = 16 * chunkX + localX; int worldZ = 16 * chunkZ + localZ; - Point2 chunkCoords = Utilities.worldToChunkCoordinates(new Point2(worldX, worldZ)); + Point2 chunkCoords = GeneralUtilities.worldToChunkCoordinates(new Point2(worldX, worldZ)); chunkGenCache.set(chunkCoords, false); //Check if we can just give it something in cache. @@ -60,14 +60,14 @@ public class UniqueBiomeGenerator implements BiomeGenerator { Biome[] res = null; if (chunkBiomeSets != null) { - Point2 localCoords = Utilities.worldToLocalChunkCoordinates(worldCoords); + Point2 localCoords = GeneralUtilities.worldToLocalChunkCoordinates(worldCoords); return chunkBiomeSets[localCoords.x][localCoords.y]; } res = biomeCache.get(worldCoords); if (res != null) return res; - Point2 chunkCoords = Utilities.worldToChunkCoordinates(worldCoords); + Point2 chunkCoords = GeneralUtilities.worldToChunkCoordinates(worldCoords); Boolean chunkExists = existenceCache.get(chunkCoords); if (chunkExists == null) { chunkExists = world.isChunkGenerated(worldX, worldZ); @@ -85,7 +85,7 @@ public class UniqueBiomeGenerator implements BiomeGenerator { private void setCacheBiome(int worldX, int worldZ, Biome[] biomeSet, Biome[][][] localBiomes, Cache biomeCache) { Point2 worldCoords = new Point2(worldX, worldZ); if (localBiomes != null) { - Point2 localCoords = Utilities.worldToLocalChunkCoordinates(worldCoords); + Point2 localCoords = GeneralUtilities.worldToLocalChunkCoordinates(worldCoords); localBiomes[localCoords.x][localCoords.y] = biomeSet; } biomeCache.set(worldCoords, biomeSet); @@ -145,7 +145,7 @@ public class UniqueBiomeGenerator implements BiomeGenerator { @Override public boolean flood(Point2 point) { - Point2 chunkCoords = Utilities.worldToChunkCoordinates(point); + Point2 chunkCoords = GeneralUtilities.worldToChunkCoordinates(point); if (!this.chunkCoords.fastEquals(chunkCoords) || !mapper.validate(point.x, point.y)) return false; int x = point.x; int y = point.y; diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/chunks/IslandWorldChunkGenerator.java b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/chunks/IslandWorldChunkGenerator.java index ba7435f..5293270 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/chunks/IslandWorldChunkGenerator.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/chunks/IslandWorldChunkGenerator.java @@ -15,9 +15,9 @@ import org.bukkit.block.data.BlockData; import org.bukkit.event.Listener; import org.bukkit.generator.ChunkGenerator; -import ca.recrown.islandsurvivalcraft.Utilities; -import ca.recrown.islandsurvivalcraft.caching.Cache; -import ca.recrown.islandsurvivalcraft.datatypes.Point2; +import ca.recrown.islandsurvivalcraft.utilities.GeneralUtilities; +import ca.recrown.islandsurvivalcraft.utilities.caching.Cache; +import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2; import ca.recrown.islandsurvivalcraft.world.BiomeMap; import ca.recrown.islandsurvivalcraft.world.IslandWorldMap; import ca.recrown.islandsurvivalcraft.world.TemperatureMap; @@ -39,8 +39,8 @@ public class IslandWorldChunkGenerator extends ChunkGenerator implements Listene private volatile WorldLayerShader layerShader; private volatile Cache biomeCache = new Cache<>(131072); private volatile Cache chunkLoadedCache = new Cache<>(4096); - private volatile ExecutorService exAlpha = Utilities.ISC_EXECUTOR_ALPHA; - private volatile ExecutorService exBeta = Utilities.ISC_EXECUTOR_BETA; + private volatile ExecutorService exAlpha = GeneralUtilities.ISC_EXECUTOR_ALPHA; + private volatile ExecutorService exBeta = GeneralUtilities.ISC_EXECUTOR_BETA; public void initialize(Random random, boolean uniqueBiome, int seaLevel, int worldHeight) { if (initialized) throw new IllegalStateException("This generator has already been initialized"); @@ -76,22 +76,22 @@ public class IslandWorldChunkGenerator extends ChunkGenerator implements Listene LinkedList> tasks = new LinkedList<>(); ChunkData chunkData = createChunkData(world); Future preLoader = exAlpha.submit(() -> { - for (int x = Utilities.CHUNK_SIZE - 1; x >= 0; x--) { - for (int z = Utilities.CHUNK_SIZE - 1; z >= 0; z--) { + for (int x = GeneralUtilities.CHUNK_SIZE - 1; x >= 0; x--) { + for (int z = GeneralUtilities.CHUNK_SIZE - 1; z >= 0; z--) { if (Thread.currentThread().isInterrupted()) return false; - islandMap.getWorldValue(Utilities.CHUNK_SIZE * chunkX + x, Utilities.CHUNK_SIZE * chunkZ + z); + islandMap.getWorldValue(GeneralUtilities.CHUNK_SIZE * chunkX + x, GeneralUtilities.CHUNK_SIZE * chunkZ + z); } } return true; }); - Biome[][][] biomeArraySet = new Biome[Utilities.CHUNK_SIZE][Utilities.CHUNK_SIZE][4]; - for (int x = 0; x < Utilities.CHUNK_SIZE; x++) { - for (int z = 0; z < Utilities.CHUNK_SIZE; z++) { + Biome[][][] biomeArraySet = new Biome[GeneralUtilities.CHUNK_SIZE][GeneralUtilities.CHUNK_SIZE][4]; + for (int x = 0; x < GeneralUtilities.CHUNK_SIZE; x++) { + for (int z = 0; z < GeneralUtilities.CHUNK_SIZE; z++) { final int localX = x; final int localZ = z; - final int worldX = Utilities.CHUNK_SIZE * chunkX + localX; - final int worldZ = Utilities.CHUNK_SIZE * chunkZ + localZ; + final int worldX = GeneralUtilities.CHUNK_SIZE * chunkX + localX; + final int worldZ = GeneralUtilities.CHUNK_SIZE * chunkZ + localZ; if (biomeArraySet[localX][localZ][0] == null) { biomeGenerator.generateBiomeColumn(biomeArraySet, world, chunkX, chunkZ, localX, localZ, islandMap, biomeMap, temperatureMap, biomeCache, chunkLoadedCache); diff --git a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/shaders/WorldLayerShader.java b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/shaders/WorldLayerShader.java index 2d3c933..74f800b 100644 --- a/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/shaders/WorldLayerShader.java +++ b/src/main/java/ca/recrown/islandsurvivalcraft/world/generation/shaders/WorldLayerShader.java @@ -7,8 +7,8 @@ import org.bukkit.block.Biome; import org.bukkit.block.data.BlockData; import org.bukkit.util.noise.SimplexOctaveGenerator; -import ca.recrown.islandsurvivalcraft.caching.Cache; -import ca.recrown.islandsurvivalcraft.datatypes.Vector3; +import ca.recrown.islandsurvivalcraft.utilities.caching.Cache; +import ca.recrown.islandsurvivalcraft.utilities.datatypes.Vector3; import ca.recrown.islandsurvivalcraft.world.IslandWorldMap; @SuppressWarnings("unused") diff --git a/src/test/java/ca/recrown/islandsurvivalcraft/UtilitiesTest.java b/src/test/java/ca/recrown/islandsurvivalcraft/UtilitiesTest.java deleted file mode 100644 index b73d0c1..0000000 --- a/src/test/java/ca/recrown/islandsurvivalcraft/UtilitiesTest.java +++ /dev/null @@ -1,129 +0,0 @@ -package ca.recrown.islandsurvivalcraft; - -import static org.junit.jupiter.api.Assertions.assertEquals; - -import java.util.ArrayList; -import java.util.HashMap; - -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; -import org.junit.jupiter.api.TestInstance.Lifecycle; - -import ca.recrown.islandsurvivalcraft.datatypes.Point2; - -/** - * Unit test for simple App. - */ -@TestInstance(Lifecycle.PER_CLASS) -public class UtilitiesTest { - /** - * Basic hashmap inversion test. - */ - @Test - public void testInvertHashMap() - { - HashMap hashMap = new HashMap<>(); - hashMap.put("a", 1); - hashMap.put("b", 1); - hashMap.put("c", 2); - hashMap.put("d", 2); - - HashMap> res = Utilities.invertHashMap(hashMap); - ArrayList first = res.get(1); - ArrayList expectedFirst = new ArrayList<>(); - expectedFirst.add("a"); - expectedFirst.add("b"); - - ArrayList second = res.get(2); - ArrayList expectedSecond = new ArrayList<>(); - expectedSecond.add("c"); - expectedSecond.add("d"); - assertEquals(first, expectedFirst); - assertEquals(second, expectedSecond); - } - - @Test - public void testMagnitudeAddPositive() { - assertEquals(2, Utilities.addMagnitude(1, 1)); - } - @Test - public void testMagnitudeAddNegative() { - assertEquals(-2, Utilities.addMagnitude(-1, 1)); - } - - @Test - public void testWorldToChunkCoordinatesNegativePerfect() { - assertEquals(new Point2(-4, -3), Utilities.worldToChunkCoordinates(-64, -48)); - } - - @Test - public void testWorldToChunkCoordinatesNegativeOff() { - assertEquals(new Point2(-4, -3), Utilities.worldToChunkCoordinates(-55, -33)); - } - - @Test - public void testWorldToChunkCoordinatesNegativeOffClose() { - assertEquals(new Point2(15, -15), Utilities.worldToChunkCoordinates(255, -227)); - } - - @Test - public void testWorldToChunkCoordinatesPositivePerfect() { - assertEquals(new Point2(4, 5), Utilities.worldToChunkCoordinates(64, 80)); - } - - @Test - public void testWorldToChunkCoordinatesPositiveOff() { - assertEquals(new Point2(4, 5), Utilities.worldToChunkCoordinates(67, 84)); - } - - @Test - public void testWorldToLocalCoordinatesNegative() { - assertEquals(new Point2(2, 5), Utilities.worldToLocalChunkCoordinates(-62, -27)); - assertEquals(new Point2(2, 5), Utilities.worldToLocalChunkCoordinates(new Point2(-62, -27))); - } - - @Test - public void testWorldToLocalCoordinatesNegativePerfect() { - assertEquals(new Point2(0, 0), Utilities.worldToLocalChunkCoordinates(-128, -32)); - assertEquals(new Point2(0, 0), Utilities.worldToLocalChunkCoordinates(new Point2(-256, -16))); - } - - @Test - public void testWorldToLocalCoordinatesPositive() { - assertEquals(new Point2(7, 3), Utilities.worldToLocalChunkCoordinates(39, 83)); - assertEquals(new Point2(7, 3), Utilities.worldToLocalChunkCoordinates(new Point2(39, 83))); - } - - @Test - public void testWorldToLocalCoordinatesPositivePerfect() { - assertEquals(new Point2(0, 0), Utilities.worldToLocalChunkCoordinates(1024, 32)); - assertEquals(new Point2(0, 0), Utilities.worldToLocalChunkCoordinates(new Point2(16, 80))); - } - - @Test - public void testWorldToLocalCoordinatesPositiveEntirety() { - int chunkX = 4; - int chunkZ = 3; - for (int x = 0; x < Utilities.CHUNK_SIZE; x++) { - for (int z = 0; z < Utilities.CHUNK_SIZE; z++) { - int worldX = Utilities.CHUNK_SIZE * chunkX + x; - int worldZ = Utilities.CHUNK_SIZE * chunkZ + z; - assertEquals(new Point2(x, z), Utilities.worldToLocalChunkCoordinates(new Point2(worldX, worldZ))); - } - } - } - - @Test - public void testWorldToLocalCoordinatesNegativeEntirety() { - int chunkX = -42; - int chunkZ = -3; - for (int x = 0; x < Utilities.CHUNK_SIZE; x++) { - for (int z = 0; z < Utilities.CHUNK_SIZE; z++) { - int worldX = Utilities.CHUNK_SIZE * chunkX + x; - int worldZ = Utilities.CHUNK_SIZE * chunkZ + z; - assertEquals(new Point2(x, z), Utilities.worldToLocalChunkCoordinates(new Point2(worldX, worldZ))); - } - } - } -} - diff --git a/src/test/java/ca/recrown/islandsurvivalcraft/utilities/GeneralUtilitiesTest.java b/src/test/java/ca/recrown/islandsurvivalcraft/utilities/GeneralUtilitiesTest.java new file mode 100644 index 0000000..e854a9a --- /dev/null +++ b/src/test/java/ca/recrown/islandsurvivalcraft/utilities/GeneralUtilitiesTest.java @@ -0,0 +1,129 @@ +package ca.recrown.islandsurvivalcraft.utilities; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.TestInstance.Lifecycle; + +import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2; + +/** + * Unit test for simple App. + */ +@TestInstance(Lifecycle.PER_CLASS) +public class GeneralUtilitiesTest { + /** + * Basic hashmap inversion test. + */ + @Test + public void testInvertHashMap() + { + HashMap hashMap = new HashMap<>(); + hashMap.put("a", 1); + hashMap.put("b", 1); + hashMap.put("c", 2); + hashMap.put("d", 2); + + HashMap> res = GeneralUtilities.invertHashMap(hashMap); + ArrayList first = res.get(1); + ArrayList expectedFirst = new ArrayList<>(); + expectedFirst.add("a"); + expectedFirst.add("b"); + + ArrayList second = res.get(2); + ArrayList expectedSecond = new ArrayList<>(); + expectedSecond.add("c"); + expectedSecond.add("d"); + assertEquals(first, expectedFirst); + assertEquals(second, expectedSecond); + } + + @Test + public void testMagnitudeAddPositive() { + assertEquals(2, GeneralUtilities.addMagnitude(1, 1)); + } + @Test + public void testMagnitudeAddNegative() { + assertEquals(-2, GeneralUtilities.addMagnitude(-1, 1)); + } + + @Test + public void testWorldToChunkCoordinatesNegativePerfect() { + assertEquals(new Point2(-4, -3), GeneralUtilities.worldToChunkCoordinates(-64, -48)); + } + + @Test + public void testWorldToChunkCoordinatesNegativeOff() { + assertEquals(new Point2(-4, -3), GeneralUtilities.worldToChunkCoordinates(-55, -33)); + } + + @Test + public void testWorldToChunkCoordinatesNegativeOffClose() { + assertEquals(new Point2(15, -15), GeneralUtilities.worldToChunkCoordinates(255, -227)); + } + + @Test + public void testWorldToChunkCoordinatesPositivePerfect() { + assertEquals(new Point2(4, 5), GeneralUtilities.worldToChunkCoordinates(64, 80)); + } + + @Test + public void testWorldToChunkCoordinatesPositiveOff() { + assertEquals(new Point2(4, 5), GeneralUtilities.worldToChunkCoordinates(67, 84)); + } + + @Test + public void testWorldToLocalCoordinatesNegative() { + assertEquals(new Point2(2, 5), GeneralUtilities.worldToLocalChunkCoordinates(-62, -27)); + assertEquals(new Point2(2, 5), GeneralUtilities.worldToLocalChunkCoordinates(new Point2(-62, -27))); + } + + @Test + public void testWorldToLocalCoordinatesNegativePerfect() { + assertEquals(new Point2(0, 0), GeneralUtilities.worldToLocalChunkCoordinates(-128, -32)); + assertEquals(new Point2(0, 0), GeneralUtilities.worldToLocalChunkCoordinates(new Point2(-256, -16))); + } + + @Test + public void testWorldToLocalCoordinatesPositive() { + assertEquals(new Point2(7, 3), GeneralUtilities.worldToLocalChunkCoordinates(39, 83)); + assertEquals(new Point2(7, 3), GeneralUtilities.worldToLocalChunkCoordinates(new Point2(39, 83))); + } + + @Test + public void testWorldToLocalCoordinatesPositivePerfect() { + assertEquals(new Point2(0, 0), GeneralUtilities.worldToLocalChunkCoordinates(1024, 32)); + assertEquals(new Point2(0, 0), GeneralUtilities.worldToLocalChunkCoordinates(new Point2(16, 80))); + } + + @Test + public void testWorldToLocalCoordinatesPositiveEntirety() { + int chunkX = 4; + int chunkZ = 3; + for (int x = 0; x < GeneralUtilities.CHUNK_SIZE; x++) { + for (int z = 0; z < GeneralUtilities.CHUNK_SIZE; z++) { + int worldX = GeneralUtilities.CHUNK_SIZE * chunkX + x; + int worldZ = GeneralUtilities.CHUNK_SIZE * chunkZ + z; + assertEquals(new Point2(x, z), GeneralUtilities.worldToLocalChunkCoordinates(new Point2(worldX, worldZ))); + } + } + } + + @Test + public void testWorldToLocalCoordinatesNegativeEntirety() { + int chunkX = -42; + int chunkZ = -3; + for (int x = 0; x < GeneralUtilities.CHUNK_SIZE; x++) { + for (int z = 0; z < GeneralUtilities.CHUNK_SIZE; z++) { + int worldX = GeneralUtilities.CHUNK_SIZE * chunkX + x; + int worldZ = GeneralUtilities.CHUNK_SIZE * chunkZ + z; + assertEquals(new Point2(x, z), GeneralUtilities.worldToLocalChunkCoordinates(new Point2(worldX, worldZ))); + } + } + } +} + diff --git a/src/test/java/ca/recrown/islandsurvivalcraft/caching/CacheTest.java b/src/test/java/ca/recrown/islandsurvivalcraft/utilities/caching/CacheTest.java similarity index 99% rename from src/test/java/ca/recrown/islandsurvivalcraft/caching/CacheTest.java rename to src/test/java/ca/recrown/islandsurvivalcraft/utilities/caching/CacheTest.java index 69168e7..3283d73 100644 --- a/src/test/java/ca/recrown/islandsurvivalcraft/caching/CacheTest.java +++ b/src/test/java/ca/recrown/islandsurvivalcraft/utilities/caching/CacheTest.java @@ -1,4 +1,4 @@ -package ca.recrown.islandsurvivalcraft.caching; +package ca.recrown.islandsurvivalcraft.utilities.caching; import static org.junit.Assert.assertSame; import static org.junit.jupiter.api.Assertions.assertEquals; diff --git a/src/test/java/ca/recrown/islandsurvivalcraft/floodfill/FloodFillTest.java b/src/test/java/ca/recrown/islandsurvivalcraft/utilities/floodfill/FloodFillTest.java similarity index 94% rename from src/test/java/ca/recrown/islandsurvivalcraft/floodfill/FloodFillTest.java rename to src/test/java/ca/recrown/islandsurvivalcraft/utilities/floodfill/FloodFillTest.java index a8e4d5e..11bb882 100644 --- a/src/test/java/ca/recrown/islandsurvivalcraft/floodfill/FloodFillTest.java +++ b/src/test/java/ca/recrown/islandsurvivalcraft/utilities/floodfill/FloodFillTest.java @@ -1,4 +1,4 @@ -package ca.recrown.islandsurvivalcraft.floodfill; +package ca.recrown.islandsurvivalcraft.utilities.floodfill; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -13,7 +13,8 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestInstance.Lifecycle; -import ca.recrown.islandsurvivalcraft.datatypes.Point2; +import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2; +import ca.recrown.islandsurvivalcraft.utilities.floodfill.Floodable; @TestInstance(Lifecycle.PER_CLASS) public class FloodFillTest { diff --git a/src/test/java/ca/recrown/islandsurvivalcraft/pathfinding/DepthFirstSearchTest.java b/src/test/java/ca/recrown/islandsurvivalcraft/utilities/pathfinding/DepthFirstSearchTest.java similarity index 96% rename from src/test/java/ca/recrown/islandsurvivalcraft/pathfinding/DepthFirstSearchTest.java rename to src/test/java/ca/recrown/islandsurvivalcraft/utilities/pathfinding/DepthFirstSearchTest.java index cea4edb..84c9f7d 100644 --- a/src/test/java/ca/recrown/islandsurvivalcraft/pathfinding/DepthFirstSearchTest.java +++ b/src/test/java/ca/recrown/islandsurvivalcraft/utilities/pathfinding/DepthFirstSearchTest.java @@ -1,4 +1,4 @@ -package ca.recrown.islandsurvivalcraft.pathfinding; +package ca.recrown.islandsurvivalcraft.utilities.pathfinding; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -14,6 +14,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.TestInstance.Lifecycle; +import ca.recrown.islandsurvivalcraft.utilities.pathfinding.CoordinateTargetValidatable; +import ca.recrown.islandsurvivalcraft.utilities.pathfinding.CoordinateValidatable; + /** * Unit test for simple App. */ diff --git a/src/test/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/UniqueBiomeGeneratorTest.java b/src/test/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/UniqueBiomeGeneratorTest.java index 821808d..be7f492 100644 --- a/src/test/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/UniqueBiomeGeneratorTest.java +++ b/src/test/java/ca/recrown/islandsurvivalcraft/world/generation/biomes/UniqueBiomeGeneratorTest.java @@ -19,9 +19,9 @@ import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.Timeout; import org.junit.jupiter.api.TestInstance.Lifecycle; -import ca.recrown.islandsurvivalcraft.Utilities; -import ca.recrown.islandsurvivalcraft.caching.Cache; -import ca.recrown.islandsurvivalcraft.datatypes.Point2; +import ca.recrown.islandsurvivalcraft.utilities.GeneralUtilities; +import ca.recrown.islandsurvivalcraft.utilities.caching.Cache; +import ca.recrown.islandsurvivalcraft.utilities.datatypes.Point2; import ca.recrown.islandsurvivalcraft.world.BiomeMap; import ca.recrown.islandsurvivalcraft.world.IslandWorldMap; import ca.recrown.islandsurvivalcraft.world.TemperatureMap; @@ -60,9 +60,9 @@ public class UniqueBiomeGeneratorTest { TemperatureMap temperatureMapGenerator = new TemperatureMap(random); BiomeGenerator biomeGenerator = new UniqueBiomeGenerator(); - Biome[][][] biomes = new Biome[Utilities.CHUNK_SIZE][Utilities.CHUNK_SIZE][4]; - for (int localX = 0; localX < Utilities.CHUNK_SIZE; localX++) { - for (int localZ = 0; localZ < Utilities.CHUNK_SIZE; localZ++) { + Biome[][][] biomes = new Biome[GeneralUtilities.CHUNK_SIZE][GeneralUtilities.CHUNK_SIZE][4]; + for (int localX = 0; localX < GeneralUtilities.CHUNK_SIZE; localX++) { + for (int localZ = 0; localZ < GeneralUtilities.CHUNK_SIZE; localZ++) { if (biomes[localX][localZ] == null) { biomeGenerator.generateBiomeColumn(biomes, dummyWorld, chunkX, chunkZ, localX, localZ, mapper, biomeSelector, temperatureMapGenerator, biomeCache, chunkExistenceCache);