Skip to content

Commit

Permalink
Merge pull request #161 from BentoBoxWorld/develop
Browse files Browse the repository at this point in the history
Version 1.20.0
  • Loading branch information
tastybento authored Nov 16, 2024
2 parents f7ae02f + 7a2e766 commit a24735b
Show file tree
Hide file tree
Showing 11 changed files with 252 additions and 54 deletions.
19 changes: 13 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
name: SonarCloud
name: Build
on:
push:
branches:
- develop
- master
pull_request:
types: [opened, synchronize, reopened]
jobs:
build:
name: Build and analyze
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
distribution: 'adopt'
java-version: 17
java-version: '21'
- name: Cache SonarCloud packages
uses: actions/cache@v3
with:
Expand All @@ -35,4 +34,12 @@ 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 -Dsonar.projectKey=BentoBoxWorld_AcidIsland
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=BentoBoxWorld_AcidIsland
- run: mvn --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install
- run: mkdir staging && cp target/*.jar staging
- name: Save artifacts
uses: actions/upload-artifact@v3
with:
name: Package
path: staging

22 changes: 7 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,27 @@
</issueManagement>

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

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>17</java.version>
<java.version>21</java.version>
<!-- 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.19.0</build.version>
<build.version>1.20.0</build.version>
<!-- Sonar Cloud -->
<sonar.projectKey>BentoBoxWorld_AcidIsland</sonar.projectKey>
<sonar.organization>bentobox-world</sonar.organization>
Expand Down Expand Up @@ -121,11 +117,7 @@
</repository>
<repository>
<id>codemc-repo</id>
<url>https://repo.codemc.org/repository/maven-public/</url>
</repository>
<repository>
<id>codemc</id>
<url>https://repo.codemc.org/repository/maven-snapshots/</url>
<url>https://repo.codemc.io/repository/bentoboxworld/</url>
</repository>
<repository>
<id>ess-repo</id>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/world/bentobox/acidisland/AISettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public class AISettings implements WorldSettings {
private Biome defaultBiome = Biome.WARM_OCEAN;
@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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import org.bukkit.World.Environment;
import org.bukkit.attribute.Attribute;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -56,9 +55,9 @@ public class AcidEffect implements Listener {
private static final List<PotionEffectType> EFFECTS;
static {
if (!inTest()) {
EFFECTS = List.of(PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HUNGER,
PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS,
PotionEffectType.POISON);
EFFECTS = List.of(PotionEffectType.BLINDNESS, PotionEffectType.NAUSEA, PotionEffectType.HUNGER,
PotionEffectType.SLOWNESS, PotionEffectType.MINING_FATIGUE, PotionEffectType.WEAKNESS,
PotionEffectType.POISON, PotionEffectType.DARKNESS, PotionEffectType.UNLUCK);
} else {
EFFECTS = List.of();
}
Expand Down Expand Up @@ -294,8 +293,8 @@ boolean isSafeFromAcid(Player player) {
return true;
}
// Check if player is on a boat
if (player.getVehicle() != null && (player.getVehicle().getType().equals(EntityType.BOAT)
|| player.getVehicle().getType().equals(EntityType.CHEST_BOAT))) {
if (player.getVehicle() != null && (player.getVehicle().getType().getKey().getKey().contains("boat")
|| player.getVehicle().getType().getKey().getKey().contains("raft"))) {
// I'M ON A BOAT! I'M ON A BOAT! A %^&&* BOAT! SNL Sketch. https://youtu.be/avaSdC0QOUM.
return true;
}
Expand Down Expand Up @@ -330,7 +329,7 @@ private boolean isEssentialsGodMode(Player player) {
*/
public static double getDamageReduced(LivingEntity le) {
// Full diamond armor value = 20. This normalizes it to a max of 0.8. Enchantments can raise it out further.
double red = le.getAttribute(Attribute.GENERIC_ARMOR).getValue() * 0.04;
double red = le.getAttribute(Attribute.ARMOR).getValue() * 0.04;
EntityEquipment inv = le.getEquipment();
ItemStack boots = inv.getBoots();
ItemStack helmet = inv.getHelmet();
Expand Down
15 changes: 15 additions & 0 deletions src/test/java/world/bentobox/acidisland/AISettingsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,44 @@
import java.util.Collections;
import java.util.List;

import org.bukkit.Bukkit;
import org.bukkit.Difficulty;
import org.bukkit.GameMode;
import org.bukkit.block.Biome;
import org.bukkit.entity.EntityType;
import org.bukkit.potion.PotionEffectType;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;

import world.bentobox.acidisland.mocks.ServerMocks;
import world.bentobox.bentobox.lists.Flags;

/**
* @author tastybento
*
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({ Bukkit.class })
public class AISettingsTest {

/**
* Class under test
*/
private AISettings s;

@BeforeClass
public static void beforeClass() {
ServerMocks.newServer();
}

/**
* @throws java.lang.Exception
*/
Expand Down
2 changes: 2 additions & 0 deletions src/test/java/world/bentobox/acidisland/AcidIslandTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;

import world.bentobox.acidisland.mocks.ServerMocks;
import world.bentobox.acidisland.world.ChunkGeneratorWorld;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.Settings;
Expand Down Expand Up @@ -104,6 +105,7 @@ public static void beforeClass() throws IllegalAccessException, InvocationTarget
when(DatabaseSetup.getDatabase()).thenReturn(dbSetup);
when(dbSetup.getHandler(any())).thenReturn(h);
when(h.saveObject(any())).thenReturn(CompletableFuture.completedFuture(true));
ServerMocks.newServer();
}

