mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-01-24 08:31:29 +01:00
Minor: Converters - reduce visibility
- Change fields from public to private - Make classes package-private where appropriate - Remove redundant javadoc
This commit is contained in:
parent
25a9b6cb00
commit
68e5f636ae
@ -578,7 +578,7 @@ public class AuthMe extends JavaPlugin {
|
||||
|
||||
if (Settings.getDataSource == DataSource.DataSourceType.FILE) {
|
||||
ConsoleLogger.showError("FlatFile backend has been detected and is now deprecated, it will be changed to SQLite... Connection will be impossible until conversion is done!");
|
||||
ForceFlatToSqlite converter = new ForceFlatToSqlite(database, this);
|
||||
ForceFlatToSqlite converter = new ForceFlatToSqlite(database);
|
||||
DataSource source = converter.run();
|
||||
if (source != null) {
|
||||
database = source;
|
||||
|
@ -14,13 +14,11 @@ import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Xephi59
|
||||
* @version $Revision: 1.0 $
|
||||
*/
|
||||
public class CrazyLoginConverter implements Converter {
|
||||
|
||||
public final AuthMe instance;
|
||||
public final DataSource database;
|
||||
public final CommandSender sender;
|
||||
private final DataSource database;
|
||||
private final CommandSender sender;
|
||||
|
||||
/**
|
||||
* Constructor for CrazyLoginConverter.
|
||||
@ -29,7 +27,6 @@ public class CrazyLoginConverter implements Converter {
|
||||
* @param sender CommandSender
|
||||
*/
|
||||
public CrazyLoginConverter(AuthMe instance, CommandSender sender) {
|
||||
this.instance = instance;
|
||||
this.database = instance.database;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
@ -13,21 +12,10 @@ public class ForceFlatToSqlite {
|
||||
|
||||
private final DataSource data;
|
||||
|
||||
/**
|
||||
* Constructor for ForceFlatToSqlite.
|
||||
*
|
||||
* @param data DataSource
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public ForceFlatToSqlite(DataSource data, AuthMe plugin) {
|
||||
public ForceFlatToSqlite(DataSource data) {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
public DataSource run() {
|
||||
DataSource sqlite = null;
|
||||
try {
|
||||
@ -39,7 +27,7 @@ public class ForceFlatToSqlite {
|
||||
Settings.setValue("DataSource.backend", "sqlite");
|
||||
ConsoleLogger.info("Database successfully converted to sqlite !");
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.showError("An error occured while trying to convert flatfile to sqlite ...");
|
||||
ConsoleLogger.showError("An error occurred while trying to convert flatfile to sqlite ...");
|
||||
return null;
|
||||
}
|
||||
return sqlite;
|
||||
|
@ -19,7 +19,6 @@ import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* @author Xephi59
|
||||
* @version $Revision: 1.0 $
|
||||
*/
|
||||
public class RakamakConverter implements Converter {
|
||||
|
||||
@ -27,32 +26,16 @@ public class RakamakConverter implements Converter {
|
||||
public final DataSource database;
|
||||
public final CommandSender sender;
|
||||
|
||||
/**
|
||||
* Constructor for RakamakConverter.
|
||||
*
|
||||
* @param instance AuthMe
|
||||
* @param sender CommandSender
|
||||
*/
|
||||
public RakamakConverter(AuthMe instance, CommandSender sender) {
|
||||
this.instance = instance;
|
||||
this.database = instance.database;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getInstance.
|
||||
*
|
||||
* @return RakamakConverter
|
||||
*/
|
||||
public RakamakConverter getInstance() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
HashAlgorithm hash = Settings.getPasswordHash;
|
||||
|
@ -8,28 +8,16 @@ import org.bukkit.OfflinePlayer;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class RoyalAuthConverter implements Converter {
|
||||
|
||||
public final AuthMe plugin;
|
||||
private final AuthMe plugin;
|
||||
private final DataSource data;
|
||||
|
||||
/**
|
||||
* Constructor for RoyalAuthConverter.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public RoyalAuthConverter(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
this.data = plugin.database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
for (OfflinePlayer o : plugin.getServer().getOfflinePlayers()) {
|
||||
|
@ -4,35 +4,18 @@ import fr.xephi.authme.settings.CustomConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class RoyalAuthYamlReader extends CustomConfiguration {
|
||||
class RoyalAuthYamlReader extends CustomConfiguration {
|
||||
|
||||
/**
|
||||
* Constructor for RoyalAuthYamlReader.
|
||||
*
|
||||
* @param file File
|
||||
*/
|
||||
public RoyalAuthYamlReader(File file) {
|
||||
super(file);
|
||||
load();
|
||||
save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getLastLogin.
|
||||
*
|
||||
* @return long
|
||||
*/
|
||||
public long getLastLogin() {
|
||||
return getLong("timestamps.quit");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getHash.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getHash() {
|
||||
return getString("login.password");
|
||||
}
|
||||
|
@ -2,38 +2,22 @@ package fr.xephi.authme.converter;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class vAuthConverter implements Converter {
|
||||
|
||||
public final AuthMe plugin;
|
||||
public final DataSource database;
|
||||
public final CommandSender sender;
|
||||
private final AuthMe plugin;
|
||||
private final CommandSender sender;
|
||||
|
||||
/**
|
||||
* Constructor for vAuthConverter.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
* @param sender CommandSender
|
||||
*/
|
||||
public vAuthConverter(AuthMe plugin, CommandSender sender) {
|
||||
this.plugin = plugin;
|
||||
this.database = plugin.database;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
new vAuthFileReader(plugin, sender).convert();
|
||||
new vAuthFileReader(plugin).convert();
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(e.getMessage());
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
|
@ -6,30 +6,24 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Scanner;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class vAuthFileReader {
|
||||
class vAuthFileReader {
|
||||
|
||||
public final AuthMe plugin;
|
||||
public final DataSource database;
|
||||
public final CommandSender sender;
|
||||
private final AuthMe plugin;
|
||||
private final DataSource database;
|
||||
|
||||
/**
|
||||
* Constructor for vAuthFileReader.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
* @param sender CommandSender
|
||||
*/
|
||||
public vAuthFileReader(AuthMe plugin, CommandSender sender) {
|
||||
public vAuthFileReader(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
this.database = plugin.database;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
public void convert() {
|
||||
@ -68,13 +62,6 @@ public class vAuthFileReader {
|
||||
return s.length() > 8 && s.charAt(8) == '-';
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getName.
|
||||
*
|
||||
* @param uuid UUID
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
private String getName(UUID uuid) {
|
||||
try {
|
||||
for (OfflinePlayer op : Bukkit.getOfflinePlayers()) {
|
||||
|
@ -5,8 +5,8 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
public class xAuthConverter implements Converter {
|
||||
|
||||
public final AuthMe plugin;
|
||||
public final CommandSender sender;
|
||||
private final AuthMe plugin;
|
||||
private final CommandSender sender;
|
||||
|
||||
public xAuthConverter(AuthMe plugin, CommandSender sender) {
|
||||
this.plugin = plugin;
|
||||
|
@ -16,11 +16,11 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class xAuthToFlat {
|
||||
class xAuthToFlat {
|
||||
|
||||
public final AuthMe instance;
|
||||
public final DataSource database;
|
||||
public final CommandSender sender;
|
||||
private final AuthMe instance;
|
||||
private final DataSource database;
|
||||
private final CommandSender sender;
|
||||
|
||||
/**
|
||||
* Constructor for xAuthToFlat.
|
||||
@ -57,14 +57,14 @@ public class xAuthToFlat {
|
||||
database.saveAuth(auth);
|
||||
}
|
||||
}
|
||||
sender.sendMessage("[AuthMe] Successfully convert from xAuth database");
|
||||
sender.sendMessage("[AuthMe] Successfully converted 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) {
|
||||
private String getIdPlayer(int id) {
|
||||
String realPass = "";
|
||||
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
|
||||
PreparedStatement ps = null;
|
||||
@ -86,7 +86,7 @@ public class xAuthToFlat {
|
||||
return realPass;
|
||||
}
|
||||
|
||||
public List<Integer> getXAuthPlayers() {
|
||||
private List<Integer> getXAuthPlayers() {
|
||||
List<Integer> xP = new ArrayList<>();
|
||||
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
|
||||
PreparedStatement ps = null;
|
||||
@ -107,7 +107,7 @@ public class xAuthToFlat {
|
||||
return xP;
|
||||
}
|
||||
|
||||
public String getPassword(int accountId) {
|
||||
private String getPassword(int accountId) {
|
||||
String realPass = "";
|
||||
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
|
||||
PreparedStatement ps = null;
|
||||
|
Loading…
Reference in New Issue
Block a user