Update 2.9

* Add a better MultiThreading support for database
* Fix some problem with assertion error
* Add WBB3 support
* Add SH512 support
* Add reg_email_msg in all messages.yml for diff visibility
* Fix Problem with DeOped players
* FIX BungeeCord support - Thanks to games647
This commit is contained in:
Xephi 2013-08-05 15:28:48 +02:00
parent f81ae45f16
commit 84d362196c
39 changed files with 2024 additions and 1250 deletions

View File

@ -28,12 +28,12 @@
</plugin>
</plugins>
</build>
<version>2.8b1</version>
<version>2.9</version>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.6.2-R0.1-SNAPSHOT</version>
<version>1.6.2-R0.1</version>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>

View File

@ -65,6 +65,9 @@ import uk.org.whoami.authme.plugin.manager.EssSpawn;
import uk.org.whoami.authme.settings.Messages;
import uk.org.whoami.authme.settings.PlayersLogs;
import uk.org.whoami.authme.settings.Settings;
import uk.org.whoami.authme.threads.FlatFileThread;
import uk.org.whoami.authme.threads.MySQLThread;
import uk.org.whoami.authme.threads.SQLiteThread;
import me.muizers.Notifications.Notifications;
import net.citizensnpcs.Citizens;
@ -108,6 +111,7 @@ public class AuthMe extends JavaPlugin {
public List<String> premium = new ArrayList<String>();
public MultiverseCore mv = null;
public Location essentialsSpawn;
public Thread databaseThread = null;
@Override
public void onEnable() {
@ -169,6 +173,13 @@ public class AuthMe extends JavaPlugin {
*/
switch (Settings.getDataSource) {
case FILE:
if (Settings.useMultiThreading) {
FlatFileThread fileThread = new FlatFileThread();
fileThread.run();
database = fileThread;
databaseThread = fileThread;
break;
}
try {
database = new FileDataSource();
} catch (IOException ex) {
@ -183,6 +194,13 @@ public class AuthMe extends JavaPlugin {
}
break;
case MYSQL:
if (Settings.useMultiThreading) {
MySQLThread sqlThread = new MySQLThread();
sqlThread.run();
database = sqlThread;
databaseThread = sqlThread;
break;
}
try {
database = new MySQLDataSource();
} catch (ClassNotFoundException ex) {
@ -215,6 +233,13 @@ public class AuthMe extends JavaPlugin {
}
break;
case SQLITE:
if (Settings.useMultiThreading) {
SQLiteThread sqliteThread = new SQLiteThread();
sqliteThread.run();
database = sqliteThread;
databaseThread = sqliteThread;
break;
}
try {
database = new SqliteDataSource();
} catch (ClassNotFoundException ex) {
@ -285,7 +310,7 @@ public class AuthMe extends JavaPlugin {
this.getCommand("changepassword").setExecutor(new ChangePasswordCommand(database, this));
this.getCommand("logout").setExecutor(new LogoutCommand(this,database));
this.getCommand("unregister").setExecutor(new UnregisterCommand(this, database));
this.getCommand("passpartu").setExecutor(new PasspartuCommand(database, this));
this.getCommand("passpartu").setExecutor(new PasspartuCommand(this));
this.getCommand("email").setExecutor(new EmailCommand(this, database));
this.getCommand("captcha").setExecutor(new CaptchaCommand(this));
@ -428,6 +453,10 @@ public class AuthMe extends JavaPlugin {
if (database != null) {
database.close();
}
if (databaseThread != null) {
databaseThread.interrupt();
}
if(Settings.isBackupActivated && Settings.isBackupOnStop) {
Boolean Backup = new PerformBackup(this).DoBackup();

View File

@ -1,7 +1,3 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package uk.org.whoami.authme;
import java.io.File;

View File

@ -1,6 +1,7 @@
package uk.org.whoami.authme.api;
import java.lang.reflect.Array;
import java.security.NoSuchAlgorithmException;
import java.util.List;
import org.bukkit.Bukkit;
@ -15,17 +16,18 @@ import uk.org.whoami.authme.cache.auth.PlayerAuth;
import uk.org.whoami.authme.cache.auth.PlayerCache;
import uk.org.whoami.authme.datasource.DataSource;
import uk.org.whoami.authme.datasource.DataSource.DataSourceType;
import uk.org.whoami.authme.security.PasswordSecurity;
import uk.org.whoami.authme.security.PasswordSecurity.HashAlgorithm;
import uk.org.whoami.authme.settings.Settings;
public class API {
public AuthMe instance;
public DataSource database;
public static AuthMe instance;
public static DataSource database;
public API(AuthMe instance, DataSource database) {
this.instance = instance;
this.database = database;
API.instance = instance;
API.database = database;
}
/**
* Hook into AuthMe
@ -173,15 +175,6 @@ public class API {
} catch (NullPointerException npe) {
}
}
public void saveAuth(final PlayerAuth auth) {
instance.getServer().getScheduler().runTask(instance, new Runnable() {
@Override
public void run() {
database.saveAuth(auth);
}
});
}
/**
*
@ -189,10 +182,26 @@ public class API {
* @return true if player is registered
*/
public static boolean isRegistered(String playerName) {
PlayerAuth auth = PlayerCache.getInstance().getAuth(playerName);
String player = playerName.toLowerCase();
PlayerAuth auth = database.getAuth(player);
if (auth != null)
return true;
return false;
}
/**
* @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(), player);
} catch (NoSuchAlgorithmException e) {
return false;
}
}
}

View File

@ -97,7 +97,7 @@ public class EmailCommand implements CommandExecutor {
if (!data.isAuthAvailable(name)) {
player.sendMessage(m._("login_msg"));
} else {
player.sendMessage(m._("reg_msg"));
player.sendMessage(m._("reg_email_msg"));
}
}
} else if(args[0].equalsIgnoreCase("change") && args.length == 3 ) {
@ -129,7 +129,7 @@ public class EmailCommand implements CommandExecutor {
if (!data.isAuthAvailable(name)) {
player.sendMessage(m._("login_msg"));
} else {
player.sendMessage(m._("reg_msg"));
player.sendMessage(m._("reg_email_msg"));
}
}
}
@ -189,7 +189,7 @@ public class EmailCommand implements CommandExecutor {
sender.sendMessage(m._("error"));
}
} else {
player.sendMessage(m._("reg_msg"));
player.sendMessage(m._("reg_email_msg"));
}
}
return true;

View File

@ -23,8 +23,6 @@ import org.bukkit.entity.Player;
import uk.org.whoami.authme.AuthMe;
import uk.org.whoami.authme.settings.Messages;
import uk.org.whoami.authme.settings.Settings;
import uk.org.whoami.authme.threads.LoginThread;
public class LoginCommand implements CommandExecutor {
@ -52,12 +50,7 @@ public class LoginCommand implements CommandExecutor {
player.sendMessage(m._("no_perm"));
return true;
}
if (Settings.useMultiThreading) {
plugin.management.performLogin(player, args[0], false);
} else {
Thread mThread = new LoginThread(plugin.database, plugin, player, args[0]);
mThread.run();
}
plugin.management.performLogin(player, args[0], false);
return true;
}
}

View File

@ -12,10 +12,7 @@ import org.bukkit.entity.Player;
import uk.org.whoami.authme.AuthMe;
import uk.org.whoami.authme.Utils;
import uk.org.whoami.authme.cache.auth.PlayerCache;
import uk.org.whoami.authme.datasource.DataSource;
import uk.org.whoami.authme.settings.Messages;
import uk.org.whoami.authme.settings.Settings;
import uk.org.whoami.authme.threads.LoginThread;
/**
*
@ -23,12 +20,10 @@ import uk.org.whoami.authme.threads.LoginThread;
*/
public class PasspartuCommand implements CommandExecutor {
private Utils utils = new Utils();
private DataSource database;
public AuthMe plugin;
private Messages m;
public PasspartuCommand(DataSource database, AuthMe plugin) {
this.database = database;
public PasspartuCommand(AuthMe plugin) {
this.plugin = plugin;
}
@ -47,12 +42,7 @@ public class PasspartuCommand implements CommandExecutor {
if ((sender instanceof Player) && args.length == 1) {
if(utils.readToken(args[0])) {
//bypass login!
if (Settings.useMultiThreading) {
Thread bypass = new LoginThread(database, false, plugin, (Player) sender, "dontneed");
bypass.run();
} else {
plugin.management.performLogin((Player) sender, "dontneed", true);
}
plugin.management.performLogin((Player) sender, "dontneed", true);
return true;
}
sender.sendMessage("Time is expired or Token is Wrong!");

View File

@ -48,7 +48,6 @@ import uk.org.whoami.authme.settings.Settings;
import uk.org.whoami.authme.settings.Spawn;
import uk.org.whoami.authme.task.MessageTask;
import uk.org.whoami.authme.task.TimeoutTask;
import uk.org.whoami.authme.threads.RegisterThread;
public class RegisterCommand implements CommandExecutor {
@ -87,217 +86,128 @@ public class RegisterCommand implements CommandExecutor {
final String ip = ipA;
if (Settings.useMultiThreading) {
Thread register = new RegisterThread(plugin, database, player, ip, args);
register.run();
return true;
} else {
if (PlayerCache.getInstance().isAuthenticated(name)) {
player.sendMessage(m._("logged_in"));
return true;
}
if (PlayerCache.getInstance().isAuthenticated(name)) {
player.sendMessage(m._("logged_in"));
return true;
}
if (!Settings.isRegistrationEnabled) {
player.sendMessage(m._("reg_disabled"));
return true;
}
if (!Settings.isRegistrationEnabled) {
player.sendMessage(m._("reg_disabled"));
return true;
}
if (database.isAuthAvailable(player.getName().toLowerCase())) {
player.sendMessage(m._("user_regged"));
if (pllog.getStringList("players").contains(player.getName())) {
pllog.getStringList("players").remove(player.getName());
}
return true;
if (database.isAuthAvailable(player.getName().toLowerCase())) {
player.sendMessage(m._("user_regged"));
if (pllog.getStringList("players").contains(player.getName())) {
pllog.getStringList("players").remove(player.getName());
}
return true;
}
if(Settings.getmaxRegPerIp > 0 ){
if(!plugin.authmePermissible(sender, "authme.allow2accounts") && database.getAllAuthsByIp(ipA).size() >= Settings.getmaxRegPerIp) {
player.sendMessage(m._("max_reg"));
if(Settings.getmaxRegPerIp > 0 ){
if(!plugin.authmePermissible(sender, "authme.allow2accounts") && database.getAllAuthsByIp(ipA).size() >= Settings.getmaxRegPerIp) {
player.sendMessage(m._("max_reg"));
return true;
}
}
if(Settings.emailRegistration && !Settings.getmailAccount.isEmpty()) {
if(args.length < 1 || !args[0].contains("@")) {
player.sendMessage(m._("reg_email_msg"));
return true;
}
if(Settings.doubleEmailCheck) {
if(args.length < 2) {
player.sendMessage(m._("reg_email_msg"));
return true;
}
}
if(Settings.emailRegistration && !Settings.getmailAccount.isEmpty()) {
if(!args[0].contains("@")) {
player.sendMessage(m._("usage_reg"));
}
if(!args[0].equals(args[1])) {
player.sendMessage(m._("reg_email_msg"));
return true;
}
if(Settings.doubleEmailCheck) {
if(args.length < 2) {
player.sendMessage(m._("usage_reg"));
return true;
}
if(!args[0].equals(args[1])) {
player.sendMessage(m._("usage_reg"));
return true;
}
}
final String email = args[0];
if(Settings.getmaxRegPerEmail > 0) {
if (!plugin.authmePermissible(sender, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
player.sendMessage(m._("max_reg"));
return true;
}
}
RandomString rand = new RandomString(Settings.getRecoveryPassLength);
final String thePass = rand.nextString();
if (!thePass.isEmpty()) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
if (PasswordSecurity.userSalt.containsKey(name)) {
try {
final String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, thePass, name);
final PlayerAuth fAuth = new PlayerAuth(name, hashnew, PasswordSecurity.userSalt.get(name), ip, new Date().getTime(), (int) player.getLocation().getX() , (int) player.getLocation().getY(), (int) player.getLocation().getZ(), player.getLocation().getWorld().getName(), email);
database.saveAuth(fAuth);
database.updateEmail(fAuth);
database.updateSession(fAuth);
plugin.mail.main(fAuth, thePass);
} catch (NoSuchAlgorithmException e) {
ConsoleLogger.showError(e.getMessage());
}
} else {
try {
final String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, thePass, name);
final PlayerAuth fAuth = new PlayerAuth(name, hashnew, ip, new Date().getTime(), (int) player.getLocation().getX() , (int) player.getLocation().getY(), (int) player.getLocation().getZ(), player.getLocation().getWorld().getName(), email);
database.saveAuth(fAuth);
database.updateEmail(fAuth);
database.updateSession(fAuth);
plugin.mail.main(fAuth, thePass);
} catch (NoSuchAlgorithmException e) {
ConsoleLogger.showError(e.getMessage());
}
}
}
});
if(!Settings.getRegisteredGroup.isEmpty()){
Utils.getInstance().setGroup(player, Utils.groupType.REGISTERED);
}
player.sendMessage(m._("vb_nonActiv"));
String msg = m._("login_msg");
int time = Settings.getRegistrationTimeout * 20;
int msgInterval = Settings.getWarnMessageInterval;
if (time != 0) {
Bukkit.getScheduler().cancelTask(LimboCache.getInstance().getLimboPlayer(name).getTimeoutTaskId());
BukkitTask id = Bukkit.getScheduler().runTaskLater(plugin, new TimeoutTask(plugin, name), time);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id.getTaskId());
}
Bukkit.getScheduler().cancelTask(LimboCache.getInstance().getLimboPlayer(name).getMessageTaskId());
BukkitTask nwMsg = Bukkit.getScheduler().runTask(plugin, new MessageTask(plugin, name, msg, msgInterval));
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(nwMsg.getTaskId());
LimboCache.getInstance().deleteLimboPlayer(name);
if (Settings.isTeleportToSpawnEnabled) {
World world = player.getWorld();
Location loca = world.getSpawnLocation();
if (plugin.mv != null) {
try {
loca = plugin.mv.getMVWorldManager().getMVWorld(world).getSpawnLocation();
} catch (NullPointerException npe) {
} catch (ClassCastException cce) {
} catch (NoClassDefFoundError ncdfe) {
}
}
if (plugin.essentialsSpawn != null) {
loca = plugin.essentialsSpawn;
}
if (Spawn.getInstance().getLocation() != null)
loca = Spawn.getInstance().getLocation();
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
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());
}
}
this.isFirstTimeJoin = 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!"));
}
return true;
}
}
if (args.length == 0 || (Settings.getEnablePasswordVerifier && args.length < 2) ) {
player.sendMessage(m._("usage_reg"));
return true;
}
if(args[0].length() < Settings.getPasswordMinLen || args[0].length() > Settings.passwordMaxLength) {
player.sendMessage(m._("pass_len"));
return true;
}
try {
String hash;
if(Settings.getEnablePasswordVerifier) {
if (args[0].equals(args[1])) {
hash = PasswordSecurity.getHash(Settings.getPasswordHash, args[0], name);
} else {
player.sendMessage(m._("password_error"));
return true;
}
} else
hash = PasswordSecurity.getHash(Settings.getPasswordHash, args[0], name);
if (Settings.getMySQLColumnSalt.isEmpty())
{
auth = new PlayerAuth(name, hash, ip, new Date().getTime());
} else {
auth = new PlayerAuth(name, hash, PasswordSecurity.userSalt.get(name), ip, new Date().getTime());
}
if (!database.saveAuth(auth)) {
player.sendMessage(m._("error"));
return true;
}
PlayerCache.getInstance().addPlayer(auth);
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
if (limbo != null) {
player.setGameMode(GameMode.getByValue(limbo.getGameMode()));
if (Settings.isTeleportToSpawnEnabled) {
World world = player.getWorld();
Location loca = world.getSpawnLocation();
if (plugin.mv != null) {
try {
loca = plugin.mv.getMVWorldManager().getMVWorld(world).getSpawnLocation();
} catch (NullPointerException npe) {
} catch (ClassCastException cce) {
} catch (NoClassDefFoundError ncdfe) {
}
}
if (plugin.essentialsSpawn != null) {
loca = plugin.essentialsSpawn;
}
if (Spawn.getInstance().getLocation() != null)
loca = Spawn.getInstance().getLocation();
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
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());
}
}
sender.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
sender.getServer().getScheduler().cancelTask(limbo.getMessageTaskId());
LimboCache.getInstance().deleteLimboPlayer(name);
}
}
}
final String email = args[0];
if(Settings.getmaxRegPerEmail > 0) {
if (!plugin.authmePermissible(sender, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
player.sendMessage(m._("max_reg"));
return true;
}
}
RandomString rand = new RandomString(Settings.getRecoveryPassLength);
final String thePass = rand.nextString();
if (!thePass.isEmpty()) {
Bukkit.getScheduler().runTaskAsynchronously(plugin, new Runnable() {
@Override
public void run() {
if (PasswordSecurity.userSalt.containsKey(name)) {
try {
final String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, thePass, name);
final PlayerAuth fAuth = new PlayerAuth(name, hashnew, PasswordSecurity.userSalt.get(name), ip, new Date().getTime(), (int) player.getLocation().getX() , (int) player.getLocation().getY(), (int) player.getLocation().getZ(), player.getLocation().getWorld().getName(), email);
database.saveAuth(fAuth);
database.updateEmail(fAuth);
database.updateSession(fAuth);
plugin.mail.main(fAuth, thePass);
} catch (NoSuchAlgorithmException e) {
ConsoleLogger.showError(e.getMessage());
}
} else {
try {
final String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, thePass, name);
final PlayerAuth fAuth = new PlayerAuth(name, hashnew, ip, new Date().getTime(), (int) player.getLocation().getX() , (int) player.getLocation().getY(), (int) player.getLocation().getZ(), player.getLocation().getWorld().getName(), email);
database.saveAuth(fAuth);
database.updateEmail(fAuth);
database.updateSession(fAuth);
plugin.mail.main(fAuth, thePass);
} catch (NoSuchAlgorithmException e) {
ConsoleLogger.showError(e.getMessage());
}
}
}
});
if(!Settings.getRegisteredGroup.isEmpty()){
Utils.getInstance().setGroup(player, Utils.groupType.REGISTERED);
}
player.sendMessage(m._("registered"));
if (!Settings.getmailAccount.isEmpty())
player.sendMessage(m._("add_email"));
player.sendMessage(m._("vb_nonActiv"));
String msg = m._("login_msg");
int time = Settings.getRegistrationTimeout * 20;
int msgInterval = Settings.getWarnMessageInterval;
if (time != 0) {
Bukkit.getScheduler().cancelTask(LimboCache.getInstance().getLimboPlayer(name).getTimeoutTaskId());
BukkitTask id = Bukkit.getScheduler().runTaskLater(plugin, new TimeoutTask(plugin, name), time);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id.getTaskId());
}
Bukkit.getScheduler().cancelTask(LimboCache.getInstance().getLimboPlayer(name).getMessageTaskId());
BukkitTask nwMsg = Bukkit.getScheduler().runTask(plugin, new MessageTask(plugin, name, msg, msgInterval));
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(nwMsg.getTaskId());
LimboCache.getInstance().deleteLimboPlayer(name);
if (Settings.isTeleportToSpawnEnabled) {
World world = player.getWorld();
Location loca = world.getSpawnLocation();
if (plugin.mv != null) {
try {
loca = plugin.mv.getMVWorldManager().getMVWorld(world).getSpawnLocation();
} catch (NullPointerException npe) {
} catch (ClassCastException cce) {
} catch (NoClassDefFoundError ncdfe) {
}
}
if (plugin.essentialsSpawn != null) {
loca = plugin.essentialsSpawn;
}
if (Spawn.getInstance().getLocation() != null)
loca = Spawn.getInstance().getLocation();
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
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());
}
}
this.isFirstTimeJoin = true;
player.saveData();
if (!Settings.noConsoleSpam)
@ -305,11 +215,94 @@ public class RegisterCommand implements CommandExecutor {
if(plugin.notifications != null) {
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " has registered!"));
}
} catch (NoSuchAlgorithmException ex) {
ConsoleLogger.showError(ex.getMessage());
sender.sendMessage(m._("error"));
return true;
}
}
if (args.length == 0 || (Settings.getEnablePasswordVerifier && args.length < 2) ) {
player.sendMessage(m._("usage_reg"));
return true;
}
if(args[0].length() < Settings.getPasswordMinLen || args[0].length() > Settings.passwordMaxLength) {
player.sendMessage(m._("pass_len"));
return true;
}
try {
String hash;
if(Settings.getEnablePasswordVerifier) {
if (args[0].equals(args[1])) {
hash = PasswordSecurity.getHash(Settings.getPasswordHash, args[0], name);
} else {
player.sendMessage(m._("password_error"));
return true;
}
} else
hash = PasswordSecurity.getHash(Settings.getPasswordHash, args[0], name);
if (Settings.getMySQLColumnSalt.isEmpty())
{
auth = new PlayerAuth(name, hash, ip, new Date().getTime());
} else {
auth = new PlayerAuth(name, hash, PasswordSecurity.userSalt.get(name), ip, new Date().getTime());
}
if (!database.saveAuth(auth)) {
player.sendMessage(m._("error"));
return true;
}
PlayerCache.getInstance().addPlayer(auth);
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
if (limbo != null) {
player.setGameMode(GameMode.getByValue(limbo.getGameMode()));
if (Settings.isTeleportToSpawnEnabled) {
World world = player.getWorld();
Location loca = world.getSpawnLocation();
if (plugin.mv != null) {
try {
loca = plugin.mv.getMVWorldManager().getMVWorld(world).getSpawnLocation();
} catch (NullPointerException npe) {
} catch (ClassCastException cce) {
} catch (NoClassDefFoundError ncdfe) {
}
}
if (plugin.essentialsSpawn != null) {
loca = plugin.essentialsSpawn;
}
if (Spawn.getInstance().getLocation() != null)
loca = Spawn.getInstance().getLocation();
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
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());
}
}
sender.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
sender.getServer().getScheduler().cancelTask(limbo.getMessageTaskId());
LimboCache.getInstance().deleteLimboPlayer(name);
}
if(!Settings.getRegisteredGroup.isEmpty()){
Utils.getInstance().setGroup(player, Utils.groupType.REGISTERED);
}
player.sendMessage(m._("registered"));
if (!Settings.getmailAccount.isEmpty())
player.sendMessage(m._("add_email"));
this.isFirstTimeJoin = 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!"));
}
} catch (NoSuchAlgorithmException ex) {
ConsoleLogger.showError(ex.getMessage());
sender.sendMessage(m._("error"));
}
return true;
}
}

