mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-12-30 18:08:24 +01:00
Fixed player disconnections not being logged on server shutdown
This commit is contained in:
parent
6a978128af
commit
40561e41c0
@ -4,6 +4,7 @@ import java.io.File;
|
|||||||
|
|
||||||
import org.bstats.bukkit.MetricsLite;
|
import org.bstats.bukkit.MetricsLite;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
@ -17,6 +18,7 @@ import net.coreprotect.database.Database;
|
|||||||
import net.coreprotect.language.Language;
|
import net.coreprotect.language.Language;
|
||||||
import net.coreprotect.language.Phrase;
|
import net.coreprotect.language.Phrase;
|
||||||
import net.coreprotect.listener.ListenerHandler;
|
import net.coreprotect.listener.ListenerHandler;
|
||||||
|
import net.coreprotect.listener.player.PlayerQuitListener;
|
||||||
import net.coreprotect.thread.CacheHandler;
|
import net.coreprotect.thread.CacheHandler;
|
||||||
import net.coreprotect.thread.NetworkHandler;
|
import net.coreprotect.thread.NetworkHandler;
|
||||||
import net.coreprotect.utility.Chat;
|
import net.coreprotect.utility.Chat;
|
||||||
@ -158,6 +160,13 @@ public final class CoreProtect extends JavaPlugin {
|
|||||||
|
|
||||||
private static void safeShutdown(CoreProtect plugin) {
|
private static void safeShutdown(CoreProtect plugin) {
|
||||||
try {
|
try {
|
||||||
|
/* if server is stopping, log disconnections of online players */
|
||||||
|
if (plugin.getServer().isStopping()) {
|
||||||
|
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||||
|
PlayerQuitListener.queuePlayerQuit(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ConfigHandler.serverRunning = false;
|
ConfigHandler.serverRunning = false;
|
||||||
long shutdownTime = System.currentTimeMillis();
|
long shutdownTime = System.currentTimeMillis();
|
||||||
long alertTime = shutdownTime + (10 * 1000);
|
long alertTime = shutdownTime + (10 * 1000);
|
||||||
|
@ -11,12 +11,16 @@ import net.coreprotect.consumer.Queue;
|
|||||||
|
|
||||||
public final class PlayerQuitListener extends Queue implements Listener {
|
public final class PlayerQuitListener extends Queue implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
public static void queuePlayerQuit(Player player) {
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
if (Config.getConfig(player.getWorld()).PLAYER_SESSIONS) {
|
if (Config.getConfig(player.getWorld()).PLAYER_SESSIONS) {
|
||||||
int time = (int) (System.currentTimeMillis() / 1000L);
|
int time = (int) (System.currentTimeMillis() / 1000L);
|
||||||
Queue.queuePlayerQuit(player, time);
|
Queue.queuePlayerQuit(player, time);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
queuePlayerQuit(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user