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>
</plugins>
</build>
<version>3.3.4</version>
<version>3.3.5</version>
<dependencies>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.7.2-R0.3</version>
<version>1.7.5-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>

View File

@ -1,10 +1,11 @@
package fr.xephi.authme;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.URL;
import java.net.URLConnection;
import java.util.Calendar;
@ -29,7 +30,6 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import com.earth2me.essentials.Essentials;
import com.maxmind.geoip.LookupService;
import com.onarandombox.MultiverseCore.MultiverseCore;
@ -105,6 +105,7 @@ public class AuthMe extends JavaPlugin {
public LookupService ls = null;
public boolean antibotMod = false;
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() {
return settings;
@ -532,9 +533,6 @@ public class AuthMe extends JavaPlugin {
player.getInventory().setArmorContents(limbo.getArmour());
player.getInventory().setContents(limbo.getInventory());
}
if (!limbo.getLoc().getChunk().isLoaded()) {
limbo.getLoc().getChunk().load();
}
player.teleport(limbo.getLoc());
this.utils.addNormal(player, limbo.getGroup());
player.setOp(limbo.getOperator());
@ -690,7 +688,8 @@ public class AuthMe extends JavaPlugin {
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(",");
Location spawnLoc = world.getSpawnLocation();
int i = 3;
@ -727,9 +726,8 @@ public class AuthMe extends JavaPlugin {
}
private Location getEssentialsSpawn() {
if (essentialsSpawn != null) {
if (essentialsSpawn != null)
return essentialsSpawn;
}
return null;
}
@ -767,7 +765,7 @@ public class AuthMe extends JavaPlugin {
}
}
public String getCountryCode(InetAddress ip) {
public String getCountryCode(String ip) {
try {
if (ls == null)
ls = new LookupService(new File(getDataFolder(), "GeoIP.dat"));
@ -778,7 +776,7 @@ public class AuthMe extends JavaPlugin {
return null;
}
public String getCountryName(InetAddress ip) {
public String getCountryName(String ip) {
try {
if (ls == null)
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("{ONLINE}", ""+this.getServer().getOnlinePlayers().length);
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("{WORLD}", player.getWorld().getName());
message = message.replace("{SERVER}", this.getServer().getServerName());
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) {}
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();
if (Settings.bungee) {
if (realIp.containsKey(name))
ip = realIp.get(name);
}
if (Settings.checkVeryGames)
if (getVeryGamesIP(player) != null)
ip = getVeryGamesIP(player);
return ip;
}
public boolean isLoggedIp(String ip) {
public boolean isLoggedIp(String name, String ip) {
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 false;
}
public boolean hasJoinedIp(String ip) {
public boolean hasJoinedIp(String name, String ip) {
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 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.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.Utils;
import fr.xephi.authme.cache.auth.PlayerAuth;
@ -176,4 +175,5 @@ public class API {
public static void forceLogin(Player player) {
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.FileWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import org.bukkit.Material;
@ -53,6 +55,8 @@ public class FileCache {
int amount = 0;
int durability = 0;
String enchList = "";
String name = "";
String lores = "";
if (invstack[i] != null) {
itemid = invstack[i].getType().name();
amount = invstack[i].getAmount();
@ -60,9 +64,22 @@ public class FileCache {
for(Enchantment e : invstack[i].getEnchantments().keySet()) {
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();
}
writer.write("i" + ":" + itemid + ":" + amount + ":"
+ durability + ":"+ enchList + "\r\n");
if (invstack[i].getItemMeta().hasLore()) {
for (String lore : invstack[i].getItemMeta().getLore()) {
lores = lore + "%newline%";
}
}
}
}
String writeItem = "i" + ":" + itemid + ":" + amount + ":"
+ durability + ":"+ enchList + ";" + name + "\\*" + lores + "\r\n";
writer.write(writeItem);
writer.flush();
}
@ -73,6 +90,8 @@ public class FileCache {
int amount = 0;
int durability = 0;
String enchList = "";
String name = "";
String lores = "";
if (armorstack[i] != null) {
itemid = armorstack[i].getType().name();
amount = armorstack[i].getAmount();
@ -80,9 +99,22 @@ public class FileCache {
for(Enchantment e : armorstack[i].getEnchantments().keySet()) {
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();
}
writer.write("w" + ":" + itemid + ":" + amount + ":"
+ durability + ":"+ enchList + "\r\n");
if (armorstack[i].getItemMeta().hasLore()) {
for (String lore : armorstack[i].getItemMeta().getLore()) {
lores = lore + "%newline%";
}
}
}
}
String writeItem = "w" + ":" + itemid + ":" + amount + ":"
+ durability + ":"+ enchList + ";" + name + "\\*" + lores + "\r\n";
writer.write(writeItem);
writer.flush();
}
writer.close();
@ -111,7 +143,7 @@ public class FileCache {
int i = 0;
int a = 0;
while (reader.hasNextLine()) {
final String line = reader.nextLine();
String line = reader.nextLine();
if (!line.contains(":")) {
// the fist line represent the player group, operator status and flying status
@ -130,10 +162,20 @@ public class FileCache {
continue;
}
final String[] in = line.split(":");
if (!in[0].equals("i") && !in[0].equals("w")) {
if (!line.startsWith("i") && !line.startsWith("w")) {
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
if (in[0].equals("i")) {
stacki[i] = new ItemStack(Material.getMaterial(in[1]),
@ -144,6 +186,15 @@ public class FileCache {
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++;
} else {
stacka[a] = new ItemStack(Material.getMaterial(in[1]),
@ -154,6 +205,15 @@ public class FileCache {
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++;
}
}

View File

@ -89,7 +89,7 @@ public class LimboCache {
gameMode = GameMode.SURVIVAL;
}
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));
}

View File

@ -302,9 +302,13 @@ public class AdminCommand implements CommandExecutor {
return true;
} else if (args[0].equalsIgnoreCase("convertflattosql")) {
try {
FlatToSql.FlatToSqlConverter();
if (sender instanceof Player)
FlatToSql converter = new FlatToSql();
if (sender instanceof Player) {
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) {
e.printStackTrace();
} catch (NullPointerException ex) {
@ -506,7 +510,7 @@ public class AdminCommand implements CommandExecutor {
if (target != null) {
if (target.isOnline()) {
if (Settings.isTeleportToSpawnEnabled) {
Location spawn = plugin.getSpawnLocation(target, target.getWorld());
Location spawn = plugin.getSpawnLocation(target);
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(target, target.getLocation(), spawn, false);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {
@ -578,6 +582,21 @@ public class AdminCommand implements CommandExecutor {
new RoyalAuthConverter(plugin);
sender.sendMessage("[AuthMe] RoyalAuth database has been imported correctly");
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 {
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);
if (Settings.isTeleportToSpawnEnabled) {
Location spawnLoc = plugin.getSpawnLocation(player, player.getWorld());
Location spawnLoc = plugin.getSpawnLocation(player);
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {

View File

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

View File

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

View File

@ -183,6 +183,8 @@ public class MySQLDataSource implements DataSource {
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
PlayerAuth pAuth = null;
int id = -1;
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
@ -190,15 +192,24 @@ public class MySQLDataSource implements DataSource {
pst.setString(1, user);
rs = pst.executeQuery();
if (rs.next()) {
if (rs.getString(columnIp).isEmpty() ) {
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "198.18.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld),rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
id = rs.getInt(columnID);
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 {
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.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)));
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 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 {
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 {
@ -215,6 +226,7 @@ public class MySQLDataSource implements DataSource {
close(pst);
close(con);
}
return pAuth;
}
@Override
@ -363,6 +375,21 @@ public class MySQLDataSource implements DataSource {
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) {
ConsoleLogger.showError(ex.getMessage());
return false;
@ -386,6 +413,20 @@ public class MySQLDataSource implements DataSource {
pst.setString(1, auth.getHash());
pst.setString(2, auth.getNickname());
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) {
ConsoleLogger.showError(ex.getMessage());
return false;
@ -481,6 +522,19 @@ public class MySQLDataSource implements DataSource {
PreparedStatement pst = null;
try {
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.setString(1, user);
pst.executeUpdate();

View File

@ -11,7 +11,6 @@ import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -365,7 +364,7 @@ public class AuthMePlayerListener implements Listener {
}
int radius = Settings.getMovementRadius;
Location spawn = plugin.getSpawnLocation(player, player.getWorld());
Location spawn = plugin.getSpawnLocation(player);
if (!event.getPlayer().getWorld().equals(spawn.getWorld())) {
event.getPlayer().teleport(spawn);
@ -388,14 +387,14 @@ public class AuthMePlayerListener implements Listener {
}
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")) {
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("country_banned")[0]);
return;
}
}
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")) {
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, m._("country_banned")[0]);
return;
@ -540,9 +539,8 @@ public class AuthMePlayerListener implements Listener {
return;
}
Player player = event.getPlayer();
World world = player.getWorld();
final String name = player.getName().toLowerCase();
Location spawnLoc = plugin.getSpawnLocation(player, world);
Location spawnLoc = plugin.getSpawnLocation(player);
gm = player.getGameMode();
gameMode.put(name, gm);
BukkitScheduler sched = plugin.getServer().getScheduler();
@ -557,11 +555,7 @@ public class AuthMePlayerListener implements Listener {
} catch (Exception e) {}
}
String ip = player.getAddress().getAddress().getHostAddress();
if (Settings.bungee) {
if (plugin.realIp.containsKey(name))
ip = plugin.realIp.get(name);
}
String ip = plugin.getIP(player);
if(Settings.isAllowRestrictedIp && !Settings.getRestrictedIp(name, ip)) {
GameMode gM = gameMode.get(name);
this.causeByAuthMe = true;
@ -573,7 +567,7 @@ public class AuthMePlayerListener implements Listener {
return;
}
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!");
return;
}
@ -637,12 +631,11 @@ public class AuthMePlayerListener implements Listener {
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
}
if (player != null && player.isOnline() && tpEvent.getTo() != null) {
player.teleport(tpEvent.getTo());
}
}
}
placePlayerSafely(player, spawnLoc);
LimboCache.getInstance().updateLimboPlayer(player);
DataFileCache dataFile = new DataFileCache(LimboCache.getInstance().getLimboPlayer(name).getInventory(),LimboCache.getInstance().getLimboPlayer(name).getArmour());
@ -660,12 +653,11 @@ public class AuthMePlayerListener implements Listener {
SpawnTeleportEvent tpEvent = new SpawnTeleportEvent(player, player.getLocation(), spawnLoc, PlayerCache.getInstance().isAuthenticated(name));
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
}
if (player != null && player.isOnline() && tpEvent.getTo() != null) {
player.teleport(tpEvent.getTo());
}
}
}
if (!Settings.isForcedRegistrationEnabled) {
return;
}
@ -750,11 +742,7 @@ public class AuthMePlayerListener implements Listener {
return;
}
String ip = player.getAddress().getAddress().getHostAddress();
if (Settings.bungee) {
if (plugin.realIp.containsKey(name))
ip = plugin.realIp.get(name);
}
String ip = plugin.getIP(player);
if (PlayerCache.getInstance().isAuthenticated(name) && !player.isDead()) {
if(Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) {
@ -826,11 +814,7 @@ public class AuthMePlayerListener implements Listener {
String name = player.getName().toLowerCase();
String ip = player.getAddress().getAddress().getHostAddress();
if (Settings.bungee) {
if (plugin.realIp.containsKey(name))
ip = plugin.realIp.get(name);
}
String ip = plugin.getIP(player);
if ((PlayerCache.getInstance().isAuthenticated(name)) && (!player.isDead())) {
if ((Settings.isSaveQuitLocationEnabled) && data.isAuthAvailable(name)){
final PlayerAuth auth = new PlayerAuth(name, loc.getX(), loc.getY(), loc.getZ(),loc.getWorld().getName());
@ -863,11 +847,10 @@ public class AuthMePlayerListener implements Listener {
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, limbo.getLoc());
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {
if (!tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).isLoaded()) {
tpEvent.getTo().getWorld().getChunkAt(tpEvent.getTo()).load();
}
if (player != null && player.isOnline() && tpEvent.getTo() != null) {
player.teleport(tpEvent.getTo());
}
}
} catch (NullPointerException npe) {
}
this.utils.addNormal(player, limbo.getGroup());
@ -1122,7 +1105,7 @@ public class AuthMePlayerListener implements Listener {
if (!Settings.isForcedRegistrationEnabled)
return;
Location spawn = plugin.getSpawnLocation(player, player.getWorld());
Location spawn = plugin.getSpawnLocation(player);
if(Settings.isSaveQuitLocationEnabled && data.isAuthAvailable(name)) {
final PlayerAuth auth = new PlayerAuth(name,spawn.getX(),spawn.getY(),spawn.getZ(),spawn.getWorld().getName());
try {

View File

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

View File

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

View File

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

View File

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

View File

@ -49,7 +49,7 @@ public class ProcessSyncronousEmailRegister implements Runnable {
if (Settings.isTeleportToSpawnEnabled) {
World world = player.getWorld();
Location loca = plugin.getSpawnLocation(player, world);
Location loca = plugin.getSpawnLocation(player);
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {
@ -65,7 +65,7 @@ public class ProcessSyncronousEmailRegister implements Runnable {
}
player.saveData();
if (!Settings.noConsoleSpam)
ConsoleLogger.info(player.getName() + " registered "+player.getAddress().getAddress().getHostAddress());
ConsoleLogger.info(player.getName() + " registered "+plugin.getIP(player));
if(plugin.notifications != null) {
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) {
if (Settings.isTeleportToSpawnEnabled) {
Location spawnLoc = plugin.getSpawnLocation(player, player.getWorld());
Location spawnLoc = plugin.getSpawnLocation(player);
AuthMeTeleportEvent tpEvent = new AuthMeTeleportEvent(player, spawnLoc);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {
@ -81,7 +81,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
player.setGameMode(limbo.getGameMode());
if (Settings.isTeleportToSpawnEnabled) {
World world = player.getWorld();
Location loca = plugin.getSpawnLocation(player, world);
Location loca = plugin.getSpawnLocation(player);
RegisterTeleportEvent tpEvent = new RegisterTeleportEvent(player, loca);
plugin.getServer().getPluginManager().callEvent(tpEvent);
if(!tpEvent.isCancelled()) {
@ -111,7 +111,7 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
player.saveData();
if (!Settings.noConsoleSpam)
ConsoleLogger.info(player.getName() + " registered "+player.getAddress().getAddress().getHostAddress());
ConsoleLogger.info(player.getName() + " registered "+plugin.getIP(player));
if(plugin.notifications != null) {
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,
usePurge, purgePlayerDat, purgeEssentialsFile, supportOldPassword, purgeLimitedCreative,
purgeAntiXray, purgePermissions, enableProtection, enableAntiBot, recallEmail, useWelcomeMessage,
broadcastWelcomeMessage, forceRegKick, forceRegLogin;
broadcastWelcomeMessage, forceRegKick, forceRegLogin, checkVeryGames;
public static String getNickRegex, getUnloggedinGroup, getMySQLHost, getMySQLPort,
getMySQLUsername, getMySQLPassword, getMySQLDatabase, getMySQLTablename,
@ -241,6 +241,7 @@ public void loadConfigOptions() {
spawnPriority = configFile.getString("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
checkVeryGames = configFile.getBoolean("VeryGames.enableIpCheck", false);
// Load the welcome message
getWelcomeMessage(plugin);
@ -398,6 +399,7 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
spawnPriority = configFile.getString("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
getMaxLoginPerIp = configFile.getInt("settings.restrictions.maxLoginPerIp", 0);
getMaxJoinPerIp = configFile.getInt("settings.restrictions.maxJoinPerIp", 0);
checkVeryGames = configFile.getBoolean("VeryGames.enableIpCheck", false);
// Reload the welcome message
getWelcomeMessage(AuthMe.getInstance());
@ -405,153 +407,102 @@ public static void reloadConfigOptions(YamlConfiguration newConfig) {
}
public void mergeConfig() {
if(!contains("DataSource.mySQLColumnEmail"))
set("DataSource.mySQLColumnEmail","email");
if(!contains("Email.RecoveryPasswordLength"))
set("Email.RecoveryPasswordLength", 8);
if(!contains("Email.mailPort"))
set("Email.mailPort", 465);
if(!contains("Email.mailSMTP"))
set("Email.mailSMTP", "smtp.gmail.com");
if(!contains("Email.mailAccount"))
set("Email.mailAccount", "");
if(!contains("Email.mailPassword"))
set("Email.mailPassword", "");
if(!contains("ExternalBoardOptions.mySQLOtherUsernameColumns"))
set("ExternalBoardOptions.mySQLOtherUsernameColumns", new ArrayList<String>());
if(!contains("settings.restrictions.displayOtherAccounts"))
set("settings.restrictions.displayOtherAccounts", true);
if(!contains("DataSource.mySQLColumnId"))
set("DataSource.mySQLColumnId", "id");
if(!contains("Email.mailSenderName"))
set("Email.mailSenderName", "");
if(!contains("Security.captcha.useCaptcha"))
set("Security.captcha.useCaptcha", false);
if(!contains("Security.captcha.maxLoginTry"))
set("Security.captcha.maxLoginTry", 5);
if(!contains("Security.captcha.captchaLength"))
set("Security.captcha.captchaLength", 5);
if(!contains("Email.mailSubject"))
set("Email.mailSubject", "");
if(!contains("Email.mailText"))
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");
if(contains("Email.mailText")) {
try {
String s = getString("Email.mailText");
s = s.replaceAll("\n", "<br />");
set("Email.mailText", null);
set("Email.mailText", s);
} catch (Exception e) {}
}
if(!contains("settings.registration.enableEmailRegistrationSystem"))
set("settings.registration.enableEmailRegistrationSystem", false);
if(!contains("settings.security.doubleMD5SaltLength"))
set("settings.security.doubleMD5SaltLength", 8);
if(!contains("Email.maxRegPerEmail"))
set("Email.maxRegPerEmail", 1);
if(!contains("Hooks.multiverse")) {
set("Hooks.multiverse", true);
set("Hooks.chestshop", true);
set("Hooks.notifications", true);
set("Hooks.bungeecord", false);
}
if(!contains("settings.restrictions.ForceSpawnOnTheseWorlds"))
set("settings.restrictions.ForceSpawnOnTheseWorlds", new ArrayList<String>());
if(!contains("settings.restrictions.banUnsafedIP"))
set("settings.restrictions.banUnsafedIP", false);
if(!contains("settings.registration.doubleEmailCheck"))
set("settings.registration.doubleEmailCheck", false);
if(!contains("settings.sessions.sessionExpireOnIpChange"))
set("settings.sessions.sessionExpireOnIpChange", false);
if(!contains("Security.console.logConsole"))
set("Security.console.logConsole", false);
if(!contains("Hooks.disableSocialSpy"))
set("Hooks.disableSocialSpy", true);
if(!contains("Performances.useMultiThreading"))
set("Performances.useMultiThreading", true);
if(!contains("ExternalBoardOptions.bCryptLog2Round"))
set("ExternalBoardOptions.bCryptLog2Round", 10);
if(!contains("DataSource.mySQLlastlocWorld"))
set("DataSource.mySQLlastlocWorld", "world");
if(!contains("settings.GameMode.ForceOnlyAfterLogin"))
set("settings.GameMode.ForceOnlyAfterLogin", false);
if(!contains("Hooks.useEssentialsMotd"))
set("Hooks.useEssentialsMotd", false);
if(!contains("Purge.useAutoPurge")) {
set("Purge.useAutoPurge", false);
set("Purge.daysBeforeRemovePlayer", 60);
set("Purge.removePlayerDat", false);
set("Purge.removeEssentialsFile", false);
set("Purge.defaultWorld", "world");
}
if(!contains("ExternalBoardOptions.phpbbTablePrefix")) {
set("ExternalBoardOptions.phpbbTablePrefix", "phpbb_");
set("ExternalBoardOptions.phpbbActivatedGroupId", 2);
}
if(!contains("settings.security.supportOldPasswordHash"))
set("settings.security.supportOldPasswordHash", false);
if(!contains("ExternalBoardOptions.wordpressTablePrefix"))
set("ExternalBoardOptions.wordpressTablePrefix", "wp_");
boolean changes = false;
if(contains("Xenoforo.predefinedSalt"))
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"))
if(!contains("Protection.enableProtection")) {
set("Protection.enableProtection", false);
changes = true;
}
if(!contains("Protection.countries")) {
countries = new ArrayList<String>();
countries.add("US");
countries.add("GB");
set("Protection.countries", countries);
changes = true;
}
if(!contains("Protection.enableAntiBot"))
if(!contains("Protection.enableAntiBot")) {
set("Protection.enableAntiBot", false);
if(!contains("Protection.antiBotSensibility"))
changes = true;
}
if(!contains("Protection.antiBotSensibility")) {
set("Protection.antiBotSensibility", 5);
if(!contains("Protection.antiBotDuration"))
changes = true;
}
if(!contains("Protection.antiBotDuration")) {
set("Protection.antiBotDuration", 10);
if(!contains("settings.forceCommands"))
changes = true;
}
if(!contains("settings.forceCommands")) {
set("settings.forceCommands", new ArrayList<String>());
if(!contains("Email.recallPlayers"))
changes = true;
}
if(!contains("Email.recallPlayers")) {
set("Email.recallPlayers", false);
if(!contains("Email.delayRecall"))
changes = true;
}
if(!contains("Email.delayRecall")) {
set("Email.delayRecall", 5);
if(!contains("settings.useWelcomeMessage"))
changes = true;
}
if(!contains("settings.useWelcomeMessage")) {
set("settings.useWelcomeMessage", true);
changes = true;
}
if(!contains("settings.security.unsafePasswords")) {
List<String> str = new ArrayList<String>();
str.add("123456");
str.add("password");
set("settings.security.unsafePasswords", str);
changes = true;
}
if(!contains("Protection.countriesBlacklist")) {
countriesBlacklist = new ArrayList<String>();
countriesBlacklist.add("A1");
set("Protection.countriesBlacklist", countriesBlacklist);
changes = true;
}
if(!contains("settings.broadcastWelcomeMessage"))
if(!contains("settings.broadcastWelcomeMessage")) {
set("settings.broadcastWelcomeMessage", false);
if(!contains("settings.registration.forceKickAfterRegister"))
changes = true;
}
if(!contains("settings.registration.forceKickAfterRegister")) {
set("settings.registration.forceKickAfterRegister", false);
if(!contains("settings.registration.forceLoginAfterRegister"))
changes = true;
}
if(!contains("settings.registration.forceLoginAfterRegister")) {
set("settings.registration.forceLoginAfterRegister", false);
if(!contains("DataSource.mySQLColumnLogged"))
changes = true;
}
if(!contains("DataSource.mySQLColumnLogged")) {
set("DataSource.mySQLColumnLogged", "isLogged");
if(!contains("settings.restrictions.spawnPriority"))
changes = true;
}
if(!contains("settings.restrictions.spawnPriority")) {
set("settings.restrictions.spawnPriority", "authme,essentials,multiverse,default");
if(!contains("settings.restrictions.maxLoginPerIp"))
changes = true;
}
if(!contains("settings.restrictions.maxLoginPerIp")) {
set("settings.restrictions.maxLoginPerIp", 0);
if(!contains("settings.restrictions.maxJoinPerIp"))
changes = true;
}
if(!contains("settings.restrictions.maxJoinPerIp")) {
set("settings.restrictions.maxJoinPerIp", 0);
changes = true;
}
if(!contains("VeryGames.enableIpCheck")) {
set("VeryGames.enableIpCheck", false);
changes = true;
}
if(getString("settings.restrictions.allowedNicknameCharacters").equals("[a-zA-Z0-9_?]*"))
set("settings.restrictions.allowedNicknameCharacters", "[a-zA-Z0-9_]*");
if (changes) {
plugin.getLogger().warning("Merge new Config Options if needed..");
plugin.getLogger().warning("Please check your config.yml file!");
}
plugin.saveConfig();
return;

View File

@ -212,6 +212,8 @@ public class MySQLThread extends Thread implements DataSource {
Connection con = null;
PreparedStatement pst = null;
ResultSet rs = null;
PlayerAuth pAuth = null;
int id = -1;
try {
con = makeSureConnectionIsReady();
pst = con.prepareStatement("SELECT * FROM " + tableName + " WHERE "
@ -219,15 +221,24 @@ public class MySQLThread extends Thread implements DataSource {
pst.setString(1, user);
rs = pst.executeQuery();
if (rs.next()) {
if (rs.getString(columnIp).isEmpty() ) {
return new PlayerAuth(rs.getString(columnName), rs.getString(columnPassword), "198.18.0.1", rs.getLong(columnLastLogin), rs.getDouble(lastlocX), rs.getDouble(lastlocY), rs.getDouble(lastlocZ), rs.getString(lastlocWorld),rs.getString(columnEmail), API.getPlayerRealName(rs.getString(columnName)));
id = rs.getInt(columnID);
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 {
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.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)));
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 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 {
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 {
@ -244,6 +255,7 @@ public class MySQLThread extends Thread implements DataSource {
close(pst);
close(con);
}
return pAuth;
}
@Override
@ -252,7 +264,7 @@ public class MySQLThread extends Thread 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());
@ -392,6 +404,21 @@ public class MySQLThread extends Thread implements DataSource {
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) {
ConsoleLogger.showError(ex.getMessage());
return false;
@ -415,6 +442,20 @@ public class MySQLThread extends Thread implements DataSource {
pst.setString(1, auth.getHash());
pst.setString(2, auth.getNickname());
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) {
ConsoleLogger.showError(ex.getMessage());
return false;
@ -510,6 +551,19 @@ public class MySQLThread extends Thread implements DataSource {
PreparedStatement pst = null;
try {
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.setString(1, user);
pst.executeUpdate();

View File

@ -85,7 +85,7 @@ settings:
- /passpartu
- /email
- /captcha
# Maximum Registraion per IP default: 1
# Maximum Registration per IP default: 1
maxRegPerIp: 1
# max allowed nick length (Warning when you use
# mysql and choose a value >20 you have to
@ -136,7 +136,7 @@ settings:
# should be kicked. Set to 0 to disable.
timeout: 30
# 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
# for unlimited radius
allowedMovementRadius: 100
@ -399,3 +399,6 @@ Protection:
antiBotSensibility: 5
# Duration in minutes of the antibot automatic system
antiBotDuration: 10
VeryGames:
# These features are only available on VeryGames Server Provider
enableIpCheck: false

View File

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

View File

@ -1,57 +1,57 @@
# Translate by AlexMerser / Перевод от AlexMerser
unknown_user: '&cТакой игрок не зарегестрирован'
unsafe_spawn: '&6Ваше расположение перед выходом было опасным - &aВы перенесены на спавн.'
not_logged_in: '&cВы еще не вошли!'
reg_voluntarily: '&eРегистрация - &d/reg ПАРОЛЬ ПОВТОРАРОЛЯ'
usage_log: '&спользование: &d/l ПАРОЛЬ'
wrong_pwd: '&cНеверный пароль'
unregistered: '&cВы успешно удалили свой аккаунт!'
reg_disabled: '&6Регистрация отключена'
valid_session: '&cСессия включена'
login: '&cУспешная авторизация!'
vb_nonActiv: '&aВаш аккаунт активирован. &5Проверьте свою электронную почту.'
user_regged: '&cТакой игрок уже зарегистрирован'
usage_reg: '&спользование: /reg ПАРОЛЬ ПОВТОРАРОЛЯ'
max_reg: '&fВы превысили максимальное количество регистраций на аккаунт'
no_perm: '&cУ Вас нет прав'
error: '&cЧто-то пошло не так; &5Свяжитесь с администратором.'
login_msg: '&cВойти в игру - /login ПАРОЛЬ'
reg_msg: '&eЗарегистрируйтесь - &d/reg ПАРОЛЬ ПОВТОРАРОЛЯ'
reg_email_msg: '&cЗарегистрируйтесь - /register ВАШ_EMAIL ВАШ_EMAIL'
usage_unreg: '&спользование: /unregister ПАРОЛЬ'
pwd_changed: '&ароль успешно изменен!'
user_unknown: '&cТакой игрок не зарегистрирован'
password_error: '&fПароль не совпадает'
unvalid_session: '&cСессия некорректна. &5Дождитесь, пока сессия закончится.'
reg_only: '&fВход доступен только зарегистрированным игрокам! Зарегистрируйтесь здесь - http://example.com/?do=register'
logged_in: '&cВы уже вошли!'
logout: '&cВы успешно вышли'
same_nick: '&fТакой игрок уже играет на сервере'
registered: '&cУспешная регистрация!'
pass_len: '&cТвой пароль либо слишком длинный, либо слишком короткий'
reload: '&fКонфигурация и база данных перезагружены.'
timeout: '&fВремя входа истекло, попробуйте еще раз, но быстрее'
usage_changepassword: '&спользование: /changepassword СТАРЫЙ_ПАРОЛЬ НОВЫЙ_ПАРОЛЬ'
name_len: '&cВаш логин слишком длинный или слишком короткий'
regex: '&cВаш логин содержит запрещенные символы. Разрешенные символы: REG_EX'
add_email: '&обавьте свой email: /email add ВАШ_EMAIL ВАШ_EMAIL'
bad_database_email: '&c[AuthMe] Команда &d/email&c доступна только при работе с MySQL или SQLite'
recovery_email: '&cЗабыли пароль? Используйте /email recovery ВАШ_EMAIL'
usage_captcha: '&спользование: /captcha СИМВОЛЫ_ВЫШЕ'
wrong_captcha: '&cНеправильная капча: /captcha СИМВОЛЫ_ВЫШЕ'
valid_captcha: '&cКапча введена правильно!'
kick_forvip: '&cVIP игрок зашел на переполненный сервер!'
kick_fullserver: '&cСервер переполнен!'
usage_email_add: '&спользование: /email add ВАШ_EMAIL ВАШ_EMAIL '
usage_email_change: '&спользование: /email change СТАРЫЙ_EMAIL НОВЫЙ_EMAIL '
usage_email_recovery: '&fИспользование: /email recovery ВАШ_EMAIL'
new_email_invalid: '[AuthMe] Новый email недействителен!'
old_email_invalid: '[AuthMe] Старый email недействителен!'
email_invalid: '[AuthMe] Email неправильный'
unknown_user: '&грок с таким логином не зарегистрирован'
unsafe_spawn: '&6Ваше расположение перед выходом было опасным - вы перенесены на спавн'
not_logged_in: '&4Вы еще не вошли!'
reg_voluntarily: '&6Чтобы зарегистрироваться введите: &5/reg ПАРОЛЬ ПОВТОРАРОЛЯ'
usage_log: '&спользование: &5/l ПАРОЛЬ'
wrong_pwd: '&4Неправильный пароль!'
unregistered: '&6Вы успешно удалили свой аккаунт!'
reg_disabled: '&4Регистрация отключена'
valid_session: '&6Сессия активна'
login: '&2Вы успешно вошли!'
vb_nonActiv: '&6Ваш аккаунт еще не активирован! Проверьте вашу почту!'
user_regged: '&4Такой игрок уже зарегистрирован'
usage_reg: '&спользование: &5/reg ПАРОЛЬ ПОВТОРАРОЛЯ'
max_reg: '&4Вы превысили макс количество регистраций на IP'
no_perm: '&4Недостаточно прав'
error: '&роизошла ошибка. Свяжитесь с администратором'
login_msg: '&4Авторизация: &5/l ПАРОЛЬ'
reg_msg: '&4Регистрация: &5/reg ПАРОЛЬ ПОВТОРАРОЛЯ'
reg_email_msg: '&4Регистрация: &5/reg EMAIL ПОВТОР_EMAIL'
usage_unreg: '&спользование: &5/unregister ПАРОЛЬ'
pwd_changed: '&ароль изменен!'
user_unknown: '&4Такой игрок не зарегистрирован'
password_error: '&4Пароль не совпадает'
unvalid_session: '&4Сессия некорректна. Дождитесь, пока она закончится'
reg_only: '&4Только для зарегистрированных! Посетите http://project.ru/register/ для регистрации'
logged_in: '&4Вы уже авторизированы!'
logout: '&2Вы успешно вышли'
same_nick: '&4Такой игрок уже играет на сервере'
registered: '&2Успешная регистрация!'
pass_len: '&4Твой пароль либо слишком длинный, либо слишком короткий'
reload: '&6Конфигурация и база данных перезагружены'
timeout: '&4Время авторизации истекло'
usage_changepassword: '&спользование: &5/changepassword СТАРЫЙ_ПАРОЛЬ НОВЫЙ_ПАРОЛЬ'
name_len: '&4Ваш логин слишком длинный или слишком короткий'
regex: '&4Ваш логин содержит запрещенные символы. Разрешенные символы: REG_EX'
add_email: '&обавьте свой email: &5/email add ВАШ_EMAIL ВАШ_EMAIL'
bad_database_email: '&4[AuthMe] Команда &5/email&4 доступна только при работе с MySQL или SQLite'
recovery_email: '&4Забыли пароль? Используйте &5/email recovery ВАШ_EMAIL'
usage_captcha: '&4Вы должны ввести код, используйте: &5/captcha КОД'
wrong_captcha: '&4Неверный код, используйте: &5/captcha КОД'
valid_captcha: '&2Вы успешно ввели код!'
kick_forvip: '&6VIP игрок зашел на переполненный сервер!'
kick_fullserver: '&4Сервер переполнен!'
usage_email_add: '&спользование: &5/email add ВАШ_EMAIL ПОВТОР_EMAIL'
usage_email_change: '&спользование: &5/email change СТАРЫЙ_EMAIL НОВЫЙ_EMAIL'
usage_email_recovery: '&4Использование: /email recovery EMAIL'
new_email_invalid: '[AuthMe] Недействительный новый email!'
old_email_invalid: '[AuthMe] Недействительный старый email!'
email_invalid: '[AuthMe] Недействительный email'
email_added: '[AuthMe] Email добавлен!'
email_confirm: '[AuthMe] Подтвердите ваш email!'
email_confirm: '[AuthMe] Подтвердите ваш Email!'
email_changed: '[AuthMe] Email изменен!'
email_send: '[AuthMe] Восстановительное письмо отправлено!'
country_banned: 'Ваша страна запрещена на этом сервере'
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/
description: AuthMe prevents people, which aren't logged in, from doing stuff like placing blocks, moving, typing commands or seeing the inventory of the current player.
main: fr.xephi.authme.AuthMe
version: 3.3.4
version: 3.3.5
softdepend: [Vault, ChestShop, Spout, Multiverse-Core, Notifications, Citizens, CombatTag, Essentials, EssentialsSpawn]
commands:
register:
@ -63,6 +63,7 @@ permissions:
authme.admin.purgelastpos: true
authme.admin.switchantibot: true
authme.bypassantibot: true
authme.admin.getip: true
authme.register:
description: Register an account
default: true
@ -165,3 +166,6 @@ permissions:
authme.admin.firstspawn:
description: Teleport to AuthMe First Spawn Point
default: op
authme.admin.getip:
description: Get IP from a player ( fake and real )
default: op