Merge branch 'develop' of

https://github.com/BentoBoxWorld/AcidIsland.git into develop
This commit is contained in:
tastybento 2023-01-01 09:08:48 -08:00
commit 7aa5dc6187
12 changed files with 178 additions and 93 deletions

View File

@ -14,11 +14,11 @@ jobs:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 16
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '16'
java-version: '17'
- name: Cache SonarCloud packages
uses: actions/cache@v2
with:

View File

@ -65,7 +65,7 @@
<!-- Do not change unless you want different name for local builds. -->
<build.number>-LOCAL</build.number>
<!-- This allows to change between versions. -->
<build.version>1.16.0</build.version>
<build.version>1.17.0</build.version>
<!-- Sonar Cloud -->
<sonar.projectKey>BentoBoxWorld_AcidIsland</sonar.projectKey>
<sonar.organization>bentobox-world</sonar.organization>
@ -366,4 +366,4 @@
</plugin>
</plugins>
</build>
</project>
</project>

View File

@ -1,14 +1,10 @@
package world.bentobox.acidisland;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.entity.EntityType;
import org.bukkit.potion.PotionEffectType;
@ -20,10 +16,8 @@ import world.bentobox.bentobox.api.configuration.ConfigEntry;
import world.bentobox.bentobox.api.configuration.StoreAt;
import world.bentobox.bentobox.api.configuration.WorldSettings;
import world.bentobox.bentobox.api.flags.Flag;
import world.bentobox.bentobox.database.objects.adapters.Adapter;
import world.bentobox.bentobox.database.objects.adapters.FlagSerializer;
import world.bentobox.bentobox.database.objects.adapters.FlagSerializer2;
import world.bentobox.bentobox.database.objects.adapters.PotionEffectListAdapter;
import world.bentobox.bentobox.database.objects.adapters.*;
/**
* Settings for AcidIsland
@ -206,7 +200,7 @@ public class AISettings implements WorldSettings {
@ConfigComment("It is the y coordinate of the bedrock block in the schem.")
@ConfigEntry(path = "world.island-height")
private int islandHeight = 50;
@ConfigComment("Use your own world generator for this world.")
@ConfigComment("In this case, the plugin will not generate anything.")
@ConfigEntry(path = "world.use-own-generator", experimental = true)
@ -216,6 +210,10 @@ public class AISettings implements WorldSettings {
@ConfigComment("Minimum is 0, which means you are playing Skyblock!")
@ConfigEntry(path = "world.sea-height")
private int seaHeight = 54;
@ConfigComment("Water block. This should usually stay as WATER, but may be LAVA for fun")
@ConfigEntry(path = "world.water-block", needsReset = true)
private Material waterBlock = Material.WATER;
@ConfigComment("Maximum number of islands in the world. Set to -1 or 0 for unlimited. ")
@ConfigComment("If the number of islands is greater than this number, no new island will be created.")
@ -260,6 +258,10 @@ public class AISettings implements WorldSettings {
@ConfigComment("Changing mid-game will cause problems!")
@ConfigEntry(path = "world.nether.sea-height", needsReset = true)
private int netherSeaHeight = 54;
@ConfigComment("Water block. This should usually stay as WATER, but may be LAVA for fun")
@ConfigEntry(path = "world.nether.water-block", needsReset = true)
private Material netherWaterBlock = Material.WATER;
@ConfigComment("Make the nether roof, if false, there is nothing up there")
@ConfigComment("Change to false if lag is a problem from the generation")
@ -294,6 +296,10 @@ public class AISettings implements WorldSettings {
@ConfigComment("Changing mid-game will cause problems!")
@ConfigEntry(path = "world.end.sea-height", needsReset = true)
private int endSeaHeight = 54;
@ConfigComment("Water block. This should usually stay as WATER, but may be LAVA for fun")
@ConfigEntry(path = "world.end.water-block", needsReset = true)
private Material endWaterBlock = Material.WATER;
@ConfigComment("This option indicates if obsidian platform in the end should be generated")
@ConfigComment("when player enters the end world.")
@ -318,13 +324,12 @@ public class AISettings implements WorldSettings {
@ConfigComment("The value is the minimum island rank required allowed to do the action")
@ConfigComment("Ranks are: Visitor = 0, Member = 900, Owner = 1000")
@ConfigEntry(path = "world.default-island-flags")
@Adapter(FlagSerializer.class)
private Map<Flag, Integer> defaultIslandFlags = new HashMap<>();
private Map<String, Integer> defaultIslandFlagNames = new HashMap<>();
@ConfigComment("These are the default settings for new islands")
@ConfigEntry(path = "world.default-island-settings")
@Adapter(FlagSerializer2.class)
private Map<Flag, Integer> defaultIslandSettings = new HashMap<>();
@Adapter(FlagBooleanSerializer.class)
private Map<String, Integer> defaultIslandSettingNames = new HashMap<>();
@ConfigComment("These settings/flags are hidden from users")
@ConfigComment("Ops can toggle hiding in-game using SHIFT-LEFT-CLICK on flags in settings")
@ -673,20 +678,50 @@ public class AISettings implements WorldSettings {
public GameMode getDefaultGameMode() {
return defaultGameMode;
}
/**
* @return the defaultIslandFlags
* @since 1.21.0
*/
@Override
public Map<String, Integer> getDefaultIslandFlagNames()
{
return defaultIslandFlagNames;
}
/**
* @return the defaultIslandSettings
* @since 1.21.0
*/
@Override
public Map<String, Integer> getDefaultIslandSettingNames()
{
return defaultIslandSettingNames;
}
/**
* @return the defaultIslandProtection
* @deprecated since 1.21
*/
@Override
public Map<Flag, Integer> getDefaultIslandFlags() {
return defaultIslandFlags;
return Collections.emptyMap();
}
/**
* @return the defaultIslandSettings
* @deprecated since 1.21
*/
@Override
public Map<Flag, Integer> getDefaultIslandSettings() {
return defaultIslandSettings;
return Collections.emptyMap();
}
/**
* @return the difficulty
*/
@ -1190,14 +1225,14 @@ public class AISettings implements WorldSettings {
}
/**
*/
public void setDefaultIslandFlags(Map<Flag, Integer> defaultIslandFlags) {
this.defaultIslandFlags = defaultIslandFlags;
public void setDefaultIslandFlagNames(Map<String, Integer> defaultIslandFlags) {
this.defaultIslandFlagNames = defaultIslandFlags;
}
/**
* @param defaultIslandSettings the defaultIslandSettings to set
*/
public void setDefaultIslandSettings(Map<Flag, Integer> defaultIslandSettings) {
this.defaultIslandSettings = defaultIslandSettings;
public void setDefaultIslandSettingNames(Map<String, Integer> defaultIslandSettings) {
this.defaultIslandSettingNames = defaultIslandSettings;
}
/**
* @param difficulty the difficulty to set
@ -1960,4 +1995,22 @@ public class AISettings implements WorldSettings {
public void setMakeEndPortals(boolean makeEndPortals) {
this.makeEndPortals = makeEndPortals;
}
public Material getWaterBlock() {
return waterBlock;
}
public void setWaterBlock(Material waterBlock) {
this.waterBlock = waterBlock;
}
public Material getNetherWaterBlock() {
return netherWaterBlock;
}
public void setNetherWaterBlock(Material netherWaterBlock) {
this.netherWaterBlock = netherWaterBlock;
}
public Material getEndWaterBlock() {
return endWaterBlock;
}
public void setEndWaterBlock(Material endWaterBlock) {
this.endWaterBlock = endWaterBlock;
}
}

View File

@ -27,8 +27,10 @@ public class ChunkGeneratorWorld extends ChunkGenerator {
private final AcidIsland addon;
private final Random rand = new Random();
private final Map<Environment, Integer> seaHeight = new EnumMap<>(Environment.class);
private final Map<Environment, WorldConfig> seaHeight = new EnumMap<>(Environment.class);
private final Map<Vector, Material> roofChunk = new HashMap<>();
private record WorldConfig(int seaHeight, Material waterBlock) {}
/**
* @param addon - addon
@ -36,17 +38,18 @@ public class ChunkGeneratorWorld extends ChunkGenerator {
public ChunkGeneratorWorld(AcidIsland addon) {
super();
this.addon = addon;
seaHeight.put(Environment.NORMAL, addon.getSettings().getSeaHeight());
seaHeight.put(Environment.NETHER, addon.getSettings().getNetherSeaHeight());
seaHeight.put(Environment.THE_END, addon.getSettings().getEndSeaHeight());
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()));
makeNetherRoof();
}
public ChunkData generateChunks(World world) {
ChunkData result = createChunkData(world);
int sh = seaHeight.getOrDefault(world.getEnvironment(), 0);
if (sh > 0) {
result.setRegion(0, 0, 0, 16, sh + 1, 16, Material.WATER);
WorldConfig wc = seaHeight.get(world.getEnvironment());
int sh = wc.seaHeight();
if (sh > world.getMinHeight()) {
result.setRegion(0, world.getMinHeight(), 0, 16, sh + 1, 16, wc.waterBlock());
}
if (world.getEnvironment().equals(Environment.NETHER) && addon.getSettings().isNetherRoof()) {
roofChunk.forEach((k,v) -> result.setBlock(k.getBlockX(), world.getMaxHeight() + k.getBlockY(), k.getBlockZ(), v));
@ -65,7 +68,7 @@ public class ChunkGeneratorWorld extends ChunkGenerator {
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 = 0; y < world.getMaxHeight(); y+=4) {
for (int y = world.getMinHeight(); y < world.getMaxHeight(); y+=4) {
biomeGrid.setBiome(x, y, z, biome);
}
}
@ -158,4 +161,4 @@ public class ChunkGeneratorWorld extends ChunkGenerator {
private void setBlock(int x, int y, int z, Material m) {
roofChunk.put(new Vector(x, y, z), m);
}
}
}

View File

@ -1,7 +1,7 @@
name: AcidIsland
main: world.bentobox.acidisland.AcidIsland
version: ${version}${build.number}
api-version: 1.16.5
api-version: 1.19
metrics: true
repository: "BentoBoxWorld/AcidIsland"
icon: "OAK_BOAT"

View File

@ -132,6 +132,10 @@ world:
# Sea height (don't changes this mid-game unless you delete the world)
# Minimum is 0, which means you are playing Skyblock!
sea-height: 54
# Water block this should usually stay as WATER, but may be LAVA for fun
# Changing mid-game will cause problems!
# /!\ BentoBox currently does not support changing this value mid-game. If you do need to change it, do a full reset of your databases and worlds.
water-block: WATER
# Maximum number of islands in the world. Set to -1 or 0 for unlimited.
# If the number of islands is greater than this number, no new island will be created.
max-islands: 0
@ -162,6 +166,10 @@ world:
# Changing mid-game will cause problems!
# /!\ BentoBox currently does not support changing this value mid-game. If you do need to change it, do a full reset of your databases and worlds.
sea-height: 54
# Water block this should usually stay as WATER, but may be LAVA for fun
# Changing mid-game will cause problems!
# /!\ BentoBox currently does not support changing this value mid-game. If you do need to change it, do a full reset of your databases and worlds.
water-block: WATER
# Make the nether roof, if false, there is nothing up there
# Change to false if lag is a problem from the generation
# Only applies to islands Nether
@ -186,6 +194,10 @@ world:
# Changing mid-game will cause problems!
# /!\ BentoBox currently does not support changing this value mid-game. If you do need to change it, do a full reset of your databases and worlds.
sea-height: 54
# Water block this should usually stay as WATER, but may be LAVA for fun
# Changing mid-game will cause problems!
# /!\ BentoBox currently does not support changing this value mid-game. If you do need to change it, do a full reset of your databases and worlds.
water-block: WATER
# This option indicates if obsidian platform in the end should be generated when player enters the end world.
# Added since 1.14.6
create-obsidian-platform: false

View File

@ -0,0 +1,7 @@
---
acidisland:
sign:
line0: "&1AcidIsland"
line1: "[name]"
line2: Выживание в море!
line3: Удачной игры! &c<3

View File

@ -1,7 +1,7 @@
name: Pladdon
main: world.bentobox.acidisland.AcidIslandPladdon
version: ${version}
api-version: 1.16
api-version: 1.21
description: AcidIsland
author: tastybento
depend:

View File

@ -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()}.
*/
@ -778,21 +762,21 @@ public class AISettingsTest {
}
/**
* Test method for {@link world.bentobox.acidisland.AISettings#setDefaultIslandFlags(java.util.Map)}.
* Test method for {@link world.bentobox.acidisland.AISettings#setDefaultIslandFlagNames(java.util.Map)}.
*/
@Test
public void testSetDefaultIslandFlags() {
s.setDefaultIslandFlags(Collections.singletonMap(Flags.ANIMAL_NATURAL_SPAWN, 10));
assertEquals(10, (int)s.getDefaultIslandFlags().get(Flags.ANIMAL_NATURAL_SPAWN));
s.setDefaultIslandFlagNames(Collections.singletonMap(Flags.ANIMAL_NATURAL_SPAWN.getID(), 10));
assertEquals(10, (int)s.getDefaultIslandFlagNames().get(Flags.ANIMAL_NATURAL_SPAWN.getID()));
}
/**
* Test method for {@link world.bentobox.acidisland.AISettings#setDefaultIslandSettings(java.util.Map)}.
* Test method for {@link world.bentobox.acidisland.AISettings#setDefaultIslandSettingNames(java.util.Map)}.
*/
@Test
public void testSetDefaultIslandSettings() {
s.setDefaultIslandSettings(Collections.singletonMap(Flags.ANIMAL_NATURAL_SPAWN, 10));
assertEquals(10, (int)s.getDefaultIslandSettings().get(Flags.ANIMAL_NATURAL_SPAWN));
s.setDefaultIslandSettingNames(Collections.singletonMap(Flags.ANIMAL_NATURAL_SPAWN.getID(), 10));
assertEquals(10, (int)s.getDefaultIslandSettingNames().get(Flags.ANIMAL_NATURAL_SPAWN.getID()));
}

View File

@ -29,8 +29,8 @@ import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import world.bentobox.acidisland.AcidIsland;
import world.bentobox.acidisland.AISettings;
import world.bentobox.acidisland.AcidIsland;
/**
* @author tastybento
@ -48,7 +48,6 @@ public class ChunkGeneratorWorldTest {
private final Random random = new Random();
@Mock
private BiomeGrid biomeGrid;
@Mock
private AISettings settings;
@Mock
private ChunkData data;
@ -66,54 +65,79 @@ public class ChunkGeneratorWorldTest {
when(world.getEnvironment()).thenReturn(World.Environment.NORMAL);
when(world.getMaxHeight()).thenReturn(256);
// Settings
settings = new AISettings();
when(addon.getSettings()).thenReturn(settings);
when(settings.getSeaHeight()).thenReturn(0);
when(settings.isNetherRoof()).thenReturn(true);
// Instance
cg = new ChunkGeneratorWorld(addon);
}
/**
*/
@After
public void tearDown() {
}
/**
* 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 testGenerateChunkDataWorldRandomIntIntBiomeGridOverworldVoid() {
public void testGenerateChunkDataWorldRandomIntIntBiomeGridOverworldNormal() {
// Instance
cg = new ChunkGeneratorWorld(addon);
ChunkData cd = cg.generateChunkData(world, random, 0 , 0 , biomeGrid);
assertEquals(data, cd);
// Verifications
// Default biome
verify(settings).getDefaultBiome();
verify(biomeGrid, times(1024)).setBiome(anyInt(), anyInt(), anyInt(), any());
// Sea height
verify(settings).getSeaHeight();
// Void
verify(cd, never()).setRegion(anyInt(), anyInt(), anyInt(), anyInt(), anyInt(), anyInt(), any(Material.class));
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
when(settings.getSeaHeight()).thenReturn(10);
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(settings).getDefaultBiome();
verify(biomeGrid, times(1024)).setBiome(anyInt(), anyInt(), anyInt(), any());
// Sea height
verify(settings, times(2)).getSeaHeight();
// Water. Blocks = 16 x 16 x 11 because block 0
verify(cd).setRegion(0, 0, 0, 16, 11, 16, Material.WATER);
}
@ -121,35 +145,34 @@ public class ChunkGeneratorWorldTest {
/**
* 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
// Default biome
verify(settings).getDefaultEndBiome();
// Set biome in end
verify(biomeGrid, times(1024)).setBiome(anyInt(), anyInt(), anyInt(), any());
// Sea height
verify(settings).getSeaHeight();
// Void
verify(cd, never()).setRegion(anyInt(), anyInt(), anyInt(), anyInt(), anyInt(), anyInt(), any(Material.class));
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
// Default biome
verify(settings).getDefaultNetherBiome();
// Nether roof check
verify(settings).isNetherRoof();
// Never set biome in nether
verify(biomeGrid, times(1024)).setBiome(anyInt(), anyInt(), anyInt(), any());
// Nether roof - at least bedrock layer
@ -159,17 +182,16 @@ public class ChunkGeneratorWorldTest {
/**
* 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() {
when(settings.isNetherRoof()).thenReturn(false);
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
// Nether roof check
verify(settings).isNetherRoof();
// Nether roof check
verify(settings).isNetherRoof();
// Never set biome in nether
verify(biomeGrid, times(1024)).setBiome(anyInt(), anyInt(), anyInt(), any());
// Nether roof - at least bedrock layer
@ -181,6 +203,8 @@ public class ChunkGeneratorWorldTest {
*/
@Test
public void testCanSpawnWorldIntInt() {
// Instance
cg = new ChunkGeneratorWorld(addon);
assertTrue(cg.canSpawn(mock(World.class), 0, 1));
}
@ -189,6 +213,8 @@ public class ChunkGeneratorWorldTest {
*/
@Test
public void testGetDefaultPopulatorsWorld() {
// Instance
cg = new ChunkGeneratorWorld(addon);
assertTrue(cg.getDefaultPopulators(mock(World.class)).isEmpty());
}