Update 3.1.1
//Changes 3.1.1:// * Do /login correctly in the correct thread * Add a way to force some commands after /login * Try a fix for bungeecord , let's see ... * Fix Logout command ( pos + inventory ) * Fix PHPBB support + random salt * Add a bypass antibot perm : authme.bypassantibot * Translation file will automatically update now * Some other fixes
This commit is contained in:
@@ -1,10 +1,17 @@
|
||||
package fr.xephi.authme;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
|
||||
@@ -25,6 +32,7 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
|
||||
import com.maxmind.geoip.LookupService;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
import fr.xephi.authme.api.API;
|
||||
@@ -48,6 +56,7 @@ import fr.xephi.authme.datasource.FileDataSource;
|
||||
import fr.xephi.authme.datasource.MySQLDataSource;
|
||||
import fr.xephi.authme.datasource.SqliteDataSource;
|
||||
import fr.xephi.authme.listener.AuthMeBlockListener;
|
||||
import fr.xephi.authme.listener.AuthMeBungeeCordListener;
|
||||
import fr.xephi.authme.listener.AuthMeChestShopListener;
|
||||
import fr.xephi.authme.listener.AuthMeEntityListener;
|
||||
import fr.xephi.authme.listener.AuthMePlayerListener;
|
||||
@@ -94,6 +103,9 @@ public class AuthMe extends JavaPlugin {
|
||||
public MultiverseCore multiverse = null;
|
||||
public Location essentialsSpawn;
|
||||
public Thread databaseThread = null;
|
||||
public LookupService ls = null;
|
||||
public boolean antibotMod = false;
|
||||
public boolean delayedAntiBot = true;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
@@ -105,14 +117,34 @@ public class AuthMe extends JavaPlugin {
|
||||
settings = new Settings(this);
|
||||
settings.loadConfigOptions();
|
||||
|
||||
if (Settings.enableAntiBot) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
delayedAntiBot = false;
|
||||
}
|
||||
}, 2400);
|
||||
}
|
||||
|
||||
m = Messages.getInstance();
|
||||
|
||||
setMessages(Messages.getInstance());
|
||||
pllog = PlayersLogs.getInstance();
|
||||
|
||||
server = getServer();
|
||||
|
||||
//Set Console Filter
|
||||
if (Settings.removePassword)
|
||||
Bukkit.getLogger().setFilter(new ConsoleFilter());
|
||||
if (Settings.removePassword) {
|
||||
Bukkit.getLogger().setFilter(new ConsoleFilter());
|
||||
/*// Check the log4j usage and apply a filter
|
||||
try {
|
||||
if (Class.forName("org.apache.logging.log4j.LogManager") != null) {
|
||||
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
//Load MailApi
|
||||
if(!Settings.getmailAccount.isEmpty() && !Settings.getmailPassword.isEmpty())
|
||||
@@ -137,7 +169,7 @@ public class AuthMe extends JavaPlugin {
|
||||
checkEssentials();
|
||||
|
||||
/*
|
||||
* Back style on start if avaible
|
||||
* Back style on start if avalaible
|
||||
*/
|
||||
if(Settings.isBackupActivated && Settings.isBackupOnStart) {
|
||||
Boolean Backup = new PerformBackup(this).DoBackup();
|
||||
@@ -164,7 +196,7 @@ public class AuthMe extends JavaPlugin {
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't use FLAT FILE... SHUTDOWN...");
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
if (!Settings.isStopEnabled)
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
@@ -185,7 +217,7 @@ public class AuthMe extends JavaPlugin {
|
||||
if (Settings.isStopEnabled) {
|
||||
ConsoleLogger.showError("Can't use MySQL... Please input correct MySQL informations ! SHUTDOWN...");
|
||||
server.shutdown();
|
||||
}
|
||||
}
|
||||
if (!Settings.isStopEnabled)
|
||||
this.getServer().getPluginManager().disablePlugin(this);
|
||||
return;
|
||||
@@ -225,6 +257,16 @@ public class AuthMe extends JavaPlugin {
|
||||
management = new Management(database, this);
|
||||
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
if (Settings.bungee) {
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeCordMessage(this));
|
||||
try {
|
||||
if (Class.forName("net.md_5.bungee.api.event.ChatEvent") != null)
|
||||
pm.registerEvents(new AuthMeBungeeCordListener(database, this), this);
|
||||
} catch (ClassNotFoundException e) {
|
||||
}
|
||||
ConsoleLogger.info("Successfully hook with BungeeCord!");
|
||||
}
|
||||
if (pm.isPluginEnabled("Spout")) {
|
||||
pm.registerEvents(new AuthMeSpoutListener(database), this);
|
||||
ConsoleLogger.info("Successfully hook with Spout!");
|
||||
@@ -236,10 +278,6 @@ public class AuthMe extends JavaPlugin {
|
||||
pm.registerEvents(new AuthMeChestShopListener(database, this), this);
|
||||
ConsoleLogger.info("Successfully hook with ChestShop!");
|
||||
}
|
||||
if (Settings.bungee) {
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeCordMessage(this));
|
||||
}
|
||||
|
||||
//Find Permissions
|
||||
if (pm.getPlugin("Vault") != null) {
|
||||
@@ -283,6 +321,8 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
} catch (NullPointerException ex) {
|
||||
}
|
||||
if (Settings.enableProtection)
|
||||
enableProtection();
|
||||
if (Settings.usePurge)
|
||||
autoPurge();
|
||||
ConsoleLogger.info("Authme " + this.getDescription().getVersion() + " enabled");
|
||||
@@ -338,7 +378,7 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void checkEssentials() {
|
||||
if (this.getServer().getPluginManager().getPlugin("Essentials") != null && this.getServer().getPluginManager().getPlugin("Essentials").isEnabled()) {
|
||||
try {
|
||||
@@ -405,7 +445,7 @@ public class AuthMe extends JavaPlugin {
|
||||
if (database != null) {
|
||||
database.close();
|
||||
}
|
||||
|
||||
|
||||
if (databaseThread != null) {
|
||||
databaseThread.interrupt();
|
||||
}
|
||||
@@ -414,7 +454,7 @@ public class AuthMe extends JavaPlugin {
|
||||
Boolean Backup = new PerformBackup(this).DoBackup();
|
||||
if(Backup) ConsoleLogger.info("Backup Complete");
|
||||
else ConsoleLogger.showError("Error while making Backup");
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("Authme " + this.getDescription().getVersion() + " disabled");
|
||||
}
|
||||
|
||||
@@ -427,7 +467,7 @@ public class AuthMe extends JavaPlugin {
|
||||
PlayerAuth pAuth = database.getAuth(name);
|
||||
if(pAuth == null)
|
||||
break;
|
||||
PlayerAuth auth = new PlayerAuth(name, pAuth.getHash(), pAuth.getIp(), new Date().getTime());
|
||||
PlayerAuth auth = new PlayerAuth(name, pAuth.getHash(), pAuth.getIp(), new Date().getTime(), pAuth.getEmail(), player.getName());
|
||||
database.updateSession(auth);
|
||||
PlayerCache.getInstance().addPlayer(auth);
|
||||
}
|
||||
@@ -519,7 +559,7 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
return player;
|
||||
}
|
||||
|
||||
|
||||
public boolean authmePermissible(Player player, String perm) {
|
||||
if (player.hasPermission(perm))
|
||||
return true;
|
||||
@@ -536,7 +576,7 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void autoPurge() {
|
||||
if (!Settings.usePurge) {
|
||||
return;
|
||||
@@ -551,9 +591,68 @@ public class AuthMe extends JavaPlugin {
|
||||
purgeEssentials(cleared);
|
||||
if (Settings.purgePlayerDat)
|
||||
purgeDat(cleared);
|
||||
if (Settings.purgeLimitedCreative)
|
||||
purgeLimitedCreative(cleared);
|
||||
if (Settings.purgeAntiXray)
|
||||
purgeAntiXray(cleared);
|
||||
//if (Settings.purgePermissions && permission != null)
|
||||
//purgePerms(cleared);
|
||||
}
|
||||
|
||||
private void purgeDat(List<String> cleared) {
|
||||
/* private void purgePerms(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
org.bukkit.OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
||||
if (player == null) continue;
|
||||
String playerName = player.getName();
|
||||
for (String group : permission.getPlayerGroups((String) null, playerName)) {
|
||||
permission.playerRemoveGroup((String) null, playerName, group);
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " players permissions");
|
||||
} */
|
||||
|
||||
public void purgeAntiXray(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
org.bukkit.OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
||||
if (player == null) continue;
|
||||
String playerName = player.getName();
|
||||
File playerFile = new File("." + File.separator + "plugins" + File.separator + "AntiXRayData" + File.separator + "PlayerData" + File.separator + playerName);
|
||||
if (playerFile.exists()) {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " AntiXRayData Files");
|
||||
}
|
||||
|
||||
public void purgeLimitedCreative(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
org.bukkit.OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
||||
if (player == null) continue;
|
||||
String playerName = player.getName();
|
||||
File playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + ".yml");
|
||||
if (playerFile.exists()) {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_creative.yml");
|
||||
if (playerFile.exists()) {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_adventure.yml");
|
||||
if (playerFile.exists()) {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " LimitedCreative Survival, Creative and Adventure files");
|
||||
}
|
||||
|
||||
public void purgeDat(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
org.bukkit.OfflinePlayer player = Bukkit.getOfflinePlayer(name);
|
||||
@@ -568,7 +667,7 @@ public class AuthMe extends JavaPlugin {
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " .dat Files");
|
||||
}
|
||||
|
||||
private void purgeEssentials(List<String> cleared) {
|
||||
public void purgeEssentials(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
File playerFile = new File(this.ess.getDataFolder() + File.separator + "userdata" + File.separator + name + ".yml");
|
||||
@@ -582,7 +681,7 @@ public class AuthMe extends JavaPlugin {
|
||||
|
||||
public Location getSpawnLocation(World world) {
|
||||
Location spawnLoc = world.getSpawnLocation();
|
||||
if (multiverse != null) {
|
||||
if (multiverse != null && Settings.multiverse) {
|
||||
try {
|
||||
spawnLoc = multiverse.getMVWorldManager().getMVWorld(world).getSpawnLocation();
|
||||
} catch (NullPointerException npe) {
|
||||
@@ -597,4 +696,47 @@ public class AuthMe extends JavaPlugin {
|
||||
spawnLoc = Spawn.getInstance().getLocation();
|
||||
return spawnLoc;
|
||||
}
|
||||
|
||||
private void enableProtection() {
|
||||
ConsoleLogger.info(" This product includes GeoLite data created by MaxMind, available from http://www.maxmind.com");
|
||||
File file = new File(getDataFolder(), "GeoIP.dat");
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
String url = "http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz";
|
||||
URL downloadUrl = new URL(url);
|
||||
URLConnection conn = downloadUrl.openConnection();
|
||||
conn.setConnectTimeout(10000);
|
||||
conn.connect();
|
||||
InputStream input = conn.getInputStream();
|
||||
if (url.endsWith(".gz"))
|
||||
input = new GZIPInputStream(input);
|
||||
OutputStream output = new FileOutputStream(file);
|
||||
byte[] buffer = new byte[2048];
|
||||
int length = input.read(buffer);
|
||||
while (length >= 0) {
|
||||
output.write(buffer, 0, length);
|
||||
length = input.read(buffer);
|
||||
}
|
||||
output.close();
|
||||
input.close();
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
|
||||
public String getCountryCode(InetAddress ip) {
|
||||
try {
|
||||
if (ls == null)
|
||||
ls = new LookupService(new File(getDataFolder(), "GeoIP.dat"));
|
||||
String code = ls.getCountry(ip).getCode();
|
||||
if (code != null && !code.isEmpty())
|
||||
return code;
|
||||
} catch (Exception e) {}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void switchAntiBotMod(boolean mode) {
|
||||
this.antibotMod = mode;
|
||||
Settings.switchAntiBotMod(mode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -50,24 +50,28 @@ public class Management {
|
||||
this.pm = plugin.getServer().getPluginManager();
|
||||
}
|
||||
|
||||
public void performLogin(final Player player, final String password, final boolean passpartu) {
|
||||
public void performLogin(final Player player, final String password, final boolean passpartu, final boolean forceLogin) {
|
||||
if (passpartu) {
|
||||
// Passpartu-Login Bypasses Password-Authentication.
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new AsyncronousPasspartuLogin(player));
|
||||
new AsyncronousPasspartuLogin(player).pass();
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, new AsyncronousLogin(player, password));
|
||||
new AsyncronousLogin(player, password, forceLogin).process();
|
||||
}
|
||||
}
|
||||
|
||||
class AsyncronousLogin implements Runnable {
|
||||
class AsyncronousLogin {
|
||||
protected Player player;
|
||||
protected String name;
|
||||
protected String password;
|
||||
protected String realName;
|
||||
protected boolean forceLogin;
|
||||
|
||||
public AsyncronousLogin(Player player, String password) {
|
||||
public AsyncronousLogin(Player player, String password, boolean forceLogin) {
|
||||
this.player = player;
|
||||
this.password = password;
|
||||
name = player.getName().toLowerCase();
|
||||
realName = player.getName();
|
||||
this.forceLogin = forceLogin;
|
||||
}
|
||||
|
||||
protected String getIP() {
|
||||
@@ -87,12 +91,11 @@ public class Management {
|
||||
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"));
|
||||
if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) >= Settings.maxLoginTry) {
|
||||
plugin.cap.put(name, rdm.nextString());
|
||||
player.sendMessage("Type : /captcha " + plugin.cap.get(name));
|
||||
player.sendMessage(m._("need_captcha").replace("THE_CAPTCHA", plugin.cap.get(name)).replace("<theCaptcha>", plugin.cap.get(name)));
|
||||
return true;
|
||||
} else if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) > Settings.maxLoginTry) {
|
||||
} else if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) >= Settings.maxLoginTry) {
|
||||
try {
|
||||
plugin.captcha.remove(name);
|
||||
plugin.cap.remove(name);
|
||||
@@ -127,8 +130,7 @@ public class Management {
|
||||
return pAuth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
protected void process() {
|
||||
PlayerAuth pAuth = preAuth();
|
||||
if (pAuth == null || needsCaptcha())
|
||||
return;
|
||||
@@ -136,15 +138,16 @@ public class Management {
|
||||
String hash = pAuth.getHash();
|
||||
String email = pAuth.getEmail();
|
||||
boolean passwordVerified = true;
|
||||
try {
|
||||
passwordVerified = PasswordSecurity.comparePasswordWithHash(password, hash, name);
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
player.sendMessage(m._("error"));
|
||||
return;
|
||||
}
|
||||
if (!forceLogin)
|
||||
try {
|
||||
passwordVerified = PasswordSecurity.comparePasswordWithHash(password, hash, name);
|
||||
} catch (Exception ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
player.sendMessage(m._("error"));
|
||||
return;
|
||||
}
|
||||
if (passwordVerified && player.isOnline()) {
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, getIP(), new Date().getTime(), email);
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, getIP(), new Date().getTime(), email, realName);
|
||||
database.updateSession(auth);
|
||||
|
||||
/*
|
||||
@@ -216,13 +219,12 @@ public class Management {
|
||||
}
|
||||
}
|
||||
|
||||
class AsyncronousPasspartuLogin extends AsyncronousLogin implements Runnable {
|
||||
class AsyncronousPasspartuLogin extends AsyncronousLogin {
|
||||
public AsyncronousPasspartuLogin(Player player) {
|
||||
super(player, null);
|
||||
super(player, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
public void pass() {
|
||||
PlayerAuth pAuth = preAuth();
|
||||
if (pAuth == null)
|
||||
return;
|
||||
@@ -230,7 +232,7 @@ public class Management {
|
||||
String hash = pAuth.getHash();
|
||||
String email = pAuth.getEmail();
|
||||
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, getIP(), new Date().getTime(), email);
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, getIP(), new Date().getTime(), email, realName);
|
||||
database.updateSession(auth);
|
||||
|
||||
/*
|
||||
@@ -338,6 +340,13 @@ public class Management {
|
||||
API.setPlayerInventory(player, event.getInventory(), event.getArmor());
|
||||
}
|
||||
}
|
||||
protected void forceCommands() {
|
||||
for (String command : Settings.forceCommands) {
|
||||
try {
|
||||
player.performCommand(command.replace("%p", player.getName()));
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -386,7 +395,7 @@ public class Management {
|
||||
|
||||
// Re-Force Survival GameMode if we need due to world change specification
|
||||
if (Settings.isForceSurvivalModeEnabled)
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
Utils.forceGM(player);
|
||||
|
||||
// Cleanup no longer used temporary data
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
@@ -394,9 +403,21 @@ public class Management {
|
||||
playerCache.removeCache(name);
|
||||
}
|
||||
}
|
||||
|
||||
// We can now display the join message
|
||||
if (AuthMePlayerListener.joinMessage.containsKey(name) && AuthMePlayerListener.joinMessage.get(name) != null) {
|
||||
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (p.isOnline())
|
||||
p.sendMessage(AuthMePlayerListener.joinMessage.get(name));
|
||||
}
|
||||
}
|
||||
|
||||
// The Loginevent now fires (as intended) after everything is processed
|
||||
Bukkit.getServer().getPluginManager().callEvent(new LoginEvent(player, true));
|
||||
player.saveData();
|
||||
|
||||
// Login is now finish , we can force all commands
|
||||
forceCommands();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,11 +7,13 @@ import java.util.Random;
|
||||
import java.util.Scanner;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.events.AuthMeTeleportEvent;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
@@ -126,24 +128,28 @@ public class Utils {
|
||||
}
|
||||
});
|
||||
|
||||
id = Bukkit.getScheduler().scheduleSyncRepeatingTask(AuthMe.getInstance(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
int current = (int)pl.getLocation().getY();
|
||||
World currentWorld = pl.getWorld();
|
||||
if (current != fY && world.getName() == currentWorld.getName()) {
|
||||
pl.teleport(loc);
|
||||
}
|
||||
}
|
||||
}, 1L, 20L);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(AuthMe.getInstance(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getScheduler().cancelTask(id);
|
||||
}
|
||||
}, 60L);
|
||||
if (!PlayerCache.getInstance().isAuthenticated(pl.getName().toLowerCase())) {
|
||||
id = Bukkit.getScheduler().scheduleSyncRepeatingTask(AuthMe.getInstance(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
if (!PlayerCache.getInstance().isAuthenticated(pl.getName().toLowerCase())) {
|
||||
int current = (int)pl.getLocation().getY();
|
||||
World currentWorld = pl.getWorld();
|
||||
if (current != fY && world.getName() == currentWorld.getName()) {
|
||||
pl.teleport(loc);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 1L, 20L);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(AuthMe.getInstance(), new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run() {
|
||||
Bukkit.getScheduler().cancelTask(id);
|
||||
}
|
||||
}, 60L);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -217,6 +223,14 @@ public class Utils {
|
||||
return new String(arr);
|
||||
}
|
||||
|
||||
/*
|
||||
* Used for force player GameMode
|
||||
*/
|
||||
public static void forceGM(Player player) {
|
||||
if (!AuthMe.getInstance().authmePermissible(player, "authme.bypassforcesurvival"))
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
|
||||
public enum groupType {
|
||||
UNREGISTERED, REGISTERED, NOTLOGGEDIN, LOGGEDIN
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ public class API {
|
||||
if (isRegistered(name)) {
|
||||
return false;
|
||||
}
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0);
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0, "your@email.com", getPlayerRealName(name));
|
||||
if (!database.saveAuth(auth)) {
|
||||
return false;
|
||||
}
|
||||
@@ -154,5 +154,26 @@ public class API {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Player realName from lowerCase nickname
|
||||
* @param String playerName
|
||||
* return String player real name
|
||||
*/
|
||||
public static String getPlayerRealName(String nickname) {
|
||||
try {
|
||||
String realName = Bukkit.getOfflinePlayer(nickname).getName();
|
||||
if (realName != null && !realName.isEmpty())
|
||||
return realName;
|
||||
} catch (NullPointerException npe) {}
|
||||
return nickname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Force a player to login
|
||||
* @param Player player
|
||||
*/
|
||||
public static void forceLogin(Player player) {
|
||||
instance.management.performLogin(player, "dontneed", false, true);
|
||||
}
|
||||
}
|
||||
|
||||
+24
-32
@@ -5,10 +5,10 @@ import fr.xephi.authme.settings.Settings;
|
||||
|
||||
public class PlayerAuth {
|
||||
|
||||
private String nickname;
|
||||
private String hash;
|
||||
private String nickname = "";
|
||||
private String hash = "";
|
||||
private String ip = "198.18.0.1";
|
||||
private long lastLogin;
|
||||
private long lastLogin = 0;
|
||||
private int x = 0;
|
||||
private int y = 0;
|
||||
private int z = 0;
|
||||
@@ -17,20 +17,15 @@ public class PlayerAuth {
|
||||
private String vBhash = null;
|
||||
private int groupId;
|
||||
private String email = "your@email.com";
|
||||
private String realName = "";
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String ip, long lastLogin) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
this.lastLogin = lastLogin;
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String ip, long lastLogin, String email) {
|
||||
public PlayerAuth(String nickname, String hash, String ip, long lastLogin, String email, String realName) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
this.lastLogin = lastLogin;
|
||||
this.email = email;
|
||||
this.realName = realName;
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, int x, int y, int z, String world) {
|
||||
@@ -41,7 +36,7 @@ public class PlayerAuth {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String ip, long lastLogin, int x, int y, int z, String world, String email) {
|
||||
public PlayerAuth(String nickname, String hash, String ip, long lastLogin, int x, int y, int z, String world, String email, String realName) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
@@ -51,9 +46,10 @@ public class PlayerAuth {
|
||||
this.z = z;
|
||||
this.world = world;
|
||||
this.email = email;
|
||||
this.realName = realName;
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String salt, int groupId, String ip, long lastLogin, int x, int y, int z, String world, String email) {
|
||||
public PlayerAuth(String nickname, String hash, String salt, int groupId, String ip, long lastLogin, int x, int y, int z, String world, String email, String realName) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
@@ -64,27 +60,30 @@ public class PlayerAuth {
|
||||
this.world = world;
|
||||
this.salt = salt;
|
||||
this.groupId = groupId;
|
||||
this.email = email;
|
||||
this.email = email;
|
||||
this.realName = realName;
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String salt, int groupId , String ip, long lastLogin) {
|
||||
public PlayerAuth(String nickname, String hash, String salt, int groupId , String ip, long lastLogin, String realName) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
this.lastLogin = lastLogin;
|
||||
this.salt = salt;
|
||||
this.groupId = groupId;
|
||||
this.realName = realName;
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin) {
|
||||
public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin, String realName) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
this.lastLogin = lastLogin;
|
||||
this.salt = salt;
|
||||
this.realName = realName;
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin, int x, int y, int z, String world, String email) {
|
||||
public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin, int x, int y, int z, String world, String email, String realName) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
@@ -94,19 +93,8 @@ public class PlayerAuth {
|
||||
this.z = z;
|
||||
this.world = world;
|
||||
this.salt = salt;
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public PlayerAuth(String nickname, String hash, String ip, long lastLogin, int x, int y, int z, String world) {
|
||||
this.nickname = nickname;
|
||||
this.hash = hash;
|
||||
this.ip = ip;
|
||||
this.lastLogin = lastLogin;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
this.world = world;
|
||||
this.email = "your@email.com";
|
||||
this.email = email;
|
||||
this.realName = realName;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
@@ -118,7 +106,7 @@ public class PlayerAuth {
|
||||
}
|
||||
|
||||
public String getHash() {
|
||||
if(!salt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.MD5VB) {
|
||||
if(salt != null && !salt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.MD5VB) {
|
||||
vBhash = "$MD5vb$"+salt+"$"+hash;
|
||||
return vBhash;
|
||||
}
|
||||
@@ -208,9 +196,13 @@ public class PlayerAuth {
|
||||
@Override
|
||||
public String toString() {
|
||||
String s = "Player : " + nickname + " ! IP : " + ip + " ! LastLogin : " + lastLogin + " ! LastPosition : " + x + "," + y + "," + z + "," + world
|
||||
+ " ! Email : " + email + " ! Hash : " + hash + " ! Salt : " + salt;
|
||||
+ " ! Email : " + email + " ! Hash : " + hash + " ! Salt : " + salt + " ! RealName : " + realName;
|
||||
return s;
|
||||
|
||||
}
|
||||
|
||||
public String getRealname() {
|
||||
return realName;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ package fr.xephi.authme.cache.limbo;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.backup.FileCache;
|
||||
import fr.xephi.authme.events.ResetInventoryEvent;
|
||||
import fr.xephi.authme.events.StoreInventoryEvent;
|
||||
@@ -30,6 +30,7 @@ public class LimboCache {
|
||||
public void addLimboPlayer(Player player) {
|
||||
String name = player.getName().toLowerCase();
|
||||
Location loc = player.getLocation();
|
||||
loc.setY(loc.getY() + 0.4D);
|
||||
int gameMode = player.getGameMode().getValue();
|
||||
ItemStack[] arm;
|
||||
ItemStack[] inv;
|
||||
@@ -69,11 +70,11 @@ public class LimboCache {
|
||||
}
|
||||
|
||||
if(Settings.isForceSurvivalModeEnabled) {
|
||||
if(Settings.isResetInventoryIfCreative && gameMode != 0 ) {
|
||||
if(Settings.isResetInventoryIfCreative && player.getGameMode() == GameMode.CREATIVE ) {
|
||||
ResetInventoryEvent event = new ResetInventoryEvent(player);
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
API.setPlayerInventory(player, new ItemStack[36], new ItemStack[4]);
|
||||
player.getInventory().clear();
|
||||
player.sendMessage("Your inventory has been cleaned!");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,12 +25,14 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.Utils;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.converter.FlatToSql;
|
||||
import fr.xephi.authme.converter.FlatToSqlite;
|
||||
import fr.xephi.authme.converter.RakamakConverter;
|
||||
import fr.xephi.authme.converter.xAuthToFlat;
|
||||
import fr.xephi.authme.converter.newxAuthToFlat;
|
||||
import fr.xephi.authme.converter.oldxAuthToFlat;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
@@ -66,6 +68,8 @@ public class AdminCommand implements CommandExecutor {
|
||||
sender.sendMessage("/authme spawn - Teleport you to the AuthMe SpawnPoint");
|
||||
sender.sendMessage("/authme chgemail <playername> <email> - Change player email");
|
||||
sender.sendMessage("/authme getemail <playername> - Get player email");
|
||||
sender.sendMessage("/authme purgelastpos <playername> - Purge last position for a player");
|
||||
sender.sendMessage("/authme switchantibot on/off - Enable/Disable antibot method");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -100,7 +104,16 @@ public class AdminCommand implements CommandExecutor {
|
||||
try {
|
||||
long days = Long.parseLong(args[1]) * 86400000;
|
||||
long until = new Date().getTime() - days;
|
||||
sender.sendMessage("Deleted " + database.purgeDatabase(until) + " user accounts");
|
||||
List<String> purged = database.autoPurgeDatabase(until);
|
||||
sender.sendMessage("Deleted " + purged.size() + " user accounts");
|
||||
if (Settings.purgeEssentialsFile && plugin.ess != null)
|
||||
plugin.purgeEssentials(purged);
|
||||
if (Settings.purgePlayerDat)
|
||||
plugin.purgeDat(purged);
|
||||
if (Settings.purgeLimitedCreative)
|
||||
plugin.purgeLimitedCreative(purged);
|
||||
if (Settings.purgeAntiXray)
|
||||
plugin.purgeAntiXray(purged);
|
||||
return true;
|
||||
} catch (NumberFormatException e) {
|
||||
sender.sendMessage("Usage: /authme purge <DAYS>");
|
||||
@@ -256,24 +269,27 @@ public class AdminCommand implements CommandExecutor {
|
||||
}
|
||||
try {
|
||||
String name = args[1].toLowerCase();
|
||||
String hash = PasswordSecurity.getHash(Settings.getPasswordHash, args[2], name);
|
||||
if (database.isAuthAvailable(name)) {
|
||||
sender.sendMessage(m._("user_regged"));
|
||||
return true;
|
||||
}
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0);
|
||||
auth.setSalt(PasswordSecurity.userSalt.get(name));
|
||||
String hash = PasswordSecurity.getHash(Settings.getPasswordHash, args[2], name);
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0L, "your@email.com", API.getPlayerRealName(name));
|
||||
if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null)
|
||||
auth.setSalt(PasswordSecurity.userSalt.get(name));
|
||||
else
|
||||
auth.setSalt("");
|
||||
if (!database.saveAuth(auth)) {
|
||||
sender.sendMessage(m._("error"));
|
||||
return true;
|
||||
}
|
||||
database.updateSalt(auth);
|
||||
sender.sendMessage(m._("registered"));
|
||||
ConsoleLogger.info(args[1] + " registered");
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
sender.sendMessage(m._("error"));
|
||||
}
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("convertflattosql")) {
|
||||
try {
|
||||
FlatToSql.FlatToSqlConverter();
|
||||
@@ -294,13 +310,22 @@ public class AdminCommand implements CommandExecutor {
|
||||
} catch (NullPointerException ex) {
|
||||
System.out.println(ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("xauthimport")) {
|
||||
xAuthToFlat converter = new xAuthToFlat(plugin, database);
|
||||
if (converter.convert(sender)) {
|
||||
sender.sendMessage("[AuthMe] Successfull convert from xAuth database");
|
||||
} else {
|
||||
sender.sendMessage("[AuthMe] Error while trying to convert from xAuth database");
|
||||
}
|
||||
try {
|
||||
Class.forName("com.cypherx.xauth.xAuth");
|
||||
oldxAuthToFlat converter = new oldxAuthToFlat(plugin, database, sender);
|
||||
converter.run();
|
||||
} catch (ClassNotFoundException e) {
|
||||
try {
|
||||
Class.forName("de.luricos.bukkit.xAuth.xAuth");
|
||||
newxAuthToFlat converter = new newxAuthToFlat(plugin, database, sender);
|
||||
converter.run();
|
||||
} catch (ClassNotFoundException ce) {
|
||||
sender.sendMessage("[AuthMe] No version of xAuth found or xAuth isn't enable! ");
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("getemail")) {
|
||||
if (args.length != 2) {
|
||||
sender.sendMessage("Usage: /authme getemail playername");
|
||||
@@ -343,6 +368,7 @@ public class AdminCommand implements CommandExecutor {
|
||||
} catch (NullPointerException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("setspawn")) {
|
||||
try {
|
||||
if (sender instanceof Player) {
|
||||
@@ -355,6 +381,7 @@ public class AdminCommand implements CommandExecutor {
|
||||
} catch (NullPointerException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("purgebannedplayers")) {
|
||||
List<String> bannedPlayers = new ArrayList<String>();
|
||||
for (OfflinePlayer off : plugin.getServer().getBannedPlayers()) {
|
||||
@@ -371,6 +398,15 @@ public class AdminCommand implements CommandExecutor {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (Settings.purgeEssentialsFile && plugin.ess != null)
|
||||
plugin.purgeEssentials(bannedPlayers);
|
||||
if (Settings.purgePlayerDat)
|
||||
plugin.purgeDat(bannedPlayers);
|
||||
if (Settings.purgeLimitedCreative)
|
||||
plugin.purgeLimitedCreative(bannedPlayers);
|
||||
if (Settings.purgeAntiXray)
|
||||
plugin.purgeAntiXray(bannedPlayers);
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("spawn")) {
|
||||
try {
|
||||
if (sender instanceof Player) {
|
||||
@@ -383,6 +419,7 @@ public class AdminCommand implements CommandExecutor {
|
||||
} catch (NullPointerException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
}
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("changepassword") || args[0].equalsIgnoreCase("cp")) {
|
||||
if (args.length != 3) {
|
||||
sender.sendMessage("Usage: /authme changepassword playername newpassword");
|
||||
@@ -413,6 +450,7 @@ public class AdminCommand implements CommandExecutor {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
sender.sendMessage(m._("error"));
|
||||
}
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("unregister") || args[0].equalsIgnoreCase("unreg") || args[0].equalsIgnoreCase("del") ) {
|
||||
if (args.length != 2) {
|
||||
sender.sendMessage("Usage: /authme unregister playername");
|
||||
@@ -426,6 +464,49 @@ public class AdminCommand implements CommandExecutor {
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
sender.sendMessage("unregistered");
|
||||
ConsoleLogger.info(args[1] + " unregistered");
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("purgelastpos")){
|
||||
if (args.length != 2) {
|
||||
sender.sendMessage("Usage: /authme purgelastpos playername");
|
||||
return true;
|
||||
}
|
||||
try {
|
||||
String name = args[1].toLowerCase();
|
||||
PlayerAuth auth = database.getAuth(name);
|
||||
if (auth == null) {
|
||||
sender.sendMessage("The player " + name + " is not registered ");
|
||||
return true;
|
||||
}
|
||||
auth.setQuitLocX(0);
|
||||
auth.setQuitLocY(0);
|
||||
auth.setQuitLocZ(0);
|
||||
auth.setWorld("world");
|
||||
database.updateQuitLoc(auth);
|
||||
sender.sendMessage(name + " 's last pos location is now reset");
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.showError("An error occured while trying to reset location or player do not exist, please see below: ");
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
if (sender instanceof Player)
|
||||
sender.sendMessage("An error occured while trying to reset location or player do not exist, please see logs");
|
||||
}
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("switchantibot")) {
|
||||
if (args.length != 2) {
|
||||
sender.sendMessage("Usage : /authme switchantibot on/off");
|
||||
return true;
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("on")) {
|
||||
plugin.switchAntiBotMod(true);
|
||||
sender.sendMessage("[AuthMe] AntiBotMod enabled");
|
||||
return true;
|
||||
}
|
||||
if (args[1].equalsIgnoreCase("off")) {
|
||||
plugin.switchAntiBotMod(false);
|
||||
sender.sendMessage("[AuthMe] AntiBotMod disabled");
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage("Usage : /authme switchantibot on/off");
|
||||
return true;
|
||||
} else {
|
||||
sender.sendMessage("Usage: /authme reload|register playername password|changepassword playername password|unregister playername");
|
||||
}
|
||||
|
||||
@@ -59,7 +59,10 @@ public class ChangePasswordCommand implements CommandExecutor {
|
||||
if (PasswordSecurity.comparePasswordWithHash(args[0], PlayerCache.getInstance().getAuth(name).getHash(), name)) {
|
||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
||||
auth.setHash(hashnew);
|
||||
auth.setSalt(PasswordSecurity.userSalt.get(name));
|
||||
if (PasswordSecurity.userSalt.containsKey(name) && PasswordSecurity.userSalt.get(name) != null)
|
||||
auth.setSalt(PasswordSecurity.userSalt.get(name));
|
||||
else
|
||||
auth.setSalt("");
|
||||
if (!database.updatePassword(auth)) {
|
||||
player.sendMessage(m._("error"));
|
||||
return true;
|
||||
|
||||
@@ -35,7 +35,7 @@ public class LoginCommand implements CommandExecutor {
|
||||
player.sendMessage(m._("no_perm"));
|
||||
return true;
|
||||
}
|
||||
plugin.management.performLogin(player, args[0], false);
|
||||
plugin.management.performLogin(player, args[0], false, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,18 +65,14 @@ public class LogoutCommand implements CommandExecutor {
|
||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
||||
auth.setIp("198.18.0.1");
|
||||
database.updateSession(auth);
|
||||
auth.setQuitLocX(player.getLocation().getBlockX());
|
||||
auth.setQuitLocY(player.getLocation().getBlockY());
|
||||
auth.setQuitLocZ(player.getLocation().getBlockZ());
|
||||
auth.setWorld(player.getWorld().getName());
|
||||
database.updateQuitLoc(auth);
|
||||
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
|
||||
LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
|
||||
LimboCache.getInstance().addLimboPlayer(player);
|
||||
if(Settings.protectInventoryBeforeLogInEnabled) {
|
||||
player.getInventory().setArmorContents(new ItemStack[4]);
|
||||
player.getInventory().setContents(new ItemStack[36]);
|
||||
// create cache file for handling lost of inventories on unlogged in status
|
||||
DataFileCache playerData = new DataFileCache(player.getInventory().getContents(),player.getInventory().getArmorContents());
|
||||
playerBackup.createCache(name, playerData, LimboCache.getInstance().getLimboPlayer(name).getGroup(),LimboCache.getInstance().getLimboPlayer(name).getOperator(),LimboCache.getInstance().getLimboPlayer(name).isFlying());
|
||||
}
|
||||
if (Settings.isTeleportToSpawnEnabled) {
|
||||
Location spawnLoc = player.getWorld().getSpawnLocation();
|
||||
if (plugin.essentialsSpawn != null) {
|
||||
@@ -94,6 +90,17 @@ public class LogoutCommand implements CommandExecutor {
|
||||
}
|
||||
}
|
||||
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name))
|
||||
LimboCache.getInstance().deleteLimboPlayer(name);
|
||||
LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
|
||||
LimboCache.getInstance().addLimboPlayer(player);
|
||||
if(Settings.protectInventoryBeforeLogInEnabled) {
|
||||
player.getInventory().clear();
|
||||
// create cache file for handling lost of inventories on unlogged in status
|
||||
DataFileCache playerData = new DataFileCache(LimboCache.getInstance().getLimboPlayer(name).getInventory(),LimboCache.getInstance().getLimboPlayer(name).getArmour());
|
||||
playerBackup.createCache(name, playerData, LimboCache.getInstance().getLimboPlayer(name).getGroup(),LimboCache.getInstance().getLimboPlayer(name).getOperator(),LimboCache.getInstance().getLimboPlayer(name).isFlying());
|
||||
}
|
||||
|
||||
int delay = Settings.getRegistrationTimeout * 20;
|
||||
int interval = Settings.getWarnMessageInterval;
|
||||
BukkitScheduler sched = sender.getServer().getScheduler();
|
||||
|
||||
@@ -18,7 +18,7 @@ import fr.xephi.authme.settings.Messages;
|
||||
public class PasspartuCommand implements CommandExecutor {
|
||||
private Utils utils = new Utils();
|
||||
public AuthMe plugin;
|
||||
private Messages m;
|
||||
private Messages m = Messages.getInstance();
|
||||
|
||||
public PasspartuCommand(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
@@ -39,7 +39,7 @@ public class PasspartuCommand implements CommandExecutor {
|
||||
if ((sender instanceof Player) && args.length == 1) {
|
||||
if(utils.readToken(args[0])) {
|
||||
//bypass login!
|
||||
plugin.management.performLogin((Player) sender, "dontneed", true);
|
||||
plugin.management.performLogin((Player) sender, "dontneed", true, false);
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage("Time is expired or Token is Wrong!");
|
||||
|
||||
@@ -126,7 +126,7 @@ public class RegisterCommand implements CommandExecutor {
|
||||
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);
|
||||
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, player.getName());
|
||||
database.saveAuth(fAuth);
|
||||
database.updateEmail(fAuth);
|
||||
database.updateSession(fAuth);
|
||||
@@ -137,7 +137,7 @@ public class RegisterCommand implements CommandExecutor {
|
||||
} 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);
|
||||
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, player.getName());
|
||||
database.saveAuth(fAuth);
|
||||
database.updateEmail(fAuth);
|
||||
database.updateSession(fAuth);
|
||||
@@ -216,9 +216,9 @@ public class RegisterCommand implements CommandExecutor {
|
||||
hash = PasswordSecurity.getHash(Settings.getPasswordHash, args[0], name);
|
||||
if (Settings.getMySQLColumnSalt.isEmpty())
|
||||
{
|
||||
auth = new PlayerAuth(name, hash, ip, new Date().getTime());
|
||||
auth = new PlayerAuth(name, hash, ip, new Date().getTime(), "your@email.com", player.getName());
|
||||
} else {
|
||||
auth = new PlayerAuth(name, hash, PasswordSecurity.userSalt.get(name), ip, new Date().getTime());
|
||||
auth = new PlayerAuth(name, hash, PasswordSecurity.userSalt.get(name), ip, new Date().getTime(), player.getName());
|
||||
}
|
||||
if (!database.saveAuth(auth)) {
|
||||
player.sendMessage(m._("error"));
|
||||
|
||||
@@ -77,6 +77,8 @@ public class FlatToSql {
|
||||
newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", 'world', 'your@email.com');";
|
||||
else if (args.length == 8)
|
||||
newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", '" + args[7] + "', 'your@email.com');";
|
||||
else if (args.length == 9)
|
||||
newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", '" + args[7] + "', '" + args[8] + "');";
|
||||
else
|
||||
newline = "";
|
||||
if (newline != "")
|
||||
|
||||
@@ -73,6 +73,8 @@ public class FlatToSqlite {
|
||||
newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", 'world', 'your@email.com');";
|
||||
else if (args.length == 8)
|
||||
newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", '" + args[7] + "', 'your@email.com');";
|
||||
else if (args.length == 9)
|
||||
newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", '" + args[7] + "', '" + args[8] + "');";
|
||||
else
|
||||
newline = "";
|
||||
if (newline != "")
|
||||
|
||||
@@ -94,12 +94,12 @@ public class RakamakConverter {
|
||||
String player = m.getKey();
|
||||
String psw = playerPSW.get(player);
|
||||
String ip = playerIP.get(player);
|
||||
newLine = player + ":" + psw + ":" + ip + ":1325376060:0:0:0";
|
||||
newLine = player + ":" + psw + ":" + ip + ":1325376060:0:0:0:world:your@email.com";
|
||||
} else {
|
||||
String player = m.getKey();
|
||||
String psw = playerPSW.get(player);
|
||||
String ip = "127.0.0.1";
|
||||
newLine = player + ":" + psw + ":" + ip + ":1325376060:0:0:0";
|
||||
newLine = player + ":" + psw + ":" + ip + ":1325376060:0:0:0:world:your@email.com";
|
||||
}
|
||||
if (alreadyExist) outputDB.newLine();
|
||||
outputDB.write(newLine);
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import de.luricos.bukkit.xAuth.xAuth;
|
||||
import de.luricos.bukkit.xAuth.database.Table;
|
||||
import de.luricos.bukkit.xAuth.utils.xAuthLog;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
|
||||
public class newxAuthToFlat extends Thread {
|
||||
|
||||
public AuthMe instance;
|
||||
public DataSource database;
|
||||
public CommandSender sender;
|
||||
|
||||
public newxAuthToFlat(AuthMe instance, DataSource database, CommandSender sender) {
|
||||
this.instance = instance;
|
||||
this.database = database;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
convert();
|
||||
if (isAlive())
|
||||
interrupt();
|
||||
}
|
||||
|
||||
public boolean convert() {
|
||||
if (instance.getServer().getPluginManager().getPlugin("xAuth") == null) {
|
||||
sender.sendMessage("[AuthMe] xAuth plugin not found");
|
||||
return false;
|
||||
}
|
||||
if (!(new File("./plugins/xAuth/xAuth.h2.db").exists())) {
|
||||
sender.sendMessage("[AuthMe] xAuth H2 database not found, checking for MySQL or SQLite data...");
|
||||
}
|
||||
List<Integer> players = getXAuthPlayers();
|
||||
if (players == null || players.isEmpty()) {
|
||||
sender.sendMessage("[AuthMe] Error while import xAuthPlayers");
|
||||
return false;
|
||||
}
|
||||
sender.sendMessage("[AuthMe] Starting import...");
|
||||
try {
|
||||
for (int id : players) {
|
||||
String pl = getIdPlayer(id);
|
||||
String psw = getPassword(id);
|
||||
if (psw != null && !psw.isEmpty() && pl != null) {
|
||||
PlayerAuth auth = new PlayerAuth(pl, psw, "198.18.0.1", 0, "your@email.com", API.getPlayerRealName(pl));
|
||||
database.saveAuth(auth);
|
||||
}
|
||||
}
|
||||
sender.sendMessage("[AuthMe] Successfull convert from xAuth database");
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage("[AuthMe] An error has been thrown while import xAuth database, the import hadn't fail but can be not complete ");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getIdPlayer(int id) {
|
||||
String realPass = "";
|
||||
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
String sql = String.format("SELECT `playername` FROM `%s` WHERE `id` = ?",
|
||||
xAuth.getPlugin().getDatabaseController().getTable(Table.ACCOUNT));
|
||||
ps = conn.prepareStatement(sql);
|
||||
ps.setInt(1, id);
|
||||
rs = ps.executeQuery();
|
||||
if (!rs.next())
|
||||
return null;
|
||||
realPass = rs.getString("playername").toLowerCase();
|
||||
} catch (SQLException e) {
|
||||
xAuthLog.severe("Failed to retrieve name for account: " + id, e);
|
||||
return null;
|
||||
} finally {
|
||||
xAuth.getPlugin().getDatabaseController().close(conn, ps, rs);
|
||||
}
|
||||
return realPass;
|
||||
}
|
||||
|
||||
public List<Integer> getXAuthPlayers() {
|
||||
List<Integer> xP = new ArrayList<Integer>();
|
||||
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
String sql = String.format("SELECT * FROM `%s`",
|
||||
xAuth.getPlugin().getDatabaseController().getTable(Table.ACCOUNT));
|
||||
ps = conn.prepareStatement(sql);
|
||||
rs = ps.executeQuery();
|
||||
while(rs.next()) {
|
||||
xP.add(rs.getInt("id"));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
xAuthLog.severe("Cannot import xAuthPlayers", e);
|
||||
return new ArrayList<Integer>();
|
||||
} finally {
|
||||
xAuth.getPlugin().getDatabaseController().close(conn, ps, rs);
|
||||
}
|
||||
return xP;
|
||||
}
|
||||
|
||||
public String getPassword(int accountId) {
|
||||
String realPass = "";
|
||||
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
try {
|
||||
String sql = String.format("SELECT `password`, `pwtype` FROM `%s` WHERE `id` = ?",
|
||||
xAuth.getPlugin().getDatabaseController().getTable(Table.ACCOUNT));
|
||||
ps = conn.prepareStatement(sql);
|
||||
ps.setInt(1, accountId);
|
||||
rs = ps.executeQuery();
|
||||
if (!rs.next())
|
||||
return null;
|
||||
realPass = rs.getString("password");
|
||||
} catch (SQLException e) {
|
||||
xAuthLog.severe("Failed to retrieve password hash for account: " + accountId, e);
|
||||
return null;
|
||||
} finally {
|
||||
xAuth.getPlugin().getDatabaseController().close(conn, ps, rs);
|
||||
}
|
||||
return realPass;
|
||||
}
|
||||
}
|
||||
+23
-10
@@ -15,6 +15,7 @@ import com.cypherx.xauth.database.Table;
|
||||
import com.cypherx.xauth.utils.xAuthLog;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
|
||||
@@ -23,17 +24,25 @@ import fr.xephi.authme.datasource.DataSource;
|
||||
*
|
||||
* @author Xephi59
|
||||
*/
|
||||
public class xAuthToFlat {
|
||||
public class oldxAuthToFlat extends Thread {
|
||||
|
||||
public AuthMe instance;
|
||||
public DataSource database;
|
||||
public CommandSender sender;
|
||||
|
||||
public xAuthToFlat(AuthMe instance, DataSource database) {
|
||||
public oldxAuthToFlat(AuthMe instance, DataSource database, CommandSender sender) {
|
||||
this.instance = instance;
|
||||
this.database = database;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
convert();
|
||||
if (isAlive())
|
||||
interrupt();
|
||||
}
|
||||
|
||||
public boolean convert(CommandSender sender) {
|
||||
public boolean convert() {
|
||||
if (instance.getServer().getPluginManager().getPlugin("xAuth") == null) {
|
||||
sender.sendMessage("[AuthMe] xAuth plugin not found");
|
||||
return false;
|
||||
@@ -47,15 +56,19 @@ public class xAuthToFlat {
|
||||
return false;
|
||||
}
|
||||
sender.sendMessage("[AuthMe] Starting import...");
|
||||
for (int id : players) {
|
||||
String pl = getIdPlayer(id);
|
||||
String psw = getPassword(id);
|
||||
if (psw != null && !psw.isEmpty() && pl != null) {
|
||||
PlayerAuth auth = new PlayerAuth(pl, psw, "198.18.0.1", 0);
|
||||
database.saveAuth(auth);
|
||||
try {
|
||||
for (int id : players) {
|
||||
String pl = getIdPlayer(id);
|
||||
String psw = getPassword(id);
|
||||
if (psw != null && !psw.isEmpty() && pl != null) {
|
||||
PlayerAuth auth = new PlayerAuth(pl, psw, "198.18.0.1", 0, "your@email.com", API.getPlayerRealName(pl));
|
||||
database.saveAuth(auth);
|
||||
}
|
||||
}
|
||||
sender.sendMessage("[AuthMe] Successfull convert from xAuth database");
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage("[AuthMe] An error has been thrown while import xAuth database, the import hadn't fail but can be not complete ");
|
||||
}
|
||||
sender.sendMessage("[AuthMe] Import done!");
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
@@ -19,9 +20,10 @@ public class FileDataSource implements DataSource {
|
||||
|
||||
/* file layout:
|
||||
*
|
||||
* PLAYERNAME:HASHSUM:IP:LOGININMILLIESECONDS:LASTPOSX:LASTPOSY:LASTPOSZ:LASTPOSWORLD
|
||||
* PLAYERNAME:HASHSUM:IP:LOGININMILLIESECONDS:LASTPOSX:LASTPOSY:LASTPOSZ:LASTPOSWORLD:EMAIL
|
||||
*
|
||||
* Old but compatible:
|
||||
* PLAYERNAME:HASHSUM:IP:LOGININMILLIESECONDS:LASTPOSX:LASTPOSY:LASTPOSZ:LASTPOSWORLD
|
||||
* PLAYERNAME:HASHSUM:IP:LOGININMILLIESECONDS
|
||||
* PLAYERNAME:HASHSUM:IP
|
||||
* PLAYERNAME:HASHSUM
|
||||
@@ -71,7 +73,7 @@ public class FileDataSource implements DataSource {
|
||||
BufferedWriter bw = null;
|
||||
try {
|
||||
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");
|
||||
bw.write(auth.getNickname() + ":" + auth.getHash() + ":" + auth.getIp() + ":" + auth.getLastLogin() + ":" + auth.getQuitLocX() + ":" + auth.getQuitLocY() + ":" + auth.getQuitLocZ() + ":" + auth.getWorld() + ":" + auth.getEmail() + "\n");
|
||||
} catch (IOException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
@@ -101,19 +103,23 @@ public class FileDataSource implements DataSource {
|
||||
if (args[0].equals(auth.getNickname())) {
|
||||
switch (args.length) {
|
||||
case 4: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), 0, 0, 0, "world");
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), 0, 0, 0, "world", "your@email.com", API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), "world");
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), "world", "your@email.com", API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), args[7]);
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), args[7], "your@email.com", API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
case 9: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), args[7], args[8], API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], 0, 0, 0, 0, "world");
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], 0, 0, 0, 0, "world", "your@email.com", API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -154,19 +160,23 @@ public class FileDataSource implements DataSource {
|
||||
if (args[0].equals(auth.getNickname())) {
|
||||
switch (args.length) {
|
||||
case 4: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world");
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world", "your@email.com", API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), "world");
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), "world", "your@email.com", API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), args[7]);
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), args[7], "your@email.com", API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
case 9: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), args[7], args[8], API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world");
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world", "your@email.com", API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -205,7 +215,7 @@ public class FileDataSource implements DataSource {
|
||||
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());
|
||||
newAuth = new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), auth.getEmail(), API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -407,15 +417,17 @@ public class FileDataSource implements DataSource {
|
||||
if (args[0].equals(user)) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
return new PlayerAuth(args[0], args[1], "198.18.0.1", 0);
|
||||
return new PlayerAuth(args[0], args[1], "198.18.0.1", 0, "your@email.com", API.getPlayerRealName(args[0]));
|
||||
case 3:
|
||||
return new PlayerAuth(args[0], args[1], args[2], 0);
|
||||
return new PlayerAuth(args[0], args[1], args[2], 0, "your@email.com", API.getPlayerRealName(args[0]));
|
||||
case 4:
|
||||
return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]));
|
||||
return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), "your@email.com", API.getPlayerRealName(args[0]));
|
||||
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");
|
||||
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", "your@email.com", API.getPlayerRealName(args[0]));
|
||||
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]);
|
||||
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], "your@email.com", API.getPlayerRealName(args[0]));
|
||||
case 9:
|
||||
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], args[8], API.getPlayerRealName(args[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -446,7 +458,38 @@ public class FileDataSource implements DataSource {
|
||||
|
||||
@Override
|
||||
public boolean updateEmail(PlayerAuth auth) {
|
||||
return false;
|
||||
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]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), args[7], auth.getEmail(), API.getPlayerRealName(args[0]));
|
||||
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
|
||||
@@ -511,12 +554,37 @@ public class FileDataSource implements DataSource {
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllAuthsByEmail(String email) {
|
||||
return new ArrayList<String>();
|
||||
BufferedReader br = null;
|
||||
List<String> countEmail = new ArrayList<String>();
|
||||
try {
|
||||
br = new BufferedReader(new FileReader(source));
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] args = line.split(":");
|
||||
if (args.length > 8 && args[8].equals(email)) {
|
||||
countEmail.add(args[0]);
|
||||
}
|
||||
}
|
||||
return countEmail;
|
||||
} 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
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.MiniConnectionPoolManager.TimeoutException;
|
||||
import fr.xephi.authme.security.HashAlgorithm;
|
||||
@@ -177,14 +178,14 @@ public class MySQLDataSource implements DataSource {
|
||||
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));
|
||||
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), API.getPlayerRealName(rs.getString(columnName)));
|
||||
} 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));
|
||||
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), API.getPlayerRealName(rs.getString(columnName)));
|
||||
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), API.getPlayerRealName(rs.getString(columnName)));
|
||||
} 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));
|
||||
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), API.getPlayerRealName(rs.getString(columnName)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -209,7 +210,7 @@ public class MySQLDataSource implements DataSource {
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
con = makeSureConnectionIsReady();
|
||||
if ((columnSalt.isEmpty() || columnSalt == null) && (auth.getSalt().isEmpty() || auth.getSalt() == null)) {
|
||||
if ((columnSalt == null || columnSalt.isEmpty()) && (auth.getSalt() == null || auth.getSalt().isEmpty())) {
|
||||
pst = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + ") VALUES (?,?,?,?);");
|
||||
pst.setString(1, auth.getNickname());
|
||||
pst.setString(2, auth.getHash());
|
||||
@@ -227,8 +228,8 @@ public class MySQLDataSource implements DataSource {
|
||||
}
|
||||
if (!columnOthers.isEmpty()) {
|
||||
for(String column : columnOthers) {
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + tableName + "." + column + "=? WHERE " + columnName + "=?;");
|
||||
pst.setString(1, auth.getNickname());
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + column + "=? WHERE " + columnName + "=?;");
|
||||
pst.setString(1, auth.getRealname());
|
||||
pst.setString(2, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
}
|
||||
@@ -241,12 +242,30 @@ public class MySQLDataSource implements DataSource {
|
||||
rs = pst.executeQuery();
|
||||
if (rs.next()) {
|
||||
id = rs.getInt(columnID);
|
||||
// Insert player in phpbb_user_group
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getPhpbbPrefix + "user_group (group_id, user_id, group_leader, user_pending) VALUES (?,?,?,?);");
|
||||
pst.setInt(1, Settings.getPhpbbGroup);
|
||||
pst.setInt(2, id);
|
||||
pst.setInt(3, 0);
|
||||
pst.setInt(4, 0);
|
||||
pst.executeUpdate();
|
||||
// Update player group in phpbb_users
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + tableName + ".group_id=? WHERE " + columnName + "=?;");
|
||||
pst.setInt(1, Settings.getPhpbbGroup);
|
||||
pst.setString(2, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
// Get current time without ms
|
||||
long time = System.currentTimeMillis()/1000;
|
||||
// Update user_regdate
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + tableName + ".user_regdate=? WHERE " + columnName + "=?;");
|
||||
pst.setLong(1, time);
|
||||
pst.setString(2, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
// Update user_lastvisit
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + tableName + ".user_lastvisit=? WHERE " + columnName + "=?;");
|
||||
pst.setLong(1, time);
|
||||
pst.setString(2, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
}
|
||||
}
|
||||
if (Settings.getPasswordHash == HashAlgorithm.WORDPRESS) {
|
||||
@@ -426,6 +445,9 @@ public class MySQLDataSource implements DataSource {
|
||||
while (rs.next()) {
|
||||
list.add(rs.getString(columnName));
|
||||
}
|
||||
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnLastLogin + "<?;");
|
||||
pst.setLong(1, until);
|
||||
pst.executeUpdate();
|
||||
return list;
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
|
||||
@@ -7,6 +7,7 @@ import java.util.List;
|
||||
import org.sqlite.*;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.MiniConnectionPoolManager.TimeoutException;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
@@ -147,12 +148,12 @@ public class SqliteDataSource implements DataSource {
|
||||
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));
|
||||
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), API.getPlayerRealName(rs.getString(columnName)));
|
||||
} 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));
|
||||
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), API.getPlayerRealName(rs.getString(columnName)));
|
||||
} 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));
|
||||
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), API.getPlayerRealName(rs.getString(columnName)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -41,4 +41,8 @@ public class LoginEvent extends Event {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,4 +41,8 @@ public class PasswordEncryptionEvent extends Event {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ public class LoginScreen extends GenericPopup implements Clickable{
|
||||
if (event.isCancelled() || event == null || event.getPlayer() == null) return;
|
||||
if (b.equals(loginBtn))
|
||||
{
|
||||
plugin.management.performLogin(player, passBox.getText(), false);
|
||||
plugin.management.performLogin(player, passBox.getText(), false, false);
|
||||
}else if(b.equals(exitBtn))
|
||||
{
|
||||
event.getPlayer().kickPlayer(exitMsg);
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.Utils;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
@@ -16,9 +17,11 @@ import fr.xephi.authme.settings.Settings;
|
||||
|
||||
public class AuthMeBungeeCordListener implements Listener {
|
||||
private DataSource data;
|
||||
private AuthMe plugin;
|
||||
|
||||
public AuthMeBungeeCordListener(DataSource data) {
|
||||
this.data = data;
|
||||
public AuthMeBungeeCordListener(DataSource data, AuthMe plugin) {
|
||||
this.data = data;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
@@ -27,9 +30,20 @@ public class AuthMeBungeeCordListener implements Listener {
|
||||
if (event.isCancelled()) return;
|
||||
if (!event.isCommand()) return;
|
||||
Player player = null;
|
||||
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (p.getAddress().getAddress().equals(event.getReceiver().getAddress().getAddress())) {
|
||||
player = p;
|
||||
try {
|
||||
for (String p : plugin.realIp.keySet()) {
|
||||
Player pl = Bukkit.getPlayer(p);
|
||||
if (pl != null) {
|
||||
if (plugin.realIp.get(p).equalsIgnoreCase(event.getSender().getAddress().getAddress().getHostAddress()))
|
||||
player = pl;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
if (player == null) {
|
||||
for (Player p : Bukkit.getServer().getOnlinePlayers()) {
|
||||
if (p.getAddress().getAddress().equals(event.getSender().getAddress().getAddress())) {
|
||||
player = p;
|
||||
}
|
||||
}
|
||||
}
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
@@ -65,11 +66,14 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
public static int gm = 0;
|
||||
public static HashMap<String, Integer> gameMode = new HashMap<String, Integer>();
|
||||
public static HashMap<String, String> joinMessage = new HashMap<String, String>();
|
||||
private Utils utils = Utils.getInstance();
|
||||
private Messages m = Messages.getInstance();
|
||||
public AuthMe plugin;
|
||||
private DataSource data;
|
||||
private FileCache playerBackup = new FileCache();
|
||||
public boolean causeByAuthMe = false;
|
||||
private HashMap<String, PlayerLoginEvent> antibot = new HashMap<String, PlayerLoginEvent>();
|
||||
|
||||
public AuthMePlayerListener(AuthMe plugin, DataSource data) {
|
||||
this.plugin = plugin;
|
||||
@@ -384,6 +388,21 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Settings.enableProtection && !Settings.countries.isEmpty()) {
|
||||
String code = plugin.getCountryCode(event.getAddress());
|
||||
if (((code == null) || (!Settings.countries.contains(code) && !API.isRegistered(name))) && !plugin.authmePermissible(player, "authme.bypassantibot")) {
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("country_banned"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (Settings.isKickNonRegisteredEnabled) {
|
||||
if (!data.isAuthAvailable(name)) {
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("reg_only"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (player.isOnline() && Settings.isForceSingleSessionEnabled) {
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("same_nick"));
|
||||
return;
|
||||
@@ -442,11 +461,19 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
if (Settings.isKickNonRegisteredEnabled) {
|
||||
if (!data.isAuthAvailable(name)) {
|
||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("reg_only"));
|
||||
return;
|
||||
if (event.getResult() == PlayerLoginEvent.Result.ALLOWED) {
|
||||
checkAntiBotMod(event);
|
||||
if (Settings.bungee) {
|
||||
final ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(b);
|
||||
|
||||
try {
|
||||
out.writeUTF("IP");
|
||||
} catch (IOException e) {
|
||||
}
|
||||
player.sendPluginMessage(plugin, "BungeeCord", b.toByteArray());
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (event.getResult() != PlayerLoginEvent.Result.KICK_FULL) return;
|
||||
if (player.isBanned()) return;
|
||||
@@ -467,34 +494,38 @@ public class AuthMePlayerListener implements Listener {
|
||||
} else {
|
||||
ConsoleLogger.info("The player " + player.getName() + " wants to join, but the server is full");
|
||||
event.disallow(Result.KICK_FULL, m._("kick_fullserver"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onPlayerLowestJoin(PlayerJoinEvent event) {
|
||||
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) {
|
||||
final ByteArrayOutputStream b = new ByteArrayOutputStream();
|
||||
DataOutputStream out = new DataOutputStream(b);
|
||||
|
||||
try {
|
||||
out.writeUTF("IP");
|
||||
} catch (IOException e) {
|
||||
}
|
||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.sendPluginMessage(plugin, "BungeeCord", b.toByteArray());
|
||||
}
|
||||
});
|
||||
}
|
||||
private void checkAntiBotMod(final PlayerLoginEvent event) {
|
||||
if (plugin.delayedAntiBot || plugin.antibotMod)
|
||||
return;
|
||||
if (plugin.authmePermissible(event.getPlayer(), "authme.bypassantibot"))
|
||||
return;
|
||||
if (antibot.keySet().size() > Settings.antiBotSensibility) {
|
||||
plugin.switchAntiBotMod(true);
|
||||
Bukkit.broadcastMessage(m._("antibot_auto_enabled"));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin.antibotMod) {
|
||||
plugin.switchAntiBotMod(false);
|
||||
antibot.clear();
|
||||
Bukkit.broadcastMessage(m._("antibot_auto_disabled").replace("%m", "" + Settings.antiBotDuration));
|
||||
}
|
||||
}
|
||||
}, Settings.antiBotDuration * 1200);
|
||||
return;
|
||||
}
|
||||
antibot.put(event.getPlayer().getName().toLowerCase(), event);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable(){
|
||||
@Override
|
||||
public void run() {
|
||||
antibot.remove(event.getPlayer().getName().toLowerCase());
|
||||
}
|
||||
}, 300);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@@ -510,14 +541,16 @@ public class AuthMePlayerListener implements Listener {
|
||||
final String name = player.getName().toLowerCase();
|
||||
gameMode.put(name, gm);
|
||||
BukkitScheduler sched = plugin.getServer().getScheduler();
|
||||
final PlayerJoinEvent e = event;
|
||||
|
||||
if (plugin.getCitizensCommunicator().isNPC(player, plugin) || Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (plugin.ess != null && Settings.disableSocialSpy)
|
||||
plugin.ess.getUser(player.getName()).setSocialSpyEnabled(false);
|
||||
if (plugin.ess != null && Settings.disableSocialSpy) {
|
||||
try {
|
||||
plugin.ess.getUser(player.getName()).setSocialSpyEnabled(false);
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
|
||||
String ip = player.getAddress().getAddress().getHostAddress();
|
||||
if (Settings.bungee) {
|
||||
@@ -526,7 +559,9 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
if(Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) {
|
||||
int gM = gameMode.get(name);
|
||||
this.causeByAuthMe = true;
|
||||
player.setGameMode(GameMode.getByValue(gM));
|
||||
this.causeByAuthMe = false;
|
||||
player.kickPlayer("You are not the Owner of this account, please try another name!");
|
||||
if (Settings.banUnsafeIp)
|
||||
plugin.getServer().banIP(ip);
|
||||
@@ -550,22 +585,25 @@ public class AuthMePlayerListener implements Listener {
|
||||
return;
|
||||
} else if (!Settings.sessionExpireOnIpChange){
|
||||
int gM = gameMode.get(name);
|
||||
this.causeByAuthMe = true;
|
||||
player.setGameMode(GameMode.getByValue(gM));
|
||||
this.causeByAuthMe = false;
|
||||
player.kickPlayer(m._("unvalid_session"));
|
||||
return;
|
||||
} else if (auth.getNickname().equalsIgnoreCase(name)){
|
||||
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin)
|
||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
e.getPlayer().setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
});
|
||||
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
|
||||
this.causeByAuthMe = true;
|
||||
Utils.forceGM(player);
|
||||
this.causeByAuthMe = false;
|
||||
}
|
||||
//Player change his IP between 2 relog-in
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
LimboCache.getInstance().addLimboPlayer(player , utils.removeAll(player));
|
||||
} else {
|
||||
int gM = gameMode.get(name);
|
||||
this.causeByAuthMe = true;
|
||||
player.setGameMode(GameMode.getByValue(gM));
|
||||
this.causeByAuthMe = false;
|
||||
player.kickPlayer(m._("unvalid_session"));
|
||||
return;
|
||||
}
|
||||
@@ -576,8 +614,11 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
// isent in session or session was ended correctly
|
||||
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin)
|
||||
e.getPlayer().setGameMode(GameMode.SURVIVAL);
|
||||
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
|
||||
this.causeByAuthMe = true;
|
||||
Utils.forceGM(player);
|
||||
this.causeByAuthMe = 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);
|
||||
@@ -593,8 +634,11 @@ public class AuthMePlayerListener implements Listener {
|
||||
DataFileCache dataFile = new DataFileCache(LimboCache.getInstance().getLimboPlayer(name).getInventory(),LimboCache.getInstance().getLimboPlayer(name).getArmour());
|
||||
playerBackup.createCache(name, dataFile, LimboCache.getInstance().getLimboPlayer(name).getGroup(),LimboCache.getInstance().getLimboPlayer(name).getOperator(),LimboCache.getInstance().getLimboPlayer(name).isFlying());
|
||||
} else {
|
||||
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin)
|
||||
e.getPlayer().setGameMode(GameMode.SURVIVAL);
|
||||
if (Settings.isForceSurvivalModeEnabled && !Settings.forceOnlyAfterLogin) {
|
||||
this.causeByAuthMe = true;
|
||||
Utils.forceGM(player);
|
||||
this.causeByAuthMe = false;
|
||||
}
|
||||
if(!Settings.unRegisteredGroup.isEmpty()){
|
||||
utils.setGroup(player, Utils.groupType.UNREGISTERED);
|
||||
}
|
||||
@@ -643,6 +687,10 @@ public class AuthMePlayerListener implements Listener {
|
||||
player.setNoDamageTicks(Settings.getRegistrationTimeout * 20);
|
||||
if (Settings.useEssentialsMotd)
|
||||
player.performCommand("motd");
|
||||
|
||||
// Remove the join message while the player isn't logging in
|
||||
joinMessage.put(name, event.getJoinMessage());
|
||||
event.setJoinMessage(null);
|
||||
}
|
||||
|
||||
private void placePlayerSafely(Player player, Location spawnLoc) {
|
||||
@@ -688,7 +736,9 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
} catch (NullPointerException npe) { }
|
||||
}
|
||||
}
|
||||
} else {
|
||||
event.setQuitMessage(null);
|
||||
}
|
||||
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||
LimboPlayer limbo = LimboCache.getInstance().getLimboPlayer(name);
|
||||
@@ -762,6 +812,8 @@ public class AuthMePlayerListener implements Listener {
|
||||
});
|
||||
}
|
||||
} catch (NullPointerException npe) { }
|
||||
} else if (!PlayerCache.getInstance().isAuthenticated(name)){
|
||||
event.setLeaveMessage(null);
|
||||
}
|
||||
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name))
|
||||
@@ -1040,12 +1092,48 @@ public class AuthMePlayerListener implements Listener {
|
||||
if (!data.isAuthAvailable(name))
|
||||
if (!Settings.isForcedRegistrationEnabled)
|
||||
return;
|
||||
|
||||
if (!Settings.isTeleportToSpawnEnabled && !Settings.isForceSpawnLocOnJoinEnabled)
|
||||
return;
|
||||
|
||||
Location spawn = plugin.getSpawnLocation(player.getWorld());
|
||||
if(Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) {
|
||||
final PlayerAuth auth = new PlayerAuth(name,spawn.getBlockX(),spawn.getBlockY(),spawn.getBlockZ(),spawn.getWorld().getName());
|
||||
try {
|
||||
data.updateQuitLoc(auth);
|
||||
} catch (NullPointerException npe) { }
|
||||
}
|
||||
event.setRespawnLocation(spawn);
|
||||
}
|
||||
|
||||
@EventHandler (priority = EventPriority.HIGHEST)
|
||||
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
if (event.getPlayer() == null || event == null)
|
||||
return;
|
||||
if (!Settings.isForceSurvivalModeEnabled)
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (plugin.authmePermissible(player, "authme.bypassforcesurvival"))
|
||||
return;
|
||||
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
if (Utils.getInstance().isUnrestricted(player) || CombatTagComunicator.isNPC(player))
|
||||
return;
|
||||
|
||||
if(plugin.getCitizensCommunicator().isNPC(player, plugin))
|
||||
return;
|
||||
|
||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||
return;
|
||||
|
||||
if (!data.isAuthAvailable(name))
|
||||
if (!Settings.isForcedRegistrationEnabled)
|
||||
return;
|
||||
|
||||
if (this.causeByAuthMe)
|
||||
return;
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,15 @@ public class BungeeCordMessage implements PluginMessageListener {
|
||||
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
|
||||
if (!channel.equals("BungeeCord")) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final DataInputStream in = new DataInputStream(new ByteArrayInputStream(message));
|
||||
if (in.readUTF().equals("IP")) { //We need only the IP channel
|
||||
plugin.realIp.put(player.getName().toLowerCase(), in.readUTF()); //Put the IP (only the ip not the port) in the hashmap
|
||||
String subchannel = in.readUTF();
|
||||
if (subchannel.equals("IP")) { //We need only the IP channel
|
||||
String ip = in.readUTF();
|
||||
plugin.realIp.put(player.getName().toLowerCase(), ip); //Put the IP (only the ip not the port) in the hashmap
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
|
||||
@@ -36,4 +36,5 @@ public enum HashAlgorithm {
|
||||
public Class<?> getclass() {
|
||||
return classe;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,8 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.events.PasswordEncryptionEvent;
|
||||
@@ -19,7 +21,7 @@ public class PasswordSecurity {
|
||||
private static SecureRandom rnd = new SecureRandom();
|
||||
public static HashMap<String, String> userSalt = new HashMap<String, String>();
|
||||
|
||||
private static String createSalt(int length) throws NoSuchAlgorithmException {
|
||||
public static String createSalt(int length) throws NoSuchAlgorithmException {
|
||||
byte[] msg = new byte[40];
|
||||
rnd.nextBytes(msg);
|
||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||
@@ -41,64 +43,68 @@ public class PasswordSecurity {
|
||||
}
|
||||
String salt = "";
|
||||
switch (alg) {
|
||||
case MD5:
|
||||
case SHA1:
|
||||
case WHIRLPOOL:
|
||||
case PHPBB:
|
||||
case PLAINTEXT:
|
||||
case XENFORO:
|
||||
case SHA512:
|
||||
case DOUBLEMD5:
|
||||
case WORDPRESS:
|
||||
case CUSTOM:
|
||||
break;
|
||||
case SHA256:
|
||||
salt = createSalt(16);
|
||||
break;
|
||||
case MD5VB:
|
||||
salt = createSalt(16);
|
||||
break;
|
||||
case XAUTH:
|
||||
salt = createSalt(12);
|
||||
break;
|
||||
case MYBB:
|
||||
salt = createSalt(8);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case IPB3:
|
||||
salt = createSalt(5);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case PHPFUSION:
|
||||
salt = createSalt(12);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case SALTED2MD5:
|
||||
salt = createSalt(Settings.saltLength);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case JOOMLA:
|
||||
salt = createSalt(32);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case BCRYPT:
|
||||
salt = BCRYPT.gensalt(Settings.bCryptLog2Rounds);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case WBB3:
|
||||
salt = createSalt(40);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case PBKDF2:
|
||||
salt = createSalt(12);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case SMF:
|
||||
return method.getHash(password, playerName.toLowerCase());
|
||||
default:
|
||||
throw new NoSuchAlgorithmException("Unknown hash algorithm");
|
||||
case SHA256:
|
||||
salt = createSalt(16);
|
||||
break;
|
||||
case MD5VB:
|
||||
salt = createSalt(16);
|
||||
break;
|
||||
case XAUTH:
|
||||
salt = createSalt(12);
|
||||
break;
|
||||
case MYBB:
|
||||
salt = createSalt(8);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case IPB3:
|
||||
salt = createSalt(5);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case PHPFUSION:
|
||||
salt = createSalt(12);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case SALTED2MD5:
|
||||
salt = createSalt(Settings.saltLength);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case JOOMLA:
|
||||
salt = createSalt(32);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case BCRYPT:
|
||||
salt = BCRYPT.gensalt(Settings.bCryptLog2Rounds);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case WBB3:
|
||||
salt = createSalt(40);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case PBKDF2:
|
||||
salt = createSalt(12);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case SMF:
|
||||
return method.getHash(password, playerName.toLowerCase());
|
||||
case PHPBB:
|
||||
salt = createSalt(16);
|
||||
userSalt.put(playerName, salt);
|
||||
break;
|
||||
case MD5:
|
||||
case SHA1:
|
||||
case WHIRLPOOL:
|
||||
case PLAINTEXT:
|
||||
case XENFORO:
|
||||
case SHA512:
|
||||
case DOUBLEMD5:
|
||||
case WORDPRESS:
|
||||
case CUSTOM:
|
||||
break;
|
||||
default:
|
||||
throw new NoSuchAlgorithmException("Unknown hash algorithm");
|
||||
}
|
||||
PasswordEncryptionEvent event = new PasswordEncryptionEvent(method, playerName);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
method = event.getMethod();
|
||||
if (method == null)
|
||||
throw new NoSuchAlgorithmException("Unknown hash algorithm");
|
||||
@@ -118,6 +124,7 @@ public class PasswordSecurity {
|
||||
throw new NoSuchAlgorithmException("Problem with this hash algorithm");
|
||||
}
|
||||
PasswordEncryptionEvent event = new PasswordEncryptionEvent(method, playerName);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
method = event.getMethod();
|
||||
if (method == null)
|
||||
throw new NoSuchAlgorithmException("Unknown hash algorithm");
|
||||
@@ -136,8 +143,9 @@ public class PasswordSecurity {
|
||||
private static boolean compareWithAllEncryptionMethod(String password, String hash, String playerName) throws NoSuchAlgorithmException {
|
||||
for (HashAlgorithm algo : HashAlgorithm.values()) {
|
||||
try {
|
||||
if (algo != HashAlgorithm.CUSTOM)
|
||||
if (((EncryptionMethod) algo.getclass().newInstance()).comparePassword(hash, password, playerName)) {
|
||||
EncryptionMethod method = (EncryptionMethod) algo.getclass().newInstance();
|
||||
if (algo != HashAlgorithm.CUSTOM) {
|
||||
if (method.comparePassword(hash, password, playerName)) {
|
||||
PlayerAuth nAuth = AuthMe.getInstance().database.getAuth(playerName);
|
||||
if (nAuth != null) {
|
||||
nAuth.setHash(getHash(Settings.getPasswordHash, password, playerName));
|
||||
@@ -147,9 +155,8 @@ public class PasswordSecurity {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (InstantiationException e) {
|
||||
} catch (IllegalAccessException e) {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -18,9 +18,6 @@ import java.io.UnsupportedEncodingException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
|
||||
|
||||
/**
|
||||
* BCrypt implements OpenBSD-style Blowfish password hashing using
|
||||
* the scheme described in "A Future-Adaptable Password Scheme" by
|
||||
@@ -762,7 +759,6 @@ public class BCRYPT implements EncryptionMethod {
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String salt = AuthMe.getInstance().database.getAuth(playerName).getSalt();
|
||||
return hash.equals(hashpw(password, salt));
|
||||
return checkpw(password, hash);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,14 +18,14 @@ public class PHPBB implements EncryptionMethod {
|
||||
private String itoa64 =
|
||||
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
public String phpbb_hash(String password) {
|
||||
String random_state = unique_id();
|
||||
public String phpbb_hash(String password, String salt) {
|
||||
String random_state = salt;
|
||||
String random = "";
|
||||
int count = 6;
|
||||
if (random.length() < count) {
|
||||
random = "";
|
||||
for (int i = 0; i < count; i += 16) {
|
||||
random_state = md5(unique_id() + random_state);
|
||||
random_state = md5(salt + random_state);
|
||||
random += pack(md5(random_state));
|
||||
}
|
||||
random = random.substring(0, count);
|
||||
@@ -37,15 +37,6 @@ public class PHPBB implements EncryptionMethod {
|
||||
return md5(password);
|
||||
}
|
||||
|
||||
private String unique_id() {
|
||||
return unique_id("c");
|
||||
}
|
||||
|
||||
private String unique_id(String extra) {
|
||||
//TODO: Maybe check the salt?
|
||||
return "1234567890abcdef";
|
||||
}
|
||||
|
||||
private String _hash_gensalt_private(String input, String itoa64) {
|
||||
return _hash_gensalt_private(input, itoa64, 6);
|
||||
}
|
||||
@@ -162,7 +153,7 @@ private String _hash_gensalt_private(
|
||||
@Override
|
||||
public String getHash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
return phpbb_hash(password);
|
||||
return phpbb_hash(password, salt);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -61,8 +61,6 @@ import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class WHIRLPOOL implements EncryptionMethod {
|
||||
|
||||
public WHIRLPOOL() {}
|
||||
|
||||
/**
|
||||
* The message digest size (in bits)
|
||||
@@ -181,6 +179,9 @@ public class WHIRLPOOL implements EncryptionMethod {
|
||||
protected long[] block = new long[8];
|
||||
protected long[] state = new long[8];
|
||||
|
||||
public WHIRLPOOL() {
|
||||
}
|
||||
|
||||
/**
|
||||
* The core Whirlpool transform.
|
||||
*/
|
||||
|
||||
@@ -7,8 +7,7 @@ public class XAUTH implements EncryptionMethod {
|
||||
@Override
|
||||
public String getHash(String password, String salt)
|
||||
throws NoSuchAlgorithmException {
|
||||
WHIRLPOOL w = new WHIRLPOOL();
|
||||
String hash = w.getHash((salt + password).toLowerCase(), "");
|
||||
String hash = getWhirlpool(salt + password).toLowerCase();
|
||||
int saltPos = (password.length() >= hash.length() ? hash.length() - 1 : password.length());
|
||||
return hash.substring(0, saltPos) + salt + hash.substring(saltPos);
|
||||
}
|
||||
@@ -21,4 +20,13 @@ public class XAUTH implements EncryptionMethod {
|
||||
return hash.equals(getHash(password, salt));
|
||||
}
|
||||
|
||||
public static String getWhirlpool(String message) {
|
||||
WHIRLPOOL w = new WHIRLPOOL();
|
||||
byte[] digest = new byte[WHIRLPOOL.DIGESTBYTES];
|
||||
w.NESSIEinit();
|
||||
w.NESSIEadd(message);
|
||||
w.NESSIEfinalize(digest);
|
||||
return WHIRLPOOL.display(digest);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,73 +1,64 @@
|
||||
package fr.xephi.authme.settings;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
|
||||
public class Messages extends CustomConfiguration {
|
||||
|
||||
private static Messages singleton = null;
|
||||
|
||||
public Messages() {
|
||||
super(new File(Settings.MESSAGE_FILE+"_"+Settings.messagesLanguage+".yml"));
|
||||
loadDefaults();
|
||||
public Messages(File file) {
|
||||
super(file);
|
||||
loadDefaults(file);
|
||||
loadFile();
|
||||
saveDefaults(file);
|
||||
singleton = this;
|
||||
}
|
||||
|
||||
private void loadDefaults() {
|
||||
this.set("logged_in", "&cAlready logged in!");
|
||||
this.set("not_logged_in", "&cNot logged in!");
|
||||
this.set("reg_disabled", "&cRegistration is disabled");
|
||||
this.set("user_regged", "&cUsername already registered");
|
||||
this.set("usage_reg", "&cUsage: /register password ConfirmPassword");
|
||||
this.set("usage_log", "&cUsage: /login password");
|
||||
this.set("user_unknown", "&cUsername not registered");
|
||||
this.set("pwd_changed", "&cPassword changed!");
|
||||
this.set("reg_only", "&fRegistered players only! Please visit http://example.com to register");
|
||||
this.set("valid_session", "&cSession login");
|
||||
this.set("login_msg", "&cPlease login with \"/login password\"");
|
||||
this.set("reg_msg", "&cPlease register with \"/register password ConfirmPassword\"");
|
||||
this.set("reg_email_msg", "&cPlease register with \"/register <email> <confirmEmail>\"");
|
||||
this.set("timeout", "&fLogin Timeout");
|
||||
this.set("wrong_pwd", "&cWrong password");
|
||||
this.set("logout", "&cSuccessful logout");
|
||||
this.set("usage_unreg", "&cUsage: /unregister password");
|
||||
this.set("registered", "&cSuccessfully registered!");
|
||||
this.set("unregistered", "&cSuccessfully unregistered!");
|
||||
this.set("login", "&cSuccessful login!");
|
||||
this.set("no_perm", "&cNo Permission");
|
||||
this.set("same_nick", "&fSame nick is already playing");
|
||||
this.set("reg_voluntarily", "&fYou can register your nickname with the server with the command \"/register password ConfirmPassword\"");
|
||||
this.set("reload", "&fConfiguration and database has been reloaded");
|
||||
this.set("error", "&fAn error ocurred; Please contact the admin");
|
||||
this.set("unknown_user", "&fUser is not in database");
|
||||
this.set("unsafe_spawn","&fYour Quit location was unsafe, teleporting you to World Spawn");
|
||||
this.set("unvalid_session","&fSession Dataes doesnt corrispond Plaese wait the end of session");
|
||||
this.set("max_reg","&fYou have Exceded the max number of Registration for your Account");
|
||||
this.set("password_error","&fPassword doesnt match");
|
||||
this.set("pass_len","&fYour password dind''t reach the minimum length or exeded the max length");
|
||||
this.set("vb_nonActiv","&fYour Account isent Activated yet check your Emails!");
|
||||
this.set("usage_changepassword", "&fUsage: /changepassword oldPassword newPassword");
|
||||
this.set("name_len", "&cYour nickname is too Short or too long");
|
||||
this.set("regex", "&cYour nickname contains illegal characters. Allowed chars: REG_EX");
|
||||
this.set("add_email","&cPlease add your email with : /email add yourEmail confirmEmail");
|
||||
this.set("bad_database_email", "[AuthMe] This /email command only available with MySQL and SQLite, contact an Admin");
|
||||
this.set("recovery_email", "&cForgot your password? Please use /email recovery <yourEmail>");
|
||||
this.set("usage_captcha", "&cUsage: /captcha <theCaptcha>");
|
||||
this.set("wrong_captcha", "&cWrong Captcha, please use : /captcha THE_CAPTCHA");
|
||||
this.set("valid_captcha", "&cYour captcha is valid !");
|
||||
this.set("kick_forvip", "&cA VIP Player join the full server!");
|
||||
this.set("kick_fullserver", "&cThe server is actually full, Sorry!");
|
||||
this.set("usage_email_add", "&fUsage: /email add <Email> <confirmEmail> ");
|
||||
this.set("usage_email_change", "&Usage: /email change <old> <new> ");
|
||||
this.set("usage_email_recovery", "&Usage: /email recovery <Email>");
|
||||
this.set("email_add", "[AuthMe] /email add <Email> <confirmEmail>");
|
||||
this.set("new_email_invalid", "[AuthMe] New email invalid!");
|
||||
this.set("old_email_invalid", "[AuthMe] Old email invalid!");
|
||||
this.set("email_invalid", "[AuthMe] Invalid Email !");
|
||||
this.set("email_added", "[AuthMe] Email Added !");
|
||||
this.set("email_confirm", "[AuthMe] Confirm your Email !");
|
||||
this.set("email_changed", "[AuthMe] Email Change !");
|
||||
this.set("email_send", "[AuthMe] Recovery Email Send !");
|
||||
/**
|
||||
* Loads a file from the plugin jar and sets as default
|
||||
*
|
||||
* @param filename The filename to open
|
||||
*/
|
||||
public final void loadDefaults(File file) {
|
||||
InputStream stream = AuthMe.getInstance().getResource(file.getName());
|
||||
if(stream == null) return;
|
||||
|
||||
setDefaults(YamlConfiguration.loadConfiguration(stream));
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves the configuration to disk
|
||||
*
|
||||
* @return True if saved successfully
|
||||
*/
|
||||
public final boolean saved(File file) {
|
||||
try {
|
||||
save(file);
|
||||
return true;
|
||||
} catch (Exception ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves current configuration (plus defaults) to disk.
|
||||
*
|
||||
* If defaults and configuration are empty, saves blank file.
|
||||
*
|
||||
* @return True if saved successfully
|
||||
*/
|
||||
public final boolean saveDefaults(File file) {
|
||||
options().copyDefaults(true);
|
||||
options().copyHeader(true);
|
||||
boolean success = saved(file);
|
||||
options().copyDefaults(false);
|
||||
options().copyHeader(false);
|
||||
return success;
|
||||
}
|
||||
|
||||
private void loadFile() {
|
||||
@@ -76,23 +67,24 @@ public class Messages extends CustomConfiguration {
|
||||
}
|
||||
|
||||
public String _(String msg) {
|
||||
String loc = (String) this.get(msg);
|
||||
String loc = (String) this.get(msg, this.getDefault(msg));
|
||||
if (loc != null) {
|
||||
return loc.replace("&", "\u00a7");
|
||||
}
|
||||
if (loc == null && !contains(msg)) {
|
||||
set(msg, this.getDefault(msg));
|
||||
save();
|
||||
loc = (String) this.get(msg);
|
||||
load();
|
||||
loc = (String) this.get(msg, this.getDefault(msg));
|
||||
}
|
||||
if (loc == null)
|
||||
return "Error with Translation files; Please contact the admin";
|
||||
return "Error with Translation files; Please contact the admin ";
|
||||
return loc.replace("&", "\u00a7");
|
||||
}
|
||||
|
||||
public static Messages getInstance() {
|
||||
if (singleton == null) {
|
||||
singleton = new Messages();
|
||||
singleton = new Messages(new File(Settings.MESSAGE_FILE+"_"+Settings.messagesLanguage+".yml"));
|
||||
}
|
||||
return singleton;
|
||||
}
|
||||
|
||||
@@ -29,8 +29,10 @@ public final class Settings extends YamlConfiguration {
|
||||
private static List<String> getRestrictedIp;
|
||||
public static List<String> getMySQLOtherUsernameColumn = null;
|
||||
public static List<String> getForcedWorlds = null;
|
||||
public static List<String> countries = null;
|
||||
public static List<String> forceCommands = null;
|
||||
public final Plugin plugin;
|
||||
private final File file;
|
||||
private final File file;
|
||||
public static DataSourceType getDataSource;
|
||||
public static HashAlgorithm getPasswordHash;
|
||||
public static HashAlgorithm rakamakHash;
|
||||
@@ -39,13 +41,14 @@ public final class Settings extends YamlConfiguration {
|
||||
public static Boolean isPermissionCheckEnabled, isRegistrationEnabled, isForcedRegistrationEnabled,
|
||||
isTeleportToSpawnEnabled, isSessionsEnabled, isChatAllowed, isAllowRestrictedIp,
|
||||
isMovementAllowed, isKickNonRegisteredEnabled, isForceSingleSessionEnabled,
|
||||
isForceSpawnLocOnJoinEnabled, isForceExactSpawnEnabled, isSaveQuitLocationEnabled,
|
||||
isForceSpawnLocOnJoinEnabled, isSaveQuitLocationEnabled,
|
||||
isForceSurvivalModeEnabled, isResetInventoryIfCreative, isCachingEnabled, isKickOnWrongPasswordEnabled,
|
||||
getEnablePasswordVerifier, protectInventoryBeforeLogInEnabled, isBackupActivated, isBackupOnStart,
|
||||
isBackupOnStop, enablePasspartu, isStopEnabled, reloadSupport, rakamakUseIp, noConsoleSpam, removePassword, displayOtherAccounts,
|
||||
useCaptcha, emailRegistration, multiverse, notifications, chestshop, bungee, banUnsafeIp, doubleEmailCheck, sessionExpireOnIpChange,
|
||||
disableSocialSpy, useMultiThreading, forceOnlyAfterLogin, useEssentialsMotd,
|
||||
usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword;
|
||||
usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword, purgeLimitedCreative,
|
||||
purgeAntiXray, purgePermissions, enableProtection, enableAntiBot;
|
||||
|
||||
public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort,
|
||||
getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename,
|
||||
@@ -59,7 +62,7 @@ public final class Settings extends YamlConfiguration {
|
||||
public static int getWarnMessageInterval, getSessionTimeout, getRegistrationTimeout, getMaxNickLength,
|
||||
getMinNickLength, getPasswordMinLen, getMovementRadius, getmaxRegPerIp, getNonActivatedGroup,
|
||||
passwordMaxLength, getRecoveryPassLength, getMailPort, maxLoginTry, captchaLength, saltLength, getmaxRegPerEmail,
|
||||
bCryptLog2Rounds, purgeDelay, getPhpbbGroup;
|
||||
bCryptLog2Rounds, purgeDelay, getPhpbbGroup, antiBotSensibility, antiBotDuration;
|
||||
|
||||
protected static YamlConfiguration configFile;
|
||||
|
||||
@@ -187,7 +190,7 @@ public void loadConfigOptions() {
|
||||
chestshop = configFile.getBoolean("Hooks.chestshop", true);
|
||||
notifications = configFile.getBoolean("Hooks.notifications", true);
|
||||
bungee = configFile.getBoolean("Hooks.bungeecord", false);
|
||||
getForcedWorlds = (List<String>) configFile.getList("settings.restrictions.ForceSpawnOnTheseWorlds");
|
||||
getForcedWorlds = (List<String>) configFile.getList("settings.restrictions.ForceSpawnOnTheseWorlds", new ArrayList<String>());
|
||||
banUnsafeIp = configFile.getBoolean("settings.restrictions.banUnsafedIP", false);
|
||||
doubleEmailCheck = configFile.getBoolean("settings.registration.doubleEmailCheck", false);
|
||||
sessionExpireOnIpChange = configFile.getBoolean("settings.sessions.sessionExpireOnIpChange", false);
|
||||
@@ -206,6 +209,15 @@ public void loadConfigOptions() {
|
||||
getPhpbbGroup = configFile.getInt("ExternalBoardOptions.phpbbActivatedGroupId", 2);
|
||||
supportOldPassword = configFile.getBoolean("settings.security.supportOldPasswordHash", false);
|
||||
getWordPressPrefix = configFile.getString("ExternalBoardOptions.wordpressTablePrefix", "wp_");
|
||||
purgeLimitedCreative = configFile.getBoolean("Purge.removeLimitedCreativesInventories", false);
|
||||
purgeAntiXray = configFile.getBoolean("Purge.removeAntiXRayFile", false);
|
||||
//purgePermissions = configFile.getBoolean("Purge.removePermissions", false);
|
||||
enableProtection = configFile.getBoolean("Protection.enableProtection", false);
|
||||
countries = (List<String>) configFile.getList("Protection.countries", new ArrayList<String>());
|
||||
enableAntiBot = configFile.getBoolean("Protection.enableAntiBot", false);
|
||||
antiBotSensibility = configFile.getInt("Protection.antiBotSensibility", 5);
|
||||
antiBotDuration = configFile.getInt("Protection.antiBotDuration", 10);
|
||||
forceCommands = (List<String>) configFile.getList("settings.forceCommands", new ArrayList<String>());
|
||||
|
||||
saveDefaults();
|
||||
}
|
||||
@@ -339,6 +351,15 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
|
||||
getPhpbbGroup = configFile.getInt("ExternalBoardOptions.phpbbActivatedGroupId", 2);
|
||||
supportOldPassword = configFile.getBoolean("settings.security.supportOldPasswordHash", false);
|
||||
getWordPressPrefix = configFile.getString("ExternalBoardOptions.wordpressTablePrefix", "wp_");
|
||||
purgeLimitedCreative = configFile.getBoolean("Purge.removeLimitedCreativesInventories", false);
|
||||
purgeAntiXray = configFile.getBoolean("Purge.removeAntiXRayFile", false);
|
||||
//purgePermissions = configFile.getBoolean("Purge.removePermissions", false);
|
||||
enableProtection = configFile.getBoolean("Protection.enableProtection", false);
|
||||
countries = (List<String>) configFile.getList("Protection.countries");
|
||||
enableAntiBot = configFile.getBoolean("Protection.enableAntiBot", false);
|
||||
antiBotSensibility = configFile.getInt("Protection.antiBotSensibility", 5);
|
||||
antiBotDuration = configFile.getInt("Protection.antiBotDuration", 10);
|
||||
forceCommands = (List<String>) configFile.getList("settings.forceCommands", new ArrayList<String>());
|
||||
}
|
||||
|
||||
public void mergeConfig() {
|
||||
@@ -433,7 +454,29 @@ public void mergeConfig() {
|
||||
set("Xenoforo.predefinedSalt", null);
|
||||
if(configFile.getString("settings.security.passwordHash","SHA256").toUpperCase().equals("XFSHA1") || configFile.getString("settings.security.passwordHash","SHA256").toUpperCase().equals("XFSHA256"))
|
||||
set("settings.security.passwordHash", "XENFORO");
|
||||
|
||||
if(!contains("Purge.removeLimitedCreativesInventories"))
|
||||
set("Purge.removeLimitedCreativesInventories", false);
|
||||
if(!contains("Purge.removeAntiXRayFile"))
|
||||
set("Purge.removeAntiXRayFile", false);
|
||||
/*if(!contains("Purge.removePermissions"))
|
||||
set("Purge.removePermissions", false);*/
|
||||
if(!contains("Protection.enableProtection"))
|
||||
set("Protection.enableProtection", false);
|
||||
if(!contains("Protection.countries")) {
|
||||
countries = new ArrayList<String>();
|
||||
countries.add("US");
|
||||
countries.add("GB");
|
||||
set("Protection.countries", countries);
|
||||
}
|
||||
if(!contains("Protection.enableAntiBot"))
|
||||
set("Protection.enableAntiBot", false);
|
||||
if(!contains("Protection.antiBotSensibility"))
|
||||
set("Protection.antiBotSensibility", 5);
|
||||
if(!contains("Protection.antiBotDuration"))
|
||||
set("Protection.antiBotDuration", 10);
|
||||
if(!contains("settings.forceCommands"))
|
||||
set("settings.forceCommands", new ArrayList<String>());
|
||||
|
||||
plugin.getLogger().info("Merge new Config Options if needed..");
|
||||
plugin.saveConfig();
|
||||
|
||||
@@ -581,11 +624,11 @@ public void mergeConfig() {
|
||||
setDefaults(new MemoryConfiguration());
|
||||
}
|
||||
|
||||
/**
|
||||
* Check loaded defaults against current configuration
|
||||
*
|
||||
* @return false When all defaults aren't present in config
|
||||
*/
|
||||
/**
|
||||
* Check loaded defaults against current configuration
|
||||
*
|
||||
* @return false When all defaults aren't present in config
|
||||
*/
|
||||
public boolean checkDefaults() {
|
||||
if (getDefaults() == null) {
|
||||
return true;
|
||||
@@ -604,8 +647,14 @@ public void mergeConfig() {
|
||||
return "en";
|
||||
}
|
||||
|
||||
public enum messagesLang {
|
||||
en, de, br, cz, pl, fr, ru, hu, sk, es, zhtw, fi, zhcn, lt, it, ko, pt
|
||||
public static void switchAntiBotMod(boolean mode) {
|
||||
if (mode)
|
||||
isKickNonRegisteredEnabled = true;
|
||||
else
|
||||
isKickNonRegisteredEnabled = configFile.getBoolean("settings.restrictions.kickNonRegistered",false);
|
||||
}
|
||||
|
||||
public enum messagesLang {
|
||||
en, de, br, cz, pl, fr, ru, hu, sk, es, zhtw, fi, zhcn, lt, it, ko, pt, nl
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ public class MessageTask implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (player.getName().toLowerCase().equals(name)) {
|
||||
player.sendMessage(msg);
|
||||
|
||||
@@ -32,13 +32,14 @@ public class TimeoutTask implements Runnable {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name))
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||
if (player.getName().toLowerCase().equals(name)) {
|
||||
if (LimboCache.getInstance().hasLimboPlayer(name)) {
|
||||
LimboPlayer inv = LimboCache.getInstance().getLimboPlayer(name);
|
||||
player.getServer().getScheduler().cancelTask(inv.getMessageTaskId());
|
||||
player.getServer().getScheduler().cancelTask(inv.getTimeoutTaskId());
|
||||
if(playerCache.doesCacheExist(name)) {
|
||||
playerCache.removeCache(name);
|
||||
|
||||
@@ -12,6 +12,7 @@ import java.util.List;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
@@ -21,9 +22,10 @@ public class FlatFileThread extends Thread implements DataSource {
|
||||
|
||||
/* file layout:
|
||||
*
|
||||
* PLAYERNAME:HASHSUM:IP:LOGININMILLIESECONDS:LASTPOSX:LASTPOSY:LASTPOSZ:LASTPOSWORLD
|
||||
* PLAYERNAME:HASHSUM:IP:LOGININMILLIESECONDS:LASTPOSX:LASTPOSY:LASTPOSZ:LASTPOSWORLD:EMAIL
|
||||
*
|
||||
* Old but compatible:
|
||||
* PLAYERNAME:HASHSUM:IP:LOGININMILLIESECONDS:LASTPOSX:LASTPOSY:LASTPOSZ:LASTPOSWORLD
|
||||
* PLAYERNAME:HASHSUM:IP:LOGININMILLIESECONDS
|
||||
* PLAYERNAME:HASHSUM:IP
|
||||
* PLAYERNAME:HASHSUM
|
||||
@@ -84,7 +86,7 @@ public class FlatFileThread extends Thread implements DataSource {
|
||||
BufferedWriter bw = null;
|
||||
try {
|
||||
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");
|
||||
bw.write(auth.getNickname() + ":" + auth.getHash() + ":" + auth.getIp() + ":" + auth.getLastLogin() + ":" + auth.getQuitLocX() + ":" + auth.getQuitLocY() + ":" + auth.getQuitLocZ() + ":" + auth.getWorld() + ":" + auth.getEmail() + "\n");
|
||||
} catch (IOException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return false;
|
||||
@@ -114,19 +116,23 @@ public class FlatFileThread extends Thread implements DataSource {
|
||||
if (args[0].equals(auth.getNickname())) {
|
||||
switch (args.length) {
|
||||
case 4: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), 0, 0, 0, "world");
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), 0, 0, 0, "world", "your@email.com", API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), "world");
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), "world", "your@email.com", API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), args[7]);
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), args[7], "your@email.com", API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
case 9: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], Long.parseLong(args[3]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), args[7], args[8], API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], 0, 0, 0, 0, "world");
|
||||
newAuth = new PlayerAuth(args[0], auth.getHash(), args[2], 0, 0, 0, 0, "world", "your@email.com", API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -167,19 +173,23 @@ public class FlatFileThread extends Thread implements DataSource {
|
||||
if (args[0].equals(auth.getNickname())) {
|
||||
switch (args.length) {
|
||||
case 4: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world");
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world", "your@email.com", API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), "world");
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), "world", "your@email.com", API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), args[7]);
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), args[7], "your@email.com", API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
case 9: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), args[7], args[8], API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world");
|
||||
newAuth = new PlayerAuth(args[0], args[1], auth.getIp(), auth.getLastLogin(), 0, 0, 0, "world", "your@email.com", API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -218,7 +228,7 @@ public class FlatFileThread extends Thread implements DataSource {
|
||||
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());
|
||||
newAuth = new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), auth.getQuitLocX(), auth.getQuitLocY(), auth.getQuitLocZ(), auth.getWorld(), auth.getEmail(), API.getPlayerRealName(args[0]));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -420,15 +430,17 @@ public class FlatFileThread extends Thread implements DataSource {
|
||||
if (args[0].equals(user)) {
|
||||
switch (args.length) {
|
||||
case 2:
|
||||
return new PlayerAuth(args[0], args[1], "198.18.0.1", 0);
|
||||
return new PlayerAuth(args[0], args[1], "198.18.0.1", 0, "your@email.com", API.getPlayerRealName(args[0]));
|
||||
case 3:
|
||||
return new PlayerAuth(args[0], args[1], args[2], 0);
|
||||
return new PlayerAuth(args[0], args[1], args[2], 0, "your@email.com", API.getPlayerRealName(args[0]));
|
||||
case 4:
|
||||
return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]));
|
||||
return new PlayerAuth(args[0], args[1], args[2], Long.parseLong(args[3]), "your@email.com", API.getPlayerRealName(args[0]));
|
||||
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");
|
||||
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", "your@email.com", API.getPlayerRealName(args[0]));
|
||||
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]);
|
||||
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], "your@email.com", API.getPlayerRealName(args[0]));
|
||||
case 9:
|
||||
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], args[8], API.getPlayerRealName(args[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -459,7 +471,38 @@ public class FlatFileThread extends Thread implements DataSource {
|
||||
|
||||
@Override
|
||||
public boolean updateEmail(PlayerAuth auth) {
|
||||
return false;
|
||||
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]), Integer.parseInt(args[4]), Integer.parseInt(args[5]), Integer.parseInt(args[6]), args[7], auth.getEmail(), API.getPlayerRealName(args[0]));
|
||||
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
|
||||
@@ -524,12 +567,37 @@ public class FlatFileThread extends Thread implements DataSource {
|
||||
} catch (IOException ex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getAllAuthsByEmail(String email) {
|
||||
return new ArrayList<String>();
|
||||
BufferedReader br = null;
|
||||
List<String> countEmail = new ArrayList<String>();
|
||||
try {
|
||||
br = new BufferedReader(new FileReader(source));
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) {
|
||||
String[] args = line.split(":");
|
||||
if (args.length > 8 && args[8].equals(email)) {
|
||||
countEmail.add(args[0]);
|
||||
}
|
||||
}
|
||||
return countEmail;
|
||||
} 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
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.datasource.MiniConnectionPoolManager;
|
||||
@@ -208,14 +209,14 @@ public class MySQLThread extends Thread implements DataSource {
|
||||
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));
|
||||
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), API.getPlayerRealName(rs.getString(columnName)));
|
||||
} 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));
|
||||
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), API.getPlayerRealName(rs.getString(columnName)));
|
||||
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), API.getPlayerRealName(rs.getString(columnName)));
|
||||
} 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));
|
||||
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), API.getPlayerRealName(rs.getString(columnName)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -258,8 +259,8 @@ public class MySQLThread extends Thread implements DataSource {
|
||||
}
|
||||
if (!columnOthers.isEmpty()) {
|
||||
for(String column : columnOthers) {
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + tableName + "." + column + "=? WHERE " + columnName + "=?;");
|
||||
pst.setString(1, auth.getNickname());
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + column + "=? WHERE " + columnName + "=?;");
|
||||
pst.setString(1, auth.getRealname());
|
||||
pst.setString(2, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
}
|
||||
@@ -272,12 +273,30 @@ public class MySQLThread extends Thread implements DataSource {
|
||||
rs = pst.executeQuery();
|
||||
if (rs.next()) {
|
||||
id = rs.getInt(columnID);
|
||||
// Insert player in phpbb_user_group
|
||||
pst = con.prepareStatement("INSERT INTO " + Settings.getPhpbbPrefix + "user_group (group_id, user_id, group_leader, user_pending) VALUES (?,?,?,?);");
|
||||
pst.setInt(1, Settings.getPhpbbGroup);
|
||||
pst.setInt(2, id);
|
||||
pst.setInt(3, 0);
|
||||
pst.setInt(4, 0);
|
||||
pst.executeUpdate();
|
||||
// Update player group in phpbb_users
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + tableName + ".group_id=? WHERE " + columnName + "=?;");
|
||||
pst.setInt(1, Settings.getPhpbbGroup);
|
||||
pst.setString(2, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
// Get current time without ms
|
||||
long time = System.currentTimeMillis()/1000;
|
||||
// Update user_regdate
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + tableName + ".user_regdate=? WHERE " + columnName + "=?;");
|
||||
pst.setLong(1, time);
|
||||
pst.setString(2, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
// Update user_lastvisit
|
||||
pst = con.prepareStatement("UPDATE " + tableName + " SET " + tableName + ".user_lastvisit=? WHERE " + columnName + "=?;");
|
||||
pst.setLong(1, time);
|
||||
pst.setString(2, auth.getNickname());
|
||||
pst.executeUpdate();
|
||||
}
|
||||
}
|
||||
if (Settings.getPasswordHash == HashAlgorithm.WORDPRESS) {
|
||||
@@ -457,6 +476,9 @@ public class MySQLThread extends Thread implements DataSource {
|
||||
while (rs.next()) {
|
||||
list.add(rs.getString(columnName));
|
||||
}
|
||||
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnLastLogin + "<?;");
|
||||
pst.setLong(1, until);
|
||||
pst.executeUpdate();
|
||||
return list;
|
||||
} catch (SQLException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.util.List;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.datasource.MiniConnectionPoolManager.TimeoutException;
|
||||
@@ -169,12 +170,12 @@ public class SQLiteThread extends Thread implements DataSource {
|
||||
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));
|
||||
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), API.getPlayerRealName(rs.getString(columnName)));
|
||||
} 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));
|
||||
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), API.getPlayerRealName(rs.getString(columnName)));
|
||||
} 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));
|
||||
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), API.getPlayerRealName(rs.getString(columnName)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user