diff --git a/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java b/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java index a8fe3bb09..205033ba7 100644 --- a/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java +++ b/src/main/java/world/bentobox/bentobox/listeners/JoinLeaveListener.java @@ -53,6 +53,10 @@ public void onPlayerJoin(final PlayerJoinEvent event) { // plugins return; } + // Set the addon in the User object - required to have the right context for prefixes in translations + plugin.getIWM().getAddon(event.getPlayer().getWorld()).ifPresent(gm -> user.setAddon(gm)); + + // Get the UUID UUID playerUUID = event.getPlayer().getUniqueId(); // Check if player hasn't joined before diff --git a/src/test/java/world/bentobox/bentobox/listeners/JoinLeaveListenerTest.java b/src/test/java/world/bentobox/bentobox/listeners/JoinLeaveListenerTest.java index 9929cba8f..72b131033 100644 --- a/src/test/java/world/bentobox/bentobox/listeners/JoinLeaveListenerTest.java +++ b/src/test/java/world/bentobox/bentobox/listeners/JoinLeaveListenerTest.java @@ -43,6 +43,7 @@ import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.RanksManagerBeforeClassTest; import world.bentobox.bentobox.Settings; +import world.bentobox.bentobox.api.addons.AddonDescription; import world.bentobox.bentobox.api.addons.GameModeAddon; import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.database.objects.Island; @@ -91,6 +92,8 @@ public class JoinLeaveListenerTest extends RanksManagerBeforeClassTest { @Mock private AddonsManager am; + private AddonDescription desc; + /** */ @Before @@ -107,6 +110,8 @@ public void setUp() throws Exception { when(iwm.isOnLeaveResetInventory(any())).thenReturn(true); when(iwm.getOverWorlds()).thenReturn(Collections.singletonList(world)); when(iwm.getResetEpoch(any())).thenReturn(20L); + desc = new AddonDescription.Builder("main", "BSkyBlock", "1.0.0").build(); + when(gameMode.getDescription()).thenReturn(desc); Optional opGm = Optional.of(gameMode); when(iwm.getAddon(any())).thenReturn(opGm); when(gameMode.getPermissionPrefix()).thenReturn("acidisland.");