Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MC 1.21.3 update #533

Merged
merged 4 commits into from
Nov 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,9 @@

<distributionManagement>
<snapshotRepository>
<id>codemc-snapshots</id>
<url>https://repo.codemc.org/repository/maven-snapshots</url>
<id>codemc</id>
<url>https://repo.codemc.org/repository/bentoboxworld/</url>
</snapshotRepository>
<repository>
<id>codemc-releases</id>
<url>https://repo.codemc.org/repository/maven-releases</url>
</repository>
</distributionManagement>

<properties>
Expand All @@ -58,14 +54,14 @@
<!-- Non-minecraft related dependencies -->
<powermock.version>2.0.9</powermock.version>
<!-- More visible way how to change dependency versions -->
<spigot.version>1.20.4-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>2.5.0-SNAPSHOT</bentobox.version>
<spigot.version>1.21.3-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>2.7.1-SNAPSHOT</bentobox.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
<!-- 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.18.2</build.version>
<build.version>1.19.0</build.version>
<!-- Sonar Cloud -->
<sonar.projectKey>BentoBoxWorld_BSkyBlock</sonar.projectKey>
<sonar.organization>bentobox-world</sonar.organization>
Expand Down Expand Up @@ -121,7 +117,7 @@
</repository>
<repository>
<id>codemc</id>
<url>https://repo.codemc.org/repository/maven-snapshots/</url>
<url>https://repo.codemc.org/repository/bentoboxworld/</url>
</repository>
<repository>
<id>codemc-repo</id>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/world/bentobox/bskyblock/BSkyBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import org.bukkit.World;
import org.bukkit.World.Environment;
import org.bukkit.entity.SpawnCategory;
import org.bukkit.WorldCreator;
import org.bukkit.WorldType;
import org.bukkit.entity.SpawnCategory;
import org.bukkit.event.Listener;
import org.bukkit.generator.ChunkGenerator;
import org.eclipse.jdt.annotation.Nullable;
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/world/bentobox/bskyblock/Settings.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
package world.bentobox.bskyblock;

import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.bukkit.Difficulty;
import org.bukkit.GameMode;
import org.bukkit.block.Biome;
import org.bukkit.entity.EntityType;
import org.eclipse.jdt.annotation.NonNull;

import com.google.common.base.Enums;

