Update 3.3.5

//Changes 3.3.5://
* Now Support our sponsor ipClean feature ( Get player real ip through
their servers )
* Now Cache correctly Item Custom Names and Lores
* Fix FlatToSQL converter
* Add /authme getip <playername> command, perm : authme.admin.getip
* Implement correctly XenForo Support
* Fix maxregperip
* Fix maxloginperip
* Preparation for next features, coming soon !
This commit is contained in:
Xephi 2014-04-01 10:32:27 +02:00
parent b659d8968e
commit 8c3dc12658
23 changed files with 489 additions and 341 deletions

View File

@ -24,12 +24,12 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<version>3.3.4</version> <version>3.3.5</version>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId> <artifactId>craftbukkit</artifactId>
<version>1.7.2-R0.3</version> <version>1.7.5-R0.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.milkbowl.vault</groupId> <groupId>net.milkbowl.vault</groupId>

View File

@ -1,10 +1,11 @@
package fr.xephi.authme; package fr.xephi.authme;
import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.InetAddress;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.util.Calendar; import java.util.Calendar;
@ -29,7 +30,6 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import com.earth2me.essentials.Essentials; import com.earth2me.essentials.Essentials;
import com.maxmind.geoip.LookupService; import com.maxmind.geoip.LookupService;
import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.MultiverseCore;
@ -105,6 +105,7 @@ public class AuthMe extends JavaPlugin {
public LookupService ls = null; public LookupService ls = null;
public boolean antibotMod = false; public boolean antibotMod = false;
public boolean delayedAntiBot = true; public boolean delayedAntiBot = true;
protected static String vgUrl = "http://monitor-1.verygames.net/api/?action=ipclean-real-ip&out=raw&ip=%IP%&port=%PORT%";
public Settings getSettings() { public Settings getSettings() {
return settings; return settings;
@ -532,9 +533,6 @@ public class AuthMe extends JavaPlugin {
player.getInventory().setArmorContents(limbo.getArmour()); player.getInventory().setArmorContents(limbo.getArmour());
player.getInventory().setContents(limbo.getInventory()); player.getInventory().setContents(limbo.getInventory());
} }
if (!limbo.getLoc().getChunk().isLoaded()) {
limbo.getLoc().getChunk().load();
}
player.teleport(limbo.getLoc()); player.teleport(limbo.getLoc());
this.utils.addNormal(player, limbo.getGroup()); this.utils.addNormal(player, limbo.getGroup());
player.setOp(limbo.getOperator()); player.setOp(limbo.getOperator());
@ -690,7 +688,8 @@ public class AuthMe extends JavaPlugin {
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles"); ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
} }
public Location getSpawnLocation(Player player, World world) { public Location getSpawnLocation(Player player) {
World world = player.getWorld();
String[] spawnPriority = Settings.spawnPriority.split(","); String[] spawnPriority = Settings.spawnPriority.split(",");
Location spawnLoc = world.getSpawnLocation(); Location spawnLoc = world.getSpawnLocation();
int i = 3; int i = 3;
@ -727,9 +726,8 @@ public class AuthMe extends JavaPlugin {
} }
private Location getEssentialsSpawn() { private Location getEssentialsSpawn() {
if (essentialsSpawn != null) { if (essentialsSpawn != null)
return essentialsSpawn; return essentialsSpawn;
}
return null; return null;
} }
@ -766,8 +764,8 @@ public class AuthMe extends JavaPlugin {
} catch (Exception e) {} } catch (Exception e) {}
} }
} }
public String getCountryCode(InetAddress ip) { public String getCountryCode(String ip) {
try { try {
if (ls == null) if (ls == null)
ls = new LookupService(new File(getDataFolder(), "GeoIP.dat")); ls = new LookupService(new File(getDataFolder(), "GeoIP.dat"));
@ -778,7 +776,7 @@ public class AuthMe extends JavaPlugin {
return null; return null;
} }
public String getCountryName(InetAddress ip) { public String getCountryName(String ip) {
try { try {
if (ls == null) if (ls == null)
ls = new LookupService(new File(getDataFolder(), "GeoIP.dat")); ls = new LookupService(new File(getDataFolder(), "GeoIP.dat"));
@ -821,38 +819,63 @@ public class AuthMe extends JavaPlugin {
message = message.replace("{PLAYER}", player.getName()); message = message.replace("{PLAYER}", player.getName());
message = message.replace("{ONLINE}", ""+this.getServer().getOnlinePlayers().length); message = message.replace("{ONLINE}", ""+this.getServer().getOnlinePlayers().length);
message = message.replace("{MAXPLAYERS}", ""+this.getServer().getMaxPlayers()); message = message.replace("{MAXPLAYERS}", ""+this.getServer().getMaxPlayers());
message = message.replace("{IP}", player.getAddress().getAddress().getHostAddress()); message = message.replace("{IP}", getIP(player));
message = message.replace("{LOGINS}", ""+PlayerCache.getInstance().getLogged()); message = message.replace("{LOGINS}", ""+PlayerCache.getInstance().getLogged());
message = message.replace("{WORLD}", player.getWorld().getName()); message = message.replace("{WORLD}", player.getWorld().getName());
message = message.replace("{SERVER}", this.getServer().getServerName()); message = message.replace("{SERVER}", this.getServer().getServerName());
message = message.replace("{VERSION}", this.getServer().getBukkitVersion()); message = message.replace("{VERSION}", this.getServer().getBukkitVersion());
message = message.replace("{COUNTRY}", this.getCountryName(player.getAddress().getAddress())); message = message.replace("{COUNTRY}", this.getCountryName(getIP(player)));
} catch (Exception e) {} } catch (Exception e) {}
return message; return message;
} }
public String getIP(Player player, String name) { public String getIP(Player player) {
String name = player.getName().toLowerCase();
String ip = player.getAddress().getAddress().getHostAddress(); String ip = player.getAddress().getAddress().getHostAddress();
if (Settings.bungee) { if (Settings.bungee) {
if (realIp.containsKey(name)) if (realIp.containsKey(name))
ip = realIp.get(name); ip = realIp.get(name);
} }
if (Settings.checkVeryGames)
if (getVeryGamesIP(player) != null)
ip = getVeryGamesIP(player);
return ip; return ip;
} }
public boolean isLoggedIp(String ip) { public boolean isLoggedIp(String name, String ip) {
for (Player player : this.getServer().getOnlinePlayers()) { for (Player player : this.getServer().getOnlinePlayers()) {
if(ip.equalsIgnoreCase(getIP(player, player.getName())) && database.isLogged(player.getName().toLowerCase())) if(ip.equalsIgnoreCase(getIP(player)) && database.isLogged(player.getName().toLowerCase()) && !player.getName().equalsIgnoreCase(name))
return true; return true;
} }
return false; return false;
} }
public boolean hasJoinedIp(String ip) { public boolean hasJoinedIp(String name, String ip) {
for (Player player : this.getServer().getOnlinePlayers()) { for (Player player : this.getServer().getOnlinePlayers()) {
if(ip.equalsIgnoreCase(getIP(player, player.getName()))) if(ip.equalsIgnoreCase(getIP(player)) && !player.getName().equalsIgnoreCase(name))
return true; return true;
} }
return false; return false;
} }
/**
* Get Player real IP through VeryGames method
* @param Player player
*/
public String getVeryGamesIP(Player player) {
String realIP = null;
String sUrl = vgUrl;
sUrl = sUrl.replace("%IP%", player.getAddress().getAddress().getHostAddress()).replace("%PORT%", ""+player.getAddress().getPort());
try {
URL url = new URL(sUrl);
URLConnection urlc = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));
String inputLine = in.readLine();
if (inputLine != null && !inputLine.isEmpty() && !inputLine.equalsIgnoreCase("error")) {
realIP = inputLine;
}
} catch (Exception e) {
}
return realIP;
}
} }

View File

@ -6,7 +6,6 @@ import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.Utils; import fr.xephi.authme.Utils;
import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerAuth;
@ -176,4 +175,5 @@ public class API {
public static void forceLogin(Player player) { public static void forceLogin(Player player) {
instance.management.performLogin(player, "dontneed", true); instance.management.performLogin(player, "dontneed", true);
} }
} }

View File

