mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-19 00:35:20 +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.AuthMePlayerListener16;
|
||||||
import fr.xephi.authme.listener.AuthMePlayerListener18;
|
import fr.xephi.authme.listener.AuthMePlayerListener18;
|
||||||
import fr.xephi.authme.listener.AuthMeServerListener;
|
import fr.xephi.authme.listener.AuthMeServerListener;
|
||||||
|
import fr.xephi.authme.listener.AuthMeServerStop;
|
||||||
import fr.xephi.authme.modules.ModuleManager;
|
import fr.xephi.authme.modules.ModuleManager;
|
||||||
import fr.xephi.authme.output.ConsoleFilter;
|
import fr.xephi.authme.output.ConsoleFilter;
|
||||||
import fr.xephi.authme.output.Log4JFilter;
|
import fr.xephi.authme.output.Log4JFilter;
|
||||||
@ -288,6 +289,13 @@ public class AuthMe extends JavaPlugin {
|
|||||||
// Show settings warnings
|
// Show settings warnings
|
||||||
showSettingsWarnings();
|
showSettingsWarnings();
|
||||||
|
|
||||||
|
// Register a server shutdown hook
|
||||||
|
try {
|
||||||
|
Runtime.getRuntime().addShutdownHook(new AuthMeServerStop(this));
|
||||||
|
} catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
// Sponsor messages
|
// Sponsor messages
|
||||||
ConsoleLogger.info("AuthMe hooks perfectly with the VeryGames server hosting!");
|
ConsoleLogger.info("AuthMe hooks perfectly with the VeryGames server hosting!");
|
||||||
ConsoleLogger.info("Development builds are available on our jenkins, thanks to f14stelt.");
|
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,
|
enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
|
||||||
broadcastWelcomeMessage, forceRegKick, forceRegLogin,
|
broadcastWelcomeMessage, forceRegKick, forceRegLogin,
|
||||||
checkVeryGames, delayJoinLeaveMessages, noTeleport, applyBlindEffect,
|
checkVeryGames, delayJoinLeaveMessages, noTeleport, applyBlindEffect,
|
||||||
|
kickPlayersBeforeStoping,
|
||||||
customAttributes, generateImage, isRemoveSpeedEnabled, preventOtherCase;
|
customAttributes, generateImage, isRemoveSpeedEnabled, preventOtherCase;
|
||||||
public static String helpHeader, getNickRegex, getUnloggedinGroup, getMySQLHost,
|
public static String helpHeader, getNickRegex, getUnloggedinGroup, getMySQLHost,
|
||||||
getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase,
|
getMySQLPort, getMySQLUsername, getMySQLPassword, getMySQLDatabase,
|
||||||
@ -300,6 +301,7 @@ public final class Settings {
|
|||||||
customAttributes = configFile.getBoolean("Hooks.customAttributes");
|
customAttributes = configFile.getBoolean("Hooks.customAttributes");
|
||||||
generateImage = configFile.getBoolean("Email.generateImage", false);
|
generateImage = configFile.getBoolean("Email.generateImage", false);
|
||||||
preventOtherCase = configFile.getBoolean("settings.preventOtherCase", false);
|
preventOtherCase = configFile.getBoolean("settings.preventOtherCase", false);
|
||||||
|
kickPlayersBeforeStoping = configFile.getBoolean("Security.stop.kickPlayersBeforeStoping", true);
|
||||||
|
|
||||||
// Load the welcome message
|
// Load the welcome message
|
||||||
getWelcomeMessage();
|
getWelcomeMessage();
|
||||||
@ -727,6 +729,11 @@ public final class Settings {
|
|||||||
ConsoleLogger.showError("Remove Email.mailText from config, we now use the email.html file");
|
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) {
|
if (changes) {
|
||||||
plugin.getLogger().warning("Merged new Config Options - I'm not an error, please don't report me");
|
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!");
|
plugin.getLogger().warning("Please check your config.yml file for new configs!");
|
||||||
|
@ -316,6 +316,10 @@ Security:
|
|||||||
maxLoginTry: 5
|
maxLoginTry: 5
|
||||||
# Captcha length
|
# Captcha length
|
||||||
captchaLength: 5
|
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:
|
Converter:
|
||||||
Rakamak:
|
Rakamak:
|
||||||
# Rakamak file name
|
# Rakamak file name
|
||||||
|
Loading…
Reference in New Issue
Block a user