Prepare the project for javadocs

This commit is contained in:
Gabriele C 2015-11-21 01:27:06 +01:00
parent adcd70b91d
commit 118c79401a
168 changed files with 4375 additions and 422 deletions

View File

@ -59,6 +59,8 @@ import fr.xephi.authme.util.Utils;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
import net.minelink.ctplus.CombatTagPlus; import net.minelink.ctplus.CombatTagPlus;
/**
*/
public class AuthMe extends JavaPlugin { public class AuthMe extends JavaPlugin {
/** Defines the name of the plugin. */ /** Defines the name of the plugin. */
@ -111,30 +113,58 @@ public class AuthMe extends JavaPlugin {
// In case we need to cache PlayerAuths, prevent connection before it's done // In case we need to cache PlayerAuths, prevent connection before it's done
private boolean canConnect = true; private boolean canConnect = true;
/**
* Method canConnect.
* @return boolean
*/
public boolean canConnect() { public boolean canConnect() {
return canConnect; return canConnect;
} }
/**
* Method setCanConnect.
* @param canConnect boolean
*/
public void setCanConnect(boolean canConnect) { public void setCanConnect(boolean canConnect) {
this.canConnect = canConnect; this.canConnect = canConnect;
} }
/**
* Method getInstance.
* @return AuthMe
*/
public static AuthMe getInstance() { public static AuthMe getInstance() {
return plugin; return plugin;
} }
/**
* Method getSettings.
* @return Settings
*/
public Settings getSettings() { public Settings getSettings() {
return settings; return settings;
} }
/**
* Method setMessages.
* @param m Messages
*/
public void setMessages(Messages m) { public void setMessages(Messages m) {
this.m = m; this.m = m;
} }
/**
* Method getMessages.
* @return Messages
*/
public Messages getMessages() { public Messages getMessages() {
return m; return m;
} }
/**
* Method onEnable.
* @see org.bukkit.plugin.Plugin#onEnable()
*/
@Override @Override
public void onEnable() { public void onEnable() {
// Set the Instance // Set the Instance
@ -362,6 +392,10 @@ public class AuthMe extends JavaPlugin {
ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " correctly enabled!"); ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " correctly enabled!");
} }
/**
* Method onDisable.
* @see org.bukkit.plugin.Plugin#onDisable()
*/
@Override @Override
public void onDisable() { public void onDisable() {
// Save player data // Save player data
@ -404,12 +438,20 @@ public class AuthMe extends JavaPlugin {
// Show the exception message and stop/unload the server/plugin as defined // Show the exception message and stop/unload the server/plugin as defined
// in the configuration // in the configuration
/**
* Method stopOrUnload.
* @param e Exception
*/
public void stopOrUnload(Exception e) { public void stopOrUnload(Exception e) {
ConsoleLogger.showError(e.getMessage()); ConsoleLogger.showError(e.getMessage());
stopOrUnload(); stopOrUnload();
} }
// Initialize and setup the database // Initialize and setup the database
/**
* Method setupDatabase.
* @throws Exception
*/
public void setupDatabase() throws Exception { public void setupDatabase() throws Exception {
if (database != null) if (database != null)
database.close(); database.close();
@ -465,8 +507,8 @@ public class AuthMe extends JavaPlugin {
/** /**
* Get the permissions manager instance. * Get the permissions manager instance.
* *
* @return Permissions Manager instance.
*/ * @return Permissions Manager instance. */
public PermissionsManager getPermissionsManager() { public PermissionsManager getPermissionsManager() {
return this.permsMan; return this.permsMan;
} }
@ -571,7 +613,8 @@ public class AuthMe extends JavaPlugin {
* *
* @param player * @param player
* @param perm * @param perm
* @return
* @return boolean
*/ */
public boolean authmePermissible(Player player, String perm) { public boolean authmePermissible(Player player, String perm) {
// New code: // New code:
@ -591,7 +634,8 @@ public class AuthMe extends JavaPlugin {
* *
* @param sender * @param sender
* @param perm * @param perm
* @return
* @return boolean
*/ */
public boolean authmePermissible(CommandSender sender, String perm) { public boolean authmePermissible(CommandSender sender, String perm) {
// Handle players with the permissions manager // Handle players with the permissions manager
@ -606,6 +650,10 @@ public class AuthMe extends JavaPlugin {
} }
// Save Player Data // Save Player Data
/**
* Method savePlayer.
* @param player Player
*/
public void savePlayer(Player player) { public void savePlayer(Player player) {
if ((Utils.isNPC(player)) || (Utils.isUnrestricted(player))) { if ((Utils.isNPC(player)) || (Utils.isUnrestricted(player))) {
return; return;
@ -634,6 +682,11 @@ public class AuthMe extends JavaPlugin {
} }
// Select the player to kick when a vip player join the server when full // Select the player to kick when a vip player join the server when full
/**
* Method generateKickPlayer.
* @param collection Collection<? extends Player>
* @return Player
*/
public Player generateKickPlayer(Collection<? extends Player> collection) { public Player generateKickPlayer(Collection<? extends Player> collection) {
Player player = null; Player player = null;
for (Player p : collection) { for (Player p : collection) {
@ -678,6 +731,11 @@ public class AuthMe extends JavaPlugin {
} }
// Return the spawn location of a player // Return the spawn location of a player
/**
* Method getSpawnLocation.
* @param player Player
* @return Location
*/
public Location getSpawnLocation(Player player) { public Location getSpawnLocation(Player player) {
World world = player.getWorld(); World world = player.getWorld();
String[] spawnPriority = Settings.spawnPriority.split(","); String[] spawnPriority = Settings.spawnPriority.split(",");
@ -700,11 +758,21 @@ public class AuthMe extends JavaPlugin {
} }
// Return the default spawnpoint of a world // Return the default spawnpoint of a world
/**
* Method getDefaultSpawn.
* @param world World
* @return Location
*/
private Location getDefaultSpawn(World world) { private Location getDefaultSpawn(World world) {
return world.getSpawnLocation(); return world.getSpawnLocation();
} }
// Return the multiverse spawnpoint of a world // Return the multiverse spawnpoint of a world
/**
* Method getMultiverseSpawn.
* @param world World
* @return Location
*/
private Location getMultiverseSpawn(World world) { private Location getMultiverseSpawn(World world) {
if (multiverse != null && Settings.multiverse) { if (multiverse != null && Settings.multiverse) {
try { try {
@ -717,6 +785,10 @@ public class AuthMe extends JavaPlugin {
} }
// Return the essentials spawnpoint // Return the essentials spawnpoint
/**
* Method getEssentialsSpawn.
* @return Location
*/
private Location getEssentialsSpawn() { private Location getEssentialsSpawn() {
if (essentialsSpawn != null) { if (essentialsSpawn != null) {
return essentialsSpawn; return essentialsSpawn;
@ -725,6 +797,11 @@ public class AuthMe extends JavaPlugin {
} }
// Return the authme soawnpoint // Return the authme soawnpoint
/**
* Method getAuthMeSpawn.
* @param player Player
* @return Location
*/
private Location getAuthMeSpawn(Player player) { private Location getAuthMeSpawn(Player player) {
if ((!database.isAuthAvailable(player.getName().toLowerCase()) || !player.hasPlayedBefore()) && (Spawn.getInstance().getFirstSpawn() != null)) { if ((!database.isAuthAvailable(player.getName().toLowerCase()) || !player.hasPlayedBefore()) && (Spawn.getInstance().getFirstSpawn() != null)) {
return Spawn.getInstance().getFirstSpawn(); return Spawn.getInstance().getFirstSpawn();
@ -735,11 +812,19 @@ public class AuthMe extends JavaPlugin {
return player.getWorld().getSpawnLocation(); return player.getWorld().getSpawnLocation();
} }
/**
* Method switchAntiBotMod.
* @param mode boolean
*/
public void switchAntiBotMod(boolean mode) { public void switchAntiBotMod(boolean mode) {
this.antibotMod = mode; this.antibotMod = mode;
Settings.switchAntiBotMod(mode); Settings.switchAntiBotMod(mode);
} }
/**
* Method getAntiBotModMode.
* @return boolean
*/
public boolean getAntiBotModMode() { public boolean getAntiBotModMode() {
return this.antibotMod; return this.antibotMod;
} }
@ -766,6 +851,12 @@ public class AuthMe extends JavaPlugin {
}, 1, 1200 * Settings.delayRecall); }, 1, 1200 * Settings.delayRecall);
} }
/**
* Method replaceAllInfos.
* @param message String
* @param player Player
* @return String
*/
public String replaceAllInfos(String message, Player player) { public String replaceAllInfos(String message, Player player) {
int playersOnline = Utils.getOnlinePlayers().size(); int playersOnline = Utils.getOnlinePlayers().size();
message = message.replace("&", "\u00a7"); message = message.replace("&", "\u00a7");
@ -781,6 +872,11 @@ public class AuthMe extends JavaPlugin {
return message; return message;
} }
/**
* Method getIP.
* @param player Player
* @return String
*/
public String getIP(Player player) { public String getIP(Player player) {
String name = player.getName().toLowerCase(); String name = player.getName().toLowerCase();
String ip = player.getAddress().getAddress().getHostAddress(); String ip = player.getAddress().getAddress().getHostAddress();
@ -794,6 +890,12 @@ public class AuthMe extends JavaPlugin {
return ip; return ip;
} }
/**
* Method isLoggedIp.
* @param name String
* @param ip String
* @return boolean
*/
public boolean isLoggedIp(String name, String ip) { public boolean isLoggedIp(String name, String ip) {
int count = 0; int count = 0;
for (Player player : Utils.getOnlinePlayers()) { for (Player player : Utils.getOnlinePlayers()) {
@ -803,6 +905,12 @@ public class AuthMe extends JavaPlugin {
return count >= Settings.getMaxLoginPerIp; return count >= Settings.getMaxLoginPerIp;
} }
/**
* Method hasJoinedIp.
* @param name String
* @param ip String
* @return boolean
*/
public boolean hasJoinedIp(String name, String ip) { public boolean hasJoinedIp(String name, String ip) {
int count = 0; int count = 0;
for (Player player : Utils.getOnlinePlayers()) { for (Player player : Utils.getOnlinePlayers()) {
@ -812,6 +920,10 @@ public class AuthMe extends JavaPlugin {
return count >= Settings.getMaxJoinPerIp; return count >= Settings.getMaxJoinPerIp;
} }
/**
* Method getModuleManager.
* @return ModuleManager
*/
public ModuleManager getModuleManager() { public ModuleManager getModuleManager() {
return moduleManager; return moduleManager;
} }
@ -821,6 +933,7 @@ public class AuthMe extends JavaPlugin {
* *
* @param player * @param player
* player * player
* @return String
*/ */
@Deprecated @Deprecated
public String getVeryGamesIP(Player player) { public String getVeryGamesIP(Player player) {
@ -840,11 +953,21 @@ public class AuthMe extends JavaPlugin {
return realIP; return realIP;
} }
/**
* Method getCountryCode.
* @param ip String
* @return String
*/
@Deprecated @Deprecated
public String getCountryCode(String ip) { public String getCountryCode(String ip) {
return Utils.getCountryCode(ip); return Utils.getCountryCode(ip);
} }
/**
* Method getCountryName.
* @param ip String
* @return String
*/
@Deprecated @Deprecated
public String getCountryName(String ip) { public String getCountryName(String ip) {
return Utils.getCountryName(ip); return Utils.getCountryName(ip);
@ -853,8 +976,8 @@ public class AuthMe extends JavaPlugin {
/** /**
* Get the command handler instance. * Get the command handler instance.
* *
* @return Command handler.
*/ * @return Command handler. */
public CommandHandler getCommandHandler() { public CommandHandler getCommandHandler() {
return this.commandHandler; return this.commandHandler;
} }
@ -871,7 +994,8 @@ public class AuthMe extends JavaPlugin {
* @param args * @param args
* The command arguments (Bukkit). * The command arguments (Bukkit).
* *
* @return True if the command was executed, false otherwise.
* @return True if the command was executed, false otherwise. * @see org.bukkit.command.CommandExecutor#onCommand(CommandSender, Command, String, String[])
*/ */
@Override @Override
public boolean onCommand(CommandSender sender, Command cmd, public boolean onCommand(CommandSender sender, Command cmd,
@ -888,9 +1012,9 @@ public class AuthMe extends JavaPlugin {
/** /**
* Get the current installed AuthMeReloaded version name. * Get the current installed AuthMeReloaded version name.
* *
* @return The version name of the currently installed AuthMeReloaded * @return The version name of the currently installed AuthMeReloaded
* instance. * instance. */
*/
public static String getVersionName() { public static String getVersionName() {
return PLUGIN_VERSION_NAME; return PLUGIN_VERSION_NAME;
} }
@ -898,9 +1022,9 @@ public class AuthMe extends JavaPlugin {
/** /**
* Get the current installed AuthMeReloaded version code. * Get the current installed AuthMeReloaded version code.
* *
* @return The version code of the currently installed AuthMeReloaded * @return The version code of the currently installed AuthMeReloaded
* instance. * instance. */
*/
public static int getVersionCode() { public static int getVersionCode() {
return PLUGIN_VERSION_CODE; return PLUGIN_VERSION_CODE;
} }

View File

@ -6,12 +6,19 @@ import java.util.logging.LogRecord;
/** /**
* *
* @author Xephi59 * @author Xephi59
* @version $Revision: 1.0 $
*/ */
public class ConsoleFilter implements Filter { public class ConsoleFilter implements Filter {
public ConsoleFilter() { public ConsoleFilter() {
} }
/**
* Method isLoggable.
* @param record LogRecord
* @return boolean
* @see java.util.logging.Filter#isLoggable(LogRecord)
*/
@Override @Override
public boolean isLoggable(LogRecord record) { public boolean isLoggable(LogRecord record) {
try { try {

View File

@ -13,11 +13,17 @@ import com.google.common.base.Throwables;
import fr.xephi.authme.api.NewAPI; import fr.xephi.authme.api.NewAPI;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
/**
*/
public class ConsoleLogger { public class ConsoleLogger {
private static final Logger log = AuthMe.getInstance().getLogger(); private static final Logger log = AuthMe.getInstance().getLogger();
private static final DateFormat df = new SimpleDateFormat("[MM-dd HH:mm:ss]"); private static final DateFormat df = new SimpleDateFormat("[MM-dd HH:mm:ss]");
/**
* Method info.
* @param message String
*/
public static void info(String message) { public static void info(String message) {
log.info("[AuthMe] " + message); log.info("[AuthMe] " + message);
if (Settings.useLogging) { if (Settings.useLogging) {
@ -29,6 +35,10 @@ public class ConsoleLogger {
} }
} }
/**
* Method showError.
* @param message String
*/
public static void showError(String message) { public static void showError(String message) {
log.warning("[AuthMe] " + message); log.warning("[AuthMe] " + message);
if (Settings.useLogging) { if (Settings.useLogging) {
@ -40,6 +50,10 @@ public class ConsoleLogger {
} }
} }
/**
* Method writeLog.
* @param message String
*/
public static void writeLog(String message) { public static void writeLog(String message) {
try { try {
Files.write(Settings.LOG_FILE.toPath(), (message + NewAPI.newline).getBytes(), Files.write(Settings.LOG_FILE.toPath(), (message + NewAPI.newline).getBytes(),
@ -49,6 +63,10 @@ public class ConsoleLogger {
} }
} }
/**
* Method writeStackTrace.
* @param ex Exception
*/
public static void writeStackTrace(Exception ex) { public static void writeStackTrace(Exception ex) {
if (Settings.useLogging) { if (Settings.useLogging) {
String dateTime; String dateTime;

View File

@ -15,10 +15,16 @@ import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.Utils; import fr.xephi.authme.util.Utils;
import net.milkbowl.vault.permission.Permission; import net.milkbowl.vault.permission.Permission;
/**
*/
public class DataManager { public class DataManager {
public AuthMe plugin; public AuthMe plugin;
/**
* Constructor for DataManager.
* @param plugin AuthMe
*/
public DataManager(AuthMe plugin) { public DataManager(AuthMe plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
@ -26,6 +32,11 @@ public class DataManager {
public void run() { public void run() {
} }
/**
* Method getOfflinePlayer.
* @param name String
* @return OfflinePlayer
*/
public synchronized OfflinePlayer getOfflinePlayer(final String name) { public synchronized OfflinePlayer getOfflinePlayer(final String name) {
ExecutorService executor = Executors.newSingleThreadExecutor(); ExecutorService executor = Executors.newSingleThreadExecutor();
Future<OfflinePlayer> result = executor.submit(new Callable<OfflinePlayer>() { Future<OfflinePlayer> result = executor.submit(new Callable<OfflinePlayer>() {
@ -52,6 +63,10 @@ public class DataManager {
} }
} }
/**
* Method purgeAntiXray.
* @param cleared List<String>
*/
public synchronized void purgeAntiXray(List<String> cleared) { public synchronized void purgeAntiXray(List<String> cleared) {
int i = 0; int i = 0;
for (String name : cleared) { for (String name : cleared) {
@ -71,6 +86,10 @@ public class DataManager {
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " AntiXRayData Files"); ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " AntiXRayData Files");
} }
/**
* Method purgeLimitedCreative.
* @param cleared List<String>
*/
public synchronized void purgeLimitedCreative(List<String> cleared) { public synchronized void purgeLimitedCreative(List<String> cleared) {
int i = 0; int i = 0;
for (String name : cleared) { for (String name : cleared) {
@ -100,6 +119,10 @@ public class DataManager {
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " LimitedCreative Survival, Creative and Adventure files"); ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " LimitedCreative Survival, Creative and Adventure files");
} }
/**
* Method purgeDat.
* @param cleared List<String>
*/
public synchronized void purgeDat(List<String> cleared) { public synchronized void purgeDat(List<String> cleared) {
int i = 0; int i = 0;
for (String name : cleared) { for (String name : cleared) {
@ -126,6 +149,10 @@ public class DataManager {
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " .dat Files"); ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " .dat Files");
} }
/**
* Method purgeEssentials.
* @param cleared List<String>
*/
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void purgeEssentials(List<String> cleared) { public void purgeEssentials(List<String> cleared) {
int i = 0; int i = 0;
@ -145,6 +172,11 @@ public class DataManager {
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles"); ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
} }
/**
* Method purgePermissions.
* @param cleared List<String>
* @param permission Permission
*/
public synchronized void purgePermissions(List<String> cleared, public synchronized void purgePermissions(List<String> cleared,
Permission permission) { Permission permission) {
int i = 0; int i = 0;
@ -161,6 +193,12 @@ public class DataManager {
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " Permissions"); ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " Permissions");
} }
/**
* Method isOnline.
* @param player Player
* @param name String
* @return boolean
*/
public boolean isOnline(Player player, final String name) { public boolean isOnline(Player player, final String name) {
if (player.isOnline()) if (player.isOnline())
return true; return true;
@ -185,6 +223,11 @@ public class DataManager {
} }
} }
/**
* Method getOnlinePlayerLower.
* @param name String
* @return Player
*/
public Player getOnlinePlayerLower(String name) { public Player getOnlinePlayerLower(String name) {
name = name.toLowerCase(); name = name.toLowerCase();
for (Player player : Utils.getOnlinePlayers()) { for (Player player : Utils.getOnlinePlayers()) {

View File

@ -6,13 +6,23 @@ import java.awt.GradientPaint;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
/**
*/
public class ImageGenerator { public class ImageGenerator {
private String pass; private String pass;
/**
* Constructor for ImageGenerator.
* @param pass String
*/
public ImageGenerator(String pass) { public ImageGenerator(String pass) {
this.pass = pass; this.pass = pass;
} }
/**
* Method generateImage.
* @return BufferedImage
*/
public BufferedImage generateImage() { public BufferedImage generateImage() {
BufferedImage image = new BufferedImage(200, 60, BufferedImage.TYPE_BYTE_INDEXED); BufferedImage image = new BufferedImage(200, 60, BufferedImage.TYPE_BYTE_INDEXED);
Graphics2D graphics = image.createGraphics(); Graphics2D graphics = image.createGraphics();

View File

@ -11,6 +11,7 @@ import fr.xephi.authme.util.StringUtils;
/** /**
* Implements a filter for Log4j to skip sensitive AuthMe commands. * Implements a filter for Log4j to skip sensitive AuthMe commands.
* @author Xephi59 * @author Xephi59
* @version $Revision: 1.0 $
*/ */
public class Log4JFilter implements org.apache.logging.log4j.core.Filter { public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
@ -23,6 +24,12 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
public Log4JFilter() { public Log4JFilter() {
} }
/**
* Method filter.
* @param record LogEvent
* @return Result
* @see org.apache.logging.log4j.core.Filter#filter(LogEvent)
*/
@Override @Override
public Result filter(LogEvent record) { public Result filter(LogEvent record) {
if (record == null) { if (record == null) {
@ -31,12 +38,32 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
return validateMessage(record.getMessage()); return validateMessage(record.getMessage());
} }
/**
* Method filter.
* @param arg0 Logger
* @param arg1 Level
* @param arg2 Marker
* @param message String
* @param arg4 Object[]
* @return Result
* @see org.apache.logging.log4j.core.Filter#filter(Logger, Level, Marker, String, Object[])
*/
@Override @Override
public Result filter(Logger arg0, Level arg1, Marker arg2, String message, public Result filter(Logger arg0, Level arg1, Marker arg2, String message,
Object... arg4) { Object... arg4) {
return validateMessage(message); return validateMessage(message);
} }
/**
* Method filter.
* @param arg0 Logger
* @param arg1 Level
* @param arg2 Marker
* @param message Object
* @param arg4 Throwable
* @return Result
* @see org.apache.logging.log4j.core.Filter#filter(Logger, Level, Marker, Object, Throwable)
*/
@Override @Override
public Result filter(Logger arg0, Level arg1, Marker arg2, Object message, public Result filter(Logger arg0, Level arg1, Marker arg2, Object message,
Throwable arg4) { Throwable arg4) {
@ -46,17 +73,37 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
return validateMessage(message.toString()); return validateMessage(message.toString());
} }
/**
* Method filter.
* @param arg0 Logger
* @param arg1 Level
* @param arg2 Marker
* @param message Message
* @param arg4 Throwable
* @return Result
* @see org.apache.logging.log4j.core.Filter#filter(Logger, Level, Marker, Message, Throwable)
*/
@Override @Override
public Result filter(Logger arg0, Level arg1, Marker arg2, Message message, public Result filter(Logger arg0, Level arg1, Marker arg2, Message message,
Throwable arg4) { Throwable arg4) {
return validateMessage(message); return validateMessage(message);
} }
/**
* Method getOnMatch.
* @return Result
* @see org.apache.logging.log4j.core.Filter#getOnMatch()
*/
@Override @Override
public Result getOnMatch() { public Result getOnMatch() {
return Result.NEUTRAL; return Result.NEUTRAL;
} }
/**
* Method getOnMismatch.
* @return Result
* @see org.apache.logging.log4j.core.Filter#getOnMismatch()
*/
@Override @Override
public Result getOnMismatch() { public Result getOnMismatch() {
return Result.NEUTRAL; return Result.NEUTRAL;
@ -68,8 +115,8 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
* data. * data.
* *
* @param message the Message object to verify * @param message the Message object to verify
* @return the Result value
*/ * @return the Result value */
private static Result validateMessage(Message message) { private static Result validateMessage(Message message) {
if (message == null) { if (message == null) {
return Result.NEUTRAL; return Result.NEUTRAL;
@ -82,8 +129,8 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
* depending on whether the message contains sensitive AuthMe data. * depending on whether the message contains sensitive AuthMe data.
* *
* @param message the message to verify * @param message the message to verify
* @return the Result value
*/ * @return the Result value */
private static Result validateMessage(String message) { private static Result validateMessage(String message) {
if (message == null) { if (message == null) {
return Result.NEUTRAL; return Result.NEUTRAL;

View File

@ -14,6 +14,7 @@ import fr.xephi.authme.settings.Settings;
/** /**
* *
* @author stefano * @author stefano
* @version $Revision: 1.0 $
*/ */
public class PerformBackup { public class PerformBackup {
@ -26,10 +27,18 @@ public class PerformBackup {
private String path = AuthMe.getInstance().getDataFolder() + File.separator + "backups" + File.separator + "backup" + dateString; private String path = AuthMe.getInstance().getDataFolder() + File.separator + "backups" + File.separator + "backup" + dateString;
private AuthMe instance; private AuthMe instance;
/**
* Constructor for PerformBackup.
* @param instance AuthMe
*/
public PerformBackup(AuthMe instance) { public PerformBackup(AuthMe instance) {
this.setInstance(instance); this.setInstance(instance);
} }
/**
* Method doBackup.
* @return boolean
*/
public boolean doBackup() { public boolean doBackup() {
switch (Settings.getDataSource) { switch (Settings.getDataSource) {
@ -44,6 +53,10 @@ public class PerformBackup {
return false; return false;
} }
/**
* Method MySqlBackup.
* @return boolean
*/
private boolean MySqlBackup() { private boolean MySqlBackup() {
File dirBackup = new File(AuthMe.getInstance().getDataFolder() + "/backups"); File dirBackup = new File(AuthMe.getInstance().getDataFolder() + "/backups");
@ -83,6 +96,11 @@ public class PerformBackup {
return false; return false;
} }
/**
* Method FileBackup.
* @param backend String
* @return boolean
*/
private boolean FileBackup(String backend) { private boolean FileBackup(String backend) {
File dirBackup = new File(AuthMe.getInstance().getDataFolder() + "/backups"); File dirBackup = new File(AuthMe.getInstance().getDataFolder() + "/backups");
@ -103,6 +121,11 @@ public class PerformBackup {
* Check if we are under Windows and correct location of mysqldump.exe * Check if we are under Windows and correct location of mysqldump.exe
* otherwise return error. * otherwise return error.
*/ */
/**
* Method checkWindows.
* @param windowsPath String
* @return boolean
*/
private boolean checkWindows(String windowsPath) { private boolean checkWindows(String windowsPath) {
String isWin = System.getProperty("os.name").toLowerCase(); String isWin = System.getProperty("os.name").toLowerCase();
if (isWin.indexOf("win") >= 0) { if (isWin.indexOf("win") >= 0) {
@ -118,6 +141,12 @@ public class PerformBackup {
/* /*
* Copyr src bytefile into dst file * Copyr src bytefile into dst file
*/ */
/**
* Method copy.
* @param src File
* @param dst File
* @throws IOException
*/
void copy(File src, File dst) throws IOException { void copy(File src, File dst) throws IOException {
InputStream in = new FileInputStream(src); InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dst); OutputStream out = new FileOutputStream(dst);
@ -132,10 +161,18 @@ public class PerformBackup {
out.close(); out.close();
} }
/**
* Method setInstance.
* @param instance AuthMe
*/
public void setInstance(AuthMe instance) { public void setInstance(AuthMe instance) {
this.instance = instance; this.instance = instance;
} }
/**
* Method getInstance.
* @return AuthMe
*/
public AuthMe getInstance() { public AuthMe getInstance() {
return instance; return instance;
} }

View File

@ -15,15 +15,25 @@ import fr.xephi.authme.settings.Settings;
/** /**
* *
* @author Xephi59 * @author Xephi59
* @version $Revision: 1.0 $
*/ */
public class SendMailSSL { public class SendMailSSL {
public AuthMe plugin; public AuthMe plugin;
/**
* Constructor for SendMailSSL.
* @param plugin AuthMe
*/
public SendMailSSL(AuthMe plugin) { public SendMailSSL(AuthMe plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
/**
* Method main.
* @param auth PlayerAuth
* @param newPass String
*/
public void main(final PlayerAuth auth, final String newPass) { public void main(final PlayerAuth auth, final String newPass) {
String sendername; String sendername;

View File

@ -15,11 +15,17 @@ import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.Utils; import fr.xephi.authme.util.Utils;
/**
*/
public class API { public class API {
public static final String newline = System.getProperty("line.separator"); public static final String newline = System.getProperty("line.separator");
public static AuthMe instance; public static AuthMe instance;
/**
* Constructor for API.
* @param instance AuthMe
*/
@Deprecated @Deprecated
public API(AuthMe instance) { public API(AuthMe instance) {
API.instance = instance; API.instance = instance;
@ -28,8 +34,8 @@ public class API {
/** /**
* Hook into AuthMe * Hook into AuthMe
* *
* @return AuthMe instance
*/ * @return AuthMe instance */
@Deprecated @Deprecated
public static AuthMe hookAuthMe() { public static AuthMe hookAuthMe() {
if (instance != null) if (instance != null)
@ -42,6 +48,10 @@ public class API {
return instance; return instance;
} }
/**
* Method getPlugin.
* @return AuthMe
*/
@Deprecated @Deprecated
public AuthMe getPlugin() { public AuthMe getPlugin() {
return instance; return instance;
@ -50,8 +60,8 @@ public class API {
/** /**
* *
* @param player * @param player
* @return true if player is authenticate
*/ * @return true if player is authenticate */
@Deprecated @Deprecated
public static boolean isAuthenticated(Player player) { public static boolean isAuthenticated(Player player) {
return PlayerCache.getInstance().isAuthenticated(player.getName()); return PlayerCache.getInstance().isAuthenticated(player.getName());
@ -60,8 +70,8 @@ public class API {
/** /**
* *
* @param player * @param player
* @return true if player is a npc
*/ * @return true if player is a npc */
@Deprecated @Deprecated
public boolean isaNPC(Player player) { public boolean isaNPC(Player player) {
return Utils.isNPC(player); return Utils.isNPC(player);
@ -70,8 +80,8 @@ public class API {
/** /**
* *
* @param player * @param player
* @return true if player is a npc
*/ * @return true if player is a npc */
@Deprecated @Deprecated
public boolean isNPC(Player player) { public boolean isNPC(Player player) {
return Utils.isNPC(player); return Utils.isNPC(player);
@ -80,13 +90,18 @@ public class API {
/** /**
* *
* @param player * @param player
* @return true if the player is unrestricted
*/ * @return true if the player is unrestricted */
@Deprecated @Deprecated
public static boolean isUnrestricted(Player player) { public static boolean isUnrestricted(Player player) {
return Utils.isUnrestricted(player); return Utils.isUnrestricted(player);
} }
/**
* Method getLastLocation.
* @param player Player
* @return Location
*/
@Deprecated @Deprecated
public static Location getLastLocation(Player player) { public static Location getLastLocation(Player player) {
try { try {
@ -104,6 +119,12 @@ public class API {
} }
} }
/**
* Method setPlayerInventory.
* @param player Player
* @param content ItemStack[]
* @param armor ItemStack[]
*/
@Deprecated @Deprecated
public static void setPlayerInventory(Player player, ItemStack[] content, public static void setPlayerInventory(Player player, ItemStack[] content,
ItemStack[] armor) { ItemStack[] armor) {
@ -117,8 +138,8 @@ public class API {
/** /**
* *
* @param playerName * @param playerName
* @return true if player is registered
*/ * @return true if player is registered */
@Deprecated @Deprecated
public static boolean isRegistered(String playerName) { public static boolean isRegistered(String playerName) {
String player = playerName.toLowerCase(); String player = playerName.toLowerCase();
@ -126,10 +147,11 @@ public class API {
} }
/** /**
* @param String
* playerName, String passwordToCheck
* @return true if the password is correct , false else * @param playerName String
*/ * @param passwordToCheck String
* @return true if the password is correct , false else */
@Deprecated @Deprecated
public static boolean checkPassword(String playerName, public static boolean checkPassword(String playerName,
String passwordToCheck) { String passwordToCheck) {
@ -147,10 +169,11 @@ public class API {
/** /**
* Register a player * Register a player
* *
* @param String
* playerName, String password
* @return true if the player is register correctly * @param playerName String
*/ * @param password String
* @return true if the player is register correctly */
@Deprecated @Deprecated
public static boolean registerPlayer(String playerName, String password) { public static boolean registerPlayer(String playerName, String password) {
try { try {
@ -172,8 +195,8 @@ public class API {
/** /**
* Force a player to login * Force a player to login
* *
* @param Player
* player * @param player * player
*/ */
@Deprecated @Deprecated
public static void forceLogin(Player player) { public static void forceLogin(Player player) {

View File

@ -15,16 +15,26 @@ import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.Utils; import fr.xephi.authme.util.Utils;
/**
*/
public class NewAPI { public class NewAPI {
public static final String newline = System.getProperty("line.separator"); public static final String newline = System.getProperty("line.separator");
public static NewAPI singleton; public static NewAPI singleton;
public AuthMe plugin; public AuthMe plugin;
/**
* Constructor for NewAPI.
* @param plugin AuthMe
*/
public NewAPI(AuthMe plugin) { public NewAPI(AuthMe plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
/**
* Constructor for NewAPI.
* @param serv Server
*/
public NewAPI(Server serv) { public NewAPI(Server serv) {
this.plugin = (AuthMe) serv.getPluginManager().getPlugin("AuthMe"); this.plugin = (AuthMe) serv.getPluginManager().getPlugin("AuthMe");
} }
@ -32,8 +42,8 @@ public class NewAPI {
/** /**
* Hook into AuthMe * Hook into AuthMe
* *
* @return AuthMe plugin
*/ * @return AuthMe plugin */
public static NewAPI getInstance() { public static NewAPI getInstance() {
if (singleton != null) if (singleton != null)
return singleton; return singleton;
@ -46,6 +56,10 @@ public class NewAPI {
return singleton; return singleton;
} }
/**
* Method getPlugin.
* @return AuthMe
*/
public AuthMe getPlugin() { public AuthMe getPlugin() {
return plugin; return plugin;
} }
@ -53,8 +67,8 @@ public class NewAPI {
/** /**
* *
* @param player * @param player
* @return true if player is authenticate
*/ * @return true if player is authenticate */
public boolean isAuthenticated(Player player) { public boolean isAuthenticated(Player player) {
return PlayerCache.getInstance().isAuthenticated(player.getName()); return PlayerCache.getInstance().isAuthenticated(player.getName());
} }
@ -62,8 +76,8 @@ public class NewAPI {
/** /**
* *
* @param player * @param player
* @return true if player is a npc
*/ * @return true if player is a npc */
public boolean isNPC(Player player) { public boolean isNPC(Player player) {
return Utils.isNPC(player); return Utils.isNPC(player);
} }
@ -71,12 +85,17 @@ public class NewAPI {
/** /**
* *
* @param player * @param player
* @return true if the player is unrestricted
*/ * @return true if the player is unrestricted */
public boolean isUnrestricted(Player player) { public boolean isUnrestricted(Player player) {
return Utils.isUnrestricted(player); return Utils.isUnrestricted(player);
} }
/**
* Method getLastLocation.
* @param player Player
* @return Location
*/
public Location getLastLocation(Player player) { public Location getLastLocation(Player player) {
try { try {
PlayerAuth auth = PlayerCache.getInstance().getAuth(player.getName().toLowerCase()); PlayerAuth auth = PlayerCache.getInstance().getAuth(player.getName().toLowerCase());
@ -95,18 +114,19 @@ public class NewAPI {
/** /**
* *
* @param playerName * @param playerName
* @return true if player is registered
*/ * @return true if player is registered */
public boolean isRegistered(String playerName) { public boolean isRegistered(String playerName) {
String player = playerName.toLowerCase(); String player = playerName.toLowerCase();
return plugin.database.isAuthAvailable(player); return plugin.database.isAuthAvailable(player);
} }
/** /**
* @param String
* playerName, String passwordToCheck
* @return true if the password is correct , false else * @param playerName String
*/ * @param passwordToCheck String
* @return true if the password is correct , false else */
public boolean checkPassword(String playerName, String passwordToCheck) { public boolean checkPassword(String playerName, String passwordToCheck) {
if (!isRegistered(playerName)) if (!isRegistered(playerName))
return false; return false;
@ -122,10 +142,11 @@ public class NewAPI {
/** /**
* Register a player * Register a player
* *
* @param String
* playerName, String password
* @return true if the player is register correctly * @param playerName String
*/ * @param password String
* @return true if the player is register correctly */
public boolean registerPlayer(String playerName, String password) { public boolean registerPlayer(String playerName, String password) {
try { try {
String name = playerName.toLowerCase(); String name = playerName.toLowerCase();
@ -143,8 +164,8 @@ public class NewAPI {
/** /**
* Force a player to login * Force a player to login
* *
* @param Player
* player * @param player * player
*/ */
public void forceLogin(Player player) { public void forceLogin(Player player) {
plugin.management.performLogin(player, "dontneed", true); plugin.management.performLogin(player, "dontneed", true);
@ -153,8 +174,8 @@ public class NewAPI {
/** /**
* Force a player to logout * Force a player to logout
* *
* @param Player
* player * @param player * player
*/ */
public void forceLogout(Player player) public void forceLogout(Player player)
{ {
@ -164,10 +185,10 @@ public class NewAPI {
/** /**
* Force a player to register * Force a player to register
* *
* @param Player
* player
* @param String * @param player * player
* password * @param password String
*/ */
public void forceRegister(Player player, String password) public void forceRegister(Player player, String password)
{ {
@ -177,8 +198,8 @@ public class NewAPI {
/** /**
* Force a player to unregister * Force a player to unregister
* *
* @param Player
* player * @param player * player
*/ */
public void forceUnregister(Player player) public void forceUnregister(Player player)
{ {

View File

@ -3,6 +3,8 @@ package fr.xephi.authme.cache.auth;
import fr.xephi.authme.security.HashAlgorithm; import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
/**
*/
public class PlayerAuth { public class PlayerAuth {
private String nickname; private String nickname;
@ -18,38 +20,132 @@ public class PlayerAuth {
private String email; private String email;
private String realName; private String realName;
/**
* Constructor for PlayerAuth.
* @param nickname String
* @param ip String
* @param lastLogin long
* @param realName String
*/
public PlayerAuth(String nickname, String ip, long lastLogin, String realName) { public PlayerAuth(String nickname, String ip, long lastLogin, String realName) {
this(nickname, "", "", -1, ip, lastLogin, 0, 0, 0, "world", "your@email.com", realName); this(nickname, "", "", -1, ip, lastLogin, 0, 0, 0, "world", "your@email.com", realName);
} }
/**
* Constructor for PlayerAuth.
* @param nickname String
* @param x double
* @param y double
* @param z double
* @param world String
* @param realName String
*/
public PlayerAuth(String nickname, double x, double y, double z, String world, String realName) { public PlayerAuth(String nickname, double x, double y, double z, String world, String realName) {
this(nickname, "", "", -1, "127.0.0.1", System.currentTimeMillis(), x, y, z, world, "your@email.com", realName); this(nickname, "", "", -1, "127.0.0.1", System.currentTimeMillis(), x, y, z, world, "your@email.com", realName);
} }
/**
* Constructor for PlayerAuth.
* @param nickname String
* @param hash String
* @param ip String
* @param lastLogin long
* @param realName String
*/
public PlayerAuth(String nickname, String hash, String ip, long lastLogin, String realName) { public PlayerAuth(String nickname, String hash, String ip, long lastLogin, String realName) {
this(nickname, hash, "", -1, ip, lastLogin, 0, 0, 0, "world", "your@email.com", realName); this(nickname, hash, "", -1, ip, lastLogin, 0, 0, 0, "world", "your@email.com", realName);
} }
/**
* Constructor for PlayerAuth.
* @param nickname String
* @param hash String
* @param ip String
* @param lastLogin long
* @param email String
* @param realName String
*/
public PlayerAuth(String nickname, String hash, String ip, long lastLogin, String email, String realName) { public PlayerAuth(String nickname, String hash, String ip, long lastLogin, String email, String realName) {
this(nickname, hash, "", -1, ip, lastLogin, 0, 0, 0, "world", email, realName); this(nickname, hash, "", -1, ip, lastLogin, 0, 0, 0, "world", email, realName);
} }
/**
* Constructor for PlayerAuth.
* @param nickname String
* @param hash String
* @param salt String
* @param ip String
* @param lastLogin long
* @param realName String
*/
public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin, String realName) { public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin, String realName) {
this(nickname, hash, salt, -1, ip, lastLogin, 0, 0, 0, "world", "your@email.com", realName); this(nickname, hash, salt, -1, ip, lastLogin, 0, 0, 0, "world", "your@email.com", realName);
} }
/**
* Constructor for PlayerAuth.
* @param nickname String
* @param hash String
* @param ip String
* @param lastLogin long
* @param x double
* @param y double
* @param z double
* @param world String
* @param email String
* @param realName String
*/
public PlayerAuth(String nickname, String hash, String ip, long lastLogin, double x, double y, double z, String world, String email, String realName) { public PlayerAuth(String nickname, String hash, String ip, long lastLogin, double x, double y, double z, String world, String email, String realName) {
this(nickname, hash, "", -1, ip, lastLogin, x, y, z, world, email, realName); this(nickname, hash, "", -1, ip, lastLogin, x, y, z, world, email, realName);
} }
/**
* Constructor for PlayerAuth.
* @param nickname String
* @param hash String
* @param salt String
* @param ip String
* @param lastLogin long
* @param x double
* @param y double
* @param z double
* @param world String
* @param email String
* @param realName String
*/
public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin, double x, double y, double z, String world, String email, String realName) { public PlayerAuth(String nickname, String hash, String salt, String ip, long lastLogin, double x, double y, double z, String world, String email, String realName) {
this(nickname, hash, salt, -1, ip, lastLogin, x, y, z, world, email, realName); this(nickname, hash, salt, -1, ip, lastLogin, x, y, z, world, email, realName);
} }
/**
* Constructor for PlayerAuth.
* @param nickname String
* @param hash String
* @param salt String
* @param groupId int
* @param ip String
* @param lastLogin long
* @param realName String
*/
public PlayerAuth(String nickname, String hash, String salt, int groupId, String ip, long lastLogin, String realName) { public PlayerAuth(String nickname, String hash, String salt, int groupId, String ip, long lastLogin, String realName) {
this(nickname, hash, salt, groupId, ip, lastLogin, 0, 0, 0, "world", "your@email.com", realName); this(nickname, hash, salt, groupId, ip, lastLogin, 0, 0, 0, "world", "your@email.com", realName);
} }
/**
* Constructor for PlayerAuth.
* @param nickname String
* @param hash String
* @param salt String
* @param groupId int
* @param ip String
* @param lastLogin long
* @param x double
* @param y double
* @param z double
* @param world String
* @param email String
* @param realName String
*/
public PlayerAuth(String nickname, String hash, String salt, int groupId, String ip, long lastLogin, double x, double y, double z, String world, String email, String realName) { public PlayerAuth(String nickname, String hash, String salt, int groupId, String ip, long lastLogin, double x, double y, double z, String world, String email, String realName) {
this.nickname = nickname; this.nickname = nickname;
this.hash = hash; this.hash = hash;
@ -65,6 +161,10 @@ public class PlayerAuth {
this.realName = realName; this.realName = realName;
} }
/**
* Method set.
* @param auth PlayerAuth
*/
public void set(PlayerAuth auth) { public void set(PlayerAuth auth) {
this.setEmail(auth.getEmail()); this.setEmail(auth.getEmail());
this.setHash(auth.getHash()); this.setHash(auth.getHash());
@ -79,94 +179,186 @@ public class PlayerAuth {
this.setRealName(auth.getRealName()); this.setRealName(auth.getRealName());
} }
/**
* Method setName.
* @param nickname String
*/
public void setName(String nickname) { public void setName(String nickname) {
this.nickname = nickname; this.nickname = nickname;
} }
/**
* Method getNickname.
* @return String
*/
public String getNickname() { public String getNickname() {
return nickname; return nickname;
} }
/**
* Method getRealName.
* @return String
*/
public String getRealName() { public String getRealName() {
return realName; return realName;
} }
/**
* Method setRealName.
* @param realName String
*/
public void setRealName(String realName) { public void setRealName(String realName) {
this.realName = realName; this.realName = realName;
} }
/**
* Method getGroupId.
* @return int
*/
public int getGroupId() { public int getGroupId() {
return groupId; return groupId;
} }
/**
* Method setQuitLocX.
* @param d double
*/
public void setQuitLocX(double d) { public void setQuitLocX(double d) {
this.x = d; this.x = d;
} }
/**
* Method getQuitLocX.
* @return double
*/
public double getQuitLocX() { public double getQuitLocX() {
return x; return x;
} }
/**
* Method setQuitLocY.
* @param d double
*/
public void setQuitLocY(double d) { public void setQuitLocY(double d) {
this.y = d; this.y = d;
} }
/**
* Method getQuitLocY.
* @return double
*/
public double getQuitLocY() { public double getQuitLocY() {
return y; return y;
} }
/**
* Method setQuitLocZ.
* @param d double
*/
public void setQuitLocZ(double d) { public void setQuitLocZ(double d) {
this.z = d; this.z = d;
} }
/**
* Method getQuitLocZ.
* @return double
*/
public double getQuitLocZ() { public double getQuitLocZ() {
return z; return z;
} }
/**
* Method setWorld.
* @param world String
*/
public void setWorld(String world) { public void setWorld(String world) {
this.world = world; this.world = world;
} }
/**
* Method getWorld.
* @return String
*/
public String getWorld() { public String getWorld() {
return world; return world;
} }
/**
* Method setIp.
* @param ip String
*/
public void setIp(String ip) { public void setIp(String ip) {
this.ip = ip; this.ip = ip;
} }
/**
* Method getIp.
* @return String
*/
public String getIp() { public String getIp() {
return ip; return ip;
} }
/**
* Method setLastLogin.
* @param lastLogin long
*/
public void setLastLogin(long lastLogin) { public void setLastLogin(long lastLogin) {
this.lastLogin = lastLogin; this.lastLogin = lastLogin;
} }
/**
* Method getLastLogin.
* @return long
*/
public long getLastLogin() { public long getLastLogin() {
return lastLogin; return lastLogin;
} }
/**
* Method setEmail.
* @param email String
*/
public void setEmail(String email) { public void setEmail(String email) {
this.email = email; this.email = email;
} }
/**
* Method getEmail.
* @return String
*/
public String getEmail() { public String getEmail() {
return email; return email;
} }
/**
* Method setSalt.
* @param salt String
*/
public void setSalt(String salt) { public void setSalt(String salt) {
this.salt = salt; this.salt = salt;
} }
/**
* Method getSalt.
* @return String
*/
public String getSalt() { public String getSalt() {
return this.salt; return this.salt;
} }
/**
* Method setHash.
* @param hash String
*/
public void setHash(String hash) { public void setHash(String hash) {
this.hash = hash; this.hash = hash;
} }
/**
* Method getHash.
* @return String
*/
public String getHash() { public String getHash() {
if (Settings.getPasswordHash == HashAlgorithm.MD5VB) { if (Settings.getPasswordHash == HashAlgorithm.MD5VB) {
if (salt != null && !salt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.MD5VB) { if (salt != null && !salt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.MD5VB) {
@ -176,6 +368,11 @@ public class PlayerAuth {
return hash; return hash;
} }
/**
* Method equals.
* @param obj Object
* @return boolean
*/
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (!(obj instanceof PlayerAuth)) { if (!(obj instanceof PlayerAuth)) {
@ -185,6 +382,10 @@ public class PlayerAuth {
return other.getIp().equals(this.ip) && other.getNickname().equals(this.nickname); return other.getIp().equals(this.ip) && other.getNickname().equals(this.nickname);
} }
/**
* Method hashCode.
* @return int
*/
@Override @Override
public int hashCode() { public int hashCode() {
int hashCode = 7; int hashCode = 7;
@ -193,6 +394,10 @@ public class PlayerAuth {
return hashCode; return hashCode;
} }
/**
* Method toString.
* @return String
*/
@Override @Override
public String toString() { public String toString() {
return ("Player : " + nickname + " | " + realName return ("Player : " + nickname + " | " + realName

View File

@ -2,6 +2,8 @@ package fr.xephi.authme.cache.auth;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
/**
*/
public class PlayerCache { public class PlayerCache {
private volatile static PlayerCache singleton; private volatile static PlayerCache singleton;
@ -11,27 +13,53 @@ public class PlayerCache {
cache = new ConcurrentHashMap<>(); cache = new ConcurrentHashMap<>();
} }
/**
* Method addPlayer.
* @param auth PlayerAuth
*/
public void addPlayer(PlayerAuth auth) { public void addPlayer(PlayerAuth auth) {
cache.put(auth.getNickname().toLowerCase(), auth); cache.put(auth.getNickname().toLowerCase(), auth);
} }
/**
* Method updatePlayer.
* @param auth PlayerAuth
*/
public void updatePlayer(PlayerAuth auth) { public void updatePlayer(PlayerAuth auth) {
cache.remove(auth.getNickname().toLowerCase()); cache.remove(auth.getNickname().toLowerCase());
cache.put(auth.getNickname().toLowerCase(), auth); cache.put(auth.getNickname().toLowerCase(), auth);
} }
/**
* Method removePlayer.
* @param user String
*/
public void removePlayer(String user) { public void removePlayer(String user) {
cache.remove(user.toLowerCase()); cache.remove(user.toLowerCase());
} }
/**
* Method isAuthenticated.
* @param user String
* @return boolean
*/
public boolean isAuthenticated(String user) { public boolean isAuthenticated(String user) {
return cache.containsKey(user.toLowerCase()); return cache.containsKey(user.toLowerCase());
} }
/**
* Method getAuth.
* @param user String
* @return PlayerAuth
*/
public PlayerAuth getAuth(String user) { public PlayerAuth getAuth(String user) {
return cache.get(user.toLowerCase()); return cache.get(user.toLowerCase());
} }
/**
* Method getInstance.
* @return PlayerCache
*/
public static PlayerCache getInstance() { public static PlayerCache getInstance() {
if (singleton == null) { if (singleton == null) {
singleton = new PlayerCache(); singleton = new PlayerCache();
@ -39,10 +67,18 @@ public class PlayerCache {
return singleton; return singleton;
} }
/**
* Method getLogged.
* @return int
*/
public int getLogged() { public int getLogged() {
return cache.size(); return cache.size();
} }
/**
* Method getCache.
* @return ConcurrentHashMap<String,PlayerAuth>
*/
public ConcurrentHashMap<String, PlayerAuth> getCache() { public ConcurrentHashMap<String, PlayerAuth> getCache() {
return this.cache; return this.cache;
} }

View File

@ -1,25 +1,45 @@
package fr.xephi.authme.cache.backup; package fr.xephi.authme.cache.backup;
/**
*/
public class DataFileCache { public class DataFileCache {
private String group; private String group;
private boolean operator; private boolean operator;
private boolean flying; private boolean flying;
/**
* Constructor for DataFileCache.
* @param group String
* @param operator boolean
* @param flying boolean
*/
public DataFileCache(String group, boolean operator, boolean flying) { public DataFileCache(String group, boolean operator, boolean flying) {
this.group = group; this.group = group;
this.operator = operator; this.operator = operator;
this.flying = flying; this.flying = flying;
} }
/**
* Method getGroup.
* @return String
*/
public String getGroup() { public String getGroup() {
return group; return group;
} }
/**
* Method getOperator.
* @return boolean
*/
public boolean getOperator() { public boolean getOperator() {
return operator; return operator;
} }
/**
* Method isFlying.
* @return boolean
*/
public boolean isFlying() { public boolean isFlying() {
return flying; return flying;
} }

View File

@ -22,6 +22,8 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.Utils; import fr.xephi.authme.util.Utils;
/**
*/
public class JsonCache { public class JsonCache {
private final Gson gson; private final Gson gson;
@ -39,6 +41,11 @@ public class JsonCache {
.create(); .create();
} }
/**
* Method createCache.
* @param player Player
* @param playerData DataFileCache
*/
public void createCache(Player player, DataFileCache playerData) { public void createCache(Player player, DataFileCache playerData) {
if (player == null) { if (player == null) {
return; return;
@ -68,6 +75,11 @@ public class JsonCache {
} }
} }
/**
* Method readCache.
* @param player Player
* @return DataFileCache
*/
public DataFileCache readCache(Player player) { public DataFileCache readCache(Player player) {
String path; String path;
try { try {
@ -90,7 +102,16 @@ public class JsonCache {
} }
} }
/**
*/
private class PlayerDataSerializer implements JsonSerializer<DataFileCache> { private class PlayerDataSerializer implements JsonSerializer<DataFileCache> {
/**
* Method serialize.
* @param dataFileCache DataFileCache
* @param type Type
* @param jsonSerializationContext JsonSerializationContext
* @return JsonElement
*/
@Override @Override
public JsonElement serialize(DataFileCache dataFileCache, Type type, JsonSerializationContext jsonSerializationContext) { public JsonElement serialize(DataFileCache dataFileCache, Type type, JsonSerializationContext jsonSerializationContext) {
JsonObject jsonObject = new JsonObject(); JsonObject jsonObject = new JsonObject();
@ -102,7 +123,18 @@ public class JsonCache {
} }
} }
/**
*/
private static class PlayerDataDeserializer implements JsonDeserializer<DataFileCache> { private static class PlayerDataDeserializer implements JsonDeserializer<DataFileCache> {
/**
* Method deserialize.
* @param jsonElement JsonElement
* @param type Type
* @param jsonDeserializationContext JsonDeserializationContext
* @return DataFileCache
* @throws JsonParseException
* @see com.google.gson.JsonDeserializer#deserialize(JsonElement, Type, JsonDeserializationContext)
*/
@Override @Override
public DataFileCache deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException { public DataFileCache deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
JsonObject jsonObject = jsonElement.getAsJsonObject(); JsonObject jsonObject = jsonElement.getAsJsonObject();
@ -128,6 +160,10 @@ public class JsonCache {
} }
} }
/**
* Method removeCache.
* @param player Player
*/
public void removeCache(Player player) { public void removeCache(Player player) {
String path; String path;
try { try {
@ -144,6 +180,11 @@ public class JsonCache {
} }
} }
/**
* Method doesCacheExist.
* @param player Player
* @return boolean
*/
public boolean doesCacheExist(Player player) { public boolean doesCacheExist(Player player) {
String path; String path;
try { try {

View File

@ -14,6 +14,8 @@ import fr.xephi.authme.cache.backup.JsonCache;
import fr.xephi.authme.events.ResetInventoryEvent; import fr.xephi.authme.events.ResetInventoryEvent;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
/**
*/
public class LimboCache { public class LimboCache {
private volatile static LimboCache singleton; private volatile static LimboCache singleton;
@ -21,12 +23,20 @@ public class LimboCache {
private JsonCache playerData; private JsonCache playerData;
public AuthMe plugin; public AuthMe plugin;
/**
* Constructor for LimboCache.
* @param plugin AuthMe
*/
private LimboCache(AuthMe plugin) { private LimboCache(AuthMe plugin) {
this.plugin = plugin; this.plugin = plugin;
this.cache = new ConcurrentHashMap<>(); this.cache = new ConcurrentHashMap<>();
this.playerData = new JsonCache(); this.playerData = new JsonCache();
} }
/**
* Method addLimboPlayer.
* @param player Player
*/
public void addLimboPlayer(Player player) { public void addLimboPlayer(Player player) {
String name = player.getName().toLowerCase(); String name = player.getName().toLowerCase();
Location loc = player.getLocation(); Location loc = player.getLocation();
@ -75,22 +85,45 @@ public class LimboCache {
cache.put(name, new LimboPlayer(name, loc, gameMode, operator, playerGroup, flying)); cache.put(name, new LimboPlayer(name, loc, gameMode, operator, playerGroup, flying));
} }
/**
* Method addLimboPlayer.
* @param player Player
* @param group String
*/
public void addLimboPlayer(Player player, String group) { public void addLimboPlayer(Player player, String group) {
cache.put(player.getName().toLowerCase(), new LimboPlayer(player.getName().toLowerCase(), group)); cache.put(player.getName().toLowerCase(), new LimboPlayer(player.getName().toLowerCase(), group));
} }
/**
* Method deleteLimboPlayer.
* @param name String
*/
public void deleteLimboPlayer(String name) { public void deleteLimboPlayer(String name) {
cache.remove(name); cache.remove(name);
} }
/**
* Method getLimboPlayer.
* @param name String
* @return LimboPlayer
*/
public LimboPlayer getLimboPlayer(String name) { public LimboPlayer getLimboPlayer(String name) {
return cache.get(name); return cache.get(name);
} }
/**
* Method hasLimboPlayer.
* @param name String
* @return boolean
*/
public boolean hasLimboPlayer(String name) { public boolean hasLimboPlayer(String name) {
return cache.containsKey(name); return cache.containsKey(name);
} }
/**
* Method getInstance.
* @return LimboCache
*/
public static LimboCache getInstance() { public static LimboCache getInstance() {
if (singleton == null) { if (singleton == null) {
singleton = new LimboCache(AuthMe.getInstance()); singleton = new LimboCache(AuthMe.getInstance());
@ -98,6 +131,10 @@ public class LimboCache {
return singleton; return singleton;
} }
/**
* Method updateLimboPlayer.
* @param player Player
*/
public void updateLimboPlayer(Player player) { public void updateLimboPlayer(Player player) {
if (this.hasLimboPlayer(player.getName().toLowerCase())) { if (this.hasLimboPlayer(player.getName().toLowerCase())) {
this.deleteLimboPlayer(player.getName().toLowerCase()); this.deleteLimboPlayer(player.getName().toLowerCase());

View File

@ -4,6 +4,8 @@ import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
/**
*/
public class LimboPlayer { public class LimboPlayer {
private String name; private String name;
@ -15,6 +17,15 @@ public class LimboPlayer {
private String group = ""; private String group = "";
private boolean flying = false; private boolean flying = false;
/**
* Constructor for LimboPlayer.
* @param name String
* @param loc Location
* @param gameMode GameMode
* @param operator boolean
* @param group String
* @param flying boolean
*/
public LimboPlayer(String name, Location loc, GameMode gameMode, public LimboPlayer(String name, Location loc, GameMode gameMode,
boolean operator, String group, boolean flying) { boolean operator, String group, boolean flying) {
this.name = name; this.name = name;
@ -25,51 +36,96 @@ public class LimboPlayer {
this.flying = flying; this.flying = flying;
} }
/**
* Constructor for LimboPlayer.
* @param name String
* @param group String
*/
public LimboPlayer(String name, String group) { public LimboPlayer(String name, String group) {
this.name = name; this.name = name;
this.group = group; this.group = group;
} }
/**
* Method getName.
* @return String
*/
public String getName() { public String getName() {
return name; return name;
} }
/**
* Method getLoc.
* @return Location
*/
public Location getLoc() { public Location getLoc() {
return loc; return loc;
} }
/**
* Method getGameMode.
* @return GameMode
*/
public GameMode getGameMode() { public GameMode getGameMode() {
return gameMode; return gameMode;
} }
/**
* Method getOperator.
* @return boolean
*/
public boolean getOperator() { public boolean getOperator() {
return operator; return operator;
} }
/**
* Method getGroup.
* @return String
*/
public String getGroup() { public String getGroup() {
return group; return group;
} }
/**
* Method setTimeoutTaskId.
* @param i BukkitTask
*/
public void setTimeoutTaskId(BukkitTask i) { public void setTimeoutTaskId(BukkitTask i) {
if (this.timeoutTaskId != null) if (this.timeoutTaskId != null)
this.timeoutTaskId.cancel(); this.timeoutTaskId.cancel();
this.timeoutTaskId = i; this.timeoutTaskId = i;
} }
/**
* Method getTimeoutTaskId.
* @return BukkitTask
*/
public BukkitTask getTimeoutTaskId() { public BukkitTask getTimeoutTaskId() {
return timeoutTaskId; return timeoutTaskId;
} }
/**
* Method setMessageTaskId.
* @param messageTaskId BukkitTask
*/
public void setMessageTaskId(BukkitTask messageTaskId) { public void setMessageTaskId(BukkitTask messageTaskId) {
if (this.messageTaskId != null) if (this.messageTaskId != null)
this.messageTaskId.cancel(); this.messageTaskId.cancel();
this.messageTaskId = messageTaskId; this.messageTaskId = messageTaskId;
} }
/**
* Method getMessageTaskId.
* @return BukkitTask
*/
public BukkitTask getMessageTaskId() { public BukkitTask getMessageTaskId() {
return messageTaskId; return messageTaskId;
} }
/**
* Method isFlying.
* @return boolean
*/
public boolean isFlying() { public boolean isFlying() {
return flying; return flying;
} }

View File

@ -1,5 +1,7 @@
package fr.xephi.authme.command; package fr.xephi.authme.command;
/**
*/
public class CommandArgumentDescription { public class CommandArgumentDescription {
// TODO: Allow argument to consist of infinite parts. <label ...> // TODO: Allow argument to consist of infinite parts. <label ...>
@ -37,8 +39,8 @@ public class CommandArgumentDescription {
/** /**
* Get the argument label. * Get the argument label.
* *
* @return Argument label.
*/ * @return Argument label. */
public String getLabel() { public String getLabel() {
return this.label; return this.label;
} }
@ -55,8 +57,8 @@ public class CommandArgumentDescription {
/** /**
* Get the argument description. * Get the argument description.
* *
* @return Argument description.
*/ * @return Argument description. */
public String getDescription() { public String getDescription() {
return description; return description;
} }
@ -73,8 +75,8 @@ public class CommandArgumentDescription {
/** /**
* Check whether the argument is optional. * Check whether the argument is optional.
* *
* @return True if the argument is optional, false otherwise.
*/ * @return True if the argument is optional, false otherwise. */
public boolean isOptional() { public boolean isOptional() {
return optional; return optional;
} }

View File

@ -9,6 +9,8 @@ import org.bukkit.command.CommandSender;
import fr.xephi.authme.util.StringUtils; import fr.xephi.authme.util.StringUtils;
/**
*/
public class CommandDescription { public class CommandDescription {
/** Defines the acceptable labels. */ /** Defines the acceptable labels. */
@ -97,8 +99,8 @@ public class CommandDescription {
/** /**
* Get the first relative command label. * Get the first relative command label.
* *
* @return First relative command label.
*/ * @return First relative command label. */
public String getLabel() { public String getLabel() {
// Ensure there's any item in the command list // Ensure there's any item in the command list
if(this.labels.size() == 0) if(this.labels.size() == 0)
@ -113,8 +115,8 @@ public class CommandDescription {
* *
* @param reference The command reference. * @param reference The command reference.
* *
* @return The most similar label, or the first label. An empty label will be returned if no label was set.
*/ * @return The most similar label, or the first label. An empty label will be returned if no label was set. */
public String getLabel(CommandParts reference) { public String getLabel(CommandParts reference) {
// Ensure there's any item in the command list // Ensure there's any item in the command list
if(this.labels.size() == 0) if(this.labels.size() == 0)
@ -145,8 +147,8 @@ public class CommandDescription {
/** /**
* Get all relative command labels. * Get all relative command labels.
* *
* @return All relative labels labels.
*/ * @return All relative labels labels. */
public List<String> getLabels() { public List<String> getLabels() {
return this.labels; return this.labels;
} }
@ -181,8 +183,8 @@ public class CommandDescription {
* @param overwrite True to replace all old command labels, false to append this command label to the currently * @param overwrite True to replace all old command labels, false to append this command label to the currently
* existing labels. * existing labels.
* *
* @return Trie if the command label is added, or if it was added already. False on failure.
*/ * @return Trie if the command label is added, or if it was added already. False on failure. */
public boolean setLabel(String commandLabel, boolean overwrite) { public boolean setLabel(String commandLabel, boolean overwrite) {
// Check whether this new command should overwrite the previous ones // Check whether this new command should overwrite the previous ones
if(!overwrite) if(!overwrite)
@ -198,8 +200,8 @@ public class CommandDescription {
* *
* @param commandLabel Command label to add. * @param commandLabel Command label to add.
* *
* @return True if the label was added, or if it was added already. False on error.
*/ * @return True if the label was added, or if it was added already. False on error. */
public boolean addLabel(String commandLabel) { public boolean addLabel(String commandLabel) {
// Verify the label // Verify the label
if(!isValidLabel(commandLabel)) if(!isValidLabel(commandLabel))
@ -218,8 +220,8 @@ public class CommandDescription {
* *
* @param commandLabels List of command labels to add. * @param commandLabels List of command labels to add.
* *
* @return True if succeed, false on failure.
*/ * @return True if succeed, false on failure. */
public boolean addLabels(List<String> commandLabels) { public boolean addLabels(List<String> commandLabels) {
// Add each command label separately // Add each command label separately
for(String cmd : commandLabels) for(String cmd : commandLabels)
@ -233,8 +235,8 @@ public class CommandDescription {
* *
* @param commandLabel Command to check for. * @param commandLabel Command to check for.
* *
* @return True if this command label equals to the param command.
*/ * @return True if this command label equals to the param command. */
public boolean hasLabel(String commandLabel) { public boolean hasLabel(String commandLabel) {
// Check whether any command matches with the argument // Check whether any command matches with the argument
for(String entry : this.labels) for(String entry : this.labels)
@ -248,8 +250,8 @@ public class CommandDescription {
/** /**
* Check whether this command description has a list of labels * Check whether this command description has a list of labels
* @param commandLabels List of labels * @param commandLabels List of labels
* @return True if all labels match, false otherwise
*/ * @return True if all labels match, false otherwise */
public boolean hasLabels(List<String> commandLabels) { public boolean hasLabels(List<String> commandLabels) {
// Check if there's a match for every command // Check if there's a match for every command
for(String cmd : commandLabels) for(String cmd : commandLabels)
@ -266,8 +268,8 @@ public class CommandDescription {
* *
* @param commandReference The command reference. * @param commandReference The command reference.
* *
* @return True if the command reference is suitable to this command label, false otherwise.
*/ * @return True if the command reference is suitable to this command label, false otherwise. */
public boolean isSuitableLabel(CommandParts commandReference) { public boolean isSuitableLabel(CommandParts commandReference) {
// Make sure the command reference is valid // Make sure the command reference is valid
if(commandReference.getCount() <= 0) if(commandReference.getCount() <= 0)
@ -285,8 +287,8 @@ public class CommandDescription {
* *
* @param label The label to test. * @param label The label to test.
* *
* @return True if the label is valid to use, false otherwise.
*/ * @return True if the label is valid to use, false otherwise. */
public static boolean isValidLabel(String label) { public static boolean isValidLabel(String label) {
// Make sure the label isn't null // Make sure the label isn't null
if(label == null) if(label == null)
@ -305,6 +307,7 @@ public class CommandDescription {
/** /**
* Get the absolute command label, without a slash. * Get the absolute command label, without a slash.
* @return String
*/ */
public String getAbsoluteLabel() { public String getAbsoluteLabel() {
return getAbsoluteLabel(false); return getAbsoluteLabel(false);
@ -313,8 +316,9 @@ public class CommandDescription {
/** /**
* Get the absolute command label. * Get the absolute command label.
* *
* @return Absolute command label.
*/ * @param includeSlash boolean
* @return Absolute command label. */
public String getAbsoluteLabel(boolean includeSlash) { public String getAbsoluteLabel(boolean includeSlash) {
return getAbsoluteLabel(includeSlash, null); return getAbsoluteLabel(includeSlash, null);
} }
@ -322,8 +326,10 @@ public class CommandDescription {
/** /**
* Get the absolute command label. * Get the absolute command label.
* *
* @return Absolute command label.
*/ * @param includeSlash boolean
* @param reference CommandParts
* @return Absolute command label. */
public String getAbsoluteLabel(boolean includeSlash, CommandParts reference) { public String getAbsoluteLabel(boolean includeSlash, CommandParts reference) {
// Get the command reference, and make sure it is valid // Get the command reference, and make sure it is valid
CommandParts out = getCommandReference(reference); CommandParts out = getCommandReference(reference);
@ -339,8 +345,8 @@ public class CommandDescription {
* *
* @param reference The reference to use as template, which is used to choose the most similar reference. * @param reference The reference to use as template, which is used to choose the most similar reference.
* *
* @return Command reference.
*/ * @return Command reference. */
public CommandParts getCommandReference(CommandParts reference) { public CommandParts getCommandReference(CommandParts reference) {
// Build the reference // Build the reference
List<String> referenceList = new ArrayList<>(); List<String> referenceList = new ArrayList<>();
@ -361,8 +367,8 @@ public class CommandDescription {
* *
* @param other The other command reference. * @param other The other command reference.
* *
* @return The command difference. Zero if there's no difference. A negative number on error.
*/ * @return The command difference. Zero if there's no difference. A negative number on error. */
public double getCommandDifference(CommandParts other) { public double getCommandDifference(CommandParts other) {
return getCommandDifference(other, false); return getCommandDifference(other, false);
} }
@ -373,8 +379,8 @@ public class CommandDescription {
* @param other The other command reference. * @param other The other command reference.
* @param fullCompare True to fully compare both command references. * @param fullCompare True to fully compare both command references.
* *
* @return The command difference. Zero if there's no difference. A negative number on error.
*/ * @return The command difference. Zero if there's no difference. A negative number on error. */
public double getCommandDifference(CommandParts other, boolean fullCompare) { public double getCommandDifference(CommandParts other, boolean fullCompare) {
// Make sure the reference is valid // Make sure the reference is valid
if(other == null) if(other == null)
@ -390,8 +396,8 @@ public class CommandDescription {
/** /**
* Get the executable command. * Get the executable command.
* *
* @return The executable command.
*/ * @return The executable command. */
public ExecutableCommand getExecutableCommand() { public ExecutableCommand getExecutableCommand() {
return this.executableCommand; return this.executableCommand;
} }
@ -408,8 +414,8 @@ public class CommandDescription {
/** /**
* Check whether this command is executable, based on the assigned executable command. * Check whether this command is executable, based on the assigned executable command.
* *
* @return True if this command is executable.
*/ * @return True if this command is executable. */
public boolean isExecutable() { public boolean isExecutable() {
return this.executableCommand != null; return this.executableCommand != null;
} }
@ -421,8 +427,8 @@ public class CommandDescription {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True on success, false on failure.
*/ * @return True on success, false on failure. */
public boolean execute(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean execute(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Make sure the command is executable // Make sure the command is executable
if(!isExecutable()) if(!isExecutable())
@ -435,8 +441,8 @@ public class CommandDescription {
/** /**
* Get the parent command if this command description has a parent. * Get the parent command if this command description has a parent.
* *
* @return Parent command, or null
*/ * @return Parent command, or null */
public CommandDescription getParent() { public CommandDescription getParent() {
return this.parent; return this.parent;
} }
@ -444,8 +450,8 @@ public class CommandDescription {
/** /**
* Get the number of parent this description has. * Get the number of parent this description has.
* *
* @return The number of parents.
*/ * @return The number of parents. */
public int getParentCount() { public int getParentCount() {
// Check whether the this description has a parent // Check whether the this description has a parent
if(!hasParent()) if(!hasParent())
@ -460,8 +466,8 @@ public class CommandDescription {
* *
* @param parent Parent command. * @param parent Parent command.
* *
* @return True on success, false on failure.
*/ * @return True on success, false on failure. */
public boolean setParent(CommandDescription parent) { public boolean setParent(CommandDescription parent) {
// Make sure the parent is different // Make sure the parent is different
if(this.parent == parent) if(this.parent == parent)
@ -481,8 +487,8 @@ public class CommandDescription {
/** /**
* Check whether the plugin description has a parent command. * Check whether the plugin description has a parent command.
* *
* @return True if the description has a parent command, false otherwise.
*/ * @return True if the description has a parent command, false otherwise. */
public boolean hasParent() { public boolean hasParent() {
return this.parent != null; return this.parent != null;
} }
@ -490,8 +496,8 @@ public class CommandDescription {
/** /**
* Get all command children. * Get all command children.
* *
* @return Command children.
*/ * @return Command children. */
public List<CommandDescription> getChildren() { public List<CommandDescription> getChildren() {
return this.children; return this.children;
} }
@ -501,8 +507,8 @@ public class CommandDescription {
* *
* @param commandDescription The child to add. * @param commandDescription The child to add.
* *
* @return True on success, false on failure.
*/ * @return True on success, false on failure. */
public boolean addChild(CommandDescription commandDescription) { public boolean addChild(CommandDescription commandDescription) {
// Make sure the description is valid // Make sure the description is valid
if(commandDescription == null) if(commandDescription == null)
@ -539,8 +545,8 @@ public class CommandDescription {
/** /**
* Check whether this command has any child labels. * Check whether this command has any child labels.
* *
* @return True if this command has any child labels.
*/ * @return True if this command has any child labels. */
public boolean hasChilds() { public boolean hasChilds() {
return (this.children.size() != 0); return (this.children.size() != 0);
} }
@ -550,8 +556,8 @@ public class CommandDescription {
* *
* @param commandDescription The command description to check for. * @param commandDescription The command description to check for.
* *
* @return True if this command description has the specific child, false otherwise.
*/ * @return True if this command description has the specific child, false otherwise. */
public boolean isChild(CommandDescription commandDescription) { public boolean isChild(CommandDescription commandDescription) {
// Make sure the description is valid // Make sure the description is valid
if(commandDescription == null) if(commandDescription == null)
@ -568,8 +574,8 @@ public class CommandDescription {
* *
* @param argument The argument to add. * @param argument The argument to add.
* *
* @return True if succeed, false if failed.
*/ * @return True if succeed, false if failed. */
public boolean addArgument(CommandArgumentDescription argument) { public boolean addArgument(CommandArgumentDescription argument) {
// Make sure the argument is valid // Make sure the argument is valid
if(argument == null) if(argument == null)
@ -586,8 +592,8 @@ public class CommandDescription {
/** /**
* Get all command arguments. * Get all command arguments.
* *
* @return Command arguments.
*/ * @return Command arguments. */
public List<CommandArgumentDescription> getArguments() { public List<CommandArgumentDescription> getArguments() {
return this.arguments; return this.arguments;
} }
@ -611,8 +617,8 @@ public class CommandDescription {
* *
* @param argument The argument to check for. * @param argument The argument to check for.
* *
* @return True if this argument already exists, false otherwise.
*/ * @return True if this argument already exists, false otherwise. */
public boolean hasArgument(CommandArgumentDescription argument) { public boolean hasArgument(CommandArgumentDescription argument) {
// Make sure the argument is valid // Make sure the argument is valid
if(argument == null) if(argument == null)
@ -625,8 +631,8 @@ public class CommandDescription {
/** /**
* Check whether this command has any arguments. * Check whether this command has any arguments.
* *
* @return True if this command has any arguments.
*/ * @return True if this command has any arguments. */
public boolean hasArguments() { public boolean hasArguments() {
return (this.arguments.size() != 0); return (this.arguments.size() != 0);
} }
@ -634,8 +640,8 @@ public class CommandDescription {
/** /**
* The minimum number of arguments required for this command. * The minimum number of arguments required for this command.
* *
* @return The minimum number of required arguments.
*/ * @return The minimum number of required arguments. */
public int getMinimumArguments() { public int getMinimumArguments() {
// Get the number of required and optional arguments // Get the number of required and optional arguments
int requiredArguments = 0; int requiredArguments = 0;
@ -659,8 +665,8 @@ public class CommandDescription {
/** /**
* Get the maximum number of arguments. * Get the maximum number of arguments.
* *
* @return The maximum number of arguments. A negative number will be returned if there's no maximum.
*/ * @return The maximum number of arguments. A negative number will be returned if there's no maximum. */
public int getMaximumArguments() { public int getMaximumArguments() {
// Check whether there is a maximum set // Check whether there is a maximum set
if(this.noArgumentMaximum) if(this.noArgumentMaximum)
@ -682,8 +688,8 @@ public class CommandDescription {
/** /**
* Get the command description. * Get the command description.
* *
* @return Command description.
*/ * @return Command description. */
public String getDescription() { public String getDescription() {
return hasDescription() ? this.description : this.detailedDescription; return hasDescription() ? this.description : this.detailedDescription;
} }
@ -704,8 +710,8 @@ public class CommandDescription {
/** /**
* Check whether this command has any description. * Check whether this command has any description.
* *
* @return True if this command has any description.
*/ * @return True if this command has any description. */
public boolean hasDescription() { public boolean hasDescription() {
return (this.description.trim().length() != 0); return (this.description.trim().length() != 0);
} }
@ -713,8 +719,8 @@ public class CommandDescription {
/** /**
* Get the command detailed description. * Get the command detailed description.
* *
* @return Command detailed description.
*/ * @return Command detailed description. */
public String getDetailedDescription() { public String getDetailedDescription() {
return hasDetailedDescription() ? this.detailedDescription : this.description; return hasDetailedDescription() ? this.detailedDescription : this.description;
} }
@ -735,8 +741,8 @@ public class CommandDescription {
/** /**
* Check whether this command has any detailed description. * Check whether this command has any detailed description.
* *
* @return True if this command has any detailed description.
*/ * @return True if this command has any detailed description. */
public boolean hasDetailedDescription() { public boolean hasDetailedDescription() {
return (this.detailedDescription.trim().length() != 0); return (this.detailedDescription.trim().length() != 0);
} }
@ -746,8 +752,8 @@ public class CommandDescription {
* *
* @param queryReference The query reference to find a command for. * @param queryReference The query reference to find a command for.
* *
* @return The command found, or null.
*/ * @return The command found, or null. */
public FoundCommandResult findCommand(final CommandParts queryReference) { public FoundCommandResult findCommand(final CommandParts queryReference) {
// Make sure the command reference is valid // Make sure the command reference is valid
if(queryReference.getCount() <= 0) if(queryReference.getCount() <= 0)
@ -808,8 +814,8 @@ public class CommandDescription {
* *
* @param commandReference The command reference. * @param commandReference The command reference.
* *
* @return True if so, false otherwise.
*/ * @return True if so, false otherwise. */
public boolean hasSuitableCommand(CommandParts commandReference) { public boolean hasSuitableCommand(CommandParts commandReference) {
return findCommand(commandReference) != null; return findCommand(commandReference) != null;
} }
@ -819,8 +825,8 @@ public class CommandDescription {
* *
* @param commandReference The command reference. * @param commandReference The command reference.
* *
* @return True if the arguments are suitable, false otherwise.
*/ * @return True if the arguments are suitable, false otherwise. */
public boolean hasSuitableArguments(CommandParts commandReference) { public boolean hasSuitableArguments(CommandParts commandReference) {
return getSuitableArgumentsDifference(commandReference) == 0; return getSuitableArgumentsDifference(commandReference) == 0;
} }
@ -831,8 +837,8 @@ public class CommandDescription {
* *
* @param commandReference The command reference. * @param commandReference The command reference.
* *
* @return The difference in argument count between the reference and the actual command.
*/ * @return The difference in argument count between the reference and the actual command. */
public int getSuitableArgumentsDifference(CommandParts commandReference) { public int getSuitableArgumentsDifference(CommandParts commandReference) {
// Make sure the command reference is valid // Make sure the command reference is valid
if(commandReference.getCount() <= 0) if(commandReference.getCount() <= 0)
@ -856,8 +862,8 @@ public class CommandDescription {
/** /**
* Get the command permissions. * Get the command permissions.
* *
* @return The command permissions.
*/ * @return The command permissions. */
public CommandPermissions getCommandPermissions() { public CommandPermissions getCommandPermissions() {
return this.permissions; return this.permissions;
} }
@ -887,8 +893,8 @@ public class CommandDescription {
* @param commandLabel The first command label. * @param commandLabel The first command label.
* @param otherCommandLabel The other command label. * @param otherCommandLabel The other command label.
* *
* @return True if the labels are equal to each other.
*/ * @return True if the labels are equal to each other. */
private static boolean commandLabelEquals(String commandLabel, String otherCommandLabel) { private static boolean commandLabelEquals(String commandLabel, String otherCommandLabel) {
// Trim the command labels from unwanted whitespaces // Trim the command labels from unwanted whitespaces
commandLabel = commandLabel.trim(); commandLabel = commandLabel.trim();
@ -901,8 +907,8 @@ public class CommandDescription {
/** /**
* Check whether the command description has been set up properly. * Check whether the command description has been set up properly.
* *
* @return True if the command description is valid, false otherwise.
*/ * @return True if the command description is valid, false otherwise. */
public boolean isValid() { public boolean isValid() {
// Make sure any command label is set // Make sure any command label is set
if(getLabels().size() == 0) if(getLabels().size() == 0)

View File

@ -10,6 +10,8 @@ import org.bukkit.command.CommandSender;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.command.help.HelpProvider; import fr.xephi.authme.command.help.HelpProvider;
/**
*/
public class CommandHandler { public class CommandHandler {
/** The command manager instance. */ /** The command manager instance. */
@ -29,9 +31,9 @@ public class CommandHandler {
/** /**
* Initialize the command handler. * Initialize the command handler.
* *
* @return True if succeed, false on failure. True will also be returned if the command handler was already * @return True if succeed, false on failure. True will also be returned if the command handler was already
* initialized. * initialized. */
*/
public boolean init() { public boolean init() {
// Make sure the handler isn't initialized already // Make sure the handler isn't initialized already
if(isInit()) if(isInit())
@ -48,8 +50,8 @@ public class CommandHandler {
/** /**
* Check whether the command handler is initialized. * Check whether the command handler is initialized.
* *
* @return True if the command handler is initialized.
*/ * @return True if the command handler is initialized. */
public boolean isInit() { public boolean isInit() {
return this.commandManager != null; return this.commandManager != null;
} }
@ -57,9 +59,9 @@ public class CommandHandler {
/** /**
* Destroy the command handler. * Destroy the command handler.
* *
* @return True if the command handler was destroyed successfully, false otherwise. True will also be returned if * @return True if the command handler was destroyed successfully, false otherwise. True will also be returned if
* the command handler wasn't initialized. * the command handler wasn't initialized. */
*/
public boolean destroy() { public boolean destroy() {
// Make sure the command handler is initialized // Make sure the command handler is initialized
if(!isInit()) if(!isInit())
@ -73,8 +75,8 @@ public class CommandHandler {
/** /**
* Get the command manager. * Get the command manager.
* *
* @return Command manager instance.
*/ * @return Command manager instance. */
public CommandManager getCommandManager() { public CommandManager getCommandManager() {
return this.commandManager; return this.commandManager;
} }
@ -87,8 +89,8 @@ public class CommandHandler {
* @param bukkitCommandLabel The command label (Bukkit). * @param bukkitCommandLabel The command label (Bukkit).
* @param bukkitArgs The command arguments (Bukkit). * @param bukkitArgs The command arguments (Bukkit).
* *
* @return True if the command was executed, false otherwise.
*/ * @return True if the command was executed, false otherwise. */
public boolean onCommand(CommandSender sender, org.bukkit.command.Command bukkitCommand, String bukkitCommandLabel, String[] bukkitArgs) { public boolean onCommand(CommandSender sender, org.bukkit.command.Command bukkitCommand, String bukkitCommandLabel, String[] bukkitArgs) {
// Process the arguments // Process the arguments
List<String> args = processArguments(bukkitArgs); List<String> args = processArguments(bukkitArgs);
@ -180,8 +182,8 @@ public class CommandHandler {
* *
* @param args The command arguments to process. * @param args The command arguments to process.
* *
* @return The processed command arguments.
*/ * @return The processed command arguments. */
private List<String> processArguments(String[] args) { private List<String> processArguments(String[] args) {
// Convert the array into a list of arguments // Convert the array into a list of arguments
List<String> arguments = new ArrayList<>(Arrays.asList(args)); List<String> arguments = new ArrayList<>(Arrays.asList(args));

View File

@ -32,6 +32,8 @@ import fr.xephi.authme.command.executable.email.RecoverEmailCommand;
import fr.xephi.authme.command.executable.login.LoginCommand; import fr.xephi.authme.command.executable.login.LoginCommand;
import fr.xephi.authme.command.executable.logout.LogoutCommand; import fr.xephi.authme.command.executable.logout.LogoutCommand;
/**
*/
public class CommandManager { public class CommandManager {
/** The list of commandDescriptions. */ /** The list of commandDescriptions. */
@ -571,8 +573,8 @@ public class CommandManager {
/** /**
* Get the list of command descriptions * Get the list of command descriptions
* *
* @return List of command descriptions.
*/ * @return List of command descriptions. */
public List<CommandDescription> getCommandDescriptions() { public List<CommandDescription> getCommandDescriptions() {
return this.commandDescriptions; return this.commandDescriptions;
} }
@ -580,8 +582,8 @@ public class CommandManager {
/** /**
* Get the number of command description count. * Get the number of command description count.
* *
* @return Command description count.
*/ * @return Command description count. */
public int getCommandDescriptionCount() { public int getCommandDescriptionCount() {
return this.getCommandDescriptions().size(); return this.getCommandDescriptions().size();
} }
@ -592,8 +594,8 @@ public class CommandManager {
* @param queryReference * @param queryReference
* The query reference to find a command for. * The query reference to find a command for.
* *
* @return The command found, or null.
*/ * @return The command found, or null. */
public FoundCommandResult findCommand(CommandParts queryReference) { public FoundCommandResult findCommand(CommandParts queryReference) {
// Make sure the command reference is valid // Make sure the command reference is valid
if (queryReference.getCount() <= 0) if (queryReference.getCount() <= 0)

View File

@ -6,6 +6,8 @@ import java.util.List;
import fr.xephi.authme.util.ListUtils; import fr.xephi.authme.util.ListUtils;
import fr.xephi.authme.util.StringUtils; import fr.xephi.authme.util.StringUtils;
/**
*/
public class CommandParts { public class CommandParts {
/** The list of parts for this command. */ /** The list of parts for this command. */
@ -57,8 +59,8 @@ public class CommandParts {
/** /**
* Get the command parts. * Get the command parts.
* *
* @return Command parts.
*/ * @return Command parts. */
public List<String> getList() { public List<String> getList() {
return this.parts; return this.parts;
} }
@ -68,8 +70,8 @@ public class CommandParts {
* *
* @param part The part to add. * @param part The part to add.
* *
* @return The result.
*/ * @return The result. */
public boolean add(String part) { public boolean add(String part) {
return this.parts.add(part); return this.parts.add(part);
} }
@ -79,8 +81,8 @@ public class CommandParts {
* *
* @param parts The parts to add. * @param parts The parts to add.
* *
* @return The result.
*/ * @return The result. */
public boolean add(List<String> parts) { public boolean add(List<String> parts) {
return this.parts.addAll(parts); return this.parts.addAll(parts);
} }
@ -90,8 +92,8 @@ public class CommandParts {
* *
* @param parts The parts to add. * @param parts The parts to add.
* *
* @return The result.
*/ * @return The result. */
public boolean add(String[] parts) { public boolean add(String[] parts) {
for(String entry : parts) for(String entry : parts)
add(entry); add(entry);
@ -101,8 +103,8 @@ public class CommandParts {
/** /**
* Get the number of parts. * Get the number of parts.
* *
* @return Part count.
*/ * @return Part count. */
public int getCount() { public int getCount() {
return this.parts.size(); return this.parts.size();
} }
@ -112,8 +114,8 @@ public class CommandParts {
* *
* @param i Part index. * @param i Part index.
* *
* @return The part.
*/ * @return The part. */
public String get(int i) { public String get(int i) {
// Make sure the index is in-bound // Make sure the index is in-bound
if(i < 0 || i >= getCount()) if(i < 0 || i >= getCount())
@ -128,8 +130,8 @@ public class CommandParts {
* *
* @param start The starting index. * @param start The starting index.
* *
* @return The parts range. Arguments that were out of bound are not included.
*/ * @return The parts range. Arguments that were out of bound are not included. */
public List<String> getRange(int start) { public List<String> getRange(int start) {
return getRange(start, getCount() - start); return getRange(start, getCount() - start);
} }
@ -140,8 +142,8 @@ public class CommandParts {
* @param start The starting index. * @param start The starting index.
* @param count The number of parts to get. * @param count The number of parts to get.
* *
* @return The parts range. Parts that were out of bound are not included.
*/ * @return The parts range. Parts that were out of bound are not included. */
public List<String> getRange(int start, int count) { public List<String> getRange(int start, int count) {
// Create a new list to put the range into // Create a new list to put the range into
List<String> elements = new ArrayList<>(); List<String> elements = new ArrayList<>();
@ -163,8 +165,8 @@ public class CommandParts {
* *
* @param other The other reference. * @param other The other reference.
* *
* @return The result from zero to above. A negative number will be returned on error.
*/ * @return The result from zero to above. A negative number will be returned on error. */
public double getDifference(CommandParts other) { public double getDifference(CommandParts other) {
return getDifference(other, false); return getDifference(other, false);
} }
@ -175,8 +177,8 @@ public class CommandParts {
* @param other The other reference. * @param other The other reference.
* @param fullCompare True to compare the full references as far as the range reaches. * @param fullCompare True to compare the full references as far as the range reaches.
* *
* @return The result from zero to above. A negative number will be returned on error.
*/ * @return The result from zero to above. A negative number will be returned on error. */
public double getDifference(CommandParts other, boolean fullCompare) { public double getDifference(CommandParts other, boolean fullCompare) {
// Make sure the other reference is correct // Make sure the other reference is correct
if(other == null) if(other == null)
@ -194,8 +196,8 @@ public class CommandParts {
/** /**
* Convert the parts to a string. * Convert the parts to a string.
* *
* @return The part as a string.
*/ * @return The part as a string. */
@Override @Override
public String toString() { public String toString() {
return ListUtils.implode(this.parts, " "); return ListUtils.implode(this.parts, " ");

View File

@ -11,6 +11,8 @@ import org.bukkit.entity.Player;
//import com.timvisee.dungeonmaze.permission.PermissionsManager; //import com.timvisee.dungeonmaze.permission.PermissionsManager;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
/**
*/
public class CommandPermissions { public class CommandPermissions {
/** Defines the permission nodes required to have permission to execute this command. */ /** Defines the permission nodes required to have permission to execute this command. */
@ -49,8 +51,8 @@ public class CommandPermissions {
* *
* @param permissionNode The permission node to add. * @param permissionNode The permission node to add.
* *
* @return True on success, false on failure.
*/ * @return True on success, false on failure. */
public boolean addPermissionNode(String permissionNode) { public boolean addPermissionNode(String permissionNode) {
// Trim the permission node // Trim the permission node
permissionNode = permissionNode.trim(); permissionNode = permissionNode.trim();
@ -72,8 +74,8 @@ public class CommandPermissions {
* *
* @param permissionNode The permission node to check for. * @param permissionNode The permission node to check for.
* *
* @return True if this permission node is required, false if not.
*/ * @return True if this permission node is required, false if not. */
public boolean hasPermissionNode(String permissionNode) { public boolean hasPermissionNode(String permissionNode) {
return this.permissionNodes.contains(permissionNode); return this.permissionNodes.contains(permissionNode);
} }
@ -81,8 +83,8 @@ public class CommandPermissions {
/** /**
* Get the permission nodes required to execute this command. * Get the permission nodes required to execute this command.
* *
* @return The permission nodes required to execute this command.
*/ * @return The permission nodes required to execute this command. */
public List<String> getPermissionNodes() { public List<String> getPermissionNodes() {
return this.permissionNodes; return this.permissionNodes;
} }
@ -90,8 +92,8 @@ public class CommandPermissions {
/** /**
* Get the number of permission nodes set. * Get the number of permission nodes set.
* *
* @return Permission node count.
*/ * @return Permission node count. */
public int getPermissionNodeCount() { public int getPermissionNodeCount() {
return this.permissionNodes.size(); return this.permissionNodes.size();
} }
@ -108,8 +110,9 @@ public class CommandPermissions {
/** /**
* Check whether this command requires any permission to be executed. This is based on the getPermission() method. * Check whether this command requires any permission to be executed. This is based on the getPermission() method.
* *
* @return True if this command requires any permission to be executed by a player.
*/ * @param sender CommandSender
* @return True if this command requires any permission to be executed by a player. */
public boolean hasPermission(CommandSender sender) { public boolean hasPermission(CommandSender sender) {
// Make sure any permission node is set // Make sure any permission node is set
if(getPermissionNodeCount() == 0) if(getPermissionNodeCount() == 0)
@ -140,8 +143,8 @@ public class CommandPermissions {
/** /**
* Get the default permission if the permission nodes couldn't be used. * Get the default permission if the permission nodes couldn't be used.
* *
* @return The default permission.
*/ * @return The default permission. */
public DefaultPermission getDefaultPermission() { public DefaultPermission getDefaultPermission() {
return this.defaultPermission; return this.defaultPermission;
} }
@ -160,8 +163,8 @@ public class CommandPermissions {
* *
* @param sender The command sender to get the default permission for. * @param sender The command sender to get the default permission for.
* *
* @return True if the command sender has permission by default, false otherwise.
*/ * @return True if the command sender has permission by default, false otherwise. */
public boolean getDefaultPermissionCommandSender(CommandSender sender) { public boolean getDefaultPermissionCommandSender(CommandSender sender) {
switch(getDefaultPermission()) { switch(getDefaultPermission()) {
case ALLOWED: case ALLOWED:
@ -176,6 +179,8 @@ public class CommandPermissions {
} }
} }
/**
*/
public enum DefaultPermission { public enum DefaultPermission {
NOT_ALLOWED, NOT_ALLOWED,
OP_ONLY, OP_ONLY,

View File

@ -2,6 +2,8 @@ package fr.xephi.authme.command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
/**
*/
public abstract class ExecutableCommand { public abstract class ExecutableCommand {
/** /**
@ -11,7 +13,7 @@ public abstract class ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
public abstract boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments); public abstract boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments);
} }

View File

@ -2,6 +2,8 @@ package fr.xephi.authme.command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
/**
*/
public class FoundCommandResult { public class FoundCommandResult {
/** The command description instance. */ /** The command description instance. */
@ -31,8 +33,8 @@ public class FoundCommandResult {
/** /**
* Check whether the command was suitable. * Check whether the command was suitable.
* *
* @return True if the command was suitable, false otherwise.
*/ * @return True if the command was suitable, false otherwise. */
public boolean hasProperArguments() { public boolean hasProperArguments() {
// Make sure the command description is set // Make sure the command description is set
if(this.commandDescription == null) if(this.commandDescription == null)
@ -45,8 +47,8 @@ public class FoundCommandResult {
/** /**
* Get the command description. * Get the command description.
* *
* @return Command description.
*/ * @return Command description. */
public CommandDescription getCommandDescription() { public CommandDescription getCommandDescription() {
return this.commandDescription; return this.commandDescription;
} }
@ -64,8 +66,8 @@ public class FoundCommandResult {
/** /**
* Check whether the command is executable. * Check whether the command is executable.
* *
* @return True if the command is executable, false otherwise.
*/ * @return True if the command is executable, false otherwise. */
public boolean isExecutable() { public boolean isExecutable() {
// Make sure the command description is valid // Make sure the command description is valid
if(this.commandDescription == null) if(this.commandDescription == null)
@ -80,8 +82,8 @@ public class FoundCommandResult {
* *
* @param sender The command sender that executed the command. * @param sender The command sender that executed the command.
* *
* @return True on success, false on failure.
*/ * @return True on success, false on failure. */
public boolean executeCommand(CommandSender sender) { public boolean executeCommand(CommandSender sender) {
// Make sure the command description is valid // Make sure the command description is valid
if(this.commandDescription == null) if(this.commandDescription == null)
@ -96,8 +98,8 @@ public class FoundCommandResult {
* *
* @param sender The command sender. * @param sender The command sender.
* *
* @return True if the command sender has permission, false otherwise.
*/ * @return True if the command sender has permission, false otherwise. */
public boolean hasPermission(CommandSender sender) { public boolean hasPermission(CommandSender sender) {
// Make sure the command description is valid // Make sure the command description is valid
if(this.commandDescription == null) if(this.commandDescription == null)
@ -110,8 +112,8 @@ public class FoundCommandResult {
/** /**
* Get the command reference. * Get the command reference.
* *
* @return The command reference.
*/ * @return The command reference. */
public CommandParts getCommandReference() { public CommandParts getCommandReference() {
return this.commandReference; return this.commandReference;
} }
@ -119,8 +121,8 @@ public class FoundCommandResult {
/** /**
* Get the command arguments. * Get the command arguments.
* *
* @return The command arguments.
*/ * @return The command arguments. */
public CommandParts getCommandArguments() { public CommandParts getCommandArguments() {
return this.commandArguments; return this.commandArguments;
} }
@ -128,8 +130,8 @@ public class FoundCommandResult {
/** /**
* Get the original query reference. * Get the original query reference.
* *
* @return Original query reference.
*/ * @return Original query reference. */
public CommandParts getQueryReference() { public CommandParts getQueryReference() {
return this.queryReference; return this.queryReference;
} }
@ -137,8 +139,8 @@ public class FoundCommandResult {
/** /**
* Get the difference value between the original query and the result reference. * Get the difference value between the original query and the result reference.
* *
* @return The difference value.
*/ * @return The difference value. */
public double getDifference() { public double getDifference() {
// Get the difference through the command found // Get the difference through the command found
if(this.commandDescription != null) if(this.commandDescription != null)

View File

@ -6,6 +6,8 @@ import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.command.help.HelpProvider; import fr.xephi.authme.command.help.HelpProvider;
/**
*/
public class HelpCommand extends ExecutableCommand { public class HelpCommand extends ExecutableCommand {
/** /**
@ -15,8 +17,8 @@ public class HelpCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Check whether quick help should be shown // Check whether quick help should be shown

View File

@ -12,6 +12,8 @@ import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
/**
*/
public class AccountsCommand extends ExecutableCommand { public class AccountsCommand extends ExecutableCommand {
/** /**
@ -21,8 +23,8 @@ public class AccountsCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -7,6 +7,8 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
/**
*/
public class AuthMeCommand extends ExecutableCommand { public class AuthMeCommand extends ExecutableCommand {
/** /**
@ -16,8 +18,8 @@ public class AuthMeCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Show some version info // Show some version info

View File

@ -15,6 +15,8 @@ import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
/**
*/
public class ChangePasswordCommand extends ExecutableCommand { public class ChangePasswordCommand extends ExecutableCommand {
/** /**
@ -24,8 +26,8 @@ public class ChangePasswordCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -8,6 +8,8 @@ import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.settings.Spawn; import fr.xephi.authme.settings.Spawn;
/**
*/
public class FirstSpawnCommand extends ExecutableCommand { public class FirstSpawnCommand extends ExecutableCommand {
/** /**
@ -17,8 +19,8 @@ public class FirstSpawnCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Make sure the command executor is a player // Make sure the command executor is a player

View File

@ -8,6 +8,8 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
/**
*/
public class ForceLoginCommand extends ExecutableCommand { public class ForceLoginCommand extends ExecutableCommand {
/** /**
@ -17,8 +19,8 @@ public class ForceLoginCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -8,6 +8,8 @@ import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
/**
*/
public class GetEmailCommand extends ExecutableCommand { public class GetEmailCommand extends ExecutableCommand {
/** /**
@ -17,8 +19,8 @@ public class GetEmailCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -8,6 +8,8 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
/**
*/
public class GetIpCommand extends ExecutableCommand { public class GetIpCommand extends ExecutableCommand {
/** /**
@ -17,8 +19,8 @@ public class GetIpCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -10,6 +10,8 @@ import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
/**
*/
public class LastLoginCommand extends ExecutableCommand { public class LastLoginCommand extends ExecutableCommand {
/** /**
@ -19,8 +21,8 @@ public class LastLoginCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -11,6 +11,8 @@ import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
/**
*/
public class PurgeBannedPlayersCommand extends ExecutableCommand { public class PurgeBannedPlayersCommand extends ExecutableCommand {
/** /**
@ -20,8 +22,8 @@ public class PurgeBannedPlayersCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -11,6 +11,8 @@ import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
/**
*/
public class PurgeCommand extends ExecutableCommand { public class PurgeCommand extends ExecutableCommand {
/** /**
@ -20,8 +22,8 @@ public class PurgeCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -10,6 +10,8 @@ import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
/**
*/
public class PurgeLastPositionCommand extends ExecutableCommand { public class PurgeLastPositionCommand extends ExecutableCommand {
/** /**
@ -19,8 +21,8 @@ public class PurgeLastPositionCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -14,6 +14,8 @@ import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
/**
*/
public class RegisterCommand extends ExecutableCommand { public class RegisterCommand extends ExecutableCommand {
/** /**
@ -23,8 +25,8 @@ public class RegisterCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -11,6 +11,8 @@ import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.Profiler; import fr.xephi.authme.util.Profiler;
/**
*/
public class ReloadCommand extends ExecutableCommand { public class ReloadCommand extends ExecutableCommand {
/** /**
@ -20,8 +22,8 @@ public class ReloadCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Profile the reload process // Profile the reload process

View File

@ -10,6 +10,8 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
/**
*/
public class ResetNameCommand extends ExecutableCommand { public class ResetNameCommand extends ExecutableCommand {
/** /**
@ -19,8 +21,8 @@ public class ResetNameCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -10,6 +10,8 @@ import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
/**
*/
public class SetEmailCommand extends ExecutableCommand { public class SetEmailCommand extends ExecutableCommand {
/** /**
@ -19,8 +21,8 @@ public class SetEmailCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -8,6 +8,8 @@ import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.settings.Spawn; import fr.xephi.authme.settings.Spawn;
/**
*/
public class SetFirstSpawnCommand extends ExecutableCommand { public class SetFirstSpawnCommand extends ExecutableCommand {
/** /**
@ -17,8 +19,8 @@ public class SetFirstSpawnCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
try { try {

View File

@ -8,6 +8,8 @@ import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.settings.Spawn; import fr.xephi.authme.settings.Spawn;
/**
*/
public class SetSpawnCommand extends ExecutableCommand { public class SetSpawnCommand extends ExecutableCommand {
/** /**
@ -17,8 +19,8 @@ public class SetSpawnCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Make sure the command executor is a player // Make sure the command executor is a player

View File

@ -8,6 +8,8 @@ import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.settings.Spawn; import fr.xephi.authme.settings.Spawn;
/**
*/
public class SpawnCommand extends ExecutableCommand { public class SpawnCommand extends ExecutableCommand {
/** /**
@ -17,8 +19,8 @@ public class SpawnCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Make sure the command executor is a player // Make sure the command executor is a player

View File

@ -8,6 +8,8 @@ import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.command.help.HelpProvider; import fr.xephi.authme.command.help.HelpProvider;
/**
*/
public class SwitchAntiBotCommand extends ExecutableCommand { public class SwitchAntiBotCommand extends ExecutableCommand {
/** /**
@ -17,8 +19,8 @@ public class SwitchAntiBotCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -20,6 +20,8 @@ import fr.xephi.authme.task.MessageTask;
import fr.xephi.authme.task.TimeoutTask; import fr.xephi.authme.task.TimeoutTask;
import fr.xephi.authme.util.Utils; import fr.xephi.authme.util.Utils;
/**
*/
public class UnregisterCommand extends ExecutableCommand { public class UnregisterCommand extends ExecutableCommand {
/** /**
@ -28,8 +30,8 @@ public class UnregisterCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -9,6 +9,8 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
/**
*/
public class VersionCommand extends ExecutableCommand { public class VersionCommand extends ExecutableCommand {
/** /**
@ -18,8 +20,8 @@ public class VersionCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Show some version info // Show some version info
@ -71,8 +73,8 @@ public class VersionCommand extends ExecutableCommand {
* *
* @param minecraftName The Minecraft player name. * @param minecraftName The Minecraft player name.
* *
* @return True if the player is online, false otherwise.
*/ * @return True if the player is online, false otherwise. */
private boolean isPlayerOnline(String minecraftName) { private boolean isPlayerOnline(String minecraftName) {
for(Player player : Bukkit.getOnlinePlayers()) for(Player player : Bukkit.getOnlinePlayers())
if(player.getName().equalsIgnoreCase(minecraftName)) if(player.getName().equalsIgnoreCase(minecraftName))

View File

@ -11,6 +11,8 @@ import fr.xephi.authme.security.RandomString;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
/**
*/
public class CaptchaCommand extends ExecutableCommand { public class CaptchaCommand extends ExecutableCommand {
/** /**
@ -20,8 +22,8 @@ public class CaptchaCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -11,6 +11,8 @@ import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.task.ChangePasswordTask; import fr.xephi.authme.task.ChangePasswordTask;
/**
*/
public class ChangePasswordCommand extends ExecutableCommand { public class ChangePasswordCommand extends ExecutableCommand {
/** /**
@ -20,8 +22,8 @@ public class ChangePasswordCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -17,6 +17,8 @@ import fr.xephi.authme.converter.vAuthConverter;
import fr.xephi.authme.converter.xAuthConverter; import fr.xephi.authme.converter.xAuthConverter;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
/**
*/
public class ConverterCommand extends ExecutableCommand { public class ConverterCommand extends ExecutableCommand {
/** /**
@ -26,8 +28,8 @@ public class ConverterCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance
@ -85,6 +87,8 @@ public class ConverterCommand extends ExecutableCommand {
return true; return true;
} }
/**
*/
public enum ConvertType { public enum ConvertType {
ftsql("flattosql"), ftsql("flattosql"),
ftsqlite("flattosqlite"), ftsqlite("flattosqlite"),
@ -97,14 +101,27 @@ public class ConverterCommand extends ExecutableCommand {
String name; String name;
/**
* Constructor for ConvertType.
* @param name String
*/
ConvertType(String name) { ConvertType(String name) {
this.name = name; this.name = name;
} }
/**
* Method getName.
* @return String
*/
String getName() { String getName() {
return this.name; return this.name;
} }
/**
* Method fromName.
* @param name String
* @return ConvertType
*/
public static ConvertType fromName(String name) { public static ConvertType fromName(String name) {
for (ConvertType type : ConvertType.values()) { for (ConvertType type : ConvertType.values()) {
if (type.getName().equalsIgnoreCase(name)) if (type.getName().equalsIgnoreCase(name))

View File

@ -8,6 +8,8 @@ import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
/**
*/
public class AddEmailCommand extends ExecutableCommand { public class AddEmailCommand extends ExecutableCommand {
/** /**
@ -16,8 +18,8 @@ public class AddEmailCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -8,6 +8,8 @@ import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
/**
*/
public class ChangeEmailCommand extends ExecutableCommand { public class ChangeEmailCommand extends ExecutableCommand {
/** /**
@ -16,8 +18,8 @@ public class ChangeEmailCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -16,6 +16,8 @@ import fr.xephi.authme.security.RandomString;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
/**
*/
public class RecoverEmailCommand extends ExecutableCommand { public class RecoverEmailCommand extends ExecutableCommand {
/** /**
@ -25,8 +27,8 @@ public class RecoverEmailCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -7,6 +7,8 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
/**
*/
public class LoginCommand extends ExecutableCommand { public class LoginCommand extends ExecutableCommand {
/** /**
@ -16,8 +18,8 @@ public class LoginCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -7,6 +7,8 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
/**
*/
public class LogoutCommand extends ExecutableCommand { public class LogoutCommand extends ExecutableCommand {
/** /**
@ -16,8 +18,8 @@ public class LogoutCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -10,6 +10,8 @@ import fr.xephi.authme.security.RandomString;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
/**
*/
public class RegisterCommand extends ExecutableCommand { public class RegisterCommand extends ExecutableCommand {
/** /**
@ -19,8 +21,8 @@ public class RegisterCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -9,6 +9,8 @@ import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand; import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
/**
*/
public class UnregisterCommand extends ExecutableCommand { public class UnregisterCommand extends ExecutableCommand {
/** /**
@ -18,8 +20,8 @@ public class UnregisterCommand extends ExecutableCommand {
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
* *
* @return True if the command was executed successfully, false otherwise.
*/ * @return True if the command was executed successfully, false otherwise. */
@Override @Override
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance // AuthMe plugin instance

View File

@ -16,6 +16,8 @@ import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.CommandPermissions; import fr.xephi.authme.command.CommandPermissions;
import fr.xephi.authme.util.StringUtils; import fr.xephi.authme.util.StringUtils;
/**
*/
public class HelpPrinter { public class HelpPrinter {
/** /**

View File

@ -8,6 +8,8 @@ import fr.xephi.authme.command.CommandDescription;
import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.FoundCommandResult; import fr.xephi.authme.command.FoundCommandResult;
/**
*/
public class HelpProvider { public class HelpProvider {
/** /**

View File

@ -7,6 +7,8 @@ import fr.xephi.authme.command.CommandDescription;
import fr.xephi.authme.command.CommandParts; import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.util.ListUtils; import fr.xephi.authme.util.ListUtils;
/**
*/
public class HelpSyntaxHelper { public class HelpSyntaxHelper {
/** /**
@ -17,8 +19,8 @@ public class HelpSyntaxHelper {
* @param alternativeLabel The alternative label to use for this command syntax. * @param alternativeLabel The alternative label to use for this command syntax.
* @param highlight True to highlight the important parts of this command. * @param highlight True to highlight the important parts of this command.
* *
* @return The command with proper syntax.
*/ * @return The command with proper syntax. */
@SuppressWarnings("StringConcatenationInsideStringBufferAppend") @SuppressWarnings("StringConcatenationInsideStringBufferAppend")
public static String getCommandSyntax(CommandDescription commandDescription, CommandParts commandReference, String alternativeLabel, boolean highlight) { public static String getCommandSyntax(CommandDescription commandDescription, CommandParts commandReference, String alternativeLabel, boolean highlight) {
// Create a string builder to build the command // Create a string builder to build the command

View File

@ -1,4 +1,6 @@
package fr.xephi.authme.converter; package fr.xephi.authme.converter;
/**
*/
public interface Converter extends Runnable { public interface Converter extends Runnable {
} }

View File

@ -15,6 +15,7 @@ import fr.xephi.authme.settings.Settings;
/** /**
* @author Xephi59 * @author Xephi59
* @version $Revision: 1.0 $
*/ */
public class CrazyLoginConverter implements Converter { public class CrazyLoginConverter implements Converter {
@ -22,16 +23,29 @@ public class CrazyLoginConverter implements Converter {
public DataSource database; public DataSource database;
public CommandSender sender; public CommandSender sender;
/**
* Constructor for CrazyLoginConverter.
* @param instance AuthMe
* @param sender CommandSender
*/
public CrazyLoginConverter(AuthMe instance, CommandSender sender) { public CrazyLoginConverter(AuthMe instance, CommandSender sender) {
this.instance = instance; this.instance = instance;
this.database = instance.database; this.database = instance.database;
this.sender = sender; this.sender = sender;
} }
/**
* Method getInstance.
* @return CrazyLoginConverter
*/
public CrazyLoginConverter getInstance() { public CrazyLoginConverter getInstance() {
return this; return this;
} }
/**
* Method run.
* @see java.lang.Runnable#run()
*/
@Override @Override
public void run() { public void run() {
String fileName = Settings.crazyloginFileName; String fileName = Settings.crazyloginFileName;

View File

@ -13,6 +13,7 @@ import fr.xephi.authme.settings.Settings;
/** /**
* @author Xephi59 * @author Xephi59
* @version $Revision: 1.0 $
*/ */
public class FlatToSql implements Converter { public class FlatToSql implements Converter {
@ -44,6 +45,10 @@ public class FlatToSql implements Converter {
columnID = Settings.getMySQLColumnId; columnID = Settings.getMySQLColumnId;
} }
/**
* Method run.
* @see java.lang.Runnable#run()
*/
@Override @Override
public void run() { public void run() {
try { try {

View File

@ -16,6 +16,8 @@ import org.bukkit.command.CommandSender;
import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
/**
*/
public class FlatToSqlite implements Converter { public class FlatToSqlite implements Converter {
public CommandSender sender; public CommandSender sender;
@ -32,10 +34,18 @@ public class FlatToSqlite implements Converter {
private String database; private String database;
private String columnID; private String columnID;
private Connection con; private Connection con;
/**
* Constructor for FlatToSqlite.
* @param sender CommandSender
*/
public FlatToSqlite(CommandSender sender) { public FlatToSqlite(CommandSender sender) {
this.sender = sender; this.sender = sender;
} }
/**
* Method close.
* @param o AutoCloseable
*/
private static void close(AutoCloseable o) { private static void close(AutoCloseable o) {
if (o != null) { if (o != null) {
try { try {
@ -46,6 +56,10 @@ public class FlatToSqlite implements Converter {
} }
} }
/**
* Method run.
* @see java.lang.Runnable#run()
*/
@Override @Override
public void run() { public void run() {
database = Settings.getMySQLDatabase; database = Settings.getMySQLDatabase;
@ -105,11 +119,20 @@ public class FlatToSqlite implements Converter {
} }
} }
/**
* Method connect.
* @throws ClassNotFoundException
* @throws SQLException
*/
private synchronized void connect() throws ClassNotFoundException, SQLException { private synchronized void connect() throws ClassNotFoundException, SQLException {
Class.forName("org.sqlite.JDBC"); Class.forName("org.sqlite.JDBC");
con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/" + database + ".db"); con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/" + database + ".db");
} }
/**
* Method setup.
* @throws SQLException
*/
private synchronized void setup() throws SQLException { private synchronized void setup() throws SQLException {
Statement st = null; Statement st = null;
ResultSet rs = null; ResultSet rs = null;
@ -153,6 +176,11 @@ public class FlatToSqlite implements Converter {
} }
} }
/**
* Method saveAuth.
* @param s String
* @return boolean
*/
private synchronized boolean saveAuth(String s) { private synchronized boolean saveAuth(String s) {
PreparedStatement pst = null; PreparedStatement pst = null;
try { try {

View File

@ -7,13 +7,24 @@ import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.datasource.SQLite; import fr.xephi.authme.datasource.SQLite;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
/**
*/
public class ForceFlatToSqlite implements Converter { public class ForceFlatToSqlite implements Converter {
private DataSource data; private DataSource data;
/**
* Constructor for ForceFlatToSqlite.
* @param data DataSource
* @param plugin AuthMe
*/
public ForceFlatToSqlite(DataSource data, AuthMe plugin) { public ForceFlatToSqlite(DataSource data, AuthMe plugin) {
this.data = data; this.data = data;
} }
/**
* Method run.
* @see java.lang.Runnable#run()
*/
@Override @Override
public void run() { public void run() {
DataSource sqlite = null; DataSource sqlite = null;

View File

@ -20,6 +20,7 @@ import fr.xephi.authme.settings.Settings;
/** /**
* @author Xephi59 * @author Xephi59
* @version $Revision: 1.0 $
*/ */
public class RakamakConverter implements Converter { public class RakamakConverter implements Converter {
@ -27,16 +28,29 @@ public class RakamakConverter implements Converter {
public DataSource database; public DataSource database;
public CommandSender sender; public CommandSender sender;
/**
* Constructor for RakamakConverter.
* @param instance AuthMe
* @param sender CommandSender
*/
public RakamakConverter(AuthMe instance, CommandSender sender) { public RakamakConverter(AuthMe instance, CommandSender sender) {
this.instance = instance; this.instance = instance;
this.database = instance.database; this.database = instance.database;
this.sender = sender; this.sender = sender;
} }
/**
* Method getInstance.
* @return RakamakConverter
*/
public RakamakConverter getInstance() { public RakamakConverter getInstance() {
return this; return this;
} }
/**
* Method run.
* @see java.lang.Runnable#run()
*/
@Override @Override
public void run() { public void run() {
HashAlgorithm hash = Settings.getPasswordHash; HashAlgorithm hash = Settings.getPasswordHash;

View File

@ -9,16 +9,26 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.datasource.DataSource;
/**
*/
public class RoyalAuthConverter implements Converter { public class RoyalAuthConverter implements Converter {
public AuthMe plugin; public AuthMe plugin;
private DataSource data; private DataSource data;
/**
* Constructor for RoyalAuthConverter.
* @param plugin AuthMe
*/
public RoyalAuthConverter(AuthMe plugin) { public RoyalAuthConverter(AuthMe plugin) {
this.plugin = plugin; this.plugin = plugin;
this.data = plugin.database; this.data = plugin.database;
} }
/**
* Method run.
* @see java.lang.Runnable#run()
*/
@Override @Override
public void run() { public void run() {
for (OfflinePlayer o : plugin.getServer().getOfflinePlayers()) { for (OfflinePlayer o : plugin.getServer().getOfflinePlayers()) {

View File

@ -4,18 +4,32 @@ import java.io.File;
import fr.xephi.authme.settings.CustomConfiguration; import fr.xephi.authme.settings.CustomConfiguration;
/**
*/
public class RoyalAuthYamlReader extends CustomConfiguration { public class RoyalAuthYamlReader extends CustomConfiguration {
/**
* Constructor for RoyalAuthYamlReader.
* @param file File
*/
public RoyalAuthYamlReader(File file) { public RoyalAuthYamlReader(File file) {
super(file); super(file);
load(); load();
save(); save();
} }
/**
* Method getLastLogin.
* @return long
*/
public long getLastLogin() { public long getLastLogin() {
return getLong("timestamps.quit"); return getLong("timestamps.quit");
} }
/**
* Method getHash.
* @return String
*/
public String getHash() { public String getHash() {
return getString("login.password"); return getString("login.password");
} }

View File

@ -11,18 +11,29 @@ import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.datasource.FlatFile; import fr.xephi.authme.datasource.FlatFile;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
/**
*/
public class SqlToFlat implements Converter { public class SqlToFlat implements Converter {
public AuthMe plugin; public AuthMe plugin;
public DataSource database; public DataSource database;
public CommandSender sender; public CommandSender sender;
/**
* Constructor for SqlToFlat.
* @param plugin AuthMe
* @param sender CommandSender
*/
public SqlToFlat(AuthMe plugin, CommandSender sender) { public SqlToFlat(AuthMe plugin, CommandSender sender) {
this.plugin = plugin; this.plugin = plugin;
this.database = plugin.database; this.database = plugin.database;
this.sender = sender; this.sender = sender;
} }
/**
* Method run.
* @see java.lang.Runnable#run()
*/
@Override @Override
public void run() { public void run() {
try { try {

View File

@ -6,18 +6,29 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.datasource.DataSource;
/**
*/
public class vAuthConverter implements Converter { public class vAuthConverter implements Converter {
public AuthMe plugin; public AuthMe plugin;
public DataSource database; public DataSource database;
public CommandSender sender; public CommandSender sender;
/**
* Constructor for vAuthConverter.
* @param plugin AuthMe
* @param sender CommandSender
*/
public vAuthConverter(AuthMe plugin, CommandSender sender) { public vAuthConverter(AuthMe plugin, CommandSender sender) {
this.plugin = plugin; this.plugin = plugin;
this.database = plugin.database; this.database = plugin.database;
this.sender = sender; this.sender = sender;
} }
/**
* Method run.
* @see java.lang.Runnable#run()
*/
@Override @Override
public void run() { public void run() {
try { try {

View File

@ -14,18 +14,29 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.datasource.DataSource;
/**
*/
public class vAuthFileReader { public class vAuthFileReader {
public AuthMe plugin; public AuthMe plugin;
public DataSource database; public DataSource database;
public CommandSender sender; public CommandSender sender;
/**
* Constructor for vAuthFileReader.
* @param plugin AuthMe
* @param sender CommandSender
*/
public vAuthFileReader(AuthMe plugin, CommandSender sender) { public vAuthFileReader(AuthMe plugin, CommandSender sender) {
this.plugin = plugin; this.plugin = plugin;
this.database = plugin.database; this.database = plugin.database;
this.sender = sender; this.sender = sender;
} }
/**
* Method convert.
* @throws IOException
*/
public void convert() throws IOException { public void convert() throws IOException {
final File file = new File(plugin.getDataFolder().getParent() + "" + File.separator + "vAuth" + File.separator + "passwords.yml"); final File file = new File(plugin.getDataFolder().getParent() + "" + File.separator + "vAuth" + File.separator + "passwords.yml");
Scanner scanner; Scanner scanner;
@ -57,12 +68,22 @@ public class vAuthFileReader {
} }
/**
* Method isUUIDinstance.
* @param s String
* @return boolean
*/
private boolean isUUIDinstance(String s) { private boolean isUUIDinstance(String s) {
if (String.valueOf(s.charAt(8)).equalsIgnoreCase("-")) if (String.valueOf(s.charAt(8)).equalsIgnoreCase("-"))
return true; return true;
return true; return true;
} }
/**
* Method getName.
* @param uuid UUID
* @return String
*/
private String getName(UUID uuid) { private String getName(UUID uuid) {
try { try {
for (OfflinePlayer op : Bukkit.getOfflinePlayers()) { for (OfflinePlayer op : Bukkit.getOfflinePlayers()) {

View File

@ -4,16 +4,27 @@ import org.bukkit.command.CommandSender;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
/**
*/
public class xAuthConverter implements Converter { public class xAuthConverter implements Converter {
public AuthMe plugin; public AuthMe plugin;
public CommandSender sender; public CommandSender sender;
/**
* Constructor for xAuthConverter.
* @param plugin AuthMe
* @param sender CommandSender
*/
public xAuthConverter(AuthMe plugin, CommandSender sender) { public xAuthConverter(AuthMe plugin, CommandSender sender) {
this.plugin = plugin; this.plugin = plugin;
this.sender = sender; this.sender = sender;
} }
/**
* Method run.
* @see java.lang.Runnable#run()
*/
@Override @Override
public void run() { public void run() {
try { try {

View File

@ -17,18 +17,29 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource; import fr.xephi.authme.datasource.DataSource;
/**
*/
public class xAuthToFlat { public class xAuthToFlat {
public AuthMe instance; public AuthMe instance;
public DataSource database; public DataSource database;
public CommandSender sender; public CommandSender sender;
/**
* Constructor for xAuthToFlat.
* @param instance AuthMe
* @param sender CommandSender
*/
public xAuthToFlat(AuthMe instance, CommandSender sender) { public xAuthToFlat(AuthMe instance, CommandSender sender) {
this.instance = instance; this.instance = instance;
this.database = instance.database; this.database = instance.database;
this.sender = sender; this.sender = sender;
} }
/**
* Method convert.
* @return boolean
*/
public boolean convert() { public boolean convert() {
if (instance.getServer().getPluginManager().getPlugin("xAuth") == null) { if (instance.getServer().getPluginManager().getPlugin("xAuth") == null) {
sender.sendMessage("[AuthMe] xAuth plugin not found"); sender.sendMessage("[AuthMe] xAuth plugin not found");
@ -59,6 +70,11 @@ public class xAuthToFlat {
return true; return true;
} }
/**
* Method getIdPlayer.
* @param id int
* @return String
*/
public String getIdPlayer(int id) { public String getIdPlayer(int id) {
String realPass = ""; String realPass = "";
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection(); Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
@ -81,6 +97,10 @@ public class xAuthToFlat {
return realPass; return realPass;
} }
/**
* Method getXAuthPlayers.
* @return List<Integer>
*/
public List<Integer> getXAuthPlayers() { public List<Integer> getXAuthPlayers() {
List<Integer> xP = new ArrayList<>(); List<Integer> xP = new ArrayList<>();
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection(); Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
@ -102,6 +122,11 @@ public class xAuthToFlat {
return xP; return xP;
} }
/**
* Method getPassword.
* @param accountId int
* @return String
*/
public String getPassword(int accountId) { public String getPassword(int accountId) {
String realPass = ""; String realPass = "";
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection(); Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();

View File

@ -15,12 +15,19 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.util.Utils; import fr.xephi.authme.util.Utils;
/**
*/
public class CacheDataSource implements DataSource { public class CacheDataSource implements DataSource {
private final DataSource source; private final DataSource source;
private final ExecutorService exec; private final ExecutorService exec;
private final ConcurrentHashMap<String, PlayerAuth> cache = new ConcurrentHashMap<>(); private final ConcurrentHashMap<String, PlayerAuth> cache = new ConcurrentHashMap<>();
/**
* Constructor for CacheDataSource.
* @param pl AuthMe
* @param src DataSource
*/
public CacheDataSource(final AuthMe pl, DataSource src) { public CacheDataSource(final AuthMe pl, DataSource src) {
this.source = src; this.source = src;
this.exec = Executors.newCachedThreadPool(); this.exec = Executors.newCachedThreadPool();
@ -42,11 +49,23 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method isAuthAvailable.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
*/
@Override @Override
public synchronized boolean isAuthAvailable(String user) { public synchronized boolean isAuthAvailable(String user) {
return cache.containsKey(user.toLowerCase()); return cache.containsKey(user.toLowerCase());
} }
/**
* Method getAuth.
* @param user String
* @return PlayerAuth
* @see fr.xephi.authme.datasource.DataSource#getAuth(String)
*/
@Override @Override
public synchronized PlayerAuth getAuth(String user) { public synchronized PlayerAuth getAuth(String user) {
user = user.toLowerCase(); user = user.toLowerCase();
@ -56,6 +75,12 @@ public class CacheDataSource implements DataSource {
return null; return null;
} }
/**
* Method saveAuth.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
*/
@Override @Override
public synchronized boolean saveAuth(final PlayerAuth auth) { public synchronized boolean saveAuth(final PlayerAuth auth) {
cache.put(auth.getNickname(), auth); cache.put(auth.getNickname(), auth);
@ -70,6 +95,12 @@ public class CacheDataSource implements DataSource {
return true; return true;
} }
/**
* Method updatePassword.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
*/
@Override @Override
public synchronized boolean updatePassword(final PlayerAuth auth) { public synchronized boolean updatePassword(final PlayerAuth auth) {
if (!cache.containsKey(auth.getNickname())) { if (!cache.containsKey(auth.getNickname())) {
@ -90,6 +121,12 @@ public class CacheDataSource implements DataSource {
return true; return true;
} }
/**
* Method updateSession.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
*/
@Override @Override
public boolean updateSession(final PlayerAuth auth) { public boolean updateSession(final PlayerAuth auth) {
if (!cache.containsKey(auth.getNickname())) { if (!cache.containsKey(auth.getNickname())) {
@ -119,6 +156,12 @@ public class CacheDataSource implements DataSource {
return true; return true;
} }
/**
* Method updateQuitLoc.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
*/
@Override @Override
public boolean updateQuitLoc(final PlayerAuth auth) { public boolean updateQuitLoc(final PlayerAuth auth) {
if (!cache.containsKey(auth.getNickname())) { if (!cache.containsKey(auth.getNickname())) {
@ -151,6 +194,12 @@ public class CacheDataSource implements DataSource {
return true; return true;
} }
/**
* Method getIps.
* @param ip String
* @return int
* @see fr.xephi.authme.datasource.DataSource#getIps(String)
*/
@Override @Override
public int getIps(String ip) { public int getIps(String ip) {
int count = 0; int count = 0;
@ -162,6 +211,12 @@ public class CacheDataSource implements DataSource {
return count; return count;
} }
/**
* Method purgeDatabase.
* @param until long
* @return int
* @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
*/
@Override @Override
public int purgeDatabase(long until) { public int purgeDatabase(long until) {
int cleared = source.purgeDatabase(until); int cleared = source.purgeDatabase(until);
@ -175,6 +230,12 @@ public class CacheDataSource implements DataSource {
return cleared; return cleared;
} }
/**
* Method autoPurgeDatabase.
* @param until long
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
*/
@Override @Override
public List<String> autoPurgeDatabase(long until) { public List<String> autoPurgeDatabase(long until) {
List<String> cleared = source.autoPurgeDatabase(until); List<String> cleared = source.autoPurgeDatabase(until);
@ -188,6 +249,12 @@ public class CacheDataSource implements DataSource {
return cleared; return cleared;
} }
/**
* Method removeAuth.
* @param username String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
*/
@Override @Override
public synchronized boolean removeAuth(String username) { public synchronized boolean removeAuth(String username) {
final String user = username.toLowerCase(); final String user = username.toLowerCase();
@ -204,12 +271,20 @@ public class CacheDataSource implements DataSource {
return true; return true;
} }
/**
* Method close.
* @see fr.xephi.authme.datasource.DataSource#close()
*/
@Override @Override
public synchronized void close() { public synchronized void close() {
exec.shutdown(); exec.shutdown();
source.close(); source.close();
} }
/**
* Method reload.
* @see fr.xephi.authme.datasource.DataSource#reload()
*/
@Override @Override
public void reload() { public void reload() {
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -228,6 +303,12 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method updateEmail.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
*/
@Override @Override
public synchronized boolean updateEmail(final PlayerAuth auth) { public synchronized boolean updateEmail(final PlayerAuth auth) {
try { try {
@ -241,6 +322,12 @@ public class CacheDataSource implements DataSource {
} }
} }
/**
* Method updateSalt.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
*/
@Override @Override
public synchronized boolean updateSalt(final PlayerAuth auth) { public synchronized boolean updateSalt(final PlayerAuth auth) {
if (!cache.containsKey(auth.getNickname())) { if (!cache.containsKey(auth.getNickname())) {
@ -262,6 +349,12 @@ public class CacheDataSource implements DataSource {
return true; return true;
} }
/**
* Method getAllAuthsByName.
* @param auth PlayerAuth
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
*/
@Override @Override
public synchronized List<String> getAllAuthsByName(PlayerAuth auth) { public synchronized List<String> getAllAuthsByName(PlayerAuth auth) {
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
@ -273,6 +366,13 @@ public class CacheDataSource implements DataSource {
return result; return result;
} }
/**
* Method getAllAuthsByIp.
* @param ip String
* @return List<String>
* @throws Exception
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
*/
@Override @Override
public synchronized List<String> getAllAuthsByIp(final String ip) throws Exception { public synchronized List<String> getAllAuthsByIp(final String ip) throws Exception {
return exec.submit(new Callable<List<String>>() { return exec.submit(new Callable<List<String>>() {
@ -282,6 +382,13 @@ public class CacheDataSource implements DataSource {
}).get(); }).get();
} }
/**
* Method getAllAuthsByEmail.
* @param email String
* @return List<String>
* @throws Exception
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
*/
@Override @Override
public synchronized List<String> getAllAuthsByEmail(final String email) throws Exception { public synchronized List<String> getAllAuthsByEmail(final String email) throws Exception {
return exec.submit(new Callable<List<String>>() { return exec.submit(new Callable<List<String>>() {
@ -291,6 +398,11 @@ public class CacheDataSource implements DataSource {
}).get(); }).get();
} }
/**
* Method purgeBanned.
* @param banned List<String>
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
*/
@Override @Override
public synchronized void purgeBanned(final List<String> banned) { public synchronized void purgeBanned(final List<String> banned) {
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -306,17 +418,33 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method getType.
* @return DataSourceType
* @see fr.xephi.authme.datasource.DataSource#getType()
*/
@Override @Override
public DataSourceType getType() { public DataSourceType getType() {
return source.getType(); return source.getType();
} }
/**
* Method isLogged.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isLogged(String)
*/
@Override @Override
public boolean isLogged(String user) { public boolean isLogged(String user) {
user = user.toLowerCase(); user = user.toLowerCase();
return PlayerCache.getInstance().getCache().containsKey(user); return PlayerCache.getInstance().getCache().containsKey(user);
} }
/**
* Method setLogged.
* @param user String
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
*/
@Override @Override
public void setLogged(final String user) { public void setLogged(final String user) {
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -327,6 +455,11 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method setUnlogged.
* @param user String
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
*/
@Override @Override
public void setUnlogged(final String user) { public void setUnlogged(final String user) {
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -337,6 +470,10 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method purgeLogged.
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
*/
@Override @Override
public void purgeLogged() { public void purgeLogged() {
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -347,11 +484,22 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method getAccountsRegistered.
* @return int
* @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
*/
@Override @Override
public int getAccountsRegistered() { public int getAccountsRegistered() {
return cache.size(); return cache.size();
} }
/**
* Method updateName.
* @param oldone String
* @param newone String
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
*/
@Override @Override
public void updateName(final String oldone, final String newone) { public void updateName(final String oldone, final String newone) {
if (cache.containsKey(oldone)) { if (cache.containsKey(oldone)) {
@ -366,11 +514,21 @@ public class CacheDataSource implements DataSource {
}); });
} }
/**
* Method getAllAuths.
* @return List<PlayerAuth>
* @see fr.xephi.authme.datasource.DataSource#getAllAuths()
*/
@Override @Override
public List<PlayerAuth> getAllAuths() { public List<PlayerAuth> getAllAuths() {
return new ArrayList<>(cache.values()); return new ArrayList<>(cache.values());
} }
/**
* Method getLoggedPlayers.
* @return List<PlayerAuth>
* @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
*/
@Override @Override
public List<PlayerAuth> getLoggedPlayers() { public List<PlayerAuth> getLoggedPlayers() {
return new ArrayList<>(PlayerCache.getInstance().getCache().values()); return new ArrayList<>(PlayerCache.getInstance().getCache().values());

View File

@ -4,66 +4,185 @@ import java.util.List;
import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerAuth;
/**
*/
public interface DataSource { public interface DataSource {
/**
*/
enum DataSourceType { enum DataSourceType {
MYSQL, MYSQL,
FILE, FILE,
SQLITE SQLITE
} }
/**
* Method isAuthAvailable.
* @param user String
* @return boolean
*/
boolean isAuthAvailable(String user); boolean isAuthAvailable(String user);
/**
* Method getAuth.
* @param user String
* @return PlayerAuth
*/
PlayerAuth getAuth(String user); PlayerAuth getAuth(String user);
/**
* Method saveAuth.
* @param auth PlayerAuth
* @return boolean
*/
boolean saveAuth(PlayerAuth auth); boolean saveAuth(PlayerAuth auth);
/**
* Method updateSession.
* @param auth PlayerAuth
* @return boolean
*/
boolean updateSession(PlayerAuth auth); boolean updateSession(PlayerAuth auth);
/**
* Method updatePassword.
* @param auth PlayerAuth
* @return boolean
*/
boolean updatePassword(PlayerAuth auth); boolean updatePassword(PlayerAuth auth);
/**
* Method purgeDatabase.
* @param until long
* @return int
*/
int purgeDatabase(long until); int purgeDatabase(long until);
/**
* Method autoPurgeDatabase.
* @param until long
* @return List<String>
*/
List<String> autoPurgeDatabase(long until); List<String> autoPurgeDatabase(long until);
/**
* Method removeAuth.
* @param user String
* @return boolean
*/
boolean removeAuth(String user); boolean removeAuth(String user);
/**
* Method updateQuitLoc.
* @param auth PlayerAuth
* @return boolean
*/
boolean updateQuitLoc(PlayerAuth auth); boolean updateQuitLoc(PlayerAuth auth);
/**
* Method getIps.
* @param ip String
* @return int
*/
int getIps(String ip); int getIps(String ip);
/**
* Method getAllAuthsByName.
* @param auth PlayerAuth
* @return List<String>
*/
List<String> getAllAuthsByName(PlayerAuth auth); List<String> getAllAuthsByName(PlayerAuth auth);
/**
* Method getAllAuthsByIp.
* @param ip String
* @return List<String>
* @throws Exception
*/
List<String> getAllAuthsByIp(String ip) throws Exception; List<String> getAllAuthsByIp(String ip) throws Exception;
/**
* Method getAllAuthsByEmail.
* @param email String
* @return List<String>
* @throws Exception
*/
List<String> getAllAuthsByEmail(String email) throws Exception; List<String> getAllAuthsByEmail(String email) throws Exception;
/**
* Method updateEmail.
* @param auth PlayerAuth
* @return boolean
*/
boolean updateEmail(PlayerAuth auth); boolean updateEmail(PlayerAuth auth);
/**
* Method updateSalt.
* @param auth PlayerAuth
* @return boolean
*/
boolean updateSalt(PlayerAuth auth); boolean updateSalt(PlayerAuth auth);
void close(); void close();
void reload(); void reload();
/**
* Method purgeBanned.
* @param banned List<String>
*/
void purgeBanned(List<String> banned); void purgeBanned(List<String> banned);
/**
* Method getType.
* @return DataSourceType
*/
DataSourceType getType(); DataSourceType getType();
/**
* Method isLogged.
* @param user String
* @return boolean
*/
boolean isLogged(String user); boolean isLogged(String user);
/**
* Method setLogged.
* @param user String
*/
void setLogged(String user); void setLogged(String user);
/**
* Method setUnlogged.
* @param user String
*/
void setUnlogged(String user); void setUnlogged(String user);
void purgeLogged(); void purgeLogged();
/**
* Method getAccountsRegistered.
* @return int
*/
int getAccountsRegistered(); int getAccountsRegistered();
/**
* Method updateName.
* @param oldone String
* @param newone String
*/
void updateName(String oldone, String newone); void updateName(String oldone, String newone);
/**
* Method getAllAuths.
* @return List<PlayerAuth>
*/
List<PlayerAuth> getAllAuths(); List<PlayerAuth> getAllAuths();
/**
* Method getLoggedPlayers.
* @return List<PlayerAuth>
*/
List<PlayerAuth> getLoggedPlayers(); List<PlayerAuth> getLoggedPlayers();
} }

View File

@ -8,16 +8,28 @@ import java.util.concurrent.Executors;
import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerAuth;
/**
*/
public class DatabaseCalls implements DataSource { public class DatabaseCalls implements DataSource {
private DataSource database; private DataSource database;
private final ExecutorService exec; private final ExecutorService exec;
/**
* Constructor for DatabaseCalls.
* @param database DataSource
*/
public DatabaseCalls(DataSource database) { public DatabaseCalls(DataSource database) {
this.database = database; this.database = database;
this.exec = Executors.newCachedThreadPool(); this.exec = Executors.newCachedThreadPool();
} }
/**
* Method isAuthAvailable.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
*/
@Override @Override
public synchronized boolean isAuthAvailable(final String user) { public synchronized boolean isAuthAvailable(final String user) {
try { try {
@ -31,6 +43,12 @@ public class DatabaseCalls implements DataSource {
} }
} }
/**
* Method getAuth.
* @param user String
* @return PlayerAuth
* @see fr.xephi.authme.datasource.DataSource#getAuth(String)
*/
@Override @Override
public synchronized PlayerAuth getAuth(final String user) { public synchronized PlayerAuth getAuth(final String user) {
try { try {
@ -44,6 +62,12 @@ public class DatabaseCalls implements DataSource {
} }
} }
/**
* Method saveAuth.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
*/
@Override @Override
public synchronized boolean saveAuth(final PlayerAuth auth) { public synchronized boolean saveAuth(final PlayerAuth auth) {
try { try {
@ -57,6 +81,12 @@ public class DatabaseCalls implements DataSource {
} }
} }
/**
* Method updateSession.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
*/
@Override @Override
public synchronized boolean updateSession(final PlayerAuth auth) { public synchronized boolean updateSession(final PlayerAuth auth) {
try { try {
@ -70,6 +100,12 @@ public class DatabaseCalls implements DataSource {
} }
} }
/**
* Method updatePassword.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
*/
@Override @Override
public synchronized boolean updatePassword(final PlayerAuth auth) { public synchronized boolean updatePassword(final PlayerAuth auth) {
try { try {
@ -83,6 +119,12 @@ public class DatabaseCalls implements DataSource {
} }
} }
/**
* Method purgeDatabase.
* @param until long
* @return int
* @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
*/
@Override @Override
public synchronized int purgeDatabase(final long until) { public synchronized int purgeDatabase(final long until) {
try { try {
@ -96,6 +138,12 @@ public class DatabaseCalls implements DataSource {
} }
} }
/**
* Method autoPurgeDatabase.
* @param until long
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
*/
@Override @Override
public synchronized List<String> autoPurgeDatabase(final long until) { public synchronized List<String> autoPurgeDatabase(final long until) {
try { try {
@ -109,6 +157,12 @@ public class DatabaseCalls implements DataSource {
} }
} }
/**
* Method removeAuth.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
*/
@Override @Override
public synchronized boolean removeAuth(final String user) { public synchronized boolean removeAuth(final String user) {
try { try {
@ -122,6 +176,12 @@ public class DatabaseCalls implements DataSource {
} }
} }
/**
* Method updateQuitLoc.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
*/
@Override @Override
public synchronized boolean updateQuitLoc(final PlayerAuth auth) { public synchronized boolean updateQuitLoc(final PlayerAuth auth) {
try { try {
@ -135,6 +195,12 @@ public class DatabaseCalls implements DataSource {
} }
} }
/**
* Method getIps.
* @param ip String
* @return int
* @see fr.xephi.authme.datasource.DataSource#getIps(String)
*/
@Override @Override
public synchronized int getIps(final String ip) { public synchronized int getIps(final String ip) {
try { try {
@ -149,6 +215,12 @@ public class DatabaseCalls implements DataSource {
} }
} }
/**
* Method getAllAuthsByName.
* @param auth PlayerAuth
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
*/
@Override @Override
public synchronized List<String> getAllAuthsByName(final PlayerAuth auth) { public synchronized List<String> getAllAuthsByName(final PlayerAuth auth) {
try { try {
@ -162,6 +234,12 @@ public class DatabaseCalls implements DataSource {
} }
} }
/**
* Method getAllAuthsByIp.
* @param ip String
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
*/
@Override @Override
public synchronized List<String> getAllAuthsByIp(final String ip) { public synchronized List<String> getAllAuthsByIp(final String ip) {
try { try {
@ -175,6 +253,12 @@ public class DatabaseCalls implements DataSource {
} }
} }
/**
* Method getAllAuthsByEmail.
* @param email String
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
*/
@Override @Override
public synchronized List<String> getAllAuthsByEmail(final String email) { public synchronized List<String> getAllAuthsByEmail(final String email) {
try { try {
@ -188,6 +272,12 @@ public class DatabaseCalls implements DataSource {
} }
} }
/**
* Method updateEmail.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
*/
@Override @Override
public synchronized boolean updateEmail(final PlayerAuth auth) { public synchronized boolean updateEmail(final PlayerAuth auth) {
try { try {
@ -201,6 +291,12 @@ public class DatabaseCalls implements DataSource {
} }
} }
/**
* Method updateSalt.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
*/
@Override @Override
public synchronized boolean updateSalt(final PlayerAuth auth) { public synchronized boolean updateSalt(final PlayerAuth auth) {
try { try {
@ -214,17 +310,30 @@ public class DatabaseCalls implements DataSource {
} }
} }
/**
* Method close.
* @see fr.xephi.authme.datasource.DataSource#close()
*/
@Override @Override
public synchronized void close() { public synchronized void close() {
exec.shutdown(); exec.shutdown();
database.close(); database.close();
} }
/**
* Method reload.
* @see fr.xephi.authme.datasource.DataSource#reload()
*/
@Override @Override
public synchronized void reload() { public synchronized void reload() {
database.reload(); database.reload();
} }
/**
* Method purgeBanned.
* @param banned List<String>
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
*/
@Override @Override
public synchronized void purgeBanned(final List<String> banned) { public synchronized void purgeBanned(final List<String> banned) {
new Thread(new Runnable() { new Thread(new Runnable() {
@ -234,11 +343,22 @@ public class DatabaseCalls implements DataSource {
}).start(); }).start();
} }
/**
* Method getType.
* @return DataSourceType
* @see fr.xephi.authme.datasource.DataSource#getType()
*/
@Override @Override
public synchronized DataSourceType getType() { public synchronized DataSourceType getType() {
return database.getType(); return database.getType();
} }
/**
* Method isLogged.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isLogged(String)
*/
@Override @Override
public synchronized boolean isLogged(final String user) { public synchronized boolean isLogged(final String user) {
try { try {
@ -252,6 +372,11 @@ public class DatabaseCalls implements DataSource {
} }
} }
/**
* Method setLogged.
* @param user String
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
*/
@Override @Override
public synchronized void setLogged(final String user) { public synchronized void setLogged(final String user) {
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -261,6 +386,11 @@ public class DatabaseCalls implements DataSource {
}); });
} }
/**
* Method setUnlogged.
* @param user String
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
*/
@Override @Override
public synchronized void setUnlogged(final String user) { public synchronized void setUnlogged(final String user) {
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -270,6 +400,10 @@ public class DatabaseCalls implements DataSource {
}); });
} }
/**
* Method purgeLogged.
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
*/
@Override @Override
public synchronized void purgeLogged() { public synchronized void purgeLogged() {
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -279,6 +413,11 @@ public class DatabaseCalls implements DataSource {
}); });
} }
/**
* Method getAccountsRegistered.
* @return int
* @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
*/
@Override @Override
public synchronized int getAccountsRegistered() { public synchronized int getAccountsRegistered() {
try { try {
@ -292,6 +431,12 @@ public class DatabaseCalls implements DataSource {
} }
} }
/**
* Method updateName.
* @param oldone String
* @param newone String
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
*/
@Override @Override
public synchronized void updateName(final String oldone, final String newone) { public synchronized void updateName(final String oldone, final String newone) {
exec.execute(new Runnable() { exec.execute(new Runnable() {
@ -301,6 +446,11 @@ public class DatabaseCalls implements DataSource {
}); });
} }
/**
* Method getAllAuths.
* @return List<PlayerAuth>
* @see fr.xephi.authme.datasource.DataSource#getAllAuths()
*/
@Override @Override
public synchronized List<PlayerAuth> getAllAuths() { public synchronized List<PlayerAuth> getAllAuths() {
try { try {
@ -314,6 +464,11 @@ public class DatabaseCalls implements DataSource {
} }
} }
/**
* Method getLoggedPlayers.
* @return List<PlayerAuth>
* @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
*/
@Override @Override
public List<PlayerAuth> getLoggedPlayers() { public List<PlayerAuth> getLoggedPlayers() {
try { try {

View File

@ -16,6 +16,8 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
/**
*/
public class FlatFile implements DataSource { public class FlatFile implements DataSource {
/* /*
@ -48,6 +50,12 @@ public class FlatFile implements DataSource {
} }
} }
/**
* Method isAuthAvailable.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
*/
@Override @Override
public synchronized boolean isAuthAvailable(String user) { public synchronized boolean isAuthAvailable(String user) {
BufferedReader br = null; BufferedReader br = null;
@ -77,6 +85,12 @@ public class FlatFile implements DataSource {
return false; return false;
} }
/**
* Method saveAuth.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
*/
@Override @Override
public synchronized boolean saveAuth(PlayerAuth auth) { public synchronized boolean saveAuth(PlayerAuth auth) {
if (isAuthAvailable(auth.getNickname())) { if (isAuthAvailable(auth.getNickname())) {
@ -100,6 +114,12 @@ public class FlatFile implements DataSource {
return true; return true;
} }
/**
* Method updatePassword.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
*/
@Override @Override
public synchronized boolean updatePassword(PlayerAuth auth) { public synchronized boolean updatePassword(PlayerAuth auth) {
if (!isAuthAvailable(auth.getNickname())) { if (!isAuthAvailable(auth.getNickname())) {
@ -159,6 +179,12 @@ public class FlatFile implements DataSource {
return true; return true;
} }
/**
* Method updateSession.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
*/
@Override @Override
public boolean updateSession(PlayerAuth auth) { public boolean updateSession(PlayerAuth auth) {
if (!isAuthAvailable(auth.getNickname())) { if (!isAuthAvailable(auth.getNickname())) {
@ -218,6 +244,12 @@ public class FlatFile implements DataSource {
return true; return true;
} }
/**
* Method updateQuitLoc.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
*/
@Override @Override
public boolean updateQuitLoc(PlayerAuth auth) { public boolean updateQuitLoc(PlayerAuth auth) {
if (!isAuthAvailable(auth.getNickname())) { if (!isAuthAvailable(auth.getNickname())) {
@ -256,6 +288,12 @@ public class FlatFile implements DataSource {
return true; return true;
} }
/**
* Method getIps.
* @param ip String
* @return int
* @see fr.xephi.authme.datasource.DataSource#getIps(String)
*/
@Override @Override
public int getIps(String ip) { public int getIps(String ip) {
BufferedReader br = null; BufferedReader br = null;
@ -286,6 +324,12 @@ public class FlatFile implements DataSource {
} }
} }
/**
* Method purgeDatabase.
* @param until long
* @return int
* @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
*/
@Override @Override
public int purgeDatabase(long until) { public int purgeDatabase(long until) {
BufferedReader br = null; BufferedReader br = null;
@ -332,6 +376,12 @@ public class FlatFile implements DataSource {
return cleared; return cleared;
} }
/**
* Method autoPurgeDatabase.
* @param until long
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
*/
@Override @Override
public List<String> autoPurgeDatabase(long until) { public List<String> autoPurgeDatabase(long until) {
BufferedReader br = null; BufferedReader br = null;
@ -378,6 +428,12 @@ public class FlatFile implements DataSource {
return cleared; return cleared;
} }
/**
* Method removeAuth.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
*/
@Override @Override
public synchronized boolean removeAuth(String user) { public synchronized boolean removeAuth(String user) {
if (!isAuthAvailable(user)) { if (!isAuthAvailable(user)) {
@ -422,6 +478,12 @@ public class FlatFile implements DataSource {
return true; return true;
} }
/**
* Method getAuth.
* @param user String
* @return PlayerAuth
* @see fr.xephi.authme.datasource.DataSource#getAuth(String)
*/
@Override @Override
public synchronized PlayerAuth getAuth(String user) { public synchronized PlayerAuth getAuth(String user) {
BufferedReader br = null; BufferedReader br = null;
@ -464,14 +526,28 @@ public class FlatFile implements DataSource {
return null; return null;
} }
/**
* Method close.
* @see fr.xephi.authme.datasource.DataSource#close()
*/
@Override @Override
public synchronized void close() { public synchronized void close() {
} }
/**
* Method reload.
* @see fr.xephi.authme.datasource.DataSource#reload()
*/
@Override @Override
public void reload() { public void reload() {
} }
/**
* Method updateEmail.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
*/
@Override @Override
public boolean updateEmail(PlayerAuth auth) { public boolean updateEmail(PlayerAuth auth) {
if (!isAuthAvailable(auth.getNickname())) { if (!isAuthAvailable(auth.getNickname())) {
@ -510,11 +586,23 @@ public class FlatFile implements DataSource {
return true; return true;
} }
/**
* Method updateSalt.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
*/
@Override @Override
public boolean updateSalt(PlayerAuth auth) { public boolean updateSalt(PlayerAuth auth) {
return false; return false;
} }
/**
* Method getAllAuthsByName.
* @param auth PlayerAuth
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
*/
@Override @Override
public List<String> getAllAuthsByName(PlayerAuth auth) { public List<String> getAllAuthsByName(PlayerAuth auth) {
BufferedReader br = null; BufferedReader br = null;
@ -545,6 +633,12 @@ public class FlatFile implements DataSource {
} }
} }
/**
* Method getAllAuthsByIp.
* @param ip String
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
*/
@Override @Override
public List<String> getAllAuthsByIp(String ip) { public List<String> getAllAuthsByIp(String ip) {
BufferedReader br = null; BufferedReader br = null;
@ -575,6 +669,12 @@ public class FlatFile implements DataSource {
} }
} }
/**
* Method getAllAuthsByEmail.
* @param email String
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
*/
@Override @Override
public List<String> getAllAuthsByEmail(String email) { public List<String> getAllAuthsByEmail(String email) {
BufferedReader br = null; BufferedReader br = null;
@ -605,6 +705,11 @@ public class FlatFile implements DataSource {
} }
} }
/**
* Method purgeBanned.
* @param banned List<String>
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
*/
@Override @Override
public void purgeBanned(List<String> banned) { public void purgeBanned(List<String> banned) {
BufferedReader br = null; BufferedReader br = null;
@ -649,28 +754,58 @@ public class FlatFile implements DataSource {
return; return;
} }
/**
* Method getType.
* @return DataSourceType
* @see fr.xephi.authme.datasource.DataSource#getType()
*/
@Override @Override
public DataSourceType getType() { public DataSourceType getType() {
return DataSourceType.FILE; return DataSourceType.FILE;
} }
/**
* Method isLogged.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isLogged(String)
*/
@Override @Override
public boolean isLogged(String user) { public boolean isLogged(String user) {
return PlayerCache.getInstance().isAuthenticated(user); return PlayerCache.getInstance().isAuthenticated(user);
} }
/**
* Method setLogged.
* @param user String
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
*/
@Override @Override
public void setLogged(String user) { public void setLogged(String user) {
} }
/**
* Method setUnlogged.
* @param user String
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
*/
@Override @Override
public void setUnlogged(String user) { public void setUnlogged(String user) {
} }
/**
* Method purgeLogged.
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
*/
@Override @Override
public void purgeLogged() { public void purgeLogged() {
} }
/**
* Method getAccountsRegistered.
* @return int
* @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
*/
@Override @Override
public int getAccountsRegistered() { public int getAccountsRegistered() {
BufferedReader br = null; BufferedReader br = null;
@ -694,6 +829,12 @@ public class FlatFile implements DataSource {
return result; return result;
} }
/**
* Method updateName.
* @param oldone String
* @param newone String
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
*/
@Override @Override
public void updateName(String oldone, String newone) { public void updateName(String oldone, String newone) {
PlayerAuth auth = this.getAuth(oldone); PlayerAuth auth = this.getAuth(oldone);
@ -702,6 +843,11 @@ public class FlatFile implements DataSource {
this.removeAuth(oldone); this.removeAuth(oldone);
} }
/**
* Method getAllAuths.
* @return List<PlayerAuth>
* @see fr.xephi.authme.datasource.DataSource#getAllAuths()
*/
@Override @Override
public List<PlayerAuth> getAllAuths() { public List<PlayerAuth> getAllAuths() {
BufferedReader br = null; BufferedReader br = null;
@ -749,6 +895,11 @@ public class FlatFile implements DataSource {
return auths; return auths;
} }
/**
* Method getLoggedPlayers.
* @return List<PlayerAuth>
* @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
*/
@Override @Override
public List<PlayerAuth> getLoggedPlayers() { public List<PlayerAuth> getLoggedPlayers() {
return new ArrayList<>(); return new ArrayList<>();

View File

@ -19,6 +19,8 @@ import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.security.HashAlgorithm; import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
/**
*/
public class MySQL implements DataSource { public class MySQL implements DataSource {
private String host; private String host;
@ -45,6 +47,12 @@ public class MySQL implements DataSource {
private String columnRealName; private String columnRealName;
private int maxConnections; private int maxConnections;
/**
* Constructor for MySQL.
* @throws ClassNotFoundException
* @throws SQLException
* @throws PoolInitializationException
*/
public MySQL() throws ClassNotFoundException, SQLException, PoolInitializationException { public MySQL() throws ClassNotFoundException, SQLException, PoolInitializationException {
this.host = Settings.getMySQLHost; this.host = Settings.getMySQLHost;
this.port = Settings.getMySQLPort; this.port = Settings.getMySQLPort;
@ -98,6 +106,11 @@ public class MySQL implements DataSource {
} }
} }
/**
* Method setConnectionArguments.
* @throws ClassNotFoundException
* @throws IllegalArgumentException
*/
private synchronized void setConnectionArguments() private synchronized void setConnectionArguments()
throws ClassNotFoundException, IllegalArgumentException { throws ClassNotFoundException, IllegalArgumentException {
HikariConfig config = new HikariConfig(); HikariConfig config = new HikariConfig();
@ -117,6 +130,11 @@ public class MySQL implements DataSource {
ConsoleLogger.info("Connection arguments loaded, Hikari ConnectionPool ready!"); ConsoleLogger.info("Connection arguments loaded, Hikari ConnectionPool ready!");
} }
/**
* Method reloadArguments.
* @throws ClassNotFoundException
* @throws IllegalArgumentException
*/
private synchronized void reloadArguments() private synchronized void reloadArguments()
throws ClassNotFoundException, IllegalArgumentException { throws ClassNotFoundException, IllegalArgumentException {
if (ds != null) { if (ds != null) {
@ -126,10 +144,19 @@ public class MySQL implements DataSource {
ConsoleLogger.info("Hikari ConnectionPool arguments reloaded!"); ConsoleLogger.info("Hikari ConnectionPool arguments reloaded!");
} }
/**
* Method getConnection.
* @return Connection
* @throws SQLException
*/
private synchronized Connection getConnection() throws SQLException { private synchronized Connection getConnection() throws SQLException {
return ds.getConnection(); return ds.getConnection();
} }
/**
* Method setupConnection.
* @throws SQLException
*/
private synchronized void setupConnection() throws SQLException { private synchronized void setupConnection() throws SQLException {
Connection con = null; Connection con = null;
Statement st = null; Statement st = null;
@ -193,6 +220,12 @@ public class MySQL implements DataSource {
ConsoleLogger.info("MySQL Setup finished"); ConsoleLogger.info("MySQL Setup finished");
} }
/**
* Method isAuthAvailable.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
*/
@Override @Override
public synchronized boolean isAuthAvailable(String user) { public synchronized boolean isAuthAvailable(String user) {
Connection con = null; Connection con = null;
@ -215,6 +248,12 @@ public class MySQL implements DataSource {
} }
} }
/**
* Method getAuth.
* @param user String
* @return PlayerAuth
* @see fr.xephi.authme.datasource.DataSource#getAuth(String)
*/
@Override @Override
public synchronized PlayerAuth getAuth(String user) { public synchronized PlayerAuth getAuth(String user) {
Connection con = null; Connection con = null;
@ -268,6 +307,12 @@ public class MySQL implements DataSource {
return pAuth; return pAuth;
} }
/**
* Method saveAuth.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
*/
@Override @Override
public synchronized boolean saveAuth(PlayerAuth auth) { public synchronized boolean saveAuth(PlayerAuth auth) {
Connection con = null; Connection con = null;
@ -475,6 +520,12 @@ public class MySQL implements DataSource {
return true; return true;
} }
/**
* Method updatePassword.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
*/
@Override @Override
public synchronized boolean updatePassword(PlayerAuth auth) { public synchronized boolean updatePassword(PlayerAuth auth) {
Connection con = null; Connection con = null;
@ -520,6 +571,12 @@ public class MySQL implements DataSource {
return true; return true;
} }
/**
* Method updateSession.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
*/
@Override @Override
public synchronized boolean updateSession(PlayerAuth auth) { public synchronized boolean updateSession(PlayerAuth auth) {
Connection con = null; Connection con = null;
@ -543,6 +600,12 @@ public class MySQL implements DataSource {
return true; return true;
} }
/**
* Method purgeDatabase.
* @param until long
* @return int
* @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
*/
@Override @Override
public synchronized int purgeDatabase(long until) { public synchronized int purgeDatabase(long until) {
Connection con = null; Connection con = null;
@ -562,6 +625,12 @@ public class MySQL implements DataSource {
} }
} }
/**
* Method autoPurgeDatabase.
* @param until long
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
*/
@Override @Override
public synchronized List<String> autoPurgeDatabase(long until) { public synchronized List<String> autoPurgeDatabase(long until) {
Connection con = null; Connection con = null;
@ -592,6 +661,12 @@ public class MySQL implements DataSource {
} }
} }
/**
* Method removeAuth.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
*/
@Override @Override
public synchronized boolean removeAuth(String user) { public synchronized boolean removeAuth(String user) {
Connection con = null; Connection con = null;
@ -629,6 +704,12 @@ public class MySQL implements DataSource {
return true; return true;
} }
/**
* Method updateQuitLoc.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
*/
@Override @Override
public synchronized boolean updateQuitLoc(PlayerAuth auth) { public synchronized boolean updateQuitLoc(PlayerAuth auth) {
Connection con = null; Connection con = null;
@ -653,6 +734,12 @@ public class MySQL implements DataSource {
return true; return true;
} }
/**
* Method getIps.
* @param ip String
* @return int
* @see fr.xephi.authme.datasource.DataSource#getIps(String)
*/
@Override @Override
public synchronized int getIps(String ip) { public synchronized int getIps(String ip) {
Connection con = null; Connection con = null;
@ -679,6 +766,12 @@ public class MySQL implements DataSource {
} }
} }
/**
* Method updateEmail.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
*/
@Override @Override
public synchronized boolean updateEmail(PlayerAuth auth) { public synchronized boolean updateEmail(PlayerAuth auth) {
Connection con = null; Connection con = null;
@ -701,6 +794,12 @@ public class MySQL implements DataSource {
return true; return true;
} }
/**
* Method updateSalt.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
*/
@Override @Override
public synchronized boolean updateSalt(PlayerAuth auth) { public synchronized boolean updateSalt(PlayerAuth auth) {
if (columnSalt.isEmpty()) { if (columnSalt.isEmpty()) {
@ -725,6 +824,10 @@ public class MySQL implements DataSource {
return true; return true;
} }
/**
* Method reload.
* @see fr.xephi.authme.datasource.DataSource#reload()
*/
@Override @Override
public void reload() { public void reload() {
try { try {
@ -740,12 +843,20 @@ public class MySQL implements DataSource {
} }
} }
/**
* Method close.
* @see fr.xephi.authme.datasource.DataSource#close()
*/
@Override @Override
public synchronized void close() { public synchronized void close() {
if (ds != null && !ds.isClosed()) if (ds != null && !ds.isClosed())
ds.close(); ds.close();
} }
/**
* Method close.
* @param o AutoCloseable
*/
private void close(AutoCloseable o) { private void close(AutoCloseable o) {
if (o != null) { if (o != null) {
try { try {
@ -757,6 +868,12 @@ public class MySQL implements DataSource {
} }
} }
/**
* Method getAllAuthsByName.
* @param auth PlayerAuth
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
*/
@Override @Override
public synchronized List<String> getAllAuthsByName(PlayerAuth auth) { public synchronized List<String> getAllAuthsByName(PlayerAuth auth) {
Connection con = null; Connection con = null;
@ -783,6 +900,12 @@ public class MySQL implements DataSource {
} }
} }
/**
* Method getAllAuthsByIp.
* @param ip String
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
*/
@Override @Override
public synchronized List<String> getAllAuthsByIp(String ip) { public synchronized List<String> getAllAuthsByIp(String ip) {
Connection con = null; Connection con = null;
@ -809,6 +932,13 @@ public class MySQL implements DataSource {
} }
} }
/**
* Method getAllAuthsByEmail.
* @param email String
* @return List<String>
* @throws SQLException
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
*/
@Override @Override
public synchronized List<String> getAllAuthsByEmail(String email) throws SQLException { public synchronized List<String> getAllAuthsByEmail(String email) throws SQLException {
final Connection con = getConnection(); final Connection con = getConnection();
@ -831,6 +961,11 @@ public class MySQL implements DataSource {
} }
} }
/**
* Method purgeBanned.
* @param banned List<String>
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
*/
@Override @Override
public synchronized void purgeBanned(List<String> banned) { public synchronized void purgeBanned(List<String> banned) {
Connection con = null; Connection con = null;
@ -851,11 +986,22 @@ public class MySQL implements DataSource {
} }
} }
/**
* Method getType.
* @return DataSourceType
* @see fr.xephi.authme.datasource.DataSource#getType()
*/
@Override @Override
public DataSourceType getType() { public DataSourceType getType() {
return DataSourceType.MYSQL; return DataSourceType.MYSQL;
} }
/**
* Method isLogged.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isLogged(String)
*/
@Override @Override
public boolean isLogged(String user) { public boolean isLogged(String user) {
Connection con = null; Connection con = null;
@ -880,6 +1026,11 @@ public class MySQL implements DataSource {
return false; return false;
} }
/**
* Method setLogged.
* @param user String
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
*/
@Override @Override
public void setLogged(String user) { public void setLogged(String user) {
Connection con = null; Connection con = null;
@ -899,6 +1050,11 @@ public class MySQL implements DataSource {
} }
} }
/**
* Method setUnlogged.
* @param user String
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
*/
@Override @Override
public void setUnlogged(String user) { public void setUnlogged(String user) {
Connection con = null; Connection con = null;
@ -919,6 +1075,10 @@ public class MySQL implements DataSource {
} }
} }
/**
* Method purgeLogged.
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
*/
@Override @Override
public void purgeLogged() { public void purgeLogged() {
Connection con = null; Connection con = null;
@ -938,6 +1098,11 @@ public class MySQL implements DataSource {
} }
} }
/**
* Method getAccountsRegistered.
* @return int
* @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
*/
@Override @Override
public int getAccountsRegistered() { public int getAccountsRegistered() {
int result = 0; int result = 0;
@ -962,6 +1127,12 @@ public class MySQL implements DataSource {
return result; return result;
} }
/**
* Method updateName.
* @param oldone String
* @param newone String
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
*/
@Override @Override
public void updateName(String oldone, String newone) { public void updateName(String oldone, String newone) {
Connection con = null; Connection con = null;
@ -981,6 +1152,11 @@ public class MySQL implements DataSource {
} }
} }
/**
* Method getAllAuths.
* @return List<PlayerAuth>
* @see fr.xephi.authme.datasource.DataSource#getAllAuths()
*/
@Override @Override
public List<PlayerAuth> getAllAuths() { public List<PlayerAuth> getAllAuths() {
List<PlayerAuth> auths = new ArrayList<>(); List<PlayerAuth> auths = new ArrayList<>();
@ -1032,6 +1208,11 @@ public class MySQL implements DataSource {
return auths; return auths;
} }
/**
* Method getLoggedPlayers.
* @return List<PlayerAuth>
* @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
*/
@Override @Override
public List<PlayerAuth> getLoggedPlayers() { public List<PlayerAuth> getLoggedPlayers() {
List<PlayerAuth> auths = new ArrayList<>(); List<PlayerAuth> auths = new ArrayList<>();

View File

@ -13,6 +13,8 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth; import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
/**
*/
public class SQLite implements DataSource { public class SQLite implements DataSource {
private String database; private String database;
@ -33,6 +35,11 @@ public class SQLite implements DataSource {
private String columnLogged; private String columnLogged;
private String columnRealName; private String columnRealName;
/**
* Constructor for SQLite.
* @throws ClassNotFoundException
* @throws SQLException
*/
public SQLite() throws ClassNotFoundException, SQLException { public SQLite() throws ClassNotFoundException, SQLException {
this.database = Settings.getMySQLDatabase; this.database = Settings.getMySQLDatabase;
this.tableName = Settings.getMySQLTablename; this.tableName = Settings.getMySQLTablename;
@ -60,6 +67,11 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method connect.
* @throws ClassNotFoundException
* @throws SQLException
*/
private synchronized void connect() throws ClassNotFoundException, SQLException { private synchronized void connect() throws ClassNotFoundException, SQLException {
Class.forName("org.sqlite.JDBC"); Class.forName("org.sqlite.JDBC");
ConsoleLogger.info("SQLite driver loaded"); ConsoleLogger.info("SQLite driver loaded");
@ -67,6 +79,10 @@ public class SQLite implements DataSource {
} }
/**
* Method setup.
* @throws SQLException
*/
private synchronized void setup() throws SQLException { private synchronized void setup() throws SQLException {
Statement st = null; Statement st = null;
ResultSet rs = null; ResultSet rs = null;
@ -121,6 +137,12 @@ public class SQLite implements DataSource {
ConsoleLogger.info("SQLite Setup finished"); ConsoleLogger.info("SQLite Setup finished");
} }
/**
* Method isAuthAvailable.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
*/
@Override @Override
public synchronized boolean isAuthAvailable(String user) { public synchronized boolean isAuthAvailable(String user) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -139,6 +161,12 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getAuth.
* @param user String
* @return PlayerAuth
* @see fr.xephi.authme.datasource.DataSource#getAuth(String)
*/
@Override @Override
public synchronized PlayerAuth getAuth(String user) { public synchronized PlayerAuth getAuth(String user) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -169,6 +197,12 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method saveAuth.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
*/
@Override @Override
public synchronized boolean saveAuth(PlayerAuth auth) { public synchronized boolean saveAuth(PlayerAuth auth) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -200,6 +234,12 @@ public class SQLite implements DataSource {
return true; return true;
} }
/**
* Method updatePassword.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
*/
@Override @Override
public synchronized boolean updatePassword(PlayerAuth auth) { public synchronized boolean updatePassword(PlayerAuth auth) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -217,6 +257,12 @@ public class SQLite implements DataSource {
return true; return true;
} }
/**
* Method updateSession.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
*/
@Override @Override
public boolean updateSession(PlayerAuth auth) { public boolean updateSession(PlayerAuth auth) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -236,6 +282,12 @@ public class SQLite implements DataSource {
return true; return true;
} }
/**
* Method purgeDatabase.
* @param until long
* @return int
* @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
*/
@Override @Override
public int purgeDatabase(long until) { public int purgeDatabase(long until) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -252,6 +304,12 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method autoPurgeDatabase.
* @param until long
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
*/
@Override @Override
public List<String> autoPurgeDatabase(long until) { public List<String> autoPurgeDatabase(long until) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -274,6 +332,12 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method removeAuth.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
*/
@Override @Override
public synchronized boolean removeAuth(String user) { public synchronized boolean removeAuth(String user) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -290,6 +354,12 @@ public class SQLite implements DataSource {
return true; return true;
} }
/**
* Method updateQuitLoc.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
*/
@Override @Override
public boolean updateQuitLoc(PlayerAuth auth) { public boolean updateQuitLoc(PlayerAuth auth) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -310,6 +380,12 @@ public class SQLite implements DataSource {
return true; return true;
} }
/**
* Method getIps.
* @param ip String
* @return int
* @see fr.xephi.authme.datasource.DataSource#getIps(String)
*/
@Override @Override
public int getIps(String ip) { public int getIps(String ip) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -332,6 +408,12 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method updateEmail.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
*/
@Override @Override
public boolean updateEmail(PlayerAuth auth) { public boolean updateEmail(PlayerAuth auth) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -349,6 +431,12 @@ public class SQLite implements DataSource {
return true; return true;
} }
/**
* Method updateSalt.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
*/
@Override @Override
public boolean updateSalt(PlayerAuth auth) { public boolean updateSalt(PlayerAuth auth) {
if (columnSalt.isEmpty()) { if (columnSalt.isEmpty()) {
@ -369,6 +457,10 @@ public class SQLite implements DataSource {
return true; return true;
} }
/**
* Method close.
* @see fr.xephi.authme.datasource.DataSource#close()
*/
@Override @Override
public synchronized void close() { public synchronized void close() {
try { try {
@ -378,10 +470,18 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method reload.
* @see fr.xephi.authme.datasource.DataSource#reload()
*/
@Override @Override
public void reload() { public void reload() {
} }
/**
* Method close.
* @param st Statement
*/
private void close(Statement st) { private void close(Statement st) {
if (st != null) { if (st != null) {
try { try {
@ -392,6 +492,10 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method close.
* @param rs ResultSet
*/
private void close(ResultSet rs) { private void close(ResultSet rs) {
if (rs != null) { if (rs != null) {
try { try {
@ -402,6 +506,12 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getAllAuthsByName.
* @param auth PlayerAuth
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
*/
@Override @Override
public List<String> getAllAuthsByName(PlayerAuth auth) { public List<String> getAllAuthsByName(PlayerAuth auth) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -426,6 +536,12 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getAllAuthsByIp.
* @param ip String
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
*/
@Override @Override
public List<String> getAllAuthsByIp(String ip) { public List<String> getAllAuthsByIp(String ip) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -450,6 +566,12 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getAllAuthsByEmail.
* @param email String
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
*/
@Override @Override
public List<String> getAllAuthsByEmail(String email) { public List<String> getAllAuthsByEmail(String email) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -474,6 +596,11 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method purgeBanned.
* @param banned List<String>
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
*/
@Override @Override
public void purgeBanned(List<String> banned) { public void purgeBanned(List<String> banned) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -490,11 +617,22 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getType.
* @return DataSourceType
* @see fr.xephi.authme.datasource.DataSource#getType()
*/
@Override @Override
public DataSourceType getType() { public DataSourceType getType() {
return DataSourceType.SQLITE; return DataSourceType.SQLITE;
} }
/**
* Method isLogged.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isLogged(String)
*/
@Override @Override
public boolean isLogged(String user) { public boolean isLogged(String user) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -515,6 +653,11 @@ public class SQLite implements DataSource {
return false; return false;
} }
/**
* Method setLogged.
* @param user String
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
*/
@Override @Override
public void setLogged(String user) { public void setLogged(String user) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -530,6 +673,11 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method setUnlogged.
* @param user String
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
*/
@Override @Override
public void setUnlogged(String user) { public void setUnlogged(String user) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -546,6 +694,10 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method purgeLogged.
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
*/
@Override @Override
public void purgeLogged() { public void purgeLogged() {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -561,6 +713,11 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getAccountsRegistered.
* @return int
* @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
*/
@Override @Override
public int getAccountsRegistered() { public int getAccountsRegistered() {
int result = 0; int result = 0;
@ -581,6 +738,12 @@ public class SQLite implements DataSource {
return result; return result;
} }
/**
* Method updateName.
* @param oldone String
* @param newone String
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
*/
@Override @Override
public void updateName(String oldone, String newone) { public void updateName(String oldone, String newone) {
PreparedStatement pst = null; PreparedStatement pst = null;
@ -596,6 +759,11 @@ public class SQLite implements DataSource {
} }
} }
/**
* Method getAllAuths.
* @return List<PlayerAuth>
* @see fr.xephi.authme.datasource.DataSource#getAllAuths()
*/
@Override @Override
public List<PlayerAuth> getAllAuths() { public List<PlayerAuth> getAllAuths() {
List<PlayerAuth> auths = new ArrayList<>(); List<PlayerAuth> auths = new ArrayList<>();
@ -626,6 +794,11 @@ public class SQLite implements DataSource {
return auths; return auths;
} }
/**
* Method getLoggedPlayers.
* @return List<PlayerAuth>
* @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
*/
@Override @Override
public List<PlayerAuth> getLoggedPlayers() { public List<PlayerAuth> getLoggedPlayers() {
List<PlayerAuth> auths = new ArrayList<>(); List<PlayerAuth> auths = new ArrayList<>();

View File

@ -9,6 +9,7 @@ import org.bukkit.event.HandlerList;
* This event is call when a player try to /login * This event is call when a player try to /login
* *
* @author Xephi59 * @author Xephi59
* @version $Revision: 1.0 $
*/ */
public class AuthMeAsyncPreLoginEvent extends Event { public class AuthMeAsyncPreLoginEvent extends Event {
@ -16,23 +17,43 @@ public class AuthMeAsyncPreLoginEvent extends Event {
private boolean canLogin = true; private boolean canLogin = true;
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
/**
* Constructor for AuthMeAsyncPreLoginEvent.
* @param player Player
*/
public AuthMeAsyncPreLoginEvent(Player player) { public AuthMeAsyncPreLoginEvent(Player player) {
super(true); super(true);
this.player = player; this.player = player;
} }
/**
* Method getPlayer.
* @return Player
*/
public Player getPlayer() { public Player getPlayer() {
return player; return player;
} }
/**
* Method canLogin.
* @return boolean
*/
public boolean canLogin() { public boolean canLogin() {
return canLogin; return canLogin;
} }
/**
* Method setCanLogin.
* @param canLogin boolean
*/
public void setCanLogin(boolean canLogin) { public void setCanLogin(boolean canLogin) {
this.canLogin = canLogin; this.canLogin = canLogin;
} }
/**
* Method getHandlers.
* @return HandlerList
*/
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
* This event is call when AuthMe try to teleport a player * This event is call when AuthMe try to teleport a player
* *
* @author Xephi59 * @author Xephi59
* @version $Revision: 1.0 $
*/ */
public class AuthMeTeleportEvent extends CustomEvent { public class AuthMeTeleportEvent extends CustomEvent {
@ -15,24 +16,45 @@ public class AuthMeTeleportEvent extends CustomEvent {
private Location to; private Location to;
private Location from; private Location from;
/**
* Constructor for AuthMeTeleportEvent.
* @param player Player
* @param to Location
*/
public AuthMeTeleportEvent(Player player, Location to) { public AuthMeTeleportEvent(Player player, Location to) {
this.player = player; this.player = player;
this.from = player.getLocation(); this.from = player.getLocation();
this.to = to; this.to = to;
} }
/**
* Method getPlayer.
* @return Player
*/
public Player getPlayer() { public Player getPlayer() {
return player; return player;
} }
/**
* Method setTo.
* @param to Location
*/
public void setTo(Location to) { public void setTo(Location to) {
this.to = to; this.to = to;
} }
/**
* Method getTo.
* @return Location
*/
public Location getTo() { public Location getTo() {
return to; return to;
} }
/**
* Method getFrom.
* @return Location
*/
public Location getFrom() { public Location getFrom() {
return from; return from;
} }

View File

@ -7,6 +7,7 @@ import org.bukkit.event.HandlerList;
/** /**
* *
* @author Xephi59 * @author Xephi59
* @version $Revision: 1.0 $
*/ */
public class CustomEvent extends Event implements Cancellable { public class CustomEvent extends Event implements Cancellable {
@ -17,22 +18,44 @@ public class CustomEvent extends Event implements Cancellable {
super(false); super(false);
} }
/**
* Constructor for CustomEvent.
* @param b boolean
*/
public CustomEvent(boolean b) { public CustomEvent(boolean b) {
super(b); super(b);
} }
/**
* Method getHandlers.
* @return HandlerList
*/
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
/**
* Method getHandlerList.
* @return HandlerList
*/
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }
/**
* Method isCancelled.
* @return boolean
* @see org.bukkit.event.Cancellable#isCancelled()
*/
public boolean isCancelled() { public boolean isCancelled() {
return this.isCancelled; return this.isCancelled;
} }
/**
* Method setCancelled.
* @param cancelled boolean
* @see org.bukkit.event.Cancellable#setCancelled(boolean)
*/
public void setCancelled(boolean cancelled) { public void setCancelled(boolean cancelled) {
this.isCancelled = cancelled; this.isCancelled = cancelled;
} }

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
* Called if a player is teleported to the authme first spawn * Called if a player is teleported to the authme first spawn
* *
* @author Xephi59 * @author Xephi59
* @version $Revision: 1.0 $
*/ */
public class FirstSpawnTeleportEvent extends CustomEvent { public class FirstSpawnTeleportEvent extends CustomEvent {
@ -15,6 +16,12 @@ public class FirstSpawnTeleportEvent extends CustomEvent {
private Location to; private Location to;
private Location from; private Location from;
/**
* Constructor for FirstSpawnTeleportEvent.
* @param player Player
* @param from Location
* @param to Location
*/
public FirstSpawnTeleportEvent(Player player, Location from, Location to) { public FirstSpawnTeleportEvent(Player player, Location from, Location to) {
super(true); super(true);
this.player = player; this.player = player;
@ -22,18 +29,34 @@ public class FirstSpawnTeleportEvent extends CustomEvent {
this.to = to; this.to = to;
} }
/**
* Method getPlayer.
* @return Player
*/
public Player getPlayer() { public Player getPlayer() {
return player; return player;
} }
/**
* Method setTo.
* @param to Location
*/
public void setTo(Location to) { public void setTo(Location to) {
this.to = to; this.to = to;
} }
/**
* Method getTo.
* @return Location
*/
public Location getTo() { public Location getTo() {
return to; return to;
} }
/**
* Method getFrom.
* @return Location
*/
public Location getFrom() { public Location getFrom() {
return from; return from;
} }

View File

@ -10,6 +10,7 @@ import org.bukkit.event.HandlerList;
* boolean 'isLogin' will be false if, and only if, login/register failed. * boolean 'isLogin' will be false if, and only if, login/register failed.
* *
* @author Xephi59 * @author Xephi59
* @version $Revision: 1.0 $
*/ */
public class LoginEvent extends Event { public class LoginEvent extends Event {
@ -17,33 +18,62 @@ public class LoginEvent extends Event {
private boolean isLogin; private boolean isLogin;
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
/**
* Constructor for LoginEvent.
* @param player Player
* @param isLogin boolean
*/
public LoginEvent(Player player, boolean isLogin) { public LoginEvent(Player player, boolean isLogin) {
this.player = player; this.player = player;
this.isLogin = isLogin; this.isLogin = isLogin;
} }
/**
* Method getPlayer.
* @return Player
*/
public Player getPlayer() { public Player getPlayer() {
return this.player; return this.player;
} }
/**
* Method setPlayer.
* @param player Player
*/
public void setPlayer(Player player) { public void setPlayer(Player player) {
this.player = player; this.player = player;
} }
/**
* Method setLogin.
* @param isLogin boolean
*/
@Deprecated @Deprecated
public void setLogin(boolean isLogin) { public void setLogin(boolean isLogin) {
this.isLogin = isLogin; this.isLogin = isLogin;
} }
/**
* Method isLogin.
* @return boolean
*/
public boolean isLogin() { public boolean isLogin() {
return isLogin; return isLogin;
} }
/**
* Method getHandlers.
* @return HandlerList
*/
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
/**
* Method getHandlerList.
* @return HandlerList
*/
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }

View File

@ -9,29 +9,50 @@ import org.bukkit.event.HandlerList;
* This event is called when a player logout through AuthMe. * This event is called when a player logout through AuthMe.
* *
* @author Xephi59 * @author Xephi59
* @version $Revision: 1.0 $
*/ */
public class LogoutEvent extends Event { public class LogoutEvent extends Event {
private Player player; private Player player;
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
/**
* Constructor for LogoutEvent.
* @param player Player
*/
public LogoutEvent(Player player) { public LogoutEvent(Player player) {
this.player = player; this.player = player;
} }
/**
* Method getPlayer.
* @return Player
*/
public Player getPlayer() { public Player getPlayer() {
return this.player; return this.player;
} }
/**
* Method setPlayer.
* @param player Player
*/
public void setPlayer(Player player) { public void setPlayer(Player player) {
this.player = player; this.player = player;
} }
/**
* Method getHandlers.
* @return HandlerList
*/
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
/**
* Method getHandlerList.
* @return HandlerList
*/
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }

View File

@ -14,6 +14,7 @@ import fr.xephi.authme.security.crypts.EncryptionMethod;
* @see fr.xephi.authme.security.crypts.EncryptionMethod * @see fr.xephi.authme.security.crypts.EncryptionMethod
* *
* @author Xephi59 * @author Xephi59
* @version $Revision: 1.0 $
*/ */
public class PasswordEncryptionEvent extends Event { public class PasswordEncryptionEvent extends Event {
@ -21,29 +22,54 @@ public class PasswordEncryptionEvent extends Event {
private EncryptionMethod method = null; private EncryptionMethod method = null;
private String playerName = ""; private String playerName = "";
/**
* Constructor for PasswordEncryptionEvent.
* @param method EncryptionMethod
* @param playerName String
*/
public PasswordEncryptionEvent(EncryptionMethod method, String playerName) { public PasswordEncryptionEvent(EncryptionMethod method, String playerName) {
super(false); super(false);
this.method = method; this.method = method;
this.playerName = playerName; this.playerName = playerName;
} }
/**
* Method getHandlers.
* @return HandlerList
*/
@Override @Override
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
/**
* Method setMethod.
* @param method EncryptionMethod
*/
public void setMethod(EncryptionMethod method) { public void setMethod(EncryptionMethod method) {
this.method = method; this.method = method;
} }
/**
* Method getMethod.
* @return EncryptionMethod
*/
public EncryptionMethod getMethod() { public EncryptionMethod getMethod() {
return method; return method;
} }
/**
* Method getPlayerName.
* @return String
*/
public String getPlayerName() { public String getPlayerName() {
return playerName; return playerName;
} }
/**
* Method getHandlerList.
* @return HandlerList
*/
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }

View File

@ -9,6 +9,7 @@ import org.bukkit.inventory.ItemStack;
* player inventory. * player inventory.
* *
* @author Xephi59 * @author Xephi59
* @version $Revision: 1.0 $
*/ */
public class ProtectInventoryEvent extends CustomEvent { public class ProtectInventoryEvent extends CustomEvent {
@ -18,6 +19,10 @@ public class ProtectInventoryEvent extends CustomEvent {
private ItemStack[] emptyArmor = null; private ItemStack[] emptyArmor = null;
private Player player; private Player player;
/**
* Constructor for ProtectInventoryEvent.
* @param player Player
*/
public ProtectInventoryEvent(Player player) { public ProtectInventoryEvent(Player player) {
super(true); super(true);
this.player = player; this.player = player;
@ -27,30 +32,58 @@ public class ProtectInventoryEvent extends CustomEvent {
this.emptyArmor = new ItemStack[4]; this.emptyArmor = new ItemStack[4];
} }
/**
* Method getStoredInventory.
* @return ItemStack[]
*/
public ItemStack[] getStoredInventory() { public ItemStack[] getStoredInventory() {
return this.storedinventory; return this.storedinventory;
} }
/**
* Method getStoredArmor.
* @return ItemStack[]
*/
public ItemStack[] getStoredArmor() { public ItemStack[] getStoredArmor() {
return this.storedarmor; return this.storedarmor;
} }
/**
* Method getPlayer.
* @return Player
*/
public Player getPlayer() { public Player getPlayer() {
return this.player; return this.player;
} }
/**
* Method setNewInventory.
* @param emptyInventory ItemStack[]
*/
public void setNewInventory(ItemStack[] emptyInventory) { public void setNewInventory(ItemStack[] emptyInventory) {
this.emptyInventory = emptyInventory; this.emptyInventory = emptyInventory;
} }
/**
* Method getEmptyInventory.
* @return ItemStack[]
*/
public ItemStack[] getEmptyInventory() { public ItemStack[] getEmptyInventory() {
return this.emptyInventory; return this.emptyInventory;
} }
/**
* Method setNewArmor.
* @param emptyArmor ItemStack[]
*/
public void setNewArmor(ItemStack[] emptyArmor) { public void setNewArmor(ItemStack[] emptyArmor) {
this.emptyArmor = emptyArmor; this.emptyArmor = emptyArmor;
} }
/**
* Method getEmptyArmor.
* @return ItemStack[]
*/
public ItemStack[] getEmptyArmor() { public ItemStack[] getEmptyArmor() {
return this.emptyArmor; return this.emptyArmor;
} }

View File

@ -9,6 +9,7 @@ import org.bukkit.entity.Player;
* register. * register.
* *
* @author Xephi59 * @author Xephi59
* @version $Revision: 1.0 $
*/ */
public class RegisterTeleportEvent extends CustomEvent { public class RegisterTeleportEvent extends CustomEvent {
@ -16,24 +17,45 @@ public class RegisterTeleportEvent extends CustomEvent {
private Location to; private Location to;
private Location from; private Location from;
/**
* Constructor for RegisterTeleportEvent.
* @param player Player
* @param to Location
*/
public RegisterTeleportEvent(Player player, Location to) { public RegisterTeleportEvent(Player player, Location to) {
this.player = player; this.player = player;
this.from = player.getLocation(); this.from = player.getLocation();
this.to = to; this.to = to;
} }
/**
* Method getPlayer.
* @return Player
*/
public Player getPlayer() { public Player getPlayer() {
return player; return player;
} }
/**
* Method setTo.
* @param to Location
*/
public void setTo(Location to) { public void setTo(Location to) {
this.to = to; this.to = to;
} }
/**
* Method getTo.
* @return Location
*/
public Location getTo() { public Location getTo() {
return to; return to;
} }
/**
* Method getFrom.
* @return Location
*/
public Location getFrom() { public Location getFrom() {
return from; return from;
} }

View File

@ -7,20 +7,33 @@ import org.bukkit.entity.Player;
* This event is call when a creative inventory is reseted. * This event is call when a creative inventory is reseted.
* *
* @author Xephi59 * @author Xephi59
* @version $Revision: 1.0 $
*/ */
public class ResetInventoryEvent extends CustomEvent { public class ResetInventoryEvent extends CustomEvent {
private Player player; private Player player;
/**
* Constructor for ResetInventoryEvent.
* @param player Player
*/
public ResetInventoryEvent(Player player) { public ResetInventoryEvent(Player player) {
super(true); super(true);
this.player = player; this.player = player;
} }
/**
* Method getPlayer.
* @return Player
*/
public Player getPlayer() { public Player getPlayer() {
return this.player; return this.player;
} }
/**
* Method setPlayer.
* @param player Player
*/
public void setPlayer(Player player) { public void setPlayer(Player player) {
this.player = player; this.player = player;
} }

View File

@ -6,24 +6,42 @@ import org.bukkit.entity.Player;
* This event restore the inventory. * This event restore the inventory.
* *
* @author Xephi59 * @author Xephi59
* @version $Revision: 1.0 $
*/ */
public class RestoreInventoryEvent extends CustomEvent { public class RestoreInventoryEvent extends CustomEvent {
private Player player; private Player player;
/**
* Constructor for RestoreInventoryEvent.
* @param player Player
*/
public RestoreInventoryEvent(Player player) { public RestoreInventoryEvent(Player player) {
this.player = player; this.player = player;
} }
/**
* Constructor for RestoreInventoryEvent.
* @param player Player
* @param async boolean
*/
public RestoreInventoryEvent(Player player, boolean async) { public RestoreInventoryEvent(Player player, boolean async) {
super(async); super(async);
this.player = player; this.player = player;
} }
/**
* Method getPlayer.
* @return Player
*/
public Player getPlayer() { public Player getPlayer() {
return this.player; return this.player;
} }
/**
* Method setPlayer.
* @param player Player
*/
public void setPlayer(Player player) { public void setPlayer(Player player) {
this.player = player; this.player = player;
} }

View File

@ -8,6 +8,7 @@ import org.bukkit.entity.Player;
* Called if a player is teleported to a specific spawn * Called if a player is teleported to a specific spawn
* *
* @author Xephi59 * @author Xephi59
* @version $Revision: 1.0 $
*/ */
public class SpawnTeleportEvent extends CustomEvent { public class SpawnTeleportEvent extends CustomEvent {
@ -16,6 +17,13 @@ public class SpawnTeleportEvent extends CustomEvent {
private Location from; private Location from;
private boolean isAuthenticated; private boolean isAuthenticated;
/**
* Constructor for SpawnTeleportEvent.
* @param player Player
* @param from Location
* @param to Location
* @param isAuthenticated boolean
*/
public SpawnTeleportEvent(Player player, Location from, Location to, public SpawnTeleportEvent(Player player, Location from, Location to,
boolean isAuthenticated) { boolean isAuthenticated) {
this.player = player; this.player = player;
@ -24,22 +32,42 @@ public class SpawnTeleportEvent extends CustomEvent {
this.isAuthenticated = isAuthenticated; this.isAuthenticated = isAuthenticated;
} }
/**
* Method getPlayer.
* @return Player
*/
public Player getPlayer() { public Player getPlayer() {
return player; return player;
} }
/**
* Method setTo.
* @param to Location
*/
public void setTo(Location to) { public void setTo(Location to) {
this.to = to; this.to = to;
} }
/**
* Method getTo.
* @return Location
*/
public Location getTo() { public Location getTo() {
return to; return to;
} }
/**
* Method getFrom.
* @return Location
*/
public Location getFrom() { public Location getFrom() {
return from; return from;
} }
/**
* Method isAuthenticated.
* @return boolean
*/
public boolean isAuthenticated() { public boolean isAuthenticated() {
return isAuthenticated; return isAuthenticated;
} }

View File

@ -8,14 +8,27 @@ import com.google.common.io.ByteStreams;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
/**
*/
public class BungeeCordMessage implements PluginMessageListener { public class BungeeCordMessage implements PluginMessageListener {
public AuthMe plugin; public AuthMe plugin;
/**
* Constructor for BungeeCordMessage.
* @param plugin AuthMe
*/
public BungeeCordMessage(AuthMe plugin) { public BungeeCordMessage(AuthMe plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
/**
* Method onPluginMessageReceived.
* @param channel String
* @param player Player
* @param message byte[]
* @see org.bukkit.plugin.messaging.PluginMessageListener#onPluginMessageReceived(String, Player, byte[])
*/
@Override @Override
public void onPluginMessageReceived(String channel, Player player, public void onPluginMessageReceived(String channel, Player player,
byte[] message) { byte[] message) {

View File

@ -7,6 +7,8 @@ import org.bukkit.Location;
import fr.xephi.authme.settings.CustomConfiguration; import fr.xephi.authme.settings.CustomConfiguration;
/**
*/
public class EssSpawn extends CustomConfiguration { public class EssSpawn extends CustomConfiguration {
private static EssSpawn spawn; private static EssSpawn spawn;
@ -17,6 +19,10 @@ public class EssSpawn extends CustomConfiguration {
load(); load();
} }
/**
* Method getInstance.
* @return EssSpawn
*/
public static EssSpawn getInstance() { public static EssSpawn getInstance() {
if (spawn == null) { if (spawn == null) {
spawn = new EssSpawn(); spawn = new EssSpawn();
@ -24,6 +30,10 @@ public class EssSpawn extends CustomConfiguration {
return spawn; return spawn;
} }
/**
* Method getLocation.
* @return Location
*/
public Location getLocation() { public Location getLocation() {
try { try {
if (!this.contains("spawns.default.world")) if (!this.contains("spawns.default.world"))

View File

@ -9,15 +9,25 @@ import org.bukkit.event.block.BlockPlaceEvent;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.util.Utils; import fr.xephi.authme.util.Utils;
/**
*/
public class AuthMeBlockListener implements Listener { public class AuthMeBlockListener implements Listener {
public AuthMe instance; public AuthMe instance;
/**
* Constructor for AuthMeBlockListener.
* @param instance AuthMe
*/
public AuthMeBlockListener(AuthMe instance) { public AuthMeBlockListener(AuthMe instance) {
this.instance = instance; this.instance = instance;
} }
/**
* Method onBlockPlace.
* @param event BlockPlaceEvent
*/
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) { public void onBlockPlace(BlockPlaceEvent event) {
if (Utils.checkAuth(event.getPlayer())) if (Utils.checkAuth(event.getPlayer()))
@ -25,6 +35,10 @@ public class AuthMeBlockListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method onBlockBreak.
* @param event BlockBreakEvent
*/
@EventHandler(ignoreCancelled = true) @EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) { public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();

View File

@ -22,12 +22,18 @@ import org.bukkit.projectiles.ProjectileSource;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.util.Utils; import fr.xephi.authme.util.Utils;
/**
*/
public class AuthMeEntityListener implements Listener { public class AuthMeEntityListener implements Listener {
public AuthMe instance; public AuthMe instance;
private static Method getShooter; private static Method getShooter;
private static boolean shooterIsProjectileSource; private static boolean shooterIsProjectileSource;
/**
* Constructor for AuthMeEntityListener.
* @param instance AuthMe
*/
public AuthMeEntityListener(AuthMe instance) { public AuthMeEntityListener(AuthMe instance) {
this.instance = instance; this.instance = instance;
try { try {
@ -37,6 +43,10 @@ public class AuthMeEntityListener implements Listener {
} }
} }
/**
* Method onEntityDamage.
* @param event EntityDamageEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onEntityDamage(EntityDamageEvent event) { public void onEntityDamage(EntityDamageEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
@ -53,6 +63,10 @@ public class AuthMeEntityListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method onEntityTarget.
* @param event EntityTargetEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onEntityTarget(EntityTargetEvent event) { public void onEntityTarget(EntityTargetEvent event) {
Entity entity = event.getTarget(); Entity entity = event.getTarget();
@ -68,6 +82,10 @@ public class AuthMeEntityListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method onDmg.
* @param event EntityDamageByEntityEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onDmg(EntityDamageByEntityEvent event) { public void onDmg(EntityDamageByEntityEvent event) {
Entity entity = event.getDamager(); Entity entity = event.getDamager();
@ -83,6 +101,10 @@ public class AuthMeEntityListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method onFoodLevelChange.
* @param event FoodLevelChangeEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onFoodLevelChange(FoodLevelChangeEvent event) { public void onFoodLevelChange(FoodLevelChangeEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
@ -97,6 +119,10 @@ public class AuthMeEntityListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method entityRegainHealthEvent.
* @param event EntityRegainHealthEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void entityRegainHealthEvent(EntityRegainHealthEvent event) { public void entityRegainHealthEvent(EntityRegainHealthEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
@ -112,6 +138,10 @@ public class AuthMeEntityListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method onEntityInteract.
* @param event EntityInteractEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityInteract(EntityInteractEvent event) { public void onEntityInteract(EntityInteractEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
@ -126,6 +156,10 @@ public class AuthMeEntityListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method onLowestEntityInteract.
* @param event EntityInteractEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onLowestEntityInteract(EntityInteractEvent event) { public void onLowestEntityInteract(EntityInteractEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();
@ -141,6 +175,10 @@ public class AuthMeEntityListener implements Listener {
} }
// TODO: Need to check this, player can't throw snowball but the item is taken. // TODO: Need to check this, player can't throw snowball but the item is taken.
/**
* Method onProjectileLaunch.
* @param event ProjectileLaunchEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onProjectileLaunch(ProjectileLaunchEvent event) { public void onProjectileLaunch(ProjectileLaunchEvent event) {
Projectile projectile = event.getEntity(); Projectile projectile = event.getEntity();
@ -173,6 +211,10 @@ public class AuthMeEntityListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method onShoot.
* @param event EntityShootBowEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onShoot(EntityShootBowEvent event) { public void onShoot(EntityShootBowEvent event) {
Entity entity = event.getEntity(); Entity entity = event.getEntity();

View File

@ -36,6 +36,8 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerCache; import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
/**
*/
public class AuthMeInventoryPacketAdapter extends PacketAdapter { public class AuthMeInventoryPacketAdapter extends PacketAdapter {
private static final int PLAYER_INVENTORY = 0; private static final int PLAYER_INVENTORY = 0;
@ -44,10 +46,19 @@ public class AuthMeInventoryPacketAdapter extends PacketAdapter {
private static final int PLAYER_CRAFTING_SIZE = 5; private static final int PLAYER_CRAFTING_SIZE = 5;
private static final int HOTBAR_SIZE = 9; private static final int HOTBAR_SIZE = 9;
/**
* Constructor for AuthMeInventoryPacketAdapter.
* @param plugin AuthMe
*/
public AuthMeInventoryPacketAdapter(AuthMe plugin) { public AuthMeInventoryPacketAdapter(AuthMe plugin) {
super(plugin, PacketType.Play.Server.SET_SLOT, PacketType.Play.Server.WINDOW_ITEMS); super(plugin, PacketType.Play.Server.SET_SLOT, PacketType.Play.Server.WINDOW_ITEMS);
} }
/**
* Method onPacketSending.
* @param packetEvent PacketEvent
* @see com.comphenix.protocol.events.PacketListener#onPacketSending(PacketEvent)
*/
@Override @Override
public void onPacketSending(PacketEvent packetEvent) { public void onPacketSending(PacketEvent packetEvent) {
Player player = packetEvent.getPlayer(); Player player = packetEvent.getPlayer();
@ -64,6 +75,10 @@ public class AuthMeInventoryPacketAdapter extends PacketAdapter {
ProtocolLibrary.getProtocolManager().addPacketListener(this); ProtocolLibrary.getProtocolManager().addPacketListener(this);
} }
/**
* Method sendInventoryPacket.
* @param player Player
*/
public void sendInventoryPacket(Player player) { public void sendInventoryPacket(Player player) {
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager(); ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
PacketContainer inventoryPacket = protocolManager.createPacket(PacketType.Play.Server.WINDOW_ITEMS); PacketContainer inventoryPacket = protocolManager.createPacket(PacketType.Play.Server.WINDOW_ITEMS);

View File

@ -51,6 +51,8 @@ import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.Utils; import fr.xephi.authme.util.Utils;
/**
*/
public class AuthMePlayerListener implements Listener { public class AuthMePlayerListener implements Listener {
public AuthMe plugin; public AuthMe plugin;
@ -61,10 +63,18 @@ public class AuthMePlayerListener implements Listener {
public static ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>(); public static ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
private List<String> antibot = new ArrayList<>(); private List<String> antibot = new ArrayList<>();
/**
* Constructor for AuthMePlayerListener.
* @param plugin AuthMe
*/
public AuthMePlayerListener(AuthMe plugin) { public AuthMePlayerListener(AuthMe plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
/**
* Method handleChat.
* @param event AsyncPlayerChatEvent
*/
private void handleChat(AsyncPlayerChatEvent event) { private void handleChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -87,6 +97,10 @@ public class AuthMePlayerListener implements Listener {
} }
/**
* Method onPlayerCommandPreprocess.
* @param event PlayerCommandPreprocessEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
String cmd = event.getMessage().split(" ")[0].toLowerCase(); String cmd = event.getMessage().split(" ")[0].toLowerCase();
@ -99,36 +113,64 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method onPlayerNormalChat.
* @param event AsyncPlayerChatEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerNormalChat(AsyncPlayerChatEvent event) { public void onPlayerNormalChat(AsyncPlayerChatEvent event) {
handleChat(event); handleChat(event);
} }
/**
* Method onPlayerHighChat.
* @param event AsyncPlayerChatEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH) @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerHighChat(AsyncPlayerChatEvent event) { public void onPlayerHighChat(AsyncPlayerChatEvent event) {
handleChat(event); handleChat(event);
} }
/**
* Method onPlayerChat.
* @param event AsyncPlayerChatEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerChat(AsyncPlayerChatEvent event) { public void onPlayerChat(AsyncPlayerChatEvent event) {
handleChat(event); handleChat(event);
} }
/**
* Method onPlayerHighestChat.
* @param event AsyncPlayerChatEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerHighestChat(AsyncPlayerChatEvent event) { public void onPlayerHighestChat(AsyncPlayerChatEvent event) {
handleChat(event); handleChat(event);
} }
/**
* Method onPlayerEarlyChat.
* @param event AsyncPlayerChatEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerEarlyChat(AsyncPlayerChatEvent event) { public void onPlayerEarlyChat(AsyncPlayerChatEvent event) {
handleChat(event); handleChat(event);
} }
/**
* Method onPlayerLowChat.
* @param event AsyncPlayerChatEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void onPlayerLowChat(AsyncPlayerChatEvent event) { public void onPlayerLowChat(AsyncPlayerChatEvent event) {
handleChat(event); handleChat(event);
} }
/**
* Method onPlayerMove.
* @param event PlayerMoveEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerMove(PlayerMoveEvent event) { public void onPlayerMove(PlayerMoveEvent event) {
int radius = Settings.getMovementRadius; int radius = Settings.getMovementRadius;
@ -163,6 +205,10 @@ public class AuthMePlayerListener implements Listener {
} }
} }
/**
* Method checkAntiBotMod.
* @param player Player
*/
private void checkAntiBotMod(final Player player) { private void checkAntiBotMod(final Player player) {
if (plugin.delayedAntiBot || plugin.antibotMod) if (plugin.delayedAntiBot || plugin.antibotMod)
return; return;
@ -196,6 +242,10 @@ public class AuthMePlayerListener implements Listener {
}, 300); }, 300);
} }
/**
* Method onPlayerJoin.
* @param event PlayerJoinEvent
*/
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
if (event.getPlayer() == null) if (event.getPlayer() == null)
@ -223,6 +273,10 @@ public class AuthMePlayerListener implements Listener {
}); });
} }
/**
* Method onPreLogin.
* @param event AsyncPlayerPreLoginEvent
*/
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onPreLogin(AsyncPlayerPreLoginEvent event) { public void onPreLogin(AsyncPlayerPreLoginEvent event) {
final String name = event.getName().toLowerCase(); final String name = event.getName().toLowerCase();
@ -250,6 +304,10 @@ public class AuthMePlayerListener implements Listener {
} }
} }
/**
* Method onPlayerLogin.
* @param event PlayerLoginEvent
*/
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerLogin(PlayerLoginEvent event) { public void onPlayerLogin(PlayerLoginEvent event) {
final Player player = event.getPlayer(); final Player player = event.getPlayer();
@ -369,6 +427,10 @@ public class AuthMePlayerListener implements Listener {
} }
} }
/**
* Method onPlayerQuit.
* @param event PlayerQuitEvent
*/
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event) { public void onPlayerQuit(PlayerQuitEvent event) {
if (event.getPlayer() == null) { if (event.getPlayer() == null) {
@ -384,6 +446,10 @@ public class AuthMePlayerListener implements Listener {
plugin.management.performQuit(player, false); plugin.management.performQuit(player, false);
} }
/**
* Method onPlayerKick.
* @param event PlayerKickEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR) @EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerKick(PlayerKickEvent event) { public void onPlayerKick(PlayerKickEvent event) {
if (event.getPlayer() == null) { if (event.getPlayer() == null) {
@ -399,6 +465,10 @@ public class AuthMePlayerListener implements Listener {
plugin.management.performQuit(player, true); plugin.management.performQuit(player, true);
} }
/**
* Method onPlayerPickupItem.
* @param event PlayerPickupItemEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerPickupItem(PlayerPickupItemEvent event) { public void onPlayerPickupItem(PlayerPickupItemEvent event) {
if (Utils.checkAuth(event.getPlayer())) if (Utils.checkAuth(event.getPlayer()))
@ -406,6 +476,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method onPlayerInteract.
* @param event PlayerInteractEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -414,6 +488,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method onPlayerConsumeItem.
* @param event PlayerItemConsumeEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerConsumeItem(PlayerItemConsumeEvent event) { public void onPlayerConsumeItem(PlayerItemConsumeEvent event) {
if (Utils.checkAuth(event.getPlayer())) if (Utils.checkAuth(event.getPlayer()))
@ -421,6 +499,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method onPlayerInventoryOpen.
* @param event InventoryOpenEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerInventoryOpen(InventoryOpenEvent event) { public void onPlayerInventoryOpen(InventoryOpenEvent event) {
final Player player = (Player) event.getPlayer(); final Player player = (Player) event.getPlayer();
@ -441,6 +523,10 @@ public class AuthMePlayerListener implements Listener {
}, 1); }, 1);
} }
/**
* Method onPlayerInventoryClick.
* @param event InventoryClickEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerInventoryClick(InventoryClickEvent event) { public void onPlayerInventoryClick(InventoryClickEvent event) {
if (event.getWhoClicked() == null) if (event.getWhoClicked() == null)
@ -452,6 +538,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method playerHitPlayerEvent.
* @param event EntityDamageByEntityEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void playerHitPlayerEvent(EntityDamageByEntityEvent event) { public void playerHitPlayerEvent(EntityDamageByEntityEvent event) {
Entity damager = event.getDamager(); Entity damager = event.getDamager();
@ -464,6 +554,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method onPlayerInteractEntity.
* @param event PlayerInteractEntityEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -472,6 +566,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method onPlayerDropItem.
* @param event PlayerDropItemEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerDropItem(PlayerDropItemEvent event) { public void onPlayerDropItem(PlayerDropItemEvent event) {
if (Utils.checkAuth(event.getPlayer())) if (Utils.checkAuth(event.getPlayer()))
@ -479,6 +577,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method onPlayerBedEnter.
* @param event PlayerBedEnterEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerBedEnter(PlayerBedEnterEvent event) { public void onPlayerBedEnter(PlayerBedEnterEvent event) {
if (Utils.checkAuth(event.getPlayer())) if (Utils.checkAuth(event.getPlayer()))
@ -486,6 +588,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method onSignChange.
* @param event SignChangeEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onSignChange(SignChangeEvent event) { public void onSignChange(SignChangeEvent event) {
if (Utils.checkAuth(event.getPlayer())) if (Utils.checkAuth(event.getPlayer()))
@ -493,6 +599,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method onPlayerRespawn.
* @param event PlayerRespawnEvent
*/
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerRespawn(PlayerRespawnEvent event) { public void onPlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -509,6 +619,10 @@ public class AuthMePlayerListener implements Listener {
} }
} }
/**
* Method onPlayerGameModeChange.
* @param event PlayerGameModeChangeEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) { public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -527,6 +641,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method onPlayerShear.
* @param event PlayerShearEntityEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerShear(PlayerShearEntityEvent event) { public void onPlayerShear(PlayerShearEntityEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -535,6 +653,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
/**
* Method onPlayerFish.
* @param event PlayerFishEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerFish(PlayerFishEvent event) { public void onPlayerFish(PlayerFishEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();

View File

@ -9,14 +9,24 @@ import org.bukkit.event.player.PlayerEditBookEvent;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.util.Utils; import fr.xephi.authme.util.Utils;
/**
*/
public class AuthMePlayerListener16 implements Listener { public class AuthMePlayerListener16 implements Listener {
public AuthMe plugin; public AuthMe plugin;
/**
* Constructor for AuthMePlayerListener16.
* @param plugin AuthMe
*/
public AuthMePlayerListener16(AuthMe plugin) { public AuthMePlayerListener16(AuthMe plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
/**
* Method onPlayerEditBook.
* @param event PlayerEditBookEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerEditBook(PlayerEditBookEvent event) { public void onPlayerEditBook(PlayerEditBookEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();

View File

@ -9,14 +9,24 @@ import org.bukkit.event.player.PlayerInteractAtEntityEvent;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.util.Utils; import fr.xephi.authme.util.Utils;
/**
*/
public class AuthMePlayerListener18 implements Listener { public class AuthMePlayerListener18 implements Listener {
public AuthMe plugin; public AuthMe plugin;
/**
* Constructor for AuthMePlayerListener18.
* @param plugin AuthMe
*/
public AuthMePlayerListener18(AuthMe plugin) { public AuthMePlayerListener18(AuthMe plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
/**
* Method onPlayerInteractAtEntity.
* @param event PlayerInteractAtEntityEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST) @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) { public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();

View File

@ -6,6 +6,8 @@ import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent; import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent; import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
/**
*/
public class AuthMePluginListener implements Listener { public class AuthMePluginListener implements Listener {
/** Plugin instance. */ /** Plugin instance. */

View File

@ -13,15 +13,25 @@ import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.Utils; import fr.xephi.authme.util.Utils;
/**
*/
public class AuthMeServerListener implements Listener { public class AuthMeServerListener implements Listener {
public AuthMe plugin; public AuthMe plugin;
private Messages m = Messages.getInstance(); private Messages m = Messages.getInstance();
/**
* Constructor for AuthMeServerListener.
* @param plugin AuthMe
*/
public AuthMeServerListener(AuthMe plugin) { public AuthMeServerListener(AuthMe plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
/**
* Method onServerPing.
* @param event ServerListPingEvent
*/
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onServerPing(ServerListPingEvent event) { public void onServerPing(ServerListPingEvent event) {
if (!Settings.enableProtection) if (!Settings.enableProtection)
@ -39,6 +49,10 @@ public class AuthMeServerListener implements Listener {
} }
} }
/**
* Method onPluginDisable.
* @param event PluginDisableEvent
*/
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onPluginDisable(PluginDisableEvent event) { public void onPluginDisable(PluginDisableEvent event) {
String pluginName = event.getPlugin().getName(); String pluginName = event.getPlugin().getName();
@ -71,6 +85,10 @@ public class AuthMeServerListener implements Listener {
} }
} }
/**
* Method onPluginEnable.
* @param event PluginEnableEvent
*/
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onPluginEnable(PluginEnableEvent event) { public void onPluginEnable(PluginEnableEvent event) {
String pluginName = event.getPlugin().getName(); String pluginName = event.getPlugin().getName();

Some files were not shown because too many files have changed in this diff Show More