Skip to content

Commit 76b02f7

Browse files
authored
Merge pull request #160 from BentoBoxWorld/1.23.1_new
Updated to 1.21.3
2 parents 284e7e9 + d0a4cd1 commit 76b02f7

File tree

11 files changed

+251
-53
lines changed

11 files changed

+251
-53
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
1-
name: SonarCloud
1+
name: Build
22
on:
33
push:
44
branches:
55
- develop
6-
- master
76
pull_request:
87
types: [opened, synchronize, reopened]
98
jobs:
109
build:
11-
name: Build and analyze
10+
name: Build
1211
runs-on: ubuntu-latest
1312
steps:
1413
- uses: actions/checkout@v3
1514
with:
1615
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
17-
- name: Set up JDK 17
16+
- name: Set up JDK 21
1817
uses: actions/setup-java@v3
1918
with:
2019
distribution: 'adopt'
21-
java-version: 17
20+
java-version: '21'
2221
- name: Cache SonarCloud packages
2322
uses: actions/cache@v3
2423
with:
@@ -35,4 +34,12 @@ jobs:
3534
env:
3635
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
3736
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
38-
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=BentoBoxWorld_AcidIsland
37+
run: mvn -B verify org.sonarsource.scanner.maven:sonar-maven-plugin:sonar -Dsonar.projectKey=BentoBoxWorld_AcidIsland
38+
- run: mvn --batch-mode clean org.jacoco:jacoco-maven-plugin:prepare-agent install
39+
- run: mkdir staging && cp target/*.jar staging
40+
- name: Save artifacts
41+
uses: actions/upload-artifact@v3
42+
with:
43+
name: Package
44+
path: staging
45+

pom.xml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,24 +42,20 @@
4242

4343
<distributionManagement>
4444
<snapshotRepository>
45-
<id>codemc-snapshots</id>
46-
<url>https://repo.codemc.org/repository/maven-snapshots</url>
45+
<id>codemc</id>
46+
<url>https://repo.codemc.org/repository/bentoboxworld/</url>
4747
</snapshotRepository>
48-
<repository>
49-
<id>codemc-releases</id>
50-
<url>https://repo.codemc.org/repository/maven-releases</url>
51-
</repository>
5248
</distributionManagement>
5349

5450
<properties>
5551
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
5652
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
57-
<java.version>17</java.version>
53+
<java.version>21</java.version>
5854
<!-- Non-minecraft related dependencies -->
5955
<powermock.version>2.0.9</powermock.version>
6056
<!-- More visible way how to change dependency versions -->
61-
<spigot.version>1.20.4-R0.1-SNAPSHOT</spigot.version>
62-
<bentobox.version>2.5.0-SNAPSHOT</bentobox.version>
57+
<spigot.version>1.21.3-R0.1-SNAPSHOT</spigot.version>
58+
<bentobox.version>2.7.1-SNAPSHOT</bentobox.version>
6359
<!-- Revision variable removes warning about dynamic version -->
6460
<revision>${build.version}-SNAPSHOT</revision>
6561
<!-- Do not change unless you want different name for local builds. -->
@@ -121,11 +117,7 @@
121117
</repository>
122118
<repository>
123119
<id>codemc-repo</id>
124-
<url>https://repo.codemc.org/repository/maven-public/</url>
125-
</repository>
126-
<repository>
127-
<id>codemc</id>
128-
<url>https://repo.codemc.org/repository/maven-snapshots/</url>
120+
<url>https://repo.codemc.io/repository/bentoboxworld/</url>
129121
</repository>
130122
<repository>
131123
<id>ess-repo</id>

src/main/java/world/bentobox/acidisland/AISettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ public class AISettings implements WorldSettings {
260260
private Biome defaultBiome = Biome.WARM_OCEAN;
261261
@ConfigComment("The default biome for the nether world (this may affect what mobs can spawn)")
262262
@ConfigEntry(path = "world.default-nether-biome")
263-
private Biome defaultNetherBiome = Enums.getIfPresent(Biome.class, "NETHER").or(Enums.getIfPresent(Biome.class, "NETHER_WASTES").or(Biome.BADLANDS));
263+
private Biome defaultNetherBiome = Biome.NETHER_WASTES;
264264
@ConfigComment("The default biome for the end world (this may affect what mobs can spawn)")
265265
@ConfigEntry(path = "world.default-end-biome")
266266
private Biome defaultEndBiome = Biome.THE_END;

src/main/java/world/bentobox/acidisland/listeners/AcidEffect.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
import org.bukkit.World.Environment;
1313
import org.bukkit.attribute.Attribute;
1414
import org.bukkit.block.BlockFace;
15-
import org.bukkit.entity.EntityType;
1615
import org.bukkit.entity.LivingEntity;
1716
import org.bukkit.entity.Player;
1817
import org.bukkit.event.EventHandler;
@@ -56,9 +55,9 @@ public class AcidEffect implements Listener {
5655
private static final List<PotionEffectType> EFFECTS;
5756
static {
5857
if (!inTest()) {
59-
EFFECTS = List.of(PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HUNGER,
60-
PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS,
61-
PotionEffectType.POISON);
58+
EFFECTS = List.of(PotionEffectType.BLINDNESS, PotionEffectType.NAUSEA, PotionEffectType.HUNGER,
59+
PotionEffectType.SLOWNESS, PotionEffectType.MINING_FATIGUE, PotionEffectType.WEAKNESS,
60+
PotionEffectType.POISON, PotionEffectType.DARKNESS, PotionEffectType.UNLUCK);
6261
} else {
6362
EFFECTS = List.of();
6463
}
@@ -294,8 +293,8 @@ boolean isSafeFromAcid(Player player) {
294293
return true;
295294
}
296295
// Check if player is on a boat
297-
if (player.getVehicle() != null && (player.getVehicle().getType().equals(EntityType.BOAT)
298-
|| player.getVehicle().getType().equals(EntityType.CHEST_BOAT))) {
296+
if (player.getVehicle() != null && (player.getVehicle().getType().getKey().getKey().contains("boat")
297+
|| player.getVehicle().getType().getKey().getKey().contains("raft"))) {
299298
// I'M ON A BOAT! I'M ON A BOAT! A %^&&* BOAT! SNL Sketch. https://youtu.be/avaSdC0QOUM.
300299
return true;
301300
}
@@ -330,7 +329,7 @@ private boolean isEssentialsGodMode(Player player) {
330329
*/
331330
public static double getDamageReduced(LivingEntity le) {
332331
// Full diamond armor value = 20. This normalizes it to a max of 0.8. Enchantments can raise it out further.
333-
double red = le.getAttribute(Attribute.GENERIC_ARMOR).getValue() * 0.04;
332+
double red = le.getAttribute(Attribute.ARMOR).getValue() * 0.04;
334333
EntityEquipment inv = le.getEquipment();
335334
ItemStack boots = inv.getBoots();
336335
ItemStack helmet = inv.getHelmet();

src/test/java/world/bentobox/acidisland/AISettingsTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,44 @@
77
import java.util.Collections;
88
import java.util.List;
99

10+
import org.bukkit.Bukkit;
1011
import org.bukkit.Difficulty;
1112
import org.bukkit.GameMode;
1213
import org.bukkit.block.Biome;
1314
import org.bukkit.entity.EntityType;
1415
import org.bukkit.potion.PotionEffectType;
1516
import org.junit.After;
1617
import org.junit.Before;
18+
import org.junit.BeforeClass;
1719
import org.junit.Ignore;
1820
import org.junit.Test;
21+
import org.junit.runner.RunWith;
22+
import org.mockito.Mockito;
23+
import org.powermock.api.mockito.PowerMockito;
24+
import org.powermock.core.classloader.annotations.PrepareForTest;
25+
import org.powermock.modules.junit4.PowerMockRunner;
1926

27+
import world.bentobox.acidisland.mocks.ServerMocks;
2028
import world.bentobox.bentobox.lists.Flags;
2129

2230
/**
2331
* @author tastybento
2432
*
2533
*/
34+
@RunWith(PowerMockRunner.class)
35+
@PrepareForTest({ Bukkit.class })
2636
public class AISettingsTest {
2737

2838
/**
2939
* Class under test
3040
*/
3141
private AISettings s;
3242

43+
@BeforeClass
44+
public static void beforeClass() {
45+
ServerMocks.newServer();
46+
}
47+
3348
/**
3449
* @throws java.lang.Exception
3550
*/

src/test/java/world/bentobox/acidisland/AcidIslandTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import org.powermock.modules.junit4.PowerMockRunner;
4747
import org.powermock.reflect.Whitebox;
4848

49+
import world.bentobox.acidisland.mocks.ServerMocks;
4950
import world.bentobox.acidisland.world.ChunkGeneratorWorld;
5051
import world.bentobox.bentobox.BentoBox;
5152
import world.bentobox.bentobox.Settings;
@@ -104,6 +105,7 @@ public static void beforeClass() throws IllegalAccessException, InvocationTarget
104105
when(DatabaseSetup.getDatabase()).thenReturn(dbSetup);
105106
when(dbSetup.getHandler(any())).thenReturn(h);
106107
when(h.saveObject(any())).thenReturn(CompletableFuture.completedFuture(true));
108+
ServerMocks.newServer();
107109
}
108110

109111
@After

src/test/java/world/bentobox/acidisland/listeners/AcidEffectTest.java

Lines changed: 67 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.bukkit.World.Environment;
2525
import org.bukkit.attribute.Attribute;
2626
import org.bukkit.attribute.AttributeInstance;
27+
import org.bukkit.attribute.AttributeModifier;
2728
import org.bukkit.block.Block;
2829
import org.bukkit.entity.Boat;
2930
import org.bukkit.entity.Entity;
@@ -44,6 +45,7 @@
4445
import org.bukkit.util.Vector;
4546
import org.junit.After;
4647
import org.junit.Before;
48+
import org.junit.BeforeClass;
4749
import org.junit.Ignore;
4850
import org.junit.Test;
4951
import org.junit.runner.RunWith;
@@ -59,6 +61,7 @@
5961

6062
import world.bentobox.acidisland.AISettings;
6163
import world.bentobox.acidisland.AcidIsland;
64+
import world.bentobox.acidisland.mocks.ServerMocks;
6265
import world.bentobox.bentobox.BentoBox;
6366
import world.bentobox.bentobox.managers.IslandWorldManager;
6467
import world.bentobox.bentobox.managers.IslandsManager;
@@ -118,8 +121,11 @@ public class AcidEffectTest {
118121
@Mock
119122
private Server server;
120123

121-
/**
122-
*/
124+
@BeforeClass
125+
public static void beforeClass() {
126+
ServerMocks.newServer();
127+
}
128+
123129
@Before
124130
public void setUp() {
125131
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);
@@ -480,7 +486,7 @@ public void testOnPlayerMoveNoSnowAcidDamage() {
480486
public void testOnPlayerMoveInBoat() {
481487
when(settings.getAcidRainDamage()).thenReturn(0);
482488
Entity boat = mock(Boat.class);
483-
when(boat.getType()).thenReturn(EntityType.BOAT);
489+
when(boat.getType()).thenReturn(EntityType.ACACIA_BOAT);
484490
when(player.getVehicle()).thenReturn(boat);
485491
PlayerMoveEvent e = new PlayerMoveEvent(player, from, to);
486492
ae.onPlayerMove(e);
@@ -574,10 +580,11 @@ public void testOnPlayerMoveActivePotionsBadOmen() {
574580
*/
575581
@Test
576582
public void testGetDamageReducedFullDiamond() {
577-
AttributeInstance value = mock(AttributeInstance.class);
578-
when(value.getValue()).thenReturn(20D);
583+
Att value = new Att();
584+
//AttributeInstance value = new AttributeInstance();
585+
//when(value.getValue()).thenReturn(20D);
579586
// Diamond armor
580-
when(player.getAttribute(eq(Attribute.GENERIC_ARMOR))).thenReturn(value);
587+
when(player.getAttribute(eq(Attribute.ARMOR))).thenReturn(value);
581588
EntityEquipment equip = mock(EntityEquipment.class);
582589
when(equip.getBoots()).thenReturn(new ItemStack(Material.DIAMOND_BOOTS));
583590
when(equip.getHelmet()).thenReturn(new ItemStack(Material.DIAMOND_HELMET));
@@ -589,6 +596,57 @@ public void testGetDamageReducedFullDiamond() {
589596

590597
}
591598

599+
class Att implements AttributeInstance {
600+
601+
@Override
602+
public Attribute getAttribute() {
603+
// TODO Auto-generated method stub
604+
return null;
605+
}
606+
607+
@Override
608+
public double getBaseValue() {
609+
// TODO Auto-generated method stub
610+
return 0;
611+
}
612+
613+
@Override
614+
public void setBaseValue(double value) {
615+
// TODO Auto-generated method stub
616+
617+
}
618+
619+
@Override
620+
public Collection<AttributeModifier> getModifiers() {
621+
// TODO Auto-generated method stub
622+
return null;
623+
}
624+
625+
@Override
626+
public void addModifier(AttributeModifier modifier) {
627+
// TODO Auto-generated method stub
628+
629+
}
630+
631+
@Override
632+
public void removeModifier(AttributeModifier modifier) {
633+
// TODO Auto-generated method stub
634+
635+
}
636+
637+
@Override
638+
public double getValue() {
639+
return 20;
640+
}
641+
642+
@Override
643+
public double getDefaultValue() {
644+
// TODO Auto-generated method stub
645+
return 0;
646+
}
647+
648+
}
649+
592650
/**
593651
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#checkForRain(Player)}.
594652
*/
@@ -629,7 +687,7 @@ public void testCheckForRainWetPlayer() {
629687
AttributeInstance value = mock(AttributeInstance.class);
630688
when(value.getValue()).thenReturn(20D);
631689
// Diamond armor
632-
when(player.getAttribute(eq(Attribute.GENERIC_ARMOR))).thenReturn(value);
690+
when(player.getAttribute(eq(Attribute.ARMOR))).thenReturn(value);
633691
EntityEquipment equip = mock(EntityEquipment.class);
634692
when(equip.getBoots()).thenReturn(new ItemStack(Material.DIAMOND_BOOTS));
635693
when(equip.getHelmet()).thenReturn(new ItemStack(Material.DIAMOND_HELMET));
@@ -672,7 +730,7 @@ public void testIsSafeFromAcidEssentialGodMode() {
672730
public void testIsSafeFromAcidBoat() {
673731
when(player.isInsideVehicle()).thenReturn(true);
674732
Entity boat = mock(Entity.class);
675-
when(boat.getType()).thenReturn(EntityType.BOAT);
733+
when(boat.getType()).thenReturn(EntityType.ACACIA_BOAT);
676734
when(player.getVehicle()).thenReturn(boat);
677735
assertTrue(ae.isSafeFromAcid(player));
678736
}
@@ -684,7 +742,7 @@ public void testIsSafeFromAcidBoat() {
684742
public void testIsSafeFromAcidChestBoat() {
685743
when(player.isInsideVehicle()).thenReturn(true);
686744
Entity boat = mock(Entity.class);
687-
when(boat.getType()).thenReturn(EntityType.CHEST_BOAT);
745+
when(boat.getType()).thenReturn(EntityType.ACACIA_CHEST_BOAT);
688746
when(player.getVehicle()).thenReturn(boat);
689747
assertTrue(ae.isSafeFromAcid(player));
690748
}

src/test/java/world/bentobox/acidisland/listeners/LavaCheckTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.bukkit.plugin.PluginManager;
2020
import org.bukkit.scheduler.BukkitScheduler;
2121
import org.junit.Before;
22+
import org.junit.BeforeClass;
2223
import org.junit.Test;
2324
import org.junit.runner.RunWith;
2425
import org.mockito.ArgumentCaptor;
@@ -33,6 +34,7 @@
3334

3435
import world.bentobox.acidisland.AISettings;
3536
import world.bentobox.acidisland.AcidIsland;
37+
import world.bentobox.acidisland.mocks.ServerMocks;
3638
import world.bentobox.bentobox.BentoBox;
3739
import world.bentobox.bentobox.managers.IslandWorldManager;
3840
import world.bentobox.bentobox.managers.IslandsManager;
@@ -86,8 +88,11 @@ public class LavaCheckTest {
8688

8789
private LavaCheck lc;
8890

89-
/**
90-
*/
91+
@BeforeClass
92+
public static void beforeClass() {
93+
ServerMocks.newServer();
94+
}
95+
9196
@Before
9297
public void setUp() {
9398
PowerMockito.mockStatic(Bukkit.class, Mockito.RETURNS_MOCKS);

0 commit comments

Comments
 (0)