AuthMe 3.0

//Changes 3.0://
* Repackaging from uk.org.whoami.authme to fr.xephi.authme, please
developpers, update!
* Rewrite some of parts of the plugin
* Some code was already perfect , also did not change it :p
* Full support for phpbb3
* Add full support for WordPress + passwordHash: WORDPRESS
* Completely rewrite Management system for inventories and tp issues,
Thanks to : [[http://dev.bukkit.org/profiles/Possible/|Possible]]
* Rework on /passpartu command
* Completely rewrite the password encryption method
* Add a way for developers to add their own Password Encryption Method
on AuthMe via event way (please see
fr.xephi.authme.events.PasswordEncryptionEvent)
* Add an auto purge with players.dat removing method and essentials
files removing ( if you want authme to hook with an another plugin let
me know )
* Complete Hook with BungeeCord by removing the /server command before
login
* message_lang.yml will never be overwritten with English Strings , but
correctly update the message_lang.yml when needed to
* Fix a lot of issues mentioned in tickets , commants , or by mp, Thanks
for all your reports!
This commit is contained in:
Xephi
2013-10-17 05:14:46 +02:00
parent e6467eccf2
commit 10b4eaeca7
112 changed files with 3142 additions and 2640 deletions
@@ -0,0 +1,87 @@
package fr.xephi.authme.settings;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
public class CustomConfiguration extends YamlConfiguration{
private File configFile;
public CustomConfiguration(File file)
{
this.configFile = file;
load();
}
public void load()
{
try {
super.load(configFile);
} catch (FileNotFoundException e) {
Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Could not find " + configFile.getName() + ", creating new one...");
reLoad();
} catch (IOException e) {
Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Could not load " + configFile.getName(), e);
} catch (InvalidConfigurationException e) {
Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, configFile.getName() + " is no valid configuration file", e);
}
}
public boolean reLoad() {
boolean out = true;
if (!configFile.exists())
{
out = loadRessource(configFile);
}
if (out) load();
return out;
}
public void save() {
try {
super.save(configFile);
} catch (IOException ex) {
Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Could not save config to " + configFile.getName(), ex);
}
}
public boolean loadRessource(File file) {
boolean out = true;
if (!file.exists()) {
InputStream fis = getClass().getResourceAsStream("/" + file.getName());
FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
byte[] buf = new byte[1024];
int i = 0;
while ((i = fis.read(buf)) != -1) {
fos.write(buf, 0, i);
}
} catch (Exception e) {
Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Failed to load config from JAR");
out = false;
} finally {
try {
if (fis != null) {
fis.close();
}
if (fos != null) {
fos.close();
}
} catch (Exception e) {
}
}
}
return out;
}
}
@@ -0,0 +1,100 @@
package fr.xephi.authme.settings;
import java.io.File;
public class Messages extends CustomConfiguration {
private static Messages singleton = null;
public Messages() {
super(new File(Settings.MESSAGE_FILE+"_"+Settings.messagesLanguage+".yml"));
loadDefaults();
loadFile();
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 !");
}
private void loadFile() {
this.load();
this.save();
}
public String _(String msg) {
String loc = (String) this.get(msg);
if (loc != null) {
return loc.replace("&", "\u00a7");
}
if (loc == null && !contains(msg)) {
set(msg, this.getDefault(msg));
save();
loc = (String) this.get(msg);
}
if (loc == null)
return "Error with Translation files; Please contact the admin";
return loc.replace("&", "\u00a7");
}
public static Messages getInstance() {
if (singleton == null) {
singleton = new Messages();
}
return singleton;
}
}
@@ -0,0 +1,40 @@
package fr.xephi.authme.settings;
import java.io.File;
import java.util.List;
import org.bukkit.entity.Player;
/**
*
* @author Xephi59
*/
public class PlayersLogs extends CustomConfiguration {
private static PlayersLogs pllog = null;
public static List<String> players;
@SuppressWarnings("unchecked")
public PlayersLogs() {
super(new File("./plugins/AuthMe/players.yml"));
pllog = this;
load();
save();
players = (List<String>) this.getList("players");
}
public static PlayersLogs getInstance() {
if (pllog == null) {
pllog = new PlayersLogs();
}
return pllog;
}
public void addPlayer(Player player) {
List<String> players = this.getStringList("players");
if (!players.contains(player.getName())) {
players.add(player.getName());
this.set("players", players);
save();
}
}
}
@@ -0,0 +1,611 @@
package fr.xephi.authme.settings;
import java.io.File;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.bukkit.configuration.MemoryConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.Plugin;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.datasource.DataSource.DataSourceType;
import fr.xephi.authme.security.HashAlgorithm;
public final class Settings extends YamlConfiguration {
public static final String PLUGIN_FOLDER = "./plugins/AuthMe";
public static final String CACHE_FOLDER = Settings.PLUGIN_FOLDER + "/cache";
public static final String AUTH_FILE = Settings.PLUGIN_FOLDER + "/auths.db";
public static final String MESSAGE_FILE = Settings.PLUGIN_FOLDER + "/messages";
public static final String SETTINGS_FILE = Settings.PLUGIN_FOLDER + "/config.yml";
public static List<String> allowCommands = null;
public static List<String> getJoinPermissions = null;
public static List<String> getUnrestrictedName = null;
private static List<String> getRestrictedIp;
public static List<String> getMySQLOtherUsernameColumn = null;
public static List<String> getForcedWorlds = null;
public final Plugin plugin;
private final File file;
public static DataSourceType getDataSource;
public static HashAlgorithm getPasswordHash;
public static HashAlgorithm rakamakHash;
public static Boolean useLogging = false;
public static Boolean isPermissionCheckEnabled, isRegistrationEnabled, isForcedRegistrationEnabled,
isTeleportToSpawnEnabled, isSessionsEnabled, isChatAllowed, isAllowRestrictedIp,
isMovementAllowed, isKickNonRegisteredEnabled, isForceSingleSessionEnabled,
isForceSpawnLocOnJoinEnabled, isForceExactSpawnEnabled, 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;
public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort,
getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename,
getMySQLColumnName, getMySQLColumnPassword, getMySQLColumnIp, getMySQLColumnLastLogin,
getMySQLColumnSalt, getMySQLColumnGroup, getMySQLColumnEmail, unRegisteredGroup, backupWindowsPath,
getcUnrestrictedName, getRegisteredGroup, messagesLanguage, getMySQLlastlocX, getMySQLlastlocY, getMySQLlastlocZ,
rakamakUsers, rakamakUsersIp, getmailAccount, getmailPassword, getmailSMTP, getMySQLColumnId, getmailSenderName,
getMailSubject, getMailText, getMySQLlastlocWorld, defaultWorld,
getPhpbbPrefix, getWordPressPrefix;
public static int getWarnMessageInterval, getSessionTimeout, getRegistrationTimeout, getMaxNickLength,
getMinNickLength, getPasswordMinLen, getMovementRadius, getmaxRegPerIp, getNonActivatedGroup,
passwordMaxLength, getRecoveryPassLength, getMailPort, maxLoginTry, captchaLength, saltLength, getmaxRegPerEmail,
bCryptLog2Rounds, purgeDelay, getPhpbbGroup;
protected static YamlConfiguration configFile;
public Settings(Plugin plugin) {
this.file = new File(plugin.getDataFolder(),"config.yml");
this.plugin = plugin;
if(exists()) {
load();
}
else {
loadDefaults(file.getName());
load();
}
configFile = (YamlConfiguration) plugin.getConfig();
}
@SuppressWarnings("unchecked")
public void loadConfigOptions() {
plugin.getLogger().info("Loading Configuration File...");
mergeConfig();
messagesLanguage = checkLang(configFile.getString("settings.messagesLanguage","en"));
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");
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);
rakamakHash = getRakamakHash();
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);
notifications = configFile.getBoolean("Hooks.notifications", true);
bungee = configFile.getBoolean("Hooks.bungeecord", false);
getForcedWorlds = (List<String>) configFile.getList("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);
useMultiThreading = configFile.getBoolean("Performances.useMultiThreading", 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_");
saveDefaults();
}
@SuppressWarnings("unchecked")
public static void reloadConfigOptions(YamlConfiguration newConfig) {
configFile = newConfig;
messagesLanguage = checkLang(configFile.getString("settings.messagesLanguage","en"));
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");
getMySQLlastlocX = configFile.getString("DataSource.mySQLlastlocX","x");
getMySQLlastlocY = configFile.getString("DataSource.mySQLlastlocY","y");
getMySQLlastlocZ = configFile.getString("DataSource.mySQLlastlocZ","z");
getMySQLlastlocWorld = configFile.getString("DataSource.mySQLlastlocWorld", "world");
getMySQLColumnSalt = configFile.getString("ExternalBoardOptions.mySQLColumnSalt","");
getMySQLColumnGroup = configFile.getString("ExternalBoardOptions.mySQLColumnGroup","");
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);
rakamakHash = getRakamakHash();
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);
notifications = configFile.getBoolean("Hooks.notifications", true);
bungee = configFile.getBoolean("Hooks.bungeecord", false);
getForcedWorlds = (List<String>) configFile.getList("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);
useMultiThreading = configFile.getBoolean("Performances.useMultiThreading", 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_");
}
public void mergeConfig() {
if(!contains("DataSource.mySQLColumnEmail"))
set("DataSource.mySQLColumnEmail","email");
if(!contains("Email.RecoveryPasswordLength"))
set("Email.RecoveryPasswordLength", 8);
if(!contains("Email.mailPort"))
set("Email.mailPort", 465);
if(!contains("Email.mailSMTP"))
set("Email.mailSMTP", "smtp.gmail.com");
if(!contains("Email.mailAccount"))
set("Email.mailAccount", "");
if(!contains("Email.mailPassword"))
set("Email.mailPassword", "");
if(!contains("ExternalBoardOptions.mySQLOtherUsernameColumns"))
set("ExternalBoardOptions.mySQLOtherUsernameColumns", new ArrayList<String>());
if(!contains("settings.restrictions.displayOtherAccounts"))
set("settings.restrictions.displayOtherAccounts", true);
if(!contains("DataSource.mySQLColumnId"))
set("DataSource.mySQLColumnId", "id");
if(!contains("Email.mailSenderName"))
set("Email.mailSenderName", "");
if(!contains("Security.captcha.useCaptcha"))
set("Security.captcha.useCaptcha", false);
if(!contains("Security.captcha.maxLoginTry"))
set("Security.captcha.maxLoginTry", 5);
if(!contains("Security.captcha.captchaLength"))
set("Security.captcha.captchaLength", 5);
if(!contains("Email.mailSubject"))
set("Email.mailSubject", "");
if(!contains("Email.mailText"))
set("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");
if(contains("Email.mailText")) {
try {
String s = getString("Email.mailText");
s = s.replaceAll("\n", "<br />");
set("Email.mailText", null);
set("Email.mailText", s);
} catch (Exception e) {}
}
if(!contains("settings.registration.enableEmailRegistrationSystem"))
set("settings.registration.enableEmailRegistrationSystem", false);
if(!contains("settings.security.doubleMD5SaltLength"))
set("settings.security.doubleMD5SaltLength", 8);
if(!contains("Email.maxRegPerEmail"))
set("Email.maxRegPerEmail", 1);
if(!contains("Hooks.multiverse")) {
set("Hooks.multiverse", true);
set("Hooks.chestshop", true);
set("Hooks.notifications", true);
set("Hooks.bungeecord", false);
}
if(!contains("settings.restrictions.ForceSpawnOnTheseWorlds"))
set("settings.restrictions.ForceSpawnOnTheseWorlds", new ArrayList<String>());
if(!contains("settings.restrictions.banUnsafedIP"))
set("settings.restrictions.banUnsafedIP", false);
if(!contains("settings.registration.doubleEmailCheck"))
set("settings.registration.doubleEmailCheck", false);
if(!contains("settings.sessions.sessionExpireOnIpChange"))
set("settings.sessions.sessionExpireOnIpChange", false);
if(!contains("Security.console.logConsole"))
set("Security.console.logConsole", false);
if(!contains("Hooks.disableSocialSpy"))
set("Hooks.disableSocialSpy", true);
if(!contains("Performances.useMultiThreading"))
set("Performances.useMultiThreading", true);
if(!contains("ExternalBoardOptions.bCryptLog2Round"))
set("ExternalBoardOptions.bCryptLog2Round", 10);
if(!contains("DataSource.mySQLlastlocWorld"))
set("DataSource.mySQLlastlocWorld", "world");
if(!contains("settings.GameMode.ForceOnlyAfterLogin"))
set("settings.GameMode.ForceOnlyAfterLogin", false);
if(!contains("Hooks.useEssentialsMotd"))
set("Hooks.useEssentialsMotd", false);
if(!contains("Purge.useAutoPurge")) {
set("Purge.useAutoPurge", false);
set("Purge.daysBeforeRemovePlayer", 60);
set("Purge.removePlayerDat", false);
set("Purge.removeEssentialsFile", false);
set("Purge.defaultWorld", "world");
}
if(!contains("ExternalBoardOptions.phpbbTablePrefix")) {
set("ExternalBoardOptions.phpbbTablePrefix", "phpbb_");
set("ExternalBoardOptions.phpbbActivatedGroupId", 2);
}
if(!contains("settings.security.supportOldPasswordHash"))
set("settings.security.supportOldPasswordHash", false);
if(!contains("ExternalBoardOptions.wordpressTablePrefix"))
set("ExternalBoardOptions.wordpressTablePrefix", "wp_");
if(contains("Xenoforo.predefinedSalt"))
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");
plugin.getLogger().info("Merge new Config Options if needed..");
plugin.saveConfig();
return;
}
private static HashAlgorithm getPasswordHash() {
String key = "settings.security.passwordHash";
try {
return HashAlgorithm.valueOf(configFile.getString(key,"SHA256").toUpperCase());
} catch (IllegalArgumentException ex) {
ConsoleLogger.showError("Unknown Hash Algorithm; defaulting to SHA256");
return HashAlgorithm.SHA256;
}
}
private static HashAlgorithm getRakamakHash() {
String key = "Converter.Rakamak.newPasswordHash";
try {
return HashAlgorithm.valueOf(configFile.getString(key,"SHA256").toUpperCase());
} catch (IllegalArgumentException ex) {
ConsoleLogger.showError("Unknown Hash Algorithm; defaulting to SHA256");
return HashAlgorithm.SHA256;
}
}
private static DataSourceType getDataSource() {
String key = "DataSource.backend";
try {
return DataSource.DataSourceType.valueOf(configFile.getString(key).toUpperCase());
} catch (IllegalArgumentException ex) {
ConsoleLogger.showError("Unknown database backend; defaulting to file database");
return DataSource.DataSourceType.FILE;
}
}
/**
* Config option for setting and check restricted user by
* username;ip , return false if ip and name doesnt amtch with
* player that join the server, so player has a restricted access
*/
public static Boolean getRestrictedIp(String name, String ip) {
Iterator<String> iter = getRestrictedIp.iterator();
Boolean trueonce = false;
Boolean namefound = false;
while (iter.hasNext()) {
String[] args = iter.next().split(";");
String testname = args[0];
String testip = args[1];
if(testname.equalsIgnoreCase(name) ) {
namefound = true;
if(testip.equalsIgnoreCase(ip)) {
trueonce = true;
};
}
}
if ( namefound == false){
return true;
}
else {
if ( trueonce == true ){
return true;
} else {
return false;
}
}
}
/**
* Loads the configuration from disk
*
* @return True if loaded successfully
*/
public final boolean load() {
try {
load(file);
return true;
} catch (Exception ex) {
return false;
}
}
public final void reload() {
load();
loadDefaults(file.getName());
}
/**
* Saves the configuration to disk
*
* @return True if saved successfully
*/
public final boolean save() {
try {
save(file);
return true;
} catch (Exception ex) {
return false;
}
}
/**
* Simple function for if the Configuration file exists
*
* @return True if configuration exists on disk
*/
public final boolean exists() {
return file.exists();
}
/**
* Loads a file from the plugin jar and sets as default
*
* @param filename The filename to open
*/
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.
*
* If defaults and configuration are empty, saves blank file.
*
* @return True if saved successfully
*/
public final boolean saveDefaults() {
options().copyDefaults(true);
options().copyHeader(true);
boolean success = save();
options().copyDefaults(false);
options().copyHeader(false);
return success;
}
/**
* Clears current configuration defaults
*/
public final void clearDefaults() {
setDefaults(new MemoryConfiguration());
}
/**
* Check loaded defaults against current configuration
*
* @return false When all defaults aren't present in config
*/
public boolean checkDefaults() {
if (getDefaults() == null) {
return true;
}
return getKeys(true).containsAll(getDefaults().getKeys(true));
}
public static String checkLang(String lang) {
for(messagesLang language: messagesLang.values()) {
if(lang.toLowerCase().contains(language.toString())) {
ConsoleLogger.info("Set Language: "+lang);
return lang;
}
}
ConsoleLogger.info("Set Default Language: En ");
return "en";
}
public enum messagesLang {
en, de, br, cz, pl, fr, ru, hu, sk, es, zhtw, fi, zhcn, lt, it, ko, pt
}
}
@@ -0,0 +1,74 @@
package fr.xephi.authme.settings;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
/**
*
* @author Xephi59
*/
public class Spawn extends CustomConfiguration {
private static Spawn spawn;
private static List<String> emptyList = new ArrayList<String>();
public Spawn() {
super(new File("./plugins/AuthMe/spawn.yml"));
spawn = this;
load();
save();
saveDefault();
}
private void saveDefault() {
if (!contains("spawn")) {
set("spawn", emptyList);
set("spawn.world", "");
set("spawn.x", "");
set("spawn.y", "");
set("spawn.z", "");
set("spawn.yaw", "");
set("spawn.pitch", "");
save();
}
}
public static Spawn getInstance() {
if (spawn == null) {
spawn = new Spawn();
}
return spawn;
}
public boolean setSpawn(Location location) {
try {
set("spawn.world", location.getWorld().getName());
set("spawn.x", location.getX());
set("spawn.y", location.getY());
set("spawn.z", location.getZ());
set("spawn.yaw", location.getYaw());
set("spawn.pitch", location.getPitch());
save();
return true;
} catch (NullPointerException npe) {
return false;
}
}
public Location getLocation() {
try {
if (this.getString("spawn.world").isEmpty() || this.getString("spawn.world") == "") return null;
Location location = new Location(Bukkit.getWorld(this.getString("spawn.world")), this.getDouble("spawn.x"), this.getDouble("spawn.y"), this.getDouble("spawn.z"), Float.parseFloat(this.getString("spawn.yaw")), Float.parseFloat(this.getString("spawn.pitch")));
return location;
} catch (NullPointerException npe) {
return null;
} catch (NumberFormatException nfe) {
return null;
}
}
}
@@ -0,0 +1,38 @@
package fr.xephi.authme.settings;
import java.io.File;
import java.util.ArrayList;
public class SpoutCfg extends CustomConfiguration{
private static SpoutCfg instance = null;
public SpoutCfg(File file)
{
super(file);
loadDefaults();
load();
save();
}
@SuppressWarnings("serial")
private void loadDefaults() {
this.set("Spout GUI enabled", true);
this.set("LoginScreen.enabled", true);
this.set("LoginScreen.exit button", "Quit");
this.set("LoginScreen.exit message", "Good Bye");
this.set("LoginScreen.login button", "Login");
this.set("LoginScreen.title", "LOGIN");
this.set("LoginScreen.text", new ArrayList<String>() {{
add("Sample text");
add("Change this at spout.yml");
add("--- AuthMe Reloaded by ---");
add("Xephi59");
}});
}
public static SpoutCfg getInstance() {
if (instance == null) instance = new SpoutCfg(new File("plugins/AuthMe", "spout.yml"));
return instance;
}
}