diff --git a/circle.yml b/circle.yml new file mode 100644 index 00000000..85064c5c --- /dev/null +++ b/circle.yml @@ -0,0 +1,9 @@ +machine: + java: + version: oraclejdk7 +general: + artifacts: + - "target/*.jar" +test: + override: + - mvn clean install diff --git a/libs/Citizens.jar b/libs/Citizens.jar deleted file mode 100644 index 9cf4d17c..00000000 Binary files a/libs/Citizens.jar and /dev/null differ diff --git a/libs/Notifications.jar b/libs/Notifications.jar deleted file mode 100644 index 0a862e66..00000000 Binary files a/libs/Notifications.jar and /dev/null differ diff --git a/libs/xAuth.jar b/libs/xAuth.jar deleted file mode 100644 index 0b943212..00000000 Binary files a/libs/xAuth.jar and /dev/null differ diff --git a/pom.xml b/pom.xml index c6f2877a..fcccfad1 100644 --- a/pom.xml +++ b/pom.xml @@ -3,8 +3,8 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - fr.xephi.authme - AuthMe + fr.xephi + authme 5.0-SNAPSHOT AuthMeReloaded @@ -22,8 +22,6 @@ 1.8.7-R0.1-SNAPSHOT - - ${project.groupId}.${project.artifactId} @@ -77,6 +75,7 @@ ${manifest.file} + AuthMe-${project.version} @@ -90,8 +89,15 @@ com.sun.mail:* javax.mail:* com.comphenix.attribute:* + org.mcstats.*:* + + + org.mcstats + fr.xephi.authme + + @@ -113,6 +119,12 @@ https://hub.spigotmc.org/nexus/content/groups/public/ + + + Plugin Metrics + http://repo.mcstats.org/content/repositories/public + + vault-repo @@ -128,7 +140,7 @@ ess-repo - http://repo.ess3.net/content/groups/public + http://repo.ess3.net/content/groups/essentials @@ -143,12 +155,6 @@ http://repo.luricos.de/content/repositories/releases/ - - - sonatype-nexus-snapshots - https://oss.sonatype.org/content/repositories/snapshots - - comphenix-snapshots @@ -181,13 +187,6 @@ 3.8.10.1 - - - com.h2database - h2 - 1.4.187 - - com.sun.mail @@ -202,6 +201,23 @@ 1.2.14 + + org.mcstats.bukkit + metrics + R7 + compile + + + org.bukkit + bukkit + + + org.bukkit + craftbukkit + + + + @@ -348,23 +364,6 @@ - - - org.spoutcraft - spoutcraftplugin - 1.6.4-SNAPSHOT - - - org.bukkit - bukkit - - - org.bukkit - craftbukkit - - - - @@ -376,32 +375,5 @@ ${project.basedir}/libs/ChestShop.jar - - - net.citizensnpcs - citizens - 1.2.4 - system - ${project.basedir}/libs/Citizens.jar - - - - - com.cypherx - xauth - 2.0.26 - system - ${project.basedir}/libs/xAuth.jar - - - - - me.muizers - Notifications - 1.6 - system - ${project.basedir}/libs/Notifications.jar - - diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java index 4f44363a..c1b99337 100644 --- a/src/main/java/fr/xephi/authme/AuthMe.java +++ b/src/main/java/fr/xephi/authme/AuthMe.java @@ -3,6 +3,7 @@ package fr.xephi.authme; import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; +import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; @@ -14,13 +15,10 @@ import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.List; +import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Logger; import java.util.zip.GZIPInputStream; -import me.muizers.Notifications.Notifications; -import net.citizensnpcs.Citizens; -import net.milkbowl.vault.permission.Permission; - import org.apache.logging.log4j.LogManager; import org.bukkit.Bukkit; import org.bukkit.Location; @@ -31,6 +29,8 @@ import org.bukkit.entity.Player; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.scheduler.BukkitTask; +import org.mcstats.Metrics; import com.earth2me.essentials.Essentials; import com.maxmind.geoip.LookupService; @@ -63,7 +63,6 @@ import fr.xephi.authme.listener.AuthMeChestShopListener; import fr.xephi.authme.listener.AuthMeEntityListener; import fr.xephi.authme.listener.AuthMePlayerListener; import fr.xephi.authme.listener.AuthMeServerListener; -import fr.xephi.authme.listener.AuthMeSpoutListener; import fr.xephi.authme.plugin.manager.BungeeCordMessage; import fr.xephi.authme.plugin.manager.CitizensCommunicator; import fr.xephi.authme.plugin.manager.CombatTagComunicator; @@ -74,6 +73,7 @@ import fr.xephi.authme.settings.OtherAccounts; import fr.xephi.authme.settings.PlayersLogs; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Spawn; +import net.milkbowl.vault.permission.Permission; public class AuthMe extends JavaPlugin { @@ -89,13 +89,12 @@ public class AuthMe extends JavaPlugin { private Utils utils = Utils.getInstance(); private FileCache playerBackup = new FileCache(this); public CitizensCommunicator citizens; + public boolean isCitizensActive = false; public SendMailSSL mail = null; - public int CitizensVersion = 0; - public int CombatTag = 0; + public boolean CombatTag = false; public double ChestShop = 0; public boolean BungeeCord = false; public Essentials ess; - public Notifications notifications; public API api; public Management management; public HashMap captcha = new HashMap(); @@ -108,6 +107,7 @@ public class AuthMe extends JavaPlugin { public boolean delayedAntiBot = true; protected static String vgUrl = "http://monitor-1.verygames.net/api/?action=ipclean-real-ip&out=raw&ip=%IP%&port=%PORT%"; public DataManager dataManager; + public ConcurrentHashMap sessions = new ConcurrentHashMap(); public Settings getSettings() { return settings; @@ -128,6 +128,15 @@ public class AuthMe extends JavaPlugin { return; } + try { + Metrics metrics = new Metrics(this); + metrics.start(); + ConsoleLogger.info("Metrics started successfully!"); + } catch (IOException e) { + // Failed to submit the stats :-( + ConsoleLogger.showError("Can't start Metrics! The plugin will work anyway..."); + } + citizens = new CitizensCommunicator(this); if (Settings.enableAntiBot) { @@ -178,9 +187,6 @@ public class AuthMe extends JavaPlugin { // Check Combat Tag Version combatTag(); - // Check Notifications - checkNotifications(); - // Check Multiverse checkMultiverse(); @@ -200,37 +206,7 @@ public class AuthMe extends JavaPlugin { else ConsoleLogger.showError("Error while making Backup"); } - /* - * Backend MYSQL - FILE - SQLITE - */ - switch (Settings.getDataSource) { - case FILE: - FlatFile fileThread = new FlatFile(); - database = fileThread; - final int a = database.getAccountsRegistered(); - if (a >= 1000) { - ConsoleLogger.showError("YOU'RE USING FILE DATABASE WITH " + a + "+ ACCOUNTS, FOR BETTER PERFORMANCES, PLEASE USE MYSQL!!"); - } - break; - case MYSQL: - MySQL sqlThread = new MySQL(); - database = sqlThread; - break; - case SQLITE: - SQLite sqliteThread = new SQLite(); - database = sqliteThread; - final int b = database.getAccountsRegistered(); - if (b >= 2000) { - ConsoleLogger.showError("YOU'RE USING SQLITE DATABASE WITH " + b + "+ ACCOUNTS, FOR BETTER PERFORMANCES, PLEASE USE MYSQL!!"); - } - break; - } - - if (Settings.isCachingEnabled) { - database = new CacheDataSource(this, database); - } - - database = new DatabaseCalls(this, database); + setupDatabase(); dataManager = new DataManager(this, database); @@ -245,10 +221,7 @@ public class AuthMe extends JavaPlugin { Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeCordMessage(this)); } - if (pm.isPluginEnabled("Spout")) { - pm.registerEvents(new AuthMeSpoutListener(database), this); - ConsoleLogger.info("Successfully hook with Spout!"); - } + pm.registerEvents(new AuthMePlayerListener(this, database), this); pm.registerEvents(new AuthMeBlockListener(database, this), this); pm.registerEvents(new AuthMeEntityListener(database, this), this); @@ -270,7 +243,7 @@ public class AuthMe extends JavaPlugin { this.getCommand("converter").setExecutor(new ConverterCommand(this, database)); if (!Settings.isForceSingleSessionEnabled) { - ConsoleLogger.showError("ATTENTION by disabling ForceSingleSession, your server protection is set to low"); + ConsoleLogger.showError("BECAREFUL !!! By disabling ForceSingleSession, your server protection is set to LOW"); } if (Settings.reloadSupport) @@ -281,19 +254,15 @@ public class AuthMe extends JavaPlugin { if (Bukkit.class.getMethod("getOnlinePlayers", new Class[0]).getReturnType() == Collection.class) playersOnline = ((Collection) Bukkit.class.getMethod("getOnlinePlayers", new Class[0]).invoke(null, new Object[0])).size(); else playersOnline = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers", new Class[0]).invoke(null, new Object[0])).length; - } catch (NoSuchMethodException ex) { - } // can never happen - catch (InvocationTargetException ex) { - } // can also never happen - catch (IllegalAccessException ex) { - } // can still never happen + } catch (Exception ex) { + } if (playersOnline < 1) { try { database.purgeLogged(); } catch (NullPointerException npe) { } } - } catch (NullPointerException ex) { + } catch (Exception ex) { } if (Settings.usePurge) @@ -306,8 +275,7 @@ public class AuthMe extends JavaPlugin { recallEmail(); // Sponsor message - ConsoleLogger.info("[SPONSOR] AuthMe is sponsored and hook perfectly with server hosting VERYGAMES, rent your server for only 1.99$/months"); - ConsoleLogger.info("[SPONSOR] Look Minecraft and other offers on www.verygames.net ! "); + ConsoleLogger.info("AuthMe hook perfectly with server hosting VERYGAMES"); ConsoleLogger.info("Authme " + this.getDescription().getVersion() + " enabled"); } @@ -419,40 +387,18 @@ public class AuthMe extends JavaPlugin { } } - public void checkNotifications() { - if (!Settings.notifications) { - this.notifications = null; - return; - } - if (this.getServer().getPluginManager().getPlugin("Notifications") != null && this.getServer().getPluginManager().getPlugin("Notifications").isEnabled()) { - this.notifications = (Notifications) this.getServer().getPluginManager().getPlugin("Notifications"); - ConsoleLogger.info("Successfully hook with Notifications"); - } else { - this.notifications = null; - } - } - public void combatTag() { if (this.getServer().getPluginManager().getPlugin("CombatTag") != null && this.getServer().getPluginManager().getPlugin("CombatTag").isEnabled()) { - this.CombatTag = 1; + this.CombatTag = true; } else { - this.CombatTag = 0; + this.CombatTag = false; } } public void citizensVersion() { - if (this.getServer().getPluginManager().getPlugin("Citizens") != null && this.getServer().getPluginManager().getPlugin("Citizens").isEnabled()) { - Citizens cit = (Citizens) this.getServer().getPluginManager().getPlugin("Citizens"); - String ver = cit.getDescription().getVersion(); - String[] args = ver.split("\\."); - if (args[0].contains("1")) { - this.CitizensVersion = 1; - } else { - this.CitizensVersion = 2; - } - } else { - this.CitizensVersion = 0; - } + if (this.getServer().getPluginManager().getPlugin("Citizens") != null && this.getServer().getPluginManager().getPlugin("Citizens").isEnabled()) + this.isCitizensActive = true; + else this.isCitizensActive = false; } @Override @@ -502,7 +448,7 @@ public class AuthMe extends JavaPlugin { } } return; - } catch (NullPointerException ex) { + } catch (Exception ex) { return; } } @@ -511,8 +457,8 @@ public class AuthMe extends JavaPlugin { return authme; } - public void savePlayer(Player player) throws IllegalStateException, - NullPointerException { + public void savePlayer(Player player) + throws IllegalStateException, NullPointerException { try { if ((citizens.isNPC(player, this)) || (Utils.getInstance().isUnrestricted(player)) || (CombatTagComunicator.isNPC(player))) { return; @@ -827,4 +773,33 @@ public class AuthMe extends JavaPlugin { } return realIP; } + + public void setupDatabase() { + /* + * Backend MYSQL - FILE - SQLITE + */ + switch (Settings.getDataSource) { + case FILE: + database = new FlatFile(); + final int a = database.getAccountsRegistered(); + if (a >= 1000) + ConsoleLogger.showError("YOU'RE USING FILE DATABASE WITH " + a + "+ ACCOUNTS, FOR BETTER PERFORMANCES, PLEASE USE MYSQL!!"); + break; + case MYSQL: + database = new MySQL(); + break; + case SQLITE: + database = new SQLite(); + final int b = database.getAccountsRegistered(); + if (b >= 2000) + ConsoleLogger.showError("YOU'RE USING SQLITE DATABASE WITH " + b + "+ ACCOUNTS, FOR BETTER PERFORMANCES, PLEASE USE MYSQL!!"); + break; + } + + if (Settings.isCachingEnabled) { + database = new CacheDataSource(this, database); + } + + database = new DatabaseCalls(this, database); + } } diff --git a/src/main/java/fr/xephi/authme/SendMailSSL.java b/src/main/java/fr/xephi/authme/SendMailSSL.java index 4d379379..5c1288d6 100644 --- a/src/main/java/fr/xephi/authme/SendMailSSL.java +++ b/src/main/java/fr/xephi/authme/SendMailSSL.java @@ -72,13 +72,7 @@ public class SendMailSSL { message.setSentDate(new Date()); BodyPart messageBodyPart = new MimeBodyPart(); messageBodyPart.setText(mailText); - Multipart multipart = new MimeMultipart(); - - multipart.addBodyPart(messageBodyPart); - - messageBodyPart = new MimeBodyPart(); - multipart.addBodyPart(messageBodyPart); message.setContent(multipart); Transport transport = session.getTransport("smtp"); diff --git a/src/main/java/fr/xephi/authme/api/API.java b/src/main/java/fr/xephi/authme/api/API.java index 75220e7f..1117dbdf 100644 --- a/src/main/java/fr/xephi/authme/api/API.java +++ b/src/main/java/fr/xephi/authme/api/API.java @@ -1,174 +1,188 @@ -package fr.xephi.authme.api; - -import java.security.NoSuchAlgorithmException; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.entity.Player; -import org.bukkit.inventory.ItemStack; -import org.bukkit.plugin.Plugin; -import fr.xephi.authme.AuthMe; -import fr.xephi.authme.Utils; -import fr.xephi.authme.cache.auth.PlayerAuth; -import fr.xephi.authme.cache.auth.PlayerCache; -import fr.xephi.authme.datasource.DataSource; -import fr.xephi.authme.plugin.manager.CombatTagComunicator; -import fr.xephi.authme.security.PasswordSecurity; -import fr.xephi.authme.settings.Settings; - -public class API { - - public static final String newline = System.getProperty("line.separator"); - public static AuthMe instance; - public static DataSource database; - - public API(AuthMe instance, DataSource database) { - API.instance = instance; - API.database = database; - } - - /** - * Hook into AuthMe - * - * @return AuthMe instance - */ - public static AuthMe hookAuthMe() { - Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("AuthMe"); - if (plugin == null || !(plugin instanceof AuthMe)) { - return null; - } - return (AuthMe) plugin; - } - - public AuthMe getPlugin() { - return instance; - } - - /** - * - * @param player - * @return true if player is authenticate - */ - public static boolean isAuthenticated(Player player) { - return PlayerCache.getInstance().isAuthenticated(player.getName()); - } - - /** - * - * @param player - * @return true if player is a npc - */ - @Deprecated - public boolean isaNPC(Player player) { - if (instance.getCitizensCommunicator().isNPC(player, instance)) - return true; - return CombatTagComunicator.isNPC(player); - } - - /** - * - * @param player - * @return true if player is a npc - */ - public boolean isNPC(Player player) { - if (instance.getCitizensCommunicator().isNPC(player, instance)) - return true; - return CombatTagComunicator.isNPC(player); - } - - /** - * - * @param player - * @return true if the player is unrestricted - */ - public static boolean isUnrestricted(Player player) { - return Utils.getInstance().isUnrestricted(player); - } - - public static Location getLastLocation(Player player) { - try { - PlayerAuth auth = PlayerCache.getInstance().getAuth(player.getName().toLowerCase()); - - if (auth != null) { - Location loc = new Location(Bukkit.getWorld(auth.getWorld()), auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ()); - return loc; - } else { - return null; - } - - } catch (NullPointerException ex) { - return null; - } - } - - public static void setPlayerInventory(Player player, ItemStack[] content, - ItemStack[] armor) { - try { - player.getInventory().setContents(content); - player.getInventory().setArmorContents(armor); - } catch (NullPointerException npe) { - } - } - - /** - * - * @param playerName - * @return true if player is registered - */ - public static boolean isRegistered(String playerName) { - String player = playerName.toLowerCase(); - return database.isAuthAvailable(player); - } - - /** - * @param String - * playerName, String passwordToCheck - * @return true if the password is correct , false else - */ - public static boolean checkPassword(String playerName, - String passwordToCheck) { - if (!isRegistered(playerName)) - return false; - String player = playerName.toLowerCase(); - PlayerAuth auth = database.getAuth(player); - try { - return PasswordSecurity.comparePasswordWithHash(passwordToCheck, auth.getHash(), playerName); - } catch (NoSuchAlgorithmException e) { - return false; - } - } - - /** - * Register a player - * - * @param String - * playerName, String password - * @return true if the player is register correctly - */ - public static boolean registerPlayer(String playerName, String password) { - try { - String name = playerName.toLowerCase(); - String hash = PasswordSecurity.getHash(Settings.getPasswordHash, password, name); - if (isRegistered(name)) { - return false; - } - PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0, "your@email.com"); - if (!database.saveAuth(auth)) { - return false; - } - return true; - } catch (NoSuchAlgorithmException ex) { - return false; - } - } - - /** - * Force a player to login - * - * @param Player - * player - */ - public static void forceLogin(Player player) { - instance.management.performLogin(player, "dontneed", true); - } - -} +package fr.xephi.authme.api; + +import java.security.NoSuchAlgorithmException; + +import org.bukkit.Bukkit; +import org.bukkit.Location; +import org.bukkit.Server; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.plugin.Plugin; + +import fr.xephi.authme.AuthMe; +import fr.xephi.authme.Utils; +import fr.xephi.authme.cache.auth.PlayerAuth; +import fr.xephi.authme.cache.auth.PlayerCache; +import fr.xephi.authme.datasource.DataSource; +import fr.xephi.authme.plugin.manager.CombatTagComunicator; +import fr.xephi.authme.security.PasswordSecurity; +import fr.xephi.authme.settings.Settings; + +public class API { + + public static final String newline = System.getProperty("line.separator"); + public static API singleton; + public AuthMe plugin; + public DataSource database; + + public API(AuthMe plugin, DataSource database) { + this.plugin = plugin; + this.database = database; + } + + public API(Server serv) { + this.plugin = (AuthMe) serv.getPluginManager().getPlugin("AuthMe"); + this.database = this.plugin.database; + } + + /** + * Hook into AuthMe + * + * @return + * + * @return AuthMe plugin + */ + public static API getInstance() { + if (singleton != null) + return singleton; + Plugin p = Bukkit.getServer().getPluginManager().getPlugin("AuthMe"); + if (p == null || !(p instanceof AuthMe)) { + return null; + } + AuthMe authme = (AuthMe) p; + singleton = (new API(authme, authme.database)); + return singleton; + } + + public AuthMe getPlugin() { + return plugin; + } + + /** + * + * @param player + * @return true if player is authenticate + */ + public boolean isAuthenticated(Player player) { + return PlayerCache.getInstance().isAuthenticated(player.getName()); + } + + /** + * + * @param player + * @return true if player is a npc + */ + @Deprecated + public boolean isaNPC(Player player) { + if (plugin.getCitizensCommunicator().isNPC(player, plugin)) + return true; + return CombatTagComunicator.isNPC(player); + } + + /** + * + * @param player + * @return true if player is a npc + */ + public boolean isNPC(Player player) { + if (plugin.getCitizensCommunicator().isNPC(player, plugin)) + return true; + return CombatTagComunicator.isNPC(player); + } + + /** + * + * @param player + * @return true if the player is unrestricted + */ + public boolean isUnrestricted(Player player) { + return Utils.getInstance().isUnrestricted(player); + } + + public Location getLastLocation(Player player) { + try { + PlayerAuth auth = PlayerCache.getInstance().getAuth(player.getName().toLowerCase()); + + if (auth != null) { + Location loc = new Location(Bukkit.getWorld(auth.getWorld()), auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ()); + return loc; + } else { + return null; + } + + } catch (NullPointerException ex) { + return null; + } + } + + public void setPlayerInventory(Player player, ItemStack[] content, + ItemStack[] armor) { + try { + player.getInventory().setContents(content); + player.getInventory().setArmorContents(armor); + } catch (NullPointerException npe) { + } + } + + /** + * + * @param playerName + * @return true if player is registered + */ + public boolean isRegistered(String playerName) { + String player = playerName.toLowerCase(); + return database.isAuthAvailable(player); + } + + /** + * @param String + * playerName, String passwordToCheck + * @return true if the password is correct , false else + */ + public boolean checkPassword(String playerName, String passwordToCheck) { + if (!isRegistered(playerName)) + return false; + String player = playerName.toLowerCase(); + PlayerAuth auth = database.getAuth(player); + try { + return PasswordSecurity.comparePasswordWithHash(passwordToCheck, auth.getHash(), playerName); + } catch (NoSuchAlgorithmException e) { + return false; + } + } + + /** + * Register a player + * + * @param String + * playerName, String password + * @return true if the player is register correctly + */ + public boolean registerPlayer(String playerName, String password) { + try { + String name = playerName.toLowerCase(); + String hash = PasswordSecurity.getHash(Settings.getPasswordHash, password, name); + if (isRegistered(name)) { + return false; + } + PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0, "your@email.com"); + if (!database.saveAuth(auth)) { + return false; + } + return true; + } catch (NoSuchAlgorithmException ex) { + return false; + } + } + + /** + * Force a player to login + * + * @param Player + * player + */ + public void forceLogin(Player player) { + plugin.management.performLogin(player, "dontneed", true); + } + +} diff --git a/src/main/java/fr/xephi/authme/commands/AdminCommand.java b/src/main/java/fr/xephi/authme/commands/AdminCommand.java index 2d2467eb..947df69a 100644 --- a/src/main/java/fr/xephi/authme/commands/AdminCommand.java +++ b/src/main/java/fr/xephi/authme/commands/AdminCommand.java @@ -39,7 +39,6 @@ import fr.xephi.authme.security.PasswordSecurity; import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Spawn; -import fr.xephi.authme.settings.SpoutCfg; import fr.xephi.authme.task.MessageTask; import fr.xephi.authme.task.TimeoutTask; @@ -47,7 +46,6 @@ public class AdminCommand implements CommandExecutor { public AuthMe plugin; private Messages m = Messages.getInstance(); - private SpoutCfg s = SpoutCfg.getInstance(); public DataSource database; public AdminCommand(AuthMe plugin, DataSource database) { @@ -125,7 +123,6 @@ public class AdminCommand implements CommandExecutor { return true; } } else if (args[0].equalsIgnoreCase("reload")) { - database.reload(); File newConfigFile = new File("plugins" + File.separator + "AuthMe", "config.yml"); if (!newConfigFile.exists()) { InputStream fis = getClass().getResourceAsStream("" + File.separator + "config.yml"); @@ -155,7 +152,8 @@ public class AdminCommand implements CommandExecutor { YamlConfiguration newConfig = YamlConfiguration.loadConfiguration(newConfigFile); Settings.reloadConfigOptions(newConfig); m.reLoad(); - s.reLoad(); + plugin.database.close(); + plugin.setupDatabase(); m.send(sender, "reload"); } else if (args[0].equalsIgnoreCase("lastlogin")) { if (args.length != 2) { diff --git a/src/main/java/fr/xephi/authme/commands/ChangePasswordCommand.java b/src/main/java/fr/xephi/authme/commands/ChangePasswordCommand.java index 14daf27b..c6c5fb5c 100644 --- a/src/main/java/fr/xephi/authme/commands/ChangePasswordCommand.java +++ b/src/main/java/fr/xephi/authme/commands/ChangePasswordCommand.java @@ -2,8 +2,6 @@ package fr.xephi.authme.commands; import java.security.NoSuchAlgorithmException; -import me.muizers.Notifications.Notification; - import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -58,7 +56,7 @@ public class ChangePasswordCommand implements CommandExecutor { m.send(player, "password_error"); return true; } - if ((lowpass.equalsIgnoreCase(name))){ + if ((lowpass.equalsIgnoreCase(name))) { m.send(player, "password_error_nick"); return true; } @@ -89,9 +87,6 @@ public class ChangePasswordCommand implements CommandExecutor { PlayerCache.getInstance().updatePlayer(auth); m.send(player, "pwd_changed"); ConsoleLogger.info(player.getName() + " changed his password"); - if (plugin.notifications != null) { - plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " change his password!")); - } } else { m.send(player, "wrong_pwd"); } diff --git a/src/main/java/fr/xephi/authme/commands/EmailCommand.java b/src/main/java/fr/xephi/authme/commands/EmailCommand.java index 7a4d81ca..ab32be6d 100644 --- a/src/main/java/fr/xephi/authme/commands/EmailCommand.java +++ b/src/main/java/fr/xephi/authme/commands/EmailCommand.java @@ -2,7 +2,6 @@ package fr.xephi.authme.commands; import java.security.NoSuchAlgorithmException; -import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -172,21 +171,8 @@ public class EmailCommand implements CommandExecutor { m.send(player, "email_invalid"); return true; } - final String finalhashnew = hashnew; - final PlayerAuth finalauth = auth; - if (data instanceof Thread) { - finalauth.setHash(hashnew); - data.updatePassword(auth); - } else { - Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { - - @Override - public void run() { - finalauth.setHash(finalhashnew); - data.updatePassword(finalauth); - } - }); - } + auth.setHash(hashnew); + data.updatePassword(auth); plugin.mail.main(auth, thePass); m.send(player, "email_send"); } catch (NoSuchAlgorithmException ex) { diff --git a/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java b/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java index 6c370b1e..0b8bf943 100644 --- a/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java +++ b/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java @@ -27,7 +27,6 @@ import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.task.MessageTask; import fr.xephi.authme.task.TimeoutTask; -import me.muizers.Notifications.Notification; public class UnregisterCommand implements CommandExecutor { @@ -98,9 +97,6 @@ public class UnregisterCommand implements CommandExecutor { LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("reg_msg"), interval))); m.send(player, "unregistered"); ConsoleLogger.info(player.getDisplayName() + " unregistered himself"); - if (plugin.notifications != null) { - plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " unregistered himself!")); - } return true; } if (!Settings.unRegisteredGroup.isEmpty()) { @@ -116,9 +112,6 @@ public class UnregisterCommand implements CommandExecutor { player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2)); m.send(player, "unregistered"); ConsoleLogger.info(player.getDisplayName() + " unregistered himself"); - if (plugin.notifications != null) { - plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " unregistered himself!")); - } if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) { Location spawn = plugin.getSpawnLocation(player); SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false); diff --git a/src/main/java/fr/xephi/authme/converter/oldxAuthToFlat.java b/src/main/java/fr/xephi/authme/converter/oldxAuthToFlat.java deleted file mode 100644 index 89b9abcd..00000000 --- a/src/main/java/fr/xephi/authme/converter/oldxAuthToFlat.java +++ /dev/null @@ -1,132 +0,0 @@ -package fr.xephi.authme.converter; - -import java.io.File; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; - -import org.bukkit.command.CommandSender; - -import com.cypherx.xauth.xAuth; -import com.cypherx.xauth.database.Table; -import com.cypherx.xauth.utils.xAuthLog; - -import fr.xephi.authme.AuthMe; -import fr.xephi.authme.cache.auth.PlayerAuth; -import fr.xephi.authme.datasource.DataSource; - -/** - * - * @author Xephi59 - */ -public class oldxAuthToFlat { - - public AuthMe instance; - public DataSource database; - public CommandSender sender; - - public oldxAuthToFlat(AuthMe instance, DataSource database, - CommandSender sender) { - this.instance = instance; - this.database = database; - this.sender = sender; - } - - public boolean convert() { - if (instance.getServer().getPluginManager().getPlugin("xAuth") == null) { - sender.sendMessage("[AuthMe] xAuth plugin not found"); - return false; - } - if (!(new File(instance.getDataFolder().getParent() + File.separator + "xAuth" + File.separator + "xAuth.h2.db").exists())) { - sender.sendMessage("[AuthMe] xAuth H2 database not found, checking for MySQL or SQLite data..."); - } - List players = getXAuthPlayers(); - if (players == null || players.isEmpty()) { - sender.sendMessage("[AuthMe] Error while import xAuthPlayers"); - return false; - } - sender.sendMessage("[AuthMe] Starting import..."); - try { - for (int id : players) { - String pl = getIdPlayer(id); - String psw = getPassword(id); - if (psw != null && !psw.isEmpty() && pl != null) { - PlayerAuth auth = new PlayerAuth(pl, psw, "198.18.0.1", 0, "your@email.com"); - database.saveAuth(auth); - } - } - sender.sendMessage("[AuthMe] Successfull convert from xAuth database"); - } catch (Exception e) { - sender.sendMessage("[AuthMe] An error has been thrown while import xAuth database, the import hadn't fail but can be not complete "); - } - return true; - } - - public String getIdPlayer(int id) { - String realPass = ""; - Connection conn = xAuth.getPlugin().getDatabaseController().getConnection(); - PreparedStatement ps = null; - ResultSet rs = null; - try { - String sql = String.format("SELECT `playername` FROM `%s` WHERE `id` = ?", xAuth.getPlugin().getDatabaseController().getTable(Table.ACCOUNT)); - ps = conn.prepareStatement(sql); - ps.setInt(1, id); - rs = ps.executeQuery(); - if (!rs.next()) - return null; - realPass = rs.getString("playername").toLowerCase(); - } catch (SQLException e) { - xAuthLog.severe("Failed to retrieve name for account: " + id, e); - return null; - } finally { - xAuth.getPlugin().getDatabaseController().close(conn, ps, rs); - } - return realPass; - } - - public List getXAuthPlayers() { - List xP = new ArrayList(); - Connection conn = xAuth.getPlugin().getDatabaseController().getConnection(); - PreparedStatement ps = null; - ResultSet rs = null; - try { - String sql = String.format("SELECT * FROM `%s`", xAuth.getPlugin().getDatabaseController().getTable(Table.ACCOUNT)); - ps = conn.prepareStatement(sql); - rs = ps.executeQuery(); - while (rs.next()) { - xP.add(rs.getInt("id")); - } - } catch (SQLException e) { - xAuthLog.severe("Cannot import xAuthPlayers", e); - return new ArrayList(); - } finally { - xAuth.getPlugin().getDatabaseController().close(conn, ps, rs); - } - return xP; - } - - public String getPassword(int accountId) { - String realPass = ""; - Connection conn = xAuth.getPlugin().getDatabaseController().getConnection(); - PreparedStatement ps = null; - ResultSet rs = null; - try { - String sql = String.format("SELECT `password`, `pwtype` FROM `%s` WHERE `id` = ?", xAuth.getPlugin().getDatabaseController().getTable(Table.ACCOUNT)); - ps = conn.prepareStatement(sql); - ps.setInt(1, accountId); - rs = ps.executeQuery(); - if (!rs.next()) - return null; - realPass = rs.getString("password"); - } catch (SQLException e) { - xAuthLog.severe("Failed to retrieve password hash for account: " + accountId, e); - return null; - } finally { - xAuth.getPlugin().getDatabaseController().close(conn, ps, rs); - } - return realPass; - } -} diff --git a/src/main/java/fr/xephi/authme/converter/xAuthConverter.java b/src/main/java/fr/xephi/authme/converter/xAuthConverter.java index cdb8e764..46f549ea 100644 --- a/src/main/java/fr/xephi/authme/converter/xAuthConverter.java +++ b/src/main/java/fr/xephi/authme/converter/xAuthConverter.java @@ -21,17 +21,11 @@ public class xAuthConverter implements Converter { @Override public void run() { try { - Class.forName("com.cypherx.xauth.xAuth"); - oldxAuthToFlat converter = new oldxAuthToFlat(plugin, database, sender); + Class.forName("de.luricos.bukkit.xAuth.xAuth"); + xAuthToFlat converter = new xAuthToFlat(plugin, database, sender); converter.convert(); - } catch (ClassNotFoundException e) { - try { - Class.forName("de.luricos.bukkit.xAuth.xAuth"); - newxAuthToFlat converter = new newxAuthToFlat(plugin, database, sender); - converter.convert(); - } catch (ClassNotFoundException ce) { - sender.sendMessage("xAuth has not been found, please put xAuth.jar in your plugin folder and restart!"); - } + } catch (ClassNotFoundException ce) { + sender.sendMessage("xAuth has not been found, please put xAuth.jar in your plugin folder and restart!"); } } diff --git a/src/main/java/fr/xephi/authme/converter/newxAuthToFlat.java b/src/main/java/fr/xephi/authme/converter/xAuthToFlat.java similarity index 98% rename from src/main/java/fr/xephi/authme/converter/newxAuthToFlat.java rename to src/main/java/fr/xephi/authme/converter/xAuthToFlat.java index e6732365..02d9946f 100644 --- a/src/main/java/fr/xephi/authme/converter/newxAuthToFlat.java +++ b/src/main/java/fr/xephi/authme/converter/xAuthToFlat.java @@ -17,13 +17,13 @@ import fr.xephi.authme.AuthMe; import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.datasource.DataSource; -public class newxAuthToFlat { +public class xAuthToFlat { public AuthMe instance; public DataSource database; public CommandSender sender; - public newxAuthToFlat(AuthMe instance, DataSource database, + public xAuthToFlat(AuthMe instance, DataSource database, CommandSender sender) { this.instance = instance; this.database = database; diff --git a/src/main/java/fr/xephi/authme/events/SessionEvent.java b/src/main/java/fr/xephi/authme/events/SessionEvent.java deleted file mode 100644 index 01f64006..00000000 --- a/src/main/java/fr/xephi/authme/events/SessionEvent.java +++ /dev/null @@ -1,33 +0,0 @@ -package fr.xephi.authme.events; - -import fr.xephi.authme.cache.auth.PlayerAuth; - -/** - * - * This event is call when a player logging in through a timed session - * - * @author Xephi59 - */ -public class SessionEvent extends CustomEvent { - - private PlayerAuth player; - private boolean isLogin; - - public SessionEvent(PlayerAuth auth, boolean isLogin) { - this.player = auth; - this.isLogin = isLogin; - } - - public PlayerAuth getPlayerAuth() { - return this.player; - } - - public void setPlayer(PlayerAuth player) { - this.player = player; - } - - public boolean isLogin() { - return isLogin; - } - -} diff --git a/src/main/java/fr/xephi/authme/gui/Clickable.java b/src/main/java/fr/xephi/authme/gui/Clickable.java deleted file mode 100644 index 7ff30336..00000000 --- a/src/main/java/fr/xephi/authme/gui/Clickable.java +++ /dev/null @@ -1,8 +0,0 @@ -package fr.xephi.authme.gui; - -import org.getspout.spoutapi.event.screen.ButtonClickEvent; - -public interface Clickable { - - public void handleClick(ButtonClickEvent event); -} diff --git a/src/main/java/fr/xephi/authme/gui/CustomButton.java b/src/main/java/fr/xephi/authme/gui/CustomButton.java deleted file mode 100644 index 06abf145..00000000 --- a/src/main/java/fr/xephi/authme/gui/CustomButton.java +++ /dev/null @@ -1,24 +0,0 @@ -package fr.xephi.authme.gui; - -import org.getspout.spoutapi.event.screen.ButtonClickEvent; -import org.getspout.spoutapi.gui.GenericButton; - -public class CustomButton extends GenericButton { - - public Clickable handleRef = null; - - public CustomButton(Clickable c) { - handleRef = c; - } - - @Override - public void onButtonClick(ButtonClickEvent event) { - handleRef.handleClick(event); - } - - public CustomButton setMidPos(int x, int y) { - this.setX(x).setY(y).shiftXPos(-(width / 2)).shiftYPos(-(height / 2)); - return this; - } - -} diff --git a/src/main/java/fr/xephi/authme/gui/screens/LoginScreen.java b/src/main/java/fr/xephi/authme/gui/screens/LoginScreen.java deleted file mode 100644 index 5137670a..00000000 --- a/src/main/java/fr/xephi/authme/gui/screens/LoginScreen.java +++ /dev/null @@ -1,96 +0,0 @@ -package fr.xephi.authme.gui.screens; - -import java.util.List; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.getspout.spoutapi.event.screen.ButtonClickEvent; -import org.getspout.spoutapi.gui.Button; -import org.getspout.spoutapi.gui.Color; -import org.getspout.spoutapi.gui.GenericLabel; -import org.getspout.spoutapi.gui.GenericPopup; -import org.getspout.spoutapi.gui.GenericTextField; -import org.getspout.spoutapi.gui.RenderPriority; -import org.getspout.spoutapi.gui.Widget; -import org.getspout.spoutapi.gui.WidgetAnchor; -import org.getspout.spoutapi.player.SpoutPlayer; - -import fr.xephi.authme.AuthMe; -import fr.xephi.authme.gui.Clickable; -import fr.xephi.authme.gui.CustomButton; -import fr.xephi.authme.settings.SpoutCfg; - -public class LoginScreen extends GenericPopup implements Clickable { - - public AuthMe plugin = AuthMe.getInstance(); - private SpoutCfg spoutCfg = SpoutCfg.getInstance(); - private CustomButton exitBtn; - private CustomButton loginBtn; - private GenericTextField passBox; - private GenericLabel titleLbl; - private GenericLabel textLbl; - private GenericLabel errorLbl; - - String exitTxt = spoutCfg.getString("LoginScreen.exit button"); - String loginTxt = spoutCfg.getString("LoginScreen.login button"); - String exitMsg = spoutCfg.getString("LoginScreen.exit message"); - String title = spoutCfg.getString("LoginScreen.title"); - @SuppressWarnings("unchecked") - List textlines = (List) spoutCfg.getList("LoginScreen.text"); - public SpoutPlayer splayer; - - public LoginScreen(SpoutPlayer player) { - this.splayer = player; - createScreen(); - } - - private void createScreen() { - int objects = textlines.size() + 4; - int part = !(textlines.size() <= 5) ? 195 / objects : 20; - int h = 3 * part / 4, w = 8 * part; - titleLbl = new GenericLabel(); - titleLbl.setText(title).setTextColor(new Color(1.0F, 0, 0, 1.0F)).setAlign(WidgetAnchor.TOP_CENTER).setHeight(h).setWidth(w).setX(maxWidth / 2).setY(25); - this.attachWidget(plugin, titleLbl); - int ystart = 25 + h + part / 2; - for (int x = 0; x < textlines.size(); x++) { - textLbl = new GenericLabel(); - textLbl.setText(textlines.get(x)).setAlign(WidgetAnchor.TOP_CENTER).setHeight(h).setWidth(w).setX(maxWidth / 2).setY(ystart + x * part); - this.attachWidget(plugin, textLbl); - } - passBox = new GenericTextField(); - passBox.setMaximumCharacters(18).setMaximumLines(1).setHeight(h - 2).setWidth(w - 2).setY(220 - h - 2 * part); - passBox.setPasswordField(true); - setXToMid(passBox); - this.attachWidget(plugin, passBox); - errorLbl = new GenericLabel(); - errorLbl.setText("").setTextColor(new Color(1.0F, 0, 0, 1.0F)).setHeight(h).setWidth(w).setX(passBox.getX() + passBox.getWidth() + 2).setY(passBox.getY()); - this.attachWidget(plugin, errorLbl); - loginBtn = new CustomButton(this); - loginBtn.setText(loginTxt).setHeight(h).setWidth(w).setY(220 - h - part); - setXToMid(loginBtn); - this.attachWidget(plugin, loginBtn); - exitBtn = new CustomButton(this); - exitBtn.setText(exitTxt).setHeight(h).setWidth(w).setY(220 - h); - setXToMid(exitBtn); - this.attachWidget(plugin, exitBtn); - this.setPriority(RenderPriority.Highest); - } - - @EventHandler(priority = EventPriority.HIGHEST) - public void handleClick(ButtonClickEvent event) { - Button b = event.getButton(); - SpoutPlayer player = event.getPlayer(); - if (event.isCancelled() || event == null || event.getPlayer() == null) - return; - if (b.equals(loginBtn)) { - plugin.management.performLogin(player, passBox.getText(), false); - } else if (b.equals(exitBtn)) { - event.getPlayer().kickPlayer(exitMsg); - } - } - - private void setXToMid(Widget w) { - w.setX((maxWidth - w.getWidth()) / 2); - } - -} diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java index afa6c5aa..21885897 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java @@ -39,7 +39,6 @@ import org.bukkit.event.player.PlayerRespawnEvent; import fr.xephi.authme.AuthMe; import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.Utils; -import fr.xephi.authme.api.API; import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.limbo.LimboCache; @@ -54,7 +53,6 @@ public class AuthMePlayerListener implements Listener { public static GameMode gm = GameMode.SURVIVAL; public static ConcurrentHashMap gameMode = new ConcurrentHashMap(); public static ConcurrentHashMap joinMessage = new ConcurrentHashMap(); - private Utils utils = Utils.getInstance(); private Messages m = Messages.getInstance(); public AuthMe plugin; private DataSource data; @@ -344,7 +342,8 @@ public class AuthMePlayerListener implements Listener { } if (!Settings.isMovementAllowed) { - event.setTo(event.getFrom()); + if (!event.getFrom().getBlock().equals(event.getTo().getBlock())) + event.setTo(event.getFrom()); return; } @@ -355,14 +354,15 @@ public class AuthMePlayerListener implements Listener { int radius = Settings.getMovementRadius; Location spawn = plugin.getSpawnLocation(player); - if (spawn != null && spawn.getWorld() != null) + if (spawn != null && spawn.getWorld() != null) { if (!event.getPlayer().getWorld().equals(spawn.getWorld())) { event.getPlayer().teleport(spawn); return; } - if ((spawn.distance(player.getLocation()) > radius) && spawn.getWorld() != null) { - event.getPlayer().teleport(spawn); - return; + if ((spawn.distance(player.getLocation()) > radius)) { + event.getPlayer().teleport(spawn); + return; + } } } @@ -405,6 +405,7 @@ public class AuthMePlayerListener implements Listener { if (player == null) return; final String name = player.getName().toLowerCase(); + boolean isAuthAvailable = data.isAuthAvailable(name); if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) { return; @@ -412,7 +413,7 @@ public class AuthMePlayerListener implements Listener { if (Settings.enablePasspartu && !Settings.countriesBlacklist.isEmpty()) { String code = plugin.getCountryCode(event.getAddress().getHostAddress()); - if (((code == null) || (Settings.countriesBlacklist.contains(code) && !API.isRegistered(name))) && !plugin.authmePermissible(player, "authme.bypassantibot")) { + if (((code == null) || (Settings.countriesBlacklist.contains(code) && !isAuthAvailable)) && !plugin.authmePermissible(player, "authme.bypassantibot")) { event.setKickMessage(m.send("country_banned")[0]); event.setResult(PlayerLoginEvent.Result.KICK_OTHER); return; @@ -420,7 +421,7 @@ public class AuthMePlayerListener implements Listener { } if (Settings.enableProtection && !Settings.countries.isEmpty()) { String code = plugin.getCountryCode(event.getAddress().getHostAddress()); - if (((code == null) || (!Settings.countries.contains(code) && !API.isRegistered(name))) && !plugin.authmePermissible(player, "authme.bypassantibot")) { + if (((code == null) || (!Settings.countries.contains(code) && !isAuthAvailable)) && !plugin.authmePermissible(player, "authme.bypassantibot")) { event.setKickMessage(m.send("country_banned")[0]); event.setResult(PlayerLoginEvent.Result.KICK_OTHER); return; @@ -441,18 +442,6 @@ public class AuthMePlayerListener implements Listener { return; } - if (data.isAuthAvailable(name) && LimboCache.getInstance().hasLimboPlayer(name)) - if (Settings.isSessionsEnabled) - if (PlayerCache.getInstance().isAuthenticated(name)) - if (!Settings.sessionExpireOnIpChange) - Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { - - @Override - public void run() { - LimboCache.getInstance().deleteLimboPlayer(name); - } - }); - // Check if forceSingleSession is set to true, so kick player that has // joined with same nick of online player if (player.isOnline() && Settings.isForceSingleSessionEnabled) { @@ -589,7 +578,7 @@ public class AuthMePlayerListener implements Listener { Player player = event.getPlayer(); String name = player.getName().toLowerCase(); - plugin.management.performQuit(player); + plugin.management.performQuit(player, false); if (data.getAuth(name) != null && !PlayerCache.getInstance().isAuthenticated(name) && Settings.enableProtection) event.setQuitMessage(null); @@ -611,7 +600,7 @@ public class AuthMePlayerListener implements Listener { return; } - plugin.management.performQuit(player); + plugin.management.performQuit(player, true); } @EventHandler(priority = EventPriority.HIGHEST) diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeServerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMeServerListener.java index 1766bbe9..f05710e7 100644 --- a/src/main/java/fr/xephi/authme/listener/AuthMeServerListener.java +++ b/src/main/java/fr/xephi/authme/listener/AuthMeServerListener.java @@ -56,20 +56,16 @@ public class AuthMeServerListener implements Listener { ConsoleLogger.info("Multiverse-Core has been disabled, unhook!"); return; } - if (pluginName.equalsIgnoreCase("Notifications")) { - plugin.notifications = null; - ConsoleLogger.info("Notifications has been disabled, unhook!"); - } if (pluginName.equalsIgnoreCase("ChestShop")) { plugin.ChestShop = 0; ConsoleLogger.info("ChestShop has been disabled, unhook!"); } if (pluginName.equalsIgnoreCase("CombatTag")) { - plugin.CombatTag = 0; + plugin.CombatTag = false; ConsoleLogger.info("CombatTag has been disabled, unhook!"); } if (pluginName.equalsIgnoreCase("Citizens")) { - plugin.CitizensVersion = 0; + plugin.isCitizensActive = false; ConsoleLogger.info("Citizens has been disabled, unhook!"); } if (pluginName.equalsIgnoreCase("Vault")) { @@ -85,8 +81,6 @@ public class AuthMeServerListener implements Listener { plugin.checkEssentials(); if (pluginName.equalsIgnoreCase("Multiverse-Core")) plugin.checkMultiverse(); - if (pluginName.equalsIgnoreCase("Notifications")) - plugin.checkNotifications(); if (pluginName.equalsIgnoreCase("ChestShop")) plugin.checkChestShop(); if (pluginName.equalsIgnoreCase("CombatTag")) diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeSpoutListener.java b/src/main/java/fr/xephi/authme/listener/AuthMeSpoutListener.java deleted file mode 100644 index 0c0ec624..00000000 --- a/src/main/java/fr/xephi/authme/listener/AuthMeSpoutListener.java +++ /dev/null @@ -1,28 +0,0 @@ -package fr.xephi.authme.listener; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.getspout.spoutapi.event.spout.SpoutCraftEnableEvent; - -import fr.xephi.authme.cache.auth.PlayerCache; -import fr.xephi.authme.datasource.DataSource; -import fr.xephi.authme.gui.screens.LoginScreen; -import fr.xephi.authme.settings.SpoutCfg; - -public class AuthMeSpoutListener implements Listener { - - private DataSource data; - - public AuthMeSpoutListener(DataSource data) { - this.data = data; - } - - @EventHandler - public void onSpoutCraftEnable(final SpoutCraftEnableEvent event) { - if (SpoutCfg.getInstance().getBoolean("LoginScreen.enabled")) { - if (data.isAuthAvailable(event.getPlayer().getName().toLowerCase()) && !PlayerCache.getInstance().isAuthenticated(event.getPlayer().getName().toLowerCase())) { - event.getPlayer().getMainScreen().attachPopupScreen(new LoginScreen(event.getPlayer())); - } - } - } -} diff --git a/src/main/java/fr/xephi/authme/plugin/manager/CitizensCommunicator.java b/src/main/java/fr/xephi/authme/plugin/manager/CitizensCommunicator.java index a1ec110b..b9331435 100644 --- a/src/main/java/fr/xephi/authme/plugin/manager/CitizensCommunicator.java +++ b/src/main/java/fr/xephi/authme/plugin/manager/CitizensCommunicator.java @@ -1,11 +1,9 @@ package fr.xephi.authme.plugin.manager; -import net.citizensnpcs.api.CitizensAPI; -import net.citizensnpcs.api.CitizensManager; - import org.bukkit.entity.Entity; import fr.xephi.authme.AuthMe; +import net.citizensnpcs.api.CitizensAPI; public class CitizensCommunicator { @@ -16,14 +14,10 @@ public class CitizensCommunicator { } public boolean isNPC(final Entity player, AuthMe instance) { + if (!this.instance.isCitizensActive) + return false; try { - if (instance.CitizensVersion == 1) { - return CitizensManager.isNPC(player); - } else if (instance.CitizensVersion == 2) { - return CitizensAPI.getNPCRegistry().isNPC(player); - } else { - return false; - } + return CitizensAPI.getNPCRegistry().isNPC(player); } catch (NoClassDefFoundError ncdfe) { return false; } catch (Exception npe) { diff --git a/src/main/java/fr/xephi/authme/plugin/manager/CombatTagComunicator.java b/src/main/java/fr/xephi/authme/plugin/manager/CombatTagComunicator.java index 314a4f19..ac80a632 100644 --- a/src/main/java/fr/xephi/authme/plugin/manager/CombatTagComunicator.java +++ b/src/main/java/fr/xephi/authme/plugin/manager/CombatTagComunicator.java @@ -1,7 +1,5 @@ package fr.xephi.authme.plugin.manager; -import net.minelink.ctplus.CombatTagPlus; - import org.bukkit.Bukkit; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -10,6 +8,9 @@ import org.bukkit.plugin.Plugin; import com.trc202.CombatTag.CombatTag; import com.trc202.CombatTagApi.CombatTagApi; +import fr.xephi.authme.AuthMe; +import net.minelink.ctplus.CombatTagPlus; + public abstract class CombatTagComunicator { public static CombatTagApi combatApi; @@ -21,6 +22,8 @@ public abstract class CombatTagComunicator { * @return true if the player is an NPC */ public static boolean isNPC(Entity player) { + if (!AuthMe.getInstance().CombatTag) + return false; try { if (Bukkit.getServer().getPluginManager().getPlugin("CombatTag") != null) { combatApi = new CombatTagApi((CombatTag) Bukkit.getServer().getPluginManager().getPlugin("CombatTag")); diff --git a/src/main/java/fr/xephi/authme/process/Management.java b/src/main/java/fr/xephi/authme/process/Management.java index ca3a7ae5..45fc97fa 100644 --- a/src/main/java/fr/xephi/authme/process/Management.java +++ b/src/main/java/fr/xephi/authme/process/Management.java @@ -16,8 +16,8 @@ import fr.xephi.authme.settings.Settings; /** * - * @authors Xephi59, Possible + * @authors Xephi59, + * Possible * */ public class Management { @@ -65,12 +65,12 @@ public class Management { }); } - public void performQuit(final Player player) { + public void performQuit(final Player player, final boolean isKick) { Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() { @Override public void run() { - new AsyncronousQuit(player, plugin, database).process(); + new AsyncronousQuit(player, plugin, database, isKick).process(); } }); diff --git a/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java b/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java index 2396704f..78fd0f8d 100644 --- a/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java +++ b/src/main/java/fr/xephi/authme/process/join/AsyncronousJoin.java @@ -1,7 +1,5 @@ package fr.xephi.authme.process.join; -import java.util.Date; - import org.bukkit.Bukkit; import org.bukkit.GameMode; import org.bukkit.Location; @@ -17,7 +15,6 @@ import fr.xephi.authme.AuthMe; import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.Utils; import fr.xephi.authme.Utils.groupType; -import fr.xephi.authme.api.API; import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.backup.DataFileCache; @@ -26,7 +23,6 @@ import fr.xephi.authme.cache.limbo.LimboCache; import fr.xephi.authme.cache.limbo.LimboPlayer; import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.events.ProtectInventoryEvent; -import fr.xephi.authme.events.SessionEvent; import fr.xephi.authme.events.SpawnTeleportEvent; import fr.xephi.authme.listener.AuthMePlayerListener; import fr.xephi.authme.plugin.manager.CombatTagComunicator; @@ -95,76 +91,6 @@ public class AsyncronousJoin { } final Location spawnLoc = plugin.getSpawnLocation(player); if (database.isAuthAvailable(name)) { - if (Settings.isSessionsEnabled) { - PlayerAuth auth = database.getAuth(name); - long timeout = Settings.getSessionTimeout * 60000; - long lastLogin = auth.getLastLogin(); - long cur = new Date().getTime(); - if ((cur - lastLogin < timeout || timeout == 0) && !auth.getIp().matches("198.168.(0|1).1")) { - if (auth.getNickname().equalsIgnoreCase(name) && auth.getIp().equals(ip)) { - if (PlayerCache.getInstance().getAuth(name) != null) { - PlayerCache.getInstance().updatePlayer(auth); - } else { - PlayerCache.getInstance().addPlayer(auth); - database.setLogged(name); - } - m.send(player, "valid_session"); - // Restore Permission Group - utils.setGroup(player, Utils.groupType.LOGGEDIN); - plugin.getServer().getPluginManager().callEvent(new SessionEvent(auth, true)); - return; - } else if (!Settings.sessionExpireOnIpChange) { - final GameMode gM = AuthMePlayerListener.gameMode.get(name); - sched.scheduleSyncDelayedTask(plugin, new Runnable() { - - @Override - public void run() { - AuthMePlayerListener.causeByAuthMe.put(name, true); - player.setGameMode(gM); - AuthMePlayerListener.causeByAuthMe.put(name, false); - player.kickPlayer(m.send("unvalid_session")[0]); - } - - }); - return; - } else if (auth.getNickname().equalsIgnoreCase(name)) { - if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) { - sched.scheduleSyncDelayedTask(plugin, new Runnable() { - - @Override - public void run() { - AuthMePlayerListener.causeByAuthMe.put(name, true); - Utils.forceGM(player); - AuthMePlayerListener.causeByAuthMe.put(name, false); - } - - }); - } - // Player change his IP between 2 relog-in - PlayerCache.getInstance().removePlayer(name); - database.setUnlogged(name); - } else { - final GameMode gM = AuthMePlayerListener.gameMode.get(name); - sched.scheduleSyncDelayedTask(plugin, new Runnable() { - - @Override - public void run() { - AuthMePlayerListener.causeByAuthMe.put(name, true); - player.setGameMode(gM); - AuthMePlayerListener.causeByAuthMe.put(name, false); - player.kickPlayer(m.send("unvalid_session")[0]); - } - - }); - return; - } - } else { - // Session is ended correctly - PlayerCache.getInstance().removePlayer(name); - database.setUnlogged(name); - } - } - // isent in session or session was ended correctly if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) { sched.scheduleSyncDelayedTask(plugin, new Runnable() { @@ -255,7 +181,7 @@ public class AsyncronousJoin { if (!Settings.noConsoleSpam) ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + " ..."); } else { - API.setPlayerInventory(player, ev.getEmptyInventory(), ev.getEmptyArmor()); + plugin.api.setPlayerInventory(player, ev.getEmptyInventory(), ev.getEmptyArmor()); } } catch (NullPointerException ex) { } @@ -302,6 +228,23 @@ public class AsyncronousJoin { } }); + if (Settings.isSessionsEnabled && database.isAuthAvailable(name) && (PlayerCache.getInstance().isAuthenticated(name) || database.isLogged(name))) { + if (plugin.sessions.containsKey(name)) + plugin.sessions.get(name).cancel(); + plugin.sessions.remove(name); + PlayerAuth auth = database.getAuth(name); + if (auth != null && auth.getIp().equals(ip)) { + m.send(player, "valid_session"); + PlayerCache.getInstance().removePlayer(name); + database.setUnlogged(name); + plugin.management.performLogin(player, "dontneed", true); + } else if (Settings.sessionExpireOnIpChange) { + PlayerCache.getInstance().removePlayer(name); + database.setUnlogged(name); + m.send(player, "invalid_session"); + } + return; + } BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, msg, msgInterval)); LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT); } diff --git a/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java b/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java index 3ffd7b76..b0d5af86 100644 --- a/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java @@ -19,7 +19,6 @@ import fr.xephi.authme.security.RandomString; import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.task.MessageTask; -import me.muizers.Notifications.Notification; public class AsyncronousLogin { @@ -147,23 +146,19 @@ public class AsyncronousLogin { } player.setNoDamageTicks(0); - m.send(player, "login"); + if (!forceLogin) + m.send(player, "login"); displayOtherAccounts(auth, player); - + if (Settings.recallEmail) { if (email == null || email.isEmpty() || email.equalsIgnoreCase("your@email.com")) m.send(player, "add_email"); } - if (!Settings.noConsoleSpam) ConsoleLogger.info(player.getName() + " logged in!"); - if (plugin.notifications != null) { - plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " logged in!")); - } - // makes player isLoggedin via API PlayerCache.getInstance().addPlayer(auth); database.setLogged(name); diff --git a/src/main/java/fr/xephi/authme/process/login/ProcessSyncronousPlayerLogin.java b/src/main/java/fr/xephi/authme/process/login/ProcessSyncronousPlayerLogin.java index 58951c5d..eaee58ee 100644 --- a/src/main/java/fr/xephi/authme/process/login/ProcessSyncronousPlayerLogin.java +++ b/src/main/java/fr/xephi/authme/process/login/ProcessSyncronousPlayerLogin.java @@ -91,7 +91,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable { RestoreInventoryEvent event = new RestoreInventoryEvent(player, limbo.getInventory(), limbo.getArmour()); Bukkit.getServer().getPluginManager().callEvent(event); if (!event.isCancelled()) { - API.setPlayerInventory(player, event.getInventory(), event.getArmor()); + plugin.api.setPlayerInventory(player, event.getInventory(), event.getArmor()); } } diff --git a/src/main/java/fr/xephi/authme/process/logout/AsyncronousLogout.java b/src/main/java/fr/xephi/authme/process/logout/AsyncronousLogout.java index c50be63d..d9931171 100644 --- a/src/main/java/fr/xephi/authme/process/logout/AsyncronousLogout.java +++ b/src/main/java/fr/xephi/authme/process/logout/AsyncronousLogout.java @@ -28,7 +28,8 @@ public class AsyncronousLogout { private Utils utils = Utils.getInstance(); private FileCache playerBackup; - public AsyncronousLogout(Player player, AuthMe plugin, DataSource database) { + public AsyncronousLogout(Player player, AuthMe plugin, + DataSource database) { this.player = player; this.plugin = plugin; this.database = database; @@ -50,8 +51,6 @@ public class AsyncronousLogout { final Player p = player; BukkitScheduler sched = p.getServer().getScheduler(); PlayerAuth auth = PlayerCache.getInstance().getAuth(name); - if (Settings.isSessionsEnabled) - auth.setLastLogin(0L); database.updateSession(auth); auth.setQuitLocX(p.getLocation().getX()); auth.setQuitLocY(p.getLocation().getY()); diff --git a/src/main/java/fr/xephi/authme/process/logout/ProcessSyncronousPlayerLogout.java b/src/main/java/fr/xephi/authme/process/logout/ProcessSyncronousPlayerLogout.java index c60fdced..1a0ddab6 100644 --- a/src/main/java/fr/xephi/authme/process/logout/ProcessSyncronousPlayerLogout.java +++ b/src/main/java/fr/xephi/authme/process/logout/ProcessSyncronousPlayerLogout.java @@ -15,7 +15,6 @@ import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.task.MessageTask; import fr.xephi.authme.task.TimeoutTask; -import me.muizers.Notifications.Notification; public class ProcessSyncronousPlayerLogout implements Runnable { @@ -32,6 +31,9 @@ public class ProcessSyncronousPlayerLogout implements Runnable { @Override public void run() { + if (plugin.sessions.containsKey(name)) + plugin.sessions.get(name).cancel(); + plugin.sessions.remove(name); int delay = Settings.getRegistrationTimeout * 20; int interval = Settings.getWarnMessageInterval; BukkitScheduler sched = player.getServer().getScheduler(); @@ -61,9 +63,6 @@ public class ProcessSyncronousPlayerLogout implements Runnable { }); m.send(player, "logout"); ConsoleLogger.info(player.getDisplayName() + " logged out"); - if (plugin.notifications != null) { - plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " logged out!")); - } } } diff --git a/src/main/java/fr/xephi/authme/process/quit/AsyncronousQuit.java b/src/main/java/fr/xephi/authme/process/quit/AsyncronousQuit.java index 05aa45c1..5e34fd00 100644 --- a/src/main/java/fr/xephi/authme/process/quit/AsyncronousQuit.java +++ b/src/main/java/fr/xephi/authme/process/quit/AsyncronousQuit.java @@ -4,6 +4,7 @@ import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.scheduler.BukkitTask; import fr.xephi.authme.AuthMe; import fr.xephi.authme.Utils; @@ -30,13 +31,16 @@ public class AsyncronousQuit { private boolean isOp = false; private boolean isFlying = false; private boolean needToChange = false; + private boolean isKick = false; - public AsyncronousQuit(Player p, AuthMe plugin, DataSource database) { + public AsyncronousQuit(Player p, AuthMe plugin, DataSource database, + boolean isKick) { this.p = p; this.plugin = plugin; this.database = database; this.name = p.getName().toLowerCase(); this.playerBackup = new FileCache(plugin); + this.isKick = isKick; } public void process() { @@ -79,9 +83,24 @@ public class AsyncronousQuit { playerBackup.removeCache(player); } } - PlayerCache.getInstance().removePlayer(name); - database.setUnlogged(name); + if (Settings.isSessionsEnabled && !isKick) { + BukkitTask task = plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() { + + @Override + public void run() { + PlayerCache.getInstance().removePlayer(name); + if (database.isLogged(name)) + database.setUnlogged(name); + plugin.sessions.remove(name); + } + + }, Settings.getSessionTimeout * 20 * 60); + plugin.sessions.put(name, task); + } else { + PlayerCache.getInstance().removePlayer(name); + database.setUnlogged(name); + } AuthMePlayerListener.gameMode.remove(name); - Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(player, inv, armor, isOp, isFlying, needToChange)); + Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerQuit(plugin, player, inv, armor, isOp, isFlying, needToChange)); } } diff --git a/src/main/java/fr/xephi/authme/process/quit/ProcessSyncronousPlayerQuit.java b/src/main/java/fr/xephi/authme/process/quit/ProcessSyncronousPlayerQuit.java index 83e088ff..b21a78bf 100644 --- a/src/main/java/fr/xephi/authme/process/quit/ProcessSyncronousPlayerQuit.java +++ b/src/main/java/fr/xephi/authme/process/quit/ProcessSyncronousPlayerQuit.java @@ -4,12 +4,13 @@ import org.bukkit.GameMode; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; -import fr.xephi.authme.api.API; +import fr.xephi.authme.AuthMe; import fr.xephi.authme.events.RestoreInventoryEvent; import fr.xephi.authme.settings.Settings; public class ProcessSyncronousPlayerQuit implements Runnable { + protected AuthMe plugin; protected Player player; protected boolean isOp; protected boolean isFlying; @@ -17,9 +18,10 @@ public class ProcessSyncronousPlayerQuit implements Runnable { protected ItemStack[] armor; protected boolean needToChange; - public ProcessSyncronousPlayerQuit(Player player, ItemStack[] inv, - ItemStack[] armor, boolean isOp, boolean isFlying, + public ProcessSyncronousPlayerQuit(AuthMe plugin, Player player, + ItemStack[] inv, ItemStack[] armor, boolean isOp, boolean isFlying, boolean needToChange) { + this.plugin = plugin; this.player = player; this.isOp = isOp; this.isFlying = isFlying; @@ -34,7 +36,7 @@ public class ProcessSyncronousPlayerQuit implements Runnable { RestoreInventoryEvent ev = new RestoreInventoryEvent(player, inv, armor); player.getServer().getPluginManager().callEvent(ev); if (!ev.isCancelled()) { - API.setPlayerInventory(player, ev.getInventory(), ev.getArmor()); + plugin.api.setPlayerInventory(player, ev.getInventory(), ev.getArmor()); } } if (needToChange) { diff --git a/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousEmailRegister.java b/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousEmailRegister.java index c1b3cd86..f90a506d 100644 --- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousEmailRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousEmailRegister.java @@ -12,7 +12,6 @@ import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.task.MessageTask; import fr.xephi.authme.task.TimeoutTask; -import me.muizers.Notifications.Notification; public class ProcessSyncronousEmailRegister implements Runnable { @@ -47,9 +46,6 @@ public class ProcessSyncronousEmailRegister implements Runnable { player.saveData(); if (!Settings.noConsoleSpam) ConsoleLogger.info(player.getName() + " registered " + plugin.getIP(player)); - if (plugin.notifications != null) { - plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " has registered by email!")); - } } } diff --git a/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java b/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java index cb3bf1ed..cf054456 100644 --- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java +++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java @@ -20,7 +20,6 @@ import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Settings; import fr.xephi.authme.task.MessageTask; import fr.xephi.authme.task.TimeoutTask; -import me.muizers.Notifications.Notification; public class ProcessSyncronousPasswordRegister implements Runnable { @@ -118,9 +117,6 @@ public class ProcessSyncronousPasswordRegister implements Runnable { if (!Settings.noConsoleSpam) ConsoleLogger.info(player.getName() + " registered " + plugin.getIP(player)); - if (plugin.notifications != null) { - plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " has registered!")); - } // Kick Player after Registration is enabled, kick the player if (Settings.forceRegKick) { diff --git a/src/main/java/fr/xephi/authme/settings/Settings.java b/src/main/java/fr/xephi/authme/settings/Settings.java index 2f6af800..0696c604 100644 --- a/src/main/java/fr/xephi/authme/settings/Settings.java +++ b/src/main/java/fr/xephi/authme/settings/Settings.java @@ -63,7 +63,7 @@ public final class Settings extends YamlConfiguration { isBackupOnStart, isBackupOnStop, enablePasspartu, isStopEnabled, reloadSupport, rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts, useCaptcha, emailRegistration, multiverse, - notifications, chestshop, bungee, banUnsafeIp, doubleEmailCheck, + chestshop, bungee, banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange, disableSocialSpy, forceOnlyAfterLogin, useEssentialsMotd, usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword, purgeLimitedCreative, purgeAntiXray, @@ -217,7 +217,6 @@ public final class Settings extends YamlConfiguration { 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) configFile.getList("settings.restrictions.ForceSpawnOnTheseWorlds", new ArrayList()); banUnsafeIp = configFile.getBoolean("settings.restrictions.banUnsafedIP", false); @@ -384,7 +383,6 @@ public final class Settings extends YamlConfiguration { 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) configFile.getList("settings.restrictions.ForceSpawnOnTheseWorlds"); banUnsafeIp = configFile.getBoolean("settings.restrictions.banUnsafedIP", false); @@ -587,6 +585,8 @@ public final class Settings extends YamlConfiguration { set("Purge.removePermissions", false); changes = true; } + if (contains("Hooks.notifications")) + set("Hooks.notifications", null); if (changes) { plugin.getLogger().warning("Merge new Config Options - I'm not an error, please don't report me"); diff --git a/src/main/java/fr/xephi/authme/settings/SpoutCfg.java b/src/main/java/fr/xephi/authme/settings/SpoutCfg.java deleted file mode 100644 index bc293303..00000000 --- a/src/main/java/fr/xephi/authme/settings/SpoutCfg.java +++ /dev/null @@ -1,41 +0,0 @@ -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() { - - { - 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" + File.separator + "AuthMe", "spout.yml")); - return instance; - } -} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index aac7285b..8b9796ce 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -68,7 +68,7 @@ settings: # 0 for unlimitted sessions, use 0 at your own risk! # consider that session will end only after timeout, and # if player's ip is changed but the timeout treshould isent - # ended, player will kick out of sever for unvalidSession! + # ended, player will kick out of sever for invalidSession! timeout: 10 # Do we need to timeout the session if the player is offline # And try to login with an another IP Address? @@ -375,8 +375,6 @@ Hooks: chestshop: true # Do we need to hook with BungeeCord for get the real Player ip ? bungeecord: false - # Do we need to hook with Notifications for Notifs sending ? - notifications: true # Do we need to disable Essentials SocialSpy on join ? disableSocialSpy: true # Do we need to force /motd Essentials command on join ? diff --git a/src/main/resources/messages_bg.yml b/src/main/resources/messages_bg.yml index 37bc0651..866931cc 100644 --- a/src/main/resources/messages_bg.yml +++ b/src/main/resources/messages_bg.yml @@ -24,7 +24,7 @@ user_unknown: '&cПотребителя не е регистриран' password_error: '&fПаролата не съвпада' password_error_nick: '&fYou can''t use your name as password' password_error_unsafe: '&fYou can''t use unsafe passwords' -unvalid_session: '&fSession Dataes doesnt corrispond Plaese wait the end of session' +invalid_session: '&fSession Dataes doesnt corrispond Plaese wait the end of session' reg_only: '&fСамо за регистрирани! Моля посети http://example.com за регистрация' logged_in: '&cВече сте влязъл!' logout: '&cУспешен изход от регистрацията!' diff --git a/src/main/resources/messages_cz.yml b/src/main/resources/messages_cz.yml index c147e290..9d1b1031 100644 --- a/src/main/resources/messages_cz.yml +++ b/src/main/resources/messages_cz.yml @@ -27,7 +27,7 @@ registered: '&cRegistrace byla uspesna!' reload: '&cZnovu nacteni nastaveni AuthMe probehlo uspesne.' timeout: '&cCas pro prihlaseni vyprsel!' unsafe_spawn: '&cTvoje pozice pri odpojeni byla nebezpecna, teleportuji na spawn!' -unvalid_session: '&cChybna data pri cteni pockejte do vyprseni.' +invalid_session: '&cChybna data pri cteni pockejte do vyprseni.' max_reg: '&cJiz jsi prekrocil(a) limit pro pocet uctu z jedne IP.' password_error: '&cHesla se neshoduji!' pass_len: '&cTvoje heslo nedosahuje minimalni delky (4).' diff --git a/src/main/resources/messages_de.yml b/src/main/resources/messages_de.yml index 144ff335..4e104df7 100644 --- a/src/main/resources/messages_de.yml +++ b/src/main/resources/messages_de.yml @@ -23,7 +23,7 @@ usage_unreg: '&cBenutze: /unregister ' pwd_changed: '&cPasswort geändert!' user_unknown: '&cBenutzername nicht registriert' password_error: '&fPasswort falsch' -unvalid_session: '&fUngültige Session. Bitte starte das Spiel neu oder warte, bis die Session abgelaufen ist' +invalid_session: '&fUngültige Session. Bitte starte das Spiel neu oder warte, bis die Session abgelaufen ist' reg_only: '&fNur registrierte Spieler! Bitte besuche http://example.com zum registrieren' logged_in: '&cBereits eingeloggt!' logout: '&cErfolgreich ausgeloggt' diff --git a/src/main/resources/messages_es.yml b/src/main/resources/messages_es.yml index aa062286..62fbc53a 100644 --- a/src/main/resources/messages_es.yml +++ b/src/main/resources/messages_es.yml @@ -24,7 +24,7 @@ usage_unreg: '&cUso: /unregister contraseña' pwd_changed: '&c¡Contraseña cambiada!' user_unknown: '&cUsuario no registrado' password_error: '&fLas contraseñas no son iguales' -unvalid_session: '&fLos datos de sesión no corresponden. Por favor espera a terminar la sesión.' +invalid_session: '&fLos datos de sesión no corresponden. Por favor espera a terminar la sesión.' reg_only: '&f¡Sólo para jugadores registrados! Por favor visita http://www.example.com/ para registrarte' logged_in: '&c¡Ya has iniciado sesión!' logout: '&cDesconectado correctamente.' diff --git a/src/main/resources/messages_fi.yml b/src/main/resources/messages_fi.yml index abb39892..211928fe 100644 --- a/src/main/resources/messages_fi.yml +++ b/src/main/resources/messages_fi.yml @@ -23,7 +23,7 @@ usage_unreg: '&cKäyttötapa: /unregister password' pwd_changed: '&cSalasana vaihdettu!!' user_unknown: '&cSalasanat eivät täsmää' password_error: '&fSalasanat ei täsmää' -unvalid_session: '&fIstunto ei täsmää! Ole hyvä ja odota istunnon loppuun' +invalid_session: '&fIstunto ei täsmää! Ole hyvä ja odota istunnon loppuun' reg_only: '&fMene sivustolle: http://example.com rekisteröityäksesi!' logged_in: '&cOlet jo kirjautunut!' logout: '&cKirjauduit ulos palvelimelta.' diff --git a/src/main/resources/messages_fr.yml b/src/main/resources/messages_fr.yml index 6af98db1..d337962a 100644 --- a/src/main/resources/messages_fr.yml +++ b/src/main/resources/messages_fr.yml @@ -24,7 +24,7 @@ usage_unreg: '&cPour supprimer ce compte, utilisez: /unregister password' pwd_changed: '&cMotdePasse changé avec succès!' user_unknown: '&c Ce compte n''est pas enregistré' password_error: '&fCe mot de passe est incorrect' -unvalid_session: '&fSession invalide, relancez le jeu ou attendez la fin de la session' +invalid_session: '&fSession invalide, relancez le jeu ou attendez la fin de la session' reg_only: '&fSeul les joueurs enregistré sont admis!' logged_in: '&cVous êtes déjà connecté!' logout: '&cVous avez été déconnecté!' diff --git a/src/main/resources/messages_gl.yml b/src/main/resources/messages_gl.yml index d72b0398..5a43e796 100644 --- a/src/main/resources/messages_gl.yml +++ b/src/main/resources/messages_gl.yml @@ -24,7 +24,7 @@ usage_unreg: '&cUso: /unregister ' pwd_changed: '&cCambiouse o contrasinal!' user_unknown: '&cEse nome de usuario non está rexistrado' password_error: '&fO contrasinal non coincide' -unvalid_session: '&fOs datos de sesión non corresponden, por favor, espere a que remate a sesión' +invalid_session: '&fOs datos de sesión non corresponden, por favor, espere a que remate a sesión' reg_only: '&fSó xogadores rexistrados! Por favor, visita http://example.com para rexistrarte' logged_in: '&cXa estás identificado!' logout: '&cSesión pechada con éxito' diff --git a/src/main/resources/messages_hu.yml b/src/main/resources/messages_hu.yml index fb8ac952..e71dae62 100644 --- a/src/main/resources/messages_hu.yml +++ b/src/main/resources/messages_hu.yml @@ -29,7 +29,7 @@ reg_email_msg: '&cPlease register with "/register "' unsafe_spawn: A kilépési helyzeted nem biztonságos, teleportálás a kezdö Spawnra. max_reg: Csak egy karakterrel Registrálhatsz!!! password_error: A jelszó nem illik össze -unvalid_session: Session Dataes doesnt corrispond Plaese wait the end of session +invalid_session: Session Dataes doesnt corrispond Plaese wait the end of session pass_len: A jelszavad nem éri el a minimális hosszat vb_nonActiv: Your Account isent Activated yet check your Emails! usage_changepassword: 'használat: /changepassword régiJelszó újJelszó' diff --git a/src/main/resources/messages_lt.yml b/src/main/resources/messages_lt.yml index 508a74c1..c270da9f 100644 --- a/src/main/resources/messages_lt.yml +++ b/src/main/resources/messages_lt.yml @@ -23,7 +23,7 @@ usage_unreg: '&ePanaikinti registracija: "/unregister slaptazodis"' pwd_changed: '&aSlaptazodis pakeistas' user_unknown: '&cVartotojas neprisiregistraves' password_error: '&cSlaptazodziai nesutampa' -unvalid_session: '&cSesijos laikai nesutampa, prasome palaukti kol secija baigsis.' +invalid_session: '&cSesijos laikai nesutampa, prasome palaukti kol secija baigsis.' reg_only: '&cTik prisiregistravusiem zaidejams: apsilankykite: http://example.com tam kad uzsiregistruoti.' logged_in: '&cTu aju prisijunges!' logout: '&aSekmingai atsijungete' diff --git a/src/main/resources/messages_nl.yml b/src/main/resources/messages_nl.yml index 5fb90d76..65c8a0fc 100644 --- a/src/main/resources/messages_nl.yml +++ b/src/main/resources/messages_nl.yml @@ -22,7 +22,7 @@ usage_unreg: '&cGebruik: /unregister password' pwd_changed: '&cWachtwoord aangepast!' user_unknown: '&cGebruikersnaam niet geregistreerd' password_error: Wachtwoord incorrect! -unvalid_session: Sessie beschadigt, wacht tot de sessie is verlopen en join opnieuw. +invalid_session: Sessie beschadigt, wacht tot de sessie is verlopen en join opnieuw. reg_only: Alleen voor geregistreerde spelers! Bezoek http://example.com om te registreren logged_in: '&cJe bent al ingelogt!' logout: '&cJe bent succesvol uitgelogt' diff --git a/src/main/resources/messages_pl.yml b/src/main/resources/messages_pl.yml index dbe5a6c5..e9df2139 100644 --- a/src/main/resources/messages_pl.yml +++ b/src/main/resources/messages_pl.yml @@ -27,7 +27,7 @@ reload: '&fKonfiguracja bazy danych zostala przeladowana' error: '&fBlad prosimy napisac do aministracji' unknown_user: '&fUzytkownika nie ma w bazie danych' unsafe_spawn: '&fTwoje pozycja jest niebezpieczna. Zostaniesz przeniesiony na bezpieczny spawn.' -unvalid_session: '&fSesja zakonczona!' +invalid_session: '&fSesja zakonczona!' max_reg: '&fPrzekroczyles limit zarejestrowanych kont na serwerze.' password_error: '&fHaslo niepoprawne!' pass_len: '&fTwoje haslo jest za krotkie lub za dlugie! Sprobuj ponownie...' diff --git a/src/main/resources/messages_pt.yml b/src/main/resources/messages_pt.yml index c2b65a3f..680f7c1b 100644 --- a/src/main/resources/messages_pt.yml +++ b/src/main/resources/messages_pt.yml @@ -23,7 +23,7 @@ password_error_nick: '&fYou can''t use your name as password' password_error_unsafe: '&fYou can''t use unsafe passwords' user_unknown: '&cUsername não registado' password_error: '&fAs passwords não coincidem' -unvalid_session: '&fDados de sessão não correspondem. Por favor aguarde o fim da sessão' +invalid_session: '&fDados de sessão não correspondem. Por favor aguarde o fim da sessão' reg_only: '&fApenas jogadores registados! Visite http://example.com para se registar' logged_in: '&cJá se encontra autenticado!' logout: '&cSaida com sucesso' diff --git a/src/main/resources/messages_ru.yml b/src/main/resources/messages_ru.yml index 3bae790d..ccddc163 100644 --- a/src/main/resources/messages_ru.yml +++ b/src/main/resources/messages_ru.yml @@ -24,7 +24,7 @@ usage_unreg: '&4Использование: &5/unregister ПАРОЛЬ' pwd_changed: '&2Пароль изменен!' user_unknown: '&4Такой игрок не зарегистрирован' password_error: '&4Пароль не совпадает' -unvalid_session: '&4Сессия некорректна. Дождитесь, пока она закончится' +invalid_session: '&4Сессия некорректна. Дождитесь, пока она закончится' reg_only: '&4Только для зарегистрированных! Посетите http://project.ru/register/ для регистрации' logged_in: '&4Вы уже авторизированы!' logout: '&2Вы успешно вышли' diff --git a/src/main/resources/messages_sk.yml b/src/main/resources/messages_sk.yml index f06948f9..95d293c3 100644 --- a/src/main/resources/messages_sk.yml +++ b/src/main/resources/messages_sk.yml @@ -31,7 +31,7 @@ reload: '&fKonfigurácia a databáza bola obnovená' error: '&fNastala chyba; Kontaktujte administrátora' unknown_user: '&fHrac nie je v databázi' unsafe_spawn: '&fTvoj pozícia bol nebezpecná, teleportujem hraca na spawn' -unvalid_session: '&fZapamätane casove data nie su doveryhodne. Cakaj na ukoncenie spojenia' +invalid_session: '&fZapamätane casove data nie su doveryhodne. Cakaj na ukoncenie spojenia' max_reg: '&fDosiahol si maximum registrovanych uctov.' password_error: '&fHeslá sa nezhodujú' pass_len: '&fHeslo je velmi kratke alebo dlhe' diff --git a/src/main/resources/messages_uk.yml b/src/main/resources/messages_uk.yml index 95081620..30e440b6 100644 --- a/src/main/resources/messages_uk.yml +++ b/src/main/resources/messages_uk.yml @@ -23,7 +23,7 @@ usage_unreg: '&cВикористовуйте: /unregister Пароль' pwd_changed: '&cПароль змінено!' user_unknown: '&cТакий користувач не зарєєстрований' password_error: '&fПаролі не співпадають' -unvalid_session: '&fСесія некоректна. Будь ласка зачекайте коли вона закінчиться' +invalid_session: '&fСесія некоректна. Будь ласка зачекайте коли вона закінчиться' reg_only: '&Вхід доступний лише зареєстрованим користувачам. Зареєструватися можна за адресою &9&nhttp://example.com&r' logged_in: '&2Ви уже ввійшли!' logout: '&cВи успішно вийшли' diff --git a/src/main/resources/messages_zhcn.yml b/src/main/resources/messages_zhcn.yml index 91e74a54..85a81802 100644 --- a/src/main/resources/messages_zhcn.yml +++ b/src/main/resources/messages_zhcn.yml @@ -23,7 +23,7 @@ usage_unreg: '&c正确用法:“/unregister <密码>”' pwd_changed: '&c密码已成功修改!' user_unknown: '&c此用户名还未注册过' password_error: '&f密码不相同' -unvalid_session: '&f登陆数据异常,请等待登陆结束' +invalid_session: '&f登陆数据异常,请等待登陆结束' reg_only: '&f只允许注册过的玩家进服!请到http://example.com以注册' logged_in: '&c你已经登陆过了!' logout: '&c已成功登出!' diff --git a/src/main/resources/messages_zhhk.yml b/src/main/resources/messages_zhhk.yml index 6ea573ae..f92cc426 100644 --- a/src/main/resources/messages_zhhk.yml +++ b/src/main/resources/messages_zhhk.yml @@ -25,7 +25,7 @@ usage_unreg: '&8[&6用戶系統&8] &c用法: 《 /unregister <密碼> 》' pwd_changed: '&8[&6用戶系統&8] &c你成功的更換了你的密碼 !' user_unknown: '&8[&6用戶系統&8] &c此用戶名沒有已登記資料。' password_error: '&8[&6用戶系統&8] &f密碼不符合。' -unvalid_session: '&8[&6用戶系統&8] &f登入階段資料已損壞,請等待登入階段結束。' +invalid_session: '&8[&6用戶系統&8] &f登入階段資料已損壞,請等待登入階段結束。' reg_only: '&8[&6用戶系統&8] &f限已註冊會員,請先到 https://www.example.com/ 註冊。' logged_in: '&8[&6用戶系統&8] &c你已經登入過了。' logout: '&8[&6用戶系統&8] &b你成功的登出了。' diff --git a/src/main/resources/messages_zhtw.yml b/src/main/resources/messages_zhtw.yml index a9c36432..c011b020 100644 --- a/src/main/resources/messages_zhtw.yml +++ b/src/main/resources/messages_zhtw.yml @@ -22,7 +22,7 @@ usage_unreg: '&c正確用法為:使用"/unregister <密碼>"來取消現有密 pwd_changed: '&c密碼變更成功!' user_unknown: '&c此用戶名並未被註冊!' password_error: <密碼>與<錯認密碼>不相同! -unvalid_session: 'Session Dataes doesnt corrispond Plaese wait the end of session' +invalid_session: 'Session Dataes doesnt corrispond Plaese wait the end of session' reg_only: 'Registered players only! Please visit http://example.com to register' logged_in: '&c您已經登入了!' logout: '&a登出成功!' diff --git a/src/main/resources/spout.yml b/src/main/resources/spout.yml deleted file mode 100644 index b8685153..00000000 --- a/src/main/resources/spout.yml +++ /dev/null @@ -1,12 +0,0 @@ -Spout GUI enabled: true -LoginScreen: - enabled: true - exit button: Quit - exit message: Good Bye - login button: Login - title: LOGIN - text: - - Sample text - - Change this at spout.yml - - '--- AuthMe Reloaded by ---' - - Xephi59 \ No newline at end of file