diff --git a/pom.xml b/pom.xml
index 6f5f9152..765c581b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -24,7 +24,7 @@
- 3.3.3
+ 3.3.4
org.bukkit
diff --git a/src/main/java/fr/xephi/authme/AuthMe.java b/src/main/java/fr/xephi/authme/AuthMe.java
index 03a96696..030eeb7e 100644
--- a/src/main/java/fr/xephi/authme/AuthMe.java
+++ b/src/main/java/fr/xephi/authme/AuthMe.java
@@ -55,7 +55,6 @@ import fr.xephi.authme.datasource.FileDataSource;
import fr.xephi.authme.datasource.MySQLDataSource;
import fr.xephi.authme.datasource.SqliteDataSource;
import fr.xephi.authme.listener.AuthMeBlockListener;
-import fr.xephi.authme.listener.AuthMeBungeeCordListener;
import fr.xephi.authme.listener.AuthMeChestShopListener;
import fr.xephi.authme.listener.AuthMeEntityListener;
import fr.xephi.authme.listener.AuthMePlayerListener;
@@ -74,7 +73,6 @@ import fr.xephi.authme.threads.FlatFileThread;
import fr.xephi.authme.threads.MySQLThread;
import fr.xephi.authme.threads.SQLiteThread;
-
public class AuthMe extends JavaPlugin {
public DataSource database = null;
@@ -85,7 +83,6 @@ public class AuthMe extends JavaPlugin {
public static Logger authmeLogger = Logger.getLogger("AuthMe");
public static AuthMe authme;
public Permission permission;
- private static AuthMe instance;
private Utils utils = Utils.getInstance();
private JavaPlugin plugin;
private FileCache playerBackup = new FileCache();
@@ -115,16 +112,15 @@ public class AuthMe extends JavaPlugin {
@Override
public void onEnable() {
- instance = this;
- authme = instance;
+ authme = this;
authmeLogger.setParent(this.getLogger());
- citizens = new CitizensCommunicator(this);
-
settings = new Settings(this);
settings.loadConfigOptions();
+ citizens = new CitizensCommunicator(this);
+
if (Settings.enableAntiBot) {
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
@Override
@@ -275,13 +271,6 @@ public class AuthMe extends JavaPlugin {
if (Settings.bungee) {
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeCordMessage(this));
- try {
- if (Class.forName("net.md_5.bungee.api.event.ChatEvent") != null) {
- pm.registerEvents(new AuthMeBungeeCordListener(database, this), this);
- ConsoleLogger.info("Successfully hook with BungeeCord!");
- }
- } catch (ClassNotFoundException e) {
- }
}
if (pm.isPluginEnabled("Spout")) {
pm.registerEvents(new AuthMeSpoutListener(database), this);
@@ -312,14 +301,10 @@ public class AuthMe extends JavaPlugin {
if (Settings.reloadSupport)
try {
- if (!new File(getDataFolder() + File.separator + "players.yml").exists()) {
- pllog = new PlayersLogs();
- }
onReload();
if (server.getOnlinePlayers().length < 1) {
try {
- PlayersLogs.players.clear();
- pllog.save();
+ database.purgeLogged();
} catch (NullPointerException npe) {
}
}
@@ -483,10 +468,9 @@ public class AuthMe extends JavaPlugin {
@Override
public void onDisable() {
if (Bukkit.getOnlinePlayers().length != 0)
- for(Player player : Bukkit.getOnlinePlayers()) {
+ for(Player player : Bukkit.getOnlinePlayers()) {
this.savePlayer(player);
- }
- pllog.save();
+ }
if (database != null) {
database.close();
@@ -497,25 +481,25 @@ public class AuthMe extends JavaPlugin {
}
if(Settings.isBackupActivated && Settings.isBackupOnStop) {
- Boolean Backup = new PerformBackup(this).DoBackup();
- if(Backup) ConsoleLogger.info("Backup Complete");
- else ConsoleLogger.showError("Error while making Backup");
+ Boolean Backup = new PerformBackup(this).DoBackup();
+ if(Backup) ConsoleLogger.info("Backup Complete");
+ else ConsoleLogger.showError("Error while making Backup");
}
ConsoleLogger.info("Authme " + this.getDescription().getVersion() + " disabled");
}
private void onReload() {
try {
- if (Bukkit.getServer().getOnlinePlayers() != null && !PlayersLogs.players.isEmpty()) {
+ if (Bukkit.getServer().getOnlinePlayers() != null) {
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
- if (PlayersLogs.players.contains(player.getName())) {
+ if (database.isLogged(player.getName().toLowerCase())) {
String name = player.getName().toLowerCase();
PlayerAuth pAuth = database.getAuth(name);
if(pAuth == null)
break;
PlayerAuth auth = new PlayerAuth(name, pAuth.getHash(), pAuth.getIp(), new Date().getTime(), pAuth.getEmail(), player.getName());
database.updateSession(auth);
- PlayerCache.getInstance().addPlayer(auth);
+ PlayerCache.getInstance().addPlayer(auth);
}
}
}
@@ -526,7 +510,7 @@ public class AuthMe extends JavaPlugin {
}
public static AuthMe getInstance() {
- return instance;
+ return authme;
}
public void savePlayer(Player player) throws IllegalStateException, NullPointerException {
@@ -561,6 +545,7 @@ public class AuthMe extends JavaPlugin {
}
}
PlayerCache.getInstance().removePlayer(name);
+ database.setUnlogged(name);
player.saveData();
} catch (Exception ex) {
}
@@ -636,23 +621,8 @@ public class AuthMe extends JavaPlugin {
purgeLimitedCreative(cleared);
if (Settings.purgeAntiXray)
purgeAntiXray(cleared);
- //if (Settings.purgePermissions && permission != null)
- //purgePerms(cleared);
}
-/* private void purgePerms(List cleared) {
- int i = 0;
- for (String name : cleared) {
- org.bukkit.OfflinePlayer player = Bukkit.getOfflinePlayer(name);
- if (player == null) continue;
- String playerName = player.getName();
- for (String group : permission.getPlayerGroups((String) null, playerName)) {
- permission.playerRemoveGroup((String) null, playerName, group);
- }
- }
- ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " players permissions");
- } */
-
public void purgeAntiXray(List cleared) {
int i = 0;
for (String name : cleared) {
@@ -720,28 +690,59 @@ public class AuthMe extends JavaPlugin {
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
}
- public Location getSpawnLocation(String name, World world) {
+ public Location getSpawnLocation(Player player, World world) {
+ String[] spawnPriority = Settings.spawnPriority.split(",");
Location spawnLoc = world.getSpawnLocation();
+ int i = 3;
+ for (i = 3 ; i >= 0 ; i--) {
+ String s = spawnPriority[i];
+ if (s.equalsIgnoreCase("default") && getDefaultSpawn(world) != null)
+ spawnLoc = getDefaultSpawn(world);
+ if (s.equalsIgnoreCase("multiverse") && getMultiverseSpawn(world) != null)
+ spawnLoc = getMultiverseSpawn(world);
+ if (s.equalsIgnoreCase("essentials") && getEssentialsSpawn() != null)
+ spawnLoc = getEssentialsSpawn();
+ if (s.equalsIgnoreCase("authme") && getAuthMeSpawn(player) != null)
+ spawnLoc = getAuthMeSpawn(player);
+ }
+ if (spawnLoc == null)
+ spawnLoc = world.getSpawnLocation();
+ return spawnLoc;
+ }
+
+ private Location getDefaultSpawn(World world) {
+ return world.getSpawnLocation();
+ }
+
+ private Location getMultiverseSpawn(World world) {
if (multiverse != null && Settings.multiverse) {
try {
- spawnLoc = multiverse.getMVWorldManager().getMVWorld(world).getSpawnLocation();
+ return multiverse.getMVWorldManager().getMVWorld(world).getSpawnLocation();
} catch (NullPointerException npe) {
} catch (ClassCastException cce) {
} catch (NoClassDefFoundError ncdfe) {
}
}
+ return null;
+ }
+
+ private Location getEssentialsSpawn() {
if (essentialsSpawn != null) {
- spawnLoc = essentialsSpawn;
+ return essentialsSpawn;
}
+ return null;
+ }
+
+ private Location getAuthMeSpawn(Player player) {
+ if ((!database.isAuthAvailable(player.getName().toLowerCase()) || !player.hasPlayedBefore()) && Spawn.getInstance().getFirstSpawn() != null)
+ return Spawn.getInstance().getFirstSpawn();
if (Spawn.getInstance().getSpawn() != null)
- spawnLoc = Spawn.getInstance().getSpawn();
- if (!database.isAuthAvailable(name) && Spawn.getInstance().getFirstSpawn() != null)
- spawnLoc = Spawn.getInstance().getFirstSpawn();
- return spawnLoc;
+ return Spawn.getInstance().getSpawn();
+ return null;
}
public void downloadGeoIp() {
- ConsoleLogger.info(" This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com");
+ ConsoleLogger.info("LICENSE : This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com");
File file = new File(getDataFolder(), "GeoIP.dat");
if (!file.exists()) {
try {
@@ -829,4 +830,29 @@ public class AuthMe extends JavaPlugin {
} catch (Exception e) {}
return message;
}
+
+ public String getIP(Player player, String name) {
+ String ip = player.getAddress().getAddress().getHostAddress();
+ if (Settings.bungee) {
+ if (realIp.containsKey(name))
+ ip = realIp.get(name);
+ }
+ return ip;
+ }
+
+ public boolean isLoggedIp(String ip) {
+ for (Player player : this.getServer().getOnlinePlayers()) {
+ if(ip.equalsIgnoreCase(getIP(player, player.getName())) && database.isLogged(player.getName().toLowerCase()))
+ return true;
+ }
+ return false;
+ }
+
+ public boolean hasJoinedIp(String ip) {
+ for (Player player : this.getServer().getOnlinePlayers()) {
+ if(ip.equalsIgnoreCase(getIP(player, player.getName())))
+ return true;
+ }
+ return false;
+ }
}
diff --git a/src/main/java/fr/xephi/authme/SendMailSSL.java b/src/main/java/fr/xephi/authme/SendMailSSL.java
index c2672b4c..20dfd8e8 100644
--- a/src/main/java/fr/xephi/authme/SendMailSSL.java
+++ b/src/main/java/fr/xephi/authme/SendMailSSL.java
@@ -22,68 +22,68 @@ import fr.xephi.authme.settings.Settings;
*/
public class SendMailSSL {
- public AuthMe instance;
+ public AuthMe plugin;
- public SendMailSSL(AuthMe instance) {
- this.instance = instance;
+ public SendMailSSL(AuthMe plugin) {
+ this.plugin = plugin;
}
+
public void main(final PlayerAuth auth, final String newPass) {
+ String sendername;
- String sendername;
+ if (Settings.getmailSenderName.isEmpty() || Settings.getmailSenderName == null) {
+ sendername = Settings.getmailAccount;
+ } else {
+ sendername = Settings.getmailSenderName;
+ }
- if (Settings.getmailSenderName.isEmpty() || Settings.getmailSenderName == null) {
- sendername = Settings.getmailAccount;
- } else {
- sendername = Settings.getmailSenderName;
+ Properties props = new Properties();
+ props.put("mail.smtp.host", Settings.getmailSMTP);
+ props.put("mail.smtp.socketFactory.port", String.valueOf(Settings.getMailPort));
+ props.put("mail.smtp.socketFactory.class",
+ "javax.net.ssl.SSLSocketFactory");
+ props.put("mail.smtp.auth", "true");
+ props.put("mail.smtp.port", String.valueOf(Settings.getMailPort));
+
+ Session session = Session.getInstance(props,
+ new javax.mail.Authenticator() {
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication(Settings.getmailAccount,Settings.getmailPassword);
}
+ });
- Properties props = new Properties();
- props.put("mail.smtp.host", Settings.getmailSMTP);
- props.put("mail.smtp.socketFactory.port", String.valueOf(Settings.getMailPort));
- props.put("mail.smtp.socketFactory.class",
- "javax.net.ssl.SSLSocketFactory");
- props.put("mail.smtp.auth", "true");
- props.put("mail.smtp.port", String.valueOf(Settings.getMailPort));
+ try {
- Session session = Session.getInstance(props,
- new javax.mail.Authenticator() {
- protected PasswordAuthentication getPasswordAuthentication() {
- return new PasswordAuthentication(Settings.getmailAccount,Settings.getmailPassword);
- }
- });
-
- try {
-
- final Message message = new MimeMessage(session);
- try {
- message.setFrom(new InternetAddress(Settings.getmailAccount, sendername));
- } catch (UnsupportedEncodingException uee) {
- message.setFrom(new InternetAddress(Settings.getmailAccount));
- }
- message.setRecipients(Message.RecipientType.TO,
- InternetAddress.parse(auth.getEmail()));
- message.setSubject(Settings.getMailSubject);
- message.setSentDate(new Date());
- String text = Settings.getMailText;
- text = text.replaceAll("", auth.getNickname());
- text = text.replaceAll("", instance.getServer().getServerName());
- text = text.replaceAll("", newPass);
- message.setContent(text, "text/html");
- Bukkit.getScheduler().runTaskAsynchronously(instance, new Runnable() {
- @Override
- public void run() {
- try {
- Transport.send(message);
- } catch (MessagingException e) {
- e.printStackTrace();
- }
- }
- });
- if(!Settings.noConsoleSpam)
- ConsoleLogger.info("Email sent to : " + auth.getNickname());
- } catch (MessagingException e) {
- throw new RuntimeException(e);
- }
+ final Message message = new MimeMessage(session);
+ try {
+ message.setFrom(new InternetAddress(Settings.getmailAccount, sendername));
+ } catch (UnsupportedEncodingException uee) {
+ message.setFrom(new InternetAddress(Settings.getmailAccount));
}
+ message.setRecipients(Message.RecipientType.TO,
+ InternetAddress.parse(auth.getEmail()));
+ message.setSubject(Settings.getMailSubject);
+ message.setSentDate(new Date());
+ String text = Settings.getMailText;
+ text = text.replace("", auth.getNickname());
+ text = text.replace("", plugin.getServer().getServerName());
+ text = text.replace("", newPass);
+ message.setContent(text, "text/html");
+ Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Transport.send(message);
+ } catch (MessagingException e) {
+ e.printStackTrace();
+ }
+ }
+ });
+ if(!Settings.noConsoleSpam)
+ ConsoleLogger.info("Email sent to : " + auth.getNickname());
+ } catch (MessagingException e) {
+ throw new RuntimeException(e);
+ }
+ }
}
diff --git a/src/main/java/fr/xephi/authme/Utils.java b/src/main/java/fr/xephi/authme/Utils.java
index 8f9eb309..10fb612e 100644
--- a/src/main/java/fr/xephi/authme/Utils.java
+++ b/src/main/java/fr/xephi/authme/Utils.java
@@ -49,29 +49,29 @@ public class Utils {
String name = player;
switch(group) {
case UNREGISTERED: {
- plugin.permission.playerRemoveGroup(world, name, currentGroup);
- plugin.permission.playerAddGroup(world, name, Settings.unRegisteredGroup);
- break;
+ plugin.permission.playerRemoveGroup(world, name, currentGroup);
+ plugin.permission.playerAddGroup(world, name, Settings.unRegisteredGroup);
+ break;
}
case REGISTERED: {
- plugin.permission.playerRemoveGroup(world, name, currentGroup);
- plugin.permission.playerAddGroup(world, name, Settings.getRegisteredGroup);
- break;
+ plugin.permission.playerRemoveGroup(world, name, currentGroup);
+ plugin.permission.playerAddGroup(world, name, Settings.getRegisteredGroup);
+ break;
}
case NOTLOGGEDIN: {
- if(!useGroupSystem()) break;
- plugin.permission.playerRemoveGroup(world, name, currentGroup);
- plugin.permission.playerAddGroup(world, name, Settings.getUnloggedinGroup);
- break;
+ if(!useGroupSystem()) break;
+ plugin.permission.playerRemoveGroup(world, name, currentGroup);
+ plugin.permission.playerAddGroup(world, name, Settings.getUnloggedinGroup);
+ break;
}
case LOGGEDIN: {
- if(!useGroupSystem()) break;
- LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name.toLowerCase());
- if (limbo == null) break;
- String realGroup = limbo.getGroup();
- plugin.permission.playerRemoveGroup(world, name, currentGroup);
- plugin.permission.playerAddGroup(world, name, realGroup);
- break;
+ if(!useGroupSystem()) break;
+ LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name.toLowerCase());
+ if (limbo == null) break;
+ String realGroup = limbo.getGroup();
+ plugin.permission.playerRemoveGroup(world, name, currentGroup);
+ plugin.permission.playerAddGroup(world, name, realGroup);
+ break;
}
}
return;
diff --git a/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java b/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java
index 2f815636..4f7cb6d8 100644
--- a/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java
+++ b/src/main/java/fr/xephi/authme/cache/auth/PlayerAuth.java
@@ -97,6 +97,12 @@ public class PlayerAuth {
this.realName = realName;
}
+ public PlayerAuth(String nickname, String ip, long lastLogin) {
+ this.nickname = nickname;
+ this.ip = ip;
+ this.lastLogin = lastLogin;
+ }
+
public String getIp() {
if (ip == null || ip.isEmpty())
ip = "127.0.0.1";
diff --git a/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java b/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java
index 698560be..265cc974 100644
--- a/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java
+++ b/src/main/java/fr/xephi/authme/cache/limbo/LimboCache.java
@@ -89,7 +89,7 @@ public class LimboCache {
gameMode = GameMode.SURVIVAL;
}
if(player.isDead()) {
- loc = plugin.getSpawnLocation(player.getName().toLowerCase(), player.getWorld());
+ loc = plugin.getSpawnLocation(player, player.getWorld());
}
cache.put(player.getName().toLowerCase(), new LimboPlayer(name, loc, inv, arm, gameMode, operator, playerGroup, flying));
}
diff --git a/src/main/java/fr/xephi/authme/commands/AdminCommand.java b/src/main/java/fr/xephi/authme/commands/AdminCommand.java
index 8cf10313..057841db 100644
--- a/src/main/java/fr/xephi/authme/commands/AdminCommand.java
+++ b/src/main/java/fr/xephi/authme/commands/AdminCommand.java
@@ -179,11 +179,11 @@ public class AdminCommand implements CommandExecutor {
sender.sendMessage("[AuthMe] The player : " + player.getNickname() + " is unlogged since " + msg);
sender.sendMessage("[AuthMe] LastPlayer IP : " + lastIP);
} else {
- sender.sendMessage("This player does not exist");
+ m._(sender, "unknown_user");
return true;
}
} catch (NullPointerException e) {
- sender.sendMessage("This player does not exist");
+ m._(sender, "unknown_user");
return true;
}
} else if (args[0].equalsIgnoreCase("accounts")) {
@@ -344,7 +344,7 @@ public class AdminCommand implements CommandExecutor {
String playername = args[1].toLowerCase();
PlayerAuth getAuth = database.getAuth(playername);
if (getAuth == null) {
- sender.sendMessage("This player does not exist");
+ m._(sender, "unknown_user");
return true;
}
sender.sendMessage("[AuthMe] " + args[1] + " email : " + getAuth.getEmail());
@@ -357,7 +357,7 @@ public class AdminCommand implements CommandExecutor {
String playername = args[1].toLowerCase();
PlayerAuth getAuth = database.getAuth(playername);
if (getAuth == null) {
- sender.sendMessage("This player does not exist");
+ m._(sender, "unknown_user");
return true;
}
getAuth.setEmail(args[2]);
@@ -506,7 +506,7 @@ public class AdminCommand implements CommandExecutor {
if (target != null) {
if (target.isOnline()) {
if (Settings.isTeleportToSpawnEnabled) {
- Location spawn = plugin.getSpawnLocation(name, target.getWorld());
+ Location spawn = plugin.getSpawnLocation(target, target.getWorld());
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(target, target.getLocation(), spawn, false);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {
diff --git a/src/main/java/fr/xephi/authme/commands/EmailCommand.java b/src/main/java/fr/xephi/authme/commands/EmailCommand.java
index 08eb638a..7c14ff46 100644
--- a/src/main/java/fr/xephi/authme/commands/EmailCommand.java
+++ b/src/main/java/fr/xephi/authme/commands/EmailCommand.java
@@ -92,9 +92,13 @@ public class EmailCommand implements CommandExecutor {
m._(player, "reg_email_msg");
}
}
- } else if(args[0].equalsIgnoreCase("change") && args.length == 3 ) {
+ } else if(args[0].equalsIgnoreCase("change")) {
+ if (args.length != 3) {
+ m._(player, "usage_email_change");
+ return true;
+ }
if(Settings.getmaxRegPerEmail > 0) {
- if (!plugin.authmePermissible(sender, "authme.allow2accounts") && data.getAllAuthsByEmail(args[1]).size() >= Settings.getmaxRegPerEmail) {
+ if (!plugin.authmePermissible(sender, "authme.allow2accounts") && data.getAllAuthsByEmail(args[2]).size() >= Settings.getmaxRegPerEmail) {
m._(player, "max_reg");
return true;
}
diff --git a/src/main/java/fr/xephi/authme/commands/LogoutCommand.java b/src/main/java/fr/xephi/authme/commands/LogoutCommand.java
index b3763856..1a218d69 100644
--- a/src/main/java/fr/xephi/authme/commands/LogoutCommand.java
+++ b/src/main/java/fr/xephi/authme/commands/LogoutCommand.java
@@ -21,7 +21,6 @@ import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.AuthMeTeleportEvent;
import fr.xephi.authme.settings.Messages;
-import fr.xephi.authme.settings.PlayersLogs;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.task.MessageTask;
import fr.xephi.authme.task.TimeoutTask;
@@ -30,7 +29,6 @@ import fr.xephi.authme.task.TimeoutTask;
public class LogoutCommand implements CommandExecutor {
private Messages m = Messages.getInstance();
- private PlayersLogs pllog = PlayersLogs.getInstance();
private AuthMe plugin;
private DataSource database;
private Utils utils = Utils.getInstance();
@@ -61,7 +59,6 @@ public class LogoutCommand implements CommandExecutor {
}
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
- auth.setIp("198.18.0.1");
database.updateSession(auth);
auth.setQuitLocX(player.getLocation().getX());
auth.setQuitLocY(player.getLocation().getY());
@@ -70,9 +67,10 @@ public class LogoutCommand implements CommandExecutor {
database.updateQuitLoc(auth);
PlayerCache.getInstance().removePlayer(name);
+ database.setUnlogged(name);
if (Settings.isTeleportToSpawnEnabled) {
- Location spawnLoc = plugin.getSpawnLocation(name, player.getWorld());
+ Location spawnLoc = plugin.getSpawnLocation(player, player.getWorld());
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {
@@ -104,10 +102,6 @@ public class LogoutCommand implements CommandExecutor {
int msgT = sched.scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, m._("login_msg"), interval));
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
try {
- if (PlayersLogs.players.contains(player.getName())) {
- PlayersLogs.players.remove(player.getName());
- pllog.save();
- }
if (player.isInsideVehicle())
player.getVehicle().eject();
} catch (NullPointerException npe) {
diff --git a/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java b/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java
index a14d3e05..4e2c6328 100644
--- a/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java
+++ b/src/main/java/fr/xephi/authme/commands/UnregisterCommand.java
@@ -23,7 +23,6 @@ import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.SpawnTeleportEvent;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Messages;
-import fr.xephi.authme.settings.PlayersLogs;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.task.MessageTask;
import fr.xephi.authme.task.TimeoutTask;
@@ -32,7 +31,6 @@ import fr.xephi.authme.task.TimeoutTask;
public class UnregisterCommand implements CommandExecutor {
private Messages m = Messages.getInstance();
- private PlayersLogs pllog = PlayersLogs.getInstance();
public AuthMe plugin;
private DataSource database;
private FileCache playerCache = new FileCache();
@@ -73,7 +71,7 @@ public class UnregisterCommand implements CommandExecutor {
}
if(Settings.isForcedRegistrationEnabled) {
if (Settings.isTeleportToSpawnEnabled) {
- Location spawn = plugin.getSpawnLocation(name, player.getWorld());
+ Location spawn = plugin.getSpawnLocation(player, player.getWorld());
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {
@@ -110,17 +108,13 @@ public class UnregisterCommand implements CommandExecutor {
if(playerCache.doesCacheExist(name)) {
playerCache.removeCache(name);
}
- if (PlayersLogs.players.contains(player.getName())) {
- PlayersLogs.players.remove(player.getName());
- pllog.save();
- }
m._(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) {
- Location spawn = plugin.getSpawnLocation(name, player.getWorld());
+ Location spawn = plugin.getSpawnLocation(player, player.getWorld());
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {
diff --git a/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java b/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java
index c3d4fbe5..5483a712 100644
--- a/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java
+++ b/src/main/java/fr/xephi/authme/datasource/CacheDataSource.java
@@ -191,4 +191,28 @@ public class CacheDataSource implements DataSource {
}
}
+ @Override
+ public DataSourceType getType() {
+ return source.getType();
+ }
+
+ @Override
+ public boolean isLogged(String user) {
+ return source.isLogged(user);
+ }
+
+ @Override
+ public void setLogged(String user) {
+ source.setLogged(user);
+ }
+
+ @Override
+ public void setUnlogged(String user) {
+ source.setUnlogged(user);
+ }
+
+ @Override
+ public void purgeLogged() {
+ source.purgeLogged();
+ }
}
diff --git a/src/main/java/fr/xephi/authme/datasource/DataSource.java b/src/main/java/fr/xephi/authme/datasource/DataSource.java
index c1e6d0b2..8fb9790f 100644
--- a/src/main/java/fr/xephi/authme/datasource/DataSource.java
+++ b/src/main/java/fr/xephi/authme/datasource/DataSource.java
@@ -47,5 +47,15 @@ public interface DataSource {
void reload();
void purgeBanned(List banned);
+
+ DataSourceType getType();
+
+ boolean isLogged(String user);
+
+ void setLogged(String user);
+
+ void setUnlogged(String user);
+
+ void purgeLogged();
}
diff --git a/src/main/java/fr/xephi/authme/datasource/FileDataSource.java b/src/main/java/fr/xephi/authme/datasource/FileDataSource.java
index 091d4264..269229b6 100644
--- a/src/main/java/fr/xephi/authme/datasource/FileDataSource.java
+++ b/src/main/java/fr/xephi/authme/datasource/FileDataSource.java
@@ -13,6 +13,7 @@ import java.util.List;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.api.API;
import fr.xephi.authme.cache.auth.PlayerAuth;
+import fr.xephi.authme.settings.PlayersLogs;
import fr.xephi.authme.settings.Settings;
@@ -629,4 +630,29 @@ public class FileDataSource implements DataSource {
return;
}
+ @Override
+ public DataSourceType getType() {
+ return DataSourceType.FILE;
+ }
+
+ @Override
+ public boolean isLogged(String user) {
+ return PlayersLogs.getInstance().players.contains(user.toLowerCase());
+ }
+
+ @Override
+ public void setLogged(String user) {
+ PlayersLogs.getInstance().addPlayer(user);
+ }
+
+ @Override
+ public void setUnlogged(String user) {
+ PlayersLogs.getInstance().removePlayer(user);
+ }
+
+ @Override
+ public void purgeLogged() {
+ PlayersLogs.getInstance().clear();
+ }
+
}
diff --git a/src/main/java/fr/xephi/authme/datasource/MySQLDataSource.java b/src/main/java/fr/xephi/authme/datasource/MySQLDataSource.java
index ae543aba..740abfbb 100644
--- a/src/main/java/fr/xephi/authme/datasource/MySQLDataSource.java
+++ b/src/main/java/fr/xephi/authme/datasource/MySQLDataSource.java
@@ -39,6 +39,7 @@ public class MySQLDataSource implements DataSource {
private String lastlocWorld;
private String columnEmail;
private String columnID;
+ private String columnLogged;
private List columnOthers;
private MiniConnectionPoolManager conPool;
@@ -62,6 +63,7 @@ public class MySQLDataSource implements DataSource {
this.columnEmail = Settings.getMySQLColumnEmail;
this.columnOthers = Settings.getMySQLOtherUsernameColumn;
this.columnID = Settings.getMySQLColumnId;
+ this.columnLogged = Settings.getMySQLColumnLogged;
connect();
setup();
@@ -91,13 +93,14 @@ public class MySQLDataSource implements DataSource {
+ columnID + " INTEGER AUTO_INCREMENT,"
+ columnName + " VARCHAR(255) NOT NULL UNIQUE,"
+ columnPassword + " VARCHAR(255) NOT NULL,"
- + columnIp + " VARCHAR(40) NOT NULL,"
- + columnLastLogin + " BIGINT,"
+ + columnIp + " VARCHAR(40) NOT NULL DEFAULT '127.0.0.1',"
+ + columnLastLogin + " BIGINT DEFAULT '0',"
+ lastlocX + " DOUBLE NOT NULL DEFAULT '0.0',"
+ lastlocY + " DOUBLE NOT NULL DEFAULT '0.0',"
+ lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0',"
+ lastlocWorld + " VARCHAR(255) DEFAULT 'world',"
+ columnEmail + " VARCHAR(255) DEFAULT 'your@email.com',"
+ + columnLogged + " SMALLINT NOT NULL DEFAULT '0',"
+ "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
if (!rs.next()) {
@@ -108,13 +111,13 @@ public class MySQLDataSource implements DataSource {
rs = con.getMetaData().getColumns(null, null, tableName, columnIp);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + columnIp + " VARCHAR(40) NOT NULL;");
+ + columnIp + " VARCHAR(40) NOT NULL DEFAULT '127.0.0.1';");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, columnLastLogin);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
- + columnLastLogin + " BIGINT;");
+ + columnLastLogin + " BIGINT DEFAULT '0';");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
@@ -130,7 +133,12 @@ public class MySQLDataSource implements DataSource {
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, columnEmail);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com' AFTER " + lastlocZ +";");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com' AFTER " + lastlocWorld +";");
+ }
+ rs.close();
+ rs = con.getMetaData().getColumns(null, null, tableName, columnLogged);
+ if (!rs.next()) {
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnLogged + " SMALLINT NOT NULL DEFAULT '0' AFTER " + columnEmail +";");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
@@ -731,7 +739,7 @@ public class MySQLDataSource implements DataSource {
close(rs);
close(pst);
close(con);
- }
+ }
}
@Override
@@ -806,4 +814,105 @@ public class MySQLDataSource implements DataSource {
ConsoleLogger.info("ConnectionPool was unavailable... Reconnected!");
}
+ @Override
+ public DataSourceType getType() {
+ return DataSourceType.MYSQL;
+ }
+
+ @Override
+ public boolean isLogged(String user) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ try {
+ con = makeSureConnectionIsReady();
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ + columnName + "=?;");
+ pst.setString(1, user);
+ rs = pst.executeQuery();
+ if (rs.next())
+ return (rs.getInt(columnLogged) == 1);
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } finally {
+ close(rs);
+ close(pst);
+ close(con);
+ }
+ return false;
+ }
+
+ @Override
+ public void setLogged(String user) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ try {
+ con = makeSureConnectionIsReady();
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnName + "=?;");
+ pst.setInt(1, 1);
+ pst.setString(2, user);
+ pst.executeUpdate();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return;
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return;
+ }
+
+ @Override
+ public void setUnlogged(String user) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ try {
+ con = makeSureConnectionIsReady();
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnName + "=?;");
+ pst.setInt(1, 0);
+ pst.setString(2, user);
+ pst.executeUpdate();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return;
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return;
+ }
+
+ @Override
+ public void purgeLogged() {
+ Connection con = null;
+ PreparedStatement pst = null;
+ try {
+ con = makeSureConnectionIsReady();
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnLogged + "=?;");
+ pst.setInt(1, 0);
+ pst.setInt(2, 1);
+ pst.executeUpdate();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return;
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return;
+ }
+
}
diff --git a/src/main/java/fr/xephi/authme/datasource/SqliteDataSource.java b/src/main/java/fr/xephi/authme/datasource/SqliteDataSource.java
index bbc716b3..6d4ac0be 100644
--- a/src/main/java/fr/xephi/authme/datasource/SqliteDataSource.java
+++ b/src/main/java/fr/xephi/authme/datasource/SqliteDataSource.java
@@ -10,6 +10,7 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.api.API;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.MiniConnectionPoolManager.TimeoutException;
+import fr.xephi.authme.settings.PlayersLogs;
import fr.xephi.authme.settings.Settings;
/**
@@ -509,4 +510,28 @@ public class SqliteDataSource implements DataSource {
}
}
+ @Override
+ public DataSourceType getType() {
+ return DataSourceType.SQLITE;
+ }
+
+ @Override
+ public boolean isLogged(String user) {
+ return PlayersLogs.getInstance().players.contains(user.toLowerCase());
+ }
+
+ @Override
+ public void setLogged(String user) {
+ PlayersLogs.getInstance().addPlayer(user);
+ }
+
+ @Override
+ public void setUnlogged(String user) {
+ PlayersLogs.getInstance().removePlayer(user);
+ }
+
+ @Override
+ public void purgeLogged() {
+ PlayersLogs.getInstance().clear();
+ }
}
diff --git a/src/main/java/fr/xephi/authme/listener/AuthMeBungeeCordListener.java b/src/main/java/fr/xephi/authme/listener/AuthMeBungeeCordListener.java
deleted file mode 100644
index 0702e8d7..00000000
--- a/src/main/java/fr/xephi/authme/listener/AuthMeBungeeCordListener.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package fr.xephi.authme.listener;
-
-import net.md_5.bungee.api.event.ChatEvent;
-
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.Listener;
-
-import fr.xephi.authme.AuthMe;
-import fr.xephi.authme.Utils;
-import fr.xephi.authme.cache.auth.PlayerCache;
-import fr.xephi.authme.datasource.DataSource;
-import fr.xephi.authme.settings.Settings;
-
-
-public class AuthMeBungeeCordListener implements Listener {
- private DataSource data;
- private AuthMe plugin;
-
- public AuthMeBungeeCordListener(DataSource data, AuthMe plugin) {
- this.data = data;
- this.plugin = plugin;
- }
-
- @EventHandler (priority = EventPriority.LOWEST)
- public void onBungeeChatEvent(ChatEvent event) {
- if (!Settings.bungee) return;
- if (event.isCancelled()) return;
- if (!event.isCommand()) return;
- Player player = null;
- try {
- for (String p : plugin.realIp.keySet()) {
- Player pl = Bukkit.getPlayer(p);
- if (pl != null) {
- if (plugin.realIp.get(p).equalsIgnoreCase(event.getSender().getAddress().getAddress().getHostAddress()))
- player = pl;
- }
- }
- } catch (Exception e) {}
- if (player == null) {
- for (Player p : Bukkit.getServer().getOnlinePlayers()) {
- if (p.getAddress().getAddress().equals(event.getSender().getAddress().getAddress())) {
- player = p;
- }
- }
- }
- String name = player.getName().toLowerCase();
-
- if (Utils.getInstance().isUnrestricted(player)) {
- return;
- }
-
- if (PlayerCache.getInstance().isAuthenticated(name)) {
- return;
- }
-
- if (!data.isAuthAvailable(name)) {
- if (!Settings.isForcedRegistrationEnabled) {
- return;
- }
- }
- event.setMessage("/unreacheablecommand");
- event.setCancelled(true);
- }
-}
diff --git a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java
index 5cca514a..1346210e 100644
--- a/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java
+++ b/src/main/java/fr/xephi/authme/listener/AuthMePlayerListener.java
@@ -56,7 +56,6 @@ import fr.xephi.authme.events.SessionEvent;
import fr.xephi.authme.events.SpawnTeleportEvent;
import fr.xephi.authme.plugin.manager.CombatTagComunicator;
import fr.xephi.authme.settings.Messages;
-import fr.xephi.authme.settings.PlayersLogs;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.task.MessageTask;
import fr.xephi.authme.task.TimeoutTask;
@@ -366,7 +365,7 @@ public class AuthMePlayerListener implements Listener {
}
int radius = Settings.getMovementRadius;
- Location spawn = plugin.getSpawnLocation(name, player.getWorld());
+ Location spawn = plugin.getSpawnLocation(player, player.getWorld());
if (!event.getPlayer().getWorld().equals(spawn.getWorld())) {
event.getPlayer().teleport(spawn);
@@ -543,7 +542,7 @@ public class AuthMePlayerListener implements Listener {
Player player = event.getPlayer();
World world = player.getWorld();
final String name = player.getName().toLowerCase();
- Location spawnLoc = plugin.getSpawnLocation(name, world);
+ Location spawnLoc = plugin.getSpawnLocation(player, world);
gm = player.getGameMode();
gameMode.put(name, gm);
BukkitScheduler sched = plugin.getServer().getScheduler();
@@ -563,16 +562,22 @@ public class AuthMePlayerListener implements Listener {
if (plugin.realIp.containsKey(name))
ip = plugin.realIp.get(name);
}
- if(Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) {
- GameMode gM = gameMode.get(name);
- this.causeByAuthMe = true;
- player.setGameMode(gM);
- this.causeByAuthMe = false;
- player.kickPlayer("You are not the Owner of this account, please try another name!");
- if (Settings.banUnsafeIp)
- plugin.getServer().banIP(ip);
- return;
- }
+ if(Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) {
+ GameMode gM = gameMode.get(name);
+ this.causeByAuthMe = true;
+ player.setGameMode(gM);
+ this.causeByAuthMe = false;
+ player.kickPlayer("You are not the Owner of this account, please try another name!");
+ if (Settings.banUnsafeIp)
+ plugin.getServer().banIP(ip);
+ return;
+ }
+ if(Settings.getMaxJoinPerIp > 0 && !plugin.authmePermissible(player, "authme.allow2accounts") && !ip.equalsIgnoreCase("127.0.0.1") && !ip.equalsIgnoreCase("localhost")) {
+ if (plugin.hasJoinedIp(ip)) {
+ player.kickPlayer("A player with the same IP is already in game!");
+ return;
+ }
+ }
if (data.isAuthAvailable(name)) {
if (Settings.isSessionsEnabled) {
PlayerAuth auth = data.getAuth(name);
@@ -586,6 +591,7 @@ public class AuthMePlayerListener implements Listener {
PlayerCache.getInstance().updatePlayer(auth);
} else {
PlayerCache.getInstance().addPlayer(auth);
+ data.setLogged(name);
}
m._(player, "valid_session");
// Restore Permission Group
@@ -606,6 +612,7 @@ public class AuthMePlayerListener implements Listener {
}
//Player change his IP between 2 relog-in
PlayerCache.getInstance().removePlayer(name);
+ data.setUnlogged(name);
} else {
GameMode gM = gameMode.get(name);
this.causeByAuthMe = true;
@@ -617,6 +624,7 @@ public class AuthMePlayerListener implements Listener {
} else {
//Session is ended correctly
PlayerCache.getInstance().removePlayer(name);
+ data.setUnlogged(name);
}
}
// isent in session or session was ended correctly
@@ -742,6 +750,12 @@ public class AuthMePlayerListener implements Listener {
return;
}
+ String ip = player.getAddress().getAddress().getHostAddress();
+ if (Settings.bungee) {
+ if (plugin.realIp.containsKey(name))
+ ip = plugin.realIp.get(name);
+ }
+
if (PlayerCache.getInstance().isAuthenticated(name) && !player.isDead()) {
if(Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) {
final PlayerAuth auth = new PlayerAuth(name,loc.getX(),loc.getY(),loc.getZ(),loc.getWorld().getName());
@@ -749,8 +763,10 @@ public class AuthMePlayerListener implements Listener {
data.updateQuitLoc(auth);
} catch (NullPointerException npe) { }
}
+ PlayerAuth auth = new PlayerAuth(name, ip, System.currentTimeMillis());
+ data.updateSession(auth);
}
-
+
if (data.getAuth(name) != null && !PlayerCache.getInstance().isAuthenticated(name) && Settings.enableProtection)
event.setQuitMessage(null);
@@ -777,9 +793,8 @@ public class AuthMePlayerListener implements Listener {
}
}
PlayerCache.getInstance().removePlayer(name);
+ data.setUnlogged(name);
try {
- PlayersLogs.players.remove(player.getName());
- PlayersLogs.getInstance().save();
player.getVehicle().eject();
} catch (NullPointerException ex) {
}
@@ -810,12 +825,21 @@ public class AuthMePlayerListener implements Listener {
}
String name = player.getName().toLowerCase();
- if ((PlayerCache.getInstance().isAuthenticated(name)) && (!player.isDead()) &&
- (Settings.isSaveQuitLocationEnabled) && data.isAuthAvailable(name)) {
- final PlayerAuth auth = new PlayerAuth(name, loc.getX(), loc.getY(), loc.getZ(),loc.getWorld().getName());
- try {
- data.updateQuitLoc(auth);
- } catch (NullPointerException npe) { }
+
+ String ip = player.getAddress().getAddress().getHostAddress();
+ if (Settings.bungee) {
+ if (plugin.realIp.containsKey(name))
+ ip = plugin.realIp.get(name);
+ }
+ if ((PlayerCache.getInstance().isAuthenticated(name)) && (!player.isDead())) {
+ if ((Settings.isSaveQuitLocationEnabled) && data.isAuthAvailable(name)){
+ final PlayerAuth auth = new PlayerAuth(name, loc.getX(), loc.getY(), loc.getZ(),loc.getWorld().getName());
+ try {
+ data.updateQuitLoc(auth);
+ } catch (NullPointerException npe) { }
+ }
+ PlayerAuth auth = new PlayerAuth(name, ip, System.currentTimeMillis());
+ data.updateSession(auth);
}
if (data.getAuth(name) != null && !PlayerCache.getInstance().isAuthenticated(name) && Settings.enableProtection)
@@ -823,50 +847,49 @@ public class AuthMePlayerListener implements Listener {
if (LimboCache.getInstance().hasLimboPlayer(name))
{
- LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
- if (Settings.protectInventoryBeforeLogInEnabled) {
- try {
- RestoreInventoryEvent ev = new RestoreInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
- plugin.getServer().getPluginManager().callEvent(ev);
- if (!ev.isCancelled()) {
- API.setPlayerInventory(player, ev.getInventory(), ev.getArmor());
- }
- } catch (NullPointerException npe){
- ConsoleLogger.showError("Problem while restore " + name + " inventory after a kick");
- }
- }
- try {
- AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
- plugin.getServer().getPluginManager().callEvent(tpEvent);
- if(!tpEvent.isCancelled()) {
- if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
- tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
- }
- player.teleport(tpEvent.getTo());
- }
- } catch (NullPointerException npe) {
- }
- this.utils.addNormal(player, limbo.getGroup());
- player.setOp(limbo.getOperator());
- if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
- player.setAllowFlight(limbo.isFlying());
- player.setFlying(limbo.isFlying());
- }
- this.plugin.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
- this.plugin.getServer().getScheduler().cancelTask(limbo.getMessageTaskId());
- LimboCache.getInstance().deleteLimboPlayer(name);
- if (this.playerBackup.doesCacheExist(name)) {
- this.playerBackup.removeCache(name);
- }
+ LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
+ if (Settings.protectInventoryBeforeLogInEnabled) {
+ try {
+ RestoreInventoryEvent ev = new RestoreInventoryEvent(player, limbo.getInventory(), limbo.getArmour());
+ plugin.getServer().getPluginManager().callEvent(ev);
+ if (!ev.isCancelled()) {
+ API.setPlayerInventory(player, ev.getInventory(), ev.getArmor());
+ }
+ } catch (NullPointerException npe){
+ ConsoleLogger.showError("Problem while restore " + name + " inventory after a kick");
+ }
+ }
+ try {
+ AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
+ plugin.getServer().getPluginManager().callEvent(tpEvent);
+ if(!tpEvent.isCancelled()) {
+ if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
+ tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
+ }
+ player.teleport(tpEvent.getTo());
+ }
+ } catch (NullPointerException npe) {
+ }
+ this.utils.addNormal(player, limbo.getGroup());
+ player.setOp(limbo.getOperator());
+ if (player.getGameMode() != GameMode.CREATIVE && !Settings.isMovementAllowed) {
+ player.setAllowFlight(limbo.isFlying());
+ player.setFlying(limbo.isFlying());
+ }
+ this.plugin.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
+ this.plugin.getServer().getScheduler().cancelTask(limbo.getMessageTaskId());
+ LimboCache.getInstance().deleteLimboPlayer(name);
+ if (this.playerBackup.doesCacheExist(name)) {
+ this.playerBackup.removeCache(name);
+ }
}
- try {
- PlayerCache.getInstance().removePlayer(name);
- PlayersLogs.players.remove(player.getName());
- PlayersLogs.getInstance().save();
- if (gameMode.containsKey(name)) gameMode.remove(name);
- player.getVehicle().eject();
- player.saveData();
- } catch (NullPointerException ex) {}
+ PlayerCache.getInstance().removePlayer(name);
+ data.setUnlogged(name);
+ if (gameMode.containsKey(name)) gameMode.remove(name);
+ try {
+ player.getVehicle().eject();
+ } catch (NullPointerException ex) {}
+ player.saveData();
}
@EventHandler(priority = EventPriority.MONITOR)
@@ -1099,7 +1122,7 @@ public class AuthMePlayerListener implements Listener {
if (!Settings.isForcedRegistrationEnabled)
return;
- Location spawn = plugin.getSpawnLocation(name, player.getWorld());
+ Location spawn = plugin.getSpawnLocation(player, player.getWorld());
if(Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) {
final PlayerAuth auth = new PlayerAuth(name,spawn.getX(),spawn.getY(),spawn.getZ(),spawn.getWorld().getName());
try {
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 1c09087c..4a5c0058 100644
--- a/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java
+++ b/src/main/java/fr/xephi/authme/process/login/AsyncronousLogin.java
@@ -61,7 +61,7 @@ public class AsyncronousLogin {
}
if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) >= Settings.maxLoginTry) {
plugin.cap.put(name, rdm.nextString());
- for (String s : m._("need_captcha")) {
+ for (String s : m._("usage_captcha")) {
player.sendMessage(s.replace("THE_CAPTCHA", plugin.cap.get(name)).replace("", plugin.cap.get(name)));
}
return true;
@@ -99,6 +99,12 @@ public class AsyncronousLogin {
}
return null;
}
+ if (Settings.getMaxLoginPerIp > 0 && !plugin.authmePermissible(player, "authme.allow2accounts") && !getIP().equalsIgnoreCase("127.0.0.1") && !getIP().equalsIgnoreCase("localhost")) {
+ if (plugin.isLoggedIp(getIP())) {
+ m._(player, "logged_in");
+ return null;
+ }
+ }
PlayerAuth pAuth = database.getAuth(name);
if (pAuth == null) {
m._(player, "user_unknown");
@@ -131,8 +137,6 @@ public class AsyncronousLogin {
PlayerAuth auth = new PlayerAuth(name, hash, getIP(), new Date().getTime(), email, realName);
database.updateSession(auth);
- plugin.pllog.addPlayer(player);
-
if (Settings.useCaptcha) {
if (plugin.captcha.containsKey(name)) {
plugin.captcha.remove(name);
@@ -156,6 +160,7 @@ public class AsyncronousLogin {
// makes player isLoggedin via API
PlayerCache.getInstance().addPlayer(auth);
+ database.setLogged(name);
// As the scheduling executes the Task most likely after the current task, we schedule it in the end
// so that we can be sure, and have not to care if it might be processed in other order.
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 b33dc1f5..fde113c5 100644
--- a/src/main/java/fr/xephi/authme/process/login/ProcessSyncronousPlayerLogin.java
+++ b/src/main/java/fr/xephi/authme/process/login/ProcessSyncronousPlayerLogin.java
@@ -68,7 +68,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
}
}
protected void teleportToSpawn() {
- Location spawnL = plugin.getSpawnLocation(name, player.getWorld());
+ Location spawnL = plugin.getSpawnLocation(player, player.getWorld());
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnL, true);
pm.callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
diff --git a/src/main/java/fr/xephi/authme/process/register/AsyncronousRegister.java b/src/main/java/fr/xephi/authme/process/register/AsyncronousRegister.java
index 2c6f6fc8..b9c048f9 100644
--- a/src/main/java/fr/xephi/authme/process/register/AsyncronousRegister.java
+++ b/src/main/java/fr/xephi/authme/process/register/AsyncronousRegister.java
@@ -148,7 +148,10 @@ public class AsyncronousRegister {
m._(player, "error");
return;
}
- PlayerCache.getInstance().addPlayer(auth);
+ if (!Settings.forceRegLogin) {
+ PlayerCache.getInstance().addPlayer(auth);
+ database.setLogged(name);
+ }
ProcessSyncronousPasswordRegister syncronous = new ProcessSyncronousPasswordRegister(player, plugin);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, syncronous);
return;
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 6ae9fa1e..08d39af4 100644
--- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousEmailRegister.java
+++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousEmailRegister.java
@@ -49,7 +49,7 @@ public class ProcessSyncronousEmailRegister implements Runnable {
if (Settings.isTeleportToSpawnEnabled) {
World world = player.getWorld();
- Location loca = plugin.getSpawnLocation(name, world);
+ Location loca = plugin.getSpawnLocation(player, world);
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {
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 3462b2cf..f9d8bdf0 100644
--- a/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java
+++ b/src/main/java/fr/xephi/authme/process/register/ProcessSyncronousPasswordRegister.java
@@ -7,16 +7,20 @@ import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
+import org.bukkit.scheduler.BukkitScheduler;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.Utils;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.LimboPlayer;
+import fr.xephi.authme.events.AuthMeTeleportEvent;
import fr.xephi.authme.events.LoginEvent;
import fr.xephi.authme.events.RegisterTeleportEvent;
import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings;
+import fr.xephi.authme.task.MessageTask;
+import fr.xephi.authme.task.TimeoutTask;
public class ProcessSyncronousPasswordRegister implements Runnable {
@@ -37,6 +41,39 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
} catch (Exception e) {}
}
}
+
+ protected void forceLogin(Player player) {
+ if (Settings.isTeleportToSpawnEnabled) {
+ Location spawnLoc = plugin.getSpawnLocation(player, player.getWorld());
+ AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc);
+ plugin.getServer().getPluginManager().callEvent(tpEvent);
+ if(!tpEvent.isCancelled()) {
+ if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
+ tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
+ }
+ player.teleport(tpEvent.getTo());
+ }
+ }
+ if (LimboCache.getInstance().hasLimboPlayer(name))
+ LimboCache.getInstance().deleteLimboPlayer(name);
+ LimboCache.getInstance().addLimboPlayer(player);
+ int delay = Settings.getRegistrationTimeout * 20;
+ int interval = Settings.getWarnMessageInterval;
+ BukkitScheduler sched = plugin.getServer().getScheduler();
+ if (delay != 0) {
+ int id = sched.scheduleSyncDelayedTask(plugin, new TimeoutTask(plugin, name), delay);
+ LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
+ }
+ int msgT = sched.scheduleSyncDelayedTask(plugin, new MessageTask(plugin, name, m._("login_msg"), interval));
+ LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
+ try {
+ plugin.pllog.removePlayer(name);
+ if (player.isInsideVehicle())
+ player.getVehicle().eject();
+ } catch (NullPointerException npe) {
+ }
+ }
+
@Override
public void run() {
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
@@ -44,7 +81,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
player.setGameMode(limbo.getGameMode());
if (Settings.isTeleportToSpawnEnabled) {
World world = player.getWorld();
- Location loca = plugin.getSpawnLocation(name, world);
+ Location loca = plugin.getSpawnLocation(player, world);
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {
@@ -73,11 +110,29 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
player.saveData();
+ if (!Settings.noConsoleSpam)
+ ConsoleLogger.info(player.getName() + " registered "+player.getAddress().getAddress().getHostAddress());
+ 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) {
+ player.kickPlayer(m._("registered")[0]);
+ return;
+ }
+
+ // Request Login after Registation
+ if (Settings.forceRegLogin) {
+ forceLogin(player);
+ return;
+ }
+
// Register is finish and player is logged, display welcome message
if(Settings.useWelcomeMessage)
if(Settings.broadcastWelcomeMessage) {
for (String s : Settings.welcomeMsg) {
- Bukkit.getServer().broadcastMessage(s);
+ Bukkit.getServer().broadcastMessage(plugin.replaceAllInfos(s, player));
}
} else {
for (String s : Settings.welcomeMsg) {
@@ -87,11 +142,6 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
// Register is now finish , we can force all commands
forceCommands(player);
- if (!Settings.noConsoleSpam)
- ConsoleLogger.info(player.getName() + " registered "+player.getAddress().getAddress().getHostAddress());
- if(plugin.notifications != null) {
- plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " has registered!"));
- }
- }
+ }
}
diff --git a/src/main/java/fr/xephi/authme/settings/CustomConfiguration.java b/src/main/java/fr/xephi/authme/settings/CustomConfiguration.java
index 1709e2c6..273f8961 100644
--- a/src/main/java/fr/xephi/authme/settings/CustomConfiguration.java
+++ b/src/main/java/fr/xephi/authme/settings/CustomConfiguration.java
@@ -1,10 +1,16 @@
package fr.xephi.authme.settings;
+import java.io.BufferedReader;
+import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.nio.charset.Charset;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -58,8 +64,24 @@ public class CustomConfiguration extends YamlConfiguration{
public boolean loadRessource(File file) {
boolean out = true;
if (!file.exists()) {
- InputStream fis = getClass().getResourceAsStream("/" + file.getName());
- FileOutputStream fos = null;
+ try {
+ InputStream fis = getClass().getResourceAsStream("/" + file.getName());
+ BufferedReader reader = new BufferedReader(new InputStreamReader(fis, Charset.forName("UTF-8").newDecoder()));
+ String str;
+ Writer writer = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(file), Charset.forName("UTF-8").newEncoder()));
+ while ((str = reader.readLine()) != null) {
+ writer.append(str).append("\r\n");
+ }
+ writer.flush();
+ writer.close();
+ reader.close();
+ fis.close();
+ } catch (Exception e) {
+ Logger.getLogger(JavaPlugin.class.getName()).log(Level.SEVERE, "Failed to load config from JAR");
+ out = false;
+ }
+ /*FileOutputStream fos = null;
try {
fos = new FileOutputStream(file);
byte[] buf = new byte[1024];
@@ -81,7 +103,8 @@ public class CustomConfiguration extends YamlConfiguration{
} catch (Exception e) {
}
}
+ }*/
}
return out;
}
-}
+}
\ No newline at end of file
diff --git a/src/main/java/fr/xephi/authme/settings/PlayersLogs.java b/src/main/java/fr/xephi/authme/settings/PlayersLogs.java
index 73bb9780..345dc6ec 100644
--- a/src/main/java/fr/xephi/authme/settings/PlayersLogs.java
+++ b/src/main/java/fr/xephi/authme/settings/PlayersLogs.java
@@ -1,25 +1,28 @@
package fr.xephi.authme.settings;
import java.io.File;
+import java.util.ArrayList;
import java.util.List;
-import org.bukkit.entity.Player;
-
/**
*
* @author Xephi59
*/
public class PlayersLogs extends CustomConfiguration {
private static PlayersLogs pllog = null;
- public static List players;
+ public List players;
- @SuppressWarnings("unchecked")
public PlayersLogs() {
super(new File("./plugins/AuthMe/players.yml"));
pllog = this;
load();
save();
- players = (List) this.getList("players");
+ players = this.getStringList("players");
+ }
+
+ public void clear() {
+ set("players", new ArrayList());
+ save();
}
public static PlayersLogs getInstance() {
@@ -28,13 +31,22 @@ public class PlayersLogs extends CustomConfiguration {
}
return pllog;
}
-
- public void addPlayer(Player player) {
- List players = this.getStringList("players");
- if (!players.contains(player.getName())) {
- players.add(player.getName());
- this.set("players", players);
+
+ public void addPlayer(String user) {
+ players = this.getStringList("players");
+ if (!players.contains(user.toLowerCase())) {
+ players.add(user.toLowerCase());
+ set("players", players);
save();
}
}
+
+ public void removePlayer(String user) {
+ players = this.getStringList("players");
+ if (players.contains(user.toLowerCase())) {
+ players.remove(user.toLowerCase());
+ set("players", players);
+ save();
+ }
+ }
}
diff --git a/src/main/java/fr/xephi/authme/settings/Settings.java b/src/main/java/fr/xephi/authme/settings/Settings.java
index 959e554a..4be58b03 100644
--- a/src/main/java/fr/xephi/authme/settings/Settings.java
+++ b/src/main/java/fr/xephi/authme/settings/Settings.java
@@ -59,7 +59,7 @@ public final class Settings extends YamlConfiguration {
disableSocialSpy, useMultiThreading, forceOnlyAfterLogin, useEssentialsMotd,
usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword, purgeLimitedCreative,
purgeAntiXray, purgePermissions, enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
- broadcastWelcomeMessage;
+ broadcastWelcomeMessage, forceRegKick, forceRegLogin;
public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort,
getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename,
@@ -68,12 +68,12 @@ public final class Settings extends YamlConfiguration {
getcUnrestrictedName, getRegisteredGroup, messagesLanguage, getMySQLlastlocX, getMySQLlastlocY, getMySQLlastlocZ,
rakamakUsers, rakamakUsersIp, getmailAccount, getmailPassword, getmailSMTP, getMySQLColumnId, getmailSenderName,
getMailSubject, getMailText, getMySQLlastlocWorld, defaultWorld,
- getPhpbbPrefix, getWordPressPrefix;
+ getPhpbbPrefix, getWordPressPrefix, getMySQLColumnLogged, spawnPriority;
public static int getWarnMessageInterval, getSessionTimeout, getRegistrationTimeout, getMaxNickLength,
getMinNickLength, getPasswordMinLen, getMovementRadius, getmaxRegPerIp, getNonActivatedGroup,
passwordMaxLength, getRecoveryPassLength, getMailPort, maxLoginTry, captchaLength, saltLength, getmaxRegPerEmail,
- bCryptLog2Rounds, getPhpbbGroup, antiBotSensibility, antiBotDuration, delayRecall;
+ bCryptLog2Rounds, getPhpbbGroup, antiBotSensibility, antiBotDuration, delayRecall, getMaxLoginPerIp, getMaxJoinPerIp;
protected static YamlConfiguration configFile;
@@ -235,6 +235,12 @@ public void loadConfigOptions() {
unsafePasswords = (List) configFile.getList("settings.security.unsafePasswords", new ArrayList());
countriesBlacklist = (List) configFile.getList("Protection.countriesBlacklist", new ArrayList());
broadcastWelcomeMessage = configFile.getBoolean("settings.broadcastWelcomeMessage", false);
+ forceRegKick = configFile.getBoolean("settings.registration.forceKickAfterRegister", false);
+ forceRegLogin = configFile.getBoolean("settings.registration.forceLoginAfterRegister", false);
+ getMySQLColumnLogged = configFile.getString("DataSource.mySQLColumnLogged","isLogged");
+ spawnPriority = configFile.getString("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
+ getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
+ getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
// Load the welcome message
getWelcomeMessage(plugin);
@@ -386,6 +392,12 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
unsafePasswords = (List) configFile.getList("settings.security.unsafePasswords", new ArrayList());
countriesBlacklist = (List) configFile.getList("Protection.countriesBlacklist", new ArrayList());
broadcastWelcomeMessage = configFile.getBoolean("settings.broadcastWelcomeMessage", false);
+ forceRegKick = configFile.getBoolean("settings.registration.forceKickAfterRegister", false);
+ forceRegLogin = configFile.getBoolean("settings.registration.forceLoginAfterRegister", false);
+ getMySQLColumnLogged = configFile.getString("DataSource.mySQLColumnLogged","isLogged");
+ spawnPriority = configFile.getString("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
+ getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
+ getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
// Reload the welcome message
getWelcomeMessage(AuthMe.getInstance());
@@ -525,6 +537,18 @@ public void mergeConfig() {
}
if(!contains("settings.broadcastWelcomeMessage"))
set("settings.broadcastWelcomeMessage", false);
+ if(!contains("settings.registration.forceKickAfterRegister"))
+ set("settings.registration.forceKickAfterRegister", false);
+ if(!contains("settings.registration.forceLoginAfterRegister"))
+ set("settings.registration.forceLoginAfterRegister", false);
+ if(!contains("DataSource.mySQLColumnLogged"))
+ set("DataSource.mySQLColumnLogged", "isLogged");
+ if(!contains("settings.restrictions.spawnPriority"))
+ set("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
+ if(!contains("settings.restrictions.maxLoginPerIp"))
+ set("settings.restrictions.maxLoginPerIp", 0);
+ if(!contains("settings.restrictions.maxJoinPerIp"))
+ set("settings.restrictions.maxJoinPerIp", 0);
plugin.getLogger().warning("Merge new Config Options if needed..");
plugin.getLogger().warning("Please check your config.yml file!");
@@ -728,6 +752,7 @@ public void mergeConfig() {
while((line = br.readLine()) != null) {
welcomeMsg.add(line);
}
+ br.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
diff --git a/src/main/java/fr/xephi/authme/threads/FlatFileThread.java b/src/main/java/fr/xephi/authme/threads/FlatFileThread.java
index bbc14d25..0f2be182 100644
--- a/src/main/java/fr/xephi/authme/threads/FlatFileThread.java
+++ b/src/main/java/fr/xephi/authme/threads/FlatFileThread.java
@@ -15,6 +15,7 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.api.API;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
+import fr.xephi.authme.settings.PlayersLogs;
import fr.xephi.authme.settings.Settings;
@@ -642,4 +643,28 @@ public class FlatFileThread extends Thread implements DataSource {
return;
}
+ @Override
+ public DataSourceType getType() {
+ return DataSourceType.FILE;
+ }
+
+ @Override
+ public boolean isLogged(String user) {
+ return PlayersLogs.getInstance().players.contains(user.toLowerCase());
+ }
+
+ @Override
+ public void setLogged(String user) {
+ PlayersLogs.getInstance().addPlayer(user);
+ }
+
+ @Override
+ public void setUnlogged(String user) {
+ PlayersLogs.getInstance().removePlayer(user);
+ }
+
+ @Override
+ public void purgeLogged() {
+ PlayersLogs.getInstance().clear();
+ }
}
diff --git a/src/main/java/fr/xephi/authme/threads/MySQLThread.java b/src/main/java/fr/xephi/authme/threads/MySQLThread.java
index 98fab821..e52e23d8 100644
--- a/src/main/java/fr/xephi/authme/threads/MySQLThread.java
+++ b/src/main/java/fr/xephi/authme/threads/MySQLThread.java
@@ -8,7 +8,6 @@ import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
-
import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource;
import fr.xephi.authme.AuthMe;
@@ -41,6 +40,7 @@ public class MySQLThread extends Thread implements DataSource {
private String lastlocWorld;
private String columnEmail;
private String columnID;
+ private String columnLogged;
private List columnOthers;
private MiniConnectionPoolManager conPool;
@@ -64,6 +64,7 @@ public class MySQLThread extends Thread implements DataSource {
this.columnEmail = Settings.getMySQLColumnEmail;
this.columnOthers = Settings.getMySQLOtherUsernameColumn;
this.columnID = Settings.getMySQLColumnId;
+ this.columnLogged = Settings.getMySQLColumnLogged;
try {
this.connect();
this.setup();
@@ -121,13 +122,14 @@ public class MySQLThread extends Thread implements DataSource {
+ columnID + " INTEGER AUTO_INCREMENT,"
+ columnName + " VARCHAR(255) NOT NULL UNIQUE,"
+ columnPassword + " VARCHAR(255) NOT NULL,"
- + columnIp + " VARCHAR(40) NOT NULL,"
- + columnLastLogin + " BIGINT,"
+ + columnIp + " VARCHAR(40) NOT NULL DEFAULT '127.0.0.1',"
+ + columnLastLogin + " BIGINT DEFAULT '0',"
+ lastlocX + " DOUBLE NOT NULL DEFAULT '0.0',"
+ lastlocY + " DOUBLE NOT NULL DEFAULT '0.0',"
+ lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0',"
+ lastlocWorld + " VARCHAR(255) DEFAULT 'world',"
+ columnEmail + " VARCHAR(255) DEFAULT 'your@email.com',"
+ + columnLogged + " SMALLINT NOT NULL DEFAULT '0',"
+ "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
if (!rs.next()) {
@@ -160,7 +162,12 @@ public class MySQLThread extends Thread implements DataSource {
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, columnEmail);
if (!rs.next()) {
- st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com' AFTER " + lastlocZ +";");
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com' AFTER " + lastlocWorld +";");
+ }
+ rs.close();
+ rs = con.getMetaData().getColumns(null, null, tableName, columnLogged);
+ if (!rs.next()) {
+ st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + columnLogged + " SMALLINT NOT NULL DEFAULT '0' AFTER " + columnEmail +";");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
@@ -836,4 +843,105 @@ public class MySQLThread extends Thread implements DataSource {
ConsoleLogger.info("ConnectionPool was unavailable... Reconnected!");
}
+ @Override
+ public DataSourceType getType() {
+ return DataSourceType.MYSQL;
+ }
+
+ @Override
+ public boolean isLogged(String user) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ ResultSet rs = null;
+ try {
+ con = makeSureConnectionIsReady();
+ pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ + columnName + "=?;");
+ pst.setString(1, user);
+ rs = pst.executeQuery();
+ if (rs.next())
+ return (rs.getInt(columnLogged) == 1);
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return false;
+ } finally {
+ close(rs);
+ close(pst);
+ close(con);
+ }
+ return false;
+ }
+
+ @Override
+ public void setLogged(String user) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ try {
+ con = makeSureConnectionIsReady();
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnName + "=?;");
+ pst.setInt(1, 1);
+ pst.setString(2, user);
+ pst.executeUpdate();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return;
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return;
+ }
+
+ @Override
+ public void setUnlogged(String user) {
+ Connection con = null;
+ PreparedStatement pst = null;
+ try {
+ con = makeSureConnectionIsReady();
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnName + "=?;");
+ pst.setInt(1, 0);
+ pst.setString(2, user);
+ pst.executeUpdate();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return;
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return;
+ }
+
+ @Override
+ public void purgeLogged() {
+ Connection con = null;
+ PreparedStatement pst = null;
+ try {
+ con = makeSureConnectionIsReady();
+ pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnLogged + "=? WHERE " + columnLogged + "=?;");
+ pst.setInt(1, 0);
+ pst.setInt(2, 1);
+ pst.executeUpdate();
+ } catch (SQLException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return;
+ } catch (TimeoutException ex) {
+ ConsoleLogger.showError(ex.getMessage());
+ return;
+ } finally {
+ close(pst);
+ close(con);
+ }
+ return;
+ }
+
}
diff --git a/src/main/java/fr/xephi/authme/threads/SQLiteThread.java b/src/main/java/fr/xephi/authme/threads/SQLiteThread.java
index db465bba..0a61fcb1 100644
--- a/src/main/java/fr/xephi/authme/threads/SQLiteThread.java
+++ b/src/main/java/fr/xephi/authme/threads/SQLiteThread.java
@@ -15,6 +15,7 @@ import fr.xephi.authme.api.API;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.datasource.MiniConnectionPoolManager.TimeoutException;
+import fr.xephi.authme.settings.PlayersLogs;
import fr.xephi.authme.settings.Settings;
@@ -521,4 +522,28 @@ public class SQLiteThread extends Thread implements DataSource {
}
}
+ @Override
+ public DataSourceType getType() {
+ return DataSourceType.SQLITE;
+ }
+
+ @Override
+ public boolean isLogged(String user) {
+ return PlayersLogs.getInstance().players.contains(user.toLowerCase());
+ }
+
+ @Override
+ public void setLogged(String user) {
+ PlayersLogs.getInstance().addPlayer(user);
+ }
+
+ @Override
+ public void setUnlogged(String user) {
+ PlayersLogs.getInstance().removePlayer(user);
+ }
+
+ @Override
+ public void purgeLogged() {
+ PlayersLogs.getInstance().clear();
+ }
}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 4dedf56d..c03832ce 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -21,7 +21,7 @@ DataSource:
mySQLColumnPassword: password
# Password about Database Connection Infos
mySQLPassword: '12345'
- # Do we need to cache all things ? Not Recommanded with multiThreading enable
+ # Do we need to cache all query?
caching: true
# Column for SaveQuitLocation - X
mySQLlastlocX: x
@@ -35,6 +35,8 @@ DataSource:
mySQLColumnEmail: email
# Column of IDs to sort data
mySQLColumnId: id
+ # Column for Saving if a player is logged in or not
+ mySQLColumnLogged: isLogged
GroupOptions:
# if you want to set up a particulary Permission Group for
# users that arent registered yet. Pay attention this option
@@ -154,6 +156,12 @@ settings:
- world_the_end
# Ban ip when the ip is not the ip registered in database
banUnsafedIP: false
+ # Spawn Priority, Values : authme, essentials, multiverse, default
+ spawnPriority: authme,essentials,multiverse,default
+ # Maximum Login authorized by IP
+ maxLoginPerIp: 0
+ # Maximum Join authorized by IP
+ maxJoinPerIp: 0
GameMode:
# ForceSurvivalMode to player when join ?
ForceSurvivalMode: false
@@ -199,10 +207,10 @@ settings:
# AuthMe will update the password to the new passwordHash !
supportOldPasswordHash: false
# Cancel unsafe passwords for being used, put them on lowercase!
- unsafePasswords: []
#unsafePasswords:
#- '123456'
#- 'password'
+ unsafePasswords: []
registration:
# enable registration on the server?
enabled: true
@@ -218,6 +226,11 @@ settings:
# when it's true, registration require that kind of command:
# /register
doubleEmailCheck: false
+ # Do we force kicking player after a successful registration ?
+ # Do not use with login feature below
+ forceKickAfterRegister: false
+ # Does AuthMe need to enforce a /login after a successful registration ?
+ forceLoginAfterRegister: false
unrestrictions:
# below you can list all your account name, that
# AuthMe will ignore for registration or login, configure it
diff --git a/src/main/resources/messages_fi.yml b/src/main/resources/messages_fi.yml
index 8fccc444..f2fff3f0 100644
--- a/src/main/resources/messages_fi.yml
+++ b/src/main/resources/messages_fi.yml
@@ -1,4 +1,4 @@
-unknown_user: '&fKäyttäjä ei ole tietokannassa!'
+unknown_user: '&fKäyttäjä ei ole tietokannassa!'
unsafe_spawn: '&fHengenvaarallinen poistumispaikka! Siirsimme sinut spawnille!'
not_logged_in: '&cEt ole kirjautunut sisään!'
reg_voluntarily: '&fNyt voit rekisteröidä pelaajasi palvelimellemme: "/register salasana salasana"'
diff --git a/src/main/resources/messages_hu.yml b/src/main/resources/messages_hu.yml
index 0d736503..25f14563 100644
--- a/src/main/resources/messages_hu.yml
+++ b/src/main/resources/messages_hu.yml
@@ -1,36 +1,36 @@
-reg_only: Csak regisztrlt jtkosoknak! Jelentkezni a yndicraft@freemail.hu e-mail cmen lehet
-usage_unreg: '&cHasznlat: /unregister jelsz'
-registered: '&aSikeres regisztrci. dvzllek!'
-user_regged: '&cJtkosnv mr regisztrlva'
-login_msg: '&cKrlek jelentkezz be: "/login jelsz"'
+reg_only: Csak regisztrált játékosoknak! Jelentkezni a yndicraft@freemail.hu e-mail címen lehet
+usage_unreg: '&cHasználat: /unregister jelszó'
+registered: '&aSikeres regisztráció. Üdvözöllek!'
+user_regged: '&cJátékosnév már regisztrálva'
+login_msg: '&cKérlek jelentkezz be: "/login jelszó"'
not_logged_in: '&cNem vagy bejelentkezve!'
-logout: '&cSikeresen kijelentkeztl'
-usage_log: '&cBejelentkezs: /login jelsz'
+logout: '&cSikeresen kijelentkeztél'
+usage_log: '&cBejelentkezés: /login jelszó'
unknown_user: User is not in database
-reg_voluntarily: Regisztrlhatod beceneved a szerveren a kvetkez parancsal "/register jelsz jelsz"
-reg_disabled: '&cRegisztrci letiltva'
-no_perm: '&cNincs engedlyed'
-usage_reg: '&cHasznlat: /register jelsz jelszjra'
-unregistered: '&cRegisztrci sikeresen trlve!'
-same_nick: Ezen a jtkosnven mr jtszanak
+reg_voluntarily: Regisztrálhatod beceneved a szerveren a következö parancsal "/register jelszó jelszó"
+reg_disabled: '&cRegisztráció letiltva'
+no_perm: '&cNincs engedélyed'
+usage_reg: '&cHasználat: /register jelszó jelszóújra'
+unregistered: '&cRegisztráció sikeresen törölve!'
+same_nick: Ezen a játékosnéven már játszanak
valid_session: '&cSession login'
-pwd_changed: '&cJelsz cserlve!'
-reload: Beltsok s adatbzis jratltve!
-timeout: Bejelentkezsi idtllps
-error: Hiba lpett fel; Lpj kapcsolatba a tulajjal'
-logged_in: '&cMr be vagy jelentkezve!'
-login: '&aSikeresen Belptl! dvzllek!!!'
-wrong_pwd: '&4Hibs jelsz'
-user_unknown: '&cJtkosnv nem regisztrlt'
-reg_msg: '&cKrlek Regisztrlj: "/register jelsz jelszjra"'
+pwd_changed: '&cJelszó cserélve!'
+reload: Beálítások és adatbázis újratöltve!
+timeout: Bejelentkezési idötúllépés
+error: Hiba lépett fel; Lépj kapcsolatba a tulajjal'
+logged_in: '&cMár be vagy jelentkezve!'
+login: '&aSikeresen Beléptél! Üdvözöllek!!!'
+wrong_pwd: '&4Hibás jelszó'
+user_unknown: '&cJátékosnév nem regisztrált'
+reg_msg: '&cKérlek Regisztrálj: "/register jelszó jelszóújra"'
reg_email_msg: '&cPlease register with "/register "'
-unsafe_spawn: A kilpsi helyzeted nem biztonsgos, teleportls a kezd Spawnra.
-max_reg: Csak egy karakterrel Registrlhatsz!!!
-password_error: A jelsz nem illik ssze
+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
-pass_len: A jelszavad nem ri el a minimlis hosszat
+pass_len: A jelszavad nem éri el a minimális hosszat
vb_nonActiv: Your Account isent Activated yet check your Emails!
-usage_changepassword: 'hasznlat: /changepassword rgiJelsz jJelsz'
+usage_changepassword: 'használat: /changepassword régiJelszó újJelszó'
name_len: '&cYour nickname is too Short or too long'
regex: '&cYour nickname contains illegal characters. Allowed chars: REG_EX'
add_email: '&cPlease add your email with : /email add yourEmail confirmEmail'
diff --git a/src/main/resources/messages_ko.yml b/src/main/resources/messages_ko.yml
index 8342a56b..38b5fc37 100644
--- a/src/main/resources/messages_ko.yml
+++ b/src/main/resources/messages_ko.yml
@@ -1,4 +1,4 @@
-unknown_user: 사용자는 데이터베이스에 없습니다
+unknown_user: 사용자는 데이터베이스에 없습니다
unsafe_spawn: 당신이 나갔던 위치는 안전하지 않았습니다, 당신을 윌드 스폰으로 텔레포트시킵니다
not_logged_in: '&c로그인하지 않았습니다!'
reg_voluntarily: 당신이 서버에 게정을 등록하고 싶다면 "/register 비밀번호 비밀번호재입력"을 치세요
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 04b3a930..adf1f2f8 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -3,7 +3,7 @@ author: Xephi59
website: http://dev.bukkit.org/bukkit-plugins/authme-reloaded/
description: AuthMe prevents people, which aren't logged in, from doing stuff like placing blocks, moving, typing commands or seeing the inventory of the current player.
main: fr.xephi.authme.AuthMe
-version: 3.3.3
+version: 3.3.4
softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag, Essentials, EssentialsSpawn]
commands:
register: