mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-19 07:07:55 +01:00
Add a way to kick players before a server stop
This commit is contained in:
parent
5c2547cd82
commit
e272a3bfb5
@ -27,6 +27,7 @@ import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||
import fr.xephi.authme.listener.AuthMePlayerListener16;
|
||||
import fr.xephi.authme.listener.AuthMePlayerListener18;
|
||||
import fr.xephi.authme.listener.AuthMeServerListener;
|
||||
import fr.xephi.authme.listener.AuthMeServerStop;
|
||||
import fr.xephi.authme.modules.ModuleManager;
|
||||
import fr.xephi.authme.output.ConsoleFilter;
|
||||
import fr.xephi.authme.output.Log4JFilter;
|
||||
@ -288,6 +289,13 @@ public class AuthMe extends JavaPlugin {
|
||||
// Show settings warnings
|
||||
showSettingsWarnings();
|
||||
|
||||
// Register a server shutdown hook
|
||||
try {
|
||||
Runtime.getRuntime().addShutdownHook(new AuthMeServerStop(this));
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Sponsor messages
|
||||
ConsoleLogger.info("AuthMe hooks perfectly with the VeryGames server hosting!");
|
||||
ConsoleLogger.info("Development builds are available on our jenkins, thanks to f14stelt.");
|
||||
|
23
src/main/java/fr/xephi/authme/listener/AuthMeServerStop.java
Normal file
23
src/main/java/fr/xephi/authme/listener/AuthMeServerStop.java
Normal file
@ -0,0 +1,23 @@
|
||||
package fr.xephi.authme.listener;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
public class AuthMeServerStop extends Thread {
|
||||
|
||||
private AuthMe plugin;
|
||||
|
||||
public AuthMeServerStop(AuthMe plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
// TODO: add a MessageKey
|
||||
if (Settings.kickPlayersBeforeStoping)
|
||||
for (Player p : plugin.getServer().getOnlinePlayers())
|
||||
p.kickPlayer("Server is restarting");
|
||||
}
|
||||
}
|
@ -79,6 +79,7 @@ public final class Settings {
|
||||
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
|
||||
broadcastWelcomeMessage, forceRegKick, forceRegLogin,
|
||||
checkVeryGames, delayJoinLeaveMessages, noTeleport, applyBlindEffect,
|
||||
kickPlayersBeforeStoping,
|
||||
customAttributes, generateImage, isRemoveSpeedEnabled, preventOtherCase;
|
||||
public static String helpHeader, getNickRegex, getUnloggedinGroup, getMySQLHost,
|
||||
getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase,
|
||||
@ -300,6 +301,7 @@ public final class Settings {
|
||||
customAttributes = configFile.getBoolean("Hooks.customAttributes");
|
||||
generateImage = configFile.getBoolean("Email.generateImage", false);
|
||||
preventOtherCase = configFile.getBoolean("settings.preventOtherCase", false);
|
||||
kickPlayersBeforeStoping = configFile.getBoolean("Security.stop.kickPlayersBeforeStoping", true);
|
||||
|
||||
// Load the welcome message
|
||||
getWelcomeMessage();
|
||||
@ -727,6 +729,11 @@ public final class Settings {
|
||||
ConsoleLogger.showError("Remove Email.mailText from config, we now use the email.html file");
|
||||
}
|
||||
|
||||
if (!contains("Security.stop.kickPlayersBeforeStoping")) {
|
||||
set("Security.stop.kickPlayersBeforeStoping", true);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if (changes) {
|
||||
plugin.getLogger().warning("Merged new Config Options - I'm not an error, please don't report me");
|
||||
plugin.getLogger().warning("Please check your config.yml file for new configs!");
|
||||
|
@ -316,6 +316,10 @@ Security:
|
||||
maxLoginTry: 5
|
||||
# Captcha length
|
||||
captchaLength: 5
|
||||
stop:
|
||||
# Kick players before stoping the server, that allow us to save position of players, and all needed
|
||||
# informations correctly without any corruption.
|
||||
kickPlayersBeforeStoping: true
|
||||
Converter:
|
||||
Rakamak:
|
||||
# Rakamak file name
|
||||
|
Loading…
Reference in New Issue
Block a user