From 2c01dd709b0105dba4fc169ffaa6f904f3c5308d Mon Sep 17 00:00:00 2001 From: Dev Date: Thu, 5 Nov 2026 21:01:05 +0100 Subject: [PATCH] Test actual sun exposure reset in water, shade, night and other worlds --- .../test/java/com/example/dunerealms/SunWearTest.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/DuneRealms-minecraft-only/src/test/java/com/example/dunerealms/SunWearTest.java b/DuneRealms-minecraft-only/src/test/java/com/example/dunerealms/SunWearTest.java index 63397af4..7f0029ff 100644 --- a/DuneRealms-minecraft-only/src/test/java/com/example/dunerealms/SunWearTest.java +++ b/DuneRealms-minecraft-only/src/test/java/com/example/dunerealms/SunWearTest.java @@ -21,4 +21,14 @@ class SunWearTest { verify(player,never()).setFireTicks(anyInt());verify(player,never()).damage(anyDouble()); } } + @Test void actualExposureLoopResetsInWaterShadeNightAndOtherWorld() throws Exception { + for(int scenario=0;scenario<5;scenario++){ + DuneCore core=mock(DuneCore.class,CALLS_REAL_METHODS);Player player=mock(Player.class);org.bukkit.World world=mock(org.bukkit.World.class);org.bukkit.Location location=mock(org.bukkit.Location.class);PlayerInventory inventory=mock(PlayerInventory.class);org.bukkit.configuration.file.FileConfiguration config=mock(org.bukkit.configuration.file.FileConfiguration.class); + doReturn(config).when(core).getConfig();when(config.getBoolean("arrakis-sun.enabled",true)).thenReturn(true);when(config.getInt("arrakis-sun.lethal-seconds",300)).thenReturn(300);when(config.getInt("arrakis-sun.warning-interval-seconds",30)).thenReturn(30); + java.util.UUID id=java.util.UUID.randomUUID();when(player.getUniqueId()).thenReturn(id);when(player.getWorld()).thenReturn(world);when(player.getInventory()).thenReturn(inventory);when(inventory.getArmorContents()).thenReturn(new ItemStack[]{null,null,null,null});when(player.getLocation()).thenReturn(location);when(location.getBlockY()).thenReturn(64);when(world.getName()).thenReturn(scenario==4?"caladan":"arrakis");when(world.isClearWeather()).thenReturn(true);when(world.getTime()).thenReturn(scenario==3?13000L:1000L);when(world.getHighestBlockYAt(location)).thenReturn(scenario==2?70:64);when(player.isInWater()).thenReturn(scenario==1);when(player.getGameMode()).thenReturn(org.bukkit.GameMode.SURVIVAL); + java.util.Map exposure=new java.util.HashMap<>();exposure.put(id,10);Field f=DuneCore.class.getDeclaredField("sunExposureSeconds");f.setAccessible(true);f.set(core,exposure); + try(var bukkit=mockStatic(org.bukkit.Bukkit.class)){bukkit.when(org.bukkit.Bukkit::getOnlinePlayers).thenReturn(java.util.List.of(player));Method check=DuneCore.class.getDeclaredMethod("checkArrakisSun");check.setAccessible(true);check.invoke(core);} + if(scenario==0)assertEquals(11,exposure.get(id));else assertFalse(exposure.containsKey(id));verify(player,never()).setFireTicks(anyInt()); + } + } }