@After
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import org.bukkit.World.Environment;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.block.Block;
import org.bukkit.entity.Boat;
import org.bukkit.entity.Entity;
Expand All @@ -44,6 +45,7 @@
import org.bukkit.util.Vector;
import org.junit.After;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -59,6 +61,7 @@

import world.bentobox.acidisland.AISettings;
import world.bentobox.acidisland.AcidIsland;
import world.bentobox.acidisland.mocks.ServerMocks;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.managers.IslandWorldManager;
import world.bentobox.bentobox.managers.IslandsManager;
Expand Down Expand Up @@ -118,8 +121,11 @@ public class AcidEffectTest {
@Mock
private Server server;

/**
*/
@BeforeClass
public static void beforeClass() {
ServerMocks.newServer();
}

@Before
public void setUp() {
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
Expand Down Expand Up @@ -480,7 +486,7 @@ public void testOnPlayerMoveNoSnowAcidDamage() {
public void testOnPlayerMoveInBoat() {
when(settings.getAcidRainDamage()).thenReturn(0);
Entity boat = mock(Boat.class);
when(boat.getType()).thenReturn(EntityType.BOAT);
when(boat.getType()).thenReturn(EntityType.ACACIA_BOAT);
when(player.getVehicle()).thenReturn(boat);
PlayerMoveEvent e = new PlayerMoveEvent(player, from, to);
ae.onPlayerMove(e);
Expand Down Expand Up @@ -574,10 +580,11 @@ public void testOnPlayerMoveActivePotionsBadOmen() {
*/
@Test
public void testGetDamageReducedFullDiamond() {
AttributeInstance value = mock(AttributeInstance.class);
when(value.getValue()).thenReturn(20D);
Att value = new Att();
//AttributeInstance value = new AttributeInstance();
//when(value.getValue()).thenReturn(20D);
// Diamond armor
when(player.getAttribute(eq(Attribute.GENERIC_ARMOR))).thenReturn(value);
when(player.getAttribute(eq(Attribute.ARMOR))).thenReturn(value);
EntityEquipment equip = mock(EntityEquipment.class);
when(equip.getBoots()).thenReturn(new ItemStack(Material.DIAMOND_BOOTS));
when(equip.getHelmet()).thenReturn(new ItemStack(Material.DIAMOND_HELMET));
Expand All @@ -589,6 +596,57 @@ public void testGetDamageReducedFullDiamond() {

}

class Att implements AttributeInstance {

@Override
public Attribute getAttribute() {
// TODO Auto-generated method stub
return null;
}

@Override
public double getBaseValue() {
// TODO Auto-generated method stub
return 0;
}

@Override
public void setBaseValue(double value) {
// TODO Auto-generated method stub

}

@Override
public Collection<AttributeModifier> getModifiers() {
// TODO Auto-generated method stub
return null;
}

@Override
public void addModifier(AttributeModifier modifier) {
// TODO Auto-generated method stub

}

@Override
public void removeModifier(AttributeModifier modifier) {
// TODO Auto-generated method stub

}

@Override
public double getValue() {
return 20;
}

@Override
public double getDefaultValue() {
// TODO Auto-generated method stub
return 0;
}

}

/**
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#checkForRain(Player)}.
*/
Expand Down Expand Up @@ -629,7 +687,7 @@ public void testCheckForRainWetPlayer() {
AttributeInstance value = mock(AttributeInstance.class);
when(value.getValue()).thenReturn(20D);
// Diamond armor
when(player.getAttribute(eq(Attribute.GENERIC_ARMOR))).thenReturn(value);
when(player.getAttribute(eq(Attribute.ARMOR))).thenReturn(value);
EntityEquipment equip = mock(EntityEquipment.class);
when(equip.getBoots()).thenReturn(new ItemStack(Material.DIAMOND_BOOTS));
when(equip.getHelmet()).thenReturn(new ItemStack(Material.DIAMOND_HELMET));
Expand Down Expand Up @@ -672,7 +730,7 @@ public void testIsSafeFromAcidEssentialGodMode() {
public void testIsSafeFromAcidBoat() {
when(player.isInsideVehicle()).thenReturn(true);
Entity boat = mock(Entity.class);
when(boat.getType()).thenReturn(EntityType.BOAT);
when(boat.getType()).thenReturn(EntityType.ACACIA_BOAT);
when(player.getVehicle()).thenReturn(boat);
assertTrue(ae.isSafeFromAcid(player));
}
Expand All @@ -684,7 +742,7 @@ public void testIsSafeFromAcidBoat() {
public void testIsSafeFromAcidChestBoat() {
when(player.isInsideVehicle()).thenReturn(true);
Entity boat = mock(Entity.class);
when(boat.getType()).thenReturn(EntityType.CHEST_BOAT);
when(boat.getType()).thenReturn(EntityType.ACACIA_CHEST_BOAT);
when(player.getVehicle()).thenReturn(boat);
assertTrue(ae.isSafeFromAcid(player));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.bukkit.plugin.PluginManager;
import org.bukkit.scheduler.BukkitScheduler;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
Expand All @@ -33,6 +34,7 @@

import world.bentobox.acidisland.AISettings;
import world.bentobox.acidisland.AcidIsland;
import world.bentobox.acidisland.mocks.ServerMocks;
import world.bentobox.bentobox.BentoBox;
import world.bentobox.bentobox.managers.IslandWorldManager;
import world.bentobox.bentobox.managers.IslandsManager;
Expand Down Expand Up @@ -86,8 +88,11 @@ public class LavaCheckTest {

private LavaCheck lc;

/**
*/
@BeforeClass
public static void beforeClass() {
ServerMocks.newServer();
}

@Before
public void setUp() {
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
Expand Down
Loading

0 comments on commit a24735b

Please sign in to comment.