增加服务器被关闭时的邮箱通知

This commit is contained in:
Sabrita 2023-02-27 19:57:00 +08:00
parent 4ca879b08a
commit 912646c041
7 changed files with 25 additions and 27 deletions

View File

@ -62,8 +62,8 @@ public class AuthMe extends JavaPlugin {
private static final int CLEANUP_INTERVAL = 5 * TICKS_PER_MINUTE;
// Version and build number values
private static String pluginVersion = "N/D";
private static String pluginBuildNumber = "Unknown";
private static String pluginVersion = "5.6.0";
private static String pluginBuildNumber = "Custom";
// Private instances
private CommandHandler commandHandler;
@ -78,8 +78,6 @@ public class AuthMe extends JavaPlugin {
/**
* Constructor.
*/
public AuthMe() {
}
/*
* Constructor for unit testing.
@ -313,10 +311,10 @@ public class AuthMe extends JavaPlugin {
onShutdownPlayerSaver.saveAllPlayers();
}
if (settings.getProperty(EmailSettings.SHOUTDOWN_MAIL)){
if (settings.getProperty(EmailSettings.SHUTDOWN_MAIL)){
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy'年'MM'月'dd'日' HH:mm:ss");
Date date = new Date(System.currentTimeMillis());
emailService.sendShutDown("wujiaxin752@icloud.com",dateFormat.format(date));
emailService.sendShutDown(settings.getProperty(EmailSettings.SHUTDOWN_MAIL_ADDRESS),dateFormat.format(date));
}
// Do backup on stop if enabled

View File

@ -62,6 +62,7 @@ public class ValidationService implements Reloadable {
restrictedNames = settings.getProperty(RestrictionSettings.ENABLE_RESTRICTED_USERS)
? loadNameRestrictions(settings.getProperty(RestrictionSettings.RESTRICTED_USERS))
: HashMultimap.create();
emailRegex = Utils.safePatternCompile(settings.getProperty(RestrictionSettings.ALLOWED_EMAIL_REGEX));
}

View File

@ -75,8 +75,11 @@ public final class EmailSettings implements SettingsHolder {
public static final Property<String> OAUTH2_TOKEN =
newProperty("Email.emailOauth2Token", "");
@Comment("Email notifications when the server shuts down")
public static final Property<Boolean> SHOUTDOWN_MAIL =
public static final Property<Boolean> SHUTDOWN_MAIL =
newProperty("Email.shutDownEmail", true);
@Comment("Email notification address when the server is shut down")
public static final Property<String> SHUTDOWN_MAIL_ADDRESS =
newProperty("Email.shutDownEmailAddress", "your@mail.com");
private EmailSettings() {
}

View File

@ -18,21 +18,21 @@ public final class PluginSettings implements SettingsHolder {
"expired, he will not need to authenticate."
})
public static final Property<Boolean> SESSIONS_ENABLED =
newProperty("settings.sessions.enabled", false);
newProperty("settings.sessions.enabled", true);
@Comment({
"After how many minutes should a session expire?",
"A player's session ends after the timeout or if his IP has changed"
})
public static final Property<Integer> SESSIONS_TIMEOUT =
newProperty("settings.sessions.timeout", 10);
newProperty("settings.sessions.timeout", 43200);
@Comment({
"Message language, available languages:",
"https://github.com/AuthMe/AuthMeReloaded/blob/master/docs/translations.md"
})
public static final Property<String> MESSAGES_LANGUAGE =
newProperty("settings.messagesLanguage", "en");
newProperty("settings.messagesLanguage", "zhcn");
@Comment({
"Enables switching a player to defined permission groups before they log in.",

View File

@ -14,7 +14,7 @@ public final class ProtectionSettings implements SettingsHolder {
@Comment("Enable some servers protection (country based login, antibot)")
public static final Property<Boolean> ENABLE_PROTECTION =
newProperty("Protection.enableProtection", false);
newProperty("Protection.enableProtection", true);
@Comment("Apply the protection also to registered usernames")
public static final Property<Boolean> ENABLE_PROTECTION_REGISTERED =
@ -37,7 +37,7 @@ public final class ProtectionSettings implements SettingsHolder {
"Use \"LOCALHOST\" for local addresses.",
"PLEASE USE QUOTES!"})
public static final Property<List<String>> COUNTRIES_WHITELIST =
newListProperty("Protection.countries", "US", "GB", "LOCALHOST");
newListProperty("Protection.countries", "CN", "LOCALHOST");
@Comment({
"Countries not allowed to join the server and register",
@ -69,7 +69,7 @@ public final class ProtectionSettings implements SettingsHolder {
@Comment("Kicks the player that issued a command before the defined time after the join process")
public static final Property<Integer> QUICK_COMMANDS_DENIED_BEFORE_MILLISECONDS =
newProperty("Protection.quickCommands.denyCommandsBeforeMilliseconds", 1000);
newProperty("Protection.quickCommands.denyCommandsBeforeMilliseconds", 3000);
private ProtectionSettings() {
}

View File

@ -18,7 +18,7 @@ public final class RegistrationSettings implements SettingsHolder {
"Send every X seconds a message to a player to",
"remind him that he has to login/register"})
public static final Property<Integer> MESSAGE_INTERVAL =
newProperty("settings.registration.messageInterval", 5);
newProperty("settings.registration.messageInterval", 600);
@Comment({
"Only registered and logged in players can play.",
@ -55,16 +55,9 @@ public final class RegistrationSettings implements SettingsHolder {
@Comment("Does AuthMe need to enforce a /login after a successful registration?")
public static final Property<Boolean> FORCE_LOGIN_AFTER_REGISTER =
newProperty("settings.registration.forceLoginAfterRegister", false);
@Comment({
"Broadcast the welcome message to the server or only to the player?",
"set true for server or false for player"})
public static final Property<Boolean> BROADCAST_WELCOME_MESSAGE =
newProperty("settings.broadcastWelcomeMessage", false);
@Comment("Should we delay the join message and display it once the player has logged in?")
public static final Property<Boolean> DELAY_JOIN_MESSAGE =
newProperty("settings.delayJoinMessage", false);
newProperty("settings.delayJoinMessage", true);
@Comment({
"The custom join message that will be sent after a successful login,",
@ -78,15 +71,15 @@ public final class RegistrationSettings implements SettingsHolder {
@Comment("Should we remove the leave messages of unlogged users?")
public static final Property<Boolean> REMOVE_UNLOGGED_LEAVE_MESSAGE =
newProperty("settings.removeUnloggedLeaveMessage", false);
newProperty("settings.removeUnloggedLeaveMessage", true);
@Comment("Should we remove join messages altogether?")
public static final Property<Boolean> REMOVE_JOIN_MESSAGE =
newProperty("settings.removeJoinMessage", false);
newProperty("settings.removeJoinMessage", true);
@Comment("Should we remove leave messages altogether?")
public static final Property<Boolean> REMOVE_LEAVE_MESSAGE =
newProperty("settings.removeLeaveMessage", false);
newProperty("settings.removeLeaveMessage", true);
@Comment("Do we need to add potion effect Blinding before login/register?")
public static final Property<Boolean> APPLY_BLIND_EFFECT =

View File

@ -41,7 +41,10 @@
# executor: CONSOLE
# ifNumberOfAccountsAtLeast: 5
# Commands to run for players logging in whose 'last login date' was empty
onFirstLogin: {}
onFirstLogin:
broadcast:
command: 'cmi broadcast &b欢迎 &r%p &7( %ip ) &b光临服务器,请大家多多关照!'
executor: CONSOLE
onJoin: {}
onLogin: {}
# These commands are called whenever a logged in player uses /logout or quits.
@ -52,4 +55,4 @@ onLogout: {}
onRegister: {}
onSessionLogin: {}
# Commands to run whenever a player is unregistered (by himself, or by an admin)
onUnregister: {}
onUnregister: {}