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 5fa729e2f..ba0dc489f 100644 --- a/src/main/java/world/bentobox/bentobox/api/user/User.java +++ b/src/main/java/world/bentobox/bentobox/api/user/User.java @@ -291,6 +291,9 @@ public class User { * @return max value */ public int getPermissionValue(String permissionPrefix, int defaultValue) { + // If requester is console, then return the default value + if (!isPlayer()) return defaultValue; + int value = defaultValue; // If there is a dot at the end of the permissionPrefix, remove it diff --git a/src/test/java/world/bentobox/bentobox/api/commands/island/CustomIslandMultiHomeHelpTest.java b/src/test/java/world/bentobox/bentobox/api/commands/island/CustomIslandMultiHomeHelpTest.java index cb98a092d..c53adbb9f 100644 --- a/src/test/java/world/bentobox/bentobox/api/commands/island/CustomIslandMultiHomeHelpTest.java +++ b/src/test/java/world/bentobox/bentobox/api/commands/island/CustomIslandMultiHomeHelpTest.java @@ -3,11 +3,11 @@ package world.bentobox.bentobox.api.commands.island; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; -import static org.mockito.Mockito.any; -import static org.mockito.Mockito.anyString; import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import java.util.Collections; import java.util.HashMap; @@ -48,6 +48,8 @@ public class CustomIslandMultiHomeHelpTest { @Mock private User user; private CustomIslandMultiHomeHelp ch; + @Mock + private IslandWorldManager iwm; /** * @throws java.lang.Exception @@ -106,9 +108,11 @@ public class CustomIslandMultiHomeHelpTest { when(Bukkit.getScheduler()).thenReturn(sch); // IWM friendly name - IslandWorldManager iwm = mock(IslandWorldManager.class); when(iwm.getFriendlyName(any())).thenReturn("BSkyBlock"); when(plugin.getIWM()).thenReturn(iwm); + + // Locales + // Command ch = new CustomIslandMultiHomeHelp(ic); @@ -194,5 +198,5 @@ public class CustomIslandMultiHomeHelpTest { "description" ); } - + } 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 de86d3c42..68b1f9005 100644 --- a/src/test/java/world/bentobox/bentobox/api/user/UserTest.java +++ b/src/test/java/world/bentobox/bentobox/api/user/UserTest.java @@ -5,8 +5,8 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -481,6 +481,16 @@ public class UserTest { assertEquals(33, u.getPermissionValue("bskyblock.max", 2)); } + /** + * Test for {@link User#getPermissionValue(String, int)} + */ + @Test + public void testGetPermissionValueConsole() { + User.clearUsers(); + CommandSender console = mock(CommandSender.class); + User u = User.getInstance(console); + assertEquals(35, u.getPermissionValue("bskyblock.max", 35)); + } /** * Test for {@link User#getPermissionValue(String, int)}