View File

@ -1,4 +1,4 @@
// Copyright 2007-2011 Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland
// Copyright 2007-2013 Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland
// www.source-code.biz, www.inventec.ch/chdh
//
// This module is multi-licensed and may be used under the terms
@ -37,7 +37,7 @@ public class MiniConnectionPoolManager {
private ConnectionPoolDataSource dataSource;
private int maxConnections;
private long timeoutMs = 70 * 1000L;
private long timeoutMs = 100 * 1000L;
private PrintWriter logWriter;
private Semaphore semaphore;
private LinkedList<PooledConnection> recycledConnections;
@ -66,7 +66,7 @@ public static class TimeoutException extends RuntimeException {
* the maximum number of connections.
*/
public MiniConnectionPoolManager (ConnectionPoolDataSource dataSource, int maxConnections) {
this(dataSource, maxConnections, 70); }
this(dataSource, maxConnections, 100); }
/**
* Constructs a MiniConnectionPoolManager object.

View File

@ -88,7 +88,7 @@ public class MySQLDataSource implements DataSource {
dataSource.setPort(Integer.parseInt(port));
dataSource.setUser(username);
dataSource.setPassword(password);
conPool = new MiniConnectionPoolManager(dataSource, 10);
conPool = new MiniConnectionPoolManager(dataSource, 20);
ConsoleLogger.info("Connection pool ready");
}

View File

@ -21,10 +21,6 @@ import uk.org.whoami.authme.settings.Settings;
@SuppressWarnings("unused")
public class SqliteDataSource implements DataSource {
private String host;
private String port;
private String username;
private String password;
private String database;
private String tableName;
private String columnName;
@ -33,7 +29,6 @@ public class SqliteDataSource implements DataSource {
private String columnLastLogin;
private String columnSalt;
private String columnGroup;
private int nonActivatedGroup;
private String lastlocX;
private String lastlocY;
private String lastlocZ;
@ -43,11 +38,7 @@ public class SqliteDataSource implements DataSource {
private Connection con;
public SqliteDataSource() throws ClassNotFoundException, SQLException {
this.host = Settings.getMySQLHost;
this.port = Settings.getMySQLPort;
this.username = Settings.getMySQLUsername;
this.password = Settings.getMySQLPassword;
this.database = Settings.getMySQLDatabase;
this.database = Settings.getMySQLDatabase;
this.tableName = Settings.getMySQLTablename;
this.columnName = Settings.getMySQLColumnName;
this.columnPassword = Settings.getMySQLColumnPassword;
@ -59,7 +50,6 @@ public class SqliteDataSource implements DataSource {
this.lastlocY = Settings.getMySQLlastlocY;
this.lastlocZ = Settings.getMySQLlastlocZ;
this.lastlocWorld = Settings.getMySQLlastlocWorld;
this.nonActivatedGroup = Settings.getNonActivatedGroup;
this.columnEmail = Settings.getMySQLColumnEmail;
this.columnID = Settings.getMySQLColumnId;

View File

@ -21,9 +21,7 @@ import org.getspout.spoutapi.player.SpoutPlayer;
import uk.org.whoami.authme.AuthMe;
import uk.org.whoami.authme.gui.Clickable;
import uk.org.whoami.authme.gui.CustomButton;
import uk.org.whoami.authme.settings.Settings;
import uk.org.whoami.authme.settings.SpoutCfg;
import uk.org.whoami.authme.threads.LoginThread;
public class LoginScreen extends GenericPopup implements Clickable{
@ -121,12 +119,7 @@ public class LoginScreen extends GenericPopup implements Clickable{
if (event.isCancelled() || event == null || event.getPlayer() == null) return;
if (b.equals(loginBtn))
{
if (Settings.useMultiThreading) {
Thread mT = new LoginThread(plugin.database, plugin, player, passBox.getText());
mT.run();
} else {
plugin.management.performLogin(player, passBox.getText(), false);
}
plugin.management.performLogin(player, passBox.getText(), false);
}else if(b.equals(exitBtn))
{
event.getPlayer().kickPlayer(exitMsg);

View File

@ -28,6 +28,7 @@ import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@ -162,7 +163,11 @@ public class AuthMePlayerListener implements Listener {
if (!Settings.isForcedRegistrationEnabled) {
return;
}
player.sendMessage(m._("reg_msg"));
if (Settings.emailRegistration) {
player.sendMessage(m._("reg_email_msg"));
} else {
player.sendMessage(m._("reg_msg"));
}
}
} else {
Bukkit.getScheduler().runTask(plugin, new Runnable()
@ -173,7 +178,11 @@ public class AuthMePlayerListener implements Listener {
player.sendMessage(m._("login_msg"));
} else {
if (Settings.isForcedRegistrationEnabled) {
player.sendMessage(m._("reg_msg"));
if (Settings.emailRegistration) {
player.sendMessage(m._("reg_email_msg"));
} else {
player.sendMessage(m._("reg_msg"));
}
}
}
}});
@ -211,7 +220,11 @@ public class AuthMePlayerListener implements Listener {
if (!Settings.isForcedRegistrationEnabled) {
return;
}
player.sendMessage(m._("reg_msg"));
if (Settings.emailRegistration) {
player.sendMessage(m._("reg_email_msg"));
} else {
player.sendMessage(m._("reg_msg"));
}
}
} else {
Bukkit.getScheduler().runTask(plugin, new Runnable()
@ -222,7 +235,11 @@ public class AuthMePlayerListener implements Listener {
player.sendMessage(m._("login_msg"));
} else {
if (Settings.isForcedRegistrationEnabled) {
player.sendMessage(m._("reg_msg"));
if (Settings.emailRegistration) {
player.sendMessage(m._("reg_email_msg"));
} else {
player.sendMessage(m._("reg_msg"));
}
}
}
}});
@ -261,7 +278,11 @@ public class AuthMePlayerListener implements Listener {
if (!Settings.isForcedRegistrationEnabled) {
return;
}
player.sendMessage(m._("reg_msg"));
if (Settings.emailRegistration) {
player.sendMessage(m._("reg_email_msg"));
} else {
player.sendMessage(m._("reg_msg"));
}
}
} else {
Bukkit.getScheduler().runTask(plugin, new Runnable()
@ -272,7 +293,11 @@ public class AuthMePlayerListener implements Listener {
player.sendMessage(m._("login_msg"));
} else {
if (Settings.isForcedRegistrationEnabled) {
player.sendMessage(m._("reg_msg"));
if (Settings.emailRegistration) {
player.sendMessage(m._("reg_email_msg"));
} else {
player.sendMessage(m._("reg_msg"));
}
}
}
}});
@ -310,7 +335,11 @@ public class AuthMePlayerListener implements Listener {
if (!Settings.isForcedRegistrationEnabled) {
return;
}
player.sendMessage(m._("reg_msg"));
if (Settings.emailRegistration) {
player.sendMessage(m._("reg_email_msg"));
} else {
player.sendMessage(m._("reg_msg"));
}
}
} else {
Bukkit.getScheduler().runTask(plugin, new Runnable()
@ -321,7 +350,11 @@ public class AuthMePlayerListener implements Listener {
player.sendMessage(m._("login_msg"));
} else {
if (Settings.isForcedRegistrationEnabled) {
player.sendMessage(m._("reg_msg"));
if (Settings.emailRegistration) {
player.sendMessage(m._("reg_email_msg"));
} else {
player.sendMessage(m._("reg_msg"));
}
}
}
}});
@ -359,7 +392,11 @@ public class AuthMePlayerListener implements Listener {
if (!Settings.isForcedRegistrationEnabled) {
return;
}
player.sendMessage(m._("reg_msg"));
if (Settings.emailRegistration) {
player.sendMessage(m._("reg_email_msg"));
} else {
player.sendMessage(m._("reg_msg"));
}
}
} else {
Bukkit.getScheduler().runTask(plugin, new Runnable()
@ -370,7 +407,11 @@ public class AuthMePlayerListener implements Listener {
player.sendMessage(m._("login_msg"));
} else {
if (Settings.isForcedRegistrationEnabled) {
player.sendMessage(m._("reg_msg"));
if (Settings.emailRegistration) {
player.sendMessage(m._("reg_email_msg"));
} else {
player.sendMessage(m._("reg_msg"));
}
}
}
}});
@ -408,7 +449,11 @@ public class AuthMePlayerListener implements Listener {
if (!Settings.isForcedRegistrationEnabled) {
return;
}
player.sendMessage(m._("reg_msg"));
if (Settings.emailRegistration) {
player.sendMessage(m._("reg_email_msg"));
} else {
player.sendMessage(m._("reg_msg"));
}
}
} else {
Bukkit.getScheduler().runTask(plugin, new Runnable()
@ -419,7 +464,11 @@ public class AuthMePlayerListener implements Listener {
player.sendMessage(m._("login_msg"));
} else {
if (Settings.isForcedRegistrationEnabled) {
player.sendMessage(m._("reg_msg"));
if (Settings.emailRegistration) {
player.sendMessage(m._("reg_email_msg"));
} else {
player.sendMessage(m._("reg_msg"));
}
}
}
}});
@ -576,22 +625,27 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerLowestJoin(PlayerJoinEvent event) {
if (event.getPlayer() == null) return;
Player player = event.getPlayer();
if (event.getPlayer() == null) return;
final Player player = event.getPlayer();
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
return;
}
if (Settings.bungee) {
ByteArrayOutputStream b = new ByteArrayOutputStream();
final ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try {
out.writeUTF("IP");
} catch (IOException e) {
}
player.sendPluginMessage(this.plugin, "BungeeCord", b.toByteArray());
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
@Override
public void run() {
player.sendPluginMessage(plugin, "BungeeCord", b.toByteArray());
}
});
}
}
@ -705,8 +759,6 @@ public class AuthMePlayerListener implements Listener {
} catch (NullPointerException ex) {
}
}
if(player.isOp())
player.setOp(false);
if (Settings.isTeleportToSpawnEnabled || (Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds.contains(player.getWorld().getName()))) {
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
plugin.getServer().getPluginManager().callEvent(tpEvent);
@ -717,7 +769,12 @@ public class AuthMePlayerListener implements Listener {
player.teleport(tpEvent.getTo());
}
}
String msg = data.isAuthAvailable(name) ? m._("login_msg") : m._("reg_msg");
String msg = "";
if(Settings.emailRegistration) {
msg = data.isAuthAvailable(name) ? m._("login_msg") : m._("reg_email_msg");
} else {
msg = data.isAuthAvailable(name) ? m._("login_msg") : m._("reg_msg");
}
int time = Settings.getRegistrationTimeout * 20;
int msgInterval = Settings.getWarnMessageInterval;
if (time != 0) {
@ -728,16 +785,27 @@ public class AuthMePlayerListener implements Listener {
}
if(!LimboCache.getInstance().hasLimboPlayer(name))
LimboCache.getInstance().addLimboPlayer(player);
if(player.isOp())
player.setOp(false);
BukkitTask msgT = sched.runTask(plugin, new MessageTask(plugin, name, msg, msgInterval));
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT.getTaskId());
if (Settings.isForceSurvivalModeEnabled)
sched.runTask(plugin, new Runnable() {
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
public void run() {
e.getPlayer().setGameMode(GameMode.SURVIVAL);
}
});
placePlayerSafely(player, spawnLoc);
}
private void placePlayerSafely(Player player, Location spawnLoc) {
Block b = player.getLocation().getBlock();
if (b.getType() == Material.PORTAL || b.getType() == Material.ENDER_PORTAL) {
player.sendMessage(m._("unsafe_spawn"));
player.teleport(spawnLoc);
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event) {
if (event.getPlayer() == null) {

View File

@ -1,5 +1,9 @@
package uk.org.whoami.authme.plugin.manager;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.IOException;
import org.bukkit.entity.Player;
import org.bukkit.plugin.messaging.PluginMessageListener;
@ -17,8 +21,14 @@ public class BungeeCordMessage implements PluginMessageListener {
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
ConsoleLogger.info("PluginMessage send to " + player.getName() + " , the message was : " + message.toString());
plugin.realIp.put(player.getName().toLowerCase(), message.toString());
try {
final DataInputStream in = new DataInputStream(new ByteArrayInputStream(message));
if (in.readUTF().equals("IP")) { //We need only the IP channel
ConsoleLogger.info("PluginMessage send to " + player.getName() + " , the message was : " + message.toString());
plugin.realIp.put(player.getName().toLowerCase(), in.readUTF()); //Put the IP (only the ip not the port) in the hashmap
}
} catch (IOException ex) {
}
}
}

View File

@ -58,6 +58,14 @@ public class PasswordSecurity {
byte[] digest = sha256.digest();
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
}
private static String getSHA512(String message) throws NoSuchAlgorithmException {
MessageDigest sha512 = MessageDigest.getInstance("SHA-512");
sha512.reset();
sha512.update(message.getBytes());
byte[] digest = sha512.digest();
return String.format("%0" + (digest.length << 1) + "x", new BigInteger(1,digest));
}
public static String getWhirlpool(String message) {
Whirlpool w = new Whirlpool();
@ -93,9 +101,8 @@ public class PasswordSecurity {
private static String getBCrypt(String message, String salt) throws NoSuchAlgorithmException {
return BCrypt.hashpw(message, salt);
}
private static String getWBB3(String message, String salt) throws NoSuchAlgorithmException {
return getSHA1(salt.concat(getSHA1(salt.concat(getSHA1(message)))));
}
@ -215,6 +222,8 @@ public class PasswordSecurity {
userSalt.put(name, saltwbb);
}
return getWBB3(password, saltwbb);
case SHA512:
return getSHA512(password);
default:
throw new NoSuchAlgorithmException("Unknown hash algorithm");
}
@ -262,17 +271,20 @@ public class PasswordSecurity {
String saltj = hash.split(":")[1];
return hash.equals(getMD5(password + saltj) + ":" + saltj);
}
if(Settings.getPasswordHash == HashAlgorithm.SHA512) {
return hash.equals(getSHA512(password));
}
// PlainText Password
if(hash.length() < 32 ) {
if(Settings.getPasswordHash == HashAlgorithm.PLAINTEXT) {
return hash.equals(password);
}
if (hash.length() == 32) {
if (Settings.getPasswordHash == HashAlgorithm.MD5) {
return hash.equals(getMD5(password));
}
if (hash.length() == 40) {
if (Settings.getPasswordHash == HashAlgorithm.SHA1) {
return hash.equals(getSHA1(password));
}
if (hash.length() == 140) {
if (Settings.getPasswordHash == HashAlgorithm.XAUTH) {
int saltPos = (password.length() >= hash.length() ? hash.length() - 1 : password.length());
String salt = hash.substring(saltPos, saltPos + 12);
return hash.equals(getXAuth(password, salt));
@ -327,7 +339,7 @@ public class PasswordSecurity {
public enum HashAlgorithm {
MD5, SHA1, SHA256, WHIRLPOOL, XAUTH, MD5VB, PHPBB, PLAINTEXT, MYBB, IPB3, PHPFUSION, SMF, XFSHA1,
XFSHA256, SALTED2MD5, JOOMLA, BCRYPT, WBB3
XFSHA256, SALTED2MD5, JOOMLA, BCRYPT, WBB3, SHA512
}
}

View File

@ -42,6 +42,7 @@ public class Messages extends CustomConfiguration {
this.set("valid_session", "&cSession login");
this.set("login_msg", "&cPlease login with \"/login password\"");
this.set("reg_msg", "&cPlease register with \"/register password ConfirmPassword\"");
this.set("reg_email_msg", "&cPlease register with \"/register <email> <confirmEmail>\"");
this.set("timeout", "&fLogin Timeout");
this.set("wrong_pwd", "&cWrong password");
this.set("logout", "&cSuccessful logout");

View File

@ -30,7 +30,7 @@ public class SpoutCfg extends CustomConfiguration{
add("Sample text");
add("Change this at spout.yml");
add("--- AuthMe Reloaded by ---");
add("d4rkwarriors and Xephi59");
add("Xephi59");
}});
}

View File

@ -0,0 +1,500 @@
package uk.org.whoami.authme.threads;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import uk.org.whoami.authme.AuthMe;
import uk.org.whoami.authme.ConsoleLogger;
import uk.org.whoami.authme.cache.auth.PlayerAuth;
import uk.org.whoami.authme.datasource.DataSource;
import uk.org.whoami.authme.settings.Settings;
public class FlatFileThread extends Thread implements DataSource {
/* file layout:
*
* PLAYERNAME:HASHSUM:IP:LOGININMILLIESECONDS:COORDS
*
* Old but compatible:
* PLAYERNAME:HASHSUM:IP
* PLAYERNAME:HASHSUM
*
*/
private File source;
public void run() {
source = new File(Settings.AUTH_FILE);
try {
source.createNewFile();
} catch (IOException e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
ConsoleLogger.showError("Can't use FLAT FILE... SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
if (!Settings.isStopEnabled)
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
return;
}
}
@Override
public synchronized boolean isAuthAvailable(String user) {
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(source));
String line;
while ((line = br.readLine()) != null) {
String[] args = line.split(":");
if (args.length > 1 && args[0].equals(user)) {
return true;
}
}
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
if (br != null) {
try {
br.close();
} catch (IOException ex) {
}
}
}
return false;
}
@Override
public synchronized boolean saveAuth(PlayerAuth auth) {
if (isAuthAvailable(auth.getNickname())) {
return false;
}
BufferedWriter bw = null;
try {
if( auth.getQuitLocY() == 0 ) {
bw = new BufferedWriter(new FileWriter(source, true));
bw.write(auth.getNickname() + ":" + auth.getHash() + ":" + auth.getIp() + ":" + auth.getLastLogin() + "\n");
} else {
bw = new BufferedWriter(new FileWriter(source, true));
bw.write(auth.getNickname() + ":" + auth.getHash() + ":" + auth.getIp() + ":" + auth.getLastLogin() + ":" + auth.getQuitLocX() + ":" + auth.getQuitLocY() + ":" + auth.getQuitLocZ() + ":" + auth.getWorld() + "\n");
}
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
if (bw != null) {
try {
bw.close();
} catch (IOException ex) {
}
}
}
return true;
}
@Override
public synchronized boolean updatePassword(PlayerAuth auth) {
if (!isAuthAvailable(auth.getNickname())) {
return false;
}
PlayerAuth newAuth = null;
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(source));
String line = "";
while ((line = br.readLine()) != null) {
String[] args = line.split(":");
if (args[0].equals(auth.getNickname())) {
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]));
break;
}
}
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
if (br != null) {
try {
br.close();
} catch (IOException ex) {
}
}
}
removeAuth(auth.getNickname());
saveAuth(newAuth);
return true;
}
@Override
public boolean updateSession(PlayerAuth auth) {
if (!isAuthAvailable(auth.getNickname())) {
return false;
}
PlayerAuth newAuth = null;
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(source));
String line = "";
while ((line = br.readLine()) != null) {
String[] args = line.split(":");
if (args[0].equals(auth.getNickname())) {
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin());
break;
}
}
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
if (br != null) {
try {
br.close();
} catch (IOException ex) {
}
}
}
removeAuth(auth.getNickname());
saveAuth(newAuth);
return true;
}
@Override
public boolean updateQuitLoc(PlayerAuth auth) {
if (!isAuthAvailable(auth.getNickname())) {
return false;
}
PlayerAuth newAuth = null;
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(source));
String line = "";
while ((line = br.readLine()) != null) {
String[] args = line.split(":");
if (args[0].equals(auth.getNickname())) {
newAuth = new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld());
break;
}
}
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
if (br != null) {
try {
br.close();
} catch (IOException ex) {
}
}
}
removeAuth(auth.getNickname());
saveAuth(newAuth);
return true;
}
@Override
public int getIps(String ip) {
BufferedReader br = null;
int countIp = 0;
try {
br = new BufferedReader(new FileReader(source));
String line;
while ((line = br.readLine()) != null) {
String[] args = line.split(":");
if (args.length > 3 && args[2].equals(ip)) {
countIp++;
}
}
return countIp;
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
return 0;
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
return 0;
} finally {
if (br != null) {
try {
br.close();
} catch (IOException ex) {
}
}
}
}
@Override
public int purgeDatabase(long until) {
BufferedReader br = null;
BufferedWriter bw = null;
ArrayList<String> lines = new ArrayList<String>();
int cleared = 0;
try {
br = new BufferedReader(new FileReader(source));
String line;
while ((line = br.readLine()) != null) {
String[] args = line.split(":");
if (args.length == 4) {
if (Long.parseLong(args[3]) >= until) {
lines.add(line);
continue;
}
}
cleared++;
}
bw = new BufferedWriter(new FileWriter(source));
for (String l : lines) {
bw.write(l + "\n");
}
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
return cleared;
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
return cleared;
} finally {
if (br != null) {
try {
br.close();
} catch (IOException ex) {
}
}
if (bw != null) {
try {
bw.close();
} catch (IOException ex) {
}
}
}
return cleared;
}
@Override
public synchronized boolean removeAuth(String user) {
if (!isAuthAvailable(user)) {
return false;
}
BufferedReader br = null;
BufferedWriter bw = null;
ArrayList<String> lines = new ArrayList<String>();
try {
br = new BufferedReader(new FileReader(source));
String line;
while ((line = br.readLine()) != null) {
String[] args = line.split(":");
if (args.length > 1 && !args[0].equals(user)) {
lines.add(line);
}
}
bw = new BufferedWriter(new FileWriter(source));
for (String l : lines) {
bw.write(l + "\n");
}
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
if (br != null) {
try {
br.close();
} catch (IOException ex) {
}
}
if (bw != null) {
try {
bw.close();
} catch (IOException ex) {
}
}
}
return true;
}
@Override
public synchronized PlayerAuth getAuth(String user) {
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(source));
String line;
while ((line = br.readLine()) != null) {
String[] args = line.split(":");
if (args[0].equals(user)) {
switch (args.length) {
case 2:
return new PlayerAuth(args[0], args[1], "198.18.0.1", 0);
case 3:
return new PlayerAuth(args[0], args[1], args[2], 0);
case 4:
return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]));
case 7:
return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), "unavailableworld");
case 8:
return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), args[7]);
}
}
}
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
return null;
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
return null;
} finally {
if (br != null) {
try {
br.close();
} catch (IOException ex) {
}
}
}
return null;
}
@Override
public synchronized void close() {
}
@Override
public void reload() {
}
@Override
public boolean updateEmail(PlayerAuth auth) {
return false;
}
@Override
public boolean updateSalt(PlayerAuth auth) {
return false;
}
@Override
public List<String> getAllAuthsByName(PlayerAuth auth) {
BufferedReader br = null;
List<String> countIp = new ArrayList<String>();
try {
br = new BufferedReader(new FileReader(source));
String line;
while ((line = br.readLine()) != null) {
String[] args = line.split(":");
if (args.length > 3 && args[2].equals(auth.getIp())) {
countIp.add(args[0]);
}
}
return countIp;
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
return new ArrayList<String>();
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
return new ArrayList<String>();
} finally {
if (br != null) {
try {
br.close();
} catch (IOException ex) {
}
}
}
}
@Override
public List<String> getAllAuthsByIp(String ip) {
BufferedReader br = null;
List<String> countIp = new ArrayList<String>();
try {
br = new BufferedReader(new FileReader(source));
String line;
while ((line = br.readLine()) != null) {
String[] args = line.split(":");
if (args.length > 3 && args[2].equals(ip)) {
countIp.add(args[0]);
}
}
return countIp;
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
return new ArrayList<String>();
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
return new ArrayList<String>();
} finally {
if (br != null) {
try {
br.close();
} catch (IOException ex) {
}
}
}
}
@Override
public List<String> getAllAuthsByEmail(String email) {
return new ArrayList<String>();
}
@Override
public void purgeBanned(List<String> banned) {
BufferedReader br = null;
BufferedWriter bw = null;
ArrayList<String> lines = new ArrayList<String>();
try {
br = new BufferedReader(new FileReader(source));
String line;
while ((line = br.readLine()) != null) {
String[] args = line.split(":");
try {
if (banned.contains(args[0])) {
lines.add(line);
}
} catch (NullPointerException npe) {}
catch (ArrayIndexOutOfBoundsException aioobe) {}
}
bw = new BufferedWriter(new FileWriter(source));
for (String l : lines) {
bw.write(l + "\n");
}
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
return;
} catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage());
return;
} finally {
if (br != null) {
try {
br.close();
} catch (IOException ex) {
}
}
if (bw != null) {
try {
bw.close();
} catch (IOException ex) {
}
}
}
return;
}
}

