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

Updated to 1.21.3 #160

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
10 changes: 3 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@
<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>
<spigot.version>1.21.3-R0.1-SNAPSHOT</spigot.version>
<bentobox.version>2.5.0-SNAPSHOT</bentobox.version>
<!-- Revision variable removes warning about dynamic version -->
<revision>${build.version}-SNAPSHOT</revision>
Expand Down Expand Up @@ -121,11 +121,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/tastybento/</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
Loading