diff --git a/src/main/java/world/bentobox/bentobox/api/user/User.java b/src/main/java/world/bentobox/bentobox/api/user/User.java index 7d0e4f12a..8e7c32260 100644 --- a/src/main/java/world/bentobox/bentobox/api/user/User.java +++ b/src/main/java/world/bentobox/bentobox/api/user/User.java @@ -527,9 +527,10 @@ public class User implements MetaDataAble { // Replace game mode and friendly name in general // Replace the [gamemode] text variable - translation = translation.replace("[gamemode]", - addon != null ? addon.getDescription().getName() : "[gamemode]"); - if (getWorld() != null) { + if (addon != null && addon.getDescription() != null) { + translation = translation.replace("[gamemode]", addon.getDescription().getName()); + } + if (player != null && player.getWorld() != null) { // Replace the [friendly_name] text variable translation = translation.replace("[friendly_name]", isPlayer() ? plugin.getIWM().getFriendlyName(getWorld()) : "[friendly_name]"); diff --git a/src/test/java/world/bentobox/bentobox/api/commands/island/IslandSpawnCommandTest.java b/src/test/java/world/bentobox/bentobox/api/commands/island/IslandSpawnCommandTest.java index 417d6cc65..3a5e73426 100644 --- a/src/test/java/world/bentobox/bentobox/api/commands/island/IslandSpawnCommandTest.java +++ b/src/test/java/world/bentobox/bentobox/api/commands/island/IslandSpawnCommandTest.java @@ -127,6 +127,7 @@ public class IslandSpawnCommandTest { when(plugin.getSettings()).thenReturn(s); // IWM + when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock"); when(plugin.getIWM()).thenReturn(iwm); when(iwm.getWorldSettings(any())).thenReturn(ws); map = new HashMap<>(); diff --git a/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamLeaveCommandTest.java b/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamLeaveCommandTest.java index 7fcd5638b..465d20c58 100644 --- a/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamLeaveCommandTest.java +++ b/src/test/java/world/bentobox/bentobox/api/commands/island/team/IslandTeamLeaveCommandTest.java @@ -120,6 +120,7 @@ public class IslandTeamLeaveCommandTest { when(Bukkit.getScheduler()).thenReturn(sch); // Island World Manager + when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock"); when(plugin.getIWM()).thenReturn(iwm); // Plugin Manager diff --git a/src/test/java/world/bentobox/bentobox/api/user/UserTest.java b/src/test/java/world/bentobox/bentobox/api/user/UserTest.java index 1500e5f46..ca6775329 100644 --- a/src/test/java/world/bentobox/bentobox/api/user/UserTest.java +++ b/src/test/java/world/bentobox/bentobox/api/user/UserTest.java @@ -935,7 +935,7 @@ public class UserTest { when(addon.getDescription()).thenReturn(new Builder("main", "gameAddon", "1.0").build()); p.setAddon(addon); p.getTranslation(TEST_TRANSLATION); - verify(addon, times(2)).getDescription(); + verify(addon, times(3)).getDescription(); } /** diff --git a/src/test/java/world/bentobox/bentobox/listeners/BannedCommandsTest.java b/src/test/java/world/bentobox/bentobox/listeners/BannedCommandsTest.java index 1af8737bc..702ba1739 100644 --- a/src/test/java/world/bentobox/bentobox/listeners/BannedCommandsTest.java +++ b/src/test/java/world/bentobox/bentobox/listeners/BannedCommandsTest.java @@ -77,6 +77,7 @@ public class BannedCommandsTest { when(iwm.getPermissionPrefix(any())).thenReturn("bskyblock."); when(iwm.getVisitorBannedCommands(any())).thenReturn(new ArrayList<>()); when(iwm.getFallingBannedCommands(any())).thenReturn(new ArrayList<>()); + when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock"); WorldSettings ws = new MyWorldSettings(); when(iwm.getWorldSettings(any())).thenReturn(ws); when(plugin.getIWM()).thenReturn(iwm); diff --git a/src/test/java/world/bentobox/bentobox/listeners/JoinLeaveListenerTest.java b/src/test/java/world/bentobox/bentobox/listeners/JoinLeaveListenerTest.java index 43a8b1e1e..431de3936 100644 --- a/src/test/java/world/bentobox/bentobox/listeners/JoinLeaveListenerTest.java +++ b/src/test/java/world/bentobox/bentobox/listeners/JoinLeaveListenerTest.java @@ -134,6 +134,7 @@ public class JoinLeaveListenerTest { when(iwm.getAddon(any())).thenReturn(opGm); when(gameMode.getPermissionPrefix()).thenReturn("acidisland."); when(iwm.getIslandDistance(any())).thenReturn(100); + when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock"); UUID uuid = UUID.randomUUID(); // Player diff --git a/src/test/java/world/bentobox/bentobox/listeners/StandardSpawnProtectionListenerTest.java b/src/test/java/world/bentobox/bentobox/listeners/StandardSpawnProtectionListenerTest.java index ca550760f..b0e48b3f6 100644 --- a/src/test/java/world/bentobox/bentobox/listeners/StandardSpawnProtectionListenerTest.java +++ b/src/test/java/world/bentobox/bentobox/listeners/StandardSpawnProtectionListenerTest.java @@ -110,6 +110,7 @@ public class StandardSpawnProtectionListenerTest extends AbstractCommonSetup { when(iwm.inWorld(any(World.class))).thenReturn(true); when(iwm.getNetherSpawnRadius(any())).thenReturn(25); when(iwm.getWorldSettings(any())).thenReturn(ws); + when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock"); // Util PowerMockito.mockStatic(Util.class); when(Util.getWorld(any())).thenReturn(world); diff --git a/src/test/java/world/bentobox/bentobox/listeners/flags/AbstractCommonSetup.java b/src/test/java/world/bentobox/bentobox/listeners/flags/AbstractCommonSetup.java index d4443627e..8bb864e37 100644 --- a/src/test/java/world/bentobox/bentobox/listeners/flags/AbstractCommonSetup.java +++ b/src/test/java/world/bentobox/bentobox/listeners/flags/AbstractCommonSetup.java @@ -138,6 +138,7 @@ public abstract class AbstractCommonSetup { when(plugin.getIWM()).thenReturn(iwm); when(iwm.inWorld(any(Location.class))).thenReturn(true); when(iwm.inWorld(any(World.class))).thenReturn(true); + when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock"); // Addon when(iwm.getAddon(any())).thenReturn(Optional.empty()); diff --git a/src/test/java/world/bentobox/bentobox/listeners/flags/settings/PVPListenerTest.java b/src/test/java/world/bentobox/bentobox/listeners/flags/settings/PVPListenerTest.java index 10c48be30..146b5b249 100644 --- a/src/test/java/world/bentobox/bentobox/listeners/flags/settings/PVPListenerTest.java +++ b/src/test/java/world/bentobox/bentobox/listeners/flags/settings/PVPListenerTest.java @@ -136,6 +136,7 @@ public class PVPListenerTest { when(iwm.inWorld(any(World.class))).thenReturn(true); when(iwm.inWorld(any(Location.class))).thenReturn(true); when(iwm.getPermissionPrefix(Mockito.any())).thenReturn("bskyblock."); + when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock"); // No visitor protection right now when(iwm.getIvSettings(any())).thenReturn(new ArrayList<>()); when(plugin.getIWM()).thenReturn(iwm); diff --git a/src/test/java/world/bentobox/bentobox/listeners/flags/worldsettings/ObsidianScoopingListenerTest.java b/src/test/java/world/bentobox/bentobox/listeners/flags/worldsettings/ObsidianScoopingListenerTest.java index 8804778fd..e4165e258 100644 --- a/src/test/java/world/bentobox/bentobox/listeners/flags/worldsettings/ObsidianScoopingListenerTest.java +++ b/src/test/java/world/bentobox/bentobox/listeners/flags/worldsettings/ObsidianScoopingListenerTest.java @@ -114,6 +114,7 @@ public class ObsidianScoopingListenerTest { when(iwm.getIslandWorld(Mockito.any())).thenReturn(world); when(iwm.getNetherWorld(Mockito.any())).thenReturn(world); when(iwm.getEndWorld(Mockito.any())).thenReturn(world); + when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock"); // Mock up IslandsManager when(plugin.getIslands()).thenReturn(im);