Fixed NPE on manage remove command if player was not online (Remove was still successful)

This commit is contained in:
Rsl1122 2017-10-03 10:35:11 +03:00
parent 9447bb812b
commit 4784d6f035
2 changed files with 9 additions and 8 deletions

View File

@ -93,9 +93,10 @@ public class ManageRemoveCommand extends SubCommand {
DataCache dataCache = plugin.getDataCache();
Player player = getPlayer(uuid);
dataCache.getActiveSessions().remove(uuid);
dataCache.cacheSession(uuid, new Session(MiscUtils.getTime(), player.getWorld().getName(), player.getGameMode().name()));
if (player != null) {
dataCache.getActiveSessions().remove(uuid);
dataCache.cacheSession(uuid, new Session(MiscUtils.getTime(), player.getWorld().getName(), player.getGameMode().name()));
}
sender.sendMessage(Locale.get(Msg.MANAGE_INFO_REMOVE_SUCCESS).parse(playerName, plugin.getDB().getConfigName()));
} catch (SQLException e) {
Log.toLog(this.getClass().getName(), e);

View File

@ -34,12 +34,12 @@ public class SessionCache {
}
public void endSession(UUID uuid, long time) {
Session session = activeSessions.get(uuid);
if (session == null) {
return;
}
session.endSession(time);
try {
Session session = activeSessions.get(uuid);
if (session == null) {
return;
}
session.endSession(time);
plugin.getDB().getSessionsTable().saveSession(uuid, session);
} catch (SQLException e) {
Log.toLog(this.getClass().getName(), e);