@ -3,6 +3,8 @@ package fr.xephi.authme.cache.backup;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner; import java.util.Scanner;
import org.bukkit.Material; import org.bukkit.Material;
@ -53,6 +55,8 @@ public class FileCache {
int amount = 0; int amount = 0;
int durability = 0; int durability = 0;
String enchList = ""; String enchList = "";
String name = "";
String lores = "";
if (invstack[i] != null) { if (invstack[i] != null) {
itemid = invstack[i].getType().name(); itemid = invstack[i].getType().name();
amount = invstack[i].getAmount(); amount = invstack[i].getAmount();
@ -60,9 +64,22 @@ public class FileCache {
for(Enchantment e : invstack[i].getEnchantments().keySet()) { for(Enchantment e : invstack[i].getEnchantments().keySet()) {
enchList = enchList.concat(e.getName()+":"+invstack[i].getEnchantmentLevel(e)+":"); enchList = enchList.concat(e.getName()+":"+invstack[i].getEnchantmentLevel(e)+":");
} }
if (enchList.length() > 1)
enchList = enchList.substring(0, enchList.length() - 1);
if (invstack[i].hasItemMeta()) {
if (invstack[i].getItemMeta().hasDisplayName()) {
name = invstack[i].getItemMeta().getDisplayName();
}
if (invstack[i].getItemMeta().hasLore()) {
for (String lore : invstack[i].getItemMeta().getLore()) {
lores = lore + "%newline%";
}
}
}
} }
writer.write("i" + ":" + itemid + ":" + amount + ":" String writeItem = "i" + ":" + itemid + ":" + amount + ":"
+ durability + ":"+ enchList + "\r\n"); + durability + ":"+ enchList + ";" + name + "\\*" + lores + "\r\n";
writer.write(writeItem);
writer.flush(); writer.flush();
} }
@ -73,16 +90,31 @@ public class FileCache {
int amount = 0; int amount = 0;
int durability = 0; int durability = 0;
String enchList = ""; String enchList = "";
String name = "";
String lores = "";
if (armorstack[i] != null) { if (armorstack[i] != null) {
itemid = armorstack[i].getType().name(); itemid = armorstack[i].getType().name();
amount = armorstack[i].getAmount(); amount = armorstack[i].getAmount();
durability = armorstack[i].getDurability(); durability = armorstack[i].getDurability();
for(Enchantment e : armorstack[i].getEnchantments().keySet()) { for(Enchantment e : armorstack[i].getEnchantments().keySet()) {
enchList = enchList.concat(e.getName()+":"+armorstack[i].getEnchantmentLevel(e)+":"); enchList = enchList.concat(e.getName()+":"+armorstack[i].getEnchantmentLevel(e)+":");
} }
if (enchList.length() > 1)
enchList = enchList.substring(0, enchList.length() - 1);
if (armorstack[i].hasItemMeta()) {
if (armorstack[i].getItemMeta().hasDisplayName()) {
name = armorstack[i].getItemMeta().getDisplayName();
}
if (armorstack[i].getItemMeta().hasLore()) {
for (String lore : armorstack[i].getItemMeta().getLore()) {
lores = lore + "%newline%";
}
}
}
} }
writer.write("w" + ":" + itemid + ":" + amount + ":" String writeItem = "w" + ":" + itemid + ":" + amount + ":"
+ durability + ":"+ enchList + "\r\n"); + durability + ":"+ enchList + ";" + name + "\\*" + lores + "\r\n";
writer.write(writeItem);
writer.flush(); writer.flush();
} }
writer.close(); writer.close();
@ -111,7 +143,7 @@ public class FileCache {
int i = 0; int i = 0;
int a = 0; int a = 0;
while (reader.hasNextLine()) { while (reader.hasNextLine()) {
final String line = reader.nextLine(); String line = reader.nextLine();
if (!line.contains(":")) { if (!line.contains(":")) {
// the fist line represent the player group, operator status and flying status // the fist line represent the player group, operator status and flying status
@ -130,10 +162,20 @@ public class FileCache {
continue; continue;
} }
final String[] in = line.split(":"); if (!line.startsWith("i") && !line.startsWith("w")) {
if (!in[0].equals("i") && !in[0].equals("w")) {
continue; continue;
} }
String lores = "";
String name = "";
if (line.split("\\*").length > 1) {
lores = line.split("\\*")[1];
line = line.split("\\*")[0];
}
if (line.split(";").length > 1) {
name = line.split(";")[1];
line = line.split(";")[0];
}
final String[] in = line.split(":");
// can enchant item? size ofstring in file - 4 all / 2 = number of enchant // can enchant item? size ofstring in file - 4 all / 2 = number of enchant
if (in[0].equals("i")) { if (in[0].equals("i")) {
stacki[i] = new ItemStack(Material.getMaterial(in[1]), stacki[i] = new ItemStack(Material.getMaterial(in[1]),
@ -144,6 +186,15 @@ public class FileCache {
k++; k++;
} }
} }
if (!name.isEmpty())
stacki[i].getItemMeta().setDisplayName(name);
if (!lores.isEmpty()) {
List<String> loreList = new ArrayList<String>();
for (String s : lores.split("%newline%")) {
loreList.add(s);
}
stacki[i].getItemMeta().setLore(loreList);
}
i++; i++;
} else { } else {
stacka[a] = new ItemStack(Material.getMaterial(in[1]), stacka[a] = new ItemStack(Material.getMaterial(in[1]),
@ -154,6 +205,15 @@ public class FileCache {
k++; k++;
} }
} }
if (!name.isEmpty())
stacka[a].getItemMeta().setDisplayName(name);
if (!lores.isEmpty()) {
List<String> loreList = new ArrayList<String>();
for (String s : lores.split("%newline%")) {
loreList.add(s);
}
stacka[a].getItemMeta().setLore(loreList);
}
a++; a++;
} }
} }

View File

@ -89,7 +89,7 @@ public class LimboCache {
gameMode = GameMode.SURVIVAL; gameMode = GameMode.SURVIVAL;
} }
if(player.isDead()) { if(player.isDead()) {
loc = plugin.getSpawnLocation(player, player.getWorld()); loc = plugin.getSpawnLocation(player);
} }
cache.put(player.getName().toLowerCase(), new LimboPlayer(name, loc, inv, arm, gameMode, operator, playerGroup, flying)); cache.put(player.getName().toLowerCase(), new LimboPlayer(name, loc, inv, arm, gameMode, operator, playerGroup, flying));
} }

View File

