Less exceptions when shutting down the server #251

Problem is the CharacterLookupService in AUTHORITY is set to null when the server's shutting down.
When this happens, null pointers occur when looking up players.
This commit is contained in:
Ziggy
2020-07-13 02:57:38 +02:00
parent bfac74bfe6
commit 81885d0849

View File

@@ -143,25 +143,59 @@ public class CharacterLookupService extends Service {
return getCharacterByFirstName(name) != null;
}
@Nullable
public static Player getPlayerByFullName(String name) {
return AUTHORITY.get().getPlayerByFullName(name);
CharacterLookupService characterLookupService = AUTHORITY.get();
if (characterLookupService == null) {
return null;
}
return characterLookupService.getPlayerByFullName(name);
}
@Nullable
public static Player getPlayerByFirstName(String name) {
return AUTHORITY.get().getPlayerByFirstName(name);
CharacterLookupService characterLookupService = AUTHORITY.get();
if (characterLookupService == null) {
return null;
}
return characterLookupService.getPlayerByFirstName(name);
}
@Nullable
public static CreatureObject getCharacterByFullName(String name) {
return AUTHORITY.get().getCharacterByFullName(name);
CharacterLookupService characterLookupService = AUTHORITY.get();
if (characterLookupService == null) {
return null;
}
return characterLookupService.getCharacterByFullName(name);
}
@Nullable
public static CreatureObject getCharacterByFirstName(String name) {
return AUTHORITY.get().getCharacterByFirstName(name);
CharacterLookupService characterLookupService = AUTHORITY.get();
if (characterLookupService == null) {
return null;
}
return characterLookupService.getCharacterByFirstName(name);
}
@Nullable
public static Collection<CreatureObject> getLoggedInCharacters() {
return AUTHORITY.get().getLoggedInCharacters();
CharacterLookupService characterLookupService = AUTHORITY.get();
if (characterLookupService == null) {
return null;
}
return characterLookupService.getLoggedInCharacters();
}
}