mirror of
https://github.com/BentoBoxWorld/AcidIsland.git
synced 2025-01-23 16:41:41 +01:00
Fixed acid rain detection to skip nether or end environments.
Also fixed more fundamental bug around acid rain detection. https://github.com/BentoBoxWorld/AcidIsland/issues/76
This commit is contained in:
parent
4eb8a3327f
commit
2c99121312
@ -9,6 +9,7 @@ import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.entity.EntityType;
|
||||
@ -177,11 +178,13 @@ public class AcidEffect implements Listener {
|
||||
* @return true if they are safe
|
||||
*/
|
||||
private boolean isSafeFromRain(Player player) {
|
||||
if (addon.getSettings().isHelmetProtection() && (player.getInventory().getHelmet() != null
|
||||
&& player.getInventory().getHelmet().getType().name().contains("HELMET"))
|
||||
if (player.getWorld().getEnvironment().equals(Environment.NETHER)
|
||||
|| player.getWorld().getEnvironment().equals(Environment.THE_END)
|
||||
|| (addon.getSettings().isHelmetProtection() && (player.getInventory().getHelmet() != null && player.getInventory().getHelmet().getType().name().contains("HELMET")))
|
||||
|| (!addon.getSettings().isAcidDamageSnow() && player.getLocation().getBlock().getTemperature() < 0.1) // snow falls
|
||||
|| player.getLocation().getBlock().getHumidity() == 0 // dry
|
||||
|| (player.getActivePotionEffects().stream().map(PotionEffect::getType).anyMatch(IMMUNE_EFFECTS::contains))) {
|
||||
|| (player.getActivePotionEffects().stream().map(PotionEffect::getType).anyMatch(IMMUNE_EFFECTS::contains))
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
// Check if all air above player
|
||||
|
@ -18,6 +18,7 @@ import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
import org.bukkit.block.Block;
|
||||
@ -146,6 +147,7 @@ public class AcidEffectTest {
|
||||
when(world.hasStorm()).thenReturn(true);
|
||||
when(world.getBlockAt(anyInt(), anyInt(), anyInt())).thenReturn(airBlock);
|
||||
when(world.getMaxHeight()).thenReturn(5);
|
||||
when(world.getEnvironment()).thenReturn(Environment.NORMAL);
|
||||
|
||||
ae = new AcidEffect(addon);
|
||||
}
|
||||
@ -305,6 +307,38 @@ public class AcidEffectTest {
|
||||
verify(settings).getAcidDamageDelay();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
@Test
|
||||
public void testOnPlayerMoveAcidRainWrongWorld() {
|
||||
World nether = mock(World.class);
|
||||
when(nether.getName()).thenReturn("world_nether");
|
||||
when(nether.getEnvironment()).thenReturn(Environment.NETHER);
|
||||
when(player.getWorld()).thenReturn(nether);
|
||||
|
||||
PlayerMoveEvent e = new PlayerMoveEvent(player, from, to);
|
||||
ae.onPlayerMove(e);
|
||||
// 2 times only
|
||||
verify(addon, times(2)).getPlugin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
@Test
|
||||
public void testOnPlayerMoveAcidRainWrongWorldEnd() {
|
||||
World end = mock(World.class);
|
||||
when(end.getName()).thenReturn("world_end");
|
||||
when(end.getEnvironment()).thenReturn(Environment.THE_END);
|
||||
when(player.getWorld()).thenReturn(end);
|
||||
|
||||
PlayerMoveEvent e = new PlayerMoveEvent(player, from, to);
|
||||
ae.onPlayerMove(e);
|
||||
// 2 times only
|
||||
verify(addon, times(2)).getPlugin();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test method for {@link world.bentobox.acidisland.listeners.AcidEffect#onPlayerMove(org.bukkit.event.player.PlayerMoveEvent)}.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user