Fix NPE when gamemode is null on Mohist

This commit is contained in:
Aurora Lahtela 2021-11-19 17:10:47 +02:00 committed by GitHub
parent 4bb6c9f978
commit 2f78f5528e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,6 +51,7 @@ import javax.inject.Inject;
import java.net.InetAddress;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional
import java.util.UUID;
import java.util.function.Supplier;
@ -165,7 +166,7 @@ public class PlayerOnlineListener implements Listener {
BukkitAFKListener.afkTracker.performedAction(playerUUID, time);
String world = player.getWorld().getName();
String gm = player.getGameMode().name();
String gm = Optional.of(player.getGameMode()).map(gameMode -> gameMode.name()).orElse("Unknown");
Database database = dbSystem.getDatabase();
database.executeTransaction(new WorldNameStoreTransaction(serverUUID, world));