View File

@ -1,639 +0,0 @@
package uk.org.whoami.authme.threads;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import java.util.List;
import me.muizers.Notifications.Notification;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import uk.org.whoami.authme.AuthMe;
import uk.org.whoami.authme.ConsoleLogger;
import uk.org.whoami.authme.Utils;
import uk.org.whoami.authme.api.API;
import uk.org.whoami.authme.cache.auth.PlayerAuth;
import uk.org.whoami.authme.cache.auth.PlayerCache;
import uk.org.whoami.authme.cache.backup.FileCache;
import uk.org.whoami.authme.cache.limbo.LimboCache;
import uk.org.whoami.authme.cache.limbo.LimboPlayer;
import uk.org.whoami.authme.datasource.DataSource;
import uk.org.whoami.authme.events.AuthMeTeleportEvent;
import uk.org.whoami.authme.events.LoginEvent;
import uk.org.whoami.authme.events.RestoreInventoryEvent;
import uk.org.whoami.authme.events.SpawnTeleportEvent;
import uk.org.whoami.authme.listener.AuthMePlayerListener;
import uk.org.whoami.authme.security.PasswordSecurity;
import uk.org.whoami.authme.security.RandomString;
import uk.org.whoami.authme.settings.Messages;
import uk.org.whoami.authme.settings.PlayersLogs;
import uk.org.whoami.authme.settings.Settings;
import uk.org.whoami.authme.settings.Spawn;
public class LoginThread extends Thread {
private Messages m = Messages.getInstance();
private PlayersLogs pllog = PlayersLogs.getInstance();
private Utils utils = Utils.getInstance();
private FileCache playerCache = new FileCache();
private DataSource database;
public AuthMe plugin;
private boolean passpartu = false;
public RandomString rdm = new RandomString(Settings.captchaLength);
public PluginManager pm;
private Player player;
private String password;
public LoginThread(DataSource database, AuthMe plugin, Player player,
String password) {
this.database = database;
this.plugin = plugin;
this.pm = plugin.getServer().getPluginManager();
this.player = player;
this.password = password;
}
public LoginThread(DataSource database, boolean passpartu, AuthMe plugin,
Player player, String password) {
this.database = database;
this.passpartu = passpartu;
this.plugin = plugin;
this.pm = plugin.getServer().getPluginManager();
this.player = player;
this.password = password;
}
public void run() {
final String name = player.getName().toLowerCase();
String ip = player.getAddress().getAddress().getHostAddress();
if (Settings.bungee) {
if (plugin.realIp.containsKey(name))
ip = plugin.realIp.get(name);
}
World world = player.getWorld();
Location spawnLoc = world.getSpawnLocation();
if (plugin.mv != null) {
try {
spawnLoc = plugin.mv.getMVWorldManager().getMVWorld(world)
.getSpawnLocation();
} catch (NullPointerException npe) {
} catch (ClassCastException cce) {
} catch (NoClassDefFoundError ncdfe) {
}
}
if (plugin.essentialsSpawn != null) {
spawnLoc = plugin.essentialsSpawn;
}
if (Spawn.getInstance().getLocation() != null)
spawnLoc = Spawn.getInstance().getLocation();
if (PlayerCache.getInstance().isAuthenticated(name)) {
player.sendMessage(m._("logged_in"));
this.interrupt();
return;
}
if (!database.isAuthAvailable(player.getName().toLowerCase())) {
player.sendMessage(m._("user_unknown"));
this.interrupt();
return;
}
PlayerAuth pAuth = database.getAuth(name);
if (pAuth == null) {
player.sendMessage(m._("user_unknown"));
this.interrupt();
return;
}
if (!Settings.getMySQLColumnGroup.isEmpty()
&& pAuth.getGroupId() == Settings.getNonActivatedGroup) {
player.sendMessage(m._("vb_nonActiv"));
this.interrupt();
return;
}
String hash = pAuth.getHash();
String email = pAuth.getEmail();
try {
if (!passpartu) {
if (Settings.useCaptcha) {
if (!plugin.captcha.containsKey(name)) {
plugin.captcha.put(name, 1);
} else {
int i = plugin.captcha.get(name) + 1;
plugin.captcha.remove(name);
plugin.captcha.put(name, i);
}
if (plugin.captcha.containsKey(name)
&& plugin.captcha.get(name) > Settings.maxLoginTry) {
player.sendMessage(m._("need_captcha"));
plugin.cap.put(name, rdm.nextString());
player.sendMessage("Type : /captcha "
+ plugin.cap.get(name));
this.interrupt();
return;
} else if (plugin.captcha.containsKey(name)
&& plugin.captcha.get(name) > Settings.maxLoginTry) {
try {
plugin.captcha.remove(name);
plugin.cap.remove(name);
} catch (NullPointerException npe) {
}
}
}
if (PasswordSecurity.comparePasswordWithHash(password, hash,
name)) {
PlayerAuth auth = new PlayerAuth(name, hash, ip,
new Date().getTime(), email);
database.updateSession(auth);
PlayerCache.getInstance().addPlayer(auth);
final LimboPlayer limbo = LimboCache.getInstance()
.getLimboPlayer(name);
PlayerAuth getAuth = database.getAuth(name);
if (limbo != null) {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
player.setOp(limbo.getOperator());
}
});
utils.addNormal(player, limbo.getGroup());
if ((Settings.isTeleportToSpawnEnabled)
&& (!Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds
.contains(player.getWorld().getName()))) {
if ((Settings.isSaveQuitLocationEnabled)
&& (getAuth.getQuitLocY() != 0)) {
utils.packCoords(getAuth.getQuitLocX(),
getAuth.getQuitLocY(),
getAuth.getQuitLocZ(),
getAuth.getWorld(), player);
} else {
Bukkit.getScheduler().runTask(plugin,
new Runnable() {
@Override
public void run() {
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(
player, limbo.getLoc());
pm.callEvent(tpEvent);
Location fLoc = tpEvent.getTo();
if (!tpEvent.isCancelled()) {
if (!fLoc.getChunk()
.isLoaded()) {
fLoc.getChunk().load();
}
player.teleport(fLoc);
}
}
});
}
} else if (Settings.isForceSpawnLocOnJoinEnabled
&& Settings.getForcedWorlds.contains(player
.getWorld().getName())) {
final Location spawnL = spawnLoc;
Bukkit.getScheduler().runTask(plugin,
new Runnable() {
@Override
public void run() {
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(
player, player
.getLocation(),
spawnL, true);
pm.callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
Location fLoc = tpEvent.getTo();
if (!fLoc.getChunk().isLoaded()) {
fLoc.getChunk().load();
}
player.teleport(fLoc);
}
}
});
} else if ((Settings.isSaveQuitLocationEnabled)
&& (getAuth.getQuitLocY() != 0)) {
utils.packCoords(getAuth.getQuitLocX(),
getAuth.getQuitLocY(),
getAuth.getQuitLocZ(), getAuth.getWorld(),
player);
} else {
Bukkit.getScheduler().runTask(plugin,
new Runnable() {
@Override
public void run() {
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(
player, limbo.getLoc());
pm.callEvent(tpEvent);
Location fLoc = tpEvent.getTo();
if (!tpEvent.isCancelled()) {
if (!fLoc.getChunk().isLoaded()) {
fLoc.getChunk().load();
}
player.teleport(fLoc);
}
}
});
}
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
player.setGameMode(GameMode.getByValue(limbo
.getGameMode()));
}
});
if (Settings.protectInventoryBeforeLogInEnabled
&& player.hasPlayedBefore()) {
Bukkit.getScheduler().runTask(plugin,
new Runnable() {
@Override
public void run() {
RestoreInventoryEvent event = new RestoreInventoryEvent(
player, limbo
.getInventory(),
limbo.getArmour());
Bukkit.getServer()
.getPluginManager()
.callEvent(event);
if (!event.isCancelled()) {
API.setPlayerInventory(player,
limbo.getInventory(),
limbo.getArmour());
}
}
});
}
player.getServer().getScheduler()
.cancelTask(limbo.getTimeoutTaskId());
player.getServer().getScheduler()
.cancelTask(limbo.getMessageTaskId());
LimboCache.getInstance().deleteLimboPlayer(name);
if (playerCache.doesCacheExist(name)) {
playerCache.removeCache(name);
}
}
/*
* Little Work Around under Registration Group Switching for
* admins that add Registration thru a web Scripts.
*/
if (Settings.isPermissionCheckEnabled
&& AuthMe.permission.playerInGroup(player,
Settings.unRegisteredGroup)
&& !Settings.unRegisteredGroup.isEmpty()) {
AuthMe.permission.playerRemoveGroup(player.getWorld(),
player.getName(), Settings.unRegisteredGroup);
AuthMe.permission.playerAddGroup(player.getWorld(),
player.getName(), Settings.getRegisteredGroup);
}
try {
if (!PlayersLogs.players.contains(player.getName()))
PlayersLogs.players.add(player.getName());
pllog.save();
} catch (NullPointerException ex) {
}
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
Bukkit.getServer().getPluginManager()
.callEvent(new LoginEvent(player, true));
}
});
if (Settings.useCaptcha) {
if (plugin.captcha.containsKey(name)) {
plugin.captcha.remove(name);
}
if (plugin.cap.containsKey(name)) {
plugin.cap.containsKey(name);
}
}
player.sendMessage(m._("login"));
displayOtherAccounts(auth);
if (!Settings.noConsoleSpam)
ConsoleLogger.info(player.getName() + " logged in!");
if (plugin.notifications != null) {
plugin.notifications
.showNotification(new Notification("[AuthMe] "
+ player.getName() + " logged in!"));
}
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
player.saveData();
}
});
this.interrupt();
return;
} else {
if (!Settings.noConsoleSpam)
ConsoleLogger.info(player.getName()
+ " used the wrong password");
if (Settings.isKickOnWrongPasswordEnabled) {
try {
final int gm = AuthMePlayerListener.gameMode
.get(name);
Bukkit.getScheduler().runTask(plugin,
new Runnable() {
@Override
public void run() {
player.setGameMode(GameMode
.getByValue(gm));
}
});
} catch (NullPointerException npe) {
}
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
player.kickPlayer(m._("wrong_pwd"));
}
});
} else {
player.sendMessage(m._("wrong_pwd"));
this.interrupt();
return;
}
}
} else {
// need for bypass password check if passpartu command is
// enabled
PlayerAuth auth = new PlayerAuth(name, hash, ip,
new Date().getTime(), email);
database.updateSession(auth);
PlayerCache.getInstance().addPlayer(auth);
final LimboPlayer limbo = LimboCache.getInstance()
.getLimboPlayer(name);
if (limbo != null) {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
player.setOp(limbo.getOperator());
}
});
utils.addNormal(player, limbo.getGroup());
if ((Settings.isTeleportToSpawnEnabled)
&& (!Settings.isForceSpawnLocOnJoinEnabled && Settings.getForcedWorlds
.contains(player.getWorld().getName()))) {
if ((Settings.isSaveQuitLocationEnabled)
&& (database.getAuth(name).getQuitLocY() != 0)) {
String worldname = database.getAuth(name)
.getWorld();
World theWorld;
if (worldname.equals("unavailableworld")) {
theWorld = player.getWorld();
} else {
theWorld = Bukkit.getWorld(worldname);
}
if (theWorld == null)
theWorld = player.getWorld();
final Location quitLoc = new Location(
theWorld,
database.getAuth(name).getQuitLocX() + 0.5D,
database.getAuth(name).getQuitLocY() + 0.5D,
database.getAuth(name).getQuitLocZ() + 0.5D);
Bukkit.getScheduler().runTask(plugin,
new Runnable() {
@Override
public void run() {
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(
player, quitLoc);
pm.callEvent(tpEvent);
Location fLoc = tpEvent.getTo();
if (!tpEvent.isCancelled()) {
if (!fLoc.getChunk().isLoaded()) {
fLoc.getChunk().load();
}
player.teleport(fLoc);
}
}
});
} else {
Bukkit.getScheduler().runTask(plugin,
new Runnable() {
@Override
public void run() {
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(
player, limbo.getLoc());
pm.callEvent(tpEvent);
Location fLoc = tpEvent.getTo();
if (!tpEvent.isCancelled()) {
if (!fLoc.getChunk().isLoaded()) {
fLoc.getChunk().load();
}
player.teleport(fLoc);
}
}
});
}
} else if (Settings.isForceSpawnLocOnJoinEnabled
&& Settings.getForcedWorlds.contains(player
.getWorld().getName())) {
final Location spawnL = spawnLoc;
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(
player, player.getLocation(), spawnL,
true);
pm.callEvent(tpEvent);
if (!tpEvent.isCancelled()) {
Location fLoc = tpEvent.getTo();
if (!fLoc.getChunk().isLoaded()) {
fLoc.getChunk().load();
}
player.teleport(fLoc);
}
}
});
} else if ((Settings.isSaveQuitLocationEnabled)
&& (database.getAuth(name).getQuitLocY() != 0)) {
String worldname = database.getAuth(name).getWorld();
World theWorld;
if (worldname.equals("unavailableworld")) {
theWorld = player.getWorld();
} else {
theWorld = Bukkit.getWorld(worldname);
}
if (theWorld == null)
theWorld = player.getWorld();
final Location quitLoc = new Location(theWorld,
database.getAuth(name).getQuitLocX() + 0.5D,
database.getAuth(name).getQuitLocY() + 0.5D,
database.getAuth(name).getQuitLocZ() + 0.5D);
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(
player, quitLoc);
pm.callEvent(tpEvent);
Location fLoc = tpEvent.getTo();
if (!tpEvent.isCancelled()) {
if (!fLoc.getChunk().isLoaded()) {
fLoc.getChunk().load();
}
player.teleport(fLoc);
}
}
});
} else {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(
player, limbo.getLoc());
pm.callEvent(tpEvent);
Location fLoc = tpEvent.getTo();
if (!tpEvent.isCancelled()) {
if (!fLoc.getChunk().isLoaded()) {
fLoc.getChunk().load();
}
player.teleport(fLoc);
}
}
});
}
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
player.setGameMode(GameMode.getByValue(limbo
.getGameMode()));
}
});
if (Settings.protectInventoryBeforeLogInEnabled
&& player.hasPlayedBefore()) {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
RestoreInventoryEvent event = new RestoreInventoryEvent(
player, limbo.getInventory(), limbo
.getArmour());
Bukkit.getServer().getPluginManager()
.callEvent(event);
if (!event.isCancelled()) {
API.setPlayerInventory(player,
limbo.getInventory(),
limbo.getArmour());
}
}
});
}
player.getServer().getScheduler()
.cancelTask(limbo.getTimeoutTaskId());
player.getServer().getScheduler()
.cancelTask(limbo.getMessageTaskId());
LimboCache.getInstance().deleteLimboPlayer(name);
if (playerCache.doesCacheExist(name)) {
playerCache.removeCache(name);
}
}
/*
* Little Work Around under Registration Group Switching for
* admins that add Registration thru a web Scripts.
*/
if (Settings.isPermissionCheckEnabled
&& AuthMe.permission.playerInGroup(player,
Settings.unRegisteredGroup)
&& !Settings.unRegisteredGroup.isEmpty()) {
AuthMe.permission.playerRemoveGroup(player.getWorld(),
player.getName(), Settings.unRegisteredGroup);
AuthMe.permission.playerAddGroup(player.getWorld(),
player.getName(), Settings.getRegisteredGroup);
}
try {
if (!PlayersLogs.players.contains(player.getName()))
PlayersLogs.players.add(player.getName());
pllog.save();
} catch (NullPointerException ex) {
}
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
Bukkit.getServer().getPluginManager()
.callEvent(new LoginEvent(player, true));
}
});
if (Settings.useCaptcha) {
if (plugin.captcha.containsKey(name)) {
plugin.captcha.remove(name);
}
if (plugin.cap.containsKey(name)) {
plugin.cap.containsKey(name);
}
}
player.sendMessage(m._("login"));
displayOtherAccounts(auth);
if (!Settings.noConsoleSpam)
ConsoleLogger.info(player.getName() + " logged in!");
if (plugin.notifications != null) {
plugin.notifications.showNotification(new Notification(
"[AuthMe] " + player.getName() + " logged in!"));
}
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
player.saveData();
}
});
this.interrupt();
}
} catch (NoSuchAlgorithmException ex) {
ConsoleLogger.showError(ex.getMessage());
player.sendMessage(m._("error"));
this.interrupt();
return;
}
this.interrupt();
return;
}
private void displayOtherAccounts(PlayerAuth auth) {
if (!Settings.displayOtherAccounts) {
return;
}
if (auth == null) {
return;
}
if (this.database.getAllAuthsByName(auth).isEmpty()
|| this.database.getAllAuthsByName(auth) == null) {
return;
}
if (this.database.getAllAuthsByName(auth).size() == 1) {
return;
}
List<String> accountList = this.database.getAllAuthsByName(auth);
String message = "[AuthMe] ";
int i = 0;
for (String account : accountList) {
i++;
message = message + account;
if (i != accountList.size()) {
message = message + ", ";
} else {
message = message + ".";
}
}
for (Player player : AuthMe.getInstance().getServer()
.getOnlinePlayers()) {
if (plugin.authmePermissible(player, "authme.seeOtherAccounts")) {
player.sendMessage("[AuthMe] The player " + auth.getNickname()
+ " has " + String.valueOf(accountList.size())
+ " accounts");
player.sendMessage(message);
}
}
}
}

