Drop old supports

This commit is contained in:
Xephi59 2015-07-09 01:56:13 +02:00
parent 5fe8ece0b3
commit d2cc60db78
10 changed files with 25 additions and 201 deletions

Binary file not shown.

Binary file not shown.

27
pom.xml
View File

@ -140,7 +140,7 @@
<!-- Essentials Repo -->
<repository>
<id>ess-repo</id>
<url>http://repo.ess3.net/content/groups/public</url>
<url>http://repo.ess3.net/content/groups/essentials</url>
</repository>
<!-- CombatTagPlus Repo -->
@ -187,13 +187,6 @@
<version>3.8.10.1</version>
</dependency>
<!-- Database Library -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>1.4.187</version>
</dependency>
<!-- Java Email API -->
<dependency>
<groupId>com.sun.mail</groupId>
@ -382,23 +375,5 @@
<systemPath>${project.basedir}/libs/ChestShop.jar</systemPath>
</dependency>
<!-- Citizens 1.X (No API) -->
<dependency>
<groupId>net.citizensnpcs</groupId>
<artifactId>citizens</artifactId>
<version>1.2.4</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/Citizens.jar</systemPath>
</dependency>
<!-- Old version of xAuth by Cypherx -->
<dependency>
<groupId>com.cypherx</groupId>
<artifactId>xauth</artifactId>
<version>2.0.26</version>
<scope>system</scope>
<systemPath>${project.basedir}/libs/xAuth.jar</systemPath>
</dependency>
</dependencies>
</project>

View File

@ -73,7 +73,6 @@ import fr.xephi.authme.settings.OtherAccounts;
import fr.xephi.authme.settings.PlayersLogs;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.Spawn;
import net.citizensnpcs.Citizens;
import net.milkbowl.vault.permission.Permission;
public class AuthMe extends JavaPlugin {
@ -90,9 +89,9 @@ public class AuthMe extends JavaPlugin {
private Utils utils = Utils.getInstance();
private FileCache playerBackup = new FileCache(this);
public CitizensCommunicator citizens;
public boolean isCitizensActive = false;
public SendMailSSL mail = null;
public int CitizensVersion = 0;
public int CombatTag = 0;
public boolean CombatTag = false;
public double ChestShop = 0;
public boolean BungeeCord = false;
public Essentials ess;
@ -390,25 +389,16 @@ public class AuthMe extends JavaPlugin {
public void combatTag() {
if (this.getServer().getPluginManager().getPlugin("CombatTag") != null && this.getServer().getPluginManager().getPlugin("CombatTag").isEnabled()) {
this.CombatTag = 1;
this.CombatTag = true;
} else {
this.CombatTag = 0;
this.CombatTag = false;
}
}
public void citizensVersion() {
if (this.getServer().getPluginManager().getPlugin("Citizens") != null && this.getServer().getPluginManager().getPlugin("Citizens").isEnabled()) {
Citizens cit = (Citizens) this.getServer().getPluginManager().getPlugin("Citizens");
String ver = cit.getDescription().getVersion();
String[] args = ver.split("\\.");
if (args[0].contains("1")) {
this.CitizensVersion = 1;
} else {
this.CitizensVersion = 2;
}
} else {
this.CitizensVersion = 0;
}
if (this.getServer().getPluginManager().getPlugin("Citizens") != null && this.getServer().getPluginManager().getPlugin("Citizens").isEnabled())
this.isCitizensActive = true;
else this.isCitizensActive = false;
}
@Override

View File

@ -1,132 +0,0 @@
package fr.xephi.authme.converter;
import java.io.File;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.command.CommandSender;
import com.cypherx.xauth.xAuth;
import com.cypherx.xauth.database.Table;
import com.cypherx.xauth.utils.xAuthLog;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
/**
*
* @author Xephi59
*/
public class oldxAuthToFlat {
public AuthMe instance;
public DataSource database;
public CommandSender sender;
public oldxAuthToFlat(AuthMe instance, DataSource database,
CommandSender sender) {
this.instance = instance;
this.database = database;
this.sender = sender;
}
public boolean convert() {
if (instance.getServer().getPluginManager().getPlugin("xAuth") == null) {
sender.sendMessage("[AuthMe] xAuth plugin not found");
return false;
}
if (!(new File(instance.getDataFolder().getParent() + File.separator + "xAuth" + File.separator + "xAuth.h2.db").exists())) {
sender.sendMessage("[AuthMe] xAuth H2 database not found, checking for MySQL or SQLite data...");
}
List<Integer> players = getXAuthPlayers();
if (players == null || players.isEmpty()) {
sender.sendMessage("[AuthMe] Error while import xAuthPlayers");
return false;
}
sender.sendMessage("[AuthMe] Starting import...");
try {
for (int id : players) {
String pl = getIdPlayer(id);
String psw = getPassword(id);
if (psw != null && !psw.isEmpty() && pl != null) {
PlayerAuth auth = new PlayerAuth(pl, psw, "198.18.0.1", 0, "your@email.com");
database.saveAuth(auth);
}
}
sender.sendMessage("[AuthMe] Successfull convert from xAuth database");
} catch (Exception e) {
sender.sendMessage("[AuthMe] An error has been thrown while import xAuth database, the import hadn't fail but can be not complete ");
}
return true;
}
public String getIdPlayer(int id) {
String realPass = "";
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
try {
String sql = String.format("SELECT `playername` FROM `%s` WHERE `id` = ?", xAuth.getPlugin().getDatabaseController().getTable(Table.ACCOUNT));
ps = conn.prepareStatement(sql);
ps.setInt(1, id);
rs = ps.executeQuery();
if (!rs.next())
return null;
realPass = rs.getString("playername").toLowerCase();
} catch (SQLException e) {
xAuthLog.severe("Failed to retrieve name for account: " + id, e);
return null;
} finally {
xAuth.getPlugin().getDatabaseController().close(conn, ps, rs);
}
return realPass;
}
public List<Integer> getXAuthPlayers() {
List<Integer> xP = new ArrayList<Integer>();
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
try {
String sql = String.format("SELECT * FROM `%s`", xAuth.getPlugin().getDatabaseController().getTable(Table.ACCOUNT));
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
while (rs.next()) {
xP.add(rs.getInt("id"));
}
} catch (SQLException e) {
xAuthLog.severe("Cannot import xAuthPlayers", e);
return new ArrayList<Integer>();
} finally {
xAuth.getPlugin().getDatabaseController().close(conn, ps, rs);
}
return xP;
}
public String getPassword(int accountId) {
String realPass = "";
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
PreparedStatement ps = null;
ResultSet rs = null;
try {
String sql = String.format("SELECT `password`, `pwtype` FROM `%s` WHERE `id` = ?", xAuth.getPlugin().getDatabaseController().getTable(Table.ACCOUNT));
ps = conn.prepareStatement(sql);
ps.setInt(1, accountId);
rs = ps.executeQuery();
if (!rs.next())
return null;
realPass = rs.getString("password");
} catch (SQLException e) {
xAuthLog.severe("Failed to retrieve password hash for account: " + accountId, e);
return null;
} finally {
xAuth.getPlugin().getDatabaseController().close(conn, ps, rs);
}
return realPass;
}
}

View File

@ -20,19 +20,13 @@ public class xAuthConverter implements Converter {
@Override
public void run() {
try {
Class.forName("com.cypherx.xauth.xAuth");
oldxAuthToFlat converter = new oldxAuthToFlat(plugin, database, sender);
converter.convert();
} catch (ClassNotFoundException e) {
try {
Class.forName("de.luricos.bukkit.xAuth.xAuth");
newxAuthToFlat converter = new newxAuthToFlat(plugin, database, sender);
xAuthToFlat converter = new xAuthToFlat(plugin, database, sender);
converter.convert();
} catch (ClassNotFoundException ce) {
sender.sendMessage("xAuth has not been found, please put xAuth.jar in your plugin folder and restart!");
}
}
}
}

View File

@ -17,13 +17,13 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
public class newxAuthToFlat {
public class xAuthToFlat {
public AuthMe instance;
public DataSource database;
public CommandSender sender;
public newxAuthToFlat(AuthMe instance, DataSource database,
public xAuthToFlat(AuthMe instance, DataSource database,
CommandSender sender) {
this.instance = instance;
this.database = database;

View File

@ -61,11 +61,11 @@ public class AuthMeServerListener implements Listener {
ConsoleLogger.info("ChestShop has been disabled, unhook!");
}
if (pluginName.equalsIgnoreCase("CombatTag")) {
plugin.CombatTag = 0;
plugin.CombatTag = false;
ConsoleLogger.info("CombatTag has been disabled, unhook!");
}
if (pluginName.equalsIgnoreCase("Citizens")) {
plugin.CitizensVersion = 0;
plugin.isCitizensActive = false;
ConsoleLogger.info("Citizens has been disabled, unhook!");
}
if (pluginName.equalsIgnoreCase("Vault")) {

View File

@ -1,11 +1,9 @@
package fr.xephi.authme.plugin.manager;
import net.citizensnpcs.api.CitizensAPI;
import net.citizensnpcs.api.CitizensManager;
import org.bukkit.entity.Entity;
import fr.xephi.authme.AuthMe;
import net.citizensnpcs.api.CitizensAPI;
public class CitizensCommunicator {
@ -16,14 +14,10 @@ public class CitizensCommunicator {
}
public boolean isNPC(final Entity player, AuthMe instance) {
try {
if (instance.CitizensVersion == 1) {
return CitizensManager.isNPC(player);
} else if (instance.CitizensVersion == 2) {
return CitizensAPI.getNPCRegistry().isNPC(player);
} else {
if (!this.instance.isCitizensActive)
return false;
}
try {
return CitizensAPI.getNPCRegistry().isNPC(player);
} catch (NoClassDefFoundError ncdfe) {
return false;
} catch (Exception npe) {

View File

@ -1,7 +1,5 @@
package fr.xephi.authme.plugin.manager;
import net.minelink.ctplus.CombatTagPlus;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@ -10,6 +8,9 @@ import org.bukkit.plugin.Plugin;
import com.trc202.CombatTag.CombatTag;
import com.trc202.CombatTagApi.CombatTagApi;
import fr.xephi.authme.AuthMe;
import net.minelink.ctplus.CombatTagPlus;
public abstract class CombatTagComunicator {
public static CombatTagApi combatApi;
@ -21,6 +22,8 @@ public abstract class CombatTagComunicator {
* @return true if the player is an NPC
*/
public static boolean isNPC(Entity player) {
if (!AuthMe.getInstance().CombatTag)
return false;
try {
if (Bukkit.getServer().getPluginManager().getPlugin("CombatTag") != null) {
combatApi = new CombatTagApi((CombatTag) Bukkit.getServer().getPluginManager().getPlugin("CombatTag"));