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
+205
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
@@ -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;
}
@@ -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;
}
@@ -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 {
@@ -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());
@@ -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;
}