View File

@ -0,0 +1,620 @@
package uk.org.whoami.authme.threads;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import uk.org.whoami.authme.AuthMe;
import uk.org.whoami.authme.ConsoleLogger;
import uk.org.whoami.authme.cache.auth.PlayerAuth;
import uk.org.whoami.authme.datasource.DataSource;
import uk.org.whoami.authme.datasource.MiniConnectionPoolManager;
import uk.org.whoami.authme.datasource.MiniConnectionPoolManager.TimeoutException;
import uk.org.whoami.authme.settings.Settings;
import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource;
public class MySQLThread extends Thread implements DataSource {
private String host;
private String port;
private String username;
private String password;
private String database;
private String tableName;
private String columnName;
private String columnPassword;
private String columnIp;
private String columnLastLogin;
private String columnSalt;
private String columnGroup;
private String lastlocX;
private String lastlocY;
private String lastlocZ;
private String lastlocWorld;
private String columnEmail;
private String columnID;
private List<String> columnOthers;
private MiniConnectionPoolManager conPool;
public void run() {
this.host = Settings.getMySQLHost;
this.port = Settings.getMySQLPort;
this.username = Settings.getMySQLUsername;
this.password = Settings.getMySQLPassword;
this.database = Settings.getMySQLDatabase;
this.tableName = Settings.getMySQLTablename;
this.columnName = Settings.getMySQLColumnName;
this.columnPassword = Settings.getMySQLColumnPassword;
this.columnIp = Settings.getMySQLColumnIp;
this.columnLastLogin = Settings.getMySQLColumnLastLogin;
this.lastlocX = Settings.getMySQLlastlocX;
this.lastlocY = Settings.getMySQLlastlocY;
this.lastlocZ = Settings.getMySQLlastlocZ;
this.lastlocWorld = Settings.getMySQLlastlocWorld;
this.columnSalt = Settings.getMySQLColumnSalt;
this.columnGroup = Settings.getMySQLColumnGroup;
this.columnEmail = Settings.getMySQLColumnEmail;
this.columnOthers = Settings.getMySQLOtherUsernameColumn;
this.columnID = Settings.getMySQLColumnId;
try {
this.connect();
this.setup();
} catch (ClassNotFoundException e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
ConsoleLogger.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
if (!Settings.isStopEnabled)
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
return;
} catch (SQLException e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
ConsoleLogger.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
if (!Settings.isStopEnabled)
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
return;
} catch (TimeoutException e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
ConsoleLogger.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
if (!Settings.isStopEnabled)
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
return;
}
}
private synchronized void connect() throws ClassNotFoundException, SQLException, TimeoutException {
Class.forName("com.mysql.jdbc.Driver");
ConsoleLogger.info("MySQL driver loaded");
MysqlConnectionPoolDataSource dataSource = new MysqlConnectionPoolDataSource();
dataSource.setDatabaseName(database);
dataSource.setServerName(host);
dataSource.setPort(Integer.parseInt(port));
dataSource.setUser(username);
dataSource.setPassword(password);
conPool = new MiniConnectionPoolManager(dataSource, 10);
ConsoleLogger.info("Connection pool ready");
}
private synchronized void setup() throws SQLException {
Connection con = null;
Statement st = null;
ResultSet rs = null;
try {
con = conPool.getValidConnection();
st = con.createStatement();
st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " ("
+ columnID + " INTEGER AUTO_INCREMENT,"
+ columnName + " VARCHAR(255) NOT NULL UNIQUE,"
+ columnPassword + " VARCHAR(255) NOT NULL,"
+ columnIp + " VARCHAR(40) NOT NULL,"
+ columnLastLogin + " BIGINT,"
+ lastlocX + " smallint(6) DEFAULT '0',"
+ lastlocY + " smallint(6) DEFAULT '0',"
+ lastlocZ + " smallint(6) DEFAULT '0',"
+ lastlocWorld + " VARCHAR(255) DEFAULT 'world',"
+ columnEmail + " VARCHAR(255) DEFAULT 'your@email.com',"
+ "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ columnPassword + " VARCHAR(255) NOT NULL;");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, columnIp);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ columnIp + " VARCHAR(40) NOT NULL;");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, columnLastLogin);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ columnLastLogin + " BIGINT;");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocX + " smallint(6) NOT NULL DEFAULT '0' AFTER "
+ columnLastLogin +" , ADD " + lastlocY + " smallint(6) NOT NULL DEFAULT '0' AFTER " + lastlocX + " , ADD " + lastlocZ + " smallint(6) NOT NULL DEFAULT '0' AFTER " + lastlocY + ";");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, lastlocWorld);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocWorld + " VARCHAR(255) NOT NULL DEFAULT 'world' AFTER " + lastlocZ + ";");
}
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 +";");
}
} finally {
close(rs);
close(st);
close(con);
}
}
@Override
public synchronized boolean isAuthAvailable(String user) {
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
try {
con = conPool.getValidConnection();
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnName + "=?;");
pst.setString(1, user);
rs = pst.executeQuery();
return rs.next();
} 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);
}
}
@Override
public synchronized PlayerAuth getAuth(String user) {
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
try {
con = conPool.getValidConnection();
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnName + "=?;");
pst.setString(1, user);
rs = pst.executeQuery();
if (rs.next()) {
if (rs.getString(columnIp).isEmpty() ) {
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "198.18.0.1", rs.getLong(columnLastLogin), rs.getInt(lastlocX), rs.getInt(lastlocY), rs.getInt(lastlocZ), rs.getString(lastlocWorld),rs.getString(columnEmail));
} else {
if(!columnSalt.isEmpty()){
if(!columnGroup.isEmpty())
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword),rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getInt(lastlocX), rs.getInt(lastlocY), rs.getInt(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail));
else return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword),rs.getString(columnSalt), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getInt(lastlocX), rs.getInt(lastlocY), rs.getInt(lastlocZ), rs.getString(lastlocWorld),rs.getString(columnEmail));
} else {
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getInt(lastlocX), rs.getInt(lastlocY), rs.getInt(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail));
}
}
} else {
return null;
}
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return null;
} catch (TimeoutException ex) {
ConsoleLogger.showError(ex.getMessage());
return null;
} finally {
close(rs);
close(pst);
close(con);
}
}
@Override
public synchronized boolean saveAuth(PlayerAuth auth) {
Connection con = null;
PreparedStatement pst = null;
try {
con = conPool.getValidConnection();
if ((columnSalt.isEmpty() || columnSalt == null) && (auth.getSalt().isEmpty() || auth.getSalt() == null)) {
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + ") VALUES (?,?,?,?);");
pst.setString(1, auth.getNickname());
pst.setString(2, auth.getHash());
pst.setString(3, auth.getIp());
pst.setLong(4, auth.getLastLogin());
pst.executeUpdate();
} else {
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + columnSalt + ") VALUES (?,?,?,?,?);");
pst.setString(1, auth.getNickname());
pst.setString(2, auth.getHash());
pst.setString(3, auth.getIp());
pst.setLong(4, auth.getLastLogin());
pst.setString(5, auth.getSalt());
pst.executeUpdate();
}
if (!columnOthers.isEmpty()) {
for(String column : columnOthers) {
pst = con.prepareStatement("UPDATE " + tableName + " SET " + tableName + "." + column + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getNickname());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
}
}
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} catch (TimeoutException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
close(pst);
close(con);
}
return true;
}
@Override
public synchronized boolean updatePassword(PlayerAuth auth) {
Connection con = null;
PreparedStatement pst = null;
try {
con = conPool.getValidConnection();
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnPassword + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getHash());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} catch (TimeoutException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
close(pst);
close(con);
}
return true;
}
@Override
public boolean updateSession(PlayerAuth auth) {
Connection con = null;
PreparedStatement pst = null;
try {
con = conPool.getValidConnection();
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnIp + "=?, " + columnLastLogin + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getIp());
pst.setLong(2, auth.getLastLogin());
pst.setString(3, auth.getNickname());
pst.executeUpdate();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} catch (TimeoutException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
close(pst);
close(con);
}
return true;
}
@Override
public int purgeDatabase(long until) {
Connection con = null;
PreparedStatement pst = null;
try {
con = conPool.getValidConnection();
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnLastLogin + "<?;");
pst.setLong(1, until);
return pst.executeUpdate();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return 0;
} catch (TimeoutException ex) {
ConsoleLogger.showError(ex.getMessage());
return 0;
} finally {
close(pst);
close(con);
}
}
@Override
public synchronized boolean removeAuth(String user) {
Connection con = null;
PreparedStatement pst = null;
try {
con = conPool.getValidConnection();
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user);
pst.executeUpdate();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} catch (TimeoutException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
close(pst);
close(con);
}
return true;
}
@Override
public boolean updateQuitLoc(PlayerAuth auth) {
Connection con = null;
PreparedStatement pst = null;
try {
con = conPool.getValidConnection();
pst = con.prepareStatement("UPDATE " + tableName + " SET "+ lastlocX + " =?, "+ lastlocY +"=?, "+ lastlocZ +"=?, " + lastlocWorld + "=? WHERE " + columnName + "=?;");
pst.setLong(1, auth.getQuitLocX());
pst.setLong(2, auth.getQuitLocY());
pst.setLong(3, auth.getQuitLocZ());
pst.setString(4, auth.getWorld());
pst.setString(5, auth.getNickname());
pst.executeUpdate();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} catch (TimeoutException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
close(pst);
close(con);
}
return true;
}
@Override
public int getIps(String ip) {
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
int countIp=0;
try {
con = conPool.getValidConnection();
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnIp + "=?;");
pst.setString(1, ip);
rs = pst.executeQuery();
while(rs.next()) {
countIp++;
}
return countIp;
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return 0;
} catch (TimeoutException ex) {
ConsoleLogger.showError(ex.getMessage());
return 0;
} finally {
close(rs);
close(pst);
close(con);
}
}
@Override
public boolean updateEmail(PlayerAuth auth) {
Connection con = null;
PreparedStatement pst = null;
try {
con = conPool.getValidConnection();
pst = con.prepareStatement("UPDATE " + tableName + " SET "+ columnEmail + " =? WHERE " + columnName + "=?;");
pst.setString(1, auth.getEmail());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} catch (TimeoutException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
close(pst);
close(con);
}
return true;
}
@Override
public boolean updateSalt(PlayerAuth auth) {
if (columnSalt.isEmpty()) {
return false;
}
Connection con = null;
PreparedStatement pst = null;
try {
con = conPool.getValidConnection();
pst = con.prepareStatement("UPDATE " + tableName + " SET "+ columnSalt + " =? WHERE " + columnName + "=?;");
pst.setString(1, auth.getSalt());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} catch (TimeoutException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
close(pst);
close(con);
}
return true;
}
@Override
public synchronized void close() {
try {
conPool.dispose();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
}
}
@Override
public void reload() {
}
private void close(Statement st) {
if (st != null) {
try {
st.close();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
}
}
}
private void close(ResultSet rs) {
if (rs != null) {
try {
rs.close();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
}
}
}
private void close(Connection con) {
if (con != null) {
try {
con.close();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
}
}
}
@Override
public List<String> getAllAuthsByName(PlayerAuth auth) {
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
List<String> countIp = new ArrayList<String>();
try {
con = conPool.getValidConnection();
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnIp + "=?;");
pst.setString(1, auth.getIp());
rs = pst.executeQuery();
while(rs.next()) {
countIp.add(rs.getString(columnName));
}
return countIp;
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return new ArrayList<String>();
} catch (TimeoutException ex) {
ConsoleLogger.showError(ex.getMessage());
return new ArrayList<String>();
} finally {
close(rs);
close(pst);
close(con);
}
}
@Override
public List<String> getAllAuthsByIp(String ip) {
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
List<String> countIp = new ArrayList<String>();
try {
con = conPool.getValidConnection();
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnIp + "=?;");
pst.setString(1, ip);
rs = pst.executeQuery();
while(rs.next()) {
countIp.add(rs.getString(columnName));
}
return countIp;
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return new ArrayList<String>();
} catch (TimeoutException ex) {
ConsoleLogger.showError(ex.getMessage());
return new ArrayList<String>();
} finally {
close(rs);
close(pst);
close(con);
}
}
@Override
public List<String> getAllAuthsByEmail(String email) {
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
List<String> countEmail = new ArrayList<String>();
try {
con = conPool.getValidConnection();
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnEmail + "=?;");
pst.setString(1, email);
rs = pst.executeQuery();
while(rs.next()) {
countEmail.add(rs.getString(columnName));
}
return countEmail;
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return new ArrayList<String>();
} catch (TimeoutException ex) {
ConsoleLogger.showError(ex.getMessage());
return new ArrayList<String>();
} finally {
close(rs);
close(pst);
close(con);
}
}
@Override
public void purgeBanned(List<String> banned) {
Connection con = null;
PreparedStatement pst = null;
try {
for (String name : banned) {
con = conPool.getValidConnection();
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, name);
pst.executeUpdate();
}
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
} finally {
close(pst);
close(con);
}
}
}

