use of fr.xephi.authme.data.limbo.LimboService in project AuthMeReloaded by AuthMe.
the class DebugSectionUtilsTest method shouldHandleErrorGracefully.
@Test
public void shouldHandleErrorGracefully() {
// given
LimboService limboService = mock(LimboService.class);
Map<String, LimboPlayer> limboMap = new HashMap<>();
ReflectionTestUtils.setField(LimboService.class, limboService, "entries", limboMap);
// when
Object result = DebugSectionUtils.applyToLimboPlayersMap(limboService, map -> {
throw new IllegalStateException();
});
// then
assertThat(result, nullValue());
}
use of fr.xephi.authme.data.limbo.LimboService in project AuthMeReloaded by AuthMe.
the class LimboPlayerViewer method execute.
@Override
public void execute(CommandSender sender, List<String> arguments) {
if (arguments.isEmpty()) {
sender.sendMessage(ChatColor.BLUE + "AuthMe limbo viewer");
sender.sendMessage("/authme debug limbo <player>: show a player's limbo info");
sender.sendMessage("Available limbo records: " + applyToLimboPlayersMap(limboService, Map::keySet));
return;
}
LimboPlayer memoryLimbo = limboService.getLimboPlayer(arguments.get(0));
Player player = bukkitService.getPlayerExact(arguments.get(0));
LimboPlayer diskLimbo = player != null ? limboPersistence.getLimboPlayer(player) : null;
if (memoryLimbo == null && player == null) {
sender.sendMessage(ChatColor.BLUE + "No AuthMe limbo data");
sender.sendMessage("No limbo data and no player online with name '" + arguments.get(0) + "'");
return;
}
sender.sendMessage(ChatColor.BLUE + "Player / limbo / disk limbo info for '" + arguments.get(0) + "'");
new InfoDisplayer(sender, player, memoryLimbo, diskLimbo).sendEntry("Is op", Player::isOp, LimboPlayer::isOperator).sendEntry("Walk speed", Player::getWalkSpeed, LimboPlayer::getWalkSpeed).sendEntry("Can fly", Player::getAllowFlight, LimboPlayer::isCanFly).sendEntry("Fly speed", Player::getFlySpeed, LimboPlayer::getFlySpeed).sendEntry("Location", p -> formatLocation(p.getLocation()), l -> formatLocation(l.getLocation())).sendEntry("Prim. group", p -> permissionsManager.hasGroupSupport() ? permissionsManager.getPrimaryGroup(p) : "N/A", LimboPlayer::getGroups);
}
use of fr.xephi.authme.data.limbo.LimboService in project AuthMeReloaded by AuthMe.
the class DebugSectionUtilsTest method shouldFetchMapInLimboService.
@Test
public void shouldFetchMapInLimboService() {
// given
LimboService limboService = mock(LimboService.class);
Map<String, LimboPlayer> limboMap = new HashMap<>();
ReflectionTestUtils.setField(LimboService.class, limboService, "entries", limboMap);
// when
Map map = DebugSectionUtils.applyToLimboPlayersMap(limboService, Function.identity());
// then
assertThat(map, sameInstance(limboMap));
}
Aggregations