From c3ca82e12a2c4d2d626ab75c45ec3468db8fa09f Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Sun, 11 Nov 2018 10:37:08 +0100 Subject: [PATCH] Fixed the ENDER_CHEST flag not using the Notifier --- .../bentobox/listeners/flags/EnderChestListener.java | 2 +- .../bentobox/listeners/flags/EnderChestListenerTest.java | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/listeners/flags/EnderChestListener.java b/src/main/java/world/bentobox/bentobox/listeners/flags/EnderChestListener.java index e912d8479..63581946c 100644 --- a/src/main/java/world/bentobox/bentobox/listeners/flags/EnderChestListener.java +++ b/src/main/java/world/bentobox/bentobox/listeners/flags/EnderChestListener.java @@ -52,7 +52,7 @@ && getIWM().inWorld(player.getLocation()) && !Flags.ENDER_CHEST.isSetForWorld(player.getWorld())) { // Not allowed User user = User.getInstance(player); - user.sendMessage("protection.protected", TextVariables.DESCRIPTION, user.getTranslation(Flags.ENDER_CHEST.getHintReference())); + user.notify("protection.protected", TextVariables.DESCRIPTION, user.getTranslation(Flags.ENDER_CHEST.getHintReference())); return true; } return false; diff --git a/src/test/java/world/bentobox/bentobox/listeners/flags/EnderChestListenerTest.java b/src/test/java/world/bentobox/bentobox/listeners/flags/EnderChestListenerTest.java index 0881e12f3..d17997007 100644 --- a/src/test/java/world/bentobox/bentobox/listeners/flags/EnderChestListenerTest.java +++ b/src/test/java/world/bentobox/bentobox/listeners/flags/EnderChestListenerTest.java @@ -39,6 +39,7 @@ import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.api.configuration.WorldSettings; +import world.bentobox.bentobox.api.user.Notifier; import world.bentobox.bentobox.api.user.User; import world.bentobox.bentobox.database.objects.Island; import world.bentobox.bentobox.lists.Flags; @@ -54,6 +55,7 @@ public class EnderChestListenerTest { private World world; private Player player; private IslandWorldManager iwm; + private Notifier notifier; @Before public void setUp() throws Exception { @@ -114,6 +116,9 @@ public void setUp() throws Exception { when(plugin.getLocalesManager()).thenReturn(lm); when(lm.get(any(), any())).thenAnswer((Answer) invocation -> invocation.getArgumentAt(1, String.class)); + // Notifier + notifier = mock(Notifier.class); + when(plugin.getNotifier()).thenReturn(notifier); } @Test @@ -208,7 +213,7 @@ public void testOnEnderChestOpenEnderChestBlocked() { Flags.ENDER_CHEST.setSetting(world, false); new EnderChestListener().onEnderChestOpen(e); assertTrue(e.isCancelled()); - Mockito.verify(player).sendMessage("protection.protected"); + Mockito.verify(notifier).notify(Mockito.anyObject(), Mockito.eq("protection.protected")); } @Test