View File

@ -1,305 +0,0 @@
package uk.org.whoami.authme.threads;
import java.security.NoSuchAlgorithmException;
import java.util.Date;
import me.muizers.Notifications.Notification;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import uk.org.whoami.authme.AuthMe;
import uk.org.whoami.authme.ConsoleLogger;
import uk.org.whoami.authme.Utils;
import uk.org.whoami.authme.cache.auth.PlayerAuth;
import uk.org.whoami.authme.cache.auth.PlayerCache;
import uk.org.whoami.authme.cache.limbo.LimboCache;
import uk.org.whoami.authme.cache.limbo.LimboPlayer;
import uk.org.whoami.authme.datasource.DataSource;
import uk.org.whoami.authme.events.RegisterTeleportEvent;
import uk.org.whoami.authme.security.PasswordSecurity;
import uk.org.whoami.authme.security.RandomString;
import uk.org.whoami.authme.settings.Messages;
import uk.org.whoami.authme.settings.PlayersLogs;
import uk.org.whoami.authme.settings.Settings;
import uk.org.whoami.authme.settings.Spawn;
import uk.org.whoami.authme.task.MessageTask;
import uk.org.whoami.authme.task.TimeoutTask;
public class RegisterThread extends Thread {
private Messages m = Messages.getInstance();
private PlayersLogs pllog = PlayersLogs.getInstance();
private DataSource database;
private boolean isFirstTimeJoin;
private PlayerAuth auth;
private AuthMe plugin;
private Player player;
private String[] args;
private String ip;
public RegisterThread(AuthMe plugin, DataSource database, Player player, String ip, String[] args) {
this.database = database;
this.setFirstTimeJoin(false);
this.plugin = plugin;
this.player = player;
this.args = args.clone();
this.ip = ip;
}
public void run() {
final String name = player.getName().toLowerCase();
if (PlayerCache.getInstance().isAuthenticated(name)) {
player.sendMessage(m._("logged_in"));
this.interrupt();
return;
}
if (!Settings.isRegistrationEnabled) {
player.sendMessage(m._("reg_disabled"));
this.interrupt();
return;
}
if (database.isAuthAvailable(player.getName().toLowerCase())) {
player.sendMessage(m._("user_regged"));
if (pllog.getStringList("players").contains(player.getName())) {
pllog.getStringList("players").remove(player.getName());
}
this.interrupt();
return;
}
if(Settings.getmaxRegPerIp > 0 ){
if(!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByIp(ip).size() >= Settings.getmaxRegPerIp) {
player.sendMessage(m._("max_reg"));
this.interrupt();
return;
}
}
if(Settings.emailRegistration && !Settings.getmailAccount.isEmpty()) {
if(!args[0].contains("@")) {
player.sendMessage(m._("usage_reg"));
this.interrupt();
return;
}
if(Settings.doubleEmailCheck) {
if(args.length < 2) {
player.sendMessage(m._("usage_reg"));
this.interrupt();
return;
}
if(!args[0].equals(args[1])) {
player.sendMessage(m._("usage_reg"));
this.interrupt();
return;
}
}
final String email = args[0];
if(Settings.getmaxRegPerEmail > 0) {
if (!plugin.authmePermissible(player, "authme.allow2accounts") && database.getAllAuthsByEmail(email).size() >= Settings.getmaxRegPerEmail) {
player.sendMessage(m._("max_reg"));
this.interrupt();
return;
}
}
RandomString rand = new RandomString(Settings.getRecoveryPassLength);
final String thePass = rand.nextString();
if (!thePass.isEmpty()) {
if (PasswordSecurity.userSalt.containsKey(name)) {
try {
final String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, thePass, name);
final PlayerAuth fAuth = new PlayerAuth(name, hashnew, PasswordSecurity.userSalt.get(name), ip, new Date().getTime(), (int) player.getLocation().getX() , (int) player.getLocation().getY(), (int) player.getLocation().getZ(), player.getWorld().getName(), email);
database.saveAuth(fAuth);
database.updateEmail(fAuth);
database.updateSession(fAuth);
plugin.mail.main(fAuth, thePass);
} catch (NoSuchAlgorithmException e) {
ConsoleLogger.showError(e.getMessage());
}
} else {
try {
final String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, thePass, name);
final PlayerAuth fAuth = new PlayerAuth(name, hashnew, ip, new Date().getTime(), (int) player.getLocation().getX() , (int) player.getLocation().getY(), (int) player.getLocation().getZ(), player.getWorld().getName(), email);
database.saveAuth(fAuth);
database.updateEmail(fAuth);
database.updateSession(fAuth);
plugin.mail.main(fAuth, thePass);
} catch (NoSuchAlgorithmException e) {
ConsoleLogger.showError(e.getMessage());
}
}
if(!Settings.getRegisteredGroup.isEmpty()){
Utils.getInstance().setGroup(player, Utils.groupType.REGISTERED);
}
player.sendMessage(m._("vb_nonActiv"));
String msg = m._("login_msg");
int time = Settings.getRegistrationTimeout * 20;
int msgInterval = Settings.getWarnMessageInterval;
if (time != 0) {
Bukkit.getScheduler().cancelTask(LimboCache.getInstance().getLimboPlayer(name).getTimeoutTaskId());
BukkitTask id = Bukkit.getScheduler().runTaskLater(plugin, new TimeoutTask(plugin, name), time);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id.getTaskId());
}
Bukkit.getScheduler().cancelTask(LimboCache.getInstance().getLimboPlayer(name).getMessageTaskId());
BukkitTask nwMsg = Bukkit.getScheduler().runTask(plugin, new MessageTask(plugin, name, msg, msgInterval));
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(nwMsg.getTaskId());
LimboCache.getInstance().deleteLimboPlayer(name);
if (Settings.isTeleportToSpawnEnabled) {
World world = player.getWorld();
Location loca = world.getSpawnLocation();
if (plugin.mv != null) {
try {
loca = plugin.mv.getMVWorldManager().getMVWorld(world).getSpawnLocation();
} catch (NullPointerException npe) {
} catch (ClassCastException cce) {
} catch (NoClassDefFoundError ncdfe) {
}
}
if (plugin.essentialsSpawn != null) {
loca = plugin.essentialsSpawn;
}
if (Spawn.getInstance().getLocation() != null)
loca = Spawn.getInstance().getLocation();
final Location locaT = loca;
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, locaT);
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());
}
}
});
}
this.setFirstTimeJoin(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!"));
}
this.interrupt();
return;
}
}
if (args.length == 0 || (Settings.getEnablePasswordVerifier && args.length < 2) ) {
player.sendMessage(m._("usage_reg"));
this.interrupt();
return;
}
if(args[0].length() < Settings.getPasswordMinLen || args[0].length() > Settings.passwordMaxLength) {
player.sendMessage(m._("pass_len"));
this.interrupt();
return;
}
try {
String hash;
if(Settings.getEnablePasswordVerifier) {
if (args[0].equals(args[1])) {
hash = PasswordSecurity.getHash(Settings.getPasswordHash, args[0], name);
} else {
player.sendMessage(m._("password_error"));
this.interrupt();
return;
}
} else
hash = PasswordSecurity.getHash(Settings.getPasswordHash, args[0], name);
if (Settings.getMySQLColumnSalt.isEmpty())
{
auth = new PlayerAuth(name, hash, ip, new Date().getTime());
} else {
auth = new PlayerAuth(name, hash, PasswordSecurity.userSalt.get(name), ip, new Date().getTime());
}
if (!database.saveAuth(auth)) {
player.sendMessage(m._("error"));
this.interrupt();
return;
}
PlayerCache.getInstance().addPlayer(auth);
final LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
if (limbo != null) {
Bukkit.getScheduler().runTask(plugin, new Runnable(){
@Override
public void run() {
player.setGameMode(GameMode.getByValue(limbo.getGameMode()));
}
});
if (Settings.isTeleportToSpawnEnabled) {
World world = player.getWorld();
Location loca = world.getSpawnLocation();
if (plugin.mv != null) {
try {
loca = plugin.mv.getMVWorldManager().getMVWorld(world).getSpawnLocation();
} catch (NullPointerException npe) {
} catch (ClassCastException cce) {
} catch (NoClassDefFoundError ncdfe) {
}
}
if (plugin.essentialsSpawn != null) {
loca = plugin.essentialsSpawn;
}
if (Spawn.getInstance().getLocation() != null)
loca = Spawn.getInstance().getLocation();
final Location locaT = loca;
Bukkit.getScheduler().runTask(plugin, new Runnable(){
@Override
public void run() {
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, locaT);
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());
}
}
});
}
player.getServer().getScheduler().cancelTask(limbo.getTimeoutTaskId());
player.getServer().getScheduler().cancelTask(limbo.getMessageTaskId());
LimboCache.getInstance().deleteLimboPlayer(name);
}
if(!Settings.getRegisteredGroup.isEmpty()){
Utils.getInstance().setGroup(player, Utils.groupType.REGISTERED);
}
player.sendMessage(m._("registered"));
if (!Settings.getmailAccount.isEmpty())
player.sendMessage(m._("add_email"));
this.setFirstTimeJoin(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!"));
}
this.interrupt();
} catch (NoSuchAlgorithmException ex) {
ConsoleLogger.showError(ex.getMessage());
player.sendMessage(m._("error"));
this.interrupt();
}
}
public void setFirstTimeJoin(boolean isFirstTimeJoin) {
this.isFirstTimeJoin = isFirstTimeJoin;
}
public boolean isFirstTimeJoin() {
return isFirstTimeJoin;
}
}

