mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-23 11:15:24 +01:00
Fix for console error when using the player command in console
https://github.com/BentoBoxWorld/BentoBox/issues/886
This commit is contained in:
parent
e6fd6e02b7
commit
21fd9e9e1a
@ -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
|
||||
|
@ -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,10 +108,12 @@ 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);
|
||||
}
|
||||
|
@ -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)}
|
||||
|
Loading…
Reference in New Issue
Block a user