Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Folia support #2701

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Fix quit events
  • Loading branch information
cavallium committed Jul 8, 2023
commit 878f81f86f0008f1001dbf367bdd6efb5d3aab0b
26 changes: 15 additions & 11 deletions src/main/java/fr/xephi/authme/process/SyncProcessManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,23 @@ public void processSyncPlayerLogin(Player player, boolean isFirstLogin, List<Str
}

public void processSyncPlayerQuit(Player player, boolean wasLoggedIn) {
runTask("PlayerQuit", player, () -> processSyncPlayerQuit.processSyncQuit(player, wasLoggedIn));
runTask("PlayerQuit", null, () -> processSyncPlayerQuit.processSyncQuit(player, wasLoggedIn));
}

private void runTask(String taskName, Entity entity, Runnable runnable) {
bukkitService.executeOptionallyOnEntityScheduler(entity, runnable, () -> {
String entityName;
try {
entityName = entity.getName();
} catch (Exception ex) {
entityName = "<none>";
}
// todo: should the tasks be executed anyway or not? I left this warning message to remind about this doubt.
logger.warning("Task " + taskName + " has not been executed because the entity " + entityName + " is not available anymore.");
});
if (entity == null) {
bukkitService.runOnGlobalRegionScheduler(task -> runnable.run());
} else {
bukkitService.executeOptionallyOnEntityScheduler(entity, runnable, () -> {
String entityName;
try {
entityName = entity.getName();
} catch (Exception ex) {
entityName = "<none>";
}
// todo: should the tasks be executed anyway or not? I left this warning message to remind about this doubt.
logger.warning("Task " + taskName + " has not been executed because the entity " + entityName + " is not available anymore.");
});
}
}
}