View File

@ -0,0 +1,499 @@
package uk.org.whoami.authme.threads;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import uk.org.whoami.authme.AuthMe;
import uk.org.whoami.authme.ConsoleLogger;
import uk.org.whoami.authme.cache.auth.PlayerAuth;
import uk.org.whoami.authme.datasource.DataSource;
import uk.org.whoami.authme.datasource.MiniConnectionPoolManager.TimeoutException;
import uk.org.whoami.authme.settings.Settings;
public class SQLiteThread extends Thread implements DataSource {
private String database;
private String tableName;
private String columnName;
private String columnPassword;
private String columnIp;
private String columnLastLogin;
private String columnSalt;
private String columnGroup;
private String lastlocX;
private String lastlocY;
private String lastlocZ;
private String lastlocWorld;
private String columnEmail;
private String columnID;
private Connection con;
public void run() {
this.database = Settings.getMySQLDatabase;
this.tableName = Settings.getMySQLTablename;
this.columnName = Settings.getMySQLColumnName;
this.columnPassword = Settings.getMySQLColumnPassword;
this.columnIp = Settings.getMySQLColumnIp;
this.columnLastLogin = Settings.getMySQLColumnLastLogin;
this.columnSalt = Settings.getMySQLColumnSalt;
this.columnGroup = Settings.getMySQLColumnGroup;
this.lastlocX = Settings.getMySQLlastlocX;
this.lastlocY = Settings.getMySQLlastlocY;
this.lastlocZ = Settings.getMySQLlastlocZ;
this.lastlocWorld = Settings.getMySQLlastlocWorld;
this.columnEmail = Settings.getMySQLColumnEmail;
this.columnID = Settings.getMySQLColumnId;
try {
this.connect();
this.setup();
} catch (ClassNotFoundException e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
ConsoleLogger.showError("Can't use SQLITE... ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
if (!Settings.isStopEnabled)
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
return;
} catch (SQLException e) {
ConsoleLogger.showError(e.getMessage());
if (Settings.isStopEnabled) {
ConsoleLogger.showError("Can't use SQLITE... ! SHUTDOWN...");
AuthMe.getInstance().getServer().shutdown();
}
if (!Settings.isStopEnabled)
AuthMe.getInstance().getServer().getPluginManager().disablePlugin(AuthMe.getInstance());
return;
}
}
private synchronized void connect() throws ClassNotFoundException, SQLException {
Class.forName("org.sqlite.JDBC");
ConsoleLogger.info("SQLite driver loaded");
this.con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/"+database+".db");
}
private synchronized void setup() throws SQLException {
Statement st = null;
ResultSet rs = null;
try {
st = con.createStatement();
st.executeUpdate("CREATE TABLE IF NOT EXISTS " + tableName + " ("
+ columnID + " INTEGER AUTO_INCREMENT,"
+ columnName + " VARCHAR(255) NOT NULL UNIQUE,"
+ columnPassword + " VARCHAR(255) NOT NULL,"
+ columnIp + " VARCHAR(40) NOT NULL,"
+ columnLastLogin + " BIGINT,"
+ lastlocX + " smallint(6) DEFAULT '0',"
+ lastlocY + " smallint(6) DEFAULT '0',"
+ lastlocZ + " smallint(6) DEFAULT '0',"
+ lastlocWorld + " VARCHAR(255) DEFAULT 'world',"
+ columnEmail + " VARCHAR(255) DEFAULT 'your@email.com',"
+ "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));");
rs = con.getMetaData().getColumns(null, null, tableName, columnPassword);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ columnPassword + " VARCHAR(255) NOT NULL;");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, columnIp);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ columnIp + " VARCHAR(40) NOT NULL;");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, columnLastLogin);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN "
+ columnLastLogin + " BIGINT;");
}
rs.close();
rs = con.getMetaData().getColumns(null, null, tableName, lastlocX);
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocX + " smallint(6) NOT NULL DEFAULT '0'; "
+ "ALTER TABLE " + tableName + " ADD COLUMN " + lastlocY + " smallint(6) NOT NULL DEFAULT '0'; "
+ "ALTER TABLE " + tableName + " ADD COLUMN " + lastlocZ + " smallint(6) NOT NULL DEFAULT '0';");
}
rs.close();
if (!rs.next()) {
st.executeUpdate("ALTER TABLE " + tableName + " ADD COLUMN " + lastlocWorld + " VARCHAR(255) NOT NULL DEFAULT 'world' AFTER " + lastlocZ + ";");
}
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';");
}
} finally {
close(rs);
close(st);
}
ConsoleLogger.info("SQLite Setup finished");
}
@Override
public synchronized boolean isAuthAvailable(String user) {
PreparedStatement pst = null;
ResultSet rs = null;
try {
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?");
pst.setString(1, user);
rs = pst.executeQuery();
return rs.next();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
close(rs);
close(pst);
}
}
@Override
public synchronized PlayerAuth getAuth(String user) {
PreparedStatement pst = null;
ResultSet rs = null;
try {
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnName + "=?;");
pst.setString(1, user);
rs = pst.executeQuery();
if (rs.next()) {
if (rs.getString(columnIp).isEmpty() ) {
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "198.18.0.1", rs.getLong(columnLastLogin), rs.getInt(lastlocX), rs.getInt(lastlocY), rs.getInt(lastlocZ), rs.getString(lastlocWorld) , rs.getString(columnEmail));
} else {
if(!columnSalt.isEmpty()){
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword),rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getInt(lastlocX), rs.getInt(lastlocY), rs.getInt(lastlocZ), rs.getString(lastlocWorld) , rs.getString(columnEmail));
} else {
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getInt(lastlocX), rs.getInt(lastlocY), rs.getInt(lastlocZ), rs.getString(lastlocWorld) , rs.getString(columnEmail));
}
}
} else {
return null;
}
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return null;
} finally {
close(rs);
close(pst);
}
}
@Override
public synchronized boolean saveAuth(PlayerAuth auth) {
PreparedStatement pst = null;
try {
if (columnSalt.isEmpty() && auth.getSalt().isEmpty()) {
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + ") VALUES (?,?,?,?);");
pst.setString(1, auth.getNickname());
pst.setString(2, auth.getHash());
pst.setString(3, auth.getIp());
pst.setLong(4, auth.getLastLogin());
pst.executeUpdate();
} else {
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + columnSalt + ") VALUES (?,?,?,?,?);");
pst.setString(1, auth.getNickname());
pst.setString(2, auth.getHash());
pst.setString(3, auth.getIp());
pst.setLong(4, auth.getLastLogin());
pst.setString(5, auth.getSalt());
pst.executeUpdate();
}
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
close(pst);
}
return true;
}
@Override
public synchronized boolean updatePassword(PlayerAuth auth) {
PreparedStatement pst = null;
try {
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnPassword + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getHash());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
close(pst);
}
return true;
}
@Override
public boolean updateSession(PlayerAuth auth) {
PreparedStatement pst = null;
try {
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnIp + "=?, " + columnLastLogin + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getIp());
pst.setLong(2, auth.getLastLogin());
pst.setString(3, auth.getNickname());
pst.executeUpdate();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
close(pst);
}
return true;
}
@Override
public int purgeDatabase(long until) {
PreparedStatement pst = null;
try {
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnLastLogin + "<?;");
pst.setLong(1, until);
return pst.executeUpdate();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return 0;
} finally {
close(pst);
}
}
@Override
public synchronized boolean removeAuth(String user) {
PreparedStatement pst = null;
try {
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user);
pst.executeUpdate();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
close(pst);
}
return true;
}
@Override
public boolean updateQuitLoc(PlayerAuth auth) {
PreparedStatement pst = null;
try {
pst = con.prepareStatement("UPDATE " + tableName + " SET " + lastlocX + "=?, "+ lastlocY +"=?, "+ lastlocZ +"=?, " + lastlocWorld + "=? WHERE " + columnName + "=?;");
pst.setLong(1, auth.getQuitLocX());
pst.setLong(2, auth.getQuitLocY());
pst.setLong(3, auth.getQuitLocZ());
pst.setString(4, auth.getWorld());
pst.setString(5, auth.getNickname());
pst.executeUpdate();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
close(pst);
}
return true;
}
@Override
public int getIps(String ip) {
PreparedStatement pst = null;
ResultSet rs = null;
int countIp=0;
try {
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnIp + "=?;");
pst.setString(1, ip);
rs = pst.executeQuery();
while(rs.next()) {
countIp++;
}
return countIp;
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return 0;
} finally {
close(rs);
close(pst);
}
}
@Override
public boolean updateEmail(PlayerAuth auth) {
PreparedStatement pst = null;
try {
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnEmail + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getEmail());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
close(pst);
}
return true;
}
@Override
public boolean updateSalt(PlayerAuth auth) {
if(columnSalt.isEmpty()) {
return false;
}
PreparedStatement pst = null;
try {
pst = con.prepareStatement("UPDATE " + tableName + " SET " + columnSalt + "=? WHERE " + columnName + "=?;");
pst.setString(1, auth.getSalt());
pst.setString(2, auth.getNickname());
pst.executeUpdate();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return false;
} finally {
close(pst);
}
return true;
}
@Override
public synchronized void close() {
try {
con.close();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
}
}
@Override
public void reload() {
}
private void close(Statement st) {
if (st != null) {
try {
st.close();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
}
}
}
private void close(ResultSet rs) {
if (rs != null) {
try {
rs.close();
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
}
}
}
@Override
public List<String> getAllAuthsByName(PlayerAuth auth) {
PreparedStatement pst = null;
ResultSet rs = null;
List<String> countIp = new ArrayList<String>();
try {
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnIp + "=?;");
pst.setString(1, auth.getIp());
rs = pst.executeQuery();
while(rs.next()) {
countIp.add(rs.getString(columnName));
}
return countIp;
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return new ArrayList<String>();
} catch (TimeoutException ex) {
ConsoleLogger.showError(ex.getMessage());
return new ArrayList<String>();
} catch (NullPointerException npe) {
return new ArrayList<String>();
} finally {
close(rs);
close(pst);
}
}
@Override
public List<String> getAllAuthsByIp(String ip) {
PreparedStatement pst = null;
ResultSet rs = null;
List<String> countIp = new ArrayList<String>();
try {
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnIp + "=?;");
pst.setString(1, ip);
rs = pst.executeQuery();
while(rs.next()) {
countIp.add(rs.getString(columnName));
}
return countIp;
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return new ArrayList<String>();
} catch (TimeoutException ex) {
ConsoleLogger.showError(ex.getMessage());
return new ArrayList<String>();
} catch (NullPointerException npe) {
return new ArrayList<String>();
} finally {
close(rs);
close(pst);
}
}
@Override
public List<String> getAllAuthsByEmail(String email) {
PreparedStatement pst = null;
ResultSet rs = null;
List<String> countEmail = new ArrayList<String>();
try {
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
+ columnEmail + "=?;");
pst.setString(1, email);
rs = pst.executeQuery();
while(rs.next()) {
countEmail.add(rs.getString(columnName));
}
return countEmail;
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
return new ArrayList<String>();
} catch (TimeoutException ex) {
ConsoleLogger.showError(ex.getMessage());
return new ArrayList<String>();
} catch (NullPointerException npe) {
return new ArrayList<String>();
} finally {
close(rs);
close(pst);
}
}
@Override
public void purgeBanned(List<String> banned) {
PreparedStatement pst = null;
try {
for (String name : banned) {
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, name);
pst.executeUpdate();
}
} catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage());
} finally {
close(pst);
}
}
}

