Skip to content

Commit

Permalink
Fixed the ENDER_CHEST flag not using the Notifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Poslovitch committed Nov 11, 2018
1 parent 23af6e7 commit c3ca82e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -114,6 +116,9 @@ public void setUp() throws Exception {
when(plugin.getLocalesManager()).thenReturn(lm);
when(lm.get(any(), any())).thenAnswer((Answer<String>) invocation -> invocation.getArgumentAt(1, String.class));

// Notifier
notifier = mock(Notifier.class);
when(plugin.getNotifier()).thenReturn(notifier);
}

@Test
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c3ca82e

Please sign in to comment.