Update 3.1.1
//Changes 3.1.1:// * Do /login correctly in the correct thread * Add a way to force some commands after /login * Try a fix for bungeecord , let's see ... * Fix Logout command ( pos + inventory ) * Fix PHPBB support + random salt * Add a bypass antibot perm : authme.bypassantibot * Translation file will automatically update now * Some other fixes
This commit is contained in:
@@ -1,73 +1,64 @@
|
||||
package fr.xephi.authme.settings;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
|
||||
public class Messages extends CustomConfiguration {
|
||||
|
||||
private static Messages singleton = null;
|
||||
|
||||
public Messages() {
|
||||
super(new File(Settings.MESSAGE_FILE+"_"+Settings.messagesLanguage+".yml"));
|
||||
loadDefaults();
|
||||
public Messages(File file) {
|
||||
super(file);
|
||||
loadDefaults(file);
|
||||
loadFile();
|
||||
saveDefaults(file);
|
||||
singleton = this;
|
||||
}
|
||||
|
||||
private void loadDefaults() {
|
||||
this.set("logged_in", "&cAlready logged in!");
|
||||
this.set("not_logged_in", "&cNot logged in!");
|
||||
this.set("reg_disabled", "&cRegistration is disabled");
|
||||
this.set("user_regged", "&cUsername already registered");
|
||||
this.set("usage_reg", "&cUsage: /register password ConfirmPassword");
|
||||
this.set("usage_log", "&cUsage: /login password");
|
||||
this.set("user_unknown", "&cUsername not registered");
|
||||
this.set("pwd_changed", "&cPassword changed!");
|
||||
this.set("reg_only", "&fRegistered players only! Please visit http://example.com to register");
|
||||
this.set("valid_session", "&cSession login");
|
||||
this.set("login_msg", "&cPlease login with \"/login password\"");
|
||||
this.set("reg_msg", "&cPlease register with \"/register password ConfirmPassword\"");
|
||||
this.set("reg_email_msg", "&cPlease register with \"/register <email> <confirmEmail>\"");
|
||||
this.set("timeout", "&fLogin Timeout");
|
||||
this.set("wrong_pwd", "&cWrong password");
|
||||
this.set("logout", "&cSuccessful logout");
|
||||
this.set("usage_unreg", "&cUsage: /unregister password");
|
||||
this.set("registered", "&cSuccessfully registered!");
|
||||
this.set("unregistered", "&cSuccessfully unregistered!");
|
||||
this.set("login", "&cSuccessful login!");
|
||||
this.set("no_perm", "&cNo Permission");
|
||||
this.set("same_nick", "&fSame nick is already playing");
|
||||
this.set("reg_voluntarily", "&fYou can register your nickname with the server with the command \"/register password ConfirmPassword\"");
|
||||
this.set("reload", "&fConfiguration and database has been reloaded");
|
||||
this.set("error", "&fAn error ocurred; Please contact the admin");
|
||||
this.set("unknown_user", "&fUser is not in database");
|
||||
this.set("unsafe_spawn","&fYour Quit location was unsafe, teleporting you to World Spawn");
|
||||
this.set("unvalid_session","&fSession Dataes doesnt corrispond Plaese wait the end of session");
|
||||
this.set("max_reg","&fYou have Exceded the max number of Registration for your Account");
|
||||
this.set("password_error","&fPassword doesnt match");
|
||||
this.set("pass_len","&fYour password dind''t reach the minimum length or exeded the max length");
|
||||
this.set("vb_nonActiv","&fYour Account isent Activated yet check your Emails!");
|
||||
this.set("usage_changepassword", "&fUsage: /changepassword oldPassword newPassword");
|
||||
this.set("name_len", "&cYour nickname is too Short or too long");
|
||||
this.set("regex", "&cYour nickname contains illegal characters. Allowed chars: REG_EX");
|
||||
this.set("add_email","&cPlease add your email with : /email add yourEmail confirmEmail");
|
||||
this.set("bad_database_email", "[AuthMe] This /email command only available with MySQL and SQLite, contact an Admin");
|
||||
this.set("recovery_email", "&cForgot your password? Please use /email recovery <yourEmail>");
|
||||
this.set("usage_captcha", "&cUsage: /captcha <theCaptcha>");
|
||||
this.set("wrong_captcha", "&cWrong Captcha, please use : /captcha THE_CAPTCHA");
|
||||
this.set("valid_captcha", "&cYour captcha is valid !");
|
||||
this.set("kick_forvip", "&cA VIP Player join the full server!");
|
||||
this.set("kick_fullserver", "&cThe server is actually full, Sorry!");
|
||||
this.set("usage_email_add", "&fUsage: /email add <Email> <confirmEmail> ");
|
||||
this.set("usage_email_change", "&Usage: /email change <old> <new> ");
|
||||
this.set("usage_email_recovery", "&Usage: /email recovery <Email>");
|
||||
this.set("email_add", "[AuthMe] /email add <Email> <confirmEmail>");
|
||||
this.set("new_email_invalid", "[AuthMe] New email invalid!");
|
||||
this.set("old_email_invalid", "[AuthMe] Old email invalid!");
|
||||
this.set("email_invalid", "[AuthMe] Invalid Email !");
|
||||
this.set("email_added", "[AuthMe] Email Added !");
|
||||
this.set("email_confirm", "[AuthMe] Confirm your Email !");
|
||||
this.set("email_changed", "[AuthMe] Email Change !");
|
||||
this.set("email_send", "[AuthMe] Recovery Email Send !");
|
||||
/**
|
||||
* Loads a file from the plugin jar and sets as default
|
||||
*
|
||||
* @param filename The filename to open
|
||||
*/
|
||||
public final void loadDefaults(File file) {
|
||||
InputStream stream = AuthMe.getInstance().getResource(file.getName());
|
||||
if(stream == null) return;
|
||||
|
||||
setDefaults(YamlConfiguration.loadConfiguration(stream));
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the configuration to disk
|
||||
*
|
||||
* @return True if saved successfully
|
||||
*/
|
||||
public final boolean saved(File file) {
|
||||
try {
|
||||
save(file);
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves current configuration (plus defaults) to disk.
|
||||
*
|
||||
* If defaults and configuration are empty, saves blank file.
|
||||
*
|
||||
* @return True if saved successfully
|
||||
*/
|
||||
public final boolean saveDefaults(File file) {
|
||||
options().copyDefaults(true);
|
||||
options().copyHeader(true);
|
||||
boolean success = saved(file);
|
||||
options().copyDefaults(false);
|
||||
options().copyHeader(false);
|
||||
return success;
|
||||
}
|
||||
|
||||
private void loadFile() {
|
||||
@@ -76,23 +67,24 @@ public class Messages extends CustomConfiguration {
|
||||
}
|
||||
|
||||
public String _(String msg) {
|
||||
String loc = (String) this.get(msg);
|
||||
String loc = (String) this.get(msg, this.getDefault(msg));
|
||||
if (loc != null) {
|
||||
return loc.replace("&", "\u00a7");
|
||||
}
|
||||
if (loc == null && !contains(msg)) {
|
||||
set(msg, this.getDefault(msg));
|
||||
save();
|
||||
loc = (String) this.get(msg);
|
||||
load();
|
||||
loc = (String) this.get(msg, this.getDefault(msg));
|
||||
}
|
||||
if (loc == null)
|
||||
return "Error with Translation files; Please contact the admin";
|
||||
return "Error with Translation files; Please contact the admin ";
|
||||
return loc.replace("&", "\u00a7");
|
||||
}
|
||||
|
||||
public static Messages getInstance() {
|
||||
if (singleton == null) {
|
||||
singleton = new Messages();
|
||||
singleton = new Messages(new File(Settings.MESSAGE_FILE+"_"+Settings.messagesLanguage+".yml"));
|
||||
}
|
||||
return singleton;
|
||||
}
|
||||
|
||||
@@ -29,8 +29,10 @@ public final class Settings extends YamlConfiguration {
|
||||
private static List<String> getRestrictedIp;
|
||||
public static List<String> getMySQLOtherUsernameColumn = null;
|
||||
public static List<String> getForcedWorlds = null;
|
||||
public static List<String> countries = null;
|
||||
public static List<String> forceCommands = null;
|
||||
public final Plugin plugin;
|
||||
private final File file;
|
||||
private final File file;
|
||||
public static DataSourceType getDataSource;
|
||||
public static HashAlgorithm getPasswordHash;
|
||||
public static HashAlgorithm rakamakHash;
|
||||
@@ -39,13 +41,14 @@ public final class Settings extends YamlConfiguration {
|
||||
public static Boolean isPermissionCheckEnabled, isRegistrationEnabled, isForcedRegistrationEnabled,
|
||||
isTeleportToSpawnEnabled, isSessionsEnabled, isChatAllowed, isAllowRestrictedIp,
|
||||
isMovementAllowed, isKickNonRegisteredEnabled, isForceSingleSessionEnabled,
|
||||
isForceSpawnLocOnJoinEnabled, isForceExactSpawnEnabled, isSaveQuitLocationEnabled,
|
||||
isForceSpawnLocOnJoinEnabled, isSaveQuitLocationEnabled,
|
||||
isForceSurvivalModeEnabled, isResetInventoryIfCreative, isCachingEnabled, isKickOnWrongPasswordEnabled,
|
||||
getEnablePasswordVerifier, protectInventoryBeforeLogInEnabled, isBackupActivated, isBackupOnStart,
|
||||
isBackupOnStop, enablePasspartu, isStopEnabled, reloadSupport, rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts,
|
||||
useCaptcha, emailRegistration, multiverse, notifications, chestshop, bungee, banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange,
|
||||
disableSocialSpy, useMultiThreading, forceOnlyAfterLogin, useEssentialsMotd,
|
||||
usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword;
|
||||
usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword, purgeLimitedCreative,
|
||||
purgeAntiXray, purgePermissions, enableProtection, enableAntiBot;
|
||||
|
||||
public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort,
|
||||
getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename,
|
||||
@@ -59,7 +62,7 @@ public final class Settings extends YamlConfiguration {
|
||||
public static int getWarnMessageInterval, getSessionTimeout, getRegistrationTimeout, getMaxNickLength,
|
||||
getMinNickLength, getPasswordMinLen, getMovementRadius, getmaxRegPerIp, getNonActivatedGroup,
|
||||
passwordMaxLength, getRecoveryPassLength, getMailPort, maxLoginTry, captchaLength, saltLength, getmaxRegPerEmail,
|
||||
bCryptLog2Rounds, purgeDelay, getPhpbbGroup;
|
||||
bCryptLog2Rounds, purgeDelay, getPhpbbGroup, antiBotSensibility, antiBotDuration;
|
||||
|
||||
protected static YamlConfiguration configFile;
|
||||
|
||||
@@ -187,7 +190,7 @@ public void loadConfigOptions() {
|
||||
chestshop = configFile.getBoolean("Hooks.chestshop", true);
|
||||
notifications = configFile.getBoolean("Hooks.notifications", true);
|
||||
bungee = configFile.getBoolean("Hooks.bungeecord", false);
|
||||
getForcedWorlds = (List<String>) configFile.getList("settings.restrictions.ForceSpawnOnTheseWorlds");
|
||||
getForcedWorlds = (List<String>) configFile.getList("settings.restrictions.ForceSpawnOnTheseWorlds", new ArrayList<String>());
|
||||
banUnsafeIp = configFile.getBoolean("settings.restrictions.banUnsafedIP", false);
|
||||
doubleEmailCheck = configFile.getBoolean("settings.registration.doubleEmailCheck", false);
|
||||
sessionExpireOnIpChange = configFile.getBoolean("settings.sessions.sessionExpireOnIpChange", false);
|
||||
@@ -206,6 +209,15 @@ public void loadConfigOptions() {
|
||||
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 = (List<String>) configFile.getList("Protection.countries", new ArrayList<String>());
|
||||
enableAntiBot = configFile.getBoolean("Protection.enableAntiBot", false);
|
||||
antiBotSensibility = configFile.getInt("Protection.antiBotSensibility", 5);
|
||||
antiBotDuration = configFile.getInt("Protection.antiBotDuration", 10);
|
||||
forceCommands = (List<String>) configFile.getList("settings.forceCommands", new ArrayList<String>());
|
||||
|
||||
saveDefaults();
|
||||
}
|
||||
@@ -339,6 +351,15 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
|
||||
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 = (List<String>) configFile.getList("Protection.countries");
|
||||
enableAntiBot = configFile.getBoolean("Protection.enableAntiBot", false);
|
||||
antiBotSensibility = configFile.getInt("Protection.antiBotSensibility", 5);
|
||||
antiBotDuration = configFile.getInt("Protection.antiBotDuration", 10);
|
||||
forceCommands = (List<String>) configFile.getList("settings.forceCommands", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public void mergeConfig() {
|
||||
@@ -433,7 +454,29 @@ public void mergeConfig() {
|
||||
set("Xenoforo.predefinedSalt", null);
|
||||
if(configFile.getString("settings.security.passwordHash","SHA256").toUpperCase().equals("XFSHA1") || configFile.getString("settings.security.passwordHash","SHA256").toUpperCase().equals("XFSHA256"))
|
||||
set("settings.security.passwordHash", "XENFORO");
|
||||
|
||||
if(!contains("Purge.removeLimitedCreativesInventories"))
|
||||
set("Purge.removeLimitedCreativesInventories", false);
|
||||
if(!contains("Purge.removeAntiXRayFile"))
|
||||
set("Purge.removeAntiXRayFile", false);
|
||||
/*if(!contains("Purge.removePermissions"))
|
||||
set("Purge.removePermissions", false);*/
|
||||
if(!contains("Protection.enableProtection"))
|
||||
set("Protection.enableProtection", false);
|
||||
if(!contains("Protection.countries")) {
|
||||
countries = new ArrayList<String>();
|
||||
countries.add("US");
|
||||
countries.add("GB");
|
||||
set("Protection.countries", countries);
|
||||
}
|
||||
if(!contains("Protection.enableAntiBot"))
|
||||
set("Protection.enableAntiBot", false);
|
||||
if(!contains("Protection.antiBotSensibility"))
|
||||
set("Protection.antiBotSensibility", 5);
|
||||
if(!contains("Protection.antiBotDuration"))
|
||||
set("Protection.antiBotDuration", 10);
|
||||
if(!contains("settings.forceCommands"))
|
||||
set("settings.forceCommands", new ArrayList<String>());
|
||||
|
||||
plugin.getLogger().info("Merge new Config Options if needed..");
|
||||
plugin.saveConfig();
|
||||
|
||||
@@ -581,11 +624,11 @@ public void mergeConfig() {
|
||||
setDefaults(new MemoryConfiguration());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check loaded defaults against current configuration
|
||||
*
|
||||
* @return false When all defaults aren't present in config
|
||||
*/
|
||||
/**
|
||||
* Check loaded defaults against current configuration
|
||||
*
|
||||
* @return false When all defaults aren't present in config
|
||||
*/
|
||||
public boolean checkDefaults() {
|
||||
if (getDefaults() == null) {
|
||||
return true;
|
||||
@@ -604,8 +647,14 @@ public void mergeConfig() {
|
||||
return "en";
|
||||
}
|
||||
|
||||
public enum messagesLang {
|
||||
en, de, br, cz, pl, fr, ru, hu, sk, es, zhtw, fi, zhcn, lt, it, ko, pt
|
||||
public static void switchAntiBotMod(boolean mode) {
|
||||
if (mode)
|
||||
isKickNonRegisteredEnabled = true;
|
||||
else
|
||||
isKickNonRegisteredEnabled = configFile.getBoolean("settings.restrictions.kickNonRegistered",false);
|
||||
}
|
||||
|
||||
public enum messagesLang {
|
||||
en, de, br, cz, pl, fr, ru, hu, sk, es, zhtw, fi, zhcn, lt, it, ko, pt, nl
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user