mirror of
https://github.com/BentoBoxWorld/AcidIsland.git
synced 2025-02-21 14:52:10 +01:00
New version 1.17 (#133)
* Fix failing unit-tests (#129) * Version 1.15.2 (#118) * Add support for 1.16.5 * Fix failing unit-tests Co-authored-by: tastybento <tastybento@users.noreply.github.com> * Init next AcidIsland version * Translate ru.yml via GitLocalize (#130) Co-authored-by: DraimCiDo <danilaorlov4@gmail.com> * Fix play sound test * Update to latest JavaDoc maven plugin to fix issue * Update to latest BentoBox API * Version that has an ocen floor and uses new generator methods * Fix tests * Fix deprecated method calls * Try different github workfow to see if coverage works * Add ${argLine} to get jacoco coverage * Fix bugs and code smells. * Fix jacoco POM for code scanning --------- Co-authored-by: BONNe <bonne@bonne.id.lv> Co-authored-by: gitlocalize-app[bot] <55277160+gitlocalize-app[bot]@users.noreply.github.com> Co-authored-by: DraimCiDo <danilaorlov4@gmail.com>
This commit is contained in:
parent
4d55b4de5e
commit
4601c76250
14
.github/workflows/build.yml
vendored
14
.github/workflows/build.yml
vendored
@ -1,4 +1,4 @@
|
|||||||
name: Build
|
name: SonarCloud
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
@ -8,25 +8,25 @@ on:
|
|||||||
types: [opened, synchronize, reopened]
|
types: [opened, synchronize, reopened]
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build
|
name: Build and analyze
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
|
||||||
- name: Set up JDK 17
|
- name: Set up JDK 17
|
||||||
uses: actions/setup-java@v2
|
uses: actions/setup-java@v1
|
||||||
with:
|
with:
|
||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
java-version: '17'
|
java-version: 17
|
||||||
- name: Cache SonarCloud packages
|
- name: Cache SonarCloud packages
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ~/.sonar/cache
|
path: ~/.sonar/cache
|
||||||
key: ${{ runner.os }}-sonar
|
key: ${{ runner.os }}-sonar
|
||||||
restore-keys: ${{ runner.os }}-sonar
|
restore-keys: ${{ runner.os }}-sonar
|
||||||
- name: Cache Maven packages
|
- name: Cache Maven packages
|
||||||
uses: actions/cache@v2
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: ~/.m2
|
path: ~/.m2
|
||||||
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
|
||||||
@ -35,4 +35,4 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
|
||||||
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
|
||||||
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar
|
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=BentoBoxWorld_AcidIsland
|
24
pom.xml
24
pom.xml
@ -54,18 +54,18 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
<java.version>16</java.version>
|
<java.version>17</java.version>
|
||||||
<!-- Non-minecraft related dependencies -->
|
<!-- Non-minecraft related dependencies -->
|
||||||
<powermock.version>2.0.9</powermock.version>
|
<powermock.version>2.0.9</powermock.version>
|
||||||
<!-- More visible way how to change dependency versions -->
|
<!-- More visible way how to change dependency versions -->
|
||||||
<spigot.version>1.19-R0.1-SNAPSHOT</spigot.version>
|
<spigot.version>1.19.3-R0.1-SNAPSHOT</spigot.version>
|
||||||
<bentobox.version>1.21.0</bentobox.version>
|
<bentobox.version>1.22.0-SNAPSHOT</bentobox.version>
|
||||||
<!-- Revision variable removes warning about dynamic version -->
|
<!-- Revision variable removes warning about dynamic version -->
|
||||||
<revision>${build.version}-SNAPSHOT</revision>
|
<revision>${build.version}-SNAPSHOT</revision>
|
||||||
<!-- Do not change unless you want different name for local builds. -->
|
<!-- Do not change unless you want different name for local builds. -->
|
||||||
<build.number>-LOCAL</build.number>
|
<build.number>-LOCAL</build.number>
|
||||||
<!-- This allows to change between versions. -->
|
<!-- This allows to change between versions. -->
|
||||||
<build.version>1.16.0</build.version>
|
<build.version>1.17.0</build.version>
|
||||||
<!-- Sonar Cloud -->
|
<!-- Sonar Cloud -->
|
||||||
<sonar.projectKey>BentoBoxWorld_AcidIsland</sonar.projectKey>
|
<sonar.projectKey>BentoBoxWorld_AcidIsland</sonar.projectKey>
|
||||||
<sonar.organization>bentobox-world</sonar.organization>
|
<sonar.organization>bentobox-world</sonar.organization>
|
||||||
@ -250,6 +250,7 @@
|
|||||||
<version>3.0.0-M5</version>
|
<version>3.0.0-M5</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<argLine>
|
<argLine>
|
||||||
|
${argLine}
|
||||||
--add-opens java.base/java.lang=ALL-UNNAMED
|
--add-opens java.base/java.lang=ALL-UNNAMED
|
||||||
--add-opens java.base/java.math=ALL-UNNAMED
|
--add-opens java.base/java.math=ALL-UNNAMED
|
||||||
--add-opens java.base/java.io=ALL-UNNAMED
|
--add-opens java.base/java.io=ALL-UNNAMED
|
||||||
@ -289,9 +290,9 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-javadoc-plugin</artifactId>
|
<artifactId>maven-javadoc-plugin</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>3.4.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>16</source>
|
<source>17</source>
|
||||||
<show>public</show>
|
<show>public</show>
|
||||||
<failOnError>false</failOnError>
|
<failOnError>false</failOnError>
|
||||||
<additionalJOption>-Xdoclint:none</additionalJOption>
|
<additionalJOption>-Xdoclint:none</additionalJOption>
|
||||||
@ -340,7 +341,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.jacoco</groupId>
|
<groupId>org.jacoco</groupId>
|
||||||
<artifactId>jacoco-maven-plugin</artifactId>
|
<artifactId>jacoco-maven-plugin</artifactId>
|
||||||
<version>0.8.3</version>
|
<version>0.8.7</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<append>true</append>
|
<append>true</append>
|
||||||
<excludes>
|
<excludes>
|
||||||
@ -351,16 +352,21 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>pre-unit-test</id>
|
<id>prepare-agent</id>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>prepare-agent</goal>
|
<goal>prepare-agent</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
<execution>
|
<execution>
|
||||||
<id>post-unit-test</id>
|
<id>report</id>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>report</goal>
|
<goal>report</goal>
|
||||||
</goals>
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<formats>
|
||||||
|
<format>XML</format>
|
||||||
|
</formats>
|
||||||
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -7,6 +7,8 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.WorldCreator;
|
import org.bukkit.WorldCreator;
|
||||||
import org.bukkit.WorldType;
|
import org.bukkit.WorldType;
|
||||||
|
import org.bukkit.entity.SpawnCategory;
|
||||||
|
import org.bukkit.generator.BiomeProvider;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
import org.eclipse.jdt.annotation.NonNull;
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
import org.eclipse.jdt.annotation.Nullable;
|
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.commands.IslandAboutCommand;
|
||||||
import world.bentobox.acidisland.listeners.AcidEffect;
|
import world.bentobox.acidisland.listeners.AcidEffect;
|
||||||
import world.bentobox.acidisland.listeners.LavaCheck;
|
import world.bentobox.acidisland.listeners.LavaCheck;
|
||||||
|
import world.bentobox.acidisland.world.AcidBiomeProvider;
|
||||||
import world.bentobox.acidisland.world.AcidTask;
|
import world.bentobox.acidisland.world.AcidTask;
|
||||||
import world.bentobox.acidisland.world.ChunkGeneratorWorld;
|
import world.bentobox.acidisland.world.ChunkGeneratorWorld;
|
||||||
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
import world.bentobox.bentobox.api.addons.GameModeAddon;
|
||||||
@ -34,6 +37,7 @@ public class AcidIsland extends GameModeAddon {
|
|||||||
private @Nullable AcidTask acidTask;
|
private @Nullable AcidTask acidTask;
|
||||||
private @Nullable ChunkGenerator chunkGenerator;
|
private @Nullable ChunkGenerator chunkGenerator;
|
||||||
private final Config<AISettings> config = new Config<>(this, AISettings.class);
|
private final Config<AISettings> config = new Config<>(this, AISettings.class);
|
||||||
|
private BiomeProvider biomeProvider;
|
||||||
|
|
||||||
private static final String NETHER = "_nether";
|
private static final String NETHER = "_nether";
|
||||||
private static final String THE_END = "_the_end";
|
private static final String THE_END = "_the_end";
|
||||||
@ -44,10 +48,11 @@ public class AcidIsland extends GameModeAddon {
|
|||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
// Load settings from config.yml. This will check if there are any issues with it too.
|
// Load settings from config.yml. This will check if there are any issues with it too.
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
// Make the biome provider
|
||||||
|
this.biomeProvider = new AcidBiomeProvider(this);
|
||||||
// Chunk generator
|
// Chunk generator
|
||||||
chunkGenerator = settings.isUseOwnGenerator() ? null : new ChunkGeneratorWorld(this);
|
chunkGenerator = settings.isUseOwnGenerator() ? null : new ChunkGeneratorWorld(this);
|
||||||
// Register commands
|
// Register commands
|
||||||
// Register commands
|
|
||||||
playerCommand = new DefaultPlayerCommand(this)
|
playerCommand = new DefaultPlayerCommand(this)
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -72,6 +77,7 @@ public class AcidIsland extends GameModeAddon {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,22 +153,22 @@ public class AcidIsland extends GameModeAddon {
|
|||||||
// Set spawn rates
|
// Set spawn rates
|
||||||
if (w != null && getSettings() != null) {
|
if (w != null && getSettings() != null) {
|
||||||
if (getSettings().getSpawnLimitMonsters() > 0) {
|
if (getSettings().getSpawnLimitMonsters() > 0) {
|
||||||
w.setMonsterSpawnLimit(getSettings().getSpawnLimitMonsters());
|
w.setSpawnLimit(SpawnCategory.MONSTER, getSettings().getSpawnLimitMonsters());
|
||||||
}
|
}
|
||||||
if (getSettings().getSpawnLimitAmbient() > 0) {
|
if (getSettings().getSpawnLimitAmbient() > 0) {
|
||||||
w.setAmbientSpawnLimit(getSettings().getSpawnLimitAmbient());
|
w.setSpawnLimit(SpawnCategory.AMBIENT, getSettings().getSpawnLimitAmbient());
|
||||||
}
|
}
|
||||||
if (getSettings().getSpawnLimitAnimals() > 0) {
|
if (getSettings().getSpawnLimitAnimals() > 0) {
|
||||||
w.setAnimalSpawnLimit(getSettings().getSpawnLimitAnimals());
|
w.setSpawnLimit(SpawnCategory.ANIMAL, getSettings().getSpawnLimitAnimals());
|
||||||
}
|
}
|
||||||
if (getSettings().getSpawnLimitWaterAnimals() > 0) {
|
if (getSettings().getSpawnLimitWaterAnimals() > 0) {
|
||||||
w.setWaterAnimalSpawnLimit(getSettings().getSpawnLimitWaterAnimals());
|
w.setSpawnLimit(SpawnCategory.WATER_ANIMAL, getSettings().getSpawnLimitWaterAnimals());
|
||||||
}
|
}
|
||||||
if (getSettings().getTicksPerAnimalSpawns() > 0) {
|
if (getSettings().getTicksPerAnimalSpawns() > 0) {
|
||||||
w.setTicksPerAnimalSpawns(getSettings().getTicksPerAnimalSpawns());
|
w.setTicksPerSpawns(SpawnCategory.ANIMAL, getSettings().getTicksPerAnimalSpawns());
|
||||||
}
|
}
|
||||||
if (getSettings().getTicksPerMonsterSpawns() > 0) {
|
if (getSettings().getTicksPerMonsterSpawns() > 0) {
|
||||||
w.setTicksPerMonsterSpawns(getSettings().getTicksPerMonsterSpawns());
|
w.setTicksPerSpawns(SpawnCategory.MONSTER, getSettings().getTicksPerMonsterSpawns());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return w;
|
return w;
|
||||||
@ -201,4 +207,8 @@ public class AcidIsland extends GameModeAddon {
|
|||||||
// Save settings. This will occur after all addons have loaded
|
// Save settings. This will occur after all addons have loaded
|
||||||
this.saveWorldSettings();
|
this.saveWorldSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BiomeProvider getBiomeProvider() {
|
||||||
|
return this.biomeProvider;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ public class AcidEffect implements Listener {
|
|||||||
public void onSeaBounce(PlayerMoveEvent e) {
|
public void onSeaBounce(PlayerMoveEvent e) {
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
if (!player.getGameMode().equals(GameMode.CREATIVE) && !player.getGameMode().equals(GameMode.SPECTATOR)
|
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()));
|
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) {
|
if (im instanceof Damageable d) {
|
||||||
d.setDamage(d.getDamage() + 1);
|
d.setDamage(d.getDamage() + 1);
|
||||||
item.setItemMeta((ItemMeta) d);
|
item.setItemMeta(d);
|
||||||
return d.getDamage() >= item.getType().getMaxDurability();
|
return d.getDamage() >= item.getType().getMaxDurability();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -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<Biome> getBiomes(WorldInfo worldInfo) {
|
||||||
|
return List.of(this.getBiome(worldInfo, 0, 0, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -10,11 +10,13 @@ import java.util.Random;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.generator.BiomeProvider;
|
||||||
import org.bukkit.generator.BlockPopulator;
|
import org.bukkit.generator.BlockPopulator;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
|
import org.bukkit.generator.WorldInfo;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
import org.bukkit.util.noise.PerlinOctaveGenerator;
|
import org.bukkit.util.noise.PerlinOctaveGenerator;
|
||||||
|
import org.eclipse.jdt.annotation.NonNull;
|
||||||
|
|
||||||
import world.bentobox.acidisland.AcidIsland;
|
import world.bentobox.acidisland.AcidIsland;
|
||||||
|
|
||||||
@ -29,6 +31,7 @@ public class ChunkGeneratorWorld extends ChunkGenerator {
|
|||||||
private final Random rand = new Random();
|
private final Random rand = new Random();
|
||||||
private final Map<Environment, WorldConfig> seaHeight = new EnumMap<>(Environment.class);
|
private final Map<Environment, WorldConfig> seaHeight = new EnumMap<>(Environment.class);
|
||||||
private final Map<Vector, Material> roofChunk = new HashMap<>();
|
private final Map<Vector, Material> roofChunk = new HashMap<>();
|
||||||
|
private PerlinOctaveGenerator gen;
|
||||||
|
|
||||||
private record WorldConfig(int seaHeight, Material waterBlock) {}
|
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.NORMAL, new WorldConfig(addon.getSettings().getSeaHeight(), addon.getSettings().getWaterBlock()));
|
||||||
seaHeight.put(Environment.NETHER, new WorldConfig(addon.getSettings().getNetherSeaHeight(), addon.getSettings().getNetherWaterBlock()));
|
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()));
|
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();
|
makeNetherRoof();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkData generateChunks(World world) {
|
@Override
|
||||||
ChunkData result = createChunkData(world);
|
public void generateNoise(@NonNull WorldInfo worldInfo, @NonNull Random random, int chunkX, int chunkZ, @NonNull ChunkData chunkData) {
|
||||||
WorldConfig wc = seaHeight.get(world.getEnvironment());
|
WorldConfig wc = seaHeight.get(worldInfo.getEnvironment());
|
||||||
int sh = wc.seaHeight();
|
int sh = wc.seaHeight();
|
||||||
if (sh > world.getMinHeight()) {
|
if (sh > worldInfo.getMinHeight()) {
|
||||||
result.setRegion(0, world.getMinHeight(), 0, 16, sh + 1, 16, wc.waterBlock());
|
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()) {
|
if (worldInfo.getEnvironment().equals(Environment.NETHER) && addon.getSettings().isNetherRoof()) {
|
||||||
roofChunk.forEach((k,v) -> result.setBlock(k.getBlockX(), world.getMaxHeight() + k.getBlockY(), k.getBlockZ(), v));
|
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
|
@Override
|
||||||
public ChunkData generateChunkData(World world, Random random, int chunkX, int chunkZ, BiomeGrid biomeGrid) {
|
public boolean shouldGenerateNoise() {
|
||||||
setBiome(world, biomeGrid);
|
return false;
|
||||||
return generateChunks(world);
|
}
|
||||||
|
@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) {
|
@Override
|
||||||
Biome biome = world.getEnvironment() == Environment.NORMAL ? addon.getSettings().getDefaultBiome() :
|
public BiomeProvider getDefaultBiomeProvider(WorldInfo worldInfo) {
|
||||||
world.getEnvironment() == Environment.NETHER ? addon.getSettings().getDefaultNetherBiome() : addon.getSettings().getDefaultEndBiome();
|
return addon.getBiomeProvider();
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This needs to be set to return true to override minecraft's default
|
// This needs to be set to return true to override minecraft's default
|
||||||
@ -91,8 +122,6 @@ public class ChunkGeneratorWorld extends ChunkGenerator {
|
|||||||
* Nether Section
|
* Nether Section
|
||||||
*/
|
*/
|
||||||
private void makeNetherRoof() {
|
private void makeNetherRoof() {
|
||||||
rand.setSeed(System.currentTimeMillis());
|
|
||||||
PerlinOctaveGenerator gen = new PerlinOctaveGenerator((long) (rand.nextLong() * rand.nextGaussian()), 8);
|
|
||||||
|
|
||||||
// Make the roof - common across the world
|
// Make the roof - common across the world
|
||||||
for (int x = 0; x < 16; x++) {
|
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) {
|
private void setBlock(int x, int y, int z, Material m) {
|
||||||
roofChunk.put(new Vector(x, y, z), m);
|
roofChunk.put(new Vector(x, y, z), m);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: AcidIsland
|
name: AcidIsland
|
||||||
main: world.bentobox.acidisland.AcidIsland
|
main: world.bentobox.acidisland.AcidIsland
|
||||||
version: ${version}${build.number}
|
version: ${version}${build.number}
|
||||||
api-version: 1.19
|
api-version: 1.22
|
||||||
metrics: true
|
metrics: true
|
||||||
repository: "BentoBoxWorld/AcidIsland"
|
repository: "BentoBoxWorld/AcidIsland"
|
||||||
icon: "OAK_BOAT"
|
icon: "OAK_BOAT"
|
||||||
|
7
src/main/resources/locales/ru.yml
Normal file
7
src/main/resources/locales/ru.yml
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
---
|
||||||
|
acidisland:
|
||||||
|
sign:
|
||||||
|
line0: "&1AcidIsland"
|
||||||
|
line1: "[name]"
|
||||||
|
line2: Выживание в море!
|
||||||
|
line3: Удачной игры! &c<3
|
@ -140,22 +140,6 @@ public class AISettingsTest {
|
|||||||
assertEquals(GameMode.SURVIVAL, s.getDefaultGameMode());
|
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()}.
|
* Test method for {@link world.bentobox.acidisland.AISettings#getDifficulty()}.
|
||||||
*/
|
*/
|
||||||
|
@ -138,7 +138,7 @@ public class AcidEffectTest {
|
|||||||
when(inv.getArmorContents()).thenReturn(armor);
|
when(inv.getArmorContents()).thenReturn(armor);
|
||||||
|
|
||||||
// Location
|
// Location
|
||||||
when(location.getBlockY()).thenReturn(0);
|
when(location.getBlockY()).thenReturn(-66);
|
||||||
when(location.getWorld()).thenReturn(world);
|
when(location.getWorld()).thenReturn(world);
|
||||||
when(location.getBlock()).thenReturn(block);
|
when(location.getBlock()).thenReturn(block);
|
||||||
|
|
||||||
@ -172,6 +172,7 @@ public class AcidEffectTest {
|
|||||||
when(world.hasStorm()).thenReturn(true);
|
when(world.hasStorm()).thenReturn(true);
|
||||||
when(world.getBlockAt(anyInt(), anyInt(), anyInt())).thenReturn(airBlock);
|
when(world.getBlockAt(anyInt(), anyInt(), anyInt())).thenReturn(airBlock);
|
||||||
when(world.getMaxHeight()).thenReturn(5);
|
when(world.getMaxHeight()).thenReturn(5);
|
||||||
|
when(world.getMinHeight()).thenReturn(-65);
|
||||||
when(world.getEnvironment()).thenReturn(Environment.NORMAL);
|
when(world.getEnvironment()).thenReturn(Environment.NORMAL);
|
||||||
|
|
||||||
// Plugin
|
// Plugin
|
||||||
|
@ -1,26 +1,14 @@
|
|||||||
package world.bentobox.acidisland.world;
|
package world.bentobox.acidisland.world;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
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.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 static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
|
||||||
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||||
import org.junit.After;
|
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
@ -45,9 +33,6 @@ public class ChunkGeneratorWorldTest {
|
|||||||
private ChunkGeneratorWorld cg;
|
private ChunkGeneratorWorld cg;
|
||||||
@Mock
|
@Mock
|
||||||
private World world;
|
private World world;
|
||||||
private final Random random = new Random();
|
|
||||||
@Mock
|
|
||||||
private BiomeGrid biomeGrid;
|
|
||||||
private AISettings settings;
|
private AISettings settings;
|
||||||
@Mock
|
@Mock
|
||||||
private ChunkData data;
|
private ChunkData data;
|
||||||
@ -69,135 +54,6 @@ public class ChunkGeneratorWorldTest {
|
|||||||
when(addon.getSettings()).thenReturn(settings);
|
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)}.
|
* Test method for {@link world.bentobox.bskyblock.generators.ChunkGeneratorWorld#canSpawn(org.bukkit.World, int, int)}.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user