@ -302,9 +302,13 @@ public class AdminCommand implements CommandExecutor {
return true; return true;
} else if (args[0].equalsIgnoreCase("convertflattosql")) { } else if (args[0].equalsIgnoreCase("convertflattosql")) {
try { try {
FlatToSql.FlatToSqlConverter(); FlatToSql converter = new FlatToSql();
if (sender instanceof Player) if (sender instanceof Player) {
sender.sendMessage("[AuthMe] FlatFile converted to authme.sql file"); if (converter.convert())
sender.sendMessage("[AuthMe] FlatFile converted to authme.sql file");
else sender.sendMessage("[AuthMe] Error while converting to authme.sql");
}
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} catch (NullPointerException ex) { } catch (NullPointerException ex) {
@ -506,7 +510,7 @@ public class AdminCommand implements CommandExecutor {
if (target != null) { if (target != null) {
if (target.isOnline()) { if (target.isOnline()) {
if (Settings.isTeleportToSpawnEnabled) { if (Settings.isTeleportToSpawnEnabled) {
Location spawn = plugin.getSpawnLocation(target, target.getWorld()); Location spawn = plugin.getSpawnLocation(target);
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(target, target.getLocation(), spawn, false); SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(target, target.getLocation(), spawn, false);
plugin.getServer().getPluginManager().callEvent(tpEvent); plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) { if(!tpEvent.isCancelled()) {
@ -578,6 +582,21 @@ public class AdminCommand implements CommandExecutor {
new RoyalAuthConverter(plugin); new RoyalAuthConverter(plugin);
sender.sendMessage("[AuthMe] RoyalAuth database has been imported correctly"); sender.sendMessage("[AuthMe] RoyalAuth database has been imported correctly");
return true; return true;
} else if (args[0].equalsIgnoreCase("getip")) {
if (args.length < 2) {
sender.sendMessage("Usage : /authme getip onlinePlayerName");
return true;
}
if (Bukkit.getOfflinePlayer(args[1]).isOnline()) {
Player player = Bukkit.getPlayer(args[1]);
sender.sendMessage(player.getName() + " actual ip is : " + player.getAddress().getAddress().getHostAddress() + ":" + player.getAddress().getPort());
sender.sendMessage(player.getName() + " real ip is : " + plugin.getIP(player));
return true;
} else {
sender.sendMessage("This player is not actually online");
sender.sendMessage("Usage : /authme getip onlinePlayerName");
return true;
}
} else { } else {
sender.sendMessage("Usage: /authme reload|register playername password|changepassword playername password|unregister playername"); sender.sendMessage("Usage: /authme reload|register playername password|changepassword playername password|unregister playername");
} }

View File

@ -70,7 +70,7 @@ public class LogoutCommand implements CommandExecutor {
database.setUnlogged(name); database.setUnlogged(name);
if (Settings.isTeleportToSpawnEnabled) { if (Settings.isTeleportToSpawnEnabled) {
Location spawnLoc = plugin.getSpawnLocation(player, player.getWorld()); Location spawnLoc = plugin.getSpawnLocation(player);
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc); AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc);
plugin.getServer().getPluginManager().callEvent(tpEvent); plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) { if(!tpEvent.isCancelled()) {

View File

@ -71,7 +71,7 @@ public class UnregisterCommand implements CommandExecutor {
} }
if(Settings.isForcedRegistrationEnabled) { if(Settings.isForcedRegistrationEnabled) {
if (Settings.isTeleportToSpawnEnabled) { if (Settings.isTeleportToSpawnEnabled) {
Location spawn = plugin.getSpawnLocation(player, player.getWorld()); Location spawn = plugin.getSpawnLocation(player);
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false); SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false);
plugin.getServer().getPluginManager().callEvent(tpEvent); plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) { if(!tpEvent.isCancelled()) {
@ -114,7 +114,7 @@ public class UnregisterCommand implements CommandExecutor {
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " unregistered himself!")); plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " unregistered himself!"));
} }
if (Settings.isTeleportToSpawnEnabled) { if (Settings.isTeleportToSpawnEnabled) {
Location spawn = plugin.getSpawnLocation(player, player.getWorld()); Location spawn = plugin.getSpawnLocation(player);
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false); SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawn, false);
plugin.getServer().getPluginManager().callEvent(tpEvent); plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) { if(!tpEvent.isCancelled()) {

View File

@ -29,10 +29,12 @@ public class FlatToSql {
private static String lastlocZ; private static String lastlocZ;
private static String lastlocWorld; private static String lastlocWorld;
private static String columnEmail; private static String columnEmail;
private static String columnLogged;
private static String columnID;
private static File source; private static File source;
private static File output; private static File output;
public static void FlatToSqlConverter() throws IOException { public FlatToSql() {
tableName = Settings.getMySQLTablename; tableName = Settings.getMySQLTablename;
columnName = Settings.getMySQLColumnName; columnName = Settings.getMySQLColumnName;
columnPassword = Settings.getMySQLColumnPassword; columnPassword = Settings.getMySQLColumnPassword;
@ -43,7 +45,11 @@ public class FlatToSql {
lastlocZ = Settings.getMySQLlastlocZ; lastlocZ = Settings.getMySQLlastlocZ;
lastlocWorld = Settings.getMySQLlastlocWorld; lastlocWorld = Settings.getMySQLlastlocWorld;
columnEmail = Settings.getMySQLColumnEmail; columnEmail = Settings.getMySQLColumnEmail;
columnLogged = Settings.getMySQLColumnLogged;
columnID = Settings.getMySQLColumnId;
}
public boolean convert() throws IOException {
try { try {
source = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db"); source = new File(AuthMe.getInstance().getDataFolder() + File.separator + "auths.db");
source.createNewFile(); source.createNewFile();
@ -53,45 +59,46 @@ public class FlatToSql {
br = new BufferedReader(new FileReader(source)); br = new BufferedReader(new FileReader(source));
sql = new BufferedWriter(new FileWriter(output)); sql = new BufferedWriter(new FileWriter(output));
String createDB = " CREATE TABLE IF NOT EXISTS " + tableName + " (" String createDB = " CREATE TABLE IF NOT EXISTS " + tableName + " ("
+ "id INTEGER AUTO_INCREMENT," + columnID + " INTEGER AUTO_INCREMENT,"
+ columnName + " VARCHAR(255) NOT NULL UNIQUE," + columnName + " VARCHAR(255) NOT NULL UNIQUE,"
+ columnPassword + " VARCHAR(255) NOT NULL," + columnPassword + " VARCHAR(255) NOT NULL,"
+ columnIp + " VARCHAR(40) NOT NULL," + columnIp + " VARCHAR(40) NOT NULL DEFAULT '127.0.0.1',"
+ columnLastLogin + " BIGINT," + columnLastLogin + " BIGINT DEFAULT '0',"
+ lastlocX + " smallint(6) DEFAULT '0'," + lastlocX + " DOUBLE NOT NULL DEFAULT '0.0',"
+ lastlocY + " smallint(6) DEFAULT '0'," + lastlocY + " DOUBLE NOT NULL DEFAULT '0.0',"
+ lastlocZ + " smallint(6) DEFAULT '0'," + lastlocZ + " DOUBLE NOT NULL DEFAULT '0.0',"
+ lastlocWorld + " VARCHAR(255) DEFAULT 'world'," + lastlocWorld + " VARCHAR(255) DEFAULT 'world',"
+ columnEmail + " VARCHAR(255) NOT NULL," + columnEmail + " VARCHAR(255) DEFAULT 'your@email.com',"
+ "CONSTRAINT table_const_prim PRIMARY KEY (id));"; + columnLogged + " SMALLINT NOT NULL DEFAULT '0',"
+ "CONSTRAINT table_const_prim PRIMARY KEY (" + columnID + "));";
sql.write(createDB); sql.write(createDB);
String line; String line;
int i = 1;
String newline; String newline;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
sql.newLine(); sql.newLine();
String[] args = line.split(":"); String[] args = line.split(":");
if (args.length == 4) if (args.length == 4)
newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", 0, 0, 0, 'world', 'your@email.com');"; newline = "INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + lastlocX + "," + lastlocY + "," + lastlocZ + "," + lastlocWorld + "," + columnEmail + "," + columnLogged + ") VALUES ('" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", 0.0, 0.0, 0.0, 'world', 'your@email.com', 0);";
else if (args.length == 7) else if (args.length == 7)
newline = "INSERT INTO " + tableName + " VALUES (" + i + ", '" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", 'world', 'your@email.com');"; newline = "INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + lastlocX + "," + lastlocY + "," + lastlocZ + "," + lastlocWorld + "," + columnEmail + "," + columnLogged + ") VALUES ('" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", 'world', 'your@email.com', 0);";
else if (args.length == 8) 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');"; newline = "INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + lastlocX + "," + lastlocY + "," + lastlocZ + "," + lastlocWorld + "," + columnEmail + "," + columnLogged + ") VALUES ('" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", '" + args[7] + "', 'your@email.com', 0);";
else if (args.length == 9) 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] + "');"; newline = "INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + "," + lastlocX + "," + lastlocY + "," + lastlocZ + "," + lastlocWorld + "," + columnEmail + "," + columnLogged + ") VALUES ('" + args[0] + "', '" + args[1] + "', '" + args[2] + "', " + args[3] + ", " + args[4] + ", " + args[5] + ", " + args[6] + ", '" + args[7] + "', '" + args[8] + "', 0);";
else else
newline = ""; newline = "";
if (newline != "") if (newline != "")
sql.write(newline); sql.write(newline);
i = i + 1;
} }
sql.close(); sql.close();
br.close(); br.close();
ConsoleLogger.info("The FlatFile has been converted to authme.sql file"); ConsoleLogger.info("The FlatFile has been converted to authme.sql file");
return true;
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.showError(ex.getMessage());
} catch (IOException ex) { } catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.showError(ex.getMessage());
} }
return false;
} }
} }

View File

@ -183,6 +183,8 @@ public class MySQLDataSource implements DataSource {
Connection con = null; Connection con = null;
PreparedStatement pst = null; PreparedStatement pst = null;
ResultSet rs = null; ResultSet rs = null;
PlayerAuth pAuth = null;
int id = -1;
try { try {
con = makeSureConnectionIsReady(); con = makeSureConnectionIsReady();
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
@ -190,17 +192,26 @@ public class MySQLDataSource implements DataSource {
pst.setString(1, user); pst.setString(1, user);
rs = pst.executeQuery(); rs = pst.executeQuery();
if (rs.next()) { if (rs.next()) {
if (rs.getString(columnIp).isEmpty() ) { id = rs.getInt(columnID);
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "198.18.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld),rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName))); if (rs.getString(columnIp).isEmpty() && rs.getString(columnIp) != null) {
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "198.18.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld),rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
} else { } else {
if(!columnSalt.isEmpty()){ if(!columnSalt.isEmpty()){
if(!columnGroup.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.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName))); pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword),rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(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.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld),rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName))); else pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword),rs.getString(columnSalt), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld),rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
} else { } else {
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName))); pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
} }
} }
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
rs.close();
pst = con.prepareStatement("SELECT * FROM xf_user_authenticate WHERE " + columnID + "=?;");
pst.setInt(1, id);
if (rs.next()) {
pAuth.setHash(rs.getString(columnPassword));
}
}
} else { } else {
return null; return null;
} }
@ -215,6 +226,7 @@ public class MySQLDataSource implements DataSource {
close(pst); close(pst);
close(con); close(con);
} }
return pAuth;
} }
@Override @Override
@ -363,6 +375,21 @@ public class MySQLDataSource implements DataSource {
pst.executeUpdate(); pst.executeUpdate();
} }
} }
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
int id;
ResultSet rs = null;
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, auth.getNickname());
rs = pst.executeQuery();
if (rs.next()) {
id = rs.getInt(columnID);
// Insert password in the correct table
pst = con.prepareStatement("INSERT INTO xf_user_authenticate (user_id, scheme_class, data) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "XenForo_Authentication_Core12");
pst.setString(3, auth.getHash());
}
}
} catch (SQLException ex) { } catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.showError(ex.getMessage());
return false; return false;
@ -386,6 +413,20 @@ public class MySQLDataSource implements DataSource {
pst.setString(1, auth.getHash()); pst.setString(1, auth.getHash());
pst.setString(2, auth.getNickname()); pst.setString(2, auth.getNickname());
pst.executeUpdate(); pst.executeUpdate();
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
int id;
ResultSet rs = null;
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, auth.getNickname());
rs = pst.executeQuery();
if (rs.next()) {
id = rs.getInt(columnID);
// Insert password in the correct table
pst = con.prepareStatement("UPDATE xf_user_authenticate SET data=? WHERE " + columnID + "=?;");
pst.setString(1, auth.getHash());
pst.setInt(2, id);
}
}
} catch (SQLException ex) { } catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.showError(ex.getMessage());
return false; return false;
@ -481,6 +522,19 @@ public class MySQLDataSource implements DataSource {
PreparedStatement pst = null; PreparedStatement pst = null;
try { try {
con = makeSureConnectionIsReady(); con = makeSureConnectionIsReady();
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
int id;
ResultSet rs = null;
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user);
rs = pst.executeQuery();
if (rs.next()) {
id = rs.getInt(columnID);
// Remove data
pst = con.prepareStatement("DELETE FROM xf_user_authenticate WHERE " + columnID + "=?;");
pst.setInt(1, id);
}
}
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;"); pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user); pst.setString(1, user);
pst.executeUpdate(); pst.executeUpdate();

View File

@ -11,7 +11,6 @@ import org.bukkit.Bukkit;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -365,7 +364,7 @@ public class AuthMePlayerListener implements Listener {
} }
int radius = Settings.getMovementRadius; int radius = Settings.getMovementRadius;
Location spawn = plugin.getSpawnLocation(player, player.getWorld()); Location spawn = plugin.getSpawnLocation(player);
if (!event.getPlayer().getWorld().equals(spawn.getWorld())) { if (!event.getPlayer().getWorld().equals(spawn.getWorld())) {
event.getPlayer().teleport(spawn); event.getPlayer().teleport(spawn);
@ -388,14 +387,14 @@ public class AuthMePlayerListener implements Listener {
} }
if (!Settings.countriesBlacklist.isEmpty()) { if (!Settings.countriesBlacklist.isEmpty()) {
String code = plugin.getCountryCode(event.getAddress()); String code = plugin.getCountryCode(event.getAddress().getHostAddress());
if (((code == null) || (Settings.countriesBlacklist.contains(code) && !API.isRegistered(name))) && !plugin.authmePermissible(player, "authme.bypassantibot")) { if (((code == null) || (Settings.countriesBlacklist.contains(code) && !API.isRegistered(name))) && !plugin.authmePermissible(player, "authme.bypassantibot")) {
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("country_banned")[0]); event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("country_banned")[0]);
return; return;
} }
} }
if (Settings.enableProtection && !Settings.countries.isEmpty()) { if (Settings.enableProtection && !Settings.countries.isEmpty()) {
String code = plugin.getCountryCode(event.getAddress()); String code = plugin.getCountryCode(event.getAddress().getHostAddress());
if (((code == null) || (!Settings.countries.contains(code) && !API.isRegistered(name))) && !plugin.authmePermissible(player, "authme.bypassantibot")) { if (((code == null) || (!Settings.countries.contains(code) && !API.isRegistered(name))) && !plugin.authmePermissible(player, "authme.bypassantibot")) {
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("country_banned")[0]); event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("country_banned")[0]);
return; return;
@ -540,9 +539,8 @@ public class AuthMePlayerListener implements Listener {
return; return;
} }
Player player = event.getPlayer(); Player player = event.getPlayer();
World world = player.getWorld();
final String name = player.getName().toLowerCase(); final String name = player.getName().toLowerCase();
Location spawnLoc = plugin.getSpawnLocation(player, world); Location spawnLoc = plugin.getSpawnLocation(player);
gm = player.getGameMode(); gm = player.getGameMode();
gameMode.put(name, gm); gameMode.put(name, gm);
BukkitScheduler sched = plugin.getServer().getScheduler(); BukkitScheduler sched = plugin.getServer().getScheduler();
@ -557,11 +555,7 @@ public class AuthMePlayerListener implements Listener {
} catch (Exception e) {} } catch (Exception e) {}
} }
String ip = player.getAddress().getAddress().getHostAddress(); String ip = plugin.getIP(player);
if (Settings.bungee) {
if (plugin.realIp.containsKey(name))
ip = plugin.realIp.get(name);
}
if(Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) { if(Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) {
GameMode gM = gameMode.get(name); GameMode gM = gameMode.get(name);
this.causeByAuthMe = true; this.causeByAuthMe = true;
@ -573,7 +567,7 @@ public class AuthMePlayerListener implements Listener {
return; return;
} }
if(Settings.getMaxJoinPerIp > 0 && !plugin.authmePermissible(player, "authme.allow2accounts") && !ip.equalsIgnoreCase("127.0.0.1") && !ip.equalsIgnoreCase("localhost")) { if(Settings.getMaxJoinPerIp > 0 && !plugin.authmePermissible(player, "authme.allow2accounts") && !ip.equalsIgnoreCase("127.0.0.1") && !ip.equalsIgnoreCase("localhost")) {
if (plugin.hasJoinedIp(ip)) { if (plugin.hasJoinedIp(player.getName(), ip)) {
player.kickPlayer("A player with the same IP is already in game!"); player.kickPlayer("A player with the same IP is already in game!");
return; return;
} }
@ -637,10 +631,9 @@ public class AuthMePlayerListener implements Listener {
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name)); SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
plugin.getServer().getPluginManager().callEvent(tpEvent); plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) { if(!tpEvent.isCancelled()) {
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) { if (player != null && player.isOnline() && tpEvent.getTo() != null) {
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load(); player.teleport(tpEvent.getTo());
} }
player.teleport(tpEvent.getTo());
} }
} }
placePlayerSafely(player, spawnLoc); placePlayerSafely(player, spawnLoc);
@ -660,10 +653,9 @@ public class AuthMePlayerListener implements Listener {
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name)); SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
plugin.getServer().getPluginManager().callEvent(tpEvent); plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) { if(!tpEvent.isCancelled()) {
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) { if (player != null && player.isOnline() && tpEvent.getTo() != null) {
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load(); player.teleport(tpEvent.getTo());
} }
player.teleport(tpEvent.getTo());
} }
} }
if (!Settings.isForcedRegistrationEnabled) { if (!Settings.isForcedRegistrationEnabled) {
@ -750,11 +742,7 @@ public class AuthMePlayerListener implements Listener {
return; return;
} }
String ip = player.getAddress().getAddress().getHostAddress(); String ip = plugin.getIP(player);
if (Settings.bungee) {
if (plugin.realIp.containsKey(name))
ip = plugin.realIp.get(name);
}
if (PlayerCache.getInstance().isAuthenticated(name) && !player.isDead()) { if (PlayerCache.getInstance().isAuthenticated(name) && !player.isDead()) {
if(Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) { if(Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) {
@ -826,11 +814,7 @@ public class AuthMePlayerListener implements Listener {
String name = player.getName().toLowerCase(); String name = player.getName().toLowerCase();
String ip = player.getAddress().getAddress().getHostAddress(); String ip = plugin.getIP(player);
if (Settings.bungee) {
if (plugin.realIp.containsKey(name))
ip = plugin.realIp.get(name);
}
if ((PlayerCache.getInstance().isAuthenticated(name)) && (!player.isDead())) { if ((PlayerCache.getInstance().isAuthenticated(name)) && (!player.isDead())) {
if ((Settings.isSaveQuitLocationEnabled) && data.isAuthAvailable(name)){ if ((Settings.isSaveQuitLocationEnabled) && data.isAuthAvailable(name)){
final PlayerAuth auth = new PlayerAuth(name, loc.getX(), loc.getY(), loc.getZ(),loc.getWorld().getName()); final PlayerAuth auth = new PlayerAuth(name, loc.getX(), loc.getY(), loc.getZ(),loc.getWorld().getName());
@ -863,10 +847,9 @@ public class AuthMePlayerListener implements Listener {
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc()); AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
plugin.getServer().getPluginManager().callEvent(tpEvent); plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) { if(!tpEvent.isCancelled()) {
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) { if (player != null && player.isOnline() && tpEvent.getTo() != null) {
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load(); player.teleport(tpEvent.getTo());
} }
player.teleport(tpEvent.getTo());
} }
} catch (NullPointerException npe) { } catch (NullPointerException npe) {
} }
@ -1122,7 +1105,7 @@ public class AuthMePlayerListener implements Listener {
if (!Settings.isForcedRegistrationEnabled) if (!Settings.isForcedRegistrationEnabled)
return; return;
Location spawn = plugin.getSpawnLocation(player, player.getWorld()); Location spawn = plugin.getSpawnLocation(player);
if(Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) { if(Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) {
final PlayerAuth auth = new PlayerAuth(name,spawn.getX(),spawn.getY(),spawn.getZ(),spawn.getWorld().getName()); final PlayerAuth auth = new PlayerAuth(name,spawn.getX(),spawn.getY(),spawn.getZ(),spawn.getWorld().getName());
try { try {

View File

@ -26,10 +26,10 @@ public class AuthMeServerListener implements Listener {
if (!Settings.enableProtection) return; if (!Settings.enableProtection) return;
if (Settings.countries.isEmpty()) return; if (Settings.countries.isEmpty()) return;
if (!Settings.countriesBlacklist.isEmpty()) { if (!Settings.countriesBlacklist.isEmpty()) {
if(Settings.countriesBlacklist.contains(plugin.getCountryCode(event.getAddress()))) if(Settings.countriesBlacklist.contains(plugin.getCountryCode(event.getAddress().getHostAddress())))
event.setMotd(m._("country_banned")[0]); event.setMotd(m._("country_banned")[0]);
} }
if(Settings.countries.contains(plugin.getCountryCode(event.getAddress()))) { if(Settings.countries.contains(plugin.getCountryCode(event.getAddress().getHostAddress()))) {
event.setMotd(plugin.getServer().getMotd()); event.setMotd(plugin.getServer().getMotd());
} else { } else {
event.setMotd(m._("country_banned")[0]); event.setMotd(m._("country_banned")[0]);

View File

@ -43,12 +43,7 @@ public class AsyncronousLogin {
} }
protected String getIP() { protected String getIP() {
String ip = player.getAddress().getAddress().getHostAddress(); return plugin.getIP(player);
if (Settings.bungee) {
if (plugin.realIp.containsKey(name))
ip = plugin.realIp.get(name);
}
return ip;
} }
protected boolean needsCaptcha() { protected boolean needsCaptcha() {
if (Settings.useCaptcha) { if (Settings.useCaptcha) {
@ -100,7 +95,7 @@ public class AsyncronousLogin {
return null; return null;
} }
if (Settings.getMaxLoginPerIp > 0 && !plugin.authmePermissible(player, "authme.allow2accounts") && !getIP().equalsIgnoreCase("127.0.0.1") && !getIP().equalsIgnoreCase("localhost")) { if (Settings.getMaxLoginPerIp > 0 && !plugin.authmePermissible(player, "authme.allow2accounts") && !getIP().equalsIgnoreCase("127.0.0.1") && !getIP().equalsIgnoreCase("localhost")) {
if (plugin.isLoggedIp(getIP())) { if (plugin.isLoggedIp(realName, getIP())) {
m._(player, "logged_in"); m._(player, "logged_in");
return null; return null;
} }

View File

@ -68,7 +68,7 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
} }
} }
protected void teleportToSpawn() { protected void teleportToSpawn() {
Location spawnL = plugin.getSpawnLocation(player, player.getWorld()); Location spawnL = plugin.getSpawnLocation(player);
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnL, true); SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnL, true);
pm.callEvent(tpEvent); pm.callEvent(tpEvent);
if (!tpEvent.isCancelled()) { if (!tpEvent.isCancelled()) {

View File

@ -15,6 +15,7 @@ import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
public class AsyncronousRegister { public class AsyncronousRegister {
protected Player player; protected Player player;
protected String name; protected String name;
protected String password; protected String password;
@ -37,13 +38,7 @@ public class AsyncronousRegister {
} }
protected String getIp() { protected String getIp() {
String ip = player.getAddress().getAddress().getHostAddress(); return plugin.getIP(player);
if (Settings.bungee) {
if (plugin.realIp.containsKey(name))
ip = plugin.realIp.get(name);
}
return ip;
} }
protected void preRegister() { protected void preRegister() {

View File

@ -49,7 +49,7 @@ public class ProcessSyncronousEmailRegister implements Runnable {
if (Settings.isTeleportToSpawnEnabled) { if (Settings.isTeleportToSpawnEnabled) {
World world = player.getWorld(); World world = player.getWorld();
Location loca = plugin.getSpawnLocation(player, world); Location loca = plugin.getSpawnLocation(player);
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca); RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
plugin.getServer().getPluginManager().callEvent(tpEvent); plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) { if(!tpEvent.isCancelled()) {
@ -65,7 +65,7 @@ public class ProcessSyncronousEmailRegister implements Runnable {
} }
player.saveData(); player.saveData();
if (!Settings.noConsoleSpam) if (!Settings.noConsoleSpam)
ConsoleLogger.info(player.getName() + " registered "+player.getAddress().getAddress().getHostAddress()); ConsoleLogger.info(player.getName() + " registered "+plugin.getIP(player));
if(plugin.notifications != null) { if(plugin.notifications != null) {
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " has registered by email!")); plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " has registered by email!"));
} }

View File

@ -44,7 +44,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
protected void forceLogin(Player player) { protected void forceLogin(Player player) {
if (Settings.isTeleportToSpawnEnabled) { if (Settings.isTeleportToSpawnEnabled) {
Location spawnLoc = plugin.getSpawnLocation(player, player.getWorld()); Location spawnLoc = plugin.getSpawnLocation(player);
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc); AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc);
plugin.getServer().getPluginManager().callEvent(tpEvent); plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) { if(!tpEvent.isCancelled()) {
@ -81,7 +81,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
player.setGameMode(limbo.getGameMode()); player.setGameMode(limbo.getGameMode());
if (Settings.isTeleportToSpawnEnabled) { if (Settings.isTeleportToSpawnEnabled) {
World world = player.getWorld(); World world = player.getWorld();
Location loca = plugin.getSpawnLocation(player, world); Location loca = plugin.getSpawnLocation(player);
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca); RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
plugin.getServer().getPluginManager().callEvent(tpEvent); plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) { if(!tpEvent.isCancelled()) {
@ -111,7 +111,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
player.saveData(); player.saveData();
if (!Settings.noConsoleSpam) if (!Settings.noConsoleSpam)
ConsoleLogger.info(player.getName() + " registered "+player.getAddress().getAddress().getHostAddress()); ConsoleLogger.info(player.getName() + " registered "+plugin.getIP(player));
if(plugin.notifications != null) { if(plugin.notifications != null) {
plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " has registered!")); plugin.notifications.showNotification(new Notification("[AuthMe] " + player.getName() + " has registered!"));
} }

View File

@ -59,7 +59,7 @@ public final class Settings extends YamlConfiguration {
disableSocialSpy, useMultiThreading, forceOnlyAfterLogin, useEssentialsMotd, disableSocialSpy, useMultiThreading, forceOnlyAfterLogin, useEssentialsMotd,
usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword, purgeLimitedCreative, usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword, purgeLimitedCreative,
purgeAntiXray, purgePermissions, enableProtection, enableAntiBot, recallEmail, useWelcomeMessage, purgeAntiXray, purgePermissions, enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
broadcastWelcomeMessage, forceRegKick, forceRegLogin; broadcastWelcomeMessage, forceRegKick, forceRegLogin, checkVeryGames;
public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort, public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort,
getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename, getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename,
@ -241,6 +241,7 @@ public void loadConfigOptions() {
spawnPriority = configFile.getString("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default"); spawnPriority = configFile.getString("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0); getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0); getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
checkVeryGames = configFile.getBoolean("VeryGames.enableIpCheck", false);
// Load the welcome message // Load the welcome message
getWelcomeMessage(plugin); getWelcomeMessage(plugin);
@ -398,163 +399,113 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
spawnPriority = configFile.getString("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default"); spawnPriority = configFile.getString("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0); getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0); getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
checkVeryGames = configFile.getBoolean("VeryGames.enableIpCheck", false);
// Reload the welcome message // Reload the welcome message
getWelcomeMessage(AuthMe.getInstance()); getWelcomeMessage(AuthMe.getInstance());
} }
public void mergeConfig() { public void mergeConfig() {
if(!contains("DataSource.mySQLColumnEmail")) boolean changes = false;
set("DataSource.mySQLColumnEmail","email"); if(contains("Xenoforo.predefinedSalt"))
if(!contains("Email.RecoveryPasswordLength")) set("Xenoforo.predefinedSalt", null);
set("Email.RecoveryPasswordLength", 8); if(configFile.getString("settings.security.passwordHash","SHA256").toUpperCase().equals("XFSHA1") || configFile.getString("settings.security.passwordHash","SHA256").toUpperCase().equals("XFSHA256"))
if(!contains("Email.mailPort")) set("settings.security.passwordHash", "XENFORO");
set("Email.mailPort", 465); if(!contains("Protection.enableProtection")) {
if(!contains("Email.mailSMTP")) set("Protection.enableProtection", false);
set("Email.mailSMTP", "smtp.gmail.com"); changes = true;
if(!contains("Email.mailAccount")) }
set("Email.mailAccount", ""); if(!contains("Protection.countries")) {
if(!contains("Email.mailPassword")) countries = new ArrayList<String>();
set("Email.mailPassword", ""); countries.add("US");
if(!contains("ExternalBoardOptions.mySQLOtherUsernameColumns")) countries.add("GB");
set("ExternalBoardOptions.mySQLOtherUsernameColumns", new ArrayList<String>()); set("Protection.countries", countries);
if(!contains("settings.restrictions.displayOtherAccounts")) changes = true;
set("settings.restrictions.displayOtherAccounts", true); }
if(!contains("DataSource.mySQLColumnId")) if(!contains("Protection.enableAntiBot")) {
set("DataSource.mySQLColumnId", "id"); set("Protection.enableAntiBot", false);
if(!contains("Email.mailSenderName")) changes = true;
set("Email.mailSenderName", ""); }
if(!contains("Security.captcha.useCaptcha")) if(!contains("Protection.antiBotSensibility")) {
set("Security.captcha.useCaptcha", false); set("Protection.antiBotSensibility", 5);
if(!contains("Security.captcha.maxLoginTry")) changes = true;
set("Security.captcha.maxLoginTry", 5); }
if(!contains("Security.captcha.captchaLength")) if(!contains("Protection.antiBotDuration")) {
set("Security.captcha.captchaLength", 5); set("Protection.antiBotDuration", 10);
if(!contains("Email.mailSubject")) changes = true;
set("Email.mailSubject", ""); }
if(!contains("Email.mailText")) if(!contains("settings.forceCommands")) {
set("Email.mailText", "Dear <playername>, <br /><br /> This is your new AuthMe password for the server <br /><br /> <servername> : <br /><br /> <generatedpass><br /><br />Do not forget to change password after login! <br /> /changepassword <generatedpass> newPassword"); set("settings.forceCommands", new ArrayList<String>());
if(contains("Email.mailText")) { changes = true;
try { }
String s = getString("Email.mailText"); if(!contains("Email.recallPlayers")) {
s = s.replaceAll("\n", "<br />"); set("Email.recallPlayers", false);
set("Email.mailText", null); changes = true;
set("Email.mailText", s); }
} catch (Exception e) {} if(!contains("Email.delayRecall")) {
} set("Email.delayRecall", 5);
if(!contains("settings.registration.enableEmailRegistrationSystem")) changes = true;
set("settings.registration.enableEmailRegistrationSystem", false); }
if(!contains("settings.security.doubleMD5SaltLength")) if(!contains("settings.useWelcomeMessage")) {
set("settings.security.doubleMD5SaltLength", 8); set("settings.useWelcomeMessage", true);
if(!contains("Email.maxRegPerEmail")) changes = true;
set("Email.maxRegPerEmail", 1); }
if(!contains("Hooks.multiverse")) { if(!contains("settings.security.unsafePasswords")) {
set("Hooks.multiverse", true); List<String> str = new ArrayList<String>();
set("Hooks.chestshop", true); str.add("123456");
set("Hooks.notifications", true); str.add("password");
set("Hooks.bungeecord", false); set("settings.security.unsafePasswords", str);
} changes = true;
if(!contains("settings.restrictions.ForceSpawnOnTheseWorlds")) }
set("settings.restrictions.ForceSpawnOnTheseWorlds", new ArrayList<String>()); if(!contains("Protection.countriesBlacklist")) {
if(!contains("settings.restrictions.banUnsafedIP")) countriesBlacklist = new ArrayList<String>();
set("settings.restrictions.banUnsafedIP", false); countriesBlacklist.add("A1");
if(!contains("settings.registration.doubleEmailCheck")) set("Protection.countriesBlacklist", countriesBlacklist);
set("settings.registration.doubleEmailCheck", false); changes = true;
if(!contains("settings.sessions.sessionExpireOnIpChange")) }
set("settings.sessions.sessionExpireOnIpChange", false); if(!contains("settings.broadcastWelcomeMessage")) {
if(!contains("Security.console.logConsole")) set("settings.broadcastWelcomeMessage", false);
set("Security.console.logConsole", false); changes = true;
if(!contains("Hooks.disableSocialSpy")) }
set("Hooks.disableSocialSpy", true); if(!contains("settings.registration.forceKickAfterRegister")) {
if(!contains("Performances.useMultiThreading")) set("settings.registration.forceKickAfterRegister", false);
set("Performances.useMultiThreading", true); changes = true;
if(!contains("ExternalBoardOptions.bCryptLog2Round")) }
set("ExternalBoardOptions.bCryptLog2Round", 10); if(!contains("settings.registration.forceLoginAfterRegister")) {
if(!contains("DataSource.mySQLlastlocWorld")) set("settings.registration.forceLoginAfterRegister", false);
set("DataSource.mySQLlastlocWorld", "world"); changes = true;
if(!contains("settings.GameMode.ForceOnlyAfterLogin")) }
set("settings.GameMode.ForceOnlyAfterLogin", false); if(!contains("DataSource.mySQLColumnLogged")) {
if(!contains("Hooks.useEssentialsMotd")) set("DataSource.mySQLColumnLogged", "isLogged");
set("Hooks.useEssentialsMotd", false); changes = true;
if(!contains("Purge.useAutoPurge")) { }
set("Purge.useAutoPurge", false); if(!contains("settings.restrictions.spawnPriority")) {
set("Purge.daysBeforeRemovePlayer", 60); set("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
set("Purge.removePlayerDat", false); changes = true;
set("Purge.removeEssentialsFile", false); }
set("Purge.defaultWorld", "world"); if(!contains("settings.restrictions.maxLoginPerIp")) {
} set("settings.restrictions.maxLoginPerIp", 0);
if(!contains("ExternalBoardOptions.phpbbTablePrefix")) { changes = true;
set("ExternalBoardOptions.phpbbTablePrefix", "phpbb_"); }
set("ExternalBoardOptions.phpbbActivatedGroupId", 2); if(!contains("settings.restrictions.maxJoinPerIp")) {
} set("settings.restrictions.maxJoinPerIp", 0);
if(!contains("settings.security.supportOldPasswordHash")) changes = true;
set("settings.security.supportOldPasswordHash", false); }
if(!contains("ExternalBoardOptions.wordpressTablePrefix")) if(!contains("VeryGames.enableIpCheck")) {
set("ExternalBoardOptions.wordpressTablePrefix", "wp_"); set("VeryGames.enableIpCheck", false);
if(contains("Xenoforo.predefinedSalt")) changes = true;
set("Xenoforo.predefinedSalt", null); }
if(configFile.getString("settings.security.passwordHash","SHA256").toUpperCase().equals("XFSHA1") || configFile.getString("settings.security.passwordHash","SHA256").toUpperCase().equals("XFSHA256")) if(getString("settings.restrictions.allowedNicknameCharacters").equals("[a-zA-Z0-9_?]*"))
set("settings.security.passwordHash", "XENFORO"); set("settings.restrictions.allowedNicknameCharacters", "[a-zA-Z0-9_]*");
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>());
if(!contains("Email.recallPlayers"))
set("Email.recallPlayers", false);
if(!contains("Email.delayRecall"))
set("Email.delayRecall", 5);
if(!contains("settings.useWelcomeMessage"))
set("settings.useWelcomeMessage", true);
if(!contains("settings.security.unsafePasswords")) {
List<String> str = new ArrayList<String>();
str.add("123456");
str.add("password");
set("settings.security.unsafePasswords", str);
}
if(!contains("Protection.countriesBlacklist")) {
countriesBlacklist = new ArrayList<String>();
countriesBlacklist.add("A1");
set("Protection.countriesBlacklist", countriesBlacklist);
}
if(!contains("settings.broadcastWelcomeMessage"))
set("settings.broadcastWelcomeMessage", false);
if(!contains("settings.registration.forceKickAfterRegister"))
set("settings.registration.forceKickAfterRegister", false);
if(!contains("settings.registration.forceLoginAfterRegister"))
set("settings.registration.forceLoginAfterRegister", false);
if(!contains("DataSource.mySQLColumnLogged"))
set("DataSource.mySQLColumnLogged", "isLogged");
if(!contains("settings.restrictions.spawnPriority"))
set("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
if(!contains("settings.restrictions.maxLoginPerIp"))
set("settings.restrictions.maxLoginPerIp", 0);
if(!contains("settings.restrictions.maxJoinPerIp"))
set("settings.restrictions.maxJoinPerIp", 0);
plugin.getLogger().warning("Merge new Config Options if needed.."); if (changes) {
plugin.getLogger().warning("Please check your config.yml file!"); plugin.getLogger().warning("Merge new Config Options if needed..");
plugin.saveConfig(); plugin.getLogger().warning("Please check your config.yml file!");
}
plugin.saveConfig();
return; return;
} }
private static HashAlgorithm getPasswordHash() { private static HashAlgorithm getPasswordHash() {

View File

@ -212,6 +212,8 @@ public class MySQLThread extends Thread implements DataSource {
Connection con = null; Connection con = null;
PreparedStatement pst = null; PreparedStatement pst = null;
ResultSet rs = null; ResultSet rs = null;
PlayerAuth pAuth = null;
int id = -1;
try { try {
con = makeSureConnectionIsReady(); con = makeSureConnectionIsReady();
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
@ -219,17 +221,26 @@ public class MySQLThread extends Thread implements DataSource {
pst.setString(1, user); pst.setString(1, user);
rs = pst.executeQuery(); rs = pst.executeQuery();
if (rs.next()) { if (rs.next()) {
if (rs.getString(columnIp).isEmpty() ) { id = rs.getInt(columnID);
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "198.18.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld),rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName))); if (rs.getString(columnIp).isEmpty() && rs.getString(columnIp) != null) {
pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "198.18.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld),rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
} else { } else {
if(!columnSalt.isEmpty()){ if(!columnSalt.isEmpty()){
if(!columnGroup.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.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName))); pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword),rs.getString(columnSalt), rs.getInt(columnGroup), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(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.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld),rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName))); else pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword),rs.getString(columnSalt), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld),rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
} else { } else {
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName))); pAuth = new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), rs.getString(columnIp), rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld), rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
} }
} }
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
rs.close();
pst = con.prepareStatement("SELECT * FROM xf_user_authenticate WHERE " + columnID + "=?;");
pst.setInt(1, id);
if (rs.next()) {
pAuth.setHash(rs.getString(columnPassword));
}
}
} else { } else {
return null; return null;
} }
@ -244,6 +255,7 @@ public class MySQLThread extends Thread implements DataSource {
close(pst); close(pst);
close(con); close(con);
} }
return pAuth;
} }
@Override @Override
@ -252,7 +264,7 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null; PreparedStatement pst = null;
try { try {
con = makeSureConnectionIsReady(); 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 = con.prepareStatement("INSERT INTO " + tableName + "(" + columnName + "," + columnPassword + "," + columnIp + "," + columnLastLogin + ") VALUES (?,?,?,?);");
pst.setString(1, auth.getNickname()); pst.setString(1, auth.getNickname());
pst.setString(2, auth.getHash()); pst.setString(2, auth.getHash());
@ -392,6 +404,21 @@ public class MySQLThread extends Thread implements DataSource {
pst.executeUpdate(); pst.executeUpdate();
} }
} }
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
int id;
ResultSet rs = null;
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, auth.getNickname());
rs = pst.executeQuery();
if (rs.next()) {
id = rs.getInt(columnID);
// Insert password in the correct table
pst = con.prepareStatement("INSERT INTO xf_user_authenticate (user_id, scheme_class, data) VALUES (?,?,?);");
pst.setInt(1, id);
pst.setString(2, "XenForo_Authentication_Core12");
pst.setString(3, auth.getHash());
}
}
} catch (SQLException ex) { } catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.showError(ex.getMessage());
return false; return false;
@ -415,6 +442,20 @@ public class MySQLThread extends Thread implements DataSource {
pst.setString(1, auth.getHash()); pst.setString(1, auth.getHash());
pst.setString(2, auth.getNickname()); pst.setString(2, auth.getNickname());
pst.executeUpdate(); pst.executeUpdate();
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
int id;
ResultSet rs = null;
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, auth.getNickname());
rs = pst.executeQuery();
if (rs.next()) {
id = rs.getInt(columnID);
// Insert password in the correct table
pst = con.prepareStatement("UPDATE xf_user_authenticate SET data=? WHERE " + columnID + "=?;");
pst.setString(1, auth.getHash());
pst.setInt(2, id);
}
}
} catch (SQLException ex) { } catch (SQLException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.showError(ex.getMessage());
return false; return false;
@ -510,6 +551,19 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null; PreparedStatement pst = null;
try { try {
con = makeSureConnectionIsReady(); con = makeSureConnectionIsReady();
if (Settings.getPasswordHash == HashAlgorithm.XENFORO) {
int id;
ResultSet rs = null;
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user);
rs = pst.executeQuery();
if (rs.next()) {
id = rs.getInt(columnID);
// Remove data
pst = con.prepareStatement("DELETE FROM xf_user_authenticate WHERE " + columnID + "=?;");
pst.setInt(1, id);
}
}
pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;"); pst = con.prepareStatement("DELETE FROM " + tableName + " WHERE " + columnName + "=?;");
pst.setString(1, user); pst.setString(1, user);
pst.executeUpdate(); pst.executeUpdate();

View File

@ -85,7 +85,7 @@ settings:
- /passpartu - /passpartu
- /email - /email
- /captcha - /captcha
# Maximum Registraion per IP default: 1 # Maximum Registration per IP default: 1
maxRegPerIp: 1 maxRegPerIp: 1
# max allowed nick length (Warning when you use # max allowed nick length (Warning when you use
# mysql and choose a value >20 you have to # mysql and choose a value >20 you have to
@ -136,7 +136,7 @@ settings:
# should be kicked. Set to 0 to disable. # should be kicked. Set to 0 to disable.
timeout: 30 timeout: 30
# Regex sintax for allowed Char in player name. # Regex sintax for allowed Char in player name.
allowedNicknameCharacters: '[a-zA-Z0-9_?]*' allowedNicknameCharacters: '[a-zA-Z0-9_]*'
# How far can unregistered players walk? Set to 0 # How far can unregistered players walk? Set to 0
# for unlimited radius # for unlimited radius
allowedMovementRadius: 100 allowedMovementRadius: 100
@ -398,4 +398,7 @@ Protection:
# Max number of player allowed to login in 5 secs before enable AntiBot system automatically # Max number of player allowed to login in 5 secs before enable AntiBot system automatically
antiBotSensibility: 5 antiBotSensibility: 5
# Duration in minutes of the antibot automatic system # Duration in minutes of the antibot automatic system
antiBotDuration: 10 antiBotDuration: 10
VeryGames:
# These features are only available on VeryGames Server Provider
enableIpCheck: false

View File

@ -35,22 +35,22 @@ name_len: '&cTvuj nick je prilis kratky, nebo prilis dlouhy'
regex: '&cTvuj nick obsahuje nepovolene znaky. Pripustne znaky jsou: REG_EX' regex: '&cTvuj nick obsahuje nepovolene znaky. Pripustne znaky jsou: REG_EX'
add_email: '&cPridej prosim svuj email pomoci : /email add TvujEmail TvujEmail' add_email: '&cPridej prosim svuj email pomoci : /email add TvujEmail TvujEmail'
bad_database_email: '[AuthMe] Prikaz /email je mozno pouzit jen s MySQL a SQLite, kontaktuj Admina' bad_database_email: '[AuthMe] Prikaz /email je mozno pouzit jen s MySQL a SQLite, kontaktuj Admina'
recovery_email: '&cZapomels heslo? Zadej: /email recovery <TvujEmail>' recovery_email: '&cZapomel jsi heslo? Zadej: /email recovery <TvujEmail>'
usage_captcha: '&cPouzij: /captcha <Captcha_text>' usage_captcha: '&cPouzij: /captcha <Captcha_text>'
wrong_captcha: '&cSpatne opsana Captcha, pouzij prosim: /captcha CAPTCHA_TEXT' wrong_captcha: '&cSpatne opsana Captcha, pouzij prosim: /captcha CAPTCHA_TEXT'
valid_captcha: '&cZadana captcha je OK !' valid_captcha: '&cZadana captcha je v poradku!'
kick_forvip: '&cA VIP Hrac se pripojil na plny server!' kick_forvip: '&cVIP Hrac se pripojil na plny server!'
kick_fullserver: '&cServer je plne obsazen, zkus to pozdeji prosim !' kick_fullserver: '&cServer je plne obsazen, zkus to pozdeji prosim!'
usage_email_add: '&fPouzij: /email add <email> <potvrzeni_emailu> ' usage_email_add: '&fPouzij: /email add <email> <potvrzeni_emailu>'
usage_email_change: '&fPouzij: /email change <StaryEmail> <NovyEmail> ' usage_email_change: '&fPouzij: /email change <StaryEmail> <NovyEmail>'
usage_email_recovery: '&fPouzij: /email recovery <Email>' usage_email_recovery: '&fPouzij: /email recovery <Email>'
new_email_invalid: '[AuthMe] Novy email je chybne zadan!' new_email_invalid: '[AuthMe] Novy email je chybne zadan!'
old_email_invalid: '[AuthMe] Stary email je chybne zadan!' old_email_invalid: '[AuthMe] Stary email je chybne zadan!'
email_invalid: '[AuthMe] Nespravny email' email_invalid: '[AuthMe] Nespravny email'
email_added: '[AuthMe] Email pridan !' email_added: '[AuthMe] Email pridan!'
email_confirm: '[AuthMe] Potvrd prosim svuj email !' email_confirm: '[AuthMe] Potvrd prosim svuj email!'
email_changed: '[AuthMe] Email zmenen !' email_changed: '[AuthMe] Email zmenen!'
email_send: '[AuthMe] Email pro obnoveni hesla odeslan !' email_send: '[AuthMe] Email pro obnoveni hesla odeslan!'
country_banned: 'Your country is banned from this server' country_banned: 'Vase zeme je na tomto serveru zakazana'
antibot_auto_enabled: '[AuthMe] AntiBotMod automatically enabled due to massive connections!' antibot_auto_enabled: '[AuthMe] AntiBotMod automaticky spusten z duvodu masivnich pripojeni!'
antibot_auto_disabled: '[AuthMe] AntiBotMod automatically disabled after %m Minutes, hope invasion stopped' antibot_auto_disabled: '[AuthMe] AntiBotMod automaticky ukoncen po %m minutach, doufejme v konec invaze'

View File

@ -1,57 +1,57 @@
# Translate by AlexMerser / Перевод от AlexMerser # Translate by AlexMerser / Перевод от AlexMerser
unknown_user: '&cТакой игрок не зарегестрирован' unknown_user: '&грок с таким логином не зарегистрирован'
unsafe_spawn: '&6Ваше расположение перед выходом было опасным - &aВы перенесены на спавн.' unsafe_spawn: '&6Ваше расположение перед выходом было опасным - вы перенесены на спавн'
not_logged_in: '&cВы еще не вошли!' not_logged_in: '&4Вы еще не вошли!'
reg_voluntarily: '&eРегистрация - &d/reg ПАРОЛЬ ПОВТОРАРОЛЯ' reg_voluntarily: '&6Чтобы зарегистрироваться введите: &5/reg ПАРОЛЬ ПОВТОРАРОЛЯ'
usage_log: '&спользование: &d/l ПАРОЛЬ' usage_log: '&спользование: &5/l ПАРОЛЬ'
wrong_pwd: '&cНеверный пароль' wrong_pwd: '&4Неправильный пароль!'
unregistered: '&cВы успешно удалили свой аккаунт!' unregistered: '&6Вы успешно удалили свой аккаунт!'
reg_disabled: '&6Регистрация отключена' reg_disabled: '&4Регистрация отключена'
valid_session: '&cСессия включена' valid_session: '&6Сессия активна'
login: '&cУспешная авторизация!' login: '&2Вы успешно вошли!'
vb_nonActiv: '&aВаш аккаунт активирован. &5Проверьте свою электронную почту.' vb_nonActiv: '&6Ваш аккаунт еще не активирован! Проверьте вашу почту!'
user_regged: '&cТакой игрок уже зарегистрирован' user_regged: '&4Такой игрок уже зарегистрирован'
usage_reg: '&спользование: /reg ПАРОЛЬ ПОВТОРАРОЛЯ' usage_reg: '&спользование: &5/reg ПАРОЛЬ ПОВТОРАРОЛЯ'
max_reg: '&fВы превысили максимальное количество регистраций на аккаунт' max_reg: '&4Вы превысили макс количество регистраций на IP'
no_perm: '&cУ Вас нет прав' no_perm: '&4Недостаточно прав'
error: '&cЧто-то пошло не так; &5Свяжитесь с администратором.' error: '&роизошла ошибка. Свяжитесь с администратором'
login_msg: '&cВойти в игру - /login ПАРОЛЬ' login_msg: '&4Авторизация: &5/l ПАРОЛЬ'
reg_msg: '&eЗарегистрируйтесь - &d/reg ПАРОЛЬ ПОВТОРАРОЛЯ' reg_msg: '&4Регистрация: &5/reg ПАРОЛЬ ПОВТОРАРОЛЯ'
reg_email_msg: '&cЗарегистрируйтесь - /register ВАШ_EMAIL ВАШ_EMAIL' reg_email_msg: '&4Регистрация: &5/reg EMAIL ПОВТОР_EMAIL'
usage_unreg: '&спользование: /unregister ПАРОЛЬ' usage_unreg: '&спользование: &5/unregister ПАРОЛЬ'
pwd_changed: '&ароль успешно изменен!' pwd_changed: '&ароль изменен!'
user_unknown: '&cТакой игрок не зарегистрирован' user_unknown: '&4Такой игрок не зарегистрирован'
password_error: '&fПароль не совпадает' password_error: '&4Пароль не совпадает'
unvalid_session: '&cСессия некорректна. &5Дождитесь, пока сессия закончится.' unvalid_session: '&4Сессия некорректна. Дождитесь, пока она закончится'
reg_only: '&fВход доступен только зарегистрированным игрокам! Зарегистрируйтесь здесь - http://example.com/?do=register' reg_only: '&4Только для зарегистрированных! Посетите http://project.ru/register/ для регистрации'
logged_in: '&cВы уже вошли!' logged_in: '&4Вы уже авторизированы!'
logout: '&cВы успешно вышли' logout: '&2Вы успешно вышли'
same_nick: '&fТакой игрок уже играет на сервере' same_nick: '&4Такой игрок уже играет на сервере'
registered: '&cУспешная регистрация!' registered: '&2Успешная регистрация!'
pass_len: '&cТвой пароль либо слишком длинный, либо слишком короткий' pass_len: '&4Твой пароль либо слишком длинный, либо слишком короткий'
reload: '&fКонфигурация и база данных перезагружены.' reload: '&6Конфигурация и база данных перезагружены'
timeout: '&fВремя входа истекло, попробуйте еще раз, но быстрее' timeout: '&4Время авторизации истекло'
usage_changepassword: '&спользование: /changepassword СТАРЫЙ_ПАРОЛЬ НОВЫЙ_ПАРОЛЬ' usage_changepassword: '&спользование: &5/changepassword СТАРЫЙ_ПАРОЛЬ НОВЫЙ_ПАРОЛЬ'
name_len: '&cВаш логин слишком длинный или слишком короткий' name_len: '&4Ваш логин слишком длинный или слишком короткий'
regex: '&cВаш логин содержит запрещенные символы. Разрешенные символы: REG_EX' regex: '&4Ваш логин содержит запрещенные символы. Разрешенные символы: REG_EX'
add_email: '&обавьте свой email: /email add ВАШ_EMAIL ВАШ_EMAIL' add_email: '&обавьте свой email: &5/email add ВАШ_EMAIL ВАШ_EMAIL'
bad_database_email: '&c[AuthMe] Команда &d/email&c доступна только при работе с MySQL или SQLite' bad_database_email: '&4[AuthMe] Команда &5/email&4 доступна только при работе с MySQL или SQLite'
recovery_email: '&cЗабыли пароль? Используйте /email recovery ВАШ_EMAIL' recovery_email: '&4Забыли пароль? Используйте &5/email recovery ВАШ_EMAIL'
usage_captcha: '&спользование: /captcha СИМВОЛЫ_ВЫШЕ' usage_captcha: '&4Вы должны ввести код, используйте: &5/captcha КОД'
wrong_captcha: '&cНеправильная капча: /captcha СИМВОЛЫ_ВЫШЕ' wrong_captcha: '&4Неверный код, используйте: &5/captcha КОД'
valid_captcha: '&cКапча введена правильно!' valid_captcha: '&2Вы успешно ввели код!'
kick_forvip: '&cVIP игрок зашел на переполненный сервер!' kick_forvip: '&6VIP игрок зашел на переполненный сервер!'
kick_fullserver: '&cСервер переполнен!' kick_fullserver: '&4Сервер переполнен!'
usage_email_add: '&спользование: /email add ВАШ_EMAIL ВАШ_EMAIL ' usage_email_add: '&спользование: &5/email add ВАШ_EMAIL ПОВТОР_EMAIL'
usage_email_change: '&спользование: /email change СТАРЫЙ_EMAIL НОВЫЙ_EMAIL ' usage_email_change: '&спользование: &5/email change СТАРЫЙ_EMAIL НОВЫЙ_EMAIL'
usage_email_recovery: '&fИспользование: /email recovery ВАШ_EMAIL' usage_email_recovery: '&4Использование: /email recovery EMAIL'
new_email_invalid: '[AuthMe] Новый email недействителен!' new_email_invalid: '[AuthMe] Недействительный новый email!'
old_email_invalid: '[AuthMe] Старый email недействителен!' old_email_invalid: '[AuthMe] Недействительный старый email!'
email_invalid: '[AuthMe] Email неправильный' email_invalid: '[AuthMe] Недействительный email'
email_added: '[AuthMe] Email добавлен!' email_added: '[AuthMe] Email добавлен!'
email_confirm: '[AuthMe] Подтвердите ваш email!' email_confirm: '[AuthMe] Подтвердите ваш Email!'
email_changed: '[AuthMe] Email изменен!' email_changed: '[AuthMe] Email изменен!'
email_send: '[AuthMe] Восстановительное письмо отправлено!' email_send: '[AuthMe] Восстановительное письмо отправлено!'
country_banned: 'Ваша страна запрещена на этом сервере' country_banned: 'Ваша страна запрещена на этом сервере'
antibot_auto_enabled: '[AuthMe] AntiBot-режим автоматически включен из-за большого количества входов!' antibot_auto_enabled: '[AuthMe] AntiBot-режим автоматически включен из-за большого количества входов!'
antibot_auto_disabled: '[AuthMe] AntiBot-режим автоматичски отключен после %m мин. Надеюсь, атака закончилась' antibot_auto_disabled: '[AuthMe] AntiBot-режим автоматичски отключен после %m мин. Надеюсь атака закончилась'

View File

@ -3,7 +3,7 @@ author: Xephi59
website: http://dev.bukkit.org/bukkit-plugins/authme-reloaded/ website: http://dev.bukkit.org/bukkit-plugins/authme-reloaded/
description: AuthMe prevents people, which aren't logged in, from doing stuff like placing blocks, moving, typing commands or seeing the inventory of the current player. description: AuthMe prevents people, which aren't logged in, from doing stuff like placing blocks, moving, typing commands or seeing the inventory of the current player.
main: fr.xephi.authme.AuthMe main: fr.xephi.authme.AuthMe
version: 3.3.4 version: 3.3.5
softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag, Essentials, EssentialsSpawn] softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag, Essentials, EssentialsSpawn]
commands: commands:
register: register:
@ -63,6 +63,7 @@ permissions:
authme.admin.purgelastpos: true authme.admin.purgelastpos: true
authme.admin.switchantibot: true authme.admin.switchantibot: true
authme.bypassantibot: true authme.bypassantibot: true
authme.admin.getip: true
authme.register: authme.register:
description: Register an account description: Register an account
default: true default: true
@ -164,4 +165,7 @@ permissions:
default: op default: op
authme.admin.firstspawn: authme.admin.firstspawn:
description: Teleport to AuthMe First Spawn Point description: Teleport to AuthMe First Spawn Point
default: op
authme.admin.getip:
description: Get IP from a player ( fake and real )
default: op default: op