View File

@ -15,6 +15,7 @@ no_perm: '&cSem permissao!'
error: '&fOcorreu um erro de sistema, por favor reporte ao ADM.'
login_msg: '&cPara entrar digite: "/login password"'
reg_msg: '&cPara registrar um nick digite: "/register senha senha"'
reg_email_msg: '&cPlease register with "/register <email> <confirmEmail>"'
usage_unreg: '&cPara desregistrar digite: /unregister senha'
pwd_changed: '&cSenha modificada!'
user_unknown: '&cNome de usuario nao existe. Verifique.'

View File

@ -13,6 +13,7 @@ no_perm: '&cNemas opravneni.'
error: '&cVyskytla se chyba kontaktujte admina ...'
login_msg: '&cProsim prihlaste se "/login vaseheslo".'
reg_msg: '&cProsim zaregistrujte se "/register heslo heslo".'
reg_email_msg: '&cPlease register with "/register <email> <confirmEmail>"'
usage_unreg: '&cPouziti: "/unregister vaseheslo".'
pwd_changed: '&cHeslo zmeneno!'
user_unknown: '&cUzivatelske jmeno neni registrovano.'

View File

@ -16,6 +16,7 @@ no_perm: '&cKeine Rechte'
error: '&fEin Fehler ist aufgetreten. Bitte kontaktiere einen Admin'
login_msg: '&cBitte logge dich ein mit "/login <passwort>"'
reg_msg: '&cBitte registriere dich mit "/register <passwort> <passwortBestätigen>"'
reg_email_msg: '&cPlease register with "/register <email> <confirmEmail>"'
usage_unreg: '&cBenutze: /unregister <passwort>'
pwd_changed: '&cPasswort geändert!'
user_unknown: '&cBenutzername nicht registriert'

