mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-20 09:15:11 +01:00
#1008 Check that OfflinePlayer's name is not null
- Add check - Create test
This commit is contained in:
parent
30343d7587
commit
dda7bd5cb5
@ -72,7 +72,7 @@ class PurgeTask extends BukkitRunnable {
|
||||
}
|
||||
|
||||
OfflinePlayer offlinePlayer = offlinePlayers[nextPosition];
|
||||
if (toPurge.remove(offlinePlayer.getName().toLowerCase())) {
|
||||
if (offlinePlayer.getName() != null && toPurge.remove(offlinePlayer.getName().toLowerCase())) {
|
||||
if (!permissionsManager.hasPermissionOffline(offlinePlayer, PlayerStatePermission.BYPASS_PURGE)) {
|
||||
playerPortion.add(offlinePlayer);
|
||||
namePortion.add(offlinePlayer.getName());
|
||||
|
@ -124,6 +124,27 @@ public class PurgeTaskTest {
|
||||
assertRanPurgeWithNames("foxtrot");
|
||||
}
|
||||
|
||||
/**
|
||||
* #1008: OfflinePlayer#getName may return null.
|
||||
*/
|
||||
@Test
|
||||
public void shouldHandleOfflinePlayerWithNullName() {
|
||||
// given
|
||||
Set<String> names = newHashSet("name1", "name2");
|
||||
OfflinePlayer[] players = asArray(
|
||||
mockOfflinePlayer(null, false), mockOfflinePlayer("charlie", false), mockOfflinePlayer("name1", false));
|
||||
reset(purgeService, permissionsManager);
|
||||
setPermissionsBehavior();
|
||||
|
||||
PurgeTask task = new PurgeTask(purgeService, permissionsManager, null, names, players);
|
||||
|
||||
// when
|
||||
task.run();
|
||||
|
||||
// then
|
||||
assertRanPurgeWithPlayers(players[2]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldStopTaskAndInformSenderUponCompletion() {
|
||||
// given
|
||||
|
Loading…
Reference in New Issue
Block a user