Merge upstream/master into ljacqu/enums

This commit is contained in:
ljacqu 2015-11-23 23:31:26 +01:00
commit 16a69d4126
137 changed files with 4848 additions and 4477 deletions

47
.gitignore vendored
View File

@ -1,10 +1,7 @@
### Java ### ### Java files ###
*.class *.class
# Mobile Tools for Java (J2ME) # Package Files
.mtj.tmp/
# Package Files #
#*.jar #*.jar
*.war *.war
*.ear *.ear
@ -13,43 +10,27 @@
hs_err_pid* hs_err_pid*
### Intellij ### ### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
# Ignore project files
*.iml *.iml
## Directory-based project format: # Ignore IDEA directory
.idea/* .idea/*
# Include the project's code style settings file # Include the project's code style settings file
!.idea/codeStyleSettings.xml !.idea/codeStyleSettings.xml
# if you remove the above rule, at least ignore the following: # Include the project's dictionary
!.idea/dictionaries/
!.idea/dictionaries/*
# User-specific stuff: # File-based project format:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries
# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml
# Gradle:
# .idea/gradle.xml
# .idea/libraries
# Mongo Explorer plugin:
# .idea/mongoSettings.xml
## File-based project format:
*.ipr *.ipr
*.iws *.iws
## Plugin-specific files: ### Plugin-specific files: ###
# IntelliJ # IntelliJ
/out/ /out/
@ -65,6 +46,7 @@ crashlytics.properties
crashlytics-build.properties crashlytics-build.properties
### Eclipse ### ### Eclipse ###
*.pydevproject *.pydevproject
.metadata .metadata
@ -104,6 +86,7 @@ local.properties
.texlipse .texlipse
### Maven ### ### Maven ###
target/ target/
pom.xml.tag pom.xml.tag
@ -115,6 +98,7 @@ dependency-reduced-pom.xml
buildNumber.properties buildNumber.properties
### NetBeans ### ### NetBeans ###
nbproject/private/ nbproject/private/
build/ build/
@ -125,5 +109,8 @@ nbactions.xml
nb-configuration.xml nb-configuration.xml
.nb-gradle/ .nb-gradle/
### Git ###
# Don't exclude the .gitignore itself # Don't exclude the .gitignore itself
!.gitignore !.gitignore

View File

@ -3,6 +3,9 @@
<component name="ProjectCodeStyleSettingsManager"> <component name="ProjectCodeStyleSettingsManager">
<option name="PER_PROJECT_SETTINGS"> <option name="PER_PROJECT_SETTINGS">
<value> <value>
<option name="LINE_SEPARATOR" value="&#10;" />
<option name="JD_ADD_BLANK_AFTER_PARM_COMMENTS" value="true" />
<option name="JD_ADD_BLANK_AFTER_RETURN" value="true" />
<XML> <XML>
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" /> <option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
</XML> </XML>

7
.idea/dictionaries/Tim.xml generated Normal file
View File

@ -0,0 +1,7 @@
<component name="ProjectDictionaryState">
<dictionary name="Tim">
<words>
<w>authme</w>
</words>
</dictionary>
</component>

View File

@ -88,10 +88,10 @@ public class AuthMe extends JavaPlugin {
public AuthMeInventoryPacketAdapter inventoryProtector; public AuthMeInventoryPacketAdapter inventoryProtector;
// Random data maps and stuff // Random data maps and stuff
// TODO: Create Manager for this // TODO: Create Manager for this
public ConcurrentHashMap<String, BukkitTask> sessions = new ConcurrentHashMap<>(); public final ConcurrentHashMap<String, BukkitTask> sessions = new ConcurrentHashMap<>();
public ConcurrentHashMap<String, Integer> captcha = new ConcurrentHashMap<>(); public final ConcurrentHashMap<String, Integer> captcha = new ConcurrentHashMap<>();
public ConcurrentHashMap<String, String> cap = new ConcurrentHashMap<>(); public final ConcurrentHashMap<String, String> cap = new ConcurrentHashMap<>();
public ConcurrentHashMap<String, String> realIp = new ConcurrentHashMap<>(); public final ConcurrentHashMap<String, String> realIp = new ConcurrentHashMap<>();
// AntiBot Status // AntiBot Status
// TODO: Create Manager for this // TODO: Create Manager for this
public boolean antiBotMod = false; public boolean antiBotMod = false;
@ -246,7 +246,7 @@ public class AuthMe extends JavaPlugin {
// Check Essentials // Check Essentials
checkEssentials(); checkEssentials();
// Check if the protocollib is available. If so we could listen for // Check if the ProtocolLib is available. If so we could listen for
// inventory protection // inventory protection
checkProtocolLib(); checkProtocolLib();
// End of Hooks // End of Hooks
@ -277,8 +277,8 @@ public class AuthMe extends JavaPlugin {
// Set up the management // Set up the management
management = new Management(this); management = new Management(this);
// Set up the Bungeecord hook // Set up the BungeeCord hook
setupBungeecordHook(); setupBungeeCordHook();
// Reload support hook // Reload support hook
reloadSupportHook(); reloadSupportHook();
@ -394,9 +394,9 @@ public class AuthMe extends JavaPlugin {
} }
/** /**
* Set up the Bungecoord hook. * Set up the BungeeCord hook.
*/ */
private void setupBungeecordHook() { private void setupBungeeCordHook() {
if (Settings.bungee) { if (Settings.bungee) {
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord"); Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeCordMessage(this)); Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeCordMessage(this));
@ -443,7 +443,7 @@ public class AuthMe extends JavaPlugin {
} }
/** /**
* Set up the antibot delay. * Set up the AntiBot delay.
*/ */
private void setupAntiBotDelay() { private void setupAntiBotDelay() {
if (Settings.enableAntiBot) { if (Settings.enableAntiBot) {
@ -652,7 +652,7 @@ public class AuthMe extends JavaPlugin {
try { try {
ess = (Essentials) server.getPluginManager().getPlugin("Essentials"); ess = (Essentials) server.getPluginManager().getPlugin("Essentials");
ConsoleLogger.info("Hooked correctly with Essentials"); ConsoleLogger.info("Hooked correctly with Essentials");
} catch (Exception | NoClassDefFoundError ingnored) { } catch (Exception | NoClassDefFoundError ignored) {
ess = null; ess = null;
} }
} else { } else {
@ -677,7 +677,7 @@ public class AuthMe extends JavaPlugin {
try { try {
combatTagPlus = (CombatTagPlus) server.getPluginManager().getPlugin("CombatTagPlus"); combatTagPlus = (CombatTagPlus) server.getPluginManager().getPlugin("CombatTagPlus");
ConsoleLogger.info("Hooked correctly with CombatTagPlus"); ConsoleLogger.info("Hooked correctly with CombatTagPlus");
} catch (Exception | NoClassDefFoundError ingnored) { } catch (Exception | NoClassDefFoundError ignored) {
combatTagPlus = null; combatTagPlus = null;
} }
} else { } else {
@ -788,12 +788,12 @@ public class AuthMe extends JavaPlugin {
return spawnLoc; return spawnLoc;
} }
// Return the default spawnpoint of a world // Return the default spawn point of a world
private Location getDefaultSpawn(World world) { private Location getDefaultSpawn(World world) {
return world.getSpawnLocation(); return world.getSpawnLocation();
} }
// Return the multiverse spawnpoint of a world // Return the multiverse spawn point of a world
private Location getMultiverseSpawn(World world) { private Location getMultiverseSpawn(World world) {
if (multiverse != null && Settings.multiverse) { if (multiverse != null && Settings.multiverse) {
try { try {
@ -805,7 +805,7 @@ public class AuthMe extends JavaPlugin {
return null; return null;
} }
// Return the essentials spawnpoint // Return the essentials spawn point
private Location getEssentialsSpawn() { private Location getEssentialsSpawn() {
if (essentialsSpawn != null) { if (essentialsSpawn != null) {
return essentialsSpawn; return essentialsSpawn;
@ -813,7 +813,7 @@ public class AuthMe extends JavaPlugin {
return null; return null;
} }
// Return the authme soawnpoint // Return the AuthMe spawn point
private Location getAuthMeSpawn(Player player) { private Location getAuthMeSpawn(Player player) {
if ((!database.isAuthAvailable(player.getName().toLowerCase()) || !player.hasPlayedBefore()) && (Spawn.getInstance().getFirstSpawn() != null)) { if ((!database.isAuthAvailable(player.getName().toLowerCase()) || !player.hasPlayedBefore()) && (Spawn.getInstance().getFirstSpawn() != null)) {
return Spawn.getInstance().getFirstSpawn(); return Spawn.getInstance().getFirstSpawn();
@ -855,7 +855,7 @@ public class AuthMe extends JavaPlugin {
}, 1, 1200 * Settings.delayRecall); }, 1, 1200 * Settings.delayRecall);
} }
public String replaceAllInfos(String message, Player player) { public String replaceAllInfo(String message, Player player) {
int playersOnline = Utils.getOnlinePlayers().size(); int playersOnline = Utils.getOnlinePlayers().size();
message = message.replace("&", "\u00a7"); message = message.replace("&", "\u00a7");
message = message.replace("{PLAYER}", player.getName()); message = message.replace("{PLAYER}", player.getName());
@ -878,8 +878,8 @@ public class AuthMe extends JavaPlugin {
ip = realIp.get(name); ip = realIp.get(name);
} }
if (Settings.checkVeryGames) if (Settings.checkVeryGames)
if (getVeryGamesIP(player) != null) if (getVeryGamesIp(player) != null)
ip = getVeryGamesIP(player); ip = getVeryGamesIp(player);
return ip; return ip;
} }
@ -908,18 +908,19 @@ public class AuthMe extends JavaPlugin {
/** /**
* Gets a player's real IP through VeryGames method. * Gets a player's real IP through VeryGames method.
* *
* @param player the player to process * @param player The player to process.
* @return the real IP of the player *
* @return The real IP of the player.
*/ */
@Deprecated @Deprecated
public String getVeryGamesIP(Player player) { public String getVeryGamesIp(Player player) {
String realIP = player.getAddress().getAddress().getHostAddress(); String realIP = player.getAddress().getAddress().getHostAddress();
String sUrl = "http://monitor-1.verygames.net/api/?action=ipclean-real-ip&out=raw&ip=%IP%&port=%PORT%"; String sUrl = "http://monitor-1.verygames.net/api/?action=ipclean-real-ip&out=raw&ip=%IP%&port=%PORT%";
sUrl = sUrl.replace("%IP%", player.getAddress().getAddress().getHostAddress()).replace("%PORT%", "" + player.getAddress().getPort()); sUrl = sUrl.replace("%IP%", player.getAddress().getAddress().getHostAddress()).replace("%PORT%", "" + player.getAddress().getPort());
try { try {
URL url = new URL(sUrl); URL url = new URL(sUrl);
URLConnection urlc = url.openConnection(); URLConnection urlCon = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream())); BufferedReader in = new BufferedReader(new InputStreamReader(urlCon.getInputStream()));
String inputLine = in.readLine(); String inputLine = in.readLine();
if (inputLine != null && !inputLine.isEmpty() && !inputLine.equalsIgnoreCase("error") && !inputLine.contains("error")) { if (inputLine != null && !inputLine.isEmpty() && !inputLine.equalsIgnoreCase("error") && !inputLine.contains("error")) {
realIP = inputLine; realIP = inputLine;
@ -940,6 +941,7 @@ public class AuthMe extends JavaPlugin {
* @param cmd The command (Bukkit). * @param cmd The command (Bukkit).
* @param commandLabel The command label (Bukkit). * @param commandLabel The command label (Bukkit).
* @param args The command arguments (Bukkit). * @param args The command arguments (Bukkit).
*
* @return True if the command was executed, false otherwise. * @return True if the command was executed, false otherwise.
*/ */
@Override @Override

View File

@ -18,6 +18,7 @@ public class ConsoleFilter implements Filter {
* Method isLoggable. * Method isLoggable.
* *
* @param record LogRecord * @param record LogRecord
*
* @return boolean * @see java.util.logging.Filter#isLoggable(LogRecord) * @return boolean * @see java.util.logging.Filter#isLoggable(LogRecord)
*/ */
@Override @Override
@ -30,8 +31,8 @@ public class ConsoleFilter implements Filter {
return true; return true;
if (!logM.contains("/login ") && !logM.contains("/l ") && !logM.contains("/reg ") && !logM.contains("/changepassword ") && !logM.contains("/unregister ") && !logM.contains("/authme register ") && !logM.contains("/authme changepassword ") && !logM.contains("/authme reg ") && !logM.contains("/authme cp ") && !logM.contains("/register ")) if (!logM.contains("/login ") && !logM.contains("/l ") && !logM.contains("/reg ") && !logM.contains("/changepassword ") && !logM.contains("/unregister ") && !logM.contains("/authme register ") && !logM.contains("/authme changepassword ") && !logM.contains("/authme reg ") && !logM.contains("/authme cp ") && !logM.contains("/register "))
return true; return true;
String playername = record.getMessage().split(" ")[0]; String playerName = record.getMessage().split(" ")[0];
record.setMessage(playername + " issued an AuthMe command!"); record.setMessage(playerName + " issued an AuthMe command!");
return true; return true;
} catch (NullPointerException npe) { } catch (NullPointerException npe) {
return true; return true;

View File

@ -62,8 +62,8 @@ public final class ConsoleLogger {
} }
try { try {
Files.write(Settings.LOG_FILE.toPath(), (dateTime + ": " + message + StringUtils.newline).getBytes(), Files.write(Settings.LOG_FILE.toPath(), (dateTime + ": " + message + StringUtils.newline).getBytes(),
StandardOpenOption.APPEND, StandardOpenOption.APPEND,
StandardOpenOption.CREATE); StandardOpenOption.CREATE);
} catch (IOException ignored) { } catch (IOException ignored) {
} }
} }

View File

@ -1,261 +1,269 @@
package fr.xephi.authme; package fr.xephi.authme;
import fr.xephi.authme.permission.PermissionsManager; import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.Utils; import fr.xephi.authme.util.Utils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService; import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.Future; import java.util.concurrent.Future;
/** /**
*/ */
public class DataManager { public class DataManager {
public AuthMe plugin; public final AuthMe plugin;
/** /**
* Constructor for DataManager. * Constructor for DataManager.
* *
* @param plugin AuthMe * @param plugin AuthMe
*/ */
public DataManager(AuthMe plugin) { public DataManager(AuthMe plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
public void run() { /**
} * Method getOfflinePlayer.
*
/** * @param name String
* Method getOfflinePlayer. *
* * @return OfflinePlayer
* @param name String */
* @return OfflinePlayer public synchronized OfflinePlayer getOfflinePlayer(final String name) {
*/ ExecutorService executor = Executors.newSingleThreadExecutor();
public synchronized OfflinePlayer getOfflinePlayer(final String name) { Future<OfflinePlayer> result = executor.submit(new Callable<OfflinePlayer>() {
ExecutorService executor = Executors.newSingleThreadExecutor();
Future<OfflinePlayer> result = executor.submit(new Callable<OfflinePlayer>() { public synchronized OfflinePlayer call() throws Exception {
OfflinePlayer result = null;
public synchronized OfflinePlayer call() throws Exception { try {
OfflinePlayer result = null; for (OfflinePlayer op : Bukkit.getOfflinePlayers())
try { if (op.getName().equalsIgnoreCase(name)) {
for (OfflinePlayer op : Bukkit.getOfflinePlayers()) result = op;
if (op.getName().equalsIgnoreCase(name)) { break;
result = op; }
break; } catch (Exception ignored) {
} }
} catch (Exception e) { return result;
} }
return result; });
} try {
}); return result.get();
try { } catch (Exception e) {
return result.get(); return (null);
} catch (Exception e) { } finally {
return (null); executor.shutdown();
} finally { }
executor.shutdown(); }
}
} /**
* Method purgeAntiXray.
/** *
* Method purgeAntiXray. * @param cleared List<String>
* */
* @param cleared List<String> public synchronized void purgeAntiXray(List<String> cleared) {
*/ int i = 0;
public synchronized void purgeAntiXray(List<String> cleared) { for (String name : cleared) {
int i = 0; try {
for (String name : cleared) { org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
try { if (player == null)
org.bukkit.OfflinePlayer player = getOfflinePlayer(name); continue;
if (player == null) String playerName = player.getName();
continue; File playerFile = new File("." + File.separator + "plugins" + File.separator + "AntiXRayData" + File.separator + "PlayerData" + File.separator + playerName);
String playerName = player.getName(); if (playerFile.exists()) {
File playerFile = new File("." + File.separator + "plugins" + File.separator + "AntiXRayData" + File.separator + "PlayerData" + File.separator + playerName); //noinspection ResultOfMethodCallIgnored
if (playerFile.exists()) { playerFile.delete();
playerFile.delete(); i++;
i++; }
} } catch (Exception ignored) {
} catch (Exception e) { }
} }
} ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " AntiXRayData Files");
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " AntiXRayData Files"); }
}
/**
/** * Method purgeLimitedCreative.
* Method purgeLimitedCreative. *
* * @param cleared List<String>
* @param cleared List<String> */
*/ public synchronized void purgeLimitedCreative(List<String> cleared) {
public synchronized void purgeLimitedCreative(List<String> cleared) { int i = 0;
int i = 0; for (String name : cleared) {
for (String name : cleared) { try {
try { org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
org.bukkit.OfflinePlayer player = getOfflinePlayer(name); if (player == null)
if (player == null) continue;
continue; String playerName = player.getName();
String playerName = player.getName(); File playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + ".yml");
File playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + ".yml"); if (playerFile.exists()) {
if (playerFile.exists()) { //noinspection ResultOfMethodCallIgnored
playerFile.delete(); playerFile.delete();
i++; i++;
} }
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_creative.yml"); playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_creative.yml");
if (playerFile.exists()) { if (playerFile.exists()) {
playerFile.delete(); //noinspection ResultOfMethodCallIgnored
i++; playerFile.delete();
} i++;
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_adventure.yml"); }
if (playerFile.exists()) { playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_adventure.yml");
playerFile.delete(); if (playerFile.exists()) {
i++; //noinspection ResultOfMethodCallIgnored
} playerFile.delete();
} catch (Exception e) { i++;
} }
} } catch (Exception ignored) {
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " LimitedCreative Survival, Creative and Adventure files"); }
} }
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " LimitedCreative Survival, Creative and Adventure files");
/** }
* Method purgeDat.
* /**
* @param cleared List<String> * Method purgeDat.
*/ *
public synchronized void purgeDat(List<String> cleared) { * @param cleared List<String>
int i = 0; */
for (String name : cleared) { public synchronized void purgeDat(List<String> cleared) {
try { int i = 0;
org.bukkit.OfflinePlayer player = getOfflinePlayer(name); for (String name : cleared) {
if (player == null) { try {
continue; org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
} if (player == null) {
continue;
try { }
File playerFile = new File(plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + player.getUniqueId() + ".dat");
playerFile.delete(); try {
i++; File playerFile = new File(plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + player.getUniqueId() + ".dat");
} catch (Exception ignore) { //noinspection ResultOfMethodCallIgnored
File playerFile = new File(plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + player.getName() + ".dat"); playerFile.delete();
if (playerFile.exists()) { i++;
playerFile.delete(); } catch (Exception ignore) {
i++; File playerFile = new File(plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + player.getName() + ".dat");
} if (playerFile.exists()) {
} //noinspection ResultOfMethodCallIgnored
} catch (Exception ignore) { playerFile.delete();
} i++;
} }
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " .dat Files"); }
} } catch (Exception ignore) {
}
/** }
* Method purgeEssentials. ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " .dat Files");
* }
* @param cleared List<String>
*/ /**
@SuppressWarnings("deprecation") * Method purgeEssentials.
public void purgeEssentials(List<String> cleared) { *
int i = 0; * @param cleared List<String>
for (String name : cleared) { */
try { @SuppressWarnings("deprecation")
File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + plugin.getServer().getOfflinePlayer(name).getUniqueId() + ".yml"); public void purgeEssentials(List<String> cleared) {
playerFile.delete(); int i = 0;
i++; for (String name : cleared) {
} catch (Exception e) { try {
File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + name + ".yml"); File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + plugin.getServer().getOfflinePlayer(name).getUniqueId() + ".yml");
if (playerFile.exists()) { //noinspection ResultOfMethodCallIgnored
playerFile.delete(); playerFile.delete();
i++; i++;
} } catch (Exception e) {
} File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + name + ".yml");
} if (playerFile.exists()) {
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles"); //noinspection ResultOfMethodCallIgnored
} playerFile.delete();
i++;
// TODO: What is this method for? Is it correct? }
}
/** }
* @param cleared Cleared players. ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
*/ }
public synchronized void purgePermissions(List<String> cleared) {
// Get the permissions manager, and make sure it's valid // TODO: What is this method for? Is it correct?
PermissionsManager permsMan = this.plugin.getPermissionsManager();
if (permsMan == null) /**
ConsoleLogger.showError("Unable to access permissions manager instance!"); * @param cleared Cleared players.
assert permsMan != null; */
public synchronized void purgePermissions(List<String> cleared) {
int i = 0; // Get the permissions manager, and make sure it's valid
for (String name : cleared) { PermissionsManager permsMan = this.plugin.getPermissionsManager();
try { if (permsMan == null)
permsMan.removeAllGroups(this.getOnlinePlayerLower(name.toLowerCase())); ConsoleLogger.showError("Unable to access permissions manager instance!");
i++; assert permsMan != null;
} catch (Exception e) {
} int i = 0;
} for (String name : cleared) {
ConsoleLogger.info("AutoPurgeDatabase : Removed " + i + " permissions"); try {
permsMan.removeAllGroups(this.getOnlinePlayerLower(name.toLowerCase()));
/*int i = 0; i++;
for (String name : cleared) { } catch (Exception ignored) {
try { }
OfflinePlayer p = this.getOfflinePlayer(name); }
for (String group : permission.getPlayerGroups((Player) p)) { ConsoleLogger.info("AutoPurgeDatabase : Removed " + i + " permissions");
permission.playerRemoveGroup(null, p, group);
} /*int i = 0;
i++; for (String name : cleared) {
} catch (Exception e) { try {
} OfflinePlayer p = this.getOfflinePlayer(name);
} for (String group : permission.getPlayerGroups((Player) p)) {
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " Permissions");*/ permission.playerRemoveGroup(null, p, group);
} }
i++;
/** } catch (Exception e) {
* Method isOnline. }
* }
* @param player Player ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " Permissions");*/
* @param name String }
* @return boolean
*/ /**
public boolean isOnline(Player player, final String name) { * Method isOnline.
if (player.isOnline()) *
return true; * @param player Player
ExecutorService executor = Executors.newSingleThreadExecutor(); * @param name String
Future<Boolean> result = executor.submit(new Callable<Boolean>() { *
* @return boolean
@Override */
public synchronized Boolean call() throws Exception { public boolean isOnline(Player player, final String name) {
for (OfflinePlayer op : Utils.getOnlinePlayers()) if (player.isOnline())
if (op.getName().equalsIgnoreCase(name)) { return true;
return true; ExecutorService executor = Executors.newSingleThreadExecutor();
} Future<Boolean> result = executor.submit(new Callable<Boolean>() {
return false;
} @Override
}); public synchronized Boolean call() throws Exception {
try { for (OfflinePlayer op : Utils.getOnlinePlayers())
return result.get(); if (op.getName().equalsIgnoreCase(name)) {
} catch (Exception e) { return true;
return false; }
} finally { return false;
executor.shutdown(); }
} });
} try {
return result.get();
/** } catch (Exception e) {
* Method getOnlinePlayerLower. return false;
* } finally {
* @param name String executor.shutdown();
* @return Player }
*/ }
public Player getOnlinePlayerLower(String name) {
name = name.toLowerCase(); /**
for (Player player : Utils.getOnlinePlayers()) { * Method getOnlinePlayerLower.
if (player.getName().equalsIgnoreCase(name)) *
return player; * @param name String
} *
return null; * @return Player
} */
} public Player getOnlinePlayerLower(String name) {
name = name.toLowerCase();
for (Player player : Utils.getOnlinePlayers()) {
if (player.getName().equalsIgnoreCase(name))
return player;
}
return null;
}
}

View File

@ -1,40 +1,40 @@
package fr.xephi.authme; package fr.xephi.authme;
import java.awt.*; import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
/** /**
*/ */
public class ImageGenerator { public class ImageGenerator {
private String pass; private final String pass;
/** /**
* Constructor for ImageGenerator. * Constructor for ImageGenerator.
* *
* @param pass String * @param pass String
*/ */
public ImageGenerator(String pass) { public ImageGenerator(String pass) {
this.pass = pass; this.pass = pass;
} }
/** /**
* Method generateImage. * Method generateImage.
* *
* @return BufferedImage * @return BufferedImage
*/ */
public BufferedImage generateImage() { public BufferedImage generateImage() {
BufferedImage image = new BufferedImage(200, 60, BufferedImage.TYPE_BYTE_INDEXED); BufferedImage image = new BufferedImage(200, 60, BufferedImage.TYPE_BYTE_INDEXED);
Graphics2D graphics = image.createGraphics(); Graphics2D graphics = image.createGraphics();
graphics.setColor(Color.BLACK); graphics.setColor(Color.BLACK);
graphics.fillRect(0, 0, 200, 40); graphics.fillRect(0, 0, 200, 40);
GradientPaint gradientPaint = new GradientPaint(10, 5, Color.WHITE, 20, 10, Color.WHITE, true); GradientPaint gradientPaint = new GradientPaint(10, 5, Color.WHITE, 20, 10, Color.WHITE, true);
graphics.setPaint(gradientPaint); graphics.setPaint(gradientPaint);
Font font = new Font("Comic Sans MS", Font.BOLD, 30); Font font = new Font("Comic Sans MS", Font.BOLD, 30);
graphics.setFont(font); graphics.setFont(font);
graphics.drawString(pass, 5, 30); graphics.drawString(pass, 5, 30);
graphics.dispose(); graphics.dispose();
image.flush(); image.flush();
return image; return image;
} }
} }

View File

@ -19,8 +19,8 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
* List of commands (lower-case) to skip. * List of commands (lower-case) to skip.
*/ */
private static final String[] COMMANDS_TO_SKIP = {"/login ", "/l ", "/reg ", "/changepassword ", private static final String[] COMMANDS_TO_SKIP = {"/login ", "/l ", "/reg ", "/changepassword ",
"/unregister ", "/authme register ", "/authme changepassword ", "/authme reg ", "/authme cp ", "/unregister ", "/authme register ", "/authme changepassword ", "/authme reg ", "/authme cp ",
"/register "}; "/register "};
/** /**
* Constructor. * Constructor.
@ -34,6 +34,7 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
* data. * data.
* *
* @param message the Message object to verify * @param message the Message object to verify
*
* @return the Result value * @return the Result value
*/ */
private static Result validateMessage(Message message) { private static Result validateMessage(Message message) {
@ -48,6 +49,7 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
* depending on whether the message contains sensitive AuthMe data. * depending on whether the message contains sensitive AuthMe data.
* *
* @param message the message to verify * @param message the message to verify
*
* @return the Result value * @return the Result value
*/ */
private static Result validateMessage(String message) { private static Result validateMessage(String message) {
@ -57,7 +59,7 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
String lowerMessage = message.toLowerCase(); String lowerMessage = message.toLowerCase();
if (lowerMessage.contains("issued server command:") if (lowerMessage.contains("issued server command:")
&& StringUtils.containsAny(lowerMessage, COMMANDS_TO_SKIP)) { && StringUtils.containsAny(lowerMessage, COMMANDS_TO_SKIP)) {
return Result.DENY; return Result.DENY;
} }
return Result.NEUTRAL; return Result.NEUTRAL;

View File

@ -14,13 +14,13 @@ import java.util.Date;
*/ */
public class PerformBackup { public class PerformBackup {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH-mm"); final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH-mm");
String dateString = format.format(new Date()); final String dateString = format.format(new Date());
private String dbName = Settings.getMySQLDatabase; private final String dbName = Settings.getMySQLDatabase;
private String dbUserName = Settings.getMySQLUsername; private final String dbUserName = Settings.getMySQLUsername;
private String dbPassword = Settings.getMySQLPassword; private final String dbPassword = Settings.getMySQLPassword;
private String tblname = Settings.getMySQLTablename; private final String tblname = Settings.getMySQLTablename;
private String path = AuthMe.getInstance().getDataFolder() + File.separator + "backups" + File.separator + "backup" + dateString; private final String path = AuthMe.getInstance().getDataFolder() + File.separator + "backups" + File.separator + "backup" + dateString;
private AuthMe instance; private AuthMe instance;
/** /**
@ -38,7 +38,7 @@ public class PerformBackup {
* @param cause BackupCause The cause of the backup. * @param cause BackupCause The cause of the backup.
*/ */
public void doBackup(BackupCause cause) { public void doBackup(BackupCause cause) {
if(!Settings.isBackupActivated) { if (!Settings.isBackupActivated) {
ConsoleLogger.showError("Can't perform a Backup: disabled in configuration. Cause of the Backup: " + cause.name()); ConsoleLogger.showError("Can't perform a Backup: disabled in configuration. Cause of the Backup: " + cause.name());
} }
// Check whether a backup should be made at the specified point in time // Check whether a backup should be made at the specified point in time
@ -128,6 +128,7 @@ public class PerformBackup {
* Method FileBackup. * Method FileBackup.
* *
* @param backend String * @param backend String
*
* @return boolean * @return boolean
*/ */
private boolean FileBackup(String backend) { private boolean FileBackup(String backend) {
@ -150,11 +151,12 @@ public class PerformBackup {
* Method checkWindows. * Method checkWindows.
* *
* @param windowsPath String * @param windowsPath String
*
* @return boolean * @return boolean
*/ */
private boolean checkWindows(String windowsPath) { private boolean checkWindows(String windowsPath) {
String isWin = System.getProperty("os.name").toLowerCase(); String isWin = System.getProperty("os.name").toLowerCase();
if (isWin.indexOf("win") >= 0) { if (isWin.contains("win")) {
if (new File(windowsPath + "\\bin\\mysqldump.exe").exists()) { if (new File(windowsPath + "\\bin\\mysqldump.exe").exists()) {
return true; return true;
} else { } else {
@ -174,6 +176,7 @@ public class PerformBackup {
* *
* @param src File * @param src File
* @param dst File * @param dst File
*
* @throws IOException * @throws IOException
*/ */
void copy(File src, File dst) throws IOException { void copy(File src, File dst) throws IOException {

View File

@ -16,7 +16,7 @@ import java.io.File;
*/ */
public class SendMailSSL { public class SendMailSSL {
public AuthMe plugin; public final AuthMe plugin;
/** /**
* Constructor for SendMailSSL. * Constructor for SendMailSSL.
@ -34,15 +34,15 @@ public class SendMailSSL {
* @param newPass String * @param newPass String
*/ */
public void main(final PlayerAuth auth, final String newPass) { public void main(final PlayerAuth auth, final String newPass) {
String sendername; String senderName;
if (Settings.getmailSenderName == null || Settings.getmailSenderName.isEmpty()) { if (Settings.getmailSenderName == null || Settings.getmailSenderName.isEmpty()) {
sendername = Settings.getmailAccount; senderName = Settings.getmailAccount;
} else { } else {
sendername = Settings.getmailSenderName; senderName = Settings.getmailSenderName;
} }
final String sender = sendername; final String sender = senderName;
final int port = Settings.getMailPort; final int port = Settings.getMailPort;
final String acc = Settings.getmailAccount; final String acc = Settings.getmailAccount;
final String subject = Settings.getMailSubject; final String subject = Settings.getMailSubject;
@ -90,6 +90,7 @@ public class SendMailSSL {
ConsoleLogger.showError("Fail to send a mail to " + mail); ConsoleLogger.showError("Fail to send a mail to " + mail);
} }
if (file != null) if (file != null)
//noinspection ResultOfMethodCallIgnored
file.delete(); file.delete();
} catch (Exception e) { } catch (Exception e) {

View File

@ -50,6 +50,7 @@ public class API {
/** /**
* @param player * @param player
*
* @return true if player is authenticate * @return true if player is authenticate
*/ */
@Deprecated @Deprecated
@ -59,6 +60,7 @@ public class API {
/** /**
* @param player * @param player
*
* @return true if the player is unrestricted * @return true if the player is unrestricted
*/ */
@Deprecated @Deprecated
@ -70,6 +72,7 @@ public class API {
* Method getLastLocation. * Method getLastLocation.
* *
* @param player Player * @param player Player
*
* @return Location * @return Location
*/ */
@Deprecated @Deprecated
@ -102,12 +105,13 @@ public class API {
try { try {
player.getInventory().setContents(content); player.getInventory().setContents(content);
player.getInventory().setArmorContents(armor); player.getInventory().setArmorContents(armor);
} catch (NullPointerException npe) { } catch (NullPointerException ignored) {
} }
} }
/** /**
* @param playerName * @param playerName
*
* @return true if player is registered * @return true if player is registered
*/ */
@Deprecated @Deprecated
@ -119,6 +123,7 @@ public class API {
/** /**
* @param playerName String * @param playerName String
* @param passwordToCheck String * @param passwordToCheck String
*
* @return true if the password is correct , false else * @return true if the password is correct , false else
*/ */
@Deprecated @Deprecated
@ -140,6 +145,7 @@ public class API {
* *
* @param playerName String * @param playerName String
* @param password String * @param password String
*
* @return true if the player is register correctly * @return true if the player is register correctly
*/ */
@Deprecated @Deprecated
@ -151,10 +157,7 @@ public class API {
return false; return false;
} }
PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0, "your@email.com", playerName); PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0, "your@email.com", playerName);
if (!instance.database.saveAuth(auth)) { return instance.database.saveAuth(auth);
return false;
}
return true;
} catch (NoSuchAlgorithmException ex) { } catch (NoSuchAlgorithmException ex) {
return false; return false;
} }
@ -182,6 +185,7 @@ public class API {
/** /**
* @param player * @param player
*
* @return true if player is a npc * @return true if player is a npc
*/ */
@Deprecated @Deprecated
@ -191,6 +195,7 @@ public class API {
/** /**
* @param player * @param player
*
* @return true if player is a npc * @return true if player is a npc
*/ */
@Deprecated @Deprecated

View File

@ -19,7 +19,7 @@ import java.security.NoSuchAlgorithmException;
public class NewAPI { public class NewAPI {
public static NewAPI singleton; public static NewAPI singleton;
public AuthMe plugin; public final AuthMe plugin;
/** /**
* Constructor for NewAPI. * Constructor for NewAPI.
@ -33,10 +33,10 @@ public class NewAPI {
/** /**
* Constructor for NewAPI. * Constructor for NewAPI.
* *
* @param serv Server * @param server Server
*/ */
public NewAPI(Server serv) { public NewAPI(Server server) {
this.plugin = (AuthMe) serv.getPluginManager().getPlugin("AuthMe"); this.plugin = (AuthMe) server.getPluginManager().getPlugin("AuthMe");
} }
/** /**
@ -67,6 +67,7 @@ public class NewAPI {
/** /**
* @param player * @param player
*
* @return true if player is authenticate * @return true if player is authenticate
*/ */
public boolean isAuthenticated(Player player) { public boolean isAuthenticated(Player player) {
@ -75,6 +76,7 @@ public class NewAPI {
/** /**
* @param player * @param player
*
* @return true if player is a npc * @return true if player is a npc
*/ */
public boolean isNPC(Player player) { public boolean isNPC(Player player) {
@ -83,6 +85,7 @@ public class NewAPI {
/** /**
* @param player * @param player
*
* @return true if the player is unrestricted * @return true if the player is unrestricted
*/ */
public boolean isUnrestricted(Player player) { public boolean isUnrestricted(Player player) {
@ -93,6 +96,7 @@ public class NewAPI {
* Method getLastLocation. * Method getLastLocation.
* *
* @param player Player * @param player Player
*
* @return Location * @return Location
*/ */
public Location getLastLocation(Player player) { public Location getLastLocation(Player player) {
@ -112,6 +116,7 @@ public class NewAPI {
/** /**
* @param playerName * @param playerName
*
* @return true if player is registered * @return true if player is registered
*/ */
public boolean isRegistered(String playerName) { public boolean isRegistered(String playerName) {
@ -122,6 +127,7 @@ public class NewAPI {
/** /**
* @param playerName String * @param playerName String
* @param passwordToCheck String * @param passwordToCheck String
*
* @return true if the password is correct , false else * @return true if the password is correct , false else
*/ */
public boolean checkPassword(String playerName, String passwordToCheck) { public boolean checkPassword(String playerName, String passwordToCheck) {
@ -141,6 +147,7 @@ public class NewAPI {
* *
* @param playerName String * @param playerName String
* @param password String * @param password String
*
* @return true if the player is register correctly * @return true if the player is register correctly
*/ */
public boolean registerPlayer(String playerName, String password) { public boolean registerPlayer(String playerName, String password) {

View File

@ -16,7 +16,7 @@ public class PlayerAuth {
private double z; private double z;
private String world; private String world;
private String salt; private String salt;
private int groupId; private final int groupId;
private String email; private String email;
private String realName; private String realName;
@ -405,6 +405,7 @@ public class PlayerAuth {
* Method equals. * Method equals.
* *
* @param obj Object * @param obj Object
*
* @return boolean * @return boolean
*/ */
@Override @Override
@ -437,12 +438,12 @@ public class PlayerAuth {
@Override @Override
public String toString() { public String toString() {
return ("Player : " + nickname + " | " + realName return ("Player : " + nickname + " | " + realName
+ " ! IP : " + ip + " ! IP : " + ip
+ " ! LastLogin : " + lastLogin + " ! LastLogin : " + lastLogin
+ " ! LastPosition : " + x + "," + y + "," + z + "," + world + " ! LastPosition : " + x + "," + y + "," + z + "," + world
+ " ! Email : " + email + " ! Email : " + email
+ " ! Hash : " + hash + " ! Hash : " + hash
+ " ! Salt : " + salt); + " ! Salt : " + salt);
} }
} }

View File

@ -7,7 +7,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class PlayerCache { public class PlayerCache {
private volatile static PlayerCache singleton; private volatile static PlayerCache singleton;
private ConcurrentHashMap<String, PlayerAuth> cache; private final ConcurrentHashMap<String, PlayerAuth> cache;
private PlayerCache() { private PlayerCache() {
cache = new ConcurrentHashMap<>(); cache = new ConcurrentHashMap<>();
@ -57,6 +57,7 @@ public class PlayerCache {
* Method isAuthenticated. * Method isAuthenticated.
* *
* @param user String * @param user String
*
* @return boolean * @return boolean
*/ */
public boolean isAuthenticated(String user) { public boolean isAuthenticated(String user) {
@ -67,6 +68,7 @@ public class PlayerCache {
* Method getAuth. * Method getAuth.
* *
* @param user String * @param user String
*
* @return PlayerAuth * @return PlayerAuth
*/ */
public PlayerAuth getAuth(String user) { public PlayerAuth getAuth(String user) {

View File

@ -4,9 +4,9 @@ package fr.xephi.authme.cache.backup;
*/ */
public class DataFileCache { public class DataFileCache {
private String group; private final String group;
private boolean operator; private final boolean operator;
private boolean flying; private final boolean flying;
/** /**
* Constructor for DataFileCache. * Constructor for DataFileCache.

View File

@ -25,10 +25,10 @@ public class JsonCache {
ConsoleLogger.showError("Failed to create cache directory."); ConsoleLogger.showError("Failed to create cache directory.");
} }
gson = new GsonBuilder() gson = new GsonBuilder()
.registerTypeAdapter(DataFileCache.class, new PlayerDataSerializer()) .registerTypeAdapter(DataFileCache.class, new PlayerDataSerializer())
.registerTypeAdapter(DataFileCache.class, new PlayerDataDeserializer()) .registerTypeAdapter(DataFileCache.class, new PlayerDataDeserializer())
.setPrettyPrinting() .setPrettyPrinting()
.create(); .create();
} }
/** /**
@ -70,6 +70,7 @@ public class JsonCache {
* Method readCache. * Method readCache.
* *
* @param player Player * @param player Player
*
* @return DataFileCache * @return DataFileCache
*/ */
public DataFileCache readCache(Player player) { public DataFileCache readCache(Player player) {
@ -119,6 +120,7 @@ public class JsonCache {
* Method doesCacheExist. * Method doesCacheExist.
* *
* @param player Player * @param player Player
*
* @return boolean * @return boolean
*/ */
public boolean doesCacheExist(Player player) { public boolean doesCacheExist(Player player) {
@ -141,6 +143,7 @@ public class JsonCache {
* @param jsonElement JsonElement * @param jsonElement JsonElement
* @param type Type * @param type Type
* @param jsonDeserializationContext JsonDeserializationContext * @param jsonDeserializationContext JsonDeserializationContext
*
* @return DataFileCache * @throws JsonParseException * @see com.google.gson.JsonDeserializer#deserialize(JsonElement, Type, JsonDeserializationContext) * @return DataFileCache * @throws JsonParseException * @see com.google.gson.JsonDeserializer#deserialize(JsonElement, Type, JsonDeserializationContext)
*/ */
@Override @Override
@ -177,6 +180,7 @@ public class JsonCache {
* @param dataFileCache DataFileCache * @param dataFileCache DataFileCache
* @param type Type * @param type Type
* @param jsonSerializationContext JsonSerializationContext * @param jsonSerializationContext JsonSerializationContext
*
* @return JsonElement * @return JsonElement
*/ */
@Override @Override

View File

@ -19,9 +19,9 @@ import java.util.concurrent.ConcurrentHashMap;
public class LimboCache { public class LimboCache {
private volatile static LimboCache singleton; private volatile static LimboCache singleton;
public ConcurrentHashMap<String, LimboPlayer> cache; public final ConcurrentHashMap<String, LimboPlayer> cache;
public AuthMe plugin; public final AuthMe plugin;
private JsonCache playerData; private final JsonCache playerData;
/** /**
* Constructor for LimboCache. * Constructor for LimboCache.
@ -124,6 +124,7 @@ public class LimboCache {
* Method getLimboPlayer. * Method getLimboPlayer.
* *
* @param name String * @param name String
*
* @return LimboPlayer * @return LimboPlayer
*/ */
public LimboPlayer getLimboPlayer(String name) { public LimboPlayer getLimboPlayer(String name) {
@ -134,6 +135,7 @@ public class LimboCache {
* Method hasLimboPlayer. * Method hasLimboPlayer.
* *
* @param name String * @param name String
*
* @return boolean * @return boolean
*/ */
public boolean hasLimboPlayer(String name) { public boolean hasLimboPlayer(String name) {

View File

@ -8,7 +8,7 @@ import org.bukkit.scheduler.BukkitTask;
*/ */
public class LimboPlayer { public class LimboPlayer {
private String name; private final String name;
private Location loc = null; private Location loc = null;
private BukkitTask timeoutTaskId = null; private BukkitTask timeoutTaskId = null;
private BukkitTask messageTaskId = null; private BukkitTask messageTaskId = null;

View File

@ -117,6 +117,7 @@ public class CommandDescription {
* Check whether a label is valid to use. * Check whether a label is valid to use.
* *
* @param label The label to test. * @param label The label to test.
*
* @return True if the label is valid to use, false otherwise. * @return True if the label is valid to use, false otherwise.
*/ */
public static boolean isValidLabel(String label) { public static boolean isValidLabel(String label) {
@ -140,6 +141,7 @@ public class CommandDescription {
* *
* @param commandLabel The first command label. * @param commandLabel The first command label.
* @param otherCommandLabel The other command label. * @param otherCommandLabel The other command label.
*
* @return True if the labels are equal to each other. * @return True if the labels are equal to each other.
*/ */
private static boolean commandLabelEquals(String commandLabel, String otherCommandLabel) { private static boolean commandLabelEquals(String commandLabel, String otherCommandLabel) {
@ -178,6 +180,7 @@ public class CommandDescription {
* Get the label most similar to the reference. The first label will be returned if no reference was supplied. * Get the label most similar to the reference. The first label will be returned if no reference was supplied.
* *
* @param reference The command reference. * @param reference The command reference.
*
* @return The most similar label, or the first label. An empty label will be returned if no label was set. * @return The most similar label, or the first label. An empty label will be returned if no label was set.
*/ */
public String getLabel(CommandParts reference) { public String getLabel(CommandParts reference) {
@ -236,6 +239,7 @@ public class CommandDescription {
* @param commandLabel Command label to set. * @param commandLabel Command label to set.
* @param overwrite True to replace all old command labels, false to append this command label to the currently * @param overwrite True to replace all old command labels, false to append this command label to the currently
* existing labels. * existing labels.
*
* @return Trie if the command label is added, or if it was added already. False on failure. * @return Trie if the command label is added, or if it was added already. False on failure.
*/ */
public boolean setLabel(String commandLabel, boolean overwrite) { public boolean setLabel(String commandLabel, boolean overwrite) {
@ -252,6 +256,7 @@ public class CommandDescription {
* Add a command label to the list. * Add a command label to the list.
* *
* @param commandLabel Command label to add. * @param commandLabel Command label to add.
*
* @return True if the label was added, or if it was added already. False on error. * @return True if the label was added, or if it was added already. False on error.
*/ */
public boolean addLabel(String commandLabel) { public boolean addLabel(String commandLabel) {
@ -271,6 +276,7 @@ public class CommandDescription {
* Add a list of command labels. * Add a list of command labels.
* *
* @param commandLabels List of command labels to add. * @param commandLabels List of command labels to add.
*
* @return True if succeed, false on failure. * @return True if succeed, false on failure.
*/ */
public boolean addLabels(List<String> commandLabels) { public boolean addLabels(List<String> commandLabels) {
@ -285,6 +291,7 @@ public class CommandDescription {
* Check whether this command description has a specific command. * Check whether this command description has a specific command.
* *
* @param commandLabel Command to check for. * @param commandLabel Command to check for.
*
* @return True if this command label equals to the param command. * @return True if this command label equals to the param command.
*/ */
public boolean hasLabel(String commandLabel) { public boolean hasLabel(String commandLabel) {
@ -301,6 +308,7 @@ public class CommandDescription {
* Check whether this command description has a list of labels * Check whether this command description has a list of labels
* *
* @param commandLabels List of labels * @param commandLabels List of labels
*
* @return True if all labels match, false otherwise * @return True if all labels match, false otherwise
*/ */
public boolean hasLabels(List<String> commandLabels) { public boolean hasLabels(List<String> commandLabels) {
@ -318,6 +326,7 @@ public class CommandDescription {
* are suitable too. * are suitable too.
* *
* @param commandReference The command reference. * @param commandReference The command reference.
*
* @return True if the command reference is suitable to this command label, false otherwise. * @return True if the command reference is suitable to this command label, false otherwise.
*/ */
public boolean isSuitableLabel(CommandParts commandReference) { public boolean isSuitableLabel(CommandParts commandReference) {
@ -345,6 +354,7 @@ public class CommandDescription {
* Get the absolute command label. * Get the absolute command label.
* *
* @param includeSlash boolean * @param includeSlash boolean
*
* @return Absolute command label. * @return Absolute command label.
*/ */
public String getAbsoluteLabel(boolean includeSlash) { public String getAbsoluteLabel(boolean includeSlash) {
@ -356,6 +366,7 @@ public class CommandDescription {
* *
* @param includeSlash boolean * @param includeSlash boolean
* @param reference CommandParts * @param reference CommandParts
*
* @return Absolute command label. * @return Absolute command label.
*/ */
public String getAbsoluteLabel(boolean includeSlash, CommandParts reference) { public String getAbsoluteLabel(boolean includeSlash, CommandParts reference) {
@ -372,6 +383,7 @@ public class CommandDescription {
* Get the command reference. * Get the command reference.
* *
* @param reference The reference to use as template, which is used to choose the most similar reference. * @param reference The reference to use as template, which is used to choose the most similar reference.
*
* @return Command reference. * @return Command reference.
*/ */
public CommandParts getCommandReference(CommandParts reference) { public CommandParts getCommandReference(CommandParts reference) {
@ -393,6 +405,7 @@ public class CommandDescription {
* Get the difference between this command and another command reference. * Get the difference between this command and another command reference.
* *
* @param other The other command reference. * @param other The other command reference.
*
* @return The command difference. Zero if there's no difference. A negative number on error. * @return The command difference. Zero if there's no difference. A negative number on error.
*/ */
public double getCommandDifference(CommandParts other) { public double getCommandDifference(CommandParts other) {
@ -404,6 +417,7 @@ public class CommandDescription {
* *
* @param other The other command reference. * @param other The other command reference.
* @param fullCompare True to fully compare both command references. * @param fullCompare True to fully compare both command references.
*
* @return The command difference. Zero if there's no difference. A negative number on error. * @return The command difference. Zero if there's no difference. A negative number on error.
*/ */
public double getCommandDifference(CommandParts other, boolean fullCompare) { public double getCommandDifference(CommandParts other, boolean fullCompare) {
@ -451,6 +465,7 @@ public class CommandDescription {
* @param sender The command sender that triggered the execution of this command. * @param sender The command sender that triggered the execution of this command.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
*
* @return True on success, false on failure. * @return True on success, false on failure.
*/ */
public boolean execute(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) { public boolean execute(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
@ -489,6 +504,7 @@ public class CommandDescription {
* Set the parent command. * Set the parent command.
* *
* @param parent Parent command. * @param parent Parent command.
*
* @return True on success, false on failure. * @return True on success, false on failure.
*/ */
public boolean setParent(CommandDescription parent) { public boolean setParent(CommandDescription parent) {
@ -543,6 +559,7 @@ public class CommandDescription {
* Add a child to the command description. * Add a child to the command description.
* *
* @param commandDescription The child to add. * @param commandDescription The child to add.
*
* @return True on success, false on failure. * @return True on success, false on failure.
*/ */
public boolean addChild(CommandDescription commandDescription) { public boolean addChild(CommandDescription commandDescription) {
@ -569,7 +586,7 @@ public class CommandDescription {
* *
* @return True if this command has any child labels. * @return True if this command has any child labels.
*/ */
public boolean hasChilds() { public boolean hasChildren() {
return (this.children.size() != 0); return (this.children.size() != 0);
} }
@ -577,6 +594,7 @@ public class CommandDescription {
* Check if this command description has a specific child. * Check if this command description has a specific child.
* *
* @param commandDescription The command description to check for. * @param commandDescription The command description to check for.
*
* @return True if this command description has the specific child, false otherwise. * @return True if this command description has the specific child, false otherwise.
*/ */
public boolean isChild(CommandDescription commandDescription) { public boolean isChild(CommandDescription commandDescription) {
@ -594,6 +612,7 @@ public class CommandDescription {
* Add an argument. * Add an argument.
* *
* @param argument The argument to add. * @param argument The argument to add.
*
* @return True if succeed, false if failed. * @return True if succeed, false if failed.
*/ */
public boolean addArgument(CommandArgumentDescription argument) { public boolean addArgument(CommandArgumentDescription argument) {
@ -636,6 +655,7 @@ public class CommandDescription {
* Check whether an argument exists. * Check whether an argument exists.
* *
* @param argument The argument to check for. * @param argument The argument to check for.
*
* @return True if this argument already exists, false otherwise. * @return True if this argument already exists, false otherwise.
*/ */
public boolean hasArgument(CommandArgumentDescription argument) { public boolean hasArgument(CommandArgumentDescription argument) {
@ -771,6 +791,7 @@ public class CommandDescription {
* Find the best suitable command for a query reference. * Find the best suitable command for a query reference.
* *
* @param queryReference The query reference to find a command for. * @param queryReference The query reference to find a command for.
*
* @return The command found, or null. * @return The command found, or null.
*/ */
public FoundCommandResult findCommand(final CommandParts queryReference) { public FoundCommandResult findCommand(final CommandParts queryReference) {
@ -781,10 +802,10 @@ public class CommandDescription {
// Check whether this description is for the last element in the command reference, if so return the current command // Check whether this description is for the last element in the command reference, if so return the current command
if (queryReference.getCount() <= getParentCount() + 1) if (queryReference.getCount() <= getParentCount() + 1)
return new FoundCommandResult( return new FoundCommandResult(
this, this,
getCommandReference(queryReference), getCommandReference(queryReference),
new CommandParts(), new CommandParts(),
queryReference); queryReference);
// Get the new command reference and arguments // Get the new command reference and arguments
CommandParts newReference = new CommandParts(queryReference.getRange(0, getParentCount() + 1)); CommandParts newReference = new CommandParts(queryReference.getRange(0, getParentCount() + 1));
@ -798,8 +819,8 @@ public class CommandDescription {
@Override @Override
public int compare(CommandDescription o1, CommandDescription o2) { public int compare(CommandDescription o1, CommandDescription o2) {
return Double.compare( return Double.compare(
o1.getCommandDifference(queryReference), o1.getCommandDifference(queryReference),
o2.getCommandDifference(queryReference)); o2.getCommandDifference(queryReference));
} }
}); });
@ -832,6 +853,7 @@ public class CommandDescription {
* Check whether there's any command description that matches the specified command reference. * Check whether there's any command description that matches the specified command reference.
* *
* @param commandReference The command reference. * @param commandReference The command reference.
*
* @return True if so, false otherwise. * @return True if so, false otherwise.
*/ */
public boolean hasSuitableCommand(CommandParts commandReference) { public boolean hasSuitableCommand(CommandParts commandReference) {
@ -842,6 +864,7 @@ public class CommandDescription {
* Check if the remaining command reference elements are suitable with arguments of the current command description. * Check if the remaining command reference elements are suitable with arguments of the current command description.
* *
* @param commandReference The command reference. * @param commandReference The command reference.
*
* @return True if the arguments are suitable, false otherwise. * @return True if the arguments are suitable, false otherwise.
*/ */
public boolean hasSuitableArguments(CommandParts commandReference) { public boolean hasSuitableArguments(CommandParts commandReference) {
@ -853,6 +876,7 @@ public class CommandDescription {
* and get the difference in argument count. * and get the difference in argument count.
* *
* @param commandReference The command reference. * @param commandReference The command reference.
*
* @return The difference in argument count between the reference and the actual command. * @return The difference in argument count between the reference and the actual command.
*/ */
public int getSuitableArgumentsDifference(CommandParts commandReference) { public int getSuitableArgumentsDifference(CommandParts commandReference) {

View File

@ -89,6 +89,7 @@ public class CommandHandler {
* @param bukkitCommand The command (Bukkit). * @param bukkitCommand The command (Bukkit).
* @param bukkitCommandLabel The command label (Bukkit). * @param bukkitCommandLabel The command label (Bukkit).
* @param bukkitArgs The command arguments (Bukkit). * @param bukkitArgs The command arguments (Bukkit).
*
* @return True if the command was executed, false otherwise. * @return True if the command was executed, false otherwise.
*/ */
public boolean onCommand(CommandSender sender, org.bukkit.command.Command bukkitCommand, String bukkitCommandLabel, String[] bukkitArgs) { public boolean onCommand(CommandSender sender, org.bukkit.command.Command bukkitCommand, String bukkitCommandLabel, String[] bukkitArgs) {
@ -133,7 +134,7 @@ public class CommandHandler {
// Show the suggested command // Show the suggested command
sender.sendMessage(ChatColor.DARK_RED + "Unknown command, assuming " + ChatColor.GOLD + "/" + suggestedCommandParts + sender.sendMessage(ChatColor.DARK_RED + "Unknown command, assuming " + ChatColor.GOLD + "/" + suggestedCommandParts +
ChatColor.DARK_RED + "!"); ChatColor.DARK_RED + "!");
} }
// Make sure the command is executable // Make sure the command is executable
@ -181,6 +182,7 @@ public class CommandHandler {
* Process the command arguments, and return them as an array list. * Process the command arguments, and return them as an array list.
* *
* @param args The command arguments to process. * @param args The command arguments to process.
*
* @return The processed command arguments. * @return The processed command arguments.
*/ */
private List<String> processArguments(String[] args) { private List<String> processArguments(String[] args) {

View File

@ -20,7 +20,7 @@ public class CommandManager {
/** /**
* The list of commandDescriptions. * The list of commandDescriptions.
*/ */
private List<CommandDescription> commandDescriptions = new ArrayList<>(); private final List<CommandDescription> commandDescriptions = new ArrayList<>();
/** /**
* Constructor. * Constructor.
@ -575,6 +575,7 @@ public class CommandManager {
* Find the best suitable command for the specified reference. * Find the best suitable command for the specified reference.
* *
* @param queryReference The query reference to find a command for. * @param queryReference The query reference to find a command for.
*
* @return The command found, or null. * @return The command found, or null.
*/ */
public FoundCommandResult findCommand(CommandParts queryReference) { public FoundCommandResult findCommand(CommandParts queryReference) {

View File

@ -12,7 +12,7 @@ public class CommandParts {
/** /**
* The list of parts for this command. * The list of parts for this command.
*/ */
private List<String> parts = new ArrayList<>(); private final List<String> parts = new ArrayList<>();
/** /**
* Constructor. * Constructor.
@ -71,6 +71,7 @@ public class CommandParts {
* Add a part. * Add a part.
* *
* @param part The part to add. * @param part The part to add.
*
* @return The result. * @return The result.
*/ */
public boolean add(String part) { public boolean add(String part) {
@ -81,6 +82,7 @@ public class CommandParts {
* Add some parts. * Add some parts.
* *
* @param parts The parts to add. * @param parts The parts to add.
*
* @return The result. * @return The result.
*/ */
public boolean add(List<String> parts) { public boolean add(List<String> parts) {
@ -91,6 +93,7 @@ public class CommandParts {
* Add some parts. * Add some parts.
* *
* @param parts The parts to add. * @param parts The parts to add.
*
* @return The result. * @return The result.
*/ */
public boolean add(String[] parts) { public boolean add(String[] parts) {
@ -112,6 +115,7 @@ public class CommandParts {
* Get a part by it's index. * Get a part by it's index.
* *
* @param i Part index. * @param i Part index.
*
* @return The part. * @return The part.
*/ */
public String get(int i) { public String get(int i) {
@ -127,6 +131,7 @@ public class CommandParts {
* Get a range of the parts starting at the specified index up to the end of the range. * Get a range of the parts starting at the specified index up to the end of the range.
* *
* @param start The starting index. * @param start The starting index.
*
* @return The parts range. Arguments that were out of bound are not included. * @return The parts range. Arguments that were out of bound are not included.
*/ */
public List<String> getRange(int start) { public List<String> getRange(int start) {
@ -138,6 +143,7 @@ public class CommandParts {
* *
* @param start The starting index. * @param start The starting index.
* @param count The number of parts to get. * @param count The number of parts to get.
*
* @return The parts range. Parts that were out of bound are not included. * @return The parts range. Parts that were out of bound are not included.
*/ */
public List<String> getRange(int start, int count) { public List<String> getRange(int start, int count) {
@ -160,6 +166,7 @@ public class CommandParts {
* Get the difference value between two references. This won't do a full compare, just the last reference parts instead. * Get the difference value between two references. This won't do a full compare, just the last reference parts instead.
* *
* @param other The other reference. * @param other The other reference.
*
* @return The result from zero to above. A negative number will be returned on error. * @return The result from zero to above. A negative number will be returned on error.
*/ */
public double getDifference(CommandParts other) { public double getDifference(CommandParts other) {
@ -171,6 +178,7 @@ public class CommandParts {
* *
* @param other The other reference. * @param other The other reference.
* @param fullCompare True to compare the full references as far as the range reaches. * @param fullCompare True to compare the full references as far as the range reaches.
*
* @return The result from zero to above. A negative number will be returned on error. * @return The result from zero to above. A negative number will be returned on error.
*/ */
public double getDifference(CommandParts other, boolean fullCompare) { public double getDifference(CommandParts other, boolean fullCompare) {

View File

@ -55,6 +55,7 @@ public class CommandPermissions {
* Add a permission node required to execute this command. * Add a permission node required to execute this command.
* *
* @param permissionNode The permission node to add. * @param permissionNode The permission node to add.
*
* @return True on success, false on failure. * @return True on success, false on failure.
*/ */
public boolean addPermissionNode(String permissionNode) { public boolean addPermissionNode(String permissionNode) {
@ -77,6 +78,7 @@ public class CommandPermissions {
* Check whether this command requires a specified permission node to execute. * Check whether this command requires a specified permission node to execute.
* *
* @param permissionNode The permission node to check for. * @param permissionNode The permission node to check for.
*
* @return True if this permission node is required, false if not. * @return True if this permission node is required, false if not.
*/ */
public boolean hasPermissionNode(String permissionNode) { public boolean hasPermissionNode(String permissionNode) {
@ -114,6 +116,7 @@ public class CommandPermissions {
* Check whether this command requires any permission to be executed. This is based on the getPermission() method. * Check whether this command requires any permission to be executed. This is based on the getPermission() method.
* *
* @param sender CommandSender * @param sender CommandSender
*
* @return True if this command requires any permission to be executed by a player. * @return True if this command requires any permission to be executed by a player.
*/ */
public boolean hasPermission(CommandSender sender) { public boolean hasPermission(CommandSender sender) {
@ -165,6 +168,7 @@ public class CommandPermissions {
* Get the default permission for a specified command sender. * Get the default permission for a specified command sender.
* *
* @param sender The command sender to get the default permission for. * @param sender The command sender to get the default permission for.
*
* @return True if the command sender has permission by default, false otherwise. * @return True if the command sender has permission by default, false otherwise.
*/ */
public boolean getDefaultPermissionCommandSender(CommandSender sender) { public boolean getDefaultPermissionCommandSender(CommandSender sender) {

View File

@ -13,6 +13,7 @@ public abstract class ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise. * @return True if the command was executed successfully, false otherwise.
*/ */
public abstract boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments); public abstract boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments);

View File

@ -13,15 +13,15 @@ public class FoundCommandResult {
/** /**
* The command reference. * The command reference.
*/ */
private CommandParts commandReference; private final CommandParts commandReference;
/** /**
* The command arguments. * The command arguments.
*/ */
private CommandParts commandArguments; private final CommandParts commandArguments;
/** /**
* The original search query reference. * The original search query reference.
*/ */
private CommandParts queryReference; private final CommandParts queryReference;
/** /**
* Constructor. * Constructor.
@ -88,6 +88,7 @@ public class FoundCommandResult {
* Execute the command. * Execute the command.
* *
* @param sender The command sender that executed the command. * @param sender The command sender that executed the command.
*
* @return True on success, false on failure. * @return True on success, false on failure.
*/ */
public boolean executeCommand(CommandSender sender) { public boolean executeCommand(CommandSender sender) {
@ -103,6 +104,7 @@ public class FoundCommandResult {
* Check whether a command sender has permission to execute the command. * Check whether a command sender has permission to execute the command.
* *
* @param sender The command sender. * @param sender The command sender.
*
* @return True if the command sender has permission, false otherwise. * @return True if the command sender has permission, false otherwise.
*/ */
public boolean hasPermission(CommandSender sender) { public boolean hasPermission(CommandSender sender) {

View File

@ -17,6 +17,7 @@ public class GetEmailCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise. * @return True if the command was executed successfully, false otherwise.
*/ */
@Override @Override

View File

@ -20,6 +20,7 @@ public class PurgeBannedPlayersCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise. * @return True if the command was executed successfully, false otherwise.
*/ */
@Override @Override

View File

@ -20,6 +20,7 @@ public class PurgeCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise. * @return True if the command was executed successfully, false otherwise.
*/ */
@Override @Override

View File

@ -19,6 +19,7 @@ public class PurgeLastPositionCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise. * @return True if the command was executed successfully, false otherwise.
*/ */
@Override @Override

View File

@ -23,6 +23,7 @@ public class RegisterCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise. * @return True if the command was executed successfully, false otherwise.
*/ */
@Override @Override

View File

@ -21,6 +21,7 @@ public class ReloadCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise. * @return True if the command was executed successfully, false otherwise.
*/ */
@Override @Override

View File

@ -19,6 +19,7 @@ public class ResetNameCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise. * @return True if the command was executed successfully, false otherwise.
*/ */
@Override @Override

View File

@ -19,6 +19,7 @@ public class SetEmailCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise. * @return True if the command was executed successfully, false otherwise.
*/ */
@Override @Override

View File

@ -17,6 +17,7 @@ public class SetFirstSpawnCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise. * @return True if the command was executed successfully, false otherwise.
*/ */
@Override @Override

View File

@ -17,6 +17,7 @@ public class SetSpawnCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise. * @return True if the command was executed successfully, false otherwise.
*/ */
@Override @Override

View File

@ -17,6 +17,7 @@ public class SpawnCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise. * @return True if the command was executed successfully, false otherwise.
*/ */
@Override @Override

View File

@ -17,6 +17,7 @@ public class SwitchAntiBotCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise. * @return True if the command was executed successfully, false otherwise.
*/ */
@Override @Override

View File

@ -29,6 +29,7 @@ public class UnregisterCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise. * @return True if the command was executed successfully, false otherwise.
*/ */
@Override @Override

View File

@ -18,6 +18,7 @@ public class VersionCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise. * @return True if the command was executed successfully, false otherwise.
*/ */
@Override @Override
@ -70,6 +71,7 @@ public class VersionCommand extends ExecutableCommand {
* Check whether a player is online. * Check whether a player is online.
* *
* @param minecraftName The Minecraft player name. * @param minecraftName The Minecraft player name.
*
* @return True if the player is online, false otherwise. * @return True if the player is online, false otherwise.
*/ */
private boolean isPlayerOnline(String minecraftName) { private boolean isPlayerOnline(String minecraftName) {

View File

@ -20,6 +20,7 @@ public class CaptchaCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise. * @return True if the command was executed successfully, false otherwise.
*/ */
@Override @Override

View File

@ -18,6 +18,7 @@ public class ConverterCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise. * @return True if the command was executed successfully, false otherwise.
*/ */
@Override @Override
@ -89,7 +90,7 @@ public class ConverterCommand extends ExecutableCommand {
vauth("vauth"), vauth("vauth"),
sqltoflat("sqltoflat"); sqltoflat("sqltoflat");
String name; final String name;
/** /**
* Constructor for ConvertType. * Constructor for ConvertType.
@ -104,6 +105,7 @@ public class ConverterCommand extends ExecutableCommand {
* Method fromName. * Method fromName.
* *
* @param name String * @param name String
*
* @return ConvertType * @return ConvertType
*/ */
public static ConvertType fromName(String name) { public static ConvertType fromName(String name) {

View File

@ -18,6 +18,7 @@ public class UnregisterCommand extends ExecutableCommand {
* @param sender The command sender. * @param sender The command sender.
* @param commandReference The command reference. * @param commandReference The command reference.
* @param commandArguments The command arguments. * @param commandArguments The command arguments.
*
* @return True if the command was executed successfully, false otherwise. * @return True if the command was executed successfully, false otherwise.
*/ */
@Override @Override

View File

@ -23,19 +23,20 @@ public final class HelpSyntaxHelper {
* @param commandReference The reference of the command. * @param commandReference The reference of the command.
* @param alternativeLabel The alternative label to use for this command syntax. * @param alternativeLabel The alternative label to use for this command syntax.
* @param highlight True to highlight the important parts of this command. * @param highlight True to highlight the important parts of this command.
*
* @return The command with proper syntax. * @return The command with proper syntax.
*/ */
public static String getCommandSyntax(CommandDescription commandDescription, CommandParts commandReference, public static String getCommandSyntax(CommandDescription commandDescription, CommandParts commandReference,
String alternativeLabel, boolean highlight) { String alternativeLabel, boolean highlight) {
// Create a string builder with white color and prefixed slash // Create a string builder with white color and prefixed slash
StringBuilder sb = new StringBuilder() StringBuilder sb = new StringBuilder()
.append(ChatColor.WHITE) .append(ChatColor.WHITE)
.append("/"); .append("/");
// Get the help command reference, and the command label // Get the help command reference, and the command label
CommandParts helpCommandReference = commandDescription.getCommandReference(commandReference); CommandParts helpCommandReference = commandDescription.getCommandReference(commandReference);
final String parentCommand = new CommandParts( final String parentCommand = new CommandParts(
helpCommandReference.getRange(0, helpCommandReference.getCount() - 1)).toString(); helpCommandReference.getRange(0, helpCommandReference.getCount() - 1)).toString();
// Check whether the alternative label should be used // Check whether the alternative label should be used
String commandLabel; String commandLabel;
@ -47,9 +48,9 @@ public final class HelpSyntaxHelper {
// Show the important bit of the command, highlight this part if required // Show the important bit of the command, highlight this part if required
sb.append(parentCommand) sb.append(parentCommand)
.append(" ") .append(" ")
.append(highlight ? ChatColor.YELLOW.toString() + ChatColor.BOLD : "") .append(highlight ? ChatColor.YELLOW.toString() + ChatColor.BOLD : "")
.append(commandLabel); .append(commandLabel);
if (highlight) { if (highlight) {
sb.append(ChatColor.YELLOW); sb.append(ChatColor.YELLOW);

View File

@ -18,9 +18,9 @@ import java.io.IOException;
*/ */
public class CrazyLoginConverter implements Converter { public class CrazyLoginConverter implements Converter {
public AuthMe instance; public final AuthMe instance;
public DataSource database; public final DataSource database;
public CommandSender sender; public final CommandSender sender;
/** /**
* Constructor for CrazyLoginConverter. * Constructor for CrazyLoginConverter.

View File

@ -14,7 +14,7 @@ import java.sql.*;
*/ */
public class FlatToSqlite implements Converter { public class FlatToSqlite implements Converter {
public CommandSender sender; public final CommandSender sender;
private String tableName; private String tableName;
private String columnName; private String columnName;
private String columnPassword; private String columnPassword;
@ -179,6 +179,7 @@ public class FlatToSqlite implements Converter {
* Method saveAuth. * Method saveAuth.
* *
* @param s String * @param s String
*
* @return boolean * @return boolean
*/ */
private synchronized boolean saveAuth(String s) { private synchronized boolean saveAuth(String s) {

View File

@ -11,7 +11,7 @@ import fr.xephi.authme.settings.Settings;
*/ */
public class ForceFlatToSqlite implements Converter { public class ForceFlatToSqlite implements Converter {
private DataSource data; private final DataSource data;
/** /**
* Constructor for ForceFlatToSqlite. * Constructor for ForceFlatToSqlite.

View File

@ -23,9 +23,9 @@ import java.util.Map.Entry;
*/ */
public class RakamakConverter implements Converter { public class RakamakConverter implements Converter {
public AuthMe instance; public final AuthMe instance;
public DataSource database; public final DataSource database;
public CommandSender sender; public final CommandSender sender;
/** /**
* Constructor for RakamakConverter. * Constructor for RakamakConverter.

View File

@ -12,8 +12,8 @@ import java.io.File;
*/ */
public class RoyalAuthConverter implements Converter { public class RoyalAuthConverter implements Converter {
public AuthMe plugin; public final AuthMe plugin;
private DataSource data; private final DataSource data;
/** /**
* Constructor for RoyalAuthConverter. * Constructor for RoyalAuthConverter.

View File

@ -14,9 +14,9 @@ import java.util.List;
*/ */
public class SqlToFlat implements Converter { public class SqlToFlat implements Converter {
public AuthMe plugin; public final AuthMe plugin;
public DataSource database; public final DataSource database;
public CommandSender sender; public final CommandSender sender;
/** /**
* Constructor for SqlToFlat. * Constructor for SqlToFlat.

View File

@ -9,9 +9,9 @@ import org.bukkit.command.CommandSender;
*/ */
public class vAuthConverter implements Converter { public class vAuthConverter implements Converter {
public AuthMe plugin; public final AuthMe plugin;
public DataSource database; public final DataSource database;
public CommandSender sender; public final CommandSender sender;
/** /**
* Constructor for vAuthConverter. * Constructor for vAuthConverter.

View File

@ -17,9 +17,9 @@ import java.util.UUID;
*/ */
public class vAuthFileReader { public class vAuthFileReader {
public AuthMe plugin; public final AuthMe plugin;
public DataSource database; public final DataSource database;
public CommandSender sender; public final CommandSender sender;
/** /**
* Constructor for vAuthFileReader. * Constructor for vAuthFileReader.
@ -38,7 +38,7 @@ public class vAuthFileReader {
* *
* @throws IOException * @throws IOException
*/ */
public void convert() throws IOException { public void convert() {
final File file = new File(plugin.getDataFolder().getParent() + "" + File.separator + "vAuth" + File.separator + "passwords.yml"); final File file = new File(plugin.getDataFolder().getParent() + "" + File.separator + "vAuth" + File.separator + "passwords.yml");
Scanner scanner; Scanner scanner;
try { try {
@ -49,15 +49,15 @@ public class vAuthFileReader {
String password = line.split(": ")[1]; String password = line.split(": ")[1];
PlayerAuth auth; PlayerAuth auth;
if (isUUIDinstance(password)) { if (isUUIDinstance(password)) {
String pname; String playerName;
try { try {
pname = Bukkit.getOfflinePlayer(UUID.fromString(name)).getName(); playerName = Bukkit.getOfflinePlayer(UUID.fromString(name)).getName();
} catch (Exception | NoSuchMethodError e) { } catch (Exception | NoSuchMethodError e) {
pname = getName(UUID.fromString(name)); playerName = getName(UUID.fromString(name));
} }
if (pname == null) if (playerName == null)
continue; continue;
auth = new PlayerAuth(pname.toLowerCase(), password, "127.0.0.1", System.currentTimeMillis(), "your@email.com", pname); auth = new PlayerAuth(playerName.toLowerCase(), password, "127.0.0.1", System.currentTimeMillis(), "your@email.com", playerName);
} else { } else {
auth = new PlayerAuth(name.toLowerCase(), password, "127.0.0.1", System.currentTimeMillis(), "your@email.com", name); auth = new PlayerAuth(name.toLowerCase(), password, "127.0.0.1", System.currentTimeMillis(), "your@email.com", name);
} }
@ -73,6 +73,7 @@ public class vAuthFileReader {
* Method isUUIDinstance. * Method isUUIDinstance.
* *
* @param s String * @param s String
*
* @return boolean * @return boolean
*/ */
private boolean isUUIDinstance(String s) { private boolean isUUIDinstance(String s) {
@ -85,6 +86,7 @@ public class vAuthFileReader {
* Method getName. * Method getName.
* *
* @param uuid UUID * @param uuid UUID
*
* @return String * @return String
*/ */
private String getName(UUID uuid) { private String getName(UUID uuid) {

View File

@ -7,8 +7,8 @@ import org.bukkit.command.CommandSender;
*/ */
public class xAuthConverter implements Converter { public class xAuthConverter implements Converter {
public AuthMe plugin; public final AuthMe plugin;
public CommandSender sender; public final CommandSender sender;
/** /**
* Constructor for xAuthConverter. * Constructor for xAuthConverter.

View File

@ -20,9 +20,9 @@ import java.util.List;
*/ */
public class xAuthToFlat { public class xAuthToFlat {
public AuthMe instance; public final AuthMe instance;
public DataSource database; public final DataSource database;
public CommandSender sender; public final CommandSender sender;
/** /**
* Constructor for xAuthToFlat. * Constructor for xAuthToFlat.
@ -64,7 +64,7 @@ public class xAuthToFlat {
database.saveAuth(auth); database.saveAuth(auth);
} }
} }
sender.sendMessage("[AuthMe] Successfull convert from xAuth database"); sender.sendMessage("[AuthMe] Successfully convert from xAuth database");
} catch (Exception e) { } catch (Exception e) {
sender.sendMessage("[AuthMe] An error has been thrown while import xAuth database, the import hadn't fail but can be not complete "); sender.sendMessage("[AuthMe] An error has been thrown while import xAuth database, the import hadn't fail but can be not complete ");
} }
@ -75,6 +75,7 @@ public class xAuthToFlat {
* Method getIdPlayer. * Method getIdPlayer.
* *
* @param id int * @param id int
*
* @return String * @return String
*/ */
public String getIdPlayer(int id) { public String getIdPlayer(int id) {
@ -129,6 +130,7 @@ public class xAuthToFlat {
* Method getPassword. * Method getPassword.
* *
* @param accountId int * @param accountId int
*
* @return String * @return String
*/ */
public String getPassword(int accountId) { public String getPassword(int accountId) {

File diff suppressed because it is too large Load Diff

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@ public class FlatFile implements DataSource {
* :LASTPOSZ:LASTPOSWORLD PLAYERNAME:HASHSUM:IP:LOGININMILLIESECONDS * :LASTPOSZ:LASTPOSWORLD PLAYERNAME:HASHSUM:IP:LOGININMILLIESECONDS
* PLAYERNAME:HASHSUM:IP PLAYERNAME:HASHSUM * PLAYERNAME:HASHSUM:IP PLAYERNAME:HASHSUM
*/ */
private File source; private final File source;
public FlatFile() { public FlatFile() {
source = Settings.AUTH_FILE; source = Settings.AUTH_FILE;
@ -48,6 +48,7 @@ public class FlatFile implements DataSource {
* Method isAuthAvailable. * Method isAuthAvailable.
* *
* @param user String * @param user String
*
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String) * @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
*/ */
@Override @Override
@ -72,7 +73,7 @@ public class FlatFile implements DataSource {
if (br != null) { if (br != null) {
try { try {
br.close(); br.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
} }
@ -83,6 +84,7 @@ public class FlatFile implements DataSource {
* Method saveAuth. * Method saveAuth.
* *
* @param auth PlayerAuth * @param auth PlayerAuth
*
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth) * @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
*/ */
@Override @Override
@ -101,7 +103,7 @@ public class FlatFile implements DataSource {
if (bw != null) { if (bw != null) {
try { try {
bw.close(); bw.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
} }
@ -112,6 +114,7 @@ public class FlatFile implements DataSource {
* Method updatePassword. * Method updatePassword.
* *
* @param auth PlayerAuth * @param auth PlayerAuth
*
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth) * @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
*/ */
@Override @Override
@ -162,7 +165,7 @@ public class FlatFile implements DataSource {
if (br != null) { if (br != null) {
try { try {
br.close(); br.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
} }
@ -177,6 +180,7 @@ public class FlatFile implements DataSource {
* Method updateSession. * Method updateSession.
* *
* @param auth PlayerAuth * @param auth PlayerAuth
*
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth) * @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
*/ */
@Override @Override
@ -227,7 +231,7 @@ public class FlatFile implements DataSource {
if (br != null) { if (br != null) {
try { try {
br.close(); br.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
} }
@ -242,6 +246,7 @@ public class FlatFile implements DataSource {
* Method updateQuitLoc. * Method updateQuitLoc.
* *
* @param auth PlayerAuth * @param auth PlayerAuth
*
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth) * @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
*/ */
@Override @Override
@ -271,7 +276,7 @@ public class FlatFile implements DataSource {
if (br != null) { if (br != null) {
try { try {
br.close(); br.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
} }
@ -286,6 +291,7 @@ public class FlatFile implements DataSource {
* Method getIps. * Method getIps.
* *
* @param ip String * @param ip String
*
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String) * @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String)
*/ */
@Override @Override
@ -312,7 +318,7 @@ public class FlatFile implements DataSource {
if (br != null) { if (br != null) {
try { try {
br.close(); br.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
} }
@ -322,6 +328,7 @@ public class FlatFile implements DataSource {
* Method purgeDatabase. * Method purgeDatabase.
* *
* @param until long * @param until long
*
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long) * @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
*/ */
@Override @Override
@ -357,13 +364,13 @@ public class FlatFile implements DataSource {
if (br != null) { if (br != null) {
try { try {
br.close(); br.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
if (bw != null) { if (bw != null) {
try { try {
bw.close(); bw.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
} }
@ -374,6 +381,7 @@ public class FlatFile implements DataSource {
* Method autoPurgeDatabase. * Method autoPurgeDatabase.
* *
* @param until long * @param until long
*
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long) * @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
*/ */
@Override @Override
@ -409,13 +417,13 @@ public class FlatFile implements DataSource {
if (br != null) { if (br != null) {
try { try {
br.close(); br.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
if (bw != null) { if (bw != null) {
try { try {
bw.close(); bw.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
} }
@ -426,6 +434,7 @@ public class FlatFile implements DataSource {
* Method removeAuth. * Method removeAuth.
* *
* @param user String * @param user String
*
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String) * @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
*/ */
@Override @Override
@ -459,13 +468,13 @@ public class FlatFile implements DataSource {
if (br != null) { if (br != null) {
try { try {
br.close(); br.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
if (bw != null) { if (bw != null) {
try { try {
bw.close(); bw.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
} }
@ -476,6 +485,7 @@ public class FlatFile implements DataSource {
* Method getAuth. * Method getAuth.
* *
* @param user String * @param user String
*
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String) * @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String)
*/ */
@Override @Override
@ -513,7 +523,7 @@ public class FlatFile implements DataSource {
if (br != null) { if (br != null) {
try { try {
br.close(); br.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
} }
@ -542,6 +552,7 @@ public class FlatFile implements DataSource {
* Method updateEmail. * Method updateEmail.
* *
* @param auth PlayerAuth * @param auth PlayerAuth
*
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth) * @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
*/ */
@Override @Override
@ -571,7 +582,7 @@ public class FlatFile implements DataSource {
if (br != null) { if (br != null) {
try { try {
br.close(); br.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
} }
@ -586,6 +597,7 @@ public class FlatFile implements DataSource {
* Method updateSalt. * Method updateSalt.
* *
* @param auth PlayerAuth * @param auth PlayerAuth
*
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth) * @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
*/ */
@Override @Override
@ -597,6 +609,7 @@ public class FlatFile implements DataSource {
* Method getAllAuthsByName. * Method getAllAuthsByName.
* *
* @param auth PlayerAuth * @param auth PlayerAuth
*
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth) * @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
*/ */
@Override @Override
@ -623,7 +636,7 @@ public class FlatFile implements DataSource {
if (br != null) { if (br != null) {
try { try {
br.close(); br.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
} }
@ -633,6 +646,7 @@ public class FlatFile implements DataSource {
* Method getAllAuthsByIp. * Method getAllAuthsByIp.
* *
* @param ip String * @param ip String
*
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String) * @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
*/ */
@Override @Override
@ -659,7 +673,7 @@ public class FlatFile implements DataSource {
if (br != null) { if (br != null) {
try { try {
br.close(); br.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
} }
@ -669,6 +683,7 @@ public class FlatFile implements DataSource {
* Method getAllAuthsByEmail. * Method getAllAuthsByEmail.
* *
* @param email String * @param email String
*
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String) * @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
*/ */
@Override @Override
@ -695,7 +710,7 @@ public class FlatFile implements DataSource {
if (br != null) { if (br != null) {
try { try {
br.close(); br.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
} }
@ -705,6 +720,7 @@ public class FlatFile implements DataSource {
* Method purgeBanned. * Method purgeBanned.
* *
* @param banned List<String> * @param banned List<String>
*
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>) * @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
*/ */
@Override @Override
@ -721,34 +737,31 @@ public class FlatFile implements DataSource {
if (banned.contains(args[0])) { if (banned.contains(args[0])) {
lines.add(line); lines.add(line);
} }
} catch (NullPointerException | ArrayIndexOutOfBoundsException exc) { } catch (NullPointerException | ArrayIndexOutOfBoundsException ignored) {
} }
} }
bw = new BufferedWriter(new FileWriter(source)); bw = new BufferedWriter(new FileWriter(source));
for (String l : lines) { for (String l : lines) {
bw.write(l + "\n"); bw.write(l + "\n");
} }
} catch (FileNotFoundException ex) {
ConsoleLogger.showError(ex.getMessage());
return;
} catch (IOException ex) { } catch (IOException ex) {
ConsoleLogger.showError(ex.getMessage()); ConsoleLogger.showError(ex.getMessage());
return;
} finally { } finally {
if (br != null) { if (br != null) {
try { try {
br.close(); br.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
if (bw != null) { if (bw != null) {
try { try {
bw.close(); bw.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
} }
return;
} }
/** /**
@ -765,6 +778,7 @@ public class FlatFile implements DataSource {
* Method isLogged. * Method isLogged.
* *
* @param user String * @param user String
*
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String) * @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String)
*/ */
@Override @Override
@ -776,6 +790,7 @@ public class FlatFile implements DataSource {
* Method setLogged. * Method setLogged.
* *
* @param user String * @param user String
*
* @see fr.xephi.authme.datasource.DataSource#setLogged(String) * @see fr.xephi.authme.datasource.DataSource#setLogged(String)
*/ */
@Override @Override
@ -786,6 +801,7 @@ public class FlatFile implements DataSource {
* Method setUnlogged. * Method setUnlogged.
* *
* @param user String * @param user String
*
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String) * @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
*/ */
@Override @Override
@ -822,7 +838,7 @@ public class FlatFile implements DataSource {
if (br != null) { if (br != null) {
try { try {
br.close(); br.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
} }
@ -832,16 +848,17 @@ public class FlatFile implements DataSource {
/** /**
* Method updateName. * Method updateName.
* *
* @param oldone String * @param oldOne String
* @param newone String * @param newOne String
*
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String) * @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
*/ */
@Override @Override
public void updateName(String oldone, String newone) { public void updateName(String oldOne, String newOne) {
PlayerAuth auth = this.getAuth(oldone); PlayerAuth auth = this.getAuth(oldOne);
auth.setName(newone); auth.setName(newOne);
this.saveAuth(auth); this.saveAuth(auth);
this.removeAuth(oldone); this.removeAuth(oldOne);
} }
/** /**
@ -889,7 +906,7 @@ public class FlatFile implements DataSource {
if (br != null) { if (br != null) {
try { try {
br.close(); br.close();
} catch (IOException ex) { } catch (IOException ignored) {
} }
} }
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@ import org.bukkit.event.HandlerList;
public class AuthMeAsyncPreLoginEvent extends Event { public class AuthMeAsyncPreLoginEvent extends Event {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private Player player; private final Player player;
private boolean canLogin = true; private boolean canLogin = true;
/** /**

View File

@ -11,9 +11,9 @@ import org.bukkit.entity.Player;
*/ */
public class AuthMeTeleportEvent extends CustomEvent { public class AuthMeTeleportEvent extends CustomEvent {
private Player player; private final Player player;
private Location to; private Location to;
private Location from; private final Location from;
/** /**
* Constructor for AuthMeTeleportEvent. * Constructor for AuthMeTeleportEvent.

View File

@ -57,6 +57,7 @@ public class CustomEvent extends Event implements Cancellable {
* Method setCancelled. * Method setCancelled.
* *
* @param cancelled boolean * @param cancelled boolean
*
* @see org.bukkit.event.Cancellable#setCancelled(boolean) * @see org.bukkit.event.Cancellable#setCancelled(boolean)
*/ */
public void setCancelled(boolean cancelled) { public void setCancelled(boolean cancelled) {

View File

@ -11,9 +11,9 @@ import org.bukkit.entity.Player;
*/ */
public class FirstSpawnTeleportEvent extends CustomEvent { public class FirstSpawnTeleportEvent extends CustomEvent {
private Player player; private final Player player;
private Location to; private Location to;
private Location from; private final Location from;
/** /**
* Constructor for FirstSpawnTeleportEvent. * Constructor for FirstSpawnTeleportEvent.

View File

@ -12,11 +12,11 @@ import org.bukkit.inventory.ItemStack;
*/ */
public class ProtectInventoryEvent extends CustomEvent { public class ProtectInventoryEvent extends CustomEvent {
private ItemStack[] storedinventory; private final ItemStack[] storedinventory;
private ItemStack[] storedarmor; private final ItemStack[] storedarmor;
private ItemStack[] emptyInventory = null; private ItemStack[] emptyInventory = null;
private ItemStack[] emptyArmor = null; private ItemStack[] emptyArmor = null;
private Player player; private final Player player;
/** /**
* Constructor for ProtectInventoryEvent. * Constructor for ProtectInventoryEvent.

View File

@ -12,9 +12,9 @@ import org.bukkit.entity.Player;
*/ */
public class RegisterTeleportEvent extends CustomEvent { public class RegisterTeleportEvent extends CustomEvent {
private Player player; private final Player player;
private Location to; private Location to;
private Location from; private final Location from;
/** /**
* Constructor for RegisterTeleportEvent. * Constructor for RegisterTeleportEvent.

View File

@ -11,10 +11,10 @@ import org.bukkit.entity.Player;
*/ */
public class SpawnTeleportEvent extends CustomEvent { public class SpawnTeleportEvent extends CustomEvent {
private Player player; private final Player player;
private Location to; private Location to;
private Location from; private final Location from;
private boolean isAuthenticated; private final boolean isAuthenticated;
/** /**
* Constructor for SpawnTeleportEvent. * Constructor for SpawnTeleportEvent.

View File

@ -10,7 +10,7 @@ import org.bukkit.plugin.messaging.PluginMessageListener;
*/ */
public class BungeeCordMessage implements PluginMessageListener { public class BungeeCordMessage implements PluginMessageListener {
public AuthMe plugin; public final AuthMe plugin;
/** /**
* Constructor for BungeeCordMessage. * Constructor for BungeeCordMessage.
@ -27,6 +27,7 @@ public class BungeeCordMessage implements PluginMessageListener {
* @param channel String * @param channel String
* @param player Player * @param player Player
* @param message byte[] * @param message byte[]
*
* @see org.bukkit.plugin.messaging.PluginMessageListener#onPluginMessageReceived(String, Player, byte[]) * @see org.bukkit.plugin.messaging.PluginMessageListener#onPluginMessageReceived(String, Player, byte[])
*/ */
@Override @Override

View File

@ -12,7 +12,7 @@ import org.bukkit.event.block.BlockPlaceEvent;
*/ */
public class AuthMeBlockListener implements Listener { public class AuthMeBlockListener implements Listener {
public AuthMe instance; public final AuthMe instance;
/** /**
* Constructor for AuthMeBlockListener. * Constructor for AuthMeBlockListener.

View File

@ -20,7 +20,7 @@ public class AuthMeEntityListener implements Listener {
private static Method getShooter; private static Method getShooter;
private static boolean shooterIsProjectileSource; private static boolean shooterIsProjectileSource;
public AuthMe instance; public final AuthMe instance;
/** /**
* Constructor for AuthMeEntityListener. * Constructor for AuthMeEntityListener.

View File

@ -57,6 +57,7 @@ public class AuthMeInventoryPacketAdapter extends PacketAdapter {
* Method onPacketSending. * Method onPacketSending.
* *
* @param packetEvent PacketEvent * @param packetEvent PacketEvent
*
* @see com.comphenix.protocol.events.PacketListener#onPacketSending(PacketEvent) * @see com.comphenix.protocol.events.PacketListener#onPacketSending(PacketEvent)
*/ */
@Override @Override
@ -66,7 +67,7 @@ public class AuthMeInventoryPacketAdapter extends PacketAdapter {
byte windowId = packet.getIntegers().read(0).byteValue(); byte windowId = packet.getIntegers().read(0).byteValue();
if (windowId == PLAYER_INVENTORY && Settings.protectInventoryBeforeLogInEnabled if (windowId == PLAYER_INVENTORY && Settings.protectInventoryBeforeLogInEnabled
&& !PlayerCache.getInstance().isAuthenticated(player.getName())) { && !PlayerCache.getInstance().isAuthenticated(player.getName())) {
packetEvent.setCancelled(true); packetEvent.setCancelled(true);
} }
} }
@ -108,9 +109,9 @@ public class AuthMeInventoryPacketAdapter extends PacketAdapter {
//storedInventory and hotbar //storedInventory and hotbar
System.arraycopy(storedInventory, 0, completeInventory System.arraycopy(storedInventory, 0, completeInventory
, playerCrafting.length + armorContents.length, storedInventory.length); , playerCrafting.length + armorContents.length, storedInventory.length);
System.arraycopy(hotbar, 0, completeInventory System.arraycopy(hotbar, 0, completeInventory
, playerCrafting.length + armorContents.length + storedInventory.length, hotbar.length); , playerCrafting.length + armorContents.length + storedInventory.length, hotbar.length);
inventoryPacket.getItemArrayModifier().write(0, completeInventory); inventoryPacket.getItemArrayModifier().write(0, completeInventory);
try { try {

View File

@ -37,12 +37,12 @@ import java.util.regex.PatternSyntaxException;
*/ */
public class AuthMePlayerListener implements Listener { public class AuthMePlayerListener implements Listener {
public static ConcurrentHashMap<String, GameMode> gameMode = new ConcurrentHashMap<>(); public static final ConcurrentHashMap<String, GameMode> gameMode = new ConcurrentHashMap<>();
public static ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>(); public static final ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>();
public static ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>(); public static final ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
public AuthMe plugin; public final AuthMe plugin;
private Messages m = Messages.getInstance(); private final Messages m = Messages.getInstance();
private List<String> antibot = new ArrayList<>(); private final List<String> antibot = new ArrayList<>();
/** /**
* Constructor for AuthMePlayerListener. * Constructor for AuthMePlayerListener.

View File

@ -12,7 +12,7 @@ import org.bukkit.event.player.PlayerEditBookEvent;
*/ */
public class AuthMePlayerListener16 implements Listener { public class AuthMePlayerListener16 implements Listener {
public AuthMe plugin; public final AuthMe plugin;
/** /**
* Constructor for AuthMePlayerListener16. * Constructor for AuthMePlayerListener16.

View File

@ -12,7 +12,7 @@ import org.bukkit.event.player.PlayerInteractAtEntityEvent;
*/ */
public class AuthMePlayerListener18 implements Listener { public class AuthMePlayerListener18 implements Listener {
public AuthMe plugin; public final AuthMe plugin;
/** /**
* Constructor for AuthMePlayerListener18. * Constructor for AuthMePlayerListener18.

View File

@ -17,8 +17,8 @@ import org.bukkit.plugin.Plugin;
*/ */
public class AuthMeServerListener implements Listener { public class AuthMeServerListener implements Listener {
public AuthMe plugin; public final AuthMe plugin;
private Messages m = Messages.getInstance(); private final Messages m = Messages.getInstance();
/** /**
* Constructor for AuthMeServerListener. * Constructor for AuthMeServerListener.

View File

@ -19,7 +19,7 @@ import java.util.jar.JarFile;
*/ */
public class ModuleManager { public class ModuleManager {
private List<Module> modules = new ArrayList<>(); private final List<Module> modules = new ArrayList<>();
/** /**
* Constructor for ModuleManager. * Constructor for ModuleManager.
@ -33,6 +33,7 @@ public class ModuleManager {
* Method isModuleEnabled. * Method isModuleEnabled.
* *
* @param name String * @param name String
*
* @return boolean * @return boolean
*/ */
public boolean isModuleEnabled(String name) { public boolean isModuleEnabled(String name) {
@ -47,6 +48,7 @@ public class ModuleManager {
* Method isModuleEnabled. * Method isModuleEnabled.
* *
* @param type Module.ModuleType * @param type Module.ModuleType
*
* @return boolean * @return boolean
*/ */
public boolean isModuleEnabled(Module.ModuleType type) { public boolean isModuleEnabled(Module.ModuleType type) {
@ -61,6 +63,7 @@ public class ModuleManager {
* Method getModule. * Method getModule.
* *
* @param name String * @param name String
*
* @return Module * @return Module
*/ */
public Module getModule(String name) { public Module getModule(String name) {
@ -75,6 +78,7 @@ public class ModuleManager {
* Method getModule. * Method getModule.
* *
* @param type Module.ModuleType * @param type Module.ModuleType
*
* @return Module * @return Module
*/ */
public Module getModule(Module.ModuleType type) { public Module getModule(Module.ModuleType type) {

View File

@ -29,10 +29,10 @@ import java.util.logging.Logger;
/** /**
* PermissionsManager. * PermissionsManager.
* <p> * <p/>
* A permissions manager, to manage and use various permissions systems. * A permissions manager, to manage and use various permissions systems.
* This manager supports dynamic plugin hooking and various other features. * This manager supports dynamic plugin hooking and various other features.
* <p> * <p/>
* Written by Tim Visée. * Written by Tim Visée.
* *
* @author Tim Visée, http://timvisee.com * @author Tim Visée, http://timvisee.com
@ -47,11 +47,11 @@ public class PermissionsManager {
/** /**
* Server instance. * Server instance.
*/ */
private Server server; private final Server server;
/** /**
* Plugin instance. * Plugin instance.
*/ */
private Plugin plugin; private final Plugin plugin;
/** /**
* Logger instance. * Logger instance.
*/ */
@ -267,9 +267,9 @@ public class PermissionsManager {
// Check if any known permissions system is enabling // Check if any known permissions system is enabling
if (pluginName.equals("PermissionsEx") || pluginName.equals("PermissionsBukkit") || if (pluginName.equals("PermissionsEx") || pluginName.equals("PermissionsBukkit") ||
pluginName.equals("bPermissions") || pluginName.equals("GroupManager") || pluginName.equals("bPermissions") || pluginName.equals("GroupManager") ||
pluginName.equals("zPermissions") || pluginName.equals("Vault") || pluginName.equals("zPermissions") || pluginName.equals("Vault") ||
pluginName.equals("Permissions")) { pluginName.equals("Permissions")) {
this.log.info(pluginName + " plugin enabled, dynamically updating permissions hooks!"); this.log.info(pluginName + " plugin enabled, dynamically updating permissions hooks!");
setup(); setup();
} }
@ -287,9 +287,9 @@ public class PermissionsManager {
// Is the WorldGuard plugin disabled // Is the WorldGuard plugin disabled
if (pluginName.equals("PermissionsEx") || pluginName.equals("PermissionsBukkit") || if (pluginName.equals("PermissionsEx") || pluginName.equals("PermissionsBukkit") ||
pluginName.equals("bPermissions") || pluginName.equals("GroupManager") || pluginName.equals("bPermissions") || pluginName.equals("GroupManager") ||
pluginName.equals("zPermissions") || pluginName.equals("Vault") || pluginName.equals("zPermissions") || pluginName.equals("Vault") ||
pluginName.equals("Permissions")) { pluginName.equals("Permissions")) {
this.log.info(pluginName + " plugin disabled, updating hooks!"); this.log.info(pluginName + " plugin disabled, updating hooks!");
setup(); setup();
} }
@ -318,6 +318,7 @@ public class PermissionsManager {
* *
* @param player The player. * @param player The player.
* @param permsNode Permissions node. * @param permsNode Permissions node.
*
* @return True if the player has permission. * @return True if the player has permission.
*/ */
public boolean hasPermission(Player player, String permsNode) { public boolean hasPermission(Player player, String permsNode) {
@ -330,6 +331,7 @@ public class PermissionsManager {
* @param player The player. * @param player The player.
* @param permsNode The permission node. * @param permsNode The permission node.
* @param def Default returned if no permissions system is used. * @param def Default returned if no permissions system is used.
*
* @return True if the player has permission. * @return True if the player has permission.
*/ */
public boolean hasPermission(Player player, String permsNode, boolean def) { public boolean hasPermission(Player player, String permsNode, boolean def) {
@ -425,6 +427,7 @@ public class PermissionsManager {
* Get the permission groups of a player, if available. * Get the permission groups of a player, if available.
* *
* @param player The player. * @param player The player.
*
* @return Permission groups, or an empty list if this feature is not supported. * @return Permission groups, or an empty list if this feature is not supported.
*/ */
@SuppressWarnings({"unchecked", "rawtypes", "deprecation"}) @SuppressWarnings({"unchecked", "rawtypes", "deprecation"})
@ -489,6 +492,7 @@ public class PermissionsManager {
* Get the primary group of a player, if available. * Get the primary group of a player, if available.
* *
* @param player The player. * @param player The player.
*
* @return The name of the primary permission group. Or null. * @return The name of the primary permission group. Or null.
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@ -542,6 +546,7 @@ public class PermissionsManager {
* *
* @param player The player. * @param player The player.
* @param groupName The group name. * @param groupName The group name.
*
* @return True if the player is in the specified group, false otherwise. * @return True if the player is in the specified group, false otherwise.
* False is also returned if groups aren't supported by the used permissions system. * False is also returned if groups aren't supported by the used permissions system.
*/ */
@ -599,6 +604,7 @@ public class PermissionsManager {
* *
* @param player The player * @param player The player
* @param groupName The name of the group. * @param groupName The name of the group.
*
* @return True if succeed, false otherwise. * @return True if succeed, false otherwise.
* False is also returned if this feature isn't supported for the current permissions system. * False is also returned if this feature isn't supported for the current permissions system.
*/ */
@ -660,6 +666,7 @@ public class PermissionsManager {
* *
* @param player The player * @param player The player
* @param groupNames The name of the groups to add. * @param groupNames The name of the groups to add.
*
* @return True if succeed, false otherwise. * @return True if succeed, false otherwise.
* False is also returned if this feature isn't supported for the current permissions system. * False is also returned if this feature isn't supported for the current permissions system.
*/ */
@ -683,6 +690,7 @@ public class PermissionsManager {
* *
* @param player The player * @param player The player
* @param groupName The name of the group. * @param groupName The name of the group.
*
* @return True if succeed, false otherwise. * @return True if succeed, false otherwise.
* False is also returned if this feature isn't supported for the current permissions system. * False is also returned if this feature isn't supported for the current permissions system.
*/ */
@ -744,6 +752,7 @@ public class PermissionsManager {
* *
* @param player The player * @param player The player
* @param groupNames The name of the groups to add. * @param groupNames The name of the groups to add.
*
* @return True if succeed, false otherwise. * @return True if succeed, false otherwise.
* False is also returned if this feature isn't supported for the current permissions system. * False is also returned if this feature isn't supported for the current permissions system.
*/ */
@ -768,6 +777,7 @@ public class PermissionsManager {
* *
* @param player The player * @param player The player
* @param groupName The name of the group. * @param groupName The name of the group.
*
* @return True if succeed, false otherwise. * @return True if succeed, false otherwise.
* False is also returned if this feature isn't supported for the current permissions system. * False is also returned if this feature isn't supported for the current permissions system.
*/ */
@ -837,6 +847,7 @@ public class PermissionsManager {
* *
* @param player The player * @param player The player
* @param groupNames The name of the groups to set. * @param groupNames The name of the groups to set.
*
* @return True if succeed, false otherwise. * @return True if succeed, false otherwise.
* False is also returned if this feature isn't supported for the current permissions system. * False is also returned if this feature isn't supported for the current permissions system.
*/ */
@ -870,6 +881,7 @@ public class PermissionsManager {
* in it's primary group. All the subgroups are removed just fine. * in it's primary group. All the subgroups are removed just fine.
* *
* @param player The player to remove all groups from. * @param player The player to remove all groups from.
*
* @return True if succeed, false otherwise. * @return True if succeed, false otherwise.
* False will also be returned if this feature isn't supported for the used permissions system. * False will also be returned if this feature isn't supported for the used permissions system.
*/ */
@ -895,7 +907,7 @@ public class PermissionsManager {
VAULT("Vault"), VAULT("Vault"),
PERMISSIONS("Permissions"); PERMISSIONS("Permissions");
public String name; public final String name;
/** /**
* Constructor for PermissionsSystemType. * Constructor for PermissionsSystemType.
@ -915,4 +927,4 @@ public class PermissionsManager {
return this.name; return this.name;
} }
} }
} }

View File

@ -1,166 +1,166 @@
package fr.xephi.authme.process; package fr.xephi.authme.process;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.process.email.AsyncChangeEmail; import fr.xephi.authme.process.email.AsyncChangeEmail;
import fr.xephi.authme.process.join.AsyncronousJoin; import fr.xephi.authme.process.join.AsynchronousJoin;
import fr.xephi.authme.process.login.AsyncronousLogin; import fr.xephi.authme.process.login.AsynchronousLogin;
import fr.xephi.authme.process.logout.AsyncronousLogout; import fr.xephi.authme.process.logout.AsynchronousLogout;
import fr.xephi.authme.process.quit.AsyncronousQuit; import fr.xephi.authme.process.quit.AsynchronousQuit;
import fr.xephi.authme.process.register.AsyncRegister; import fr.xephi.authme.process.register.AsyncRegister;
import fr.xephi.authme.process.unregister.AsyncronousUnregister; import fr.xephi.authme.process.unregister.AsynchronousUnregister;
import fr.xephi.authme.security.RandomString; import fr.xephi.authme.security.RandomString;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
/** /**
* @author Gabriele * @author Gabriele
* @version $Revision: 1.0 $ * @version $Revision: 1.0 $
*/ */
public class Management { public class Management {
public static RandomString rdm = new RandomString(Settings.captchaLength); public static RandomString rdm = new RandomString(Settings.captchaLength);
private final AuthMe plugin; private final AuthMe plugin;
private final BukkitScheduler sched; private final BukkitScheduler sched;
/** /**
* Constructor for Management. * Constructor for Management.
* *
* @param plugin AuthMe * @param plugin AuthMe
*/ */
public Management(AuthMe plugin) { public Management(AuthMe plugin) {
this.plugin = plugin; this.plugin = plugin;
this.sched = this.plugin.getServer().getScheduler(); this.sched = this.plugin.getServer().getScheduler();
} }
/** /**
* Method performLogin. * Method performLogin.
* *
* @param player Player * @param player Player
* @param password String * @param password String
* @param forceLogin boolean * @param forceLogin boolean
*/ */
public void performLogin(final Player player, final String password, final boolean forceLogin) { public void performLogin(final Player player, final String password, final boolean forceLogin) {
sched.runTaskAsynchronously(plugin, new Runnable() { sched.runTaskAsynchronously(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
new AsyncronousLogin(player, password, forceLogin, plugin, plugin.database).process(); new AsynchronousLogin(player, password, forceLogin, plugin, plugin.database).process();
} }
}); });
} }
/** /**
* Method performLogout. * Method performLogout.
* *
* @param player Player * @param player Player
*/ */
public void performLogout(final Player player) { public void performLogout(final Player player) {
sched.runTaskAsynchronously(plugin, new Runnable() { sched.runTaskAsynchronously(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
new AsyncronousLogout(player, plugin, plugin.database).process(); new AsynchronousLogout(player, plugin, plugin.database).process();
} }
}); });
} }
/** /**
* Method performRegister. * Method performRegister.
* *
* @param player Player * @param player Player
* @param password String * @param password String
* @param email String * @param email String
*/ */
public void performRegister(final Player player, final String password, final String email) { public void performRegister(final Player player, final String password, final String email) {
sched.runTaskAsynchronously(plugin, new Runnable() { sched.runTaskAsynchronously(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
new AsyncRegister(player, password, email, plugin, plugin.database).process(); new AsyncRegister(player, password, email, plugin, plugin.database).process();
} }
}); });
} }
/** /**
* Method performUnregister. * Method performUnregister.
* *
* @param player Player * @param player Player
* @param password String * @param password String
* @param force boolean * @param force boolean
*/ */
public void performUnregister(final Player player, final String password, final boolean force) { public void performUnregister(final Player player, final String password, final boolean force) {
sched.runTaskAsynchronously(plugin, new Runnable() { sched.runTaskAsynchronously(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
new AsyncronousUnregister(player, password, force, plugin).process(); new AsynchronousUnregister(player, password, force, plugin).process();
} }
}); });
} }
/** /**
* Method performJoin. * Method performJoin.
* *
* @param player Player * @param player Player
*/ */
public void performJoin(final Player player) { public void performJoin(final Player player) {
sched.runTaskAsynchronously(plugin, new Runnable() { sched.runTaskAsynchronously(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
new AsyncronousJoin(player, plugin, plugin.database).process(); new AsynchronousJoin(player, plugin, plugin.database).process();
} }
}); });
} }
/** /**
* Method performQuit. * Method performQuit.
* *
* @param player Player * @param player Player
* @param isKick boolean * @param isKick boolean
*/ */
public void performQuit(final Player player, final boolean isKick) { public void performQuit(final Player player, final boolean isKick) {
sched.runTaskAsynchronously(plugin, new Runnable() { sched.runTaskAsynchronously(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
new AsyncronousQuit(player, plugin, plugin.database, isKick).process(); new AsynchronousQuit(player, plugin, plugin.database, isKick).process();
} }
}); });
} }
/** /**
* Method performAddEmail. * Method performAddEmail.
* *
* @param player Player * @param player Player
* @param newEmail String * @param newEmail String
* @param newEmailVerify String * @param newEmailVerify String
*/ */
public void performAddEmail(final Player player, final String newEmail, final String newEmailVerify) { public void performAddEmail(final Player player, final String newEmail, final String newEmailVerify) {
sched.runTaskAsynchronously(plugin, new Runnable() { sched.runTaskAsynchronously(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
new AsyncChangeEmail(player, plugin, null, newEmail, newEmailVerify).process(); new AsyncChangeEmail(player, plugin, null, newEmail, newEmailVerify).process();
} }
}); });
} }
/** /**
* Method performChangeEmail. * Method performChangeEmail.
* *
* @param player Player * @param player Player
* @param oldEmail String * @param oldEmail String
* @param newEmail String * @param newEmail String
*/ */
public void performChangeEmail(final Player player, final String oldEmail, final String newEmail) { public void performChangeEmail(final Player player, final String oldEmail, final String newEmail) {
sched.runTaskAsynchronously(plugin, new Runnable() { sched.runTaskAsynchronously(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
new AsyncChangeEmail(player, plugin, oldEmail, newEmail).process(); new AsyncChangeEmail(player, plugin, oldEmail, newEmail).process();
} }
}); });
} }
} }

View File

@ -29,7 +29,7 @@ import org.bukkit.scheduler.BukkitTask;
/** /**
*/ */
public class AsyncronousJoin { public class AsynchronousJoin {
private final AuthMe plugin; private final AuthMe plugin;
private final Player player; private final Player player;
@ -39,13 +39,13 @@ public class AsyncronousJoin {
private final BukkitScheduler sched; private final BukkitScheduler sched;
/** /**
* Constructor for AsyncronousJoin. * Constructor for AsynchronousJoin.
* *
* @param player Player * @param player Player
* @param plugin AuthMe * @param plugin AuthMe
* @param database DataSource * @param database DataSource
*/ */
public AsyncronousJoin(Player player, AuthMe plugin, DataSource database) { public AsynchronousJoin(Player player, AuthMe plugin, DataSource database) {
this.player = player; this.player = player;
this.plugin = plugin; this.plugin = plugin;
this.sched = plugin.getServer().getScheduler(); this.sched = plugin.getServer().getScheduler();
@ -248,7 +248,7 @@ public class AsyncronousJoin {
} }
String[] msg = isAuthAvailable ? m.send("login_msg") : String[] msg = isAuthAvailable ? m.send("login_msg") :
m.send("reg_" + (Settings.emailRegistration ? "email_" : "") + "msg"); m.send("reg_" + (Settings.emailRegistration ? "email_" : "") + "msg");
BukkitTask msgTask = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, msg, msgInterval)); BukkitTask msgTask = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, msg, msgInterval));
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgTask); LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgTask);
} }
@ -261,10 +261,10 @@ public class AsyncronousJoin {
private boolean needFirstSpawn() { private boolean needFirstSpawn() {
if (player.hasPlayedBefore()) if (player.hasPlayedBefore())
return false; return false;
Location firstspawn = Spawn.getInstance().getFirstSpawn(); Location firstSpawn = Spawn.getInstance().getFirstSpawn();
if (firstspawn == null || firstspawn.getWorld() == null) if (firstSpawn == null || firstSpawn.getWorld() == null)
return false; return false;
FirstSpawnTeleportEvent tpEvent = new FirstSpawnTeleportEvent(player, player.getLocation(), firstspawn); FirstSpawnTeleportEvent tpEvent = new FirstSpawnTeleportEvent(player, player.getLocation(), firstSpawn);
plugin.getServer().getPluginManager().callEvent(tpEvent); plugin.getServer().getPluginManager().callEvent(tpEvent);
if (!tpEvent.isCancelled()) { if (!tpEvent.isCancelled()) {
if (player.isOnline() && tpEvent.getTo() != null && tpEvent.getTo().getWorld() != null) { if (player.isOnline() && tpEvent.getTo() != null && tpEvent.getTo().getWorld() != null) {
@ -306,7 +306,7 @@ public class AsyncronousJoin {
Material cur = player.getLocation().getBlock().getType(); Material cur = player.getLocation().getBlock().getType();
Material top = player.getLocation().add(0D, 1D, 0D).getBlock().getType(); Material top = player.getLocation().add(0D, 1D, 0D).getBlock().getType();
if (cur == Material.PORTAL || cur == Material.ENDER_PORTAL if (cur == Material.PORTAL || cur == Material.ENDER_PORTAL
|| top == Material.PORTAL || top == Material.ENDER_PORTAL) { || top == Material.PORTAL || top == Material.ENDER_PORTAL) {
m.send(player, "unsafe_spawn"); m.send(player, "unsafe_spawn");
player.teleport(spawnLoc); player.teleport(spawnLoc);
} }

View File

@ -23,20 +23,20 @@ import java.util.List;
/** /**
*/ */
public class AsyncronousLogin { public class AsynchronousLogin {
private static RandomString rdm = new RandomString(Settings.captchaLength); private static final RandomString rdm = new RandomString(Settings.captchaLength);
protected Player player; protected final Player player;
protected String name; protected final String name;
protected String realName; protected final String realName;
protected String password; protected final String password;
protected boolean forceLogin; protected final boolean forceLogin;
private AuthMe plugin; private final AuthMe plugin;
private DataSource database; private final DataSource database;
private Messages m = Messages.getInstance(); private final Messages m = Messages.getInstance();
/** /**
* Constructor for AsyncronousLogin. * Constructor for AsynchronousLogin.
* *
* @param player Player * @param player Player
* @param password String * @param password String
@ -44,8 +44,8 @@ public class AsyncronousLogin {
* @param plugin AuthMe * @param plugin AuthMe
* @param data DataSource * @param data DataSource
*/ */
public AsyncronousLogin(Player player, String password, boolean forceLogin, public AsynchronousLogin(Player player, String password, boolean forceLogin,
AuthMe plugin, DataSource data) { AuthMe plugin, DataSource data) {
this.player = player; this.player = player;
this.password = password; this.password = password;
name = player.getName().toLowerCase(); name = player.getName().toLowerCase();

View File

@ -24,14 +24,14 @@ import org.bukkit.potion.PotionEffectType;
*/ */
public class ProcessSyncronousPlayerLogin implements Runnable { public class ProcessSyncronousPlayerLogin implements Runnable {
private LimboPlayer limbo; private final LimboPlayer limbo;
private Player player; private final Player player;
private String name; private final String name;
private PlayerAuth auth; private final PlayerAuth auth;
private AuthMe plugin; private final AuthMe plugin;
private DataSource database; private final DataSource database;
private PluginManager pm; private final PluginManager pm;
private JsonCache playerCache; private final JsonCache playerCache;
/** /**
* Constructor for ProcessSyncronousPlayerLogin. * Constructor for ProcessSyncronousPlayerLogin.
@ -194,11 +194,11 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
if (Settings.useWelcomeMessage) if (Settings.useWelcomeMessage)
if (Settings.broadcastWelcomeMessage) { if (Settings.broadcastWelcomeMessage) {
for (String s : Settings.welcomeMsg) { for (String s : Settings.welcomeMsg) {
Bukkit.getServer().broadcastMessage(plugin.replaceAllInfos(s, player)); Bukkit.getServer().broadcastMessage(plugin.replaceAllInfo(s, player));
} }
} else { } else {
for (String s : Settings.welcomeMsg) { for (String s : Settings.welcomeMsg) {
player.sendMessage(plugin.replaceAllInfos(s, player)); player.sendMessage(plugin.replaceAllInfo(s, player));
} }
} }

View File

@ -13,24 +13,24 @@ import org.bukkit.scheduler.BukkitScheduler;
/** /**
*/ */
public class AsyncronousLogout { public class AsynchronousLogout {
protected Player player; protected final Player player;
protected String name; protected final String name;
protected AuthMe plugin; protected final AuthMe plugin;
protected DataSource database; protected final DataSource database;
protected boolean canLogout = true; protected boolean canLogout = true;
private Messages m = Messages.getInstance(); private final Messages m = Messages.getInstance();
/** /**
* Constructor for AsyncronousLogout. * Constructor for AsynchronousLogout.
* *
* @param player Player * @param player Player
* @param plugin AuthMe * @param plugin AuthMe
* @param database DataSource * @param database DataSource
*/ */
public AsyncronousLogout(Player player, AuthMe plugin, public AsynchronousLogout(Player player, AuthMe plugin,
DataSource database) { DataSource database) {
this.player = player; this.player = player;
this.plugin = plugin; this.plugin = plugin;
this.database = database; this.database = database;
@ -49,7 +49,7 @@ public class AsyncronousLogout {
if (!canLogout) if (!canLogout)
return; return;
final Player p = player; final Player p = player;
BukkitScheduler sched = p.getServer().getScheduler(); BukkitScheduler scheduler = p.getServer().getScheduler();
PlayerAuth auth = PlayerCache.getInstance().getAuth(name); PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
database.updateSession(auth); database.updateSession(auth);
auth.setQuitLocX(p.getLocation().getX()); auth.setQuitLocX(p.getLocation().getX());
@ -60,7 +60,7 @@ public class AsyncronousLogout {
PlayerCache.getInstance().removePlayer(name); PlayerCache.getInstance().removePlayer(name);
database.setUnlogged(name); database.setUnlogged(name);
sched.scheduleSyncDelayedTask(plugin, new Runnable() { scheduler.scheduleSyncDelayedTask(plugin, new Runnable() {
@Override @Override
public void run() { public void run() {
Utils.teleportToSpawn(p); Utils.teleportToSpawn(p);
@ -71,6 +71,6 @@ public class AsyncronousLogout {
LimboCache.getInstance().addLimboPlayer(player); LimboCache.getInstance().addLimboPlayer(player);
Utils.setGroup(player, GroupType.NOTLOGGEDIN); Utils.setGroup(player, GroupType.NOTLOGGEDIN);
sched.scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerLogout(p, plugin)); scheduler.scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerLogout(p, plugin));
} }
} }

View File

@ -1,77 +1,77 @@
package fr.xephi.authme.process.logout; package fr.xephi.authme.process.logout;
import fr.xephi.authme.AuthMe; import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.limbo.LimboCache; import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.events.LogoutEvent; import fr.xephi.authme.events.LogoutEvent;
import fr.xephi.authme.settings.Messages; import fr.xephi.authme.settings.Messages;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.task.MessageTask; import fr.xephi.authme.task.MessageTask;
import fr.xephi.authme.task.TimeoutTask; import fr.xephi.authme.task.TimeoutTask;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.scheduler.BukkitScheduler;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
/** /**
*/ */
public class ProcessSyncronousPlayerLogout implements Runnable { public class ProcessSyncronousPlayerLogout implements Runnable {
protected Player player; protected final Player player;
protected AuthMe plugin; protected final AuthMe plugin;
protected String name; protected final String name;
private Messages m = Messages.getInstance(); private final Messages m = Messages.getInstance();
/** /**
* Constructor for ProcessSyncronousPlayerLogout. * Constructor for ProcessSyncronousPlayerLogout.
* *
* @param player Player * @param player Player
* @param plugin AuthMe * @param plugin AuthMe
*/ */
public ProcessSyncronousPlayerLogout(Player player, AuthMe plugin) { public ProcessSyncronousPlayerLogout(Player player, AuthMe plugin) {
this.player = player; this.player = player;
this.plugin = plugin; this.plugin = plugin;
this.name = player.getName().toLowerCase(); this.name = player.getName().toLowerCase();
} }
/** /**
* Method run. * Method run.
* *
* @see java.lang.Runnable#run() * @see java.lang.Runnable#run()
*/ */
@Override @Override
public void run() { public void run() {
if (plugin.sessions.containsKey(name)) if (plugin.sessions.containsKey(name))
plugin.sessions.get(name).cancel(); plugin.sessions.get(name).cancel();
plugin.sessions.remove(name); plugin.sessions.remove(name);
int delay = Settings.getRegistrationTimeout * 20; int delay = Settings.getRegistrationTimeout * 20;
int interval = Settings.getWarnMessageInterval; int interval = Settings.getWarnMessageInterval;
BukkitScheduler sched = player.getServer().getScheduler(); BukkitScheduler sched = player.getServer().getScheduler();
if (delay != 0) { if (delay != 0) {
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), delay); BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), delay);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id); LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
} }
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval)); BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval));
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT); LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
if (player.isInsideVehicle() && player.getVehicle() != null) if (player.isInsideVehicle() && player.getVehicle() != null)
player.getVehicle().eject(); player.getVehicle().eject();
if (Settings.applyBlindEffect) if (Settings.applyBlindEffect)
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2)); player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
player.setOp(false); player.setOp(false);
if (!Settings.isMovementAllowed) { if (!Settings.isMovementAllowed) {
player.setAllowFlight(true); player.setAllowFlight(true);
player.setFlying(true); player.setFlying(true);
if (!Settings.isMovementAllowed && Settings.isRemoveSpeedEnabled) { if (!Settings.isMovementAllowed && Settings.isRemoveSpeedEnabled) {
player.setFlySpeed(0.0f); player.setFlySpeed(0.0f);
player.setWalkSpeed(0.0f); player.setWalkSpeed(0.0f);
} }
} }
// Player is now logout... Time to fire event ! // Player is now logout... Time to fire event !
Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player)); Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player));
m.send(player, "logout"); m.send(player, "logout");
ConsoleLogger.info(player.getName() + " logged out"); ConsoleLogger.info(player.getName() + " logged out");
} }
} }

View File

@ -16,27 +16,27 @@ import org.bukkit.scheduler.BukkitTask;
/** /**
*/ */
public class AsyncronousQuit { public class AsynchronousQuit {
protected AuthMe plugin; protected final AuthMe plugin;
protected DataSource database; protected final DataSource database;
protected Player player; protected final Player player;
private String name; private final String name;
private boolean isOp = false; private boolean isOp = false;
private boolean isFlying = false; private boolean isFlying = false;
private boolean needToChange = false; private boolean needToChange = false;
private boolean isKick = false; private boolean isKick = false;
/** /**
* Constructor for AsyncronousQuit. * Constructor for AsynchronousQuit.
* *
* @param p Player * @param p Player
* @param plugin AuthMe * @param plugin AuthMe
* @param database DataSource * @param database DataSource
* @param isKick boolean * @param isKick boolean
*/ */
public AsyncronousQuit(Player p, AuthMe plugin, DataSource database, public AsynchronousQuit(Player p, AuthMe plugin, DataSource database,
boolean isKick) { boolean isKick) {
this.player = p; this.player = p;
this.plugin = plugin; this.plugin = plugin;
this.database = database; this.database = database;

View File

@ -9,11 +9,11 @@ import org.bukkit.entity.Player;
*/ */
public class ProcessSyncronousPlayerQuit implements Runnable { public class ProcessSyncronousPlayerQuit implements Runnable {
protected AuthMe plugin; protected final AuthMe plugin;
protected Player player; protected final Player player;
protected boolean isOp; protected final boolean isOp;
protected boolean isFlying; protected final boolean isFlying;
protected boolean needToChange; protected final boolean needToChange;
/** /**
* Constructor for ProcessSyncronousPlayerQuit. * Constructor for ProcessSyncronousPlayerQuit.
@ -25,8 +25,8 @@ public class ProcessSyncronousPlayerQuit implements Runnable {
* @param needToChange boolean * @param needToChange boolean
*/ */
public ProcessSyncronousPlayerQuit(AuthMe plugin, Player player public ProcessSyncronousPlayerQuit(AuthMe plugin, Player player
, boolean isOp, boolean isFlying , boolean isOp, boolean isFlying
, boolean needToChange) { , boolean needToChange) {
this.plugin = plugin; this.plugin = plugin;
this.player = player; this.player = player;
this.isOp = isOp; this.isOp = isOp;
@ -51,7 +51,7 @@ public class ProcessSyncronousPlayerQuit implements Runnable {
} }
try { try {
player.getVehicle().eject(); player.getVehicle().eject();
} catch (Exception e) { } catch (Exception ignored) {
} }
} }
} }

View File

@ -17,13 +17,13 @@ import java.util.Date;
*/ */
public class AsyncRegister { public class AsyncRegister {
protected Player player; protected final Player player;
protected String name; protected final String name;
protected String password; protected final String password;
protected String email = ""; protected String email = "";
private AuthMe plugin; private final AuthMe plugin;
private DataSource database; private final DataSource database;
private Messages m = Messages.getInstance(); private final Messages m = Messages.getInstance();
/** /**
* Constructor for AsyncRegister. * Constructor for AsyncRegister.
@ -59,17 +59,17 @@ public class AsyncRegister {
* @return boolean * @throws Exception * @return boolean * @throws Exception
*/ */
protected boolean preRegisterCheck() throws Exception { protected boolean preRegisterCheck() throws Exception {
String lowpass = password.toLowerCase(); String passLow = password.toLowerCase();
if (PlayerCache.getInstance().isAuthenticated(name)) { if (PlayerCache.getInstance().isAuthenticated(name)) {
m.send(player, "logged_in"); m.send(player, "logged_in");
return false; return false;
} else if (!Settings.isRegistrationEnabled) { } else if (!Settings.isRegistrationEnabled) {
m.send(player, "reg_disabled"); m.send(player, "reg_disabled");
return false; return false;
} else if (lowpass.contains("delete") || lowpass.contains("where") || lowpass.contains("insert") || lowpass.contains("modify") || lowpass.contains("from") || lowpass.contains("select") || lowpass.contains(";") || lowpass.contains("null") || !lowpass.matches(Settings.getPassRegex)) { } else if (passLow.contains("delete") || passLow.contains("where") || passLow.contains("insert") || passLow.contains("modify") || passLow.contains("from") || passLow.contains("select") || passLow.contains(";") || passLow.contains("null") || !passLow.matches(Settings.getPassRegex)) {
m.send(player, "password_error"); m.send(player, "password_error");
return false; return false;
} else if (lowpass.equalsIgnoreCase(player.getName())) { } else if (passLow.equalsIgnoreCase(player.getName())) {
m.send(player, "password_error_nick"); m.send(player, "password_error_nick");
return false; return false;
} else if (password.length() < Settings.getPasswordMinLen || password.length() > Settings.passwordMaxLength) { } else if (password.length() < Settings.getPasswordMinLen || password.length() > Settings.passwordMaxLength) {
@ -125,8 +125,8 @@ public class AsyncRegister {
} }
} }
PlayerAuth auth; PlayerAuth auth;
final String hashnew = PasswordSecurity.getHash(Settings.getPasswordHash, password, name); final String hashNew = PasswordSecurity.getHash(Settings.getPasswordHash, password, name);
auth = new PlayerAuth(name, hashnew, getIp(), 0, (int) player.getLocation().getX(), (int) player.getLocation().getY(), (int) player.getLocation().getZ(), player.getLocation().getWorld().getName(), email, player.getName()); auth = new PlayerAuth(name, hashNew, getIp(), 0, (int) player.getLocation().getX(), (int) player.getLocation().getY(), (int) player.getLocation().getZ(), player.getLocation().getWorld().getName(), email, player.getName());
if (PasswordSecurity.userSalt.containsKey(name)) { if (PasswordSecurity.userSalt.containsKey(name)) {
auth.setSalt(PasswordSecurity.userSalt.get(name)); auth.setSalt(PasswordSecurity.userSalt.get(name));
} }
@ -134,8 +134,8 @@ public class AsyncRegister {
database.updateEmail(auth); database.updateEmail(auth);
database.updateSession(auth); database.updateSession(auth);
plugin.mail.main(auth, password); plugin.mail.main(auth, password);
ProcessSyncEmailRegister syncronous = new ProcessSyncEmailRegister(player, plugin); ProcessSyncEmailRegister sync = new ProcessSyncEmailRegister(player, plugin);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, syncronous); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, sync);
} }
@ -163,7 +163,7 @@ public class AsyncRegister {
database.setLogged(name); database.setLogged(name);
} }
plugin.otherAccounts.addPlayer(player.getUniqueId()); plugin.otherAccounts.addPlayer(player.getUniqueId());
ProcessSyncronousPasswordRegister syncronous = new ProcessSyncronousPasswordRegister(player, plugin); ProcessSyncronousPasswordRegister sync = new ProcessSyncronousPasswordRegister(player, plugin);
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, syncronous); plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, sync);
} }
} }

View File

@ -17,10 +17,10 @@ import org.bukkit.scheduler.BukkitTask;
*/ */
public class ProcessSyncEmailRegister implements Runnable { public class ProcessSyncEmailRegister implements Runnable {
protected Player player; protected final Player player;
protected String name; protected final String name;
private AuthMe plugin; private final AuthMe plugin;
private Messages m = Messages.getInstance(); private final Messages m = Messages.getInstance();
/** /**
* Constructor for ProcessSyncEmailRegister. * Constructor for ProcessSyncEmailRegister.

View File

@ -22,10 +22,10 @@ import org.bukkit.scheduler.BukkitTask;
*/ */
public class ProcessSyncronousPasswordRegister implements Runnable { public class ProcessSyncronousPasswordRegister implements Runnable {
protected Player player; protected final Player player;
protected String name; protected final String name;
private AuthMe plugin; private final AuthMe plugin;
private Messages m = Messages.getInstance(); private final Messages m = Messages.getInstance();
/** /**
* Constructor for ProcessSyncronousPasswordRegister. * Constructor for ProcessSyncronousPasswordRegister.
@ -139,11 +139,11 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
if (Settings.useWelcomeMessage) if (Settings.useWelcomeMessage)
if (Settings.broadcastWelcomeMessage) { if (Settings.broadcastWelcomeMessage) {
for (String s : Settings.welcomeMsg) { for (String s : Settings.welcomeMsg) {
plugin.getServer().broadcastMessage(plugin.replaceAllInfos(s, player)); plugin.getServer().broadcastMessage(plugin.replaceAllInfo(s, player));
} }
} else { } else {
for (String s : Settings.welcomeMsg) { for (String s : Settings.welcomeMsg) {
player.sendMessage(plugin.replaceAllInfos(s, player)); player.sendMessage(plugin.replaceAllInfo(s, player));
} }
} }

View File

@ -22,26 +22,26 @@ import java.security.NoSuchAlgorithmException;
/** /**
*/ */
public class AsyncronousUnregister { public class AsynchronousUnregister {
protected Player player; protected final Player player;
protected String name; protected final String name;
protected String password; protected final String password;
protected boolean force; protected final boolean force;
private AuthMe plugin; private final AuthMe plugin;
private Messages m = Messages.getInstance(); private final Messages m = Messages.getInstance();
private JsonCache playerCache; private final JsonCache playerCache;
/** /**
* Constructor for AsyncronousUnregister. * Constructor for AsynchronousUnregister.
* *
* @param player Player * @param player Player
* @param password String * @param password String
* @param force boolean * @param force boolean
* @param plugin AuthMe * @param plugin AuthMe
*/ */
public AsyncronousUnregister(Player player, String password, public AsynchronousUnregister(Player player, String password,
boolean force, AuthMe plugin) { boolean force, AuthMe plugin) {
this.player = player; this.player = player;
this.password = password; this.password = password;
this.force = force; this.force = force;
@ -75,12 +75,12 @@ public class AsyncronousUnregister {
LimboCache.getInstance().addLimboPlayer(player); LimboCache.getInstance().addLimboPlayer(player);
int delay = Settings.getRegistrationTimeout * 20; int delay = Settings.getRegistrationTimeout * 20;
int interval = Settings.getWarnMessageInterval; int interval = Settings.getWarnMessageInterval;
BukkitScheduler sched = plugin.getServer().getScheduler(); BukkitScheduler scheduler = plugin.getServer().getScheduler();
if (delay != 0) { if (delay != 0) {
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), delay); BukkitTask id = scheduler.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), delay);
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id); LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
} }
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("reg_msg"), interval))); LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(scheduler.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("reg_msg"), interval)));
m.send(player, "unregistered"); m.send(player, "unregistered");
ConsoleLogger.info(player.getDisplayName() + " unregistered himself"); ConsoleLogger.info(player.getDisplayName() + " unregistered himself");
return; return;

View File

@ -35,7 +35,7 @@ public enum HashAlgorithm {
SALTEDSHA512(fr.xephi.authme.security.crypts.SALTEDSHA512.class), SALTEDSHA512(fr.xephi.authme.security.crypts.SALTEDSHA512.class),
CUSTOM(Null.class); CUSTOM(Null.class);
Class<?> classe; final Class<?> classe;
/** /**
* Constructor for HashAlgorithm. * Constructor for HashAlgorithm.

View File

@ -18,17 +18,18 @@ import java.util.HashMap;
*/ */
public class PasswordSecurity { public class PasswordSecurity {
public static HashMap<String, String> userSalt = new HashMap<>(); public static final HashMap<String, String> userSalt = new HashMap<>();
private static SecureRandom rnd = new SecureRandom(); private static final SecureRandom rnd = new SecureRandom();
/** /**
* Method createSalt. * Method createSalt.
* *
* @param length int * @param length int
*
* @return String * @throws NoSuchAlgorithmException * @return String * @throws NoSuchAlgorithmException
*/ */
public static String createSalt(int length) public static String createSalt(int length)
throws NoSuchAlgorithmException { throws NoSuchAlgorithmException {
byte[] msg = new byte[40]; byte[] msg = new byte[40];
rnd.nextBytes(msg); rnd.nextBytes(msg);
MessageDigest sha1 = MessageDigest.getInstance("SHA1"); MessageDigest sha1 = MessageDigest.getInstance("SHA1");
@ -43,6 +44,7 @@ public class PasswordSecurity {
* @param alg HashAlgorithm * @param alg HashAlgorithm
* @param password String * @param password String
* @param playerName String * @param playerName String
*
* @return String * @throws NoSuchAlgorithmException * @return String * @throws NoSuchAlgorithmException
*/ */
public static String getHash(HashAlgorithm alg, String password, public static String getHash(HashAlgorithm alg, String password,
@ -146,15 +148,16 @@ public class PasswordSecurity {
* @param password String * @param password String
* @param hash String * @param hash String
* @param playerName String * @param playerName String
*
* @return boolean * @throws NoSuchAlgorithmException * @return boolean * @throws NoSuchAlgorithmException
*/ */
public static boolean comparePasswordWithHash(String password, String hash, public static boolean comparePasswordWithHash(String password, String hash,
String playerName) throws NoSuchAlgorithmException { String playerName) throws NoSuchAlgorithmException {
HashAlgorithm algo = Settings.getPasswordHash; HashAlgorithm algorithm = Settings.getPasswordHash;
EncryptionMethod method; EncryptionMethod method;
try { try {
if (algo != HashAlgorithm.CUSTOM) if (algorithm != HashAlgorithm.CUSTOM)
method = (EncryptionMethod) algo.getclasse().newInstance(); method = (EncryptionMethod) algorithm.getclasse().newInstance();
else else
method = null; method = null;
@ -184,10 +187,11 @@ public class PasswordSecurity {
* @param password String * @param password String
* @param hash String * @param hash String
* @param playerName String * @param playerName String
*
* @return boolean * @throws NoSuchAlgorithmException * @return boolean * @throws NoSuchAlgorithmException
*/ */
private static boolean compareWithAllEncryptionMethod(String password, private static boolean compareWithAllEncryptionMethod(String password,
String hash, String playerName) throws NoSuchAlgorithmException { String hash, String playerName) {
for (HashAlgorithm algo : HashAlgorithm.values()) { for (HashAlgorithm algo : HashAlgorithm.values()) {
if (algo != HashAlgorithm.CUSTOM) { if (algo != HashAlgorithm.CUSTOM) {
try { try {

View File

@ -21,37 +21,37 @@ import java.security.SecureRandom;
* BCrypt implements OpenBSD-style Blowfish password hashing using the scheme * BCrypt implements OpenBSD-style Blowfish password hashing using the scheme
* described in "A Future-Adaptable Password Scheme" by Niels Provos and David * described in "A Future-Adaptable Password Scheme" by Niels Provos and David
* Mazieres. * Mazieres.
* <p> * <p/>
* This password hashing system tries to thwart off-line password cracking using * This password hashing system tries to thwart off-line password cracking using
* a computationally-intensive hashing algorithm, based on Bruce Schneier's * a computationally-intensive hashing algorithm, based on Bruce Schneier's
* Blowfish cipher. The work factor of the algorithm is parameterised, so it can * Blowfish cipher. The work factor of the algorithm is parameterised, so it can
* be increased as computers get faster. * be increased as computers get faster.
* <p> * <p/>
* Usage is really simple. To hash a password for the first time, call the * Usage is really simple. To hash a password for the first time, call the
* hashpw method with a random salt, like this: * hashpw method with a random salt, like this:
* <p> * <p/>
* <code> * <code>
* String pw_hash = BCrypt.hashpw(plain_password, BCrypt.gensalt()); <br /> * String pw_hash = BCrypt.hashpw(plain_password, BCrypt.gensalt()); <br />
* </code> * </code>
* <p> * <p/>
* To check whether a plaintext password matches one that has been hashed * To check whether a plaintext password matches one that has been hashed
* previously, use the checkpw method: * previously, use the checkpw method:
* <p> * <p/>
* <code> * <code>
* if (BCrypt.checkpw(candidate_password, stored_hash))<br /> * if (BCrypt.checkpw(candidate_password, stored_hash))<br />
* &nbsp;&nbsp;&nbsp;&nbsp;System.out.println("It matches");<br /> * &nbsp;&nbsp;&nbsp;&nbsp;System.out.println("It matches");<br />
* else<br /> * else<br />
* &nbsp;&nbsp;&nbsp;&nbsp;System.out.println("It does not match");<br /> * &nbsp;&nbsp;&nbsp;&nbsp;System.out.println("It does not match");<br />
* </code> * </code>
* <p> * <p/>
* The gensalt() method takes an optional parameter (log_rounds) that determines * The gensalt() method takes an optional parameter (log_rounds) that determines
* the computational complexity of the hashing: * the computational complexity of the hashing:
* <p> * <p/>
* <code> * <code>
* String strong_salt = BCrypt.gensalt(10)<br /> * String strong_salt = BCrypt.gensalt(10)<br />
* String stronger_salt = BCrypt.gensalt(12)<br /> * String stronger_salt = BCrypt.gensalt(12)<br />
* </code> * </code>
* <p> * <p/>
* The amount of work increases exponentially (2**log_rounds), so each increment * The amount of work increases exponentially (2**log_rounds), so each increment
* is twice as much work. The default log_rounds is 10, and the valid range is 4 * is twice as much work. The default log_rounds is 10, and the valid range is 4
* to 31. * to 31.
@ -92,12 +92,13 @@ public class BCRYPT implements EncryptionMethod {
* *
* @param d the byte array to encode * @param d the byte array to encode
* @param len the number of bytes to encode * @param len the number of bytes to encode
*
* @return base64-encoded string * @throws IllegalArgumentException if the length is invalid * @throws IllegalArgumentException * @return base64-encoded string * @throws IllegalArgumentException if the length is invalid * @throws IllegalArgumentException
*/ */
private static String encode_base64(byte d[], int len) private static String encode_base64(byte d[], int len)
throws IllegalArgumentException { throws IllegalArgumentException {
int off = 0; int off = 0;
StringBuffer rs = new StringBuffer(); StringBuilder rs = new StringBuilder();
int c1, c2; int c1, c2;
if (len <= 0 || len > d.length) if (len <= 0 || len > d.length)
@ -132,6 +133,7 @@ public class BCRYPT implements EncryptionMethod {
* range-checking againt conversion table * range-checking againt conversion table
* *
* @param x the base64-encoded value * @param x the base64-encoded value
*
* @return the decoded value of x * @return the decoded value of x
*/ */
private static byte char64(char x) { private static byte char64(char x) {
@ -147,11 +149,12 @@ public class BCRYPT implements EncryptionMethod {
* *
* @param s the string to decode * @param s the string to decode
* @param maxolen the maximum number of bytes to decode * @param maxolen the maximum number of bytes to decode
*
* @return an array containing the decoded bytes * @throws IllegalArgumentException if maxolen is invalid * @throws IllegalArgumentException * @return an array containing the decoded bytes * @throws IllegalArgumentException if maxolen is invalid * @throws IllegalArgumentException
*/ */
private static byte[] decode_base64(String s, int maxolen) private static byte[] decode_base64(String s, int maxolen)
throws IllegalArgumentException { throws IllegalArgumentException {
StringBuffer rs = new StringBuffer(); StringBuilder rs = new StringBuilder();
int off = 0, slen = s.length(), olen = 0; int off = 0, slen = s.length(), olen = 0;
byte ret[]; byte ret[];
byte c1, c2, c3, c4, o; byte c1, c2, c3, c4, o;
@ -196,6 +199,7 @@ public class BCRYPT implements EncryptionMethod {
* @param data the string to extract the data from * @param data the string to extract the data from
* @param offp a "pointer" (as a one-entry array) to the current offset into * @param offp a "pointer" (as a one-entry array) to the current offset into
* data * data
*
* @return the next word of material from data * @return the next word of material from data
*/ */
private static int streamtoword(byte data[], int offp[]) { private static int streamtoword(byte data[], int offp[]) {
@ -217,6 +221,7 @@ public class BCRYPT implements EncryptionMethod {
* *
* @param password the password to hash * @param password the password to hash
* @param salt the salt to hash with (perhaps generated using BCrypt.gensalt) * @param salt the salt to hash with (perhaps generated using BCrypt.gensalt)
*
* @return the hashed password * @return the hashed password
*/ */
public static String hashpw(String password, String salt) { public static String hashpw(String password, String salt) {
@ -225,7 +230,7 @@ public class BCRYPT implements EncryptionMethod {
byte passwordb[], saltb[], hashed[]; byte passwordb[], saltb[], hashed[];
char minor = (char) 0; char minor = (char) 0;
int rounds, off = 0; int rounds, off = 0;
StringBuffer rs = new StringBuffer(); StringBuilder rs = new StringBuilder();
if (salt.charAt(0) != '$' || salt.charAt(1) != '2') if (salt.charAt(0) != '$' || salt.charAt(1) != '2')
throw new IllegalArgumentException("Invalid salt version"); throw new IllegalArgumentException("Invalid salt version");
@ -274,10 +279,11 @@ public class BCRYPT implements EncryptionMethod {
* @param log_rounds the log2 of the number of rounds of hashing to apply - the * @param log_rounds the log2 of the number of rounds of hashing to apply - the
* work factor therefore increases as 2**log_rounds. * work factor therefore increases as 2**log_rounds.
* @param random an instance of SecureRandom to use * @param random an instance of SecureRandom to use
*
* @return an encoded salt value * @return an encoded salt value
*/ */
public static String gensalt(int log_rounds, SecureRandom random) { public static String gensalt(int log_rounds, SecureRandom random) {
StringBuffer rs = new StringBuffer(); StringBuilder rs = new StringBuilder();
byte rnd[] = new byte[BCRYPT_SALT_LEN]; byte rnd[] = new byte[BCRYPT_SALT_LEN];
random.nextBytes(rnd); random.nextBytes(rnd);
@ -296,6 +302,7 @@ public class BCRYPT implements EncryptionMethod {
* *
* @param log_rounds the log2 of the number of rounds of hashing to apply - the * @param log_rounds the log2 of the number of rounds of hashing to apply - the
* work factor therefore increases as 2**log_rounds. * work factor therefore increases as 2**log_rounds.
*
* @return an encoded salt value * @return an encoded salt value
*/ */
public static String gensalt(int log_rounds) { public static String gensalt(int log_rounds) {
@ -317,6 +324,7 @@ public class BCRYPT implements EncryptionMethod {
* *
* @param plaintext the plaintext password to verify * @param plaintext the plaintext password to verify
* @param hashed the previously-hashed password * @param hashed the previously-hashed password
*
* @return true if the passwords match, false otherwise * @return true if the passwords match, false otherwise
*/ */
public static boolean checkpw(String plaintext, String hashed) { public static boolean checkpw(String plaintext, String hashed) {
@ -330,6 +338,7 @@ public class BCRYPT implements EncryptionMethod {
* @param text plaintext or hashed text * @param text plaintext or hashed text
* @param hashed the previously-hashed password * @param hashed the previously-hashed password
* @param rounds number of rounds to hash the password * @param rounds number of rounds to hash the password
*
* @return boolean * @return boolean
*/ */
public static boolean checkpw(String text, String hashed, int rounds) { public static boolean checkpw(String text, String hashed, int rounds) {
@ -355,6 +364,7 @@ public class BCRYPT implements EncryptionMethod {
* *
* @param text String * @param text String
* @param salt String * @param salt String
*
* @return String * @return String
*/ */
public static String getDoubleHash(String text, String salt) { public static String getDoubleHash(String text, String salt) {
@ -467,6 +477,7 @@ public class BCRYPT implements EncryptionMethod {
* @param salt the binary salt to hash with the password * @param salt the binary salt to hash with the password
* @param log_rounds the binary logarithm of the number of rounds of hashing to * @param log_rounds the binary logarithm of the number of rounds of hashing to
* apply * apply
*
* @return an array containing the binary hashed password * @return an array containing the binary hashed password
*/ */
private byte[] crypt_raw(byte password[], byte salt[], int log_rounds) { private byte[] crypt_raw(byte password[], byte salt[], int log_rounds) {
@ -509,11 +520,12 @@ public class BCRYPT implements EncryptionMethod {
* @param password String * @param password String
* @param salt String * @param salt String
* @param name String * @param name String
*
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
*/ */
@Override @Override
public String getHash(String password, String salt, String name) public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException { throws NoSuchAlgorithmException {
return hashpw(password, salt); return hashpw(password, salt);
} }
@ -523,6 +535,7 @@ public class BCRYPT implements EncryptionMethod {
* @param hash String * @param hash String
* @param password String * @param password String
* @param playerName String * @param playerName String
*
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
*/ */
@Override @Override

View File

@ -1,42 +1,44 @@
package fr.xephi.authme.security.crypts; package fr.xephi.authme.security.crypts;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
/** /**
*/ */
public class BCRYPT2Y implements EncryptionMethod { public class BCRYPT2Y implements EncryptionMethod {
/** /**
* Method getHash. * Method getHash.
* *
* @param password String * @param password String
* @param salt String * @param salt String
* @param name String * @param name String
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) *
*/ * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
@Override */
public String getHash(String password, String salt, String name) @Override
throws NoSuchAlgorithmException { public String getHash(String password, String salt, String name)
if (salt.length() == 22) throws NoSuchAlgorithmException {
salt = "$2y$10$" + salt; if (salt.length() == 22)
return (BCRYPT.hashpw(password, salt)); salt = "$2y$10$" + salt;
} return (BCRYPT.hashpw(password, salt));
}
/**
* Method comparePassword. /**
* * Method comparePassword.
* @param hash String *
* @param password String * @param hash String
* @param playerName String * @param password String
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) * @param playerName String
*/ *
@Override * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
public boolean comparePassword(String hash, String password, */
String playerName) throws NoSuchAlgorithmException { @Override
String ok = hash.substring(0, 29); public boolean comparePassword(String hash, String password,
if (ok.length() != 29) String playerName) throws NoSuchAlgorithmException {
return false; String ok = hash.substring(0, 29);
return hash.equals(getHash(password, ok, playerName)); if (ok.length() != 29)
} return false;
return hash.equals(getHash(password, ok, playerName));
} }
}

View File

@ -32,11 +32,12 @@ public class CRAZYCRYPT1 implements EncryptionMethod {
* @param password String * @param password String
* @param salt String * @param salt String
* @param name String * @param name String
*
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
*/ */
@Override @Override
public String getHash(String password, String salt, String name) public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException { throws NoSuchAlgorithmException {
final String text = "ÜÄaeut//&/=I " + password + "7421€547" + name + "__+IÄIH§%NK " + password; final String text = "ÜÄaeut//&/=I " + password + "7421€547" + name + "__+IÄIH§%NK " + password;
try { try {
final MessageDigest md = MessageDigest.getInstance("SHA-512"); final MessageDigest md = MessageDigest.getInstance("SHA-512");

View File

@ -4,6 +4,7 @@ import fr.xephi.authme.security.pbkdf2.PBKDF2Engine;
import fr.xephi.authme.security.pbkdf2.PBKDF2Parameters; import fr.xephi.authme.security.pbkdf2.PBKDF2Parameters;
import java.security.NoSuchAlgorithmException; import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
/** /**
*/ */
@ -15,16 +16,17 @@ public class CryptPBKDF2 implements EncryptionMethod {
* @param password String * @param password String
* @param salt String * @param salt String
* @param name String * @param name String
*
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
*/ */
@Override @Override
public String getHash(String password, String salt, String name) public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException { throws NoSuchAlgorithmException {
String result = "pbkdf2_sha256$10000$" + salt + "$"; String result = "pbkdf2_sha256$10000$" + salt + "$";
PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 10000); PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 10000);
PBKDF2Engine engine = new PBKDF2Engine(params); PBKDF2Engine engine = new PBKDF2Engine(params);
return result + String.valueOf(engine.deriveKey(password, 64)); return result + Arrays.toString(engine.deriveKey(password, 64));
} }
/** /**
@ -33,6 +35,7 @@ public class CryptPBKDF2 implements EncryptionMethod {
* @param hash String * @param hash String
* @param password String * @param password String
* @param playerName String * @param playerName String
*
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
*/ */
@Override @Override
@ -46,4 +49,4 @@ public class CryptPBKDF2 implements EncryptionMethod {
return engine.verifyKey(password); return engine.verifyKey(password);
} }
} }

View File

@ -16,11 +16,12 @@ public class CryptPBKDF2Django implements EncryptionMethod {
* @param password String * @param password String
* @param salt String * @param salt String
* @param name String * @param name String
*
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
*/ */
@Override @Override
public String getHash(String password, String salt, String name) public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException { throws NoSuchAlgorithmException {
String result = "pbkdf2_sha256$15000$" + salt + "$"; String result = "pbkdf2_sha256$15000$" + salt + "$";
PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 15000); PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 15000);
PBKDF2Engine engine = new PBKDF2Engine(params); PBKDF2Engine engine = new PBKDF2Engine(params);
@ -34,6 +35,7 @@ public class CryptPBKDF2Django implements EncryptionMethod {
* @param hash String * @param hash String
* @param password String * @param password String
* @param playerName String * @param playerName String
*
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
*/ */
@Override @Override

View File

@ -12,10 +12,11 @@ public class DOUBLEMD5 implements EncryptionMethod {
* Method getMD5. * Method getMD5.
* *
* @param message String * @param message String
*
* @return String * @throws NoSuchAlgorithmException * @return String * @throws NoSuchAlgorithmException
*/ */
private static String getMD5(String message) private static String getMD5(String message)
throws NoSuchAlgorithmException { throws NoSuchAlgorithmException {
MessageDigest md5 = MessageDigest.getInstance("MD5"); MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.reset(); md5.reset();
md5.update(message.getBytes()); md5.update(message.getBytes());
@ -29,11 +30,12 @@ public class DOUBLEMD5 implements EncryptionMethod {
* @param password String * @param password String
* @param salt String * @param salt String
* @param name String * @param name String
*
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
*/ */
@Override @Override
public String getHash(String password, String salt, String name) public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException { throws NoSuchAlgorithmException {
return getMD5(getMD5(password)); return getMD5(getMD5(password));
} }
@ -43,6 +45,7 @@ public class DOUBLEMD5 implements EncryptionMethod {
* @param hash String * @param hash String
* @param password String * @param password String
* @param playerName String * @param playerName String
*
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
*/ */
@Override @Override

View File

@ -24,18 +24,20 @@ public interface EncryptionMethod {
* @param salt (can be an other data like playerName;salt , playerName, * @param salt (can be an other data like playerName;salt , playerName,
* etc... for customs methods) * etc... for customs methods)
* @param name String * @param name String
*
* @return Hashing password * @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException * @return Hashing password * @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
*/ */
String getHash(String password, String salt, String name) String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException; throws NoSuchAlgorithmException;
/** /**
* @param hash * @param hash
* @param password * @param password
* @param playerName * @param playerName
*
* @return true if password match, false else * @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException * @return true if password match, false else * @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
*/ */
boolean comparePassword(String hash, String password, String playerName) boolean comparePassword(String hash, String password, String playerName)
throws NoSuchAlgorithmException; throws NoSuchAlgorithmException;
} }

View File

@ -14,10 +14,11 @@ public class IPB3 implements EncryptionMethod {
* Method getMD5. * Method getMD5.
* *
* @param message String * @param message String
*
* @return String * @throws NoSuchAlgorithmException * @return String * @throws NoSuchAlgorithmException
*/ */
private static String getMD5(String message) private static String getMD5(String message)
throws NoSuchAlgorithmException { throws NoSuchAlgorithmException {
MessageDigest md5 = MessageDigest.getInstance("MD5"); MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.reset(); md5.reset();
md5.update(message.getBytes()); md5.update(message.getBytes());
@ -31,11 +32,12 @@ public class IPB3 implements EncryptionMethod {
* @param password String * @param password String
* @param salt String * @param salt String
* @param name String * @param name String
*
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
*/ */
@Override @Override
public String getHash(String password, String salt, String name) public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException { throws NoSuchAlgorithmException {
return getMD5(getMD5(salt) + getMD5(password)); return getMD5(getMD5(salt) + getMD5(password));
} }
@ -45,6 +47,7 @@ public class IPB3 implements EncryptionMethod {
* @param hash String * @param hash String
* @param password String * @param password String
* @param playerName String * @param playerName String
*
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
*/ */
@Override @Override

View File

@ -12,10 +12,11 @@ public class JOOMLA implements EncryptionMethod {
* Method getMD5. * Method getMD5.
* *
* @param message String * @param message String
*
* @return String * @throws NoSuchAlgorithmException * @return String * @throws NoSuchAlgorithmException
*/ */
private static String getMD5(String message) private static String getMD5(String message)
throws NoSuchAlgorithmException { throws NoSuchAlgorithmException {
MessageDigest md5 = MessageDigest.getInstance("MD5"); MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.reset(); md5.reset();
md5.update(message.getBytes()); md5.update(message.getBytes());
@ -29,11 +30,12 @@ public class JOOMLA implements EncryptionMethod {
* @param password String * @param password String
* @param salt String * @param salt String
* @param name String * @param name String
*
* @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String) * @return String * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#getHash(String, String, String)
*/ */
@Override @Override
public String getHash(String password, String salt, String name) public String getHash(String password, String salt, String name)
throws NoSuchAlgorithmException { throws NoSuchAlgorithmException {
return getMD5(password + salt) + ":" + salt; return getMD5(password + salt) + ":" + salt;
} }
@ -43,6 +45,7 @@ public class JOOMLA implements EncryptionMethod {
* @param hash String * @param hash String
* @param password String * @param password String
* @param playerName String * @param playerName String
*
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String) * @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
*/ */
@Override @Override

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