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

View File

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

View File

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

View File

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

View File

@ -6,13 +6,23 @@ import java.awt.GradientPaint;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
/**
*/
public class ImageGenerator {
private String pass;
/**
* Constructor for ImageGenerator.
* @param pass String
*/
public ImageGenerator(String pass) {
this.pass = pass;
}
/**
* Method generateImage.
* @return BufferedImage
*/
public BufferedImage generateImage() {
BufferedImage image = new BufferedImage(200, 60, BufferedImage.TYPE_BYTE_INDEXED);
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.
* @author Xephi59
* @version $Revision: 1.0 $
*/
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() {
}
/**
* Method filter.
* @param record LogEvent
* @return Result
* @see org.apache.logging.log4j.core.Filter#filter(LogEvent)
*/
@Override
public Result filter(LogEvent record) {
if (record == null) {
@ -31,12 +38,32 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
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
public Result filter(Logger arg0, Level arg1, Marker arg2, String message,
Object... arg4) {
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
public Result filter(Logger arg0, Level arg1, Marker arg2, Object message,
Throwable arg4) {
@ -46,17 +73,37 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
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
public Result filter(Logger arg0, Level arg1, Marker arg2, Message message,
Throwable arg4) {
return validateMessage(message);
}
/**
* Method getOnMatch.
* @return Result
* @see org.apache.logging.log4j.core.Filter#getOnMatch()
*/
@Override
public Result getOnMatch() {
return Result.NEUTRAL;
}
/**
* Method getOnMismatch.
* @return Result
* @see org.apache.logging.log4j.core.Filter#getOnMismatch()
*/
@Override
public Result getOnMismatch() {
return Result.NEUTRAL;
@ -68,8 +115,8 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
* data.
*
* @param message the Message object to verify
* @return the Result value
*/
* @return the Result value */
private static Result validateMessage(Message message) {
if (message == null) {
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.
*
* @param message the message to verify
* @return the Result value
*/
* @return the Result value */
private static Result validateMessage(String message) {
if (message == null) {
return Result.NEUTRAL;

View File

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

View File

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

View File

@ -15,11 +15,17 @@ import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.Utils;
/**
*/
public class API {
public static final String newline = System.getProperty("line.separator");
public static AuthMe instance;
/**
* Constructor for API.
* @param instance AuthMe
*/
@Deprecated
public API(AuthMe instance) {
API.instance = instance;
@ -28,8 +34,8 @@ public class API {
/**
* Hook into AuthMe
*
* @return AuthMe instance
*/
* @return AuthMe instance */
@Deprecated
public static AuthMe hookAuthMe() {
if (instance != null)
@ -42,6 +48,10 @@ public class API {
return instance;
}
/**
* Method getPlugin.
* @return AuthMe
*/
@Deprecated
public AuthMe getPlugin() {
return instance;
@ -50,8 +60,8 @@ public class API {
/**
*
* @param player
* @return true if player is authenticate
*/
* @return true if player is authenticate */
@Deprecated
public static boolean isAuthenticated(Player player) {
return PlayerCache.getInstance().isAuthenticated(player.getName());
@ -60,8 +70,8 @@ public class API {
/**
*
* @param player
* @return true if player is a npc
*/
* @return true if player is a npc */
@Deprecated
public boolean isaNPC(Player player) {
return Utils.isNPC(player);
@ -70,8 +80,8 @@ public class API {
/**
*
* @param player
* @return true if player is a npc
*/
* @return true if player is a npc */
@Deprecated
public boolean isNPC(Player player) {
return Utils.isNPC(player);
@ -80,13 +90,18 @@ public class API {
/**
*
* @param player
* @return true if the player is unrestricted
*/
* @return true if the player is unrestricted */
@Deprecated
public static boolean isUnrestricted(Player player) {
return Utils.isUnrestricted(player);
}
/**
* Method getLastLocation.
* @param player Player
* @return Location
*/
@Deprecated
public static Location getLastLocation(Player player) {
try {
@ -104,6 +119,12 @@ public class API {
}
}
/**
* Method setPlayerInventory.
* @param player Player
* @param content ItemStack[]
* @param armor ItemStack[]
*/
@Deprecated
public static void setPlayerInventory(Player player, ItemStack[] content,
ItemStack[] armor) {
@ -117,8 +138,8 @@ public class API {
/**
*
* @param playerName
* @return true if player is registered
*/
* @return true if player is registered */
@Deprecated
public static boolean isRegistered(String playerName) {
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
public static boolean checkPassword(String playerName,
String passwordToCheck) {
@ -147,10 +169,11 @@ public class API {
/**
* 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
public static boolean registerPlayer(String playerName, String password) {
try {
@ -172,8 +195,8 @@ public class API {
/**
* Force a player to login
*
* @param Player
* player
* @param player * player
*/
@Deprecated
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.util.Utils;
/**
*/
public class NewAPI {
public static final String newline = System.getProperty("line.separator");
public static NewAPI singleton;
public AuthMe plugin;
/**
* Constructor for NewAPI.
* @param plugin AuthMe
*/
public NewAPI(AuthMe plugin) {
this.plugin = plugin;
}
/**
* Constructor for NewAPI.
* @param serv Server
*/
public NewAPI(Server serv) {
this.plugin = (AuthMe) serv.getPluginManager().getPlugin("AuthMe");
}
@ -32,8 +42,8 @@ public class NewAPI {
/**
* Hook into AuthMe
*
* @return AuthMe plugin
*/
* @return AuthMe plugin */
public static NewAPI getInstance() {
if (singleton != null)
return singleton;
@ -46,6 +56,10 @@ public class NewAPI {
return singleton;
}
/**
* Method getPlugin.
* @return AuthMe
*/
public AuthMe getPlugin() {
return plugin;
}
@ -53,8 +67,8 @@ public class NewAPI {
/**
*
* @param player
* @return true if player is authenticate
*/
* @return true if player is authenticate */
public boolean isAuthenticated(Player player) {
return PlayerCache.getInstance().isAuthenticated(player.getName());
}
@ -62,8 +76,8 @@ public class NewAPI {
/**
*
* @param player
* @return true if player is a npc
*/
* @return true if player is a npc */
public boolean isNPC(Player player) {
return Utils.isNPC(player);
}
@ -71,12 +85,17 @@ public class NewAPI {
/**
*
* @param player
* @return true if the player is unrestricted
*/
* @return true if the player is unrestricted */
public boolean isUnrestricted(Player player) {
return Utils.isUnrestricted(player);
}
/**
* Method getLastLocation.
* @param player Player
* @return Location
*/
public Location getLastLocation(Player player) {
try {
PlayerAuth auth = PlayerCache.getInstance().getAuth(player.getName().toLowerCase());
@ -95,18 +114,19 @@ public class NewAPI {
/**
*
* @param playerName
* @return true if player is registered
*/
* @return true if player is registered */
public boolean isRegistered(String playerName) {
String player = playerName.toLowerCase();
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) {
if (!isRegistered(playerName))
return false;
@ -122,10 +142,11 @@ public class NewAPI {
/**
* 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) {
try {
String name = playerName.toLowerCase();
@ -143,8 +164,8 @@ public class NewAPI {
/**
* Force a player to login
*
* @param Player
* player
* @param player * player
*/
public void forceLogin(Player player) {
plugin.management.performLogin(player, "dontneed", true);
@ -153,8 +174,8 @@ public class NewAPI {
/**
* Force a player to logout
*
* @param Player
* player
* @param player * player
*/
public void forceLogout(Player player)
{
@ -164,10 +185,10 @@ public class NewAPI {
/**
* Force a player to register
*
* @param Player
* player
* @param String
* password
* @param player * player
* @param password String
*/
public void forceRegister(Player player, String password)
{
@ -177,8 +198,8 @@ public class NewAPI {
/**
* Force a player to unregister
*
* @param Player
* player
* @param 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.settings.Settings;
/**
*/
public class PlayerAuth {
private String nickname;
@ -18,38 +20,132 @@ public class PlayerAuth {
private String email;
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
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) {
this.nickname = nickname;
this.hash = hash;
@ -65,6 +161,10 @@ public class PlayerAuth {
this.realName = realName;
}
/**
* Method set.
* @param auth PlayerAuth
*/
public void set(PlayerAuth auth) {
this.setEmail(auth.getEmail());
this.setHash(auth.getHash());
@ -79,94 +179,186 @@ public class PlayerAuth {
this.setRealName(auth.getRealName());
}
/**
* Method setName.
* @param nickname String
*/
public void setName(String nickname) {
this.nickname = nickname;
}
/**
* Method getNickname.
* @return String
*/
public String getNickname() {
return nickname;
}
/**
* Method getRealName.
* @return String
*/
public String getRealName() {
return realName;
}
/**
* Method setRealName.
* @param realName String
*/
public void setRealName(String realName) {
this.realName = realName;
}
/**
* Method getGroupId.
* @return int
*/
public int getGroupId() {
return groupId;
}
/**
* Method setQuitLocX.
* @param d double
*/
public void setQuitLocX(double d) {
this.x = d;
}
/**
* Method getQuitLocX.
* @return double
*/
public double getQuitLocX() {
return x;
}
/**
* Method setQuitLocY.
* @param d double
*/
public void setQuitLocY(double d) {
this.y = d;
}
/**
* Method getQuitLocY.
* @return double
*/
public double getQuitLocY() {
return y;
}
/**
* Method setQuitLocZ.
* @param d double
*/
public void setQuitLocZ(double d) {
this.z = d;
}
/**
* Method getQuitLocZ.
* @return double
*/
public double getQuitLocZ() {
return z;
}
/**
* Method setWorld.
* @param world String
*/
public void setWorld(String world) {
this.world = world;
}
/**
* Method getWorld.
* @return String
*/
public String getWorld() {
return world;
}
/**
* Method setIp.
* @param ip String
*/
public void setIp(String ip) {
this.ip = ip;
}
/**
* Method getIp.
* @return String
*/
public String getIp() {
return ip;
}
/**
* Method setLastLogin.
* @param lastLogin long
*/
public void setLastLogin(long lastLogin) {
this.lastLogin = lastLogin;
}
/**
* Method getLastLogin.
* @return long
*/
public long getLastLogin() {
return lastLogin;
}
/**
* Method setEmail.
* @param email String
*/
public void setEmail(String email) {
this.email = email;
}
/**
* Method getEmail.
* @return String
*/
public String getEmail() {
return email;
}
/**
* Method setSalt.
* @param salt String
*/
public void setSalt(String salt) {
this.salt = salt;
}
/**
* Method getSalt.
* @return String
*/
public String getSalt() {
return this.salt;
}
/**
* Method setHash.
* @param hash String
*/
public void setHash(String hash) {
this.hash = hash;
}
/**
* Method getHash.
* @return String
*/
public String getHash() {
if (Settings.getPasswordHash == HashAlgorithm.MD5VB) {
if (salt != null && !salt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.MD5VB) {
@ -176,6 +368,11 @@ public class PlayerAuth {
return hash;
}
/**
* Method equals.
* @param obj Object
* @return boolean
*/
@Override
public boolean equals(Object obj) {
if (!(obj instanceof PlayerAuth)) {
@ -185,6 +382,10 @@ public class PlayerAuth {
return other.getIp().equals(this.ip) && other.getNickname().equals(this.nickname);
}
/**
* Method hashCode.
* @return int
*/
@Override
public int hashCode() {
int hashCode = 7;
@ -193,6 +394,10 @@ public class PlayerAuth {
return hashCode;
}
/**
* Method toString.
* @return String
*/
@Override
public String toString() {
return ("Player : " + nickname + " | " + realName

View File

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

View File

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

View File

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

View File

@ -14,6 +14,8 @@ import fr.xephi.authme.cache.backup.JsonCache;
import fr.xephi.authme.events.ResetInventoryEvent;
import fr.xephi.authme.settings.Settings;
/**
*/
public class LimboCache {
private volatile static LimboCache singleton;
@ -21,12 +23,20 @@ public class LimboCache {
private JsonCache playerData;
public AuthMe plugin;
/**
* Constructor for LimboCache.
* @param plugin AuthMe
*/
private LimboCache(AuthMe plugin) {
this.plugin = plugin;
this.cache = new ConcurrentHashMap<>();
this.playerData = new JsonCache();
}
/**
* Method addLimboPlayer.
* @param player Player
*/
public void addLimboPlayer(Player player) {
String name = player.getName().toLowerCase();
Location loc = player.getLocation();
@ -75,22 +85,45 @@ public class LimboCache {
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) {
cache.put(player.getName().toLowerCase(), new LimboPlayer(player.getName().toLowerCase(), group));
}
/**
* Method deleteLimboPlayer.
* @param name String
*/
public void deleteLimboPlayer(String name) {
cache.remove(name);
}
/**
* Method getLimboPlayer.
* @param name String
* @return LimboPlayer
*/
public LimboPlayer getLimboPlayer(String name) {
return cache.get(name);
}
/**
* Method hasLimboPlayer.
* @param name String
* @return boolean
*/
public boolean hasLimboPlayer(String name) {
return cache.containsKey(name);
}
/**
* Method getInstance.
* @return LimboCache
*/
public static LimboCache getInstance() {
if (singleton == null) {
singleton = new LimboCache(AuthMe.getInstance());
@ -98,6 +131,10 @@ public class LimboCache {
return singleton;
}
/**
* Method updateLimboPlayer.
* @param player Player
*/
public void updateLimboPlayer(Player player) {
if (this.hasLimboPlayer(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.scheduler.BukkitTask;
/**
*/
public class LimboPlayer {
private String name;
@ -15,6 +17,15 @@ public class LimboPlayer {
private String group = "";
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,
boolean operator, String group, boolean flying) {
this.name = name;
@ -25,51 +36,96 @@ public class LimboPlayer {
this.flying = flying;
}
/**
* Constructor for LimboPlayer.
* @param name String
* @param group String
*/
public LimboPlayer(String name, String group) {
this.name = name;
this.group = group;
}
/**
* Method getName.
* @return String
*/
public String getName() {
return name;
}
/**
* Method getLoc.
* @return Location
*/
public Location getLoc() {
return loc;
}
/**
* Method getGameMode.
* @return GameMode
*/
public GameMode getGameMode() {
return gameMode;
}
/**
* Method getOperator.
* @return boolean
*/
public boolean getOperator() {
return operator;
}
/**
* Method getGroup.
* @return String
*/
public String getGroup() {
return group;
}
/**
* Method setTimeoutTaskId.
* @param i BukkitTask
*/
public void setTimeoutTaskId(BukkitTask i) {
if (this.timeoutTaskId != null)
this.timeoutTaskId.cancel();
this.timeoutTaskId = i;
}
/**
* Method getTimeoutTaskId.
* @return BukkitTask
*/
public BukkitTask getTimeoutTaskId() {
return timeoutTaskId;
}
/**
* Method setMessageTaskId.
* @param messageTaskId BukkitTask
*/
public void setMessageTaskId(BukkitTask messageTaskId) {
if (this.messageTaskId != null)
this.messageTaskId.cancel();
this.messageTaskId = messageTaskId;
}
/**
* Method getMessageTaskId.
* @return BukkitTask
*/
public BukkitTask getMessageTaskId() {
return messageTaskId;
}
/**
* Method isFlying.
* @return boolean
*/
public boolean isFlying() {
return flying;
}

View File

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

View File

@ -9,6 +9,8 @@ import org.bukkit.command.CommandSender;
import fr.xephi.authme.util.StringUtils;
/**
*/
public class CommandDescription {
/** Defines the acceptable labels. */
@ -97,8 +99,8 @@ public class CommandDescription {
/**
* Get the first relative command label.
*
* @return First relative command label.
*/
* @return First relative command label. */
public String getLabel() {
// Ensure there's any item in the command list
if(this.labels.size() == 0)
@ -113,8 +115,8 @@ public class CommandDescription {
*
* @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) {
// Ensure there's any item in the command list
if(this.labels.size() == 0)
@ -145,8 +147,8 @@ public class CommandDescription {
/**
* Get all relative command labels.
*
* @return All relative labels labels.
*/
* @return All relative labels labels. */
public List<String> getLabels() {
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
* 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) {
// Check whether this new command should overwrite the previous ones
if(!overwrite)
@ -198,8 +200,8 @@ public class CommandDescription {
*
* @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) {
// Verify the label
if(!isValidLabel(commandLabel))
@ -218,8 +220,8 @@ public class CommandDescription {
*
* @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) {
// Add each command label separately
for(String cmd : commandLabels)
@ -233,8 +235,8 @@ public class CommandDescription {
*
* @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) {
// Check whether any command matches with the argument
for(String entry : this.labels)
@ -248,8 +250,8 @@ public class CommandDescription {
/**
* Check whether this command description has a 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) {
// Check if there's a match for every command
for(String cmd : commandLabels)
@ -266,8 +268,8 @@ public class CommandDescription {
*
* @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) {
// Make sure the command reference is valid
if(commandReference.getCount() <= 0)
@ -285,8 +287,8 @@ public class CommandDescription {
*
* @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) {
// Make sure the label isn't null
if(label == null)
@ -305,6 +307,7 @@ public class CommandDescription {
/**
* Get the absolute command label, without a slash.
* @return String
*/
public String getAbsoluteLabel() {
return getAbsoluteLabel(false);
@ -313,8 +316,9 @@ public class CommandDescription {
/**
* Get the absolute command label.
*
* @return Absolute command label.
*/
* @param includeSlash boolean
* @return Absolute command label. */
public String getAbsoluteLabel(boolean includeSlash) {
return getAbsoluteLabel(includeSlash, null);
}
@ -322,8 +326,10 @@ public class CommandDescription {
/**
* 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) {
// Get the command reference, and make sure it is valid
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.
*
* @return Command reference.
*/
* @return Command reference. */
public CommandParts getCommandReference(CommandParts reference) {
// Build the reference
List<String> referenceList = new ArrayList<>();
@ -361,8 +367,8 @@ public class CommandDescription {
*
* @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) {
return getCommandDifference(other, false);
}
@ -373,8 +379,8 @@ public class CommandDescription {
* @param other The other command reference.
* @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) {
// Make sure the reference is valid
if(other == null)
@ -390,8 +396,8 @@ public class CommandDescription {
/**
* Get the executable command.
*
* @return The executable command.
*/
* @return The executable command. */
public ExecutableCommand getExecutableCommand() {
return this.executableCommand;
}
@ -408,8 +414,8 @@ public class CommandDescription {
/**
* 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() {
return this.executableCommand != null;
}
@ -421,8 +427,8 @@ public class CommandDescription {
* @param commandReference The command reference.
* @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) {
// Make sure the command is executable
if(!isExecutable())
@ -435,8 +441,8 @@ public class CommandDescription {
/**
* Get the parent command if this command description has a parent.
*
* @return Parent command, or null
*/
* @return Parent command, or null */
public CommandDescription getParent() {
return this.parent;
}
@ -444,8 +450,8 @@ public class CommandDescription {
/**
* Get the number of parent this description has.
*
* @return The number of parents.
*/
* @return The number of parents. */
public int getParentCount() {
// Check whether the this description has a parent
if(!hasParent())
@ -460,8 +466,8 @@ public class CommandDescription {
*
* @param parent Parent command.
*
* @return True on success, false on failure.
*/
* @return True on success, false on failure. */
public boolean setParent(CommandDescription parent) {
// Make sure the parent is different
if(this.parent == parent)
@ -481,8 +487,8 @@ public class CommandDescription {
/**
* 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() {
return this.parent != null;
}
@ -490,8 +496,8 @@ public class CommandDescription {
/**
* Get all command children.
*
* @return Command children.
*/
* @return Command children. */
public List<CommandDescription> getChildren() {
return this.children;
}
@ -501,8 +507,8 @@ public class CommandDescription {
*
* @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) {
// Make sure the description is valid
if(commandDescription == null)
@ -539,8 +545,8 @@ public class CommandDescription {
/**
* 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() {
return (this.children.size() != 0);
}
@ -550,8 +556,8 @@ public class CommandDescription {
*
* @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) {
// Make sure the description is valid
if(commandDescription == null)
@ -568,8 +574,8 @@ public class CommandDescription {
*
* @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) {
// Make sure the argument is valid
if(argument == null)
@ -586,8 +592,8 @@ public class CommandDescription {
/**
* Get all command arguments.
*
* @return Command arguments.
*/
* @return Command arguments. */
public List<CommandArgumentDescription> getArguments() {
return this.arguments;
}
@ -611,8 +617,8 @@ public class CommandDescription {
*
* @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) {
// Make sure the argument is valid
if(argument == null)
@ -625,8 +631,8 @@ public class CommandDescription {
/**
* 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() {
return (this.arguments.size() != 0);
}
@ -634,8 +640,8 @@ public class CommandDescription {
/**
* 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() {
// Get the number of required and optional arguments
int requiredArguments = 0;
@ -659,8 +665,8 @@ public class CommandDescription {
/**
* 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() {
// Check whether there is a maximum set
if(this.noArgumentMaximum)
@ -682,8 +688,8 @@ public class CommandDescription {
/**
* Get the command description.
*
* @return Command description.
*/
* @return Command description. */
public String getDescription() {
return hasDescription() ? this.description : this.detailedDescription;
}
@ -704,8 +710,8 @@ public class CommandDescription {
/**
* 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() {
return (this.description.trim().length() != 0);
}
@ -713,8 +719,8 @@ public class CommandDescription {
/**
* Get the command detailed description.
*
* @return Command detailed description.
*/
* @return Command detailed description. */
public String getDetailedDescription() {
return hasDetailedDescription() ? this.detailedDescription : this.description;
}
@ -735,8 +741,8 @@ public class CommandDescription {
/**
* 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() {
return (this.detailedDescription.trim().length() != 0);
}
@ -746,8 +752,8 @@ public class CommandDescription {
*
* @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) {
// Make sure the command reference is valid
if(queryReference.getCount() <= 0)
@ -808,8 +814,8 @@ public class CommandDescription {
*
* @param commandReference The command reference.
*
* @return True if so, false otherwise.
*/
* @return True if so, false otherwise. */
public boolean hasSuitableCommand(CommandParts commandReference) {
return findCommand(commandReference) != null;
}
@ -819,8 +825,8 @@ public class CommandDescription {
*
* @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) {
return getSuitableArgumentsDifference(commandReference) == 0;
}
@ -831,8 +837,8 @@ public class CommandDescription {
*
* @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) {
// Make sure the command reference is valid
if(commandReference.getCount() <= 0)
@ -856,8 +862,8 @@ public class CommandDescription {
/**
* Get the command permissions.
*
* @return The command permissions.
*/
* @return The command permissions. */
public CommandPermissions getCommandPermissions() {
return this.permissions;
}
@ -887,8 +893,8 @@ public class CommandDescription {
* @param commandLabel The first 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) {
// Trim the command labels from unwanted whitespaces
commandLabel = commandLabel.trim();
@ -901,8 +907,8 @@ public class CommandDescription {
/**
* 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() {
// Make sure any command label is set
if(getLabels().size() == 0)

View File

@ -10,6 +10,8 @@ import org.bukkit.command.CommandSender;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.command.help.HelpProvider;
/**
*/
public class CommandHandler {
/** The command manager instance. */
@ -29,9 +31,9 @@ public class CommandHandler {
/**
* Initialize the command handler.
*
* @return True if succeed, false on failure. True will also be returned if the command handler was already
* initialized.
*/
* initialized. */
public boolean init() {
// Make sure the handler isn't initialized already
if(isInit())
@ -48,8 +50,8 @@ public class CommandHandler {
/**
* 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() {
return this.commandManager != null;
}
@ -57,9 +59,9 @@ public class CommandHandler {
/**
* Destroy the command handler.
*
* @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() {
// Make sure the command handler is initialized
if(!isInit())
@ -73,8 +75,8 @@ public class CommandHandler {
/**
* Get the command manager.
*
* @return Command manager instance.
*/
* @return Command manager instance. */
public CommandManager getCommandManager() {
return this.commandManager;
}
@ -87,8 +89,8 @@ public class CommandHandler {
* @param bukkitCommandLabel The command label (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) {
// Process the arguments
List<String> args = processArguments(bukkitArgs);
@ -180,8 +182,8 @@ public class CommandHandler {
*
* @param args The command arguments to process.
*
* @return The processed command arguments.
*/
* @return The processed command arguments. */
private List<String> processArguments(String[] args) {
// Convert the array into a list of arguments
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.logout.LogoutCommand;
/**
*/
public class CommandManager {
/** The list of commandDescriptions. */
@ -571,8 +573,8 @@ public class CommandManager {
/**
* Get the list of command descriptions
*
* @return List of command descriptions.
*/
* @return List of command descriptions. */
public List<CommandDescription> getCommandDescriptions() {
return this.commandDescriptions;
}
@ -580,8 +582,8 @@ public class CommandManager {
/**
* Get the number of command description count.
*
* @return Command description count.
*/
* @return Command description count. */
public int getCommandDescriptionCount() {
return this.getCommandDescriptions().size();
}
@ -592,8 +594,8 @@ public class CommandManager {
* @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(CommandParts queryReference) {
// Make sure the command reference is valid
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.StringUtils;
/**
*/
public class CommandParts {
/** The list of parts for this command. */
@ -57,8 +59,8 @@ public class CommandParts {
/**
* Get the command parts.
*
* @return Command parts.
*/
* @return Command parts. */
public List<String> getList() {
return this.parts;
}
@ -68,8 +70,8 @@ public class CommandParts {
*
* @param part The part to add.
*
* @return The result.
*/
* @return The result. */
public boolean add(String part) {
return this.parts.add(part);
}
@ -79,8 +81,8 @@ public class CommandParts {
*
* @param parts The parts to add.
*
* @return The result.
*/
* @return The result. */
public boolean add(List<String> parts) {
return this.parts.addAll(parts);
}
@ -90,8 +92,8 @@ public class CommandParts {
*
* @param parts The parts to add.
*
* @return The result.
*/
* @return The result. */
public boolean add(String[] parts) {
for(String entry : parts)
add(entry);
@ -101,8 +103,8 @@ public class CommandParts {
/**
* Get the number of parts.
*
* @return Part count.
*/
* @return Part count. */
public int getCount() {
return this.parts.size();
}
@ -112,8 +114,8 @@ public class CommandParts {
*
* @param i Part index.
*
* @return The part.
*/
* @return The part. */
public String get(int i) {
// Make sure the index is in-bound
if(i < 0 || i >= getCount())
@ -128,8 +130,8 @@ public class CommandParts {
*
* @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) {
return getRange(start, getCount() - start);
}
@ -140,8 +142,8 @@ public class CommandParts {
* @param start The starting index.
* @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) {
// Create a new list to put the range into
List<String> elements = new ArrayList<>();
@ -163,8 +165,8 @@ public class CommandParts {
*
* @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) {
return getDifference(other, false);
}
@ -175,8 +177,8 @@ public class CommandParts {
* @param other The other reference.
* @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) {
// Make sure the other reference is correct
if(other == null)
@ -194,8 +196,8 @@ public class CommandParts {
/**
* Convert the parts to a string.
*
* @return The part as a string.
*/
* @return The part as a string. */
@Override
public String toString() {
return ListUtils.implode(this.parts, " ");

View File

@ -11,6 +11,8 @@ import org.bukkit.entity.Player;
//import com.timvisee.dungeonmaze.permission.PermissionsManager;
import fr.xephi.authme.AuthMe;
/**
*/
public class CommandPermissions {
/** 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.
*
* @return True on success, false on failure.
*/
* @return True on success, false on failure. */
public boolean addPermissionNode(String permissionNode) {
// Trim the permission node
permissionNode = permissionNode.trim();
@ -72,8 +74,8 @@ public class CommandPermissions {
*
* @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) {
return this.permissionNodes.contains(permissionNode);
}
@ -81,8 +83,8 @@ public class CommandPermissions {
/**
* 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() {
return this.permissionNodes;
}
@ -90,8 +92,8 @@ public class CommandPermissions {
/**
* Get the number of permission nodes set.
*
* @return Permission node count.
*/
* @return Permission node count. */
public int getPermissionNodeCount() {
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.
*
* @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) {
// Make sure any permission node is set
if(getPermissionNodeCount() == 0)
@ -140,8 +143,8 @@ public class CommandPermissions {
/**
* Get the default permission if the permission nodes couldn't be used.
*
* @return The default permission.
*/
* @return The default permission. */
public DefaultPermission getDefaultPermission() {
return this.defaultPermission;
}
@ -160,8 +163,8 @@ public class CommandPermissions {
*
* @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) {
switch(getDefaultPermission()) {
case ALLOWED:
@ -176,6 +179,8 @@ public class CommandPermissions {
}
}
/**
*/
public enum DefaultPermission {
NOT_ALLOWED,
OP_ONLY,

View File

@ -2,6 +2,8 @@ package fr.xephi.authme.command;
import org.bukkit.command.CommandSender;
/**
*/
public abstract class ExecutableCommand {
/**
@ -11,7 +13,7 @@ public abstract class ExecutableCommand {
* @param commandReference The command reference.
* @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);
}

View File

@ -2,6 +2,8 @@ package fr.xephi.authme.command;
import org.bukkit.command.CommandSender;
/**
*/
public class FoundCommandResult {
/** The command description instance. */
@ -31,8 +33,8 @@ public class FoundCommandResult {
/**
* 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() {
// Make sure the command description is set
if(this.commandDescription == null)
@ -45,8 +47,8 @@ public class FoundCommandResult {
/**
* Get the command description.
*
* @return Command description.
*/
* @return Command description. */
public CommandDescription getCommandDescription() {
return this.commandDescription;
}
@ -64,8 +66,8 @@ public class FoundCommandResult {
/**
* 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() {
// Make sure the command description is valid
if(this.commandDescription == null)
@ -80,8 +82,8 @@ public class FoundCommandResult {
*
* @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) {
// Make sure the command description is valid
if(this.commandDescription == null)
@ -96,8 +98,8 @@ public class FoundCommandResult {
*
* @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) {
// Make sure the command description is valid
if(this.commandDescription == null)
@ -110,8 +112,8 @@ public class FoundCommandResult {
/**
* Get the command reference.
*
* @return The command reference.
*/
* @return The command reference. */
public CommandParts getCommandReference() {
return this.commandReference;
}
@ -119,8 +121,8 @@ public class FoundCommandResult {
/**
* Get the command arguments.
*
* @return The command arguments.
*/
* @return The command arguments. */
public CommandParts getCommandArguments() {
return this.commandArguments;
}
@ -128,8 +130,8 @@ public class FoundCommandResult {
/**
* Get the original query reference.
*
* @return Original query reference.
*/
* @return Original query reference. */
public CommandParts getQueryReference() {
return this.queryReference;
}
@ -137,8 +139,8 @@ public class FoundCommandResult {
/**
* Get the difference value between the original query and the result reference.
*
* @return The difference value.
*/
* @return The difference value. */
public double getDifference() {
// Get the difference through the command found
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.help.HelpProvider;
/**
*/
public class HelpCommand extends ExecutableCommand {
/**
@ -15,8 +17,8 @@ public class HelpCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.settings.Messages;
/**
*/
public class AccountsCommand extends ExecutableCommand {
/**
@ -21,8 +23,8 @@ public class AccountsCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.ExecutableCommand;
/**
*/
public class AuthMeCommand extends ExecutableCommand {
/**
@ -16,8 +18,8 @@ public class AuthMeCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.Settings;
/**
*/
public class ChangePasswordCommand extends ExecutableCommand {
/**
@ -24,8 +26,8 @@ public class ChangePasswordCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.settings.Spawn;
/**
*/
public class FirstSpawnCommand extends ExecutableCommand {
/**
@ -17,8 +19,8 @@ public class FirstSpawnCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.ExecutableCommand;
/**
*/
public class ForceLoginCommand extends ExecutableCommand {
/**
@ -17,8 +19,8 @@ public class ForceLoginCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.settings.Messages;
/**
*/
public class GetEmailCommand extends ExecutableCommand {
/**
@ -17,8 +19,8 @@ public class GetEmailCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.ExecutableCommand;
/**
*/
public class GetIpCommand extends ExecutableCommand {
/**
@ -17,8 +19,8 @@ public class GetIpCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.settings.Messages;
/**
*/
public class LastLoginCommand extends ExecutableCommand {
/**
@ -19,8 +21,8 @@ public class LastLoginCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.settings.Settings;
/**
*/
public class PurgeBannedPlayersCommand extends ExecutableCommand {
/**
@ -20,8 +22,8 @@ public class PurgeBannedPlayersCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.settings.Settings;
/**
*/
public class PurgeCommand extends ExecutableCommand {
/**
@ -20,8 +22,8 @@ public class PurgeCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.settings.Messages;
/**
*/
public class PurgeLastPositionCommand extends ExecutableCommand {
/**
@ -19,8 +21,8 @@ public class PurgeLastPositionCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.Settings;
/**
*/
public class RegisterCommand extends ExecutableCommand {
/**
@ -23,8 +25,8 @@ public class RegisterCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.util.Profiler;
/**
*/
public class ReloadCommand extends ExecutableCommand {
/**
@ -20,8 +22,8 @@ public class ReloadCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.ExecutableCommand;
/**
*/
public class ResetNameCommand extends ExecutableCommand {
/**
@ -19,8 +21,8 @@ public class ResetNameCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.Settings;
/**
*/
public class SetEmailCommand extends ExecutableCommand {
/**
@ -19,8 +21,8 @@ public class SetEmailCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.settings.Spawn;
/**
*/
public class SetFirstSpawnCommand extends ExecutableCommand {
/**
@ -17,8 +19,8 @@ public class SetFirstSpawnCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
try {

View File

@ -8,6 +8,8 @@ import fr.xephi.authme.command.CommandParts;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.settings.Spawn;
/**
*/
public class SetSpawnCommand extends ExecutableCommand {
/**
@ -17,8 +19,8 @@ public class SetSpawnCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.settings.Spawn;
/**
*/
public class SpawnCommand extends ExecutableCommand {
/**
@ -17,8 +19,8 @@ public class SpawnCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.help.HelpProvider;
/**
*/
public class SwitchAntiBotCommand extends ExecutableCommand {
/**
@ -17,8 +19,8 @@ public class SwitchAntiBotCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.util.Utils;
/**
*/
public class UnregisterCommand extends ExecutableCommand {
/**
@ -28,8 +30,8 @@ public class UnregisterCommand extends ExecutableCommand {
* @param sender The command sender.
* @param commandReference The command reference.
* @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
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.ExecutableCommand;
/**
*/
public class VersionCommand extends ExecutableCommand {
/**
@ -18,8 +20,8 @@ public class VersionCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// Show some version info
@ -71,8 +73,8 @@ public class VersionCommand extends ExecutableCommand {
*
* @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) {
for(Player player : Bukkit.getOnlinePlayers())
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.Settings;
/**
*/
public class CaptchaCommand extends ExecutableCommand {
/**
@ -20,8 +22,8 @@ public class CaptchaCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.task.ChangePasswordTask;
/**
*/
public class ChangePasswordCommand extends ExecutableCommand {
/**
@ -20,8 +22,8 @@ public class ChangePasswordCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.settings.Messages;
/**
*/
public class ConverterCommand extends ExecutableCommand {
/**
@ -26,8 +28,8 @@ public class ConverterCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// AuthMe plugin instance
@ -85,6 +87,8 @@ public class ConverterCommand extends ExecutableCommand {
return true;
}
/**
*/
public enum ConvertType {
ftsql("flattosql"),
ftsqlite("flattosqlite"),
@ -97,14 +101,27 @@ public class ConverterCommand extends ExecutableCommand {
String name;
/**
* Constructor for ConvertType.
* @param name String
*/
ConvertType(String name) {
this.name = name;
}
/**
* Method getName.
* @return String
*/
String getName() {
return this.name;
}
/**
* Method fromName.
* @param name String
* @return ConvertType
*/
public static ConvertType fromName(String name) {
for (ConvertType type : ConvertType.values()) {
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.settings.Messages;
/**
*/
public class AddEmailCommand extends ExecutableCommand {
/**
@ -16,8 +18,8 @@ public class AddEmailCommand extends ExecutableCommand {
* @param sender The command sender.
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.settings.Messages;
/**
*/
public class ChangeEmailCommand extends ExecutableCommand {
/**
@ -16,8 +18,8 @@ public class ChangeEmailCommand extends ExecutableCommand {
* @param sender The command sender.
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.Settings;
/**
*/
public class RecoverEmailCommand extends ExecutableCommand {
/**
@ -25,8 +27,8 @@ public class RecoverEmailCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.ExecutableCommand;
/**
*/
public class LoginCommand extends ExecutableCommand {
/**
@ -16,8 +18,8 @@ public class LoginCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.ExecutableCommand;
/**
*/
public class LogoutCommand extends ExecutableCommand {
/**
@ -16,8 +18,8 @@ public class LogoutCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.Settings;
/**
*/
public class RegisterCommand extends ExecutableCommand {
/**
@ -19,8 +21,8 @@ public class RegisterCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.settings.Messages;
/**
*/
public class UnregisterCommand extends ExecutableCommand {
/**
@ -18,8 +20,8 @@ public class UnregisterCommand extends ExecutableCommand {
* @param commandReference The command reference.
* @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
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
// 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.util.StringUtils;
/**
*/
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.FoundCommandResult;
/**
*/
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.util.ListUtils;
/**
*/
public class HelpSyntaxHelper {
/**
@ -17,8 +19,8 @@ public class HelpSyntaxHelper {
* @param alternativeLabel The alternative label to use for this command syntax.
* @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")
public static String getCommandSyntax(CommandDescription commandDescription, CommandParts commandReference, String alternativeLabel, boolean highlight) {
// Create a string builder to build the command

View File

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

View File

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

View File

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

View File

@ -16,6 +16,8 @@ import org.bukkit.command.CommandSender;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.settings.Settings;
/**
*/
public class FlatToSqlite implements Converter {
public CommandSender sender;
@ -32,10 +34,18 @@ public class FlatToSqlite implements Converter {
private String database;
private String columnID;
private Connection con;
/**
* Constructor for FlatToSqlite.
* @param sender CommandSender
*/
public FlatToSqlite(CommandSender sender) {
this.sender = sender;
}
/**
* Method close.
* @param o AutoCloseable
*/
private static void close(AutoCloseable o) {
if (o != null) {
try {
@ -46,6 +56,10 @@ public class FlatToSqlite implements Converter {
}
}
/**
* Method run.
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
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 {
Class.forName("org.sqlite.JDBC");
con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/" + database + ".db");
}
/**
* Method setup.
* @throws SQLException
*/
private synchronized void setup() throws SQLException {
Statement st = 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) {
PreparedStatement pst = null;
try {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -17,18 +17,29 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
/**
*/
public class xAuthToFlat {
public AuthMe instance;
public DataSource database;
public CommandSender sender;
/**
* Constructor for xAuthToFlat.
* @param instance AuthMe
* @param sender CommandSender
*/
public xAuthToFlat(AuthMe instance, CommandSender sender) {
this.instance = instance;
this.database = instance.database;
this.sender = sender;
}
/**
* Method convert.
* @return boolean
*/
public boolean convert() {
if (instance.getServer().getPluginManager().getPlugin("xAuth") == null) {
sender.sendMessage("[AuthMe] xAuth plugin not found");
@ -59,6 +70,11 @@ public class xAuthToFlat {
return true;
}
/**
* Method getIdPlayer.
* @param id int
* @return String
*/
public String getIdPlayer(int id) {
String realPass = "";
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
@ -81,6 +97,10 @@ public class xAuthToFlat {
return realPass;
}
/**
* Method getXAuthPlayers.
* @return List<Integer>
*/
public List<Integer> getXAuthPlayers() {
List<Integer> xP = new ArrayList<>();
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
@ -102,6 +122,11 @@ public class xAuthToFlat {
return xP;
}
/**
* Method getPassword.
* @param accountId int
* @return String
*/
public String getPassword(int accountId) {
String realPass = "";
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.util.Utils;
/**
*/
public class CacheDataSource implements DataSource {
private final DataSource source;
private final ExecutorService exec;
private final ConcurrentHashMap<String, PlayerAuth> cache = new ConcurrentHashMap<>();
/**
* Constructor for CacheDataSource.
* @param pl AuthMe
* @param src DataSource
*/
public CacheDataSource(final AuthMe pl, DataSource src) {
this.source = src;
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
public synchronized boolean isAuthAvailable(String user) {
return cache.containsKey(user.toLowerCase());
}
/**
* Method getAuth.
* @param user String
* @return PlayerAuth
* @see fr.xephi.authme.datasource.DataSource#getAuth(String)
*/
@Override
public synchronized PlayerAuth getAuth(String user) {
user = user.toLowerCase();
@ -56,6 +75,12 @@ public class CacheDataSource implements DataSource {
return null;
}
/**
* Method saveAuth.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
*/
@Override
public synchronized boolean saveAuth(final PlayerAuth auth) {
cache.put(auth.getNickname(), auth);
@ -70,6 +95,12 @@ public class CacheDataSource implements DataSource {
return true;
}
/**
* Method updatePassword.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
*/
@Override
public synchronized boolean updatePassword(final PlayerAuth auth) {
if (!cache.containsKey(auth.getNickname())) {
@ -90,6 +121,12 @@ public class CacheDataSource implements DataSource {
return true;
}
/**
* Method updateSession.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
*/
@Override
public boolean updateSession(final PlayerAuth auth) {
if (!cache.containsKey(auth.getNickname())) {
@ -119,6 +156,12 @@ public class CacheDataSource implements DataSource {
return true;
}
/**
* Method updateQuitLoc.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
*/
@Override
public boolean updateQuitLoc(final PlayerAuth auth) {
if (!cache.containsKey(auth.getNickname())) {
@ -151,6 +194,12 @@ public class CacheDataSource implements DataSource {
return true;
}
/**
* Method getIps.
* @param ip String
* @return int
* @see fr.xephi.authme.datasource.DataSource#getIps(String)
*/
@Override
public int getIps(String ip) {
int count = 0;
@ -162,6 +211,12 @@ public class CacheDataSource implements DataSource {
return count;
}
/**
* Method purgeDatabase.
* @param until long
* @return int
* @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
*/
@Override
public int purgeDatabase(long until) {
int cleared = source.purgeDatabase(until);
@ -175,6 +230,12 @@ public class CacheDataSource implements DataSource {
return cleared;
}
/**
* Method autoPurgeDatabase.
* @param until long
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
*/
@Override
public List<String> autoPurgeDatabase(long until) {
List<String> cleared = source.autoPurgeDatabase(until);
@ -188,6 +249,12 @@ public class CacheDataSource implements DataSource {
return cleared;
}
/**
* Method removeAuth.
* @param username String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
*/
@Override
public synchronized boolean removeAuth(String username) {
final String user = username.toLowerCase();
@ -204,12 +271,20 @@ public class CacheDataSource implements DataSource {
return true;
}
/**
* Method close.
* @see fr.xephi.authme.datasource.DataSource#close()
*/
@Override
public synchronized void close() {
exec.shutdown();
source.close();
}
/**
* Method reload.
* @see fr.xephi.authme.datasource.DataSource#reload()
*/
@Override
public void reload() {
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
public synchronized boolean updateEmail(final PlayerAuth auth) {
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
public synchronized boolean updateSalt(final PlayerAuth auth) {
if (!cache.containsKey(auth.getNickname())) {
@ -262,6 +349,12 @@ public class CacheDataSource implements DataSource {
return true;
}
/**
* Method getAllAuthsByName.
* @param auth PlayerAuth
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
*/
@Override
public synchronized List<String> getAllAuthsByName(PlayerAuth auth) {
List<String> result = new ArrayList<>();
@ -273,6 +366,13 @@ public class CacheDataSource implements DataSource {
return result;
}
/**
* Method getAllAuthsByIp.
* @param ip String
* @return List<String>
* @throws Exception
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
*/
@Override
public synchronized List<String> getAllAuthsByIp(final String ip) throws Exception {
return exec.submit(new Callable<List<String>>() {
@ -282,6 +382,13 @@ public class CacheDataSource implements DataSource {
}).get();
}
/**
* Method getAllAuthsByEmail.
* @param email String
* @return List<String>
* @throws Exception
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
*/
@Override
public synchronized List<String> getAllAuthsByEmail(final String email) throws Exception {
return exec.submit(new Callable<List<String>>() {
@ -291,6 +398,11 @@ public class CacheDataSource implements DataSource {
}).get();
}
/**
* Method purgeBanned.
* @param banned List<String>
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
*/
@Override
public synchronized void purgeBanned(final List<String> banned) {
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
public DataSourceType getType() {
return source.getType();
}
/**
* Method isLogged.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isLogged(String)
*/
@Override
public boolean isLogged(String user) {
user = user.toLowerCase();
return PlayerCache.getInstance().getCache().containsKey(user);
}
/**
* Method setLogged.
* @param user String
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
*/
@Override
public void setLogged(final String user) {
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
public void setUnlogged(final String user) {
exec.execute(new Runnable() {
@ -337,6 +470,10 @@ public class CacheDataSource implements DataSource {
});
}
/**
* Method purgeLogged.
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
*/
@Override
public void purgeLogged() {
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
public int getAccountsRegistered() {
return cache.size();
}
/**
* Method updateName.
* @param oldone String
* @param newone String
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
*/
@Override
public void updateName(final String oldone, final String newone) {
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
public List<PlayerAuth> getAllAuths() {
return new ArrayList<>(cache.values());
}
/**
* Method getLoggedPlayers.
* @return List<PlayerAuth>
* @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
*/
@Override
public List<PlayerAuth> getLoggedPlayers() {
return new ArrayList<>(PlayerCache.getInstance().getCache().values());

View File

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

View File

@ -8,16 +8,28 @@ import java.util.concurrent.Executors;
import fr.xephi.authme.cache.auth.PlayerAuth;
/**
*/
public class DatabaseCalls implements DataSource {
private DataSource database;
private final ExecutorService exec;
/**
* Constructor for DatabaseCalls.
* @param database DataSource
*/
public DatabaseCalls(DataSource database) {
this.database = database;
this.exec = Executors.newCachedThreadPool();
}
/**
* Method isAuthAvailable.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
*/
@Override
public synchronized boolean isAuthAvailable(final String user) {
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
public synchronized PlayerAuth getAuth(final String user) {
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
public synchronized boolean saveAuth(final PlayerAuth auth) {
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
public synchronized boolean updateSession(final PlayerAuth auth) {
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
public synchronized boolean updatePassword(final PlayerAuth auth) {
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
public synchronized int purgeDatabase(final long until) {
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
public synchronized List<String> autoPurgeDatabase(final long until) {
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
public synchronized boolean removeAuth(final String user) {
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
public synchronized boolean updateQuitLoc(final PlayerAuth auth) {
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
public synchronized int getIps(final String ip) {
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
public synchronized List<String> getAllAuthsByName(final PlayerAuth auth) {
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
public synchronized List<String> getAllAuthsByIp(final String ip) {
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
public synchronized List<String> getAllAuthsByEmail(final String email) {
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
public synchronized boolean updateEmail(final PlayerAuth auth) {
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
public synchronized boolean updateSalt(final PlayerAuth auth) {
try {
@ -214,17 +310,30 @@ public class DatabaseCalls implements DataSource {
}
}
/**
* Method close.
* @see fr.xephi.authme.datasource.DataSource#close()
*/
@Override
public synchronized void close() {
exec.shutdown();
database.close();
}
/**
* Method reload.
* @see fr.xephi.authme.datasource.DataSource#reload()
*/
@Override
public synchronized void reload() {
database.reload();
}
/**
* Method purgeBanned.
* @param banned List<String>
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
*/
@Override
public synchronized void purgeBanned(final List<String> banned) {
new Thread(new Runnable() {
@ -234,11 +343,22 @@ public class DatabaseCalls implements DataSource {
}).start();
}
/**
* Method getType.
* @return DataSourceType
* @see fr.xephi.authme.datasource.DataSource#getType()
*/
@Override
public synchronized DataSourceType getType() {
return database.getType();
}
/**
* Method isLogged.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isLogged(String)
*/
@Override
public synchronized boolean isLogged(final String user) {
try {
@ -252,6 +372,11 @@ public class DatabaseCalls implements DataSource {
}
}
/**
* Method setLogged.
* @param user String
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
*/
@Override
public synchronized void setLogged(final String user) {
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
public synchronized void setUnlogged(final String user) {
exec.execute(new Runnable() {
@ -270,6 +400,10 @@ public class DatabaseCalls implements DataSource {
});
}
/**
* Method purgeLogged.
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
*/
@Override
public synchronized void purgeLogged() {
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
public synchronized int getAccountsRegistered() {
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
public synchronized void updateName(final String oldone, final String newone) {
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
public synchronized List<PlayerAuth> getAllAuths() {
try {
@ -314,6 +464,11 @@ public class DatabaseCalls implements DataSource {
}
}
/**
* Method getLoggedPlayers.
* @return List<PlayerAuth>
* @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
*/
@Override
public List<PlayerAuth> getLoggedPlayers() {
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.settings.Settings;
/**
*/
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
public synchronized boolean isAuthAvailable(String user) {
BufferedReader br = null;
@ -77,6 +85,12 @@ public class FlatFile implements DataSource {
return false;
}
/**
* Method saveAuth.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
*/
@Override
public synchronized boolean saveAuth(PlayerAuth auth) {
if (isAuthAvailable(auth.getNickname())) {
@ -100,6 +114,12 @@ public class FlatFile implements DataSource {
return true;
}
/**
* Method updatePassword.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
*/
@Override
public synchronized boolean updatePassword(PlayerAuth auth) {
if (!isAuthAvailable(auth.getNickname())) {
@ -159,6 +179,12 @@ public class FlatFile implements DataSource {
return true;
}
/**
* Method updateSession.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
*/
@Override
public boolean updateSession(PlayerAuth auth) {
if (!isAuthAvailable(auth.getNickname())) {
@ -218,6 +244,12 @@ public class FlatFile implements DataSource {
return true;
}
/**
* Method updateQuitLoc.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
*/
@Override
public boolean updateQuitLoc(PlayerAuth auth) {
if (!isAuthAvailable(auth.getNickname())) {
@ -256,6 +288,12 @@ public class FlatFile implements DataSource {
return true;
}
/**
* Method getIps.
* @param ip String
* @return int
* @see fr.xephi.authme.datasource.DataSource#getIps(String)
*/
@Override
public int getIps(String ip) {
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
public int purgeDatabase(long until) {
BufferedReader br = null;
@ -332,6 +376,12 @@ public class FlatFile implements DataSource {
return cleared;
}
/**
* Method autoPurgeDatabase.
* @param until long
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
*/
@Override
public List<String> autoPurgeDatabase(long until) {
BufferedReader br = null;
@ -378,6 +428,12 @@ public class FlatFile implements DataSource {
return cleared;
}
/**
* Method removeAuth.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
*/
@Override
public synchronized boolean removeAuth(String user) {
if (!isAuthAvailable(user)) {
@ -422,6 +478,12 @@ public class FlatFile implements DataSource {
return true;
}
/**
* Method getAuth.
* @param user String
* @return PlayerAuth
* @see fr.xephi.authme.datasource.DataSource#getAuth(String)
*/
@Override
public synchronized PlayerAuth getAuth(String user) {
BufferedReader br = null;
@ -464,14 +526,28 @@ public class FlatFile implements DataSource {
return null;
}
/**
* Method close.
* @see fr.xephi.authme.datasource.DataSource#close()
*/
@Override
public synchronized void close() {
}
/**
* Method reload.
* @see fr.xephi.authme.datasource.DataSource#reload()
*/
@Override
public void reload() {
}
/**
* Method updateEmail.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
*/
@Override
public boolean updateEmail(PlayerAuth auth) {
if (!isAuthAvailable(auth.getNickname())) {
@ -510,11 +586,23 @@ public class FlatFile implements DataSource {
return true;
}
/**
* Method updateSalt.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
*/
@Override
public boolean updateSalt(PlayerAuth auth) {
return false;
}
/**
* Method getAllAuthsByName.
* @param auth PlayerAuth
* @return List<String>
* @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
*/
@Override
public List<String> getAllAuthsByName(PlayerAuth auth) {
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
public List<String> getAllAuthsByIp(String ip) {
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
public List<String> getAllAuthsByEmail(String email) {
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
public void purgeBanned(List<String> banned) {
BufferedReader br = null;
@ -649,28 +754,58 @@ public class FlatFile implements DataSource {
return;
}
/**
* Method getType.
* @return DataSourceType
* @see fr.xephi.authme.datasource.DataSource#getType()
*/
@Override
public DataSourceType getType() {
return DataSourceType.FILE;
}
/**
* Method isLogged.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isLogged(String)
*/
@Override
public boolean isLogged(String user) {
return PlayerCache.getInstance().isAuthenticated(user);
}
/**
* Method setLogged.
* @param user String
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
*/
@Override
public void setLogged(String user) {
}
/**
* Method setUnlogged.
* @param user String
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
*/
@Override
public void setUnlogged(String user) {
}
/**
* Method purgeLogged.
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
*/
@Override
public void purgeLogged() {
}
/**
* Method getAccountsRegistered.
* @return int
* @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
*/
@Override
public int getAccountsRegistered() {
BufferedReader br = null;
@ -694,6 +829,12 @@ public class FlatFile implements DataSource {
return result;
}
/**
* Method updateName.
* @param oldone String
* @param newone String
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
*/
@Override
public void updateName(String oldone, String newone) {
PlayerAuth auth = this.getAuth(oldone);
@ -702,6 +843,11 @@ public class FlatFile implements DataSource {
this.removeAuth(oldone);
}
/**
* Method getAllAuths.
* @return List<PlayerAuth>
* @see fr.xephi.authme.datasource.DataSource#getAllAuths()
*/
@Override
public List<PlayerAuth> getAllAuths() {
BufferedReader br = null;
@ -749,6 +895,11 @@ public class FlatFile implements DataSource {
return auths;
}
/**
* Method getLoggedPlayers.
* @return List<PlayerAuth>
* @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
*/
@Override
public List<PlayerAuth> getLoggedPlayers() {
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.settings.Settings;
/**
*/
public class MySQL implements DataSource {
private String host;
@ -45,6 +47,12 @@ public class MySQL implements DataSource {
private String columnRealName;
private int maxConnections;
/**
* Constructor for MySQL.
* @throws ClassNotFoundException
* @throws SQLException
* @throws PoolInitializationException
*/
public MySQL() throws ClassNotFoundException, SQLException, PoolInitializationException {
this.host = Settings.getMySQLHost;
this.port = Settings.getMySQLPort;
@ -98,6 +106,11 @@ public class MySQL implements DataSource {
}
}
/**
* Method setConnectionArguments.
* @throws ClassNotFoundException
* @throws IllegalArgumentException
*/
private synchronized void setConnectionArguments()
throws ClassNotFoundException, IllegalArgumentException {
HikariConfig config = new HikariConfig();
@ -117,6 +130,11 @@ public class MySQL implements DataSource {
ConsoleLogger.info("Connection arguments loaded, Hikari ConnectionPool ready!");
}
/**
* Method reloadArguments.
* @throws ClassNotFoundException
* @throws IllegalArgumentException
*/
private synchronized void reloadArguments()
throws ClassNotFoundException, IllegalArgumentException {
if (ds != null) {
@ -126,10 +144,19 @@ public class MySQL implements DataSource {
ConsoleLogger.info("Hikari ConnectionPool arguments reloaded!");
}
/**
* Method getConnection.
* @return Connection
* @throws SQLException
*/
private synchronized Connection getConnection() throws SQLException {
return ds.getConnection();
}
/**
* Method setupConnection.
* @throws SQLException
*/
private synchronized void setupConnection() throws SQLException {
Connection con = null;
Statement st = null;
@ -193,6 +220,12 @@ public class MySQL implements DataSource {
ConsoleLogger.info("MySQL Setup finished");
}
/**
* Method isAuthAvailable.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
*/
@Override
public synchronized boolean isAuthAvailable(String user) {
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
public synchronized PlayerAuth getAuth(String user) {
Connection con = null;
@ -268,6 +307,12 @@ public class MySQL implements DataSource {
return pAuth;
}
/**
* Method saveAuth.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
*/
@Override
public synchronized boolean saveAuth(PlayerAuth auth) {
Connection con = null;
@ -475,6 +520,12 @@ public class MySQL implements DataSource {
return true;
}
/**
* Method updatePassword.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
*/
@Override
public synchronized boolean updatePassword(PlayerAuth auth) {
Connection con = null;
@ -520,6 +571,12 @@ public class MySQL implements DataSource {
return true;
}
/**
* Method updateSession.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
*/
@Override
public synchronized boolean updateSession(PlayerAuth auth) {
Connection con = null;
@ -543,6 +600,12 @@ public class MySQL implements DataSource {
return true;
}
/**
* Method purgeDatabase.
* @param until long
* @return int
* @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
*/
@Override
public synchronized int purgeDatabase(long until) {
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
public synchronized List<String> autoPurgeDatabase(long until) {
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
public synchronized boolean removeAuth(String user) {
Connection con = null;
@ -629,6 +704,12 @@ public class MySQL implements DataSource {
return true;
}
/**
* Method updateQuitLoc.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
*/
@Override
public synchronized boolean updateQuitLoc(PlayerAuth auth) {
Connection con = null;
@ -653,6 +734,12 @@ public class MySQL implements DataSource {
return true;
}
/**
* Method getIps.
* @param ip String
* @return int
* @see fr.xephi.authme.datasource.DataSource#getIps(String)
*/
@Override
public synchronized int getIps(String ip) {
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
public synchronized boolean updateEmail(PlayerAuth auth) {
Connection con = null;
@ -701,6 +794,12 @@ public class MySQL implements DataSource {
return true;
}
/**
* Method updateSalt.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
*/
@Override
public synchronized boolean updateSalt(PlayerAuth auth) {
if (columnSalt.isEmpty()) {
@ -725,6 +824,10 @@ public class MySQL implements DataSource {
return true;
}
/**
* Method reload.
* @see fr.xephi.authme.datasource.DataSource#reload()
*/
@Override
public void reload() {
try {
@ -740,12 +843,20 @@ public class MySQL implements DataSource {
}
}
/**
* Method close.
* @see fr.xephi.authme.datasource.DataSource#close()
*/
@Override
public synchronized void close() {
if (ds != null && !ds.isClosed())
ds.close();
}
/**
* Method close.
* @param o AutoCloseable
*/
private void close(AutoCloseable o) {
if (o != null) {
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
public synchronized List<String> getAllAuthsByName(PlayerAuth auth) {
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
public synchronized List<String> getAllAuthsByIp(String ip) {
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
public synchronized List<String> getAllAuthsByEmail(String email) throws SQLException {
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
public synchronized void purgeBanned(List<String> banned) {
Connection con = null;
@ -851,11 +986,22 @@ public class MySQL implements DataSource {
}
}
/**
* Method getType.
* @return DataSourceType
* @see fr.xephi.authme.datasource.DataSource#getType()
*/
@Override
public DataSourceType getType() {
return DataSourceType.MYSQL;
}
/**
* Method isLogged.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isLogged(String)
*/
@Override
public boolean isLogged(String user) {
Connection con = null;
@ -880,6 +1026,11 @@ public class MySQL implements DataSource {
return false;
}
/**
* Method setLogged.
* @param user String
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
*/
@Override
public void setLogged(String user) {
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
public void setUnlogged(String user) {
Connection con = null;
@ -919,6 +1075,10 @@ public class MySQL implements DataSource {
}
}
/**
* Method purgeLogged.
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
*/
@Override
public void purgeLogged() {
Connection con = null;
@ -938,6 +1098,11 @@ public class MySQL implements DataSource {
}
}
/**
* Method getAccountsRegistered.
* @return int
* @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
*/
@Override
public int getAccountsRegistered() {
int result = 0;
@ -962,6 +1127,12 @@ public class MySQL implements DataSource {
return result;
}
/**
* Method updateName.
* @param oldone String
* @param newone String
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
*/
@Override
public void updateName(String oldone, String newone) {
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
public List<PlayerAuth> getAllAuths() {
List<PlayerAuth> auths = new ArrayList<>();
@ -1032,6 +1208,11 @@ public class MySQL implements DataSource {
return auths;
}
/**
* Method getLoggedPlayers.
* @return List<PlayerAuth>
* @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
*/
@Override
public List<PlayerAuth> getLoggedPlayers() {
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.settings.Settings;
/**
*/
public class SQLite implements DataSource {
private String database;
@ -33,6 +35,11 @@ public class SQLite implements DataSource {
private String columnLogged;
private String columnRealName;
/**
* Constructor for SQLite.
* @throws ClassNotFoundException
* @throws SQLException
*/
public SQLite() throws ClassNotFoundException, SQLException {
this.database = Settings.getMySQLDatabase;
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 {
Class.forName("org.sqlite.JDBC");
ConsoleLogger.info("SQLite driver loaded");
@ -67,6 +79,10 @@ public class SQLite implements DataSource {
}
/**
* Method setup.
* @throws SQLException
*/
private synchronized void setup() throws SQLException {
Statement st = null;
ResultSet rs = null;
@ -121,6 +137,12 @@ public class SQLite implements DataSource {
ConsoleLogger.info("SQLite Setup finished");
}
/**
* Method isAuthAvailable.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
*/
@Override
public synchronized boolean isAuthAvailable(String user) {
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
public synchronized PlayerAuth getAuth(String user) {
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
public synchronized boolean saveAuth(PlayerAuth auth) {
PreparedStatement pst = null;
@ -200,6 +234,12 @@ public class SQLite implements DataSource {
return true;
}
/**
* Method updatePassword.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
*/
@Override
public synchronized boolean updatePassword(PlayerAuth auth) {
PreparedStatement pst = null;
@ -217,6 +257,12 @@ public class SQLite implements DataSource {
return true;
}
/**
* Method updateSession.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
*/
@Override
public boolean updateSession(PlayerAuth auth) {
PreparedStatement pst = null;
@ -236,6 +282,12 @@ public class SQLite implements DataSource {
return true;
}
/**
* Method purgeDatabase.
* @param until long
* @return int
* @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
*/
@Override
public int purgeDatabase(long until) {
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
public List<String> autoPurgeDatabase(long until) {
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
public synchronized boolean removeAuth(String user) {
PreparedStatement pst = null;
@ -290,6 +354,12 @@ public class SQLite implements DataSource {
return true;
}
/**
* Method updateQuitLoc.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
*/
@Override
public boolean updateQuitLoc(PlayerAuth auth) {
PreparedStatement pst = null;
@ -310,6 +380,12 @@ public class SQLite implements DataSource {
return true;
}
/**
* Method getIps.
* @param ip String
* @return int
* @see fr.xephi.authme.datasource.DataSource#getIps(String)
*/
@Override
public int getIps(String ip) {
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
public boolean updateEmail(PlayerAuth auth) {
PreparedStatement pst = null;
@ -349,6 +431,12 @@ public class SQLite implements DataSource {
return true;
}
/**
* Method updateSalt.
* @param auth PlayerAuth
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
*/
@Override
public boolean updateSalt(PlayerAuth auth) {
if (columnSalt.isEmpty()) {
@ -369,6 +457,10 @@ public class SQLite implements DataSource {
return true;
}
/**
* Method close.
* @see fr.xephi.authme.datasource.DataSource#close()
*/
@Override
public synchronized void close() {
try {
@ -378,10 +470,18 @@ public class SQLite implements DataSource {
}
}
/**
* Method reload.
* @see fr.xephi.authme.datasource.DataSource#reload()
*/
@Override
public void reload() {
}
/**
* Method close.
* @param st Statement
*/
private void close(Statement st) {
if (st != null) {
try {
@ -392,6 +492,10 @@ public class SQLite implements DataSource {
}
}
/**
* Method close.
* @param rs ResultSet
*/
private void close(ResultSet rs) {
if (rs != null) {
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
public List<String> getAllAuthsByName(PlayerAuth auth) {
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
public List<String> getAllAuthsByIp(String ip) {
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
public List<String> getAllAuthsByEmail(String email) {
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
public void purgeBanned(List<String> banned) {
PreparedStatement pst = null;
@ -490,11 +617,22 @@ public class SQLite implements DataSource {
}
}
/**
* Method getType.
* @return DataSourceType
* @see fr.xephi.authme.datasource.DataSource#getType()
*/
@Override
public DataSourceType getType() {
return DataSourceType.SQLITE;
}
/**
* Method isLogged.
* @param user String
* @return boolean
* @see fr.xephi.authme.datasource.DataSource#isLogged(String)
*/
@Override
public boolean isLogged(String user) {
PreparedStatement pst = null;
@ -515,6 +653,11 @@ public class SQLite implements DataSource {
return false;
}
/**
* Method setLogged.
* @param user String
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
*/
@Override
public void setLogged(String user) {
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
public void setUnlogged(String user) {
PreparedStatement pst = null;
@ -546,6 +694,10 @@ public class SQLite implements DataSource {
}
}
/**
* Method purgeLogged.
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
*/
@Override
public void purgeLogged() {
PreparedStatement pst = null;
@ -561,6 +713,11 @@ public class SQLite implements DataSource {
}
}
/**
* Method getAccountsRegistered.
* @return int
* @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
*/
@Override
public int getAccountsRegistered() {
int result = 0;
@ -581,6 +738,12 @@ public class SQLite implements DataSource {
return result;
}
/**
* Method updateName.
* @param oldone String
* @param newone String
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
*/
@Override
public void updateName(String oldone, String newone) {
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
public List<PlayerAuth> getAllAuths() {
List<PlayerAuth> auths = new ArrayList<>();
@ -626,6 +794,11 @@ public class SQLite implements DataSource {
return auths;
}
/**
* Method getLoggedPlayers.
* @return List<PlayerAuth>
* @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
*/
@Override
public List<PlayerAuth> getLoggedPlayers() {
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
*
* @author Xephi59
* @version $Revision: 1.0 $
*/
public class AuthMeAsyncPreLoginEvent extends Event {
@ -16,23 +17,43 @@ public class AuthMeAsyncPreLoginEvent extends Event {
private boolean canLogin = true;
private static final HandlerList handlers = new HandlerList();
/**
* Constructor for AuthMeAsyncPreLoginEvent.
* @param player Player
*/
public AuthMeAsyncPreLoginEvent(Player player) {
super(true);
this.player = player;
}
/**
* Method getPlayer.
* @return Player
*/
public Player getPlayer() {
return player;
}
/**
* Method canLogin.
* @return boolean
*/
public boolean canLogin() {
return canLogin;
}
/**
* Method setCanLogin.
* @param canLogin boolean
*/
public void setCanLogin(boolean canLogin) {
this.canLogin = canLogin;
}
/**
* Method getHandlers.
* @return HandlerList
*/
@Override
public HandlerList getHandlers() {
return handlers;

View File

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

View File

@ -7,6 +7,7 @@ import org.bukkit.event.HandlerList;
/**
*
* @author Xephi59
* @version $Revision: 1.0 $
*/
public class CustomEvent extends Event implements Cancellable {
@ -17,22 +18,44 @@ public class CustomEvent extends Event implements Cancellable {
super(false);
}
/**
* Constructor for CustomEvent.
* @param b boolean
*/
public CustomEvent(boolean b) {
super(b);
}
/**
* Method getHandlers.
* @return HandlerList
*/
public HandlerList getHandlers() {
return handlers;
}
/**
* Method getHandlerList.
* @return HandlerList
*/
public static HandlerList getHandlerList() {
return handlers;
}
/**
* Method isCancelled.
* @return boolean
* @see org.bukkit.event.Cancellable#isCancelled()
*/
public boolean isCancelled() {
return this.isCancelled;
}
/**
* Method setCancelled.
* @param cancelled boolean
* @see org.bukkit.event.Cancellable#setCancelled(boolean)
*/
public void setCancelled(boolean 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
*
* @author Xephi59
* @version $Revision: 1.0 $
*/
public class FirstSpawnTeleportEvent extends CustomEvent {
@ -15,6 +16,12 @@ public class FirstSpawnTeleportEvent extends CustomEvent {
private Location to;
private Location from;
/**
* Constructor for FirstSpawnTeleportEvent.
* @param player Player
* @param from Location
* @param to Location
*/
public FirstSpawnTeleportEvent(Player player, Location from, Location to) {
super(true);
this.player = player;
@ -22,18 +29,34 @@ public class FirstSpawnTeleportEvent extends CustomEvent {
this.to = to;
}
/**
* Method getPlayer.
* @return Player
*/
public Player getPlayer() {
return player;
}
/**
* Method setTo.
* @param to Location
*/
public void setTo(Location to) {
this.to = to;
}
/**
* Method getTo.
* @return Location
*/
public Location getTo() {
return to;
}
/**
* Method getFrom.
* @return Location
*/
public Location getFrom() {
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.
*
* @author Xephi59
* @version $Revision: 1.0 $
*/
public class LoginEvent extends Event {
@ -17,33 +18,62 @@ public class LoginEvent extends Event {
private boolean isLogin;
private static final HandlerList handlers = new HandlerList();
/**
* Constructor for LoginEvent.
* @param player Player
* @param isLogin boolean
*/
public LoginEvent(Player player, boolean isLogin) {
this.player = player;
this.isLogin = isLogin;
}
/**
* Method getPlayer.
* @return Player
*/
public Player getPlayer() {
return this.player;
}
/**
* Method setPlayer.
* @param player Player
*/
public void setPlayer(Player player) {
this.player = player;
}
/**
* Method setLogin.
* @param isLogin boolean
*/
@Deprecated
public void setLogin(boolean isLogin) {
this.isLogin = isLogin;
}
/**
* Method isLogin.
* @return boolean
*/
public boolean isLogin() {
return isLogin;
}
/**
* Method getHandlers.
* @return HandlerList
*/
@Override
public HandlerList getHandlers() {
return handlers;
}
/**
* Method getHandlerList.
* @return HandlerList
*/
public static HandlerList getHandlerList() {
return handlers;
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -6,24 +6,42 @@ import org.bukkit.entity.Player;
* This event restore the inventory.
*
* @author Xephi59
* @version $Revision: 1.0 $
*/
public class RestoreInventoryEvent extends CustomEvent {
private Player player;
/**
* Constructor for RestoreInventoryEvent.
* @param player Player
*/
public RestoreInventoryEvent(Player player) {
this.player = player;
}
/**
* Constructor for RestoreInventoryEvent.
* @param player Player
* @param async boolean
*/
public RestoreInventoryEvent(Player player, boolean async) {
super(async);
this.player = player;
}
/**
* Method getPlayer.
* @return Player
*/
public Player getPlayer() {
return this.player;
}
/**
* Method setPlayer.
* @param player Player
*/
public void setPlayer(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
*
* @author Xephi59
* @version $Revision: 1.0 $
*/
public class SpawnTeleportEvent extends CustomEvent {
@ -16,6 +17,13 @@ public class SpawnTeleportEvent extends CustomEvent {
private Location from;
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,
boolean isAuthenticated) {
this.player = player;
@ -24,22 +32,42 @@ public class SpawnTeleportEvent extends CustomEvent {
this.isAuthenticated = isAuthenticated;
}
/**
* Method getPlayer.
* @return Player
*/
public Player getPlayer() {
return player;
}
/**
* Method setTo.
* @param to Location
*/
public void setTo(Location to) {
this.to = to;
}
/**
* Method getTo.
* @return Location
*/
public Location getTo() {
return to;
}
/**
* Method getFrom.
* @return Location
*/
public Location getFrom() {
return from;
}
/**
* Method isAuthenticated.
* @return boolean
*/
public boolean isAuthenticated() {
return isAuthenticated;
}

View File

@ -8,14 +8,27 @@ import com.google.common.io.ByteStreams;
import fr.xephi.authme.AuthMe;
/**
*/
public class BungeeCordMessage implements PluginMessageListener {
public AuthMe plugin;
/**
* Constructor for BungeeCordMessage.
* @param plugin AuthMe
*/
public BungeeCordMessage(AuthMe 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
public void onPluginMessageReceived(String channel, Player player,
byte[] message) {

View File

@ -7,6 +7,8 @@ import org.bukkit.Location;
import fr.xephi.authme.settings.CustomConfiguration;
/**
*/
public class EssSpawn extends CustomConfiguration {
private static EssSpawn spawn;
@ -17,6 +19,10 @@ public class EssSpawn extends CustomConfiguration {
load();
}
/**
* Method getInstance.
* @return EssSpawn
*/
public static EssSpawn getInstance() {
if (spawn == null) {
spawn = new EssSpawn();
@ -24,6 +30,10 @@ public class EssSpawn extends CustomConfiguration {
return spawn;
}
/**
* Method getLocation.
* @return Location
*/
public Location getLocation() {
try {
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.util.Utils;
/**
*/
public class AuthMeBlockListener implements Listener {
public AuthMe instance;
/**
* Constructor for AuthMeBlockListener.
* @param instance AuthMe
*/
public AuthMeBlockListener(AuthMe instance) {
this.instance = instance;
}
/**
* Method onBlockPlace.
* @param event BlockPlaceEvent
*/
@EventHandler(ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
if (Utils.checkAuth(event.getPlayer()))
@ -25,6 +35,10 @@ public class AuthMeBlockListener implements Listener {
event.setCancelled(true);
}
/**
* Method onBlockBreak.
* @param event BlockBreakEvent
*/
@EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();

View File

@ -22,12 +22,18 @@ import org.bukkit.projectiles.ProjectileSource;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.util.Utils;
/**
*/
public class AuthMeEntityListener implements Listener {
public AuthMe instance;
private static Method getShooter;
private static boolean shooterIsProjectileSource;
/**
* Constructor for AuthMeEntityListener.
* @param instance AuthMe
*/
public AuthMeEntityListener(AuthMe instance) {
this.instance = instance;
try {
@ -37,6 +43,10 @@ public class AuthMeEntityListener implements Listener {
}
}
/**
* Method onEntityDamage.
* @param event EntityDamageEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onEntityDamage(EntityDamageEvent event) {
Entity entity = event.getEntity();
@ -53,6 +63,10 @@ public class AuthMeEntityListener implements Listener {
event.setCancelled(true);
}
/**
* Method onEntityTarget.
* @param event EntityTargetEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onEntityTarget(EntityTargetEvent event) {
Entity entity = event.getTarget();
@ -68,6 +82,10 @@ public class AuthMeEntityListener implements Listener {
event.setCancelled(true);
}
/**
* Method onDmg.
* @param event EntityDamageByEntityEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onDmg(EntityDamageByEntityEvent event) {
Entity entity = event.getDamager();
@ -83,6 +101,10 @@ public class AuthMeEntityListener implements Listener {
event.setCancelled(true);
}
/**
* Method onFoodLevelChange.
* @param event FoodLevelChangeEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onFoodLevelChange(FoodLevelChangeEvent event) {
Entity entity = event.getEntity();
@ -97,6 +119,10 @@ public class AuthMeEntityListener implements Listener {
event.setCancelled(true);
}
/**
* Method entityRegainHealthEvent.
* @param event EntityRegainHealthEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void entityRegainHealthEvent(EntityRegainHealthEvent event) {
Entity entity = event.getEntity();
@ -112,6 +138,10 @@ public class AuthMeEntityListener implements Listener {
event.setCancelled(true);
}
/**
* Method onEntityInteract.
* @param event EntityInteractEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onEntityInteract(EntityInteractEvent event) {
Entity entity = event.getEntity();
@ -126,6 +156,10 @@ public class AuthMeEntityListener implements Listener {
event.setCancelled(true);
}
/**
* Method onLowestEntityInteract.
* @param event EntityInteractEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onLowestEntityInteract(EntityInteractEvent event) {
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.
/**
* Method onProjectileLaunch.
* @param event ProjectileLaunchEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onProjectileLaunch(ProjectileLaunchEvent event) {
Projectile projectile = event.getEntity();
@ -173,6 +211,10 @@ public class AuthMeEntityListener implements Listener {
event.setCancelled(true);
}
/**
* Method onShoot.
* @param event EntityShootBowEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onShoot(EntityShootBowEvent event) {
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.settings.Settings;
/**
*/
public class AuthMeInventoryPacketAdapter extends PacketAdapter {
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 HOTBAR_SIZE = 9;
/**
* Constructor for AuthMeInventoryPacketAdapter.
* @param plugin AuthMe
*/
public AuthMeInventoryPacketAdapter(AuthMe plugin) {
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
public void onPacketSending(PacketEvent packetEvent) {
Player player = packetEvent.getPlayer();
@ -64,6 +75,10 @@ public class AuthMeInventoryPacketAdapter extends PacketAdapter {
ProtocolLibrary.getProtocolManager().addPacketListener(this);
}
/**
* Method sendInventoryPacket.
* @param player Player
*/
public void sendInventoryPacket(Player player) {
ProtocolManager protocolManager = ProtocolLibrary.getProtocolManager();
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.util.Utils;
/**
*/
public class AuthMePlayerListener implements Listener {
public AuthMe plugin;
@ -61,10 +63,18 @@ public class AuthMePlayerListener implements Listener {
public static ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
private List<String> antibot = new ArrayList<>();
/**
* Constructor for AuthMePlayerListener.
* @param plugin AuthMe
*/
public AuthMePlayerListener(AuthMe plugin) {
this.plugin = plugin;
}
/**
* Method handleChat.
* @param event AsyncPlayerChatEvent
*/
private void handleChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
@ -87,6 +97,10 @@ public class AuthMePlayerListener implements Listener {
}
/**
* Method onPlayerCommandPreprocess.
* @param event PlayerCommandPreprocessEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
String cmd = event.getMessage().split(" ")[0].toLowerCase();
@ -99,36 +113,64 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true);
}
/**
* Method onPlayerNormalChat.
* @param event AsyncPlayerChatEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerNormalChat(AsyncPlayerChatEvent event) {
handleChat(event);
}
/**
* Method onPlayerHighChat.
* @param event AsyncPlayerChatEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerHighChat(AsyncPlayerChatEvent event) {
handleChat(event);
}
/**
* Method onPlayerChat.
* @param event AsyncPlayerChatEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerChat(AsyncPlayerChatEvent event) {
handleChat(event);
}
/**
* Method onPlayerHighestChat.
* @param event AsyncPlayerChatEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerHighestChat(AsyncPlayerChatEvent event) {
handleChat(event);
}
/**
* Method onPlayerEarlyChat.
* @param event AsyncPlayerChatEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerEarlyChat(AsyncPlayerChatEvent event) {
handleChat(event);
}
/**
* Method onPlayerLowChat.
* @param event AsyncPlayerChatEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void onPlayerLowChat(AsyncPlayerChatEvent event) {
handleChat(event);
}
/**
* Method onPlayerMove.
* @param event PlayerMoveEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerMove(PlayerMoveEvent event) {
int radius = Settings.getMovementRadius;
@ -163,6 +205,10 @@ public class AuthMePlayerListener implements Listener {
}
}
/**
* Method checkAntiBotMod.
* @param player Player
*/
private void checkAntiBotMod(final Player player) {
if (plugin.delayedAntiBot || plugin.antibotMod)
return;
@ -196,6 +242,10 @@ public class AuthMePlayerListener implements Listener {
}, 300);
}
/**
* Method onPlayerJoin.
* @param event PlayerJoinEvent
*/
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerJoin(PlayerJoinEvent event) {
if (event.getPlayer() == null)
@ -223,6 +273,10 @@ public class AuthMePlayerListener implements Listener {
});
}
/**
* Method onPreLogin.
* @param event AsyncPlayerPreLoginEvent
*/
@EventHandler(priority = EventPriority.HIGHEST)
public void onPreLogin(AsyncPlayerPreLoginEvent event) {
final String name = event.getName().toLowerCase();
@ -250,6 +304,10 @@ public class AuthMePlayerListener implements Listener {
}
}
/**
* Method onPlayerLogin.
* @param event PlayerLoginEvent
*/
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerLogin(PlayerLoginEvent event) {
final Player player = event.getPlayer();
@ -369,6 +427,10 @@ public class AuthMePlayerListener implements Listener {
}
}
/**
* Method onPlayerQuit.
* @param event PlayerQuitEvent
*/
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(PlayerQuitEvent event) {
if (event.getPlayer() == null) {
@ -384,6 +446,10 @@ public class AuthMePlayerListener implements Listener {
plugin.management.performQuit(player, false);
}
/**
* Method onPlayerKick.
* @param event PlayerKickEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerKick(PlayerKickEvent event) {
if (event.getPlayer() == null) {
@ -399,6 +465,10 @@ public class AuthMePlayerListener implements Listener {
plugin.management.performQuit(player, true);
}
/**
* Method onPlayerPickupItem.
* @param event PlayerPickupItemEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
if (Utils.checkAuth(event.getPlayer()))
@ -406,6 +476,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true);
}
/**
* Method onPlayerInteract.
* @param event PlayerInteractEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
@ -414,6 +488,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true);
}
/**
* Method onPlayerConsumeItem.
* @param event PlayerItemConsumeEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerConsumeItem(PlayerItemConsumeEvent event) {
if (Utils.checkAuth(event.getPlayer()))
@ -421,6 +499,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true);
}
/**
* Method onPlayerInventoryOpen.
* @param event InventoryOpenEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerInventoryOpen(InventoryOpenEvent event) {
final Player player = (Player) event.getPlayer();
@ -441,6 +523,10 @@ public class AuthMePlayerListener implements Listener {
}, 1);
}
/**
* Method onPlayerInventoryClick.
* @param event InventoryClickEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerInventoryClick(InventoryClickEvent event) {
if (event.getWhoClicked() == null)
@ -452,6 +538,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true);
}
/**
* Method playerHitPlayerEvent.
* @param event EntityDamageByEntityEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void playerHitPlayerEvent(EntityDamageByEntityEvent event) {
Entity damager = event.getDamager();
@ -464,6 +554,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true);
}
/**
* Method onPlayerInteractEntity.
* @param event PlayerInteractEntityEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
Player player = event.getPlayer();
@ -472,6 +566,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true);
}
/**
* Method onPlayerDropItem.
* @param event PlayerDropItemEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerDropItem(PlayerDropItemEvent event) {
if (Utils.checkAuth(event.getPlayer()))
@ -479,6 +577,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true);
}
/**
* Method onPlayerBedEnter.
* @param event PlayerBedEnterEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerBedEnter(PlayerBedEnterEvent event) {
if (Utils.checkAuth(event.getPlayer()))
@ -486,6 +588,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true);
}
/**
* Method onSignChange.
* @param event SignChangeEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onSignChange(SignChangeEvent event) {
if (Utils.checkAuth(event.getPlayer()))
@ -493,6 +599,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true);
}
/**
* Method onPlayerRespawn.
* @param event PlayerRespawnEvent
*/
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerRespawn(PlayerRespawnEvent event) {
Player player = event.getPlayer();
@ -509,6 +619,10 @@ public class AuthMePlayerListener implements Listener {
}
}
/**
* Method onPlayerGameModeChange.
* @param event PlayerGameModeChangeEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
Player player = event.getPlayer();
@ -527,6 +641,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true);
}
/**
* Method onPlayerShear.
* @param event PlayerShearEntityEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerShear(PlayerShearEntityEvent event) {
Player player = event.getPlayer();
@ -535,6 +653,10 @@ public class AuthMePlayerListener implements Listener {
event.setCancelled(true);
}
/**
* Method onPlayerFish.
* @param event PlayerFishEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerFish(PlayerFishEvent event) {
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.util.Utils;
/**
*/
public class AuthMePlayerListener16 implements Listener {
public AuthMe plugin;
/**
* Constructor for AuthMePlayerListener16.
* @param plugin AuthMe
*/
public AuthMePlayerListener16(AuthMe plugin) {
this.plugin = plugin;
}
/**
* Method onPlayerEditBook.
* @param event PlayerEditBookEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerEditBook(PlayerEditBookEvent event) {
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.util.Utils;
/**
*/
public class AuthMePlayerListener18 implements Listener {
public AuthMe plugin;
/**
* Constructor for AuthMePlayerListener18.
* @param plugin AuthMe
*/
public AuthMePlayerListener18(AuthMe plugin) {
this.plugin = plugin;
}
/**
* Method onPlayerInteractAtEntity.
* @param event PlayerInteractAtEntityEvent
*/
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerInteractAtEntity(PlayerInteractAtEntityEvent event) {
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.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
/**
*/
public class AuthMePluginListener implements Listener {
/** Plugin instance. */

View File

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

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