diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ac22f52..682e6d2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build +name: SonarCloud on: push: branches: @@ -8,25 +8,25 @@ on: types: [opened, synchronize, reopened] jobs: build: - name: Build + name: Build and analyze runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: Set up JDK 17 - uses: actions/setup-java@v2 + uses: actions/setup-java@v1 with: distribution: 'adopt' - java-version: '17' + java-version: 17 - name: Cache SonarCloud packages - uses: actions/cache@v2 + uses: actions/cache@v1 with: path: ~/.sonar/cache key: ${{ runner.os }}-sonar restore-keys: ${{ runner.os }}-sonar - name: Cache Maven packages - uses: actions/cache@v2 + uses: actions/cache@v1 with: path: ~/.m2 key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} @@ -35,4 +35,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \ No newline at end of file + run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=BentoBoxWorld_AcidIsland \ No newline at end of file diff --git a/pom.xml b/pom.xml index 4ef69b8..1626127 100644 --- a/pom.xml +++ b/pom.xml @@ -54,18 +54,18 @@ UTF-8 UTF-8 - 16 + 17 2.0.9 - 1.19-R0.1-SNAPSHOT - 1.21.0 + 1.19.3-R0.1-SNAPSHOT + 1.22.0-SNAPSHOT ${build.version}-SNAPSHOT -LOCAL - 1.16.0 + 1.17.0 BentoBoxWorld_AcidIsland bentobox-world @@ -250,6 +250,7 @@ 3.0.0-M5 + ${argLine} --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.math=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED @@ -289,9 +290,9 @@ org.apache.maven.plugins maven-javadoc-plugin - 3.2.0 + 3.4.1 - 16 + 17 public false -Xdoclint:none @@ -340,7 +341,7 @@ org.jacoco jacoco-maven-plugin - 0.8.3 + 0.8.7 true @@ -351,16 +352,21 @@ - pre-unit-test + prepare-agent prepare-agent - post-unit-test + report report + + + XML + + diff --git a/src/main/java/world/bentobox/acidisland/AcidIsland.java b/src/main/java/world/bentobox/acidisland/AcidIsland.java index 6b87884..847d622 100644 --- a/src/main/java/world/bentobox/acidisland/AcidIsland.java +++ b/src/main/java/world/bentobox/acidisland/AcidIsland.java @@ -7,6 +7,8 @@ import org.bukkit.World; import org.bukkit.World.Environment; import org.bukkit.WorldCreator; import org.bukkit.WorldType; +import org.bukkit.entity.SpawnCategory; +import org.bukkit.generator.BiomeProvider; import org.bukkit.generator.ChunkGenerator; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.Nullable; @@ -14,6 +16,7 @@ import org.eclipse.jdt.annotation.Nullable; import world.bentobox.acidisland.commands.IslandAboutCommand; import world.bentobox.acidisland.listeners.AcidEffect; import world.bentobox.acidisland.listeners.LavaCheck; +import world.bentobox.acidisland.world.AcidBiomeProvider; import world.bentobox.acidisland.world.AcidTask; import world.bentobox.acidisland.world.ChunkGeneratorWorld; import world.bentobox.bentobox.api.addons.GameModeAddon; @@ -34,6 +37,7 @@ public class AcidIsland extends GameModeAddon { private @Nullable AcidTask acidTask; private @Nullable ChunkGenerator chunkGenerator; private final Config config = new Config<>(this, AISettings.class); + private BiomeProvider biomeProvider; private static final String NETHER = "_nether"; private static final String THE_END = "_the_end"; @@ -44,10 +48,11 @@ public class AcidIsland extends GameModeAddon { saveDefaultConfig(); // Load settings from config.yml. This will check if there are any issues with it too. loadSettings(); + // Make the biome provider + this.biomeProvider = new AcidBiomeProvider(this); // Chunk generator chunkGenerator = settings.isUseOwnGenerator() ? null : new ChunkGeneratorWorld(this); // Register commands - // Register commands playerCommand = new DefaultPlayerCommand(this) { @@ -72,6 +77,7 @@ public class AcidIsland extends GameModeAddon { } return false; } + return true; } @@ -147,22 +153,22 @@ public class AcidIsland extends GameModeAddon { // Set spawn rates if (w != null && getSettings() != null) { if (getSettings().getSpawnLimitMonsters() > 0) { - w.setMonsterSpawnLimit(getSettings().getSpawnLimitMonsters()); + w.setSpawnLimit(SpawnCategory.MONSTER, getSettings().getSpawnLimitMonsters()); } if (getSettings().getSpawnLimitAmbient() > 0) { - w.setAmbientSpawnLimit(getSettings().getSpawnLimitAmbient()); + w.setSpawnLimit(SpawnCategory.AMBIENT, getSettings().getSpawnLimitAmbient()); } if (getSettings().getSpawnLimitAnimals() > 0) { - w.setAnimalSpawnLimit(getSettings().getSpawnLimitAnimals()); + w.setSpawnLimit(SpawnCategory.ANIMAL, getSettings().getSpawnLimitAnimals()); } if (getSettings().getSpawnLimitWaterAnimals() > 0) { - w.setWaterAnimalSpawnLimit(getSettings().getSpawnLimitWaterAnimals()); + w.setSpawnLimit(SpawnCategory.WATER_ANIMAL, getSettings().getSpawnLimitWaterAnimals()); } if (getSettings().getTicksPerAnimalSpawns() > 0) { - w.setTicksPerAnimalSpawns(getSettings().getTicksPerAnimalSpawns()); + w.setTicksPerSpawns(SpawnCategory.ANIMAL, getSettings().getTicksPerAnimalSpawns()); } if (getSettings().getTicksPerMonsterSpawns() > 0) { - w.setTicksPerMonsterSpawns(getSettings().getTicksPerMonsterSpawns()); + w.setTicksPerSpawns(SpawnCategory.MONSTER, getSettings().getTicksPerMonsterSpawns()); } } return w; @@ -201,4 +207,8 @@ public class AcidIsland extends GameModeAddon { // Save settings. This will occur after all addons have loaded this.saveWorldSettings(); } + + public BiomeProvider getBiomeProvider() { + return this.biomeProvider; + } } diff --git a/src/main/java/world/bentobox/acidisland/listeners/AcidEffect.java b/src/main/java/world/bentobox/acidisland/listeners/AcidEffect.java index 7bdd39a..4d61814 100644 --- a/src/main/java/world/bentobox/acidisland/listeners/AcidEffect.java +++ b/src/main/java/world/bentobox/acidisland/listeners/AcidEffect.java @@ -93,7 +93,7 @@ public class AcidEffect implements Listener { public void onSeaBounce(PlayerMoveEvent e) { Player player = e.getPlayer(); if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR) - && player.getWorld().equals(addon.getOverWorld()) && player.getLocation().getBlockY() < 1) { + && player.getWorld().equals(addon.getOverWorld()) && player.getLocation().getBlockY() < player.getWorld().getMinHeight()) { player.setVelocity(new Vector(player.getVelocity().getX(), 1D, player.getVelocity().getZ())); } } @@ -326,7 +326,7 @@ public class AcidEffect implements Listener { if (im instanceof Damageable d) { d.setDamage(d.getDamage() + 1); - item.setItemMeta((ItemMeta) d); + item.setItemMeta(d); return d.getDamage() >= item.getType().getMaxDurability(); } return false; diff --git a/src/main/java/world/bentobox/acidisland/world/AcidBiomeProvider.java b/src/main/java/world/bentobox/acidisland/world/AcidBiomeProvider.java new file mode 100644 index 0000000..b5decd7 --- /dev/null +++ b/src/main/java/world/bentobox/acidisland/world/AcidBiomeProvider.java @@ -0,0 +1,41 @@ +package world.bentobox.acidisland.world; + +import java.util.List; + +import org.bukkit.block.Biome; +import org.bukkit.generator.BiomeProvider; +import org.bukkit.generator.WorldInfo; + +import world.bentobox.acidisland.AcidIsland; + +/** + * Biome provider for AcidIsland + * @author tastybento + * + */ +public class AcidBiomeProvider extends BiomeProvider { + + private final AcidIsland addon; + + /** + * @param addon Addon + */ + public AcidBiomeProvider(AcidIsland addon) { + this.addon = addon; + } + + @Override + public Biome getBiome(WorldInfo worldInfo, int x, int y, int z) { + return switch(worldInfo.getEnvironment()) { + case NETHER -> addon.getSettings().getDefaultNetherBiome(); + case THE_END -> addon.getSettings().getDefaultEndBiome(); + default -> addon.getSettings().getDefaultBiome(); + }; + } + + @Override + public List getBiomes(WorldInfo worldInfo) { + return List.of(this.getBiome(worldInfo, 0, 0, 0)); + } + +} diff --git a/src/main/java/world/bentobox/acidisland/world/ChunkGeneratorWorld.java b/src/main/java/world/bentobox/acidisland/world/ChunkGeneratorWorld.java index 620b991..4751f92 100644 --- a/src/main/java/world/bentobox/acidisland/world/ChunkGeneratorWorld.java +++ b/src/main/java/world/bentobox/acidisland/world/ChunkGeneratorWorld.java @@ -10,11 +10,13 @@ import java.util.Random; import org.bukkit.Material; import org.bukkit.World; import org.bukkit.World.Environment; -import org.bukkit.block.Biome; +import org.bukkit.generator.BiomeProvider; import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; +import org.bukkit.generator.WorldInfo; import org.bukkit.util.Vector; import org.bukkit.util.noise.PerlinOctaveGenerator; +import org.eclipse.jdt.annotation.NonNull; import world.bentobox.acidisland.AcidIsland; @@ -29,7 +31,8 @@ public class ChunkGeneratorWorld extends ChunkGenerator { private final Random rand = new Random(); private final Map seaHeight = new EnumMap<>(Environment.class); private final Map roofChunk = new HashMap<>(); - + private PerlinOctaveGenerator gen; + private record WorldConfig(int seaHeight, Material waterBlock) {} /** @@ -41,38 +44,66 @@ public class ChunkGeneratorWorld extends ChunkGenerator { seaHeight.put(Environment.NORMAL, new WorldConfig(addon.getSettings().getSeaHeight(), addon.getSettings().getWaterBlock())); seaHeight.put(Environment.NETHER, new WorldConfig(addon.getSettings().getNetherSeaHeight(), addon.getSettings().getNetherWaterBlock())); seaHeight.put(Environment.THE_END, new WorldConfig(addon.getSettings().getEndSeaHeight(), addon.getSettings().getEndWaterBlock())); + rand.setSeed(System.currentTimeMillis()); + gen = new PerlinOctaveGenerator((long) (rand.nextLong() * rand.nextGaussian()), 8); + gen.setScale(1.0/30.0); makeNetherRoof(); } - public ChunkData generateChunks(World world) { - ChunkData result = createChunkData(world); - WorldConfig wc = seaHeight.get(world.getEnvironment()); + @Override + public void generateNoise(@NonNull WorldInfo worldInfo, @NonNull Random random, int chunkX, int chunkZ, @NonNull ChunkData chunkData) { + WorldConfig wc = seaHeight.get(worldInfo.getEnvironment()); int sh = wc.seaHeight(); - if (sh > world.getMinHeight()) { - result.setRegion(0, world.getMinHeight(), 0, 16, sh + 1, 16, wc.waterBlock()); + if (sh > worldInfo.getMinHeight()) { + chunkData.setRegion(0, worldInfo.getMinHeight(), 0, 16, worldInfo.getMinHeight() + 1, 16, Material.BEDROCK); + chunkData.setRegion(0, worldInfo.getMinHeight() + 1, 0, 16, sh + 1, 16, wc.waterBlock()); + // Add some noise + addNoise(worldInfo, chunkX, chunkZ, chunkData); } - if (world.getEnvironment().equals(Environment.NETHER) && addon.getSettings().isNetherRoof()) { - roofChunk.forEach((k,v) -> result.setBlock(k.getBlockX(), world.getMaxHeight() + k.getBlockY(), k.getBlockZ(), v)); + if (worldInfo.getEnvironment().equals(Environment.NETHER) && addon.getSettings().isNetherRoof()) { + roofChunk.forEach((k,v) -> chunkData.setBlock(k.getBlockX(), worldInfo.getMaxHeight() + k.getBlockY(), k.getBlockZ(), v)); + } + } + + private void addNoise(@NonNull WorldInfo worldInfo, int chunkX, int chunkZ, @NonNull ChunkData chunkData) { + for (int x = 0; x < 16; x++) { + for (int z = 0; z < 16; z++) { + int n = (int)(25 * gen.noise((chunkX << 4) + (double)x, (chunkZ << 4) + (double)z, 0.5, 0.5, true)); + for (int y = worldInfo.getMinHeight(); y < 25 + n; y++) { + chunkData.setBlock(x, y, z, rand.nextBoolean() ? Material.SAND : Material.SANDSTONE); + } + } } - return result; } @Override - public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biomeGrid) { - setBiome(world, biomeGrid); - return generateChunks(world); + public boolean shouldGenerateNoise() { + return false; + } + @Override + public boolean shouldGenerateSurface() { + return true; + } + @Override + public boolean shouldGenerateCaves() { + return true; + } + @Override + public boolean shouldGenerateDecorations() { + return true; + } + @Override + public boolean shouldGenerateMobs() { + return true; + } + @Override + public boolean shouldGenerateStructures() { + return true; } - private void setBiome(World world, BiomeGrid biomeGrid) { - Biome biome = world.getEnvironment() == Environment.NORMAL ? addon.getSettings().getDefaultBiome() : - world.getEnvironment() == Environment.NETHER ? addon.getSettings().getDefaultNetherBiome() : addon.getSettings().getDefaultEndBiome(); - for (int x = 0; x < 16; x+=4) { - for (int z = 0; z < 16; z+=4) { - for (int y = world.getMinHeight(); y < world.getMaxHeight(); y+=4) { - biomeGrid.setBiome(x, y, z, biome); - } - } - } + @Override + public BiomeProvider getDefaultBiomeProvider(WorldInfo worldInfo) { + return addon.getBiomeProvider(); } // This needs to be set to return true to override minecraft's default @@ -91,8 +122,6 @@ public class ChunkGeneratorWorld extends ChunkGenerator { * Nether Section */ private void makeNetherRoof() { - rand.setSeed(System.currentTimeMillis()); - PerlinOctaveGenerator gen = new PerlinOctaveGenerator((long) (rand.nextLong() * rand.nextGaussian()), 8); // Make the roof - common across the world for (int x = 0; x < 16; x++) { @@ -161,4 +190,5 @@ public class ChunkGeneratorWorld extends ChunkGenerator { private void setBlock(int x, int y, int z, Material m) { roofChunk.put(new Vector(x, y, z), m); } + } diff --git a/src/main/resources/addon.yml b/src/main/resources/addon.yml index 54d64da..1dff67e 100755 --- a/src/main/resources/addon.yml +++ b/src/main/resources/addon.yml @@ -1,7 +1,7 @@ name: AcidIsland main: world.bentobox.acidisland.AcidIsland version: ${version}${build.number} -api-version: 1.19 +api-version: 1.22 metrics: true repository: "BentoBoxWorld/AcidIsland" icon: "OAK_BOAT" diff --git a/src/main/resources/locales/ru.yml b/src/main/resources/locales/ru.yml new file mode 100644 index 0000000..21d88dc --- /dev/null +++ b/src/main/resources/locales/ru.yml @@ -0,0 +1,7 @@ +--- +acidisland: + sign: + line0: "&1AcidIsland" + line1: "[name]" + line2: Выживание в море! + line3: Удачной игры! &c<3 diff --git a/src/test/java/world/bentobox/acidisland/AISettingsTest.java b/src/test/java/world/bentobox/acidisland/AISettingsTest.java index a5c3032..815599c 100644 --- a/src/test/java/world/bentobox/acidisland/AISettingsTest.java +++ b/src/test/java/world/bentobox/acidisland/AISettingsTest.java @@ -140,22 +140,6 @@ public class AISettingsTest { assertEquals(GameMode.SURVIVAL, s.getDefaultGameMode()); } - /** - * Test method for {@link world.bentobox.acidisland.AISettings#getDefaultIslandFlags()}. - */ - @Test - public void testGetDefaultIslandFlags() { - assertTrue(s.getDefaultIslandFlags().isEmpty()); - } - - /** - * Test method for {@link world.bentobox.acidisland.AISettings#getDefaultIslandSettings()}. - */ - @Test - public void testGetDefaultIslandSettings() { - assertTrue(s.getDefaultIslandSettings().isEmpty()); - } - /** * Test method for {@link world.bentobox.acidisland.AISettings#getDifficulty()}. */ diff --git a/src/test/java/world/bentobox/acidisland/listeners/AcidEffectTest.java b/src/test/java/world/bentobox/acidisland/listeners/AcidEffectTest.java index 99aab9d..c5cd966 100644 --- a/src/test/java/world/bentobox/acidisland/listeners/AcidEffectTest.java +++ b/src/test/java/world/bentobox/acidisland/listeners/AcidEffectTest.java @@ -138,7 +138,7 @@ public class AcidEffectTest { when(inv.getArmorContents()).thenReturn(armor); // Location - when(location.getBlockY()).thenReturn(0); + when(location.getBlockY()).thenReturn(-66); when(location.getWorld()).thenReturn(world); when(location.getBlock()).thenReturn(block); @@ -172,6 +172,7 @@ public class AcidEffectTest { when(world.hasStorm()).thenReturn(true); when(world.getBlockAt(anyInt(), anyInt(), anyInt())).thenReturn(airBlock); when(world.getMaxHeight()).thenReturn(5); + when(world.getMinHeight()).thenReturn(-65); when(world.getEnvironment()).thenReturn(Environment.NORMAL); // Plugin diff --git a/src/test/java/world/bentobox/acidisland/world/ChunkGeneratorWorldTest.java b/src/test/java/world/bentobox/acidisland/world/ChunkGeneratorWorldTest.java index d3c5d2c..fc7239f 100644 --- a/src/test/java/world/bentobox/acidisland/world/ChunkGeneratorWorldTest.java +++ b/src/test/java/world/bentobox/acidisland/world/ChunkGeneratorWorldTest.java @@ -1,26 +1,14 @@ package world.bentobox.acidisland.world; -import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.atLeast; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.never; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.util.Random; - import org.bukkit.Bukkit; -import org.bukkit.Material; import org.bukkit.Server; import org.bukkit.World; -import org.bukkit.generator.ChunkGenerator.BiomeGrid; import org.bukkit.generator.ChunkGenerator.ChunkData; -import org.junit.After; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -45,9 +33,6 @@ public class ChunkGeneratorWorldTest { private ChunkGeneratorWorld cg; @Mock private World world; - private final Random random = new Random(); - @Mock - private BiomeGrid biomeGrid; private AISettings settings; @Mock private ChunkData data; @@ -69,135 +54,6 @@ public class ChunkGeneratorWorldTest { when(addon.getSettings()).thenReturn(settings); } - - /** - * Test method for {@link world.bentobox.bskyblock.generators.ChunkGeneratorWorld#generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)}. - */ - @SuppressWarnings("deprecation") - @Test - public void testGenerateChunkDataWorldRandomIntIntBiomeGridOverworldNormal() { - // Instance - cg = new ChunkGeneratorWorld(addon); - ChunkData cd = cg.generateChunkData(world, random, 0 , 0 , biomeGrid); - assertEquals(data, cd); - // Verifications - // Default biome - verify(biomeGrid, times(1024)).setBiome(anyInt(), anyInt(), anyInt(), any()); - // Void - verify(cd).setRegion(0, 0, 0, 16, 55, 16, Material.WATER); - } - - /** - * Test method for {@link world.bentobox.bskyblock.generators.ChunkGeneratorWorld#generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)}. - */ - @SuppressWarnings("deprecation") - @Test - public void testGenerateChunkDataWorldRandomIntIntBiomeGridOverworldNormalVoid() { - settings.setSeaHeight(0); - // Instance - cg = new ChunkGeneratorWorld(addon); - ChunkData cd = cg.generateChunkData(world, random, 0 , 0 , biomeGrid); - assertEquals(data, cd); - // Verifications - // Default biome - verify(biomeGrid, times(1024)).setBiome(anyInt(), anyInt(), anyInt(), any()); - // Void - verify(cd, never()).setRegion(anyInt(), anyInt(),anyInt(),anyInt(),anyInt(),anyInt(), any(Material.class)); - } - - /** - * Test method for {@link world.bentobox.bskyblock.generators.ChunkGeneratorWorld#generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)}. - */ - @SuppressWarnings("deprecation") - @Test - public void testGenerateChunkDataWorldRandomIntIntBiomeGridOverworldVoidLava() { - settings.setSeaHeight(54); - settings.setWaterBlock(Material.LAVA); - cg = new ChunkGeneratorWorld(addon); - ChunkData cd = cg.generateChunkData(world, random, 0 , 0 , biomeGrid); - assertEquals(data, cd); - // Verifications - // Default biome - verify(biomeGrid, times(1024)).setBiome(anyInt(), anyInt(), anyInt(), any()); - // Void - verify(cd).setRegion(0, 0, 0, 16, 55, 16, Material.LAVA); - } - - /** - * Test method for {@link world.bentobox.bskyblock.generators.ChunkGeneratorWorld#generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)}. - */ - @SuppressWarnings("deprecation") - @Test - public void testGenerateChunkDataWorldRandomIntIntBiomeGridOverworldSea() { - // Set sea height - settings.setSeaHeight(10); - // new instance - cg = new ChunkGeneratorWorld(addon); - ChunkData cd = cg.generateChunkData(world, random, 0 , 0 , biomeGrid); - assertEquals(data, cd); - // Verifications - // Default biome - verify(biomeGrid, times(1024)).setBiome(anyInt(), anyInt(), anyInt(), any()); - // Water. Blocks = 16 x 16 x 11 because block 0 - verify(cd).setRegion(0, 0, 0, 16, 11, 16, Material.WATER); - } - - /** - * Test method for {@link world.bentobox.bskyblock.generators.ChunkGeneratorWorld#generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)}. - */ - @SuppressWarnings("deprecation") - @Test - public void testGenerateChunkDataWorldRandomIntIntBiomeGridEnd() { - settings.setEndSeaHeight(0); - // Instance - cg = new ChunkGeneratorWorld(addon); - when(world.getEnvironment()).thenReturn(World.Environment.THE_END); - ChunkData cd = cg.generateChunkData(world, random, 0 , 0 , biomeGrid); - assertEquals(data, cd); - // Verifications - // Set biome in end - verify(biomeGrid, times(1024)).setBiome(anyInt(), anyInt(), anyInt(), any()); - // Void - verify(cd, never()).setRegion(anyInt(), anyInt(),anyInt(),anyInt(),anyInt(),anyInt(), any(Material.class)); - } - - /** - * Test method for {@link world.bentobox.bskyblock.generators.ChunkGeneratorWorld#generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)}. - */ - @SuppressWarnings("deprecation") - @Test - public void testGenerateChunkDataWorldRandomIntIntBiomeGridNetherWithRoof() { - // Instance - cg = new ChunkGeneratorWorld(addon); - when(world.getEnvironment()).thenReturn(World.Environment.NETHER); - ChunkData cd = cg.generateChunkData(world, random, 0 , 0 , biomeGrid); - assertEquals(data, cd); - // Verifications - // Never set biome in nether - verify(biomeGrid, times(1024)).setBiome(anyInt(), anyInt(), anyInt(), any()); - // Nether roof - at least bedrock layer - verify(cd, atLeast(16 * 16)).setBlock(anyInt(), anyInt(), anyInt(), eq(Material.BEDROCK)); - } - - /** - * Test method for {@link world.bentobox.bskyblock.generators.ChunkGeneratorWorld#generateChunkData(org.bukkit.World, java.util.Random, int, int, org.bukkit.generator.ChunkGenerator.BiomeGrid)}. - */ - @SuppressWarnings("deprecation") - @Test - public void testGenerateChunkDataWorldRandomIntIntBiomeGridNetherNoRoof() { - settings.setNetherRoof(false); - // Instance - cg = new ChunkGeneratorWorld(addon); - when(world.getEnvironment()).thenReturn(World.Environment.NETHER); - ChunkData cd = cg.generateChunkData(world, random, 0 , 0 , biomeGrid); - assertEquals(data, cd); - // Verifications - // Never set biome in nether - verify(biomeGrid, times(1024)).setBiome(anyInt(), anyInt(), anyInt(), any()); - // Nether roof - at least bedrock layer - verify(cd, never()).setBlock(anyInt(), anyInt(), anyInt(), any(Material.class)); - } - /** * Test method for {@link world.bentobox.bskyblock.generators.ChunkGeneratorWorld#canSpawn(org.bukkit.World, int, int)}. */