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];
|
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)) {
|
if (!permissionsManager.hasPermissionOffline(offlinePlayer, PlayerStatePermission.BYPASS_PURGE)) {
|
||||||
playerPortion.add(offlinePlayer);
|
playerPortion.add(offlinePlayer);
|
||||||
namePortion.add(offlinePlayer.getName());
|
namePortion.add(offlinePlayer.getName());
|
||||||
|
@ -124,6 +124,27 @@ public class PurgeTaskTest {
|
|||||||
assertRanPurgeWithNames("foxtrot");
|
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
|
@Test
|
||||||
public void shouldStopTaskAndInformSenderUponCompletion() {
|
public void shouldStopTaskAndInformSenderUponCompletion() {
|
||||||
// given
|
// given
|
||||||
|
Loading…
Reference in New Issue
Block a user