Skip to content
This repository has been archived by the owner on Feb 3, 2024. It is now read-only.

Commit

Permalink
Only store last login time for non-virtual players. Fixes #1639
Browse files Browse the repository at this point in the history
  • Loading branch information
zml committed Sep 2, 2014
1 parent af6e716 commit 6e361c3
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions src/main/java/ru/tehkode/permissions/bukkit/PermissionsEx.java
Original file line number Diff line number Diff line change
Expand Up @@ -428,15 +428,16 @@ public void onAsyncPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
public void onPlayerLogin(PlayerJoinEvent event) {
try {
PermissionUser user = getPermissionsManager().getUser(event.getPlayer());
if (!user.isVirtual() && !event.getPlayer().getName().equals(user.getOption("name"))) { // Update name only if user exists in config
user.setOption("name", event.getPlayer().getName());
}
if (!config.shouldLogPlayers()) {
return;
if (!user.isVirtual()) {
if (!event.getPlayer().getName().equals(user.getOption("name"))) { // Update name only if user exists in config
user.setOption("name", event.getPlayer().getName());
}
if (!config.shouldLogPlayers()) {
return;
}
user.setOption("last-login-time", Long.toString(System.currentTimeMillis() / 1000L));
// user.setOption("last-login-ip", event.getPlayer().getAddress().getAddress().getHostAddress()); // somehow this won't work
}

user.setOption("last-login-time", Long.toString(System.currentTimeMillis() / 1000L));
// user.setOption("last-login-ip", event.getPlayer().getAddress().getAddress().getHostAddress()); // somehow this won't work
} catch (Throwable t) {
ErrorReport.handleError("While login cleanup event", t);
}
Expand All @@ -445,17 +446,15 @@ public void onPlayerLogin(PlayerJoinEvent event) {
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
try {

PermissionUser user = getPermissionsManager().getUser(event.getPlayer());
if (config.shouldLogPlayers()) {
user.setOption("last-logout-time", Long.toString(System.currentTimeMillis() / 1000L));
}

if (!user.isVirtual()) {
if (config.shouldLogPlayers()) {
user.setOption("last-logout-time", Long.toString(System.currentTimeMillis() / 1000L));
}

user.getName(); // Set name if user was created during server run
}

getPermissionsManager().resetUser(event.getPlayer());
getPermissionsManager().resetUser(event.getPlayer());
} catch (Throwable t) {
ErrorReport.handleError("While logout cleanup event", t);
}
Expand Down

0 comments on commit 6e361c3

Please sign in to comment.