import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.api.configuration.ConfigComment;
import world.bentobox.bentobox.api.configuration.ConfigEntry;
Expand Down Expand Up @@ -155,7 +159,7 @@ public class Settings implements WorldSettings {
private Biome defaultBiome = Biome.PLAINS;
@ConfigComment("The default biome for the nether world (this may affect what mobs can spawn)")
@ConfigEntry(path = "world.default-nether-biome")
private Biome defaultNetherBiome = Enums.getIfPresent(Biome.class, "NETHER").or(Enums.getIfPresent(Biome.class, "NETHER_WASTES").or(Biome.BADLANDS));
private Biome defaultNetherBiome = Biome.NETHER_WASTES;
@ConfigComment("The default biome for the end world (this may affect what mobs can spawn)")
@ConfigEntry(path = "world.default-end-biome")
private Biome defaultEndBiome = Biome.THE_END;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/addon.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: BSkyBlock
main: world.bentobox.bskyblock.BSkyBlock
version: ${version}${build.number}
api-version: 2.3.0
api-version: 2.7.1
metrics: true
icon: "OAK_SAPLING"
repository: "BentoBoxWorld/BSkyBlock"
Expand Down
26 changes: 1 addition & 25 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -304,31 +304,7 @@ world:
# These settings/flags are hidden from users
# Ops can toggle hiding in-game using SHIFT-LEFT-CLICK on flags in settings
# Added since 1.4.1.
hidden-flags:
- CHEST_DAMAGE
- HURT_MONSTERS
- BREAK_SPAWNERS
- DISPENSER
- DRAGON_EGG
- DROPPER
- EXPERIENCE_BOTTLE_THROWING
- HURT_VILLAGERS
- MOUNT_INVENTORY
- NOTE_BLOCK
- TURTLE_EGGS
- PVP_END
- FIRE_BURNING
- FIRE_IGNITE
- FIRE_SPREAD
- PVP_NETHER
- PVP_OVERWORLD
- TNT_DAMAGE
- MONSTER_NATURAL_SPAWN
- MONSTER_SPAWNERS_SPAWN
- ANIMAL_SPAWNERS_SPAWN
- ANIMAL_NATURAL_SPAWN
- LEAF_DECAY
- BREAK_HOPPERS
hidden-flags: []
# Visitor banned commands - Visitors to islands cannot use these commands in this world
visitor-banned-commands:
- spawner
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: BentoBox-BSkyBlock
main: world.bentobox.bskyblock.BSkyBlockPladdon
version: ${project.version}${build.number}
api-version: "1.19"
api-version: "1.21"

authors: [tastybento]
contributors: ["The BentoBoxWorld Community"]
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/world/bentobox/bskyblock/BSkyBlockTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import org.bukkit.Bukkit;
import org.bukkit.Server;
import org.bukkit.UnsafeValues;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.junit.After;
Expand Down Expand Up @@ -59,6 +60,7 @@
import world.bentobox.bentobox.managers.IslandWorldManager;
import world.bentobox.bentobox.managers.IslandsManager;
import world.bentobox.bskyblock.generators.ChunkGeneratorWorld;
import world.bentobox.bskyblock.mocks.ServerMocks;

/**
* @author tastybento
Expand Down Expand Up @@ -101,6 +103,7 @@ public static void beforeClass() throws IllegalAccessException, InvocationTarget

@After
public void tearDown() throws IOException {
ServerMocks.unsetBukkitServer();
User.clearUsers();
Mockito.framework().clearInlineMocks();
deleteAll(new File("database"));
Expand All @@ -123,6 +126,7 @@ private void deleteAll(File file) throws IOException {
*/
@Before
public void setUp() throws Exception {
ServerMocks.newServer();
// Set up plugin
Whitebox.setInternalState(BentoBox.class, "instance", plugin);
when(plugin.getLogger()).thenReturn(Logger.getAnonymousLogger());
Expand Down Expand Up @@ -160,6 +164,9 @@ public void setUp() throws Exception {
when(Bukkit.getServer()).thenReturn(server);
when(Bukkit.getLogger()).thenReturn(Logger.getAnonymousLogger());
when(Bukkit.getPluginManager()).thenReturn(mock(PluginManager.class));
@SuppressWarnings("deprecation")
UnsafeValues unsafe = mock(UnsafeValues.class);
when(Bukkit.getUnsafe()).thenReturn(unsafe);

// Addon
addon = new BSkyBlock();
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/world/bentobox/bskyblock/SettingsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
import org.bukkit.GameMode;
import org.bukkit.block.Biome;
import org.bukkit.entity.EntityType;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import world.bentobox.bskyblock.mocks.ServerMocks;

/**
* @author tastybento
*
Expand All @@ -29,9 +32,15 @@ public class SettingsTest {
*/
@Before
public void setUp() throws Exception {
ServerMocks.newServer();
s = new Settings();
}

@After
public void tearDown() {
ServerMocks.unsetBukkitServer();
}

/**
* Test method for {@link world.bentobox.bskyblock.Settings#setFriendlyName(java.lang.String)}.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.UnsafeValues;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
Expand All @@ -32,6 +33,7 @@

import world.bentobox.bskyblock.BSkyBlock;
import world.bentobox.bskyblock.Settings;
import world.bentobox.bskyblock.mocks.ServerMocks;

/**
* @author tastybento
Expand All @@ -47,111 +49,103 @@ public class ChunkGeneratorWorldTest {
@Mock
private World world;
private final Random random = new Random();
@SuppressWarnings("deprecation")
@Mock
private BiomeGrid biomeGrid;
@Mock
private Settings settings;
@Mock
private ChunkData data;

/**
* @throws java.lang.Exception
*/
@SuppressWarnings("deprecation")
@Before
public void setUp() throws Exception {
ServerMocks.newServer();
// Bukkit

PowerMockito.mockStatic(Bukkit.class);
Server server = mock(Server.class);
when(server.createChunkData(any())).thenReturn(data);
when(Bukkit.getServer()).thenReturn(server);
UnsafeValues unsafe = mock(UnsafeValues.class);
when(Bukkit.getUnsafe()).thenReturn(unsafe);

// Instance
cg = new ChunkGeneratorWorld(addon);
// World
when(world.getEnvironment()).thenReturn(World.Environment.NORMAL);
when(world.getMaxHeight()).thenReturn(16);
// Settings
settings = new Settings();
when(addon.getSettings()).thenReturn(settings);
when(settings.getSeaHeight()).thenReturn(0);
when(settings.isNetherRoof()).thenReturn(true);
when(settings.getDefaultBiome()).thenReturn(Biome.TAIGA);
when(settings.getDefaultNetherBiome()).thenReturn(Biome.CRIMSON_FOREST);
when(settings.getDefaultEndBiome()).thenReturn(Biome.END_MIDLANDS);
}

/**
* @throws java.lang.Exception
*/
@After
public void tearDown() throws Exception {
public void tearDown() {
ServerMocks.unsetBukkitServer();
}

/**
* 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() {
ChunkData cd = cg.generateChunkData(world, random, 0 , 0 , biomeGrid);
assertEquals(data, cd);
// Verifications
// Default biome
verify(settings).getDefaultBiome();
verify(biomeGrid, times(64)).setBiome(anyInt(), anyInt(), anyInt(), any());
// Sea height
verify(settings).getSeaHeight();
// 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 testGenerateChunkDataWorldRandomIntIntBiomeGridOverworldSea() {
// Set sea height
when(settings.getSeaHeight()).thenReturn(10);
ChunkData cd = cg.generateChunkData(world, random, 0 , 0 , biomeGrid);
settings.setSeaHeight(10);
ChunkData cd = cg.generateChunkData(world, random, 0, 0, biomeGrid);
assertEquals(data, cd);
// Verifications
// Default biome
verify(settings).getDefaultBiome();
verify(biomeGrid, times(64)).setBiome(anyInt(), anyInt(), anyInt(), eq(Biome.TAIGA));
// 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);
}

/**
* 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() {
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(64)).setBiome(anyInt(), anyInt(), anyInt(), eq(Biome.END_MIDLANDS));
// Sea height
verify(settings, never()).getSeaHeight();
// 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() {
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();
// Set biome in nether
verify(biomeGrid, times(64)).setBiome(anyInt(), anyInt(), anyInt(), eq(Biome.CRIMSON_FOREST));
// Nether roof - at least bedrock layer
Expand All @@ -161,16 +155,14 @@ public void testGenerateChunkDataWorldRandomIntIntBiomeGridNetherWithRoof() {
/**
* 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);
when(world.getEnvironment()).thenReturn(World.Environment.NETHER);
ChunkData cd = cg.generateChunkData(world, random, 0 , 0 , biomeGrid);
assertEquals(data, cd);
// Verifications
verify(settings).getDefaultNetherBiome();
// Nether roof check
verify(settings).isNetherRoof();
// Set biome in nether
verify(biomeGrid, times(64)).setBiome(anyInt(), anyInt(), anyInt(), eq(Biome.CRIMSON_FOREST));
// Nether roof - at least bedrock layer
Expand Down
Loading
Loading