mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-09 12:10:56 +01:00
Change how config work for the first launch
This commit is contained in:
parent
a51eab5566
commit
d0e1d7b8b8
@ -129,7 +129,6 @@ public class AuthMe extends JavaPlugin {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
settings = new Settings(this);
|
settings = new Settings(this);
|
||||||
settings.loadConfigOptions();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ConsoleLogger.showError("Can't load the configuration file... Something went wrong, to avoid security issues the server will shutdown!");
|
ConsoleLogger.showError("Can't load the configuration file... Something went wrong, to avoid security issues the server will shutdown!");
|
||||||
this.getServer().shutdown();
|
this.getServer().shutdown();
|
||||||
|
@ -7,7 +7,6 @@ import java.io.FileNotFoundException;
|
|||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -100,21 +99,31 @@ public final class Settings extends YamlConfiguration {
|
|||||||
public Settings(AuthMe plugin) {
|
public Settings(AuthMe plugin) {
|
||||||
this.file = new File(plugin.getDataFolder(), "config.yml");
|
this.file = new File(plugin.getDataFolder(), "config.yml");
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
if (exists()) {
|
boolean exist = exists();
|
||||||
|
if (exist) {
|
||||||
load();
|
load();
|
||||||
} else {
|
} else {
|
||||||
loadDefaults(file.getName());
|
plugin.saveDefaultConfig();
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
configFile = (YamlConfiguration) plugin.getConfig();
|
configFile = (YamlConfiguration) plugin.getConfig();
|
||||||
PLUGIN_FOLDER = plugin.getDataFolder().toString();
|
PLUGIN_FOLDER = plugin.getDataFolder().toString();
|
||||||
|
loadConfigOptions(exist);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadConfigOptions(boolean exist) {
|
||||||
|
plugin.getLogger().info("Loading Configuration File...");
|
||||||
|
if (exist)
|
||||||
|
mergeConfig();
|
||||||
|
|
||||||
|
loadVariables();
|
||||||
|
|
||||||
|
if (exist)
|
||||||
|
saveDefaults();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void loadConfigOptions() {
|
public static void loadVariables() {
|
||||||
plugin.getLogger().info("Loading Configuration File...");
|
|
||||||
mergeConfig();
|
|
||||||
|
|
||||||
messagesLanguage = checkLang(configFile.getString("settings.messagesLanguage", "en"));
|
messagesLanguage = checkLang(configFile.getString("settings.messagesLanguage", "en"));
|
||||||
isPermissionCheckEnabled = configFile.getBoolean("permission.EnablePermissionCheck", false);
|
isPermissionCheckEnabled = configFile.getBoolean("permission.EnablePermissionCheck", false);
|
||||||
isForcedRegistrationEnabled = configFile.getBoolean("settings.registration.force", true);
|
isForcedRegistrationEnabled = configFile.getBoolean("settings.registration.force", true);
|
||||||
@ -274,176 +283,14 @@ public final class Settings extends YamlConfiguration {
|
|||||||
generateImage = configFile.getBoolean("Email.generateImage", true);
|
generateImage = configFile.getBoolean("Email.generateImage", true);
|
||||||
|
|
||||||
// Load the welcome message
|
// Load the welcome message
|
||||||
getWelcomeMessage(plugin);
|
getWelcomeMessage();
|
||||||
|
|
||||||
saveDefaults();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public static void reloadConfigOptions(YamlConfiguration newConfig) {
|
public static void reloadConfigOptions(YamlConfiguration newConfig) {
|
||||||
configFile = newConfig;
|
configFile = newConfig;
|
||||||
|
|
||||||
messagesLanguage = checkLang(configFile.getString("settings.messagesLanguage", "en"));
|
loadVariables();
|
||||||
isPermissionCheckEnabled = configFile.getBoolean("permission.EnablePermissionCheck", false);
|
|
||||||
isForcedRegistrationEnabled = configFile.getBoolean("settings.registration.force", true);
|
|
||||||
isRegistrationEnabled = configFile.getBoolean("settings.registration.enabled", true);
|
|
||||||
isTeleportToSpawnEnabled = configFile.getBoolean("settings.restrictions.teleportUnAuthedToSpawn", false);
|
|
||||||
getWarnMessageInterval = configFile.getInt("settings.registration.messageInterval", 5);
|
|
||||||
isSessionsEnabled = configFile.getBoolean("settings.sessions.enabled", false);
|
|
||||||
getSessionTimeout = configFile.getInt("settings.sessions.timeout", 10);
|
|
||||||
getRegistrationTimeout = configFile.getInt("settings.restrictions.timeout", 30);
|
|
||||||
isChatAllowed = configFile.getBoolean("settings.restrictions.allowChat", false);
|
|
||||||
getMaxNickLength = configFile.getInt("settings.restrictions.maxNicknameLength", 20);
|
|
||||||
getMinNickLength = configFile.getInt("settings.restrictions.minNicknameLength", 3);
|
|
||||||
getPasswordMinLen = configFile.getInt("settings.security.minPasswordLength", 4);
|
|
||||||
getNickRegex = configFile.getString("settings.restrictions.allowedNicknameCharacters", "[a-zA-Z0-9_?]*");
|
|
||||||
isAllowRestrictedIp = configFile.getBoolean("settings.restrictions.AllowRestrictedUser", false);
|
|
||||||
getRestrictedIp = configFile.getStringList("settings.restrictions.AllowedRestrictedUser");
|
|
||||||
isMovementAllowed = configFile.getBoolean("settings.restrictions.allowMovement", false);
|
|
||||||
getMovementRadius = configFile.getInt("settings.restrictions.allowedMovementRadius", 100);
|
|
||||||
getJoinPermissions = configFile.getStringList("GroupOptions.Permissions.PermissionsOnJoin");
|
|
||||||
isKickOnWrongPasswordEnabled = configFile.getBoolean("settings.restrictions.kickOnWrongPassword", false);
|
|
||||||
isKickNonRegisteredEnabled = configFile.getBoolean("settings.restrictions.kickNonRegistered", false);
|
|
||||||
isForceSingleSessionEnabled = configFile.getBoolean("settings.restrictions.ForceSingleSession", true);
|
|
||||||
isForceSpawnLocOnJoinEnabled = configFile.getBoolean("settings.restrictions.ForceSpawnLocOnJoinEnabled", false);
|
|
||||||
isSaveQuitLocationEnabled = configFile.getBoolean("settings.restrictions.SaveQuitLocation", false);
|
|
||||||
isForceSurvivalModeEnabled = configFile.getBoolean("settings.GameMode.ForceSurvivalMode", false);
|
|
||||||
isResetInventoryIfCreative = configFile.getBoolean("settings.GameMode.ResetInventoryIfCreative", false);
|
|
||||||
getmaxRegPerIp = configFile.getInt("settings.restrictions.maxRegPerIp", 1);
|
|
||||||
getPasswordHash = getPasswordHash();
|
|
||||||
getUnloggedinGroup = configFile.getString("settings.security.unLoggedinGroup", "unLoggedInGroup");
|
|
||||||
getDataSource = getDataSource();
|
|
||||||
isCachingEnabled = configFile.getBoolean("DataSource.caching", true);
|
|
||||||
getMySQLHost = configFile.getString("DataSource.mySQLHost", "127.0.0.1");
|
|
||||||
getMySQLPort = configFile.getString("DataSource.mySQLPort", "3306");
|
|
||||||
getMySQLUsername = configFile.getString("DataSource.mySQLUsername", "authme");
|
|
||||||
getMySQLPassword = configFile.getString("DataSource.mySQLPassword", "12345");
|
|
||||||
getMySQLDatabase = configFile.getString("DataSource.mySQLDatabase", "authme");
|
|
||||||
getMySQLTablename = configFile.getString("DataSource.mySQLTablename", "authme");
|
|
||||||
getMySQLColumnEmail = configFile.getString("DataSource.mySQLColumnEmail", "email");
|
|
||||||
getMySQLColumnName = configFile.getString("DataSource.mySQLColumnName", "username");
|
|
||||||
getMySQLColumnPassword = configFile.getString("DataSource.mySQLColumnPassword", "password");
|
|
||||||
getMySQLColumnIp = configFile.getString("DataSource.mySQLColumnIp", "ip");
|
|
||||||
getMySQLColumnLastLogin = configFile.getString("DataSource.mySQLColumnLastLogin", "lastlogin");
|
|
||||||
getMySQLColumnSalt = configFile.getString("ExternalBoardOptions.mySQLColumnSalt");
|
|
||||||
getMySQLColumnGroup = configFile.getString("ExternalBoardOptions.mySQLColumnGroup", "");
|
|
||||||
getMySQLlastlocX = configFile.getString("DataSource.mySQLlastlocX", "x");
|
|
||||||
getMySQLlastlocY = configFile.getString("DataSource.mySQLlastlocY", "y");
|
|
||||||
getMySQLlastlocZ = configFile.getString("DataSource.mySQLlastlocZ", "z");
|
|
||||||
getMySQLlastlocWorld = configFile.getString("DataSource.mySQLlastlocWorld", "world");
|
|
||||||
getMySQLColumnRealName = configFile.getString("DataSource.mySQLRealName", "realname");
|
|
||||||
getNonActivatedGroup = configFile.getInt("ExternalBoardOptions.nonActivedUserGroup", -1);
|
|
||||||
unRegisteredGroup = configFile.getString("GroupOptions.UnregisteredPlayerGroup", "");
|
|
||||||
getUnrestrictedName = configFile.getStringList("settings.unrestrictions.UnrestrictedName");
|
|
||||||
getRegisteredGroup = configFile.getString("GroupOptions.RegisteredPlayerGroup", "");
|
|
||||||
getEnablePasswordVerifier = configFile.getBoolean("settings.restrictions.enablePasswordVerifier", true);
|
|
||||||
protectInventoryBeforeLogInEnabled = configFile.getBoolean("settings.restrictions.ProtectInventoryBeforeLogIn", true);
|
|
||||||
passwordMaxLength = configFile.getInt("settings.security.passwordMaxLength", 20);
|
|
||||||
isBackupActivated = configFile.getBoolean("BackupSystem.ActivateBackup", false);
|
|
||||||
isBackupOnStart = configFile.getBoolean("BackupSystem.OnServerStart", false);
|
|
||||||
isBackupOnStop = configFile.getBoolean("BackupSystem.OnServeStop", false);
|
|
||||||
backupWindowsPath = configFile.getString("BackupSystem.MysqlWindowsPath", "C:\\Program Files\\MySQL\\MySQL Server 5.1\\");
|
|
||||||
enablePasspartu = configFile.getBoolean("Passpartu.enablePasspartu", false);
|
|
||||||
isStopEnabled = configFile.getBoolean("Security.SQLProblem.stopServer", true);
|
|
||||||
reloadSupport = configFile.getBoolean("Security.ReloadCommand.useReloadCommandSupport", true);
|
|
||||||
allowCommands = (List<String>) configFile.getList("settings.restrictions.allowCommands");
|
|
||||||
if (configFile.contains("allowCommands")) {
|
|
||||||
if (!allowCommands.contains("/login"))
|
|
||||||
allowCommands.add("/login");
|
|
||||||
if (!allowCommands.contains("/register"))
|
|
||||||
allowCommands.add("/register");
|
|
||||||
if (!allowCommands.contains("/l"))
|
|
||||||
allowCommands.add("/l");
|
|
||||||
if (!allowCommands.contains("/reg"))
|
|
||||||
allowCommands.add("/reg");
|
|
||||||
if (!allowCommands.contains("/passpartu"))
|
|
||||||
allowCommands.add("/passpartu");
|
|
||||||
if (!allowCommands.contains("/email"))
|
|
||||||
allowCommands.add("/email");
|
|
||||||
if (!allowCommands.contains("/captcha"))
|
|
||||||
allowCommands.add("/captcha");
|
|
||||||
}
|
|
||||||
rakamakUsers = configFile.getString("Converter.Rakamak.fileName", "users.rak");
|
|
||||||
rakamakUsersIp = configFile.getString("Converter.Rakamak.ipFileName", "UsersIp.rak");
|
|
||||||
rakamakUseIp = configFile.getBoolean("Converter.Rakamak.useIp", false);
|
|
||||||
noConsoleSpam = configFile.getBoolean("Security.console.noConsoleSpam", false);
|
|
||||||
removePassword = configFile.getBoolean("Security.console.removePassword", true);
|
|
||||||
getmailAccount = configFile.getString("Email.mailAccount", "");
|
|
||||||
getmailPassword = configFile.getString("Email.mailPassword", "");
|
|
||||||
getmailSMTP = configFile.getString("Email.mailSMTP", "smtp.gmail.com");
|
|
||||||
getMailPort = configFile.getInt("Email.mailPort", 465);
|
|
||||||
getRecoveryPassLength = configFile.getInt("Email.RecoveryPasswordLength", 8);
|
|
||||||
getMySQLOtherUsernameColumn = (List<String>) configFile.getList("ExternalBoardOptions.mySQLOtherUsernameColumns", new ArrayList<String>());
|
|
||||||
displayOtherAccounts = configFile.getBoolean("settings.restrictions.displayOtherAccounts", true);
|
|
||||||
getMySQLColumnId = configFile.getString("DataSource.mySQLColumnId", "id");
|
|
||||||
getmailSenderName = configFile.getString("Email.mailSenderName", "");
|
|
||||||
useCaptcha = configFile.getBoolean("Security.captcha.useCaptcha", false);
|
|
||||||
maxLoginTry = configFile.getInt("Security.captcha.maxLoginTry", 5);
|
|
||||||
captchaLength = configFile.getInt("Security.captcha.captchaLength", 5);
|
|
||||||
getMailSubject = configFile.getString("Email.mailSubject", "Your new AuthMe Password");
|
|
||||||
getMailText = configFile.getString("Email.mailText", "Dear <playername>, <br /><br /> This is your new AuthMe password for the server <br /><br /> <servername> : <br /><br /> <generatedpass><br /><br />Do not forget to change password after login! <br /> /changepassword <generatedpass> newPassword");
|
|
||||||
emailRegistration = configFile.getBoolean("settings.registration.enableEmailRegistrationSystem", false);
|
|
||||||
saltLength = configFile.getInt("settings.security.doubleMD5SaltLength", 8);
|
|
||||||
getmaxRegPerEmail = configFile.getInt("Email.maxRegPerEmail", 1);
|
|
||||||
multiverse = configFile.getBoolean("Hooks.multiverse", true);
|
|
||||||
chestshop = configFile.getBoolean("Hooks.chestshop", true);
|
|
||||||
bungee = configFile.getBoolean("Hooks.bungeecord", false);
|
|
||||||
getForcedWorlds = configFile.getStringList("settings.restrictions.ForceSpawnOnTheseWorlds");
|
|
||||||
banUnsafeIp = configFile.getBoolean("settings.restrictions.banUnsafedIP", false);
|
|
||||||
doubleEmailCheck = configFile.getBoolean("settings.registration.doubleEmailCheck", false);
|
|
||||||
sessionExpireOnIpChange = configFile.getBoolean("settings.sessions.sessionExpireOnIpChange", false);
|
|
||||||
useLogging = configFile.getBoolean("Security.console.logConsole", false);
|
|
||||||
disableSocialSpy = configFile.getBoolean("Hooks.disableSocialSpy", true);
|
|
||||||
bCryptLog2Rounds = configFile.getInt("ExternalBoardOptions.bCryptLog2Round", 10);
|
|
||||||
forceOnlyAfterLogin = configFile.getBoolean("settings.GameMode.ForceOnlyAfterLogin", false);
|
|
||||||
useEssentialsMotd = configFile.getBoolean("Hooks.useEssentialsMotd", false);
|
|
||||||
usePurge = configFile.getBoolean("Purge.useAutoPurge", false);
|
|
||||||
purgeDelay = configFile.getInt("Purge.daysBeforeRemovePlayer", 60);
|
|
||||||
purgePlayerDat = configFile.getBoolean("Purge.removePlayerDat", false);
|
|
||||||
purgeEssentialsFile = configFile.getBoolean("Purge.removeEssentialsFile", false);
|
|
||||||
defaultWorld = configFile.getString("Purge.defaultWorld", "world");
|
|
||||||
getPhpbbPrefix = configFile.getString("ExternalBoardOptions.phpbbTablePrefix", "phpbb_");
|
|
||||||
getPhpbbGroup = configFile.getInt("ExternalBoardOptions.phpbbActivatedGroupId", 2);
|
|
||||||
supportOldPassword = configFile.getBoolean("settings.security.supportOldPasswordHash", false);
|
|
||||||
getWordPressPrefix = configFile.getString("ExternalBoardOptions.wordpressTablePrefix", "wp_");
|
|
||||||
purgeLimitedCreative = configFile.getBoolean("Purge.removeLimitedCreativesInventories", false);
|
|
||||||
purgeAntiXray = configFile.getBoolean("Purge.removeAntiXRayFile", false);
|
|
||||||
purgePermissions = configFile.getBoolean("Purge.removePermissions", false);
|
|
||||||
enableProtection = configFile.getBoolean("Protection.enableProtection", false);
|
|
||||||
countries = configFile.getStringList("Protection.countries");
|
|
||||||
enableAntiBot = configFile.getBoolean("Protection.enableAntiBot", false);
|
|
||||||
antiBotSensibility = configFile.getInt("Protection.antiBotSensibility", 5);
|
|
||||||
antiBotDuration = configFile.getInt("Protection.antiBotDuration", 10);
|
|
||||||
forceCommands = configFile.getStringList("settings.forceCommands");
|
|
||||||
forceCommandsAsConsole = configFile.getStringList("settings.forceCommandsAsConsole");
|
|
||||||
recallEmail = configFile.getBoolean("Email.recallPlayers", false);
|
|
||||||
delayRecall = configFile.getInt("Email.delayRecall", 5);
|
|
||||||
useWelcomeMessage = configFile.getBoolean("settings.useWelcomeMessage", true);
|
|
||||||
unsafePasswords = configFile.getStringList("settings.security.unsafePasswords");
|
|
||||||
countriesBlacklist = configFile.getStringList("Protection.countriesBlacklist");
|
|
||||||
broadcastWelcomeMessage = configFile.getBoolean("settings.broadcastWelcomeMessage", false);
|
|
||||||
forceRegKick = configFile.getBoolean("settings.registration.forceKickAfterRegister", false);
|
|
||||||
forceRegLogin = configFile.getBoolean("settings.registration.forceLoginAfterRegister", false);
|
|
||||||
getMySQLColumnLogged = configFile.getString("DataSource.mySQLColumnLogged", "isLogged");
|
|
||||||
spawnPriority = configFile.getString("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
|
|
||||||
getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
|
|
||||||
getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
|
|
||||||
checkVeryGames = configFile.getBoolean("VeryGames.enableIpCheck", false);
|
|
||||||
delayJoinMessage = configFile.getBoolean("settings.delayJoinMessage", false);
|
|
||||||
noTeleport = configFile.getBoolean("settings.restrictions.noTeleport", false);
|
|
||||||
crazyloginFileName = configFile.getString("Converter.CrazyLogin.fileName", "accounts.db");
|
|
||||||
getPassRegex = configFile.getString("settings.restrictions.allowedPasswordCharacters", "[\\x21-\\x7E]*");
|
|
||||||
applyBlindEffect = configFile.getBoolean("settings.applyBlindEffect", false);
|
|
||||||
emailBlacklist = configFile.getStringList("Email.emailBlacklisted");
|
|
||||||
emailWhitelist = configFile.getStringList("Email.emailWhitelisted");
|
|
||||||
forceRegisterCommands = configFile.getStringList("settings.forceRegisterCommands");
|
|
||||||
forceRegisterCommandsAsConsole = (List<String>) configFile.getList("settings.forceRegisterCommandsAsConsole", new ArrayList<String>());
|
|
||||||
customAttributes = configFile.getBoolean("Hooks.customAttributes");
|
|
||||||
generateImage = configFile.getBoolean("Email.generateImage", true);
|
|
||||||
|
|
||||||
// Reload the welcome message
|
|
||||||
getWelcomeMessage(AuthMe.getInstance());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void mergeConfig() {
|
public void mergeConfig() {
|
||||||
@ -607,7 +454,6 @@ public final class Settings extends YamlConfiguration {
|
|||||||
plugin.getLogger().warning("Merge new Config Options - I'm not an error, please don't report me");
|
plugin.getLogger().warning("Merge 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!");
|
||||||
}
|
}
|
||||||
plugin.saveConfig();
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -685,8 +531,9 @@ public final class Settings extends YamlConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final void reload() {
|
public final void reload() {
|
||||||
|
if (!exists())
|
||||||
|
plugin.saveDefaultConfig();
|
||||||
load();
|
load();
|
||||||
loadDefaults(file.getName());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -712,21 +559,6 @@ public final class Settings extends YamlConfiguration {
|
|||||||
return file.exists();
|
return file.exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads a file from the plugin jar and sets as default
|
|
||||||
*
|
|
||||||
* @param filename
|
|
||||||
* The filename to open
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public final void loadDefaults(String filename) {
|
|
||||||
InputStream stream = plugin.getResource(filename);
|
|
||||||
if (stream == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
setDefaults(YamlConfiguration.loadConfiguration(stream));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Saves current configuration (plus defaults) to disk.
|
* Saves current configuration (plus defaults) to disk.
|
||||||
*
|
*
|
||||||
@ -779,7 +611,8 @@ public final class Settings extends YamlConfiguration {
|
|||||||
else isKickNonRegisteredEnabled = configFile.getBoolean("settings.restrictions.kickNonRegistered", false);
|
else isKickNonRegisteredEnabled = configFile.getBoolean("settings.restrictions.kickNonRegistered", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void getWelcomeMessage(AuthMe plugin) {
|
private static void getWelcomeMessage() {
|
||||||
|
AuthMe plugin = AuthMe.getInstance();
|
||||||
welcomeMsg = new ArrayList<String>();
|
welcomeMsg = new ArrayList<String>();
|
||||||
if (!useWelcomeMessage) {
|
if (!useWelcomeMessage) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user