View File

@ -16,6 +16,7 @@ no_perm: '&cNo Permission'
error: '&fAn error ocurred; Please contact the admin'
login_msg: '&cPlease login with "/login password"'
reg_msg: '&cPlease register with "/register password ConfirmPassword"'
reg_email_msg: '&cPlease register with "/register <email> <confirmEmail>"'
usage_unreg: '&cUsage: /unregister password'
pwd_changed: '&cPassword changed!'
user_unknown: '&cUsername not registered'

View File

@ -17,6 +17,7 @@ no_perm: '&cNo tienes permiso'
error: '&fHa ocurrido un error. Por favor contacta al administrador.'
login_msg: '&cInicia sesión con "/login contraseña"'
reg_msg: '&cPor favor, regístrate con "/register Contraseña ConfirmarContraseña"'
reg_email_msg: '&cPlease register with "/register <email> <confirmEmail>"'
usage_unreg: '&cUso: /unregister contraseña'
pwd_changed: '&c¡Contraseña cambiada!'
user_unknown: '&cUsuario no registrado'

View File

@ -16,6 +16,7 @@ no_perm: '&cEi oikeuksia'
error: '&fVirhe: Ota yhteys operaattoriin!'
login_msg: '&cKirjaudu palvelimmelle "/login salasana"'
reg_msg: '&cRekisteröidy palvelimellemme "/register salasana salasana"'
reg_email_msg: '&cPlease register with "/register <email> <confirmEmail>"'
usage_unreg: '&cKäyttö: /unregister password'
pwd_changed: '&cSalasana vaihdettu!!'
user_unknown: '&cSalasanat eivät täsmää'

View File

@ -16,7 +16,8 @@ max_reg: '&fLimite d''enregistrement atteinte pour ce compte'
no_perm: '&cVous n''avez pas la permission'
error: '&fUne erreur est apparue, veuillez contacter un administrateur'
login_msg: '&cPour vous connecter, utilisez: /login motdepasse'
reg_msg: '&cPour vous inscrire, utilisez /register motdepasse confirmermotdepasse'
reg_msg: '&cPour vous inscrire, utilisez "/register motdepasse confirmermotdepasse"'
reg_email_msg: '&cPour vous inscrire, utilisez "/register <email> <confirmEmail>"'
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é'

View File

@ -23,6 +23,7 @@ login: '&aSikeresen Bel
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 <email> <confirmEmail>"'
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

View File

@ -16,6 +16,7 @@ no_perm: '&cNessun Permesso'
error: "Errore; Perfavore, contatta l'admin"
login_msg: '&cPerfavore, loggati con "/login password"'
reg_msg: '&cPerfavore, registrati con "/register password confermaPassword"'
reg_email_msg: '&cPlease register with "/register <email> <confirmEmail>"'
usage_unreg: '&cUtilizzo: /unregister password'
pwd_changed: '&cPassword cambiata!'
user_unknown: '&cUtente non registrato'

View File

@ -16,6 +16,7 @@ no_perm: '&cNera leidimo'
error: '&cAtsirado klaida, praneskite adminstratoriui.'
login_msg: '&ePrasome prisijungti: /login slaptazodis'
reg_msg: '&ePrasome prisiregistruoti: /register slaptazodis pakartotiSlaptazodi'
reg_email_msg: '&cPlease register with "/register <email> <confirmEmail>"'
usage_unreg: '&ePanaikinti registracija: /unregister slaptazodis"
pwd_changed: '&aSlaptazodis pakeistas'
user_unknown: '&cVartotojas neprisiregistraves'

View File

@ -10,6 +10,7 @@ reg_only: '&fTylko zarejestrowani uzytkownicy maja do tego dostep!'
valid_session: '&cSesja logowania'
login_msg: '&2Prosze sie zalogowac przy uzyciu &6/login <haslo>'
reg_msg: '&2Prosze sie zarejestrowac przy uzyciu &6/register <haslo> <ponownie_haslo>'
reg_email_msg: '&cPlease register with "/register <email> <confirmEmail>"'
timeout: '&fUplynal limit czasu zalogowania'
wrong_pwd: '&cNiepoprawne haslo'
logout: '&cPomyslnie wylogowany'

View File

@ -19,6 +19,7 @@ error: '&cЧто-то пошло не так... &5Свяжись с админи
login_msg: '&eВойди в игру - &d/l ПАРОЛЬ &eили &d/login ПАРОЛЬ'
reg_msg: '&eЗарегистрируйся - &d/reg ПАРОЛЬ ПОВТОРАРОЛЯ &eили &d/register ПАРОЛЬ
ПОВТОРАРОЛЯ'
reg_email_msg: '&cPlease register with "/register <email> <confirmEmail>"'
usage_unreg: '&eСинтаксис: &d/unregister ПАРОЛЬ'
pwd_changed: '&aПароль изменён'
user_unknown: '&cТакой игрок не зарегистрирован'

View File

@ -14,6 +14,7 @@ reg_only: '&fVstup iba pre registrovanych! Navstiv http://www.cs-gaming.eu pre r
valid_session: '&cZapamätané prihlásenie'
login_msg: '&cPrihlás sa príkazom "/login heslo"'
reg_msg: '&cZaregistruj sa príkazom "/register heslo zopakujHeslo"'
reg_email_msg: '&cPlease register with "/register <email> <confirmEmail>"'
timeout: '&fVyprsal cas na prihlásenie'
wrong_pwd: '&cZadal si zlé heslo'
logout: '&cBol si úspesne odhláseny'

View File

@ -12,6 +12,7 @@ vb_nonActiv: '&f你的帐号还未激活请查看你的邮箱'
user_regged: '&c此用户已经在此服务器注册过'
usage_reg: '&c正确用法“/register <密码> <再输入一次以确定密码>”'
max_reg: '&f你不允许再为你的IP在服务器注册更多用户了'
reg_email_msg: '&cPlease register with "/register <email> <confirmEmail>"'
no_perm: '&c没有权限'
error: '&f发现错误请联系管理员'
login_msg: '&c请输入“/login <密码>”以登录'

View File

@ -16,6 +16,7 @@ no_perm: '&c你並沒有這個權限 。'
error: '&f發生錯誤 請與管理員聯絡 。'
login_msg: '&c請使用這個指令來登入 《 /login <密碼> 》'
reg_msg: '&c請使用這個的指令來註冊 《 /register <密碼> <重覆密碼> 》'
reg_email_msg: '&cPlease register with "/register <email> <confirmEmail>"'
usage_unreg: '&c用法 《 /unregister <密碼> 》'
pwd_changed: '&c你成功的更換了你的密碼 '
user_unknown: '&c此用戶名沒有已登記資料 。'

View File

@ -1,9 +1,9 @@
name: AuthMe
author: darkwarriors,Xephi
author: Xephi59
website: http://www.multiplayer-italia.com/
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: uk.org.whoami.authme.AuthMe
version: 2.8
version: 2.9
softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag, Essentials, EssentialsSpawn]
commands:
register:

View File

@ -9,4 +9,4 @@ LoginScreen:
- Sample text
- Change this at spout.yml
- '--- AuthMe Reloaded by ---'
- d4rkwarriors and Xephi59
- Xephi59