mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-12-19 07:07:55 +01:00
Merge upstream/master into ljacqu/enums
This commit is contained in:
commit
16a69d4126
47
.gitignore
vendored
47
.gitignore
vendored
@ -1,10 +1,7 @@
|
||||
### Java ###
|
||||
### Java files ###
|
||||
*.class
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
# Package Files
|
||||
#*.jar
|
||||
*.war
|
||||
*.ear
|
||||
@ -13,43 +10,27 @@
|
||||
hs_err_pid*
|
||||
|
||||
|
||||
|
||||
### Intellij ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
|
||||
|
||||
# Ignore project files
|
||||
*.iml
|
||||
|
||||
## Directory-based project format:
|
||||
# Ignore IDEA directory
|
||||
.idea/*
|
||||
|
||||
# Include the project's code style settings file
|
||||
!.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:
|
||||
# .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:
|
||||
# File-based project format:
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
## Plugin-specific files:
|
||||
|
||||
### Plugin-specific files: ###
|
||||
# IntelliJ
|
||||
/out/
|
||||
|
||||
@ -65,6 +46,7 @@ crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
|
||||
|
||||
|
||||
### Eclipse ###
|
||||
*.pydevproject
|
||||
.metadata
|
||||
@ -104,6 +86,7 @@ local.properties
|
||||
.texlipse
|
||||
|
||||
|
||||
|
||||
### Maven ###
|
||||
target/
|
||||
pom.xml.tag
|
||||
@ -115,6 +98,7 @@ dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
|
||||
|
||||
|
||||
### NetBeans ###
|
||||
nbproject/private/
|
||||
build/
|
||||
@ -125,5 +109,8 @@ nbactions.xml
|
||||
nb-configuration.xml
|
||||
.nb-gradle/
|
||||
|
||||
|
||||
|
||||
### Git ###
|
||||
# Don't exclude the .gitignore itself
|
||||
!.gitignore
|
||||
|
@ -3,6 +3,9 @@
|
||||
<component name="ProjectCodeStyleSettingsManager">
|
||||
<option name="PER_PROJECT_SETTINGS">
|
||||
<value>
|
||||
<option name="LINE_SEPARATOR" value=" " />
|
||||
<option name="JD_ADD_BLANK_AFTER_PARM_COMMENTS" value="true" />
|
||||
<option name="JD_ADD_BLANK_AFTER_RETURN" value="true" />
|
||||
<XML>
|
||||
<option name="XML_LEGACY_SETTINGS_IMPORTED" value="true" />
|
||||
</XML>
|
||||
|
7
.idea/dictionaries/Tim.xml
Normal file
7
.idea/dictionaries/Tim.xml
Normal file
@ -0,0 +1,7 @@
|
||||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="Tim">
|
||||
<words>
|
||||
<w>authme</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
</component>
|
@ -88,10 +88,10 @@ public class AuthMe extends JavaPlugin {
|
||||
public AuthMeInventoryPacketAdapter inventoryProtector;
|
||||
// Random data maps and stuff
|
||||
// TODO: Create Manager for this
|
||||
public ConcurrentHashMap<String, BukkitTask> sessions = new ConcurrentHashMap<>();
|
||||
public ConcurrentHashMap<String, Integer> captcha = new ConcurrentHashMap<>();
|
||||
public ConcurrentHashMap<String, String> cap = new ConcurrentHashMap<>();
|
||||
public ConcurrentHashMap<String, String> realIp = new ConcurrentHashMap<>();
|
||||
public final ConcurrentHashMap<String, BukkitTask> sessions = new ConcurrentHashMap<>();
|
||||
public final ConcurrentHashMap<String, Integer> captcha = new ConcurrentHashMap<>();
|
||||
public final ConcurrentHashMap<String, String> cap = new ConcurrentHashMap<>();
|
||||
public final ConcurrentHashMap<String, String> realIp = new ConcurrentHashMap<>();
|
||||
// AntiBot Status
|
||||
// TODO: Create Manager for this
|
||||
public boolean antiBotMod = false;
|
||||
@ -246,7 +246,7 @@ public class AuthMe extends JavaPlugin {
|
||||
// Check Essentials
|
||||
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
|
||||
checkProtocolLib();
|
||||
// End of Hooks
|
||||
@ -277,8 +277,8 @@ public class AuthMe extends JavaPlugin {
|
||||
// Set up the management
|
||||
management = new Management(this);
|
||||
|
||||
// Set up the Bungeecord hook
|
||||
setupBungeecordHook();
|
||||
// Set up the BungeeCord hook
|
||||
setupBungeeCordHook();
|
||||
|
||||
// Reload support hook
|
||||
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) {
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
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() {
|
||||
if (Settings.enableAntiBot) {
|
||||
@ -652,7 +652,7 @@ public class AuthMe extends JavaPlugin {
|
||||
try {
|
||||
ess = (Essentials) server.getPluginManager().getPlugin("Essentials");
|
||||
ConsoleLogger.info("Hooked correctly with Essentials");
|
||||
} catch (Exception | NoClassDefFoundError ingnored) {
|
||||
} catch (Exception | NoClassDefFoundError ignored) {
|
||||
ess = null;
|
||||
}
|
||||
} else {
|
||||
@ -677,7 +677,7 @@ public class AuthMe extends JavaPlugin {
|
||||
try {
|
||||
combatTagPlus = (CombatTagPlus) server.getPluginManager().getPlugin("CombatTagPlus");
|
||||
ConsoleLogger.info("Hooked correctly with CombatTagPlus");
|
||||
} catch (Exception | NoClassDefFoundError ingnored) {
|
||||
} catch (Exception | NoClassDefFoundError ignored) {
|
||||
combatTagPlus = null;
|
||||
}
|
||||
} else {
|
||||
@ -788,12 +788,12 @@ public class AuthMe extends JavaPlugin {
|
||||
return spawnLoc;
|
||||
}
|
||||
|
||||
// Return the default spawnpoint of a world
|
||||
// Return the default spawn point of a world
|
||||
private Location getDefaultSpawn(World world) {
|
||||
return world.getSpawnLocation();
|
||||
}
|
||||
|
||||
// Return the multiverse spawnpoint of a world
|
||||
// Return the multiverse spawn point of a world
|
||||
private Location getMultiverseSpawn(World world) {
|
||||
if (multiverse != null && Settings.multiverse) {
|
||||
try {
|
||||
@ -805,7 +805,7 @@ public class AuthMe extends JavaPlugin {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return the essentials spawnpoint
|
||||
// Return the essentials spawn point
|
||||
private Location getEssentialsSpawn() {
|
||||
if (essentialsSpawn != null) {
|
||||
return essentialsSpawn;
|
||||
@ -813,7 +813,7 @@ public class AuthMe extends JavaPlugin {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Return the authme soawnpoint
|
||||
// Return the AuthMe spawn point
|
||||
private Location getAuthMeSpawn(Player player) {
|
||||
if ((!database.isAuthAvailable(player.getName().toLowerCase()) || !player.hasPlayedBefore()) && (Spawn.getInstance().getFirstSpawn() != null)) {
|
||||
return Spawn.getInstance().getFirstSpawn();
|
||||
@ -855,7 +855,7 @@ public class AuthMe extends JavaPlugin {
|
||||
}, 1, 1200 * Settings.delayRecall);
|
||||
}
|
||||
|
||||
public String replaceAllInfos(String message, Player player) {
|
||||
public String replaceAllInfo(String message, Player player) {
|
||||
int playersOnline = Utils.getOnlinePlayers().size();
|
||||
message = message.replace("&", "\u00a7");
|
||||
message = message.replace("{PLAYER}", player.getName());
|
||||
@ -878,8 +878,8 @@ public class AuthMe extends JavaPlugin {
|
||||
ip = realIp.get(name);
|
||||
}
|
||||
if (Settings.checkVeryGames)
|
||||
if (getVeryGamesIP(player) != null)
|
||||
ip = getVeryGamesIP(player);
|
||||
if (getVeryGamesIp(player) != null)
|
||||
ip = getVeryGamesIp(player);
|
||||
return ip;
|
||||
}
|
||||
|
||||
@ -908,18 +908,19 @@ public class AuthMe extends JavaPlugin {
|
||||
/**
|
||||
* Gets a player's real IP through VeryGames method.
|
||||
*
|
||||
* @param player the player to process
|
||||
* @return the real IP of the player
|
||||
* @param player The player to process.
|
||||
*
|
||||
* @return The real IP of the player.
|
||||
*/
|
||||
@Deprecated
|
||||
public String getVeryGamesIP(Player player) {
|
||||
public String getVeryGamesIp(Player player) {
|
||||
String realIP = player.getAddress().getAddress().getHostAddress();
|
||||
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());
|
||||
try {
|
||||
URL url = new URL(sUrl);
|
||||
URLConnection urlc = url.openConnection();
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(urlc.getInputStream()));
|
||||
URLConnection urlCon = url.openConnection();
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(urlCon.getInputStream()));
|
||||
String inputLine = in.readLine();
|
||||
if (inputLine != null && !inputLine.isEmpty() && !inputLine.equalsIgnoreCase("error") && !inputLine.contains("error")) {
|
||||
realIP = inputLine;
|
||||
@ -940,6 +941,7 @@ public class AuthMe extends JavaPlugin {
|
||||
* @param cmd The command (Bukkit).
|
||||
* @param commandLabel The command label (Bukkit).
|
||||
* @param args The command arguments (Bukkit).
|
||||
*
|
||||
* @return True if the command was executed, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
|
@ -18,6 +18,7 @@ public class ConsoleFilter implements Filter {
|
||||
* Method isLoggable.
|
||||
*
|
||||
* @param record LogRecord
|
||||
*
|
||||
* @return boolean * @see java.util.logging.Filter#isLoggable(LogRecord)
|
||||
*/
|
||||
@Override
|
||||
@ -30,8 +31,8 @@ public class ConsoleFilter implements Filter {
|
||||
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 "))
|
||||
return true;
|
||||
String playername = record.getMessage().split(" ")[0];
|
||||
record.setMessage(playername + " issued an AuthMe command!");
|
||||
String playerName = record.getMessage().split(" ")[0];
|
||||
record.setMessage(playerName + " issued an AuthMe command!");
|
||||
return true;
|
||||
} catch (NullPointerException npe) {
|
||||
return true;
|
||||
|
@ -62,8 +62,8 @@ public final class ConsoleLogger {
|
||||
}
|
||||
try {
|
||||
Files.write(Settings.LOG_FILE.toPath(), (dateTime + ": " + message + StringUtils.newline).getBytes(),
|
||||
StandardOpenOption.APPEND,
|
||||
StandardOpenOption.CREATE);
|
||||
StandardOpenOption.APPEND,
|
||||
StandardOpenOption.CREATE);
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
|
@ -1,261 +1,269 @@
|
||||
package fr.xephi.authme;
|
||||
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class DataManager {
|
||||
|
||||
public AuthMe plugin;
|
||||
|
||||
/**
|
||||
* Constructor for DataManager.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public DataManager(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getOfflinePlayer.
|
||||
*
|
||||
* @param name String
|
||||
* @return OfflinePlayer
|
||||
*/
|
||||
public synchronized OfflinePlayer getOfflinePlayer(final String name) {
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
Future<OfflinePlayer> result = executor.submit(new Callable<OfflinePlayer>() {
|
||||
|
||||
public synchronized OfflinePlayer call() throws Exception {
|
||||
OfflinePlayer result = null;
|
||||
try {
|
||||
for (OfflinePlayer op : Bukkit.getOfflinePlayers())
|
||||
if (op.getName().equalsIgnoreCase(name)) {
|
||||
result = op;
|
||||
break;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
try {
|
||||
return result.get();
|
||||
} catch (Exception e) {
|
||||
return (null);
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method purgeAntiXray.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
public synchronized void purgeAntiXray(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
|
||||
if (player == null)
|
||||
continue;
|
||||
String playerName = player.getName();
|
||||
File playerFile = new File("." + File.separator + "plugins" + File.separator + "AntiXRayData" + File.separator + "PlayerData" + File.separator + playerName);
|
||||
if (playerFile.exists()) {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " AntiXRayData Files");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method purgeLimitedCreative.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
public synchronized void purgeLimitedCreative(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
|
||||
if (player == null)
|
||||
continue;
|
||||
String playerName = player.getName();
|
||||
File playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + ".yml");
|
||||
if (playerFile.exists()) {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_creative.yml");
|
||||
if (playerFile.exists()) {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_adventure.yml");
|
||||
if (playerFile.exists()) {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " LimitedCreative Survival, Creative and Adventure files");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method purgeDat.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
public synchronized void purgeDat(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
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();
|
||||
i++;
|
||||
} catch (Exception ignore) {
|
||||
File playerFile = new File(plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + player.getName() + ".dat");
|
||||
if (playerFile.exists()) {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " .dat Files");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method purgeEssentials.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void purgeEssentials(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + plugin.getServer().getOfflinePlayer(name).getUniqueId() + ".yml");
|
||||
playerFile.delete();
|
||||
i++;
|
||||
} catch (Exception e) {
|
||||
File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + name + ".yml");
|
||||
if (playerFile.exists()) {
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
|
||||
}
|
||||
|
||||
// TODO: What is this method for? Is it correct?
|
||||
|
||||
/**
|
||||
* @param cleared Cleared players.
|
||||
*/
|
||||
public synchronized void purgePermissions(List<String> cleared) {
|
||||
// Get the permissions manager, and make sure it's valid
|
||||
PermissionsManager permsMan = this.plugin.getPermissionsManager();
|
||||
if (permsMan == null)
|
||||
ConsoleLogger.showError("Unable to access permissions manager instance!");
|
||||
assert permsMan != null;
|
||||
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
permsMan.removeAllGroups(this.getOnlinePlayerLower(name.toLowerCase()));
|
||||
i++;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Removed " + i + " permissions");
|
||||
|
||||
/*int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
OfflinePlayer p = this.getOfflinePlayer(name);
|
||||
for (String group : permission.getPlayerGroups((Player) p)) {
|
||||
permission.playerRemoveGroup(null, p, group);
|
||||
}
|
||||
i++;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " Permissions");*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Method isOnline.
|
||||
*
|
||||
* @param player Player
|
||||
* @param name String
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isOnline(Player player, final String name) {
|
||||
if (player.isOnline())
|
||||
return true;
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
Future<Boolean> result = executor.submit(new Callable<Boolean>() {
|
||||
|
||||
@Override
|
||||
public synchronized Boolean call() throws Exception {
|
||||
for (OfflinePlayer op : Utils.getOnlinePlayers())
|
||||
if (op.getName().equalsIgnoreCase(name)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
try {
|
||||
return result.get();
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getOnlinePlayerLower.
|
||||
*
|
||||
* @param name String
|
||||
* @return Player
|
||||
*/
|
||||
public Player getOnlinePlayerLower(String name) {
|
||||
name = name.toLowerCase();
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
if (player.getName().equalsIgnoreCase(name))
|
||||
return player;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
package fr.xephi.authme;
|
||||
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class DataManager {
|
||||
|
||||
public final AuthMe plugin;
|
||||
|
||||
/**
|
||||
* Constructor for DataManager.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public DataManager(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getOfflinePlayer.
|
||||
*
|
||||
* @param name String
|
||||
*
|
||||
* @return OfflinePlayer
|
||||
*/
|
||||
public synchronized OfflinePlayer getOfflinePlayer(final String name) {
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
Future<OfflinePlayer> result = executor.submit(new Callable<OfflinePlayer>() {
|
||||
|
||||
public synchronized OfflinePlayer call() throws Exception {
|
||||
OfflinePlayer result = null;
|
||||
try {
|
||||
for (OfflinePlayer op : Bukkit.getOfflinePlayers())
|
||||
if (op.getName().equalsIgnoreCase(name)) {
|
||||
result = op;
|
||||
break;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
});
|
||||
try {
|
||||
return result.get();
|
||||
} catch (Exception e) {
|
||||
return (null);
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method purgeAntiXray.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
public synchronized void purgeAntiXray(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
|
||||
if (player == null)
|
||||
continue;
|
||||
String playerName = player.getName();
|
||||
File playerFile = new File("." + File.separator + "plugins" + File.separator + "AntiXRayData" + File.separator + "PlayerData" + File.separator + playerName);
|
||||
if (playerFile.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " AntiXRayData Files");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method purgeLimitedCreative.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
public synchronized void purgeLimitedCreative(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
org.bukkit.OfflinePlayer player = getOfflinePlayer(name);
|
||||
if (player == null)
|
||||
continue;
|
||||
String playerName = player.getName();
|
||||
File playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + ".yml");
|
||||
if (playerFile.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_creative.yml");
|
||||
if (playerFile.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
playerFile = new File("." + File.separator + "plugins" + File.separator + "LimitedCreative" + File.separator + "inventories" + File.separator + playerName + "_adventure.yml");
|
||||
if (playerFile.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " LimitedCreative Survival, Creative and Adventure files");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method purgeDat.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
public synchronized void purgeDat(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
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");
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
playerFile.delete();
|
||||
i++;
|
||||
} catch (Exception ignore) {
|
||||
File playerFile = new File(plugin.getServer().getWorldContainer() + File.separator + Settings.defaultWorld + File.separator + "players" + File.separator + player.getName() + ".dat");
|
||||
if (playerFile.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " .dat Files");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method purgeEssentials.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void purgeEssentials(List<String> cleared) {
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + plugin.getServer().getOfflinePlayer(name).getUniqueId() + ".yml");
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
playerFile.delete();
|
||||
i++;
|
||||
} catch (Exception e) {
|
||||
File playerFile = new File(plugin.ess.getDataFolder() + File.separator + "userdata" + File.separator + name + ".yml");
|
||||
if (playerFile.exists()) {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
playerFile.delete();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " EssentialsFiles");
|
||||
}
|
||||
|
||||
// TODO: What is this method for? Is it correct?
|
||||
|
||||
/**
|
||||
* @param cleared Cleared players.
|
||||
*/
|
||||
public synchronized void purgePermissions(List<String> cleared) {
|
||||
// Get the permissions manager, and make sure it's valid
|
||||
PermissionsManager permsMan = this.plugin.getPermissionsManager();
|
||||
if (permsMan == null)
|
||||
ConsoleLogger.showError("Unable to access permissions manager instance!");
|
||||
assert permsMan != null;
|
||||
|
||||
int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
permsMan.removeAllGroups(this.getOnlinePlayerLower(name.toLowerCase()));
|
||||
i++;
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Removed " + i + " permissions");
|
||||
|
||||
/*int i = 0;
|
||||
for (String name : cleared) {
|
||||
try {
|
||||
OfflinePlayer p = this.getOfflinePlayer(name);
|
||||
for (String group : permission.getPlayerGroups((Player) p)) {
|
||||
permission.playerRemoveGroup(null, p, group);
|
||||
}
|
||||
i++;
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
ConsoleLogger.info("AutoPurgeDatabase : Remove " + i + " Permissions");*/
|
||||
}
|
||||
|
||||
/**
|
||||
* Method isOnline.
|
||||
*
|
||||
* @param player Player
|
||||
* @param name String
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isOnline(Player player, final String name) {
|
||||
if (player.isOnline())
|
||||
return true;
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
Future<Boolean> result = executor.submit(new Callable<Boolean>() {
|
||||
|
||||
@Override
|
||||
public synchronized Boolean call() throws Exception {
|
||||
for (OfflinePlayer op : Utils.getOnlinePlayers())
|
||||
if (op.getName().equalsIgnoreCase(name)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
try {
|
||||
return result.get();
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
} finally {
|
||||
executor.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getOnlinePlayerLower.
|
||||
*
|
||||
* @param name String
|
||||
*
|
||||
* @return Player
|
||||
*/
|
||||
public Player getOnlinePlayerLower(String name) {
|
||||
name = name.toLowerCase();
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
if (player.getName().equalsIgnoreCase(name))
|
||||
return player;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +1,40 @@
|
||||
package fr.xephi.authme;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ImageGenerator {
|
||||
|
||||
private String pass;
|
||||
|
||||
/**
|
||||
* Constructor for ImageGenerator.
|
||||
*
|
||||
* @param pass String
|
||||
*/
|
||||
public ImageGenerator(String pass) {
|
||||
this.pass = pass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method generateImage.
|
||||
*
|
||||
* @return BufferedImage
|
||||
*/
|
||||
public BufferedImage generateImage() {
|
||||
BufferedImage image = new BufferedImage(200, 60, BufferedImage.TYPE_BYTE_INDEXED);
|
||||
Graphics2D graphics = image.createGraphics();
|
||||
graphics.setColor(Color.BLACK);
|
||||
graphics.fillRect(0, 0, 200, 40);
|
||||
GradientPaint gradientPaint = new GradientPaint(10, 5, Color.WHITE, 20, 10, Color.WHITE, true);
|
||||
graphics.setPaint(gradientPaint);
|
||||
Font font = new Font("Comic Sans MS", Font.BOLD, 30);
|
||||
graphics.setFont(font);
|
||||
graphics.drawString(pass, 5, 30);
|
||||
graphics.dispose();
|
||||
image.flush();
|
||||
return image;
|
||||
}
|
||||
}
|
||||
package fr.xephi.authme;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ImageGenerator {
|
||||
|
||||
private final String pass;
|
||||
|
||||
/**
|
||||
* Constructor for ImageGenerator.
|
||||
*
|
||||
* @param pass String
|
||||
*/
|
||||
public ImageGenerator(String pass) {
|
||||
this.pass = pass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method generateImage.
|
||||
*
|
||||
* @return BufferedImage
|
||||
*/
|
||||
public BufferedImage generateImage() {
|
||||
BufferedImage image = new BufferedImage(200, 60, BufferedImage.TYPE_BYTE_INDEXED);
|
||||
Graphics2D graphics = image.createGraphics();
|
||||
graphics.setColor(Color.BLACK);
|
||||
graphics.fillRect(0, 0, 200, 40);
|
||||
GradientPaint gradientPaint = new GradientPaint(10, 5, Color.WHITE, 20, 10, Color.WHITE, true);
|
||||
graphics.setPaint(gradientPaint);
|
||||
Font font = new Font("Comic Sans MS", Font.BOLD, 30);
|
||||
graphics.setFont(font);
|
||||
graphics.drawString(pass, 5, 30);
|
||||
graphics.dispose();
|
||||
image.flush();
|
||||
return image;
|
||||
}
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
|
||||
* List of commands (lower-case) to skip.
|
||||
*/
|
||||
private static final String[] COMMANDS_TO_SKIP = {"/login ", "/l ", "/reg ", "/changepassword ",
|
||||
"/unregister ", "/authme register ", "/authme changepassword ", "/authme reg ", "/authme cp ",
|
||||
"/register "};
|
||||
"/unregister ", "/authme register ", "/authme changepassword ", "/authme reg ", "/authme cp ",
|
||||
"/register "};
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -34,6 +34,7 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
|
||||
* data.
|
||||
*
|
||||
* @param message the Message object to verify
|
||||
*
|
||||
* @return the Result value
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param message the message to verify
|
||||
*
|
||||
* @return the Result value
|
||||
*/
|
||||
private static Result validateMessage(String message) {
|
||||
@ -57,7 +59,7 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
|
||||
|
||||
String lowerMessage = message.toLowerCase();
|
||||
if (lowerMessage.contains("issued server command:")
|
||||
&& StringUtils.containsAny(lowerMessage, COMMANDS_TO_SKIP)) {
|
||||
&& StringUtils.containsAny(lowerMessage, COMMANDS_TO_SKIP)) {
|
||||
return Result.DENY;
|
||||
}
|
||||
return Result.NEUTRAL;
|
||||
|
@ -14,13 +14,13 @@ import java.util.Date;
|
||||
*/
|
||||
public class PerformBackup {
|
||||
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH-mm");
|
||||
String dateString = format.format(new Date());
|
||||
private String dbName = Settings.getMySQLDatabase;
|
||||
private String dbUserName = Settings.getMySQLUsername;
|
||||
private String dbPassword = Settings.getMySQLPassword;
|
||||
private String tblname = Settings.getMySQLTablename;
|
||||
private String path = AuthMe.getInstance().getDataFolder() + File.separator + "backups" + File.separator + "backup" + dateString;
|
||||
final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH-mm");
|
||||
final String dateString = format.format(new Date());
|
||||
private final String dbName = Settings.getMySQLDatabase;
|
||||
private final String dbUserName = Settings.getMySQLUsername;
|
||||
private final String dbPassword = Settings.getMySQLPassword;
|
||||
private final String tblname = Settings.getMySQLTablename;
|
||||
private final String path = AuthMe.getInstance().getDataFolder() + File.separator + "backups" + File.separator + "backup" + dateString;
|
||||
private AuthMe instance;
|
||||
|
||||
/**
|
||||
@ -38,7 +38,7 @@ public class PerformBackup {
|
||||
* @param cause BackupCause The cause of the backup.
|
||||
*/
|
||||
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());
|
||||
}
|
||||
// Check whether a backup should be made at the specified point in time
|
||||
@ -128,6 +128,7 @@ public class PerformBackup {
|
||||
* Method FileBackup.
|
||||
*
|
||||
* @param backend String
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private boolean FileBackup(String backend) {
|
||||
@ -150,11 +151,12 @@ public class PerformBackup {
|
||||
* Method checkWindows.
|
||||
*
|
||||
* @param windowsPath String
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private boolean checkWindows(String windowsPath) {
|
||||
String isWin = System.getProperty("os.name").toLowerCase();
|
||||
if (isWin.indexOf("win") >= 0) {
|
||||
if (isWin.contains("win")) {
|
||||
if (new File(windowsPath + "\\bin\\mysqldump.exe").exists()) {
|
||||
return true;
|
||||
} else {
|
||||
@ -174,6 +176,7 @@ public class PerformBackup {
|
||||
*
|
||||
* @param src File
|
||||
* @param dst File
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
void copy(File src, File dst) throws IOException {
|
||||
|
@ -16,7 +16,7 @@ import java.io.File;
|
||||
*/
|
||||
public class SendMailSSL {
|
||||
|
||||
public AuthMe plugin;
|
||||
public final AuthMe plugin;
|
||||
|
||||
/**
|
||||
* Constructor for SendMailSSL.
|
||||
@ -34,15 +34,15 @@ public class SendMailSSL {
|
||||
* @param newPass String
|
||||
*/
|
||||
public void main(final PlayerAuth auth, final String newPass) {
|
||||
String sendername;
|
||||
String senderName;
|
||||
|
||||
if (Settings.getmailSenderName == null || Settings.getmailSenderName.isEmpty()) {
|
||||
sendername = Settings.getmailAccount;
|
||||
senderName = Settings.getmailAccount;
|
||||
} else {
|
||||
sendername = Settings.getmailSenderName;
|
||||
senderName = Settings.getmailSenderName;
|
||||
}
|
||||
|
||||
final String sender = sendername;
|
||||
final String sender = senderName;
|
||||
final int port = Settings.getMailPort;
|
||||
final String acc = Settings.getmailAccount;
|
||||
final String subject = Settings.getMailSubject;
|
||||
@ -90,6 +90,7 @@ public class SendMailSSL {
|
||||
ConsoleLogger.showError("Fail to send a mail to " + mail);
|
||||
}
|
||||
if (file != null)
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
file.delete();
|
||||
|
||||
} catch (Exception e) {
|
||||
|
@ -50,6 +50,7 @@ public class API {
|
||||
|
||||
/**
|
||||
* @param player
|
||||
*
|
||||
* @return true if player is authenticate
|
||||
*/
|
||||
@Deprecated
|
||||
@ -59,6 +60,7 @@ public class API {
|
||||
|
||||
/**
|
||||
* @param player
|
||||
*
|
||||
* @return true if the player is unrestricted
|
||||
*/
|
||||
@Deprecated
|
||||
@ -70,6 +72,7 @@ public class API {
|
||||
* Method getLastLocation.
|
||||
*
|
||||
* @param player Player
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
@Deprecated
|
||||
@ -102,12 +105,13 @@ public class API {
|
||||
try {
|
||||
player.getInventory().setContents(content);
|
||||
player.getInventory().setArmorContents(armor);
|
||||
} catch (NullPointerException npe) {
|
||||
} catch (NullPointerException ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param playerName
|
||||
*
|
||||
* @return true if player is registered
|
||||
*/
|
||||
@Deprecated
|
||||
@ -119,6 +123,7 @@ public class API {
|
||||
/**
|
||||
* @param playerName String
|
||||
* @param passwordToCheck String
|
||||
*
|
||||
* @return true if the password is correct , false else
|
||||
*/
|
||||
@Deprecated
|
||||
@ -140,6 +145,7 @@ public class API {
|
||||
*
|
||||
* @param playerName String
|
||||
* @param password String
|
||||
*
|
||||
* @return true if the player is register correctly
|
||||
*/
|
||||
@Deprecated
|
||||
@ -151,10 +157,7 @@ public class API {
|
||||
return false;
|
||||
}
|
||||
PlayerAuth auth = new PlayerAuth(name, hash, "198.18.0.1", 0, "your@email.com", playerName);
|
||||
if (!instance.database.saveAuth(auth)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return instance.database.saveAuth(auth);
|
||||
} catch (NoSuchAlgorithmException ex) {
|
||||
return false;
|
||||
}
|
||||
@ -182,6 +185,7 @@ public class API {
|
||||
|
||||
/**
|
||||
* @param player
|
||||
*
|
||||
* @return true if player is a npc
|
||||
*/
|
||||
@Deprecated
|
||||
@ -191,6 +195,7 @@ public class API {
|
||||
|
||||
/**
|
||||
* @param player
|
||||
*
|
||||
* @return true if player is a npc
|
||||
*/
|
||||
@Deprecated
|
||||
|
@ -19,7 +19,7 @@ import java.security.NoSuchAlgorithmException;
|
||||
public class NewAPI {
|
||||
|
||||
public static NewAPI singleton;
|
||||
public AuthMe plugin;
|
||||
public final AuthMe plugin;
|
||||
|
||||
/**
|
||||
* Constructor for NewAPI.
|
||||
@ -33,10 +33,10 @@ public class NewAPI {
|
||||
/**
|
||||
* Constructor for NewAPI.
|
||||
*
|
||||
* @param serv Server
|
||||
* @param server Server
|
||||
*/
|
||||
public NewAPI(Server serv) {
|
||||
this.plugin = (AuthMe) serv.getPluginManager().getPlugin("AuthMe");
|
||||
public NewAPI(Server server) {
|
||||
this.plugin = (AuthMe) server.getPluginManager().getPlugin("AuthMe");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -67,6 +67,7 @@ public class NewAPI {
|
||||
|
||||
/**
|
||||
* @param player
|
||||
*
|
||||
* @return true if player is authenticate
|
||||
*/
|
||||
public boolean isAuthenticated(Player player) {
|
||||
@ -75,6 +76,7 @@ public class NewAPI {
|
||||
|
||||
/**
|
||||
* @param player
|
||||
*
|
||||
* @return true if player is a npc
|
||||
*/
|
||||
public boolean isNPC(Player player) {
|
||||
@ -83,6 +85,7 @@ public class NewAPI {
|
||||
|
||||
/**
|
||||
* @param player
|
||||
*
|
||||
* @return true if the player is unrestricted
|
||||
*/
|
||||
public boolean isUnrestricted(Player player) {
|
||||
@ -93,6 +96,7 @@ public class NewAPI {
|
||||
* Method getLastLocation.
|
||||
*
|
||||
* @param player Player
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public Location getLastLocation(Player player) {
|
||||
@ -112,6 +116,7 @@ public class NewAPI {
|
||||
|
||||
/**
|
||||
* @param playerName
|
||||
*
|
||||
* @return true if player is registered
|
||||
*/
|
||||
public boolean isRegistered(String playerName) {
|
||||
@ -122,6 +127,7 @@ public class NewAPI {
|
||||
/**
|
||||
* @param playerName String
|
||||
* @param passwordToCheck String
|
||||
*
|
||||
* @return true if the password is correct , false else
|
||||
*/
|
||||
public boolean checkPassword(String playerName, String passwordToCheck) {
|
||||
@ -141,6 +147,7 @@ public class NewAPI {
|
||||
*
|
||||
* @param playerName String
|
||||
* @param password String
|
||||
*
|
||||
* @return true if the player is register correctly
|
||||
*/
|
||||
public boolean registerPlayer(String playerName, String password) {
|
||||
|
@ -16,7 +16,7 @@ public class PlayerAuth {
|
||||
private double z;
|
||||
private String world;
|
||||
private String salt;
|
||||
private int groupId;
|
||||
private final int groupId;
|
||||
private String email;
|
||||
private String realName;
|
||||
|
||||
@ -405,6 +405,7 @@ public class PlayerAuth {
|
||||
* Method equals.
|
||||
*
|
||||
* @param obj Object
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
@Override
|
||||
@ -437,12 +438,12 @@ public class PlayerAuth {
|
||||
@Override
|
||||
public String toString() {
|
||||
return ("Player : " + nickname + " | " + realName
|
||||
+ " ! IP : " + ip
|
||||
+ " ! LastLogin : " + lastLogin
|
||||
+ " ! LastPosition : " + x + "," + y + "," + z + "," + world
|
||||
+ " ! Email : " + email
|
||||
+ " ! Hash : " + hash
|
||||
+ " ! Salt : " + salt);
|
||||
+ " ! IP : " + ip
|
||||
+ " ! LastLogin : " + lastLogin
|
||||
+ " ! LastPosition : " + x + "," + y + "," + z + "," + world
|
||||
+ " ! Email : " + email
|
||||
+ " ! Hash : " + hash
|
||||
+ " ! Salt : " + salt);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class PlayerCache {
|
||||
|
||||
private volatile static PlayerCache singleton;
|
||||
private ConcurrentHashMap<String, PlayerAuth> cache;
|
||||
private final ConcurrentHashMap<String, PlayerAuth> cache;
|
||||
|
||||
private PlayerCache() {
|
||||
cache = new ConcurrentHashMap<>();
|
||||
@ -57,6 +57,7 @@ public class PlayerCache {
|
||||
* Method isAuthenticated.
|
||||
*
|
||||
* @param user String
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isAuthenticated(String user) {
|
||||
@ -67,6 +68,7 @@ public class PlayerCache {
|
||||
* Method getAuth.
|
||||
*
|
||||
* @param user String
|
||||
*
|
||||
* @return PlayerAuth
|
||||
*/
|
||||
public PlayerAuth getAuth(String user) {
|
||||
|
@ -4,9 +4,9 @@ package fr.xephi.authme.cache.backup;
|
||||
*/
|
||||
public class DataFileCache {
|
||||
|
||||
private String group;
|
||||
private boolean operator;
|
||||
private boolean flying;
|
||||
private final String group;
|
||||
private final boolean operator;
|
||||
private final boolean flying;
|
||||
|
||||
/**
|
||||
* Constructor for DataFileCache.
|
||||
|
@ -25,10 +25,10 @@ public class JsonCache {
|
||||
ConsoleLogger.showError("Failed to create cache directory.");
|
||||
}
|
||||
gson = new GsonBuilder()
|
||||
.registerTypeAdapter(DataFileCache.class, new PlayerDataSerializer())
|
||||
.registerTypeAdapter(DataFileCache.class, new PlayerDataDeserializer())
|
||||
.setPrettyPrinting()
|
||||
.create();
|
||||
.registerTypeAdapter(DataFileCache.class, new PlayerDataSerializer())
|
||||
.registerTypeAdapter(DataFileCache.class, new PlayerDataDeserializer())
|
||||
.setPrettyPrinting()
|
||||
.create();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -70,6 +70,7 @@ public class JsonCache {
|
||||
* Method readCache.
|
||||
*
|
||||
* @param player Player
|
||||
*
|
||||
* @return DataFileCache
|
||||
*/
|
||||
public DataFileCache readCache(Player player) {
|
||||
@ -119,6 +120,7 @@ public class JsonCache {
|
||||
* Method doesCacheExist.
|
||||
*
|
||||
* @param player Player
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean doesCacheExist(Player player) {
|
||||
@ -141,6 +143,7 @@ public class JsonCache {
|
||||
* @param jsonElement JsonElement
|
||||
* @param type Type
|
||||
* @param jsonDeserializationContext JsonDeserializationContext
|
||||
*
|
||||
* @return DataFileCache * @throws JsonParseException * @see com.google.gson.JsonDeserializer#deserialize(JsonElement, Type, JsonDeserializationContext)
|
||||
*/
|
||||
@Override
|
||||
@ -177,6 +180,7 @@ public class JsonCache {
|
||||
* @param dataFileCache DataFileCache
|
||||
* @param type Type
|
||||
* @param jsonSerializationContext JsonSerializationContext
|
||||
*
|
||||
* @return JsonElement
|
||||
*/
|
||||
@Override
|
||||
|
@ -19,9 +19,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
public class LimboCache {
|
||||
|
||||
private volatile static LimboCache singleton;
|
||||
public ConcurrentHashMap<String, LimboPlayer> cache;
|
||||
public AuthMe plugin;
|
||||
private JsonCache playerData;
|
||||
public final ConcurrentHashMap<String, LimboPlayer> cache;
|
||||
public final AuthMe plugin;
|
||||
private final JsonCache playerData;
|
||||
|
||||
/**
|
||||
* Constructor for LimboCache.
|
||||
@ -124,6 +124,7 @@ public class LimboCache {
|
||||
* Method getLimboPlayer.
|
||||
*
|
||||
* @param name String
|
||||
*
|
||||
* @return LimboPlayer
|
||||
*/
|
||||
public LimboPlayer getLimboPlayer(String name) {
|
||||
@ -134,6 +135,7 @@ public class LimboCache {
|
||||
* Method hasLimboPlayer.
|
||||
*
|
||||
* @param name String
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean hasLimboPlayer(String name) {
|
||||
|
@ -8,7 +8,7 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
*/
|
||||
public class LimboPlayer {
|
||||
|
||||
private String name;
|
||||
private final String name;
|
||||
private Location loc = null;
|
||||
private BukkitTask timeoutTaskId = null;
|
||||
private BukkitTask messageTaskId = null;
|
||||
|
@ -117,6 +117,7 @@ public class CommandDescription {
|
||||
* Check whether a label is valid to use.
|
||||
*
|
||||
* @param label The label to test.
|
||||
*
|
||||
* @return True if the label is valid to use, false otherwise.
|
||||
*/
|
||||
public static boolean isValidLabel(String label) {
|
||||
@ -140,6 +141,7 @@ public class CommandDescription {
|
||||
*
|
||||
* @param commandLabel The first command label.
|
||||
* @param otherCommandLabel The other command label.
|
||||
*
|
||||
* @return True if the labels are equal to each other.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
public String getLabel(CommandParts reference) {
|
||||
@ -236,6 +239,7 @@ public class CommandDescription {
|
||||
* @param commandLabel Command label to set.
|
||||
* @param overwrite True to replace all old command labels, false to append this command label to the currently
|
||||
* existing labels.
|
||||
*
|
||||
* @return Trie if the command label is added, or if it was added already. False on failure.
|
||||
*/
|
||||
public boolean setLabel(String commandLabel, boolean overwrite) {
|
||||
@ -252,6 +256,7 @@ public class CommandDescription {
|
||||
* Add a command label to the list.
|
||||
*
|
||||
* @param commandLabel Command label to add.
|
||||
*
|
||||
* @return True if the label was added, or if it was added already. False on error.
|
||||
*/
|
||||
public boolean addLabel(String commandLabel) {
|
||||
@ -271,6 +276,7 @@ public class CommandDescription {
|
||||
* Add a list of command labels.
|
||||
*
|
||||
* @param commandLabels List of command labels to add.
|
||||
*
|
||||
* @return True if succeed, false on failure.
|
||||
*/
|
||||
public boolean addLabels(List<String> commandLabels) {
|
||||
@ -285,6 +291,7 @@ public class CommandDescription {
|
||||
* Check whether this command description has a specific command.
|
||||
*
|
||||
* @param commandLabel Command to check for.
|
||||
*
|
||||
* @return True if this command label equals to the param command.
|
||||
*/
|
||||
public boolean hasLabel(String commandLabel) {
|
||||
@ -301,6 +308,7 @@ public class CommandDescription {
|
||||
* Check whether this command description has a list of labels
|
||||
*
|
||||
* @param commandLabels List of labels
|
||||
*
|
||||
* @return True if all labels match, false otherwise
|
||||
*/
|
||||
public boolean hasLabels(List<String> commandLabels) {
|
||||
@ -318,6 +326,7 @@ public class CommandDescription {
|
||||
* are suitable too.
|
||||
*
|
||||
* @param commandReference The command reference.
|
||||
*
|
||||
* @return True if the command reference is suitable to this command label, false otherwise.
|
||||
*/
|
||||
public boolean isSuitableLabel(CommandParts commandReference) {
|
||||
@ -345,6 +354,7 @@ public class CommandDescription {
|
||||
* Get the absolute command label.
|
||||
*
|
||||
* @param includeSlash boolean
|
||||
*
|
||||
* @return Absolute command label.
|
||||
*/
|
||||
public String getAbsoluteLabel(boolean includeSlash) {
|
||||
@ -356,6 +366,7 @@ public class CommandDescription {
|
||||
*
|
||||
* @param includeSlash boolean
|
||||
* @param reference CommandParts
|
||||
*
|
||||
* @return Absolute command label.
|
||||
*/
|
||||
public String getAbsoluteLabel(boolean includeSlash, CommandParts reference) {
|
||||
@ -372,6 +383,7 @@ public class CommandDescription {
|
||||
* Get the command reference.
|
||||
*
|
||||
* @param reference The reference to use as template, which is used to choose the most similar reference.
|
||||
*
|
||||
* @return Command reference.
|
||||
*/
|
||||
public CommandParts getCommandReference(CommandParts reference) {
|
||||
@ -393,6 +405,7 @@ public class CommandDescription {
|
||||
* Get the difference between this command and another command reference.
|
||||
*
|
||||
* @param other The other command reference.
|
||||
*
|
||||
* @return The command difference. Zero if there's no difference. A negative number on error.
|
||||
*/
|
||||
public double getCommandDifference(CommandParts other) {
|
||||
@ -404,6 +417,7 @@ public class CommandDescription {
|
||||
*
|
||||
* @param other The other command reference.
|
||||
* @param fullCompare True to fully compare both command references.
|
||||
*
|
||||
* @return The command difference. Zero if there's no difference. A negative number on error.
|
||||
*/
|
||||
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 commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
public boolean execute(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
@ -489,6 +504,7 @@ public class CommandDescription {
|
||||
* Set the parent command.
|
||||
*
|
||||
* @param parent Parent command.
|
||||
*
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
public boolean setParent(CommandDescription parent) {
|
||||
@ -543,6 +559,7 @@ public class CommandDescription {
|
||||
* Add a child to the command description.
|
||||
*
|
||||
* @param commandDescription The child to add.
|
||||
*
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
public boolean addChild(CommandDescription commandDescription) {
|
||||
@ -569,7 +586,7 @@ public class CommandDescription {
|
||||
*
|
||||
* @return True if this command has any child labels.
|
||||
*/
|
||||
public boolean hasChilds() {
|
||||
public boolean hasChildren() {
|
||||
return (this.children.size() != 0);
|
||||
}
|
||||
|
||||
@ -577,6 +594,7 @@ public class CommandDescription {
|
||||
* Check if this command description has a specific child.
|
||||
*
|
||||
* @param commandDescription The command description to check for.
|
||||
*
|
||||
* @return True if this command description has the specific child, false otherwise.
|
||||
*/
|
||||
public boolean isChild(CommandDescription commandDescription) {
|
||||
@ -594,6 +612,7 @@ public class CommandDescription {
|
||||
* Add an argument.
|
||||
*
|
||||
* @param argument The argument to add.
|
||||
*
|
||||
* @return True if succeed, false if failed.
|
||||
*/
|
||||
public boolean addArgument(CommandArgumentDescription argument) {
|
||||
@ -636,6 +655,7 @@ public class CommandDescription {
|
||||
* Check whether an argument exists.
|
||||
*
|
||||
* @param argument The argument to check for.
|
||||
*
|
||||
* @return True if this argument already exists, false otherwise.
|
||||
*/
|
||||
public boolean hasArgument(CommandArgumentDescription argument) {
|
||||
@ -771,6 +791,7 @@ public class CommandDescription {
|
||||
* Find the best suitable command for a query reference.
|
||||
*
|
||||
* @param queryReference The query reference to find a command for.
|
||||
*
|
||||
* @return The command found, or null.
|
||||
*/
|
||||
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
|
||||
if (queryReference.getCount() <= getParentCount() + 1)
|
||||
return new FoundCommandResult(
|
||||
this,
|
||||
getCommandReference(queryReference),
|
||||
new CommandParts(),
|
||||
queryReference);
|
||||
this,
|
||||
getCommandReference(queryReference),
|
||||
new CommandParts(),
|
||||
queryReference);
|
||||
|
||||
// Get the new command reference and arguments
|
||||
CommandParts newReference = new CommandParts(queryReference.getRange(0, getParentCount() + 1));
|
||||
@ -798,8 +819,8 @@ public class CommandDescription {
|
||||
@Override
|
||||
public int compare(CommandDescription o1, CommandDescription o2) {
|
||||
return Double.compare(
|
||||
o1.getCommandDifference(queryReference),
|
||||
o2.getCommandDifference(queryReference));
|
||||
o1.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.
|
||||
*
|
||||
* @param commandReference The command reference.
|
||||
*
|
||||
* @return True if so, false otherwise.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param commandReference The command reference.
|
||||
*
|
||||
* @return True if the arguments are suitable, false otherwise.
|
||||
*/
|
||||
public boolean hasSuitableArguments(CommandParts commandReference) {
|
||||
@ -853,6 +876,7 @@ public class CommandDescription {
|
||||
* and get the difference in argument count.
|
||||
*
|
||||
* @param commandReference The command reference.
|
||||
*
|
||||
* @return The difference in argument count between the reference and the actual command.
|
||||
*/
|
||||
public int getSuitableArgumentsDifference(CommandParts commandReference) {
|
||||
|
@ -89,6 +89,7 @@ public class CommandHandler {
|
||||
* @param bukkitCommand The command (Bukkit).
|
||||
* @param bukkitCommandLabel The command label (Bukkit).
|
||||
* @param bukkitArgs The command arguments (Bukkit).
|
||||
*
|
||||
* @return True if the command was executed, false otherwise.
|
||||
*/
|
||||
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
|
||||
sender.sendMessage(ChatColor.DARK_RED + "Unknown command, assuming " + ChatColor.GOLD + "/" + suggestedCommandParts +
|
||||
ChatColor.DARK_RED + "!");
|
||||
ChatColor.DARK_RED + "!");
|
||||
}
|
||||
|
||||
// Make sure the command is executable
|
||||
@ -181,6 +182,7 @@ public class CommandHandler {
|
||||
* Process the command arguments, and return them as an array list.
|
||||
*
|
||||
* @param args The command arguments to process.
|
||||
*
|
||||
* @return The processed command arguments.
|
||||
*/
|
||||
private List<String> processArguments(String[] args) {
|
||||
|
@ -20,7 +20,7 @@ public class CommandManager {
|
||||
/**
|
||||
* The list of commandDescriptions.
|
||||
*/
|
||||
private List<CommandDescription> commandDescriptions = new ArrayList<>();
|
||||
private final List<CommandDescription> commandDescriptions = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -575,6 +575,7 @@ public class CommandManager {
|
||||
* Find the best suitable command for the specified reference.
|
||||
*
|
||||
* @param queryReference The query reference to find a command for.
|
||||
*
|
||||
* @return The command found, or null.
|
||||
*/
|
||||
public FoundCommandResult findCommand(CommandParts queryReference) {
|
||||
|
@ -12,7 +12,7 @@ public class CommandParts {
|
||||
/**
|
||||
* The list of parts for this command.
|
||||
*/
|
||||
private List<String> parts = new ArrayList<>();
|
||||
private final List<String> parts = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -71,6 +71,7 @@ public class CommandParts {
|
||||
* Add a part.
|
||||
*
|
||||
* @param part The part to add.
|
||||
*
|
||||
* @return The result.
|
||||
*/
|
||||
public boolean add(String part) {
|
||||
@ -81,6 +82,7 @@ public class CommandParts {
|
||||
* Add some parts.
|
||||
*
|
||||
* @param parts The parts to add.
|
||||
*
|
||||
* @return The result.
|
||||
*/
|
||||
public boolean add(List<String> parts) {
|
||||
@ -91,6 +93,7 @@ public class CommandParts {
|
||||
* Add some parts.
|
||||
*
|
||||
* @param parts The parts to add.
|
||||
*
|
||||
* @return The result.
|
||||
*/
|
||||
public boolean add(String[] parts) {
|
||||
@ -112,6 +115,7 @@ public class CommandParts {
|
||||
* Get a part by it's index.
|
||||
*
|
||||
* @param i Part index.
|
||||
*
|
||||
* @return The part.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param start The starting index.
|
||||
*
|
||||
* @return The parts range. Arguments that were out of bound are not included.
|
||||
*/
|
||||
public List<String> getRange(int start) {
|
||||
@ -138,6 +143,7 @@ public class CommandParts {
|
||||
*
|
||||
* @param start The starting index.
|
||||
* @param count The number of parts to get.
|
||||
*
|
||||
* @return The parts range. Parts that were out of bound are not included.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param other The other reference.
|
||||
*
|
||||
* @return The result from zero to above. A negative number will be returned on error.
|
||||
*/
|
||||
public double getDifference(CommandParts other) {
|
||||
@ -171,6 +178,7 @@ public class CommandParts {
|
||||
*
|
||||
* @param other The other reference.
|
||||
* @param fullCompare True to compare the full references as far as the range reaches.
|
||||
*
|
||||
* @return The result from zero to above. A negative number will be returned on error.
|
||||
*/
|
||||
public double getDifference(CommandParts other, boolean fullCompare) {
|
||||
|
@ -55,6 +55,7 @@ public class CommandPermissions {
|
||||
* Add a permission node required to execute this command.
|
||||
*
|
||||
* @param permissionNode The permission node to add.
|
||||
*
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
public boolean addPermissionNode(String permissionNode) {
|
||||
@ -77,6 +78,7 @@ public class CommandPermissions {
|
||||
* Check whether this command requires a specified permission node to execute.
|
||||
*
|
||||
* @param permissionNode The permission node to check for.
|
||||
*
|
||||
* @return True if this permission node is required, false if not.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param sender CommandSender
|
||||
*
|
||||
* @return True if this command requires any permission to be executed by a player.
|
||||
*/
|
||||
public boolean hasPermission(CommandSender sender) {
|
||||
@ -165,6 +168,7 @@ public class CommandPermissions {
|
||||
* Get the default permission for a specified command sender.
|
||||
*
|
||||
* @param sender The command sender to get the default permission for.
|
||||
*
|
||||
* @return True if the command sender has permission by default, false otherwise.
|
||||
*/
|
||||
public boolean getDefaultPermissionCommandSender(CommandSender sender) {
|
||||
|
@ -13,6 +13,7 @@ public abstract class ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
public abstract boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments);
|
||||
|
@ -13,15 +13,15 @@ public class FoundCommandResult {
|
||||
/**
|
||||
* The command reference.
|
||||
*/
|
||||
private CommandParts commandReference;
|
||||
private final CommandParts commandReference;
|
||||
/**
|
||||
* The command arguments.
|
||||
*/
|
||||
private CommandParts commandArguments;
|
||||
private final CommandParts commandArguments;
|
||||
/**
|
||||
* The original search query reference.
|
||||
*/
|
||||
private CommandParts queryReference;
|
||||
private final CommandParts queryReference;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -88,6 +88,7 @@ public class FoundCommandResult {
|
||||
* Execute the command.
|
||||
*
|
||||
* @param sender The command sender that executed the command.
|
||||
*
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
public boolean executeCommand(CommandSender sender) {
|
||||
@ -103,6 +104,7 @@ public class FoundCommandResult {
|
||||
* Check whether a command sender has permission to execute the command.
|
||||
*
|
||||
* @param sender The command sender.
|
||||
*
|
||||
* @return True if the command sender has permission, false otherwise.
|
||||
*/
|
||||
public boolean hasPermission(CommandSender sender) {
|
||||
|
@ -17,6 +17,7 @@ public class GetEmailCommand extends ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
|
@ -20,6 +20,7 @@ public class PurgeBannedPlayersCommand extends ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
|
@ -20,6 +20,7 @@ public class PurgeCommand extends ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
|
@ -19,6 +19,7 @@ public class PurgeLastPositionCommand extends ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
|
@ -23,6 +23,7 @@ public class RegisterCommand extends ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
|
@ -21,6 +21,7 @@ public class ReloadCommand extends ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
|
@ -19,6 +19,7 @@ public class ResetNameCommand extends ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
|
@ -19,6 +19,7 @@ public class SetEmailCommand extends ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
|
@ -17,6 +17,7 @@ public class SetFirstSpawnCommand extends ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
|
@ -17,6 +17,7 @@ public class SetSpawnCommand extends ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
|
@ -17,6 +17,7 @@ public class SpawnCommand extends ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
|
@ -17,6 +17,7 @@ public class SwitchAntiBotCommand extends ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
|
@ -29,6 +29,7 @@ public class UnregisterCommand extends ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
|
@ -18,6 +18,7 @@ public class VersionCommand extends ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
@ -70,6 +71,7 @@ public class VersionCommand extends ExecutableCommand {
|
||||
* Check whether a player is online.
|
||||
*
|
||||
* @param minecraftName The Minecraft player name.
|
||||
*
|
||||
* @return True if the player is online, false otherwise.
|
||||
*/
|
||||
private boolean isPlayerOnline(String minecraftName) {
|
||||
|
@ -20,6 +20,7 @@ public class CaptchaCommand extends ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
|
@ -18,6 +18,7 @@ public class ConverterCommand extends ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
@ -89,7 +90,7 @@ public class ConverterCommand extends ExecutableCommand {
|
||||
vauth("vauth"),
|
||||
sqltoflat("sqltoflat");
|
||||
|
||||
String name;
|
||||
final String name;
|
||||
|
||||
/**
|
||||
* Constructor for ConvertType.
|
||||
@ -104,6 +105,7 @@ public class ConverterCommand extends ExecutableCommand {
|
||||
* Method fromName.
|
||||
*
|
||||
* @param name String
|
||||
*
|
||||
* @return ConvertType
|
||||
*/
|
||||
public static ConvertType fromName(String name) {
|
||||
|
@ -18,6 +18,7 @@ public class UnregisterCommand extends ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
|
@ -23,19 +23,20 @@ public final class HelpSyntaxHelper {
|
||||
* @param commandReference The reference of the command.
|
||||
* @param alternativeLabel The alternative label to use for this command syntax.
|
||||
* @param highlight True to highlight the important parts of this command.
|
||||
*
|
||||
* @return The command with proper syntax.
|
||||
*/
|
||||
public static String getCommandSyntax(CommandDescription commandDescription, CommandParts commandReference,
|
||||
String alternativeLabel, boolean highlight) {
|
||||
// Create a string builder with white color and prefixed slash
|
||||
StringBuilder sb = new StringBuilder()
|
||||
.append(ChatColor.WHITE)
|
||||
.append("/");
|
||||
.append(ChatColor.WHITE)
|
||||
.append("/");
|
||||
|
||||
// Get the help command reference, and the command label
|
||||
CommandParts helpCommandReference = commandDescription.getCommandReference(commandReference);
|
||||
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
|
||||
String commandLabel;
|
||||
@ -47,9 +48,9 @@ public final class HelpSyntaxHelper {
|
||||
|
||||
// Show the important bit of the command, highlight this part if required
|
||||
sb.append(parentCommand)
|
||||
.append(" ")
|
||||
.append(highlight ? ChatColor.YELLOW.toString() + ChatColor.BOLD : "")
|
||||
.append(commandLabel);
|
||||
.append(" ")
|
||||
.append(highlight ? ChatColor.YELLOW.toString() + ChatColor.BOLD : "")
|
||||
.append(commandLabel);
|
||||
|
||||
if (highlight) {
|
||||
sb.append(ChatColor.YELLOW);
|
||||
|
@ -18,9 +18,9 @@ import java.io.IOException;
|
||||
*/
|
||||
public class CrazyLoginConverter implements Converter {
|
||||
|
||||
public AuthMe instance;
|
||||
public DataSource database;
|
||||
public CommandSender sender;
|
||||
public final AuthMe instance;
|
||||
public final DataSource database;
|
||||
public final CommandSender sender;
|
||||
|
||||
/**
|
||||
* Constructor for CrazyLoginConverter.
|
||||
|
@ -14,7 +14,7 @@ import java.sql.*;
|
||||
*/
|
||||
public class FlatToSqlite implements Converter {
|
||||
|
||||
public CommandSender sender;
|
||||
public final CommandSender sender;
|
||||
private String tableName;
|
||||
private String columnName;
|
||||
private String columnPassword;
|
||||
@ -179,6 +179,7 @@ public class FlatToSqlite implements Converter {
|
||||
* Method saveAuth.
|
||||
*
|
||||
* @param s String
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private synchronized boolean saveAuth(String s) {
|
||||
|
@ -11,7 +11,7 @@ import fr.xephi.authme.settings.Settings;
|
||||
*/
|
||||
public class ForceFlatToSqlite implements Converter {
|
||||
|
||||
private DataSource data;
|
||||
private final DataSource data;
|
||||
|
||||
/**
|
||||
* Constructor for ForceFlatToSqlite.
|
||||
|
@ -23,9 +23,9 @@ import java.util.Map.Entry;
|
||||
*/
|
||||
public class RakamakConverter implements Converter {
|
||||
|
||||
public AuthMe instance;
|
||||
public DataSource database;
|
||||
public CommandSender sender;
|
||||
public final AuthMe instance;
|
||||
public final DataSource database;
|
||||
public final CommandSender sender;
|
||||
|
||||
/**
|
||||
* Constructor for RakamakConverter.
|
||||
|
@ -12,8 +12,8 @@ import java.io.File;
|
||||
*/
|
||||
public class RoyalAuthConverter implements Converter {
|
||||
|
||||
public AuthMe plugin;
|
||||
private DataSource data;
|
||||
public final AuthMe plugin;
|
||||
private final DataSource data;
|
||||
|
||||
/**
|
||||
* Constructor for RoyalAuthConverter.
|
||||
|
@ -14,9 +14,9 @@ import java.util.List;
|
||||
*/
|
||||
public class SqlToFlat implements Converter {
|
||||
|
||||
public AuthMe plugin;
|
||||
public DataSource database;
|
||||
public CommandSender sender;
|
||||
public final AuthMe plugin;
|
||||
public final DataSource database;
|
||||
public final CommandSender sender;
|
||||
|
||||
/**
|
||||
* Constructor for SqlToFlat.
|
||||
|
@ -9,9 +9,9 @@ import org.bukkit.command.CommandSender;
|
||||
*/
|
||||
public class vAuthConverter implements Converter {
|
||||
|
||||
public AuthMe plugin;
|
||||
public DataSource database;
|
||||
public CommandSender sender;
|
||||
public final AuthMe plugin;
|
||||
public final DataSource database;
|
||||
public final CommandSender sender;
|
||||
|
||||
/**
|
||||
* Constructor for vAuthConverter.
|
||||
|
@ -17,9 +17,9 @@ import java.util.UUID;
|
||||
*/
|
||||
public class vAuthFileReader {
|
||||
|
||||
public AuthMe plugin;
|
||||
public DataSource database;
|
||||
public CommandSender sender;
|
||||
public final AuthMe plugin;
|
||||
public final DataSource database;
|
||||
public final CommandSender sender;
|
||||
|
||||
/**
|
||||
* Constructor for vAuthFileReader.
|
||||
@ -38,7 +38,7 @@ public class vAuthFileReader {
|
||||
*
|
||||
* @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");
|
||||
Scanner scanner;
|
||||
try {
|
||||
@ -49,15 +49,15 @@ public class vAuthFileReader {
|
||||
String password = line.split(": ")[1];
|
||||
PlayerAuth auth;
|
||||
if (isUUIDinstance(password)) {
|
||||
String pname;
|
||||
String playerName;
|
||||
try {
|
||||
pname = Bukkit.getOfflinePlayer(UUID.fromString(name)).getName();
|
||||
playerName = Bukkit.getOfflinePlayer(UUID.fromString(name)).getName();
|
||||
} catch (Exception | NoSuchMethodError e) {
|
||||
pname = getName(UUID.fromString(name));
|
||||
playerName = getName(UUID.fromString(name));
|
||||
}
|
||||
if (pname == null)
|
||||
if (playerName == null)
|
||||
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 {
|
||||
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.
|
||||
*
|
||||
* @param s String
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private boolean isUUIDinstance(String s) {
|
||||
@ -85,6 +86,7 @@ public class vAuthFileReader {
|
||||
* Method getName.
|
||||
*
|
||||
* @param uuid UUID
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
private String getName(UUID uuid) {
|
||||
|
@ -7,8 +7,8 @@ import org.bukkit.command.CommandSender;
|
||||
*/
|
||||
public class xAuthConverter implements Converter {
|
||||
|
||||
public AuthMe plugin;
|
||||
public CommandSender sender;
|
||||
public final AuthMe plugin;
|
||||
public final CommandSender sender;
|
||||
|
||||
/**
|
||||
* Constructor for xAuthConverter.
|
||||
|
@ -20,9 +20,9 @@ import java.util.List;
|
||||
*/
|
||||
public class xAuthToFlat {
|
||||
|
||||
public AuthMe instance;
|
||||
public DataSource database;
|
||||
public CommandSender sender;
|
||||
public final AuthMe instance;
|
||||
public final DataSource database;
|
||||
public final CommandSender sender;
|
||||
|
||||
/**
|
||||
* Constructor for xAuthToFlat.
|
||||
@ -64,7 +64,7 @@ public class xAuthToFlat {
|
||||
database.saveAuth(auth);
|
||||
}
|
||||
}
|
||||
sender.sendMessage("[AuthMe] Successfull convert from xAuth database");
|
||||
sender.sendMessage("[AuthMe] Successfully convert from xAuth database");
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage("[AuthMe] An error has been thrown while import xAuth database, the import hadn't fail but can be not complete ");
|
||||
}
|
||||
@ -75,6 +75,7 @@ public class xAuthToFlat {
|
||||
* Method getIdPlayer.
|
||||
*
|
||||
* @param id int
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getIdPlayer(int id) {
|
||||
@ -129,6 +130,7 @@ public class xAuthToFlat {
|
||||
* Method getPassword.
|
||||
*
|
||||
* @param accountId int
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getPassword(int accountId) {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,210 +1,223 @@
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public interface DataSource {
|
||||
|
||||
/**
|
||||
* Method isAuthAvailable.
|
||||
*
|
||||
* @param user String
|
||||
* @return boolean
|
||||
*/
|
||||
boolean isAuthAvailable(String user);
|
||||
|
||||
/**
|
||||
* Method getAuth.
|
||||
*
|
||||
* @param user String
|
||||
* @return PlayerAuth
|
||||
*/
|
||||
PlayerAuth getAuth(String user);
|
||||
|
||||
/**
|
||||
* Method saveAuth.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
* @return boolean
|
||||
*/
|
||||
boolean saveAuth(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method updateSession.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
* @return boolean
|
||||
*/
|
||||
boolean updateSession(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method updatePassword.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
* @return boolean
|
||||
*/
|
||||
boolean updatePassword(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method purgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
* @return int
|
||||
*/
|
||||
int purgeDatabase(long until);
|
||||
|
||||
/**
|
||||
* Method autoPurgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
* @return List<String>
|
||||
*/
|
||||
List<String> autoPurgeDatabase(long until);
|
||||
|
||||
/**
|
||||
* Method removeAuth.
|
||||
*
|
||||
* @param user String
|
||||
* @return boolean
|
||||
*/
|
||||
boolean removeAuth(String user);
|
||||
|
||||
/**
|
||||
* Method updateQuitLoc.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
* @return boolean
|
||||
*/
|
||||
boolean updateQuitLoc(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method getIps.
|
||||
*
|
||||
* @param ip String
|
||||
* @return int
|
||||
*/
|
||||
int getIps(String ip);
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByName.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
* @return List<String>
|
||||
*/
|
||||
List<String> getAllAuthsByName(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByIp.
|
||||
*
|
||||
* @param ip String
|
||||
* @return List<String> * @throws Exception
|
||||
*/
|
||||
List<String> getAllAuthsByIp(String ip) throws Exception;
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByEmail.
|
||||
*
|
||||
* @param email String
|
||||
* @return List<String> * @throws Exception
|
||||
*/
|
||||
List<String> getAllAuthsByEmail(String email) throws Exception;
|
||||
|
||||
/**
|
||||
* Method updateEmail.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
* @return boolean
|
||||
*/
|
||||
boolean updateEmail(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method updateSalt.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
* @return boolean
|
||||
*/
|
||||
boolean updateSalt(PlayerAuth auth);
|
||||
|
||||
void close();
|
||||
|
||||
void reload();
|
||||
|
||||
/**
|
||||
* Method purgeBanned.
|
||||
*
|
||||
* @param banned List<String>
|
||||
*/
|
||||
void purgeBanned(List<String> banned);
|
||||
|
||||
/**
|
||||
* Method getType.
|
||||
*
|
||||
* @return DataSourceType
|
||||
*/
|
||||
DataSourceType getType();
|
||||
|
||||
/**
|
||||
* Method isLogged.
|
||||
*
|
||||
* @param user String
|
||||
* @return boolean
|
||||
*/
|
||||
boolean isLogged(String user);
|
||||
|
||||
/**
|
||||
* Method setLogged.
|
||||
*
|
||||
* @param user String
|
||||
*/
|
||||
void setLogged(String user);
|
||||
|
||||
/**
|
||||
* Method setUnlogged.
|
||||
*
|
||||
* @param user String
|
||||
*/
|
||||
void setUnlogged(String user);
|
||||
|
||||
void purgeLogged();
|
||||
|
||||
/**
|
||||
* Method getAccountsRegistered.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int getAccountsRegistered();
|
||||
|
||||
/**
|
||||
* Method updateName.
|
||||
*
|
||||
* @param oldone String
|
||||
* @param newone String
|
||||
*/
|
||||
void updateName(String oldone, String newone);
|
||||
|
||||
/**
|
||||
* Method getAllAuths.
|
||||
*
|
||||
* @return List<PlayerAuth>
|
||||
*/
|
||||
List<PlayerAuth> getAllAuths();
|
||||
|
||||
/**
|
||||
* Method getLoggedPlayers.
|
||||
*
|
||||
* @return List<PlayerAuth>
|
||||
*/
|
||||
List<PlayerAuth> getLoggedPlayers();
|
||||
|
||||
/**
|
||||
*/
|
||||
enum DataSourceType {
|
||||
MYSQL,
|
||||
FILE,
|
||||
SQLITE
|
||||
}
|
||||
|
||||
}
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public interface DataSource {
|
||||
|
||||
/**
|
||||
* Method isAuthAvailable.
|
||||
*
|
||||
* @param user String
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean isAuthAvailable(String user);
|
||||
|
||||
/**
|
||||
* Method getAuth.
|
||||
*
|
||||
* @param user String
|
||||
*
|
||||
* @return PlayerAuth
|
||||
*/
|
||||
PlayerAuth getAuth(String user);
|
||||
|
||||
/**
|
||||
* Method saveAuth.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean saveAuth(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method updateSession.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean updateSession(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method updatePassword.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean updatePassword(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method purgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int purgeDatabase(long until);
|
||||
|
||||
/**
|
||||
* Method autoPurgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
*
|
||||
* @return List<String>
|
||||
*/
|
||||
List<String> autoPurgeDatabase(long until);
|
||||
|
||||
/**
|
||||
* Method removeAuth.
|
||||
*
|
||||
* @param user String
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean removeAuth(String user);
|
||||
|
||||
/**
|
||||
* Method updateQuitLoc.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean updateQuitLoc(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method getIps.
|
||||
*
|
||||
* @param ip String
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int getIps(String ip);
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByName.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
*
|
||||
* @return List<String>
|
||||
*/
|
||||
List<String> getAllAuthsByName(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByIp.
|
||||
*
|
||||
* @param ip String
|
||||
*
|
||||
* @return List<String> * @throws Exception
|
||||
*/
|
||||
List<String> getAllAuthsByIp(String ip) throws Exception;
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByEmail.
|
||||
*
|
||||
* @param email String
|
||||
*
|
||||
* @return List<String> * @throws Exception
|
||||
*/
|
||||
List<String> getAllAuthsByEmail(String email) throws Exception;
|
||||
|
||||
/**
|
||||
* Method updateEmail.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean updateEmail(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method updateSalt.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean updateSalt(PlayerAuth auth);
|
||||
|
||||
void close();
|
||||
|
||||
void reload();
|
||||
|
||||
/**
|
||||
* Method purgeBanned.
|
||||
*
|
||||
* @param banned List<String>
|
||||
*/
|
||||
void purgeBanned(List<String> banned);
|
||||
|
||||
/**
|
||||
* Method getType.
|
||||
*
|
||||
* @return DataSourceType
|
||||
*/
|
||||
DataSourceType getType();
|
||||
|
||||
/**
|
||||
* Method isLogged.
|
||||
*
|
||||
* @param user String
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
boolean isLogged(String user);
|
||||
|
||||
/**
|
||||
* Method setLogged.
|
||||
*
|
||||
* @param user String
|
||||
*/
|
||||
void setLogged(String user);
|
||||
|
||||
/**
|
||||
* Method setUnlogged.
|
||||
*
|
||||
* @param user String
|
||||
*/
|
||||
void setUnlogged(String user);
|
||||
|
||||
void purgeLogged();
|
||||
|
||||
/**
|
||||
* Method getAccountsRegistered.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
int getAccountsRegistered();
|
||||
|
||||
/**
|
||||
* Method updateName.
|
||||
*
|
||||
* @param oldOne String
|
||||
* @param newOne String
|
||||
*/
|
||||
void updateName(String oldOne, String newOne);
|
||||
|
||||
/**
|
||||
* Method getAllAuths.
|
||||
*
|
||||
* @return List<PlayerAuth>
|
||||
*/
|
||||
List<PlayerAuth> getAllAuths();
|
||||
|
||||
/**
|
||||
* Method getLoggedPlayers.
|
||||
*
|
||||
* @return List<PlayerAuth>
|
||||
*/
|
||||
List<PlayerAuth> getLoggedPlayers();
|
||||
|
||||
enum DataSourceType {
|
||||
MYSQL,
|
||||
FILE,
|
||||
SQLITE
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,7 @@ public class FlatFile implements DataSource {
|
||||
* :LASTPOSZ:LASTPOSWORLD PLAYERNAME:HASHSUM:IP:LOGININMILLIESECONDS
|
||||
* PLAYERNAME:HASHSUM:IP PLAYERNAME:HASHSUM
|
||||
*/
|
||||
private File source;
|
||||
private final File source;
|
||||
|
||||
public FlatFile() {
|
||||
source = Settings.AUTH_FILE;
|
||||
@ -48,6 +48,7 @@ public class FlatFile implements DataSource {
|
||||
* Method isAuthAvailable.
|
||||
*
|
||||
* @param user String
|
||||
*
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
|
||||
*/
|
||||
@Override
|
||||
@ -72,7 +73,7 @@ public class FlatFile implements DataSource {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -83,6 +84,7 @@ public class FlatFile implements DataSource {
|
||||
* Method saveAuth.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
*
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
@ -101,7 +103,7 @@ public class FlatFile implements DataSource {
|
||||
if (bw != null) {
|
||||
try {
|
||||
bw.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -112,6 +114,7 @@ public class FlatFile implements DataSource {
|
||||
* Method updatePassword.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
*
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
@ -162,7 +165,7 @@ public class FlatFile implements DataSource {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -177,6 +180,7 @@ public class FlatFile implements DataSource {
|
||||
* Method updateSession.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
*
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
@ -227,7 +231,7 @@ public class FlatFile implements DataSource {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -242,6 +246,7 @@ public class FlatFile implements DataSource {
|
||||
* Method updateQuitLoc.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
*
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
@ -271,7 +276,7 @@ public class FlatFile implements DataSource {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -286,6 +291,7 @@ public class FlatFile implements DataSource {
|
||||
* Method getIps.
|
||||
*
|
||||
* @param ip String
|
||||
*
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String)
|
||||
*/
|
||||
@Override
|
||||
@ -312,7 +318,7 @@ public class FlatFile implements DataSource {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -322,6 +328,7 @@ public class FlatFile implements DataSource {
|
||||
* Method purgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
*
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
@ -357,13 +364,13 @@ public class FlatFile implements DataSource {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
if (bw != null) {
|
||||
try {
|
||||
bw.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -374,6 +381,7 @@ public class FlatFile implements DataSource {
|
||||
* Method autoPurgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
*
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
@ -409,13 +417,13 @@ public class FlatFile implements DataSource {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
if (bw != null) {
|
||||
try {
|
||||
bw.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -426,6 +434,7 @@ public class FlatFile implements DataSource {
|
||||
* Method removeAuth.
|
||||
*
|
||||
* @param user String
|
||||
*
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
|
||||
*/
|
||||
@Override
|
||||
@ -459,13 +468,13 @@ public class FlatFile implements DataSource {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
if (bw != null) {
|
||||
try {
|
||||
bw.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -476,6 +485,7 @@ public class FlatFile implements DataSource {
|
||||
* Method getAuth.
|
||||
*
|
||||
* @param user String
|
||||
*
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String)
|
||||
*/
|
||||
@Override
|
||||
@ -513,7 +523,7 @@ public class FlatFile implements DataSource {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -542,6 +552,7 @@ public class FlatFile implements DataSource {
|
||||
* Method updateEmail.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
*
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
@ -571,7 +582,7 @@ public class FlatFile implements DataSource {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -586,6 +597,7 @@ public class FlatFile implements DataSource {
|
||||
* Method updateSalt.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
*
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
@ -597,6 +609,7 @@ public class FlatFile implements DataSource {
|
||||
* Method getAllAuthsByName.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
*
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
@ -623,7 +636,7 @@ public class FlatFile implements DataSource {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -633,6 +646,7 @@ public class FlatFile implements DataSource {
|
||||
* Method getAllAuthsByIp.
|
||||
*
|
||||
* @param ip String
|
||||
*
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
|
||||
*/
|
||||
@Override
|
||||
@ -659,7 +673,7 @@ public class FlatFile implements DataSource {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -669,6 +683,7 @@ public class FlatFile implements DataSource {
|
||||
* Method getAllAuthsByEmail.
|
||||
*
|
||||
* @param email String
|
||||
*
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
|
||||
*/
|
||||
@Override
|
||||
@ -695,7 +710,7 @@ public class FlatFile implements DataSource {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -705,6 +720,7 @@ public class FlatFile implements DataSource {
|
||||
* Method purgeBanned.
|
||||
*
|
||||
* @param banned List<String>
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
|
||||
*/
|
||||
@Override
|
||||
@ -721,34 +737,31 @@ public class FlatFile implements DataSource {
|
||||
if (banned.contains(args[0])) {
|
||||
lines.add(line);
|
||||
}
|
||||
} catch (NullPointerException | ArrayIndexOutOfBoundsException exc) {
|
||||
} catch (NullPointerException | ArrayIndexOutOfBoundsException ignored) {
|
||||
}
|
||||
}
|
||||
bw = new BufferedWriter(new FileWriter(source));
|
||||
for (String l : lines) {
|
||||
bw.write(l + "\n");
|
||||
}
|
||||
} catch (FileNotFoundException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
|
||||
} catch (IOException ex) {
|
||||
ConsoleLogger.showError(ex.getMessage());
|
||||
return;
|
||||
|
||||
} finally {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
if (bw != null) {
|
||||
try {
|
||||
bw.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -765,6 +778,7 @@ public class FlatFile implements DataSource {
|
||||
* Method isLogged.
|
||||
*
|
||||
* @param user String
|
||||
*
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String)
|
||||
*/
|
||||
@Override
|
||||
@ -776,6 +790,7 @@ public class FlatFile implements DataSource {
|
||||
* Method setLogged.
|
||||
*
|
||||
* @param user String
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
|
||||
*/
|
||||
@Override
|
||||
@ -786,6 +801,7 @@ public class FlatFile implements DataSource {
|
||||
* Method setUnlogged.
|
||||
*
|
||||
* @param user String
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
|
||||
*/
|
||||
@Override
|
||||
@ -822,7 +838,7 @@ public class FlatFile implements DataSource {
|
||||
if (br != null) {
|
||||
try {
|
||||
br.close();
|
||||
} catch (IOException ex) {
|
||||
} catch (IOException ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -832,16 +848,17 @@ public class FlatFile implements DataSource {
|
||||
/**
|
||||
* Method updateName.
|
||||
*
|
||||
* @param oldone String
|
||||
* @param newone String
|
||||
* @param oldOne String
|
||||
* @param newOne String
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
|
||||
*/
|
||||
@Override
|
||||
public void updateName(String oldone, String newone) {
|
||||
PlayerAuth auth = this.getAuth(oldone);
|
||||
auth.setName(newone);
|
||||
public void updateName(String oldOne, String newOne) {
|
||||
PlayerAuth auth = this.getAuth(oldOne);
|
||||
auth.setName(newOne);
|
||||
this.saveAuth(auth);
|
||||
this.removeAuth(oldone);
|
||||
this.removeAuth(oldOne);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -889,7 +906,7 @@ public class FlatFile implements DataSource {
|
||||
if (br != null) {
|
||||
try {
|
||||
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
@ -13,7 +13,7 @@ import org.bukkit.event.HandlerList;
|
||||
public class AuthMeAsyncPreLoginEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Player player;
|
||||
private final Player player;
|
||||
private boolean canLogin = true;
|
||||
|
||||
/**
|
||||
|
@ -11,9 +11,9 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public class AuthMeTeleportEvent extends CustomEvent {
|
||||
|
||||
private Player player;
|
||||
private final Player player;
|
||||
private Location to;
|
||||
private Location from;
|
||||
private final Location from;
|
||||
|
||||
/**
|
||||
* Constructor for AuthMeTeleportEvent.
|
||||
|
@ -57,6 +57,7 @@ public class CustomEvent extends Event implements Cancellable {
|
||||
* Method setCancelled.
|
||||
*
|
||||
* @param cancelled boolean
|
||||
*
|
||||
* @see org.bukkit.event.Cancellable#setCancelled(boolean)
|
||||
*/
|
||||
public void setCancelled(boolean cancelled) {
|
||||
|
@ -11,9 +11,9 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public class FirstSpawnTeleportEvent extends CustomEvent {
|
||||
|
||||
private Player player;
|
||||
private final Player player;
|
||||
private Location to;
|
||||
private Location from;
|
||||
private final Location from;
|
||||
|
||||
/**
|
||||
* Constructor for FirstSpawnTeleportEvent.
|
||||
|
@ -12,11 +12,11 @@ import org.bukkit.inventory.ItemStack;
|
||||
*/
|
||||
public class ProtectInventoryEvent extends CustomEvent {
|
||||
|
||||
private ItemStack[] storedinventory;
|
||||
private ItemStack[] storedarmor;
|
||||
private final ItemStack[] storedinventory;
|
||||
private final ItemStack[] storedarmor;
|
||||
private ItemStack[] emptyInventory = null;
|
||||
private ItemStack[] emptyArmor = null;
|
||||
private Player player;
|
||||
private final Player player;
|
||||
|
||||
/**
|
||||
* Constructor for ProtectInventoryEvent.
|
||||
|
@ -12,9 +12,9 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public class RegisterTeleportEvent extends CustomEvent {
|
||||
|
||||
private Player player;
|
||||
private final Player player;
|
||||
private Location to;
|
||||
private Location from;
|
||||
private final Location from;
|
||||
|
||||
/**
|
||||
* Constructor for RegisterTeleportEvent.
|
||||
|
@ -11,10 +11,10 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public class SpawnTeleportEvent extends CustomEvent {
|
||||
|
||||
private Player player;
|
||||
private final Player player;
|
||||
private Location to;
|
||||
private Location from;
|
||||
private boolean isAuthenticated;
|
||||
private final Location from;
|
||||
private final boolean isAuthenticated;
|
||||
|
||||
/**
|
||||
* Constructor for SpawnTeleportEvent.
|
||||
|
@ -10,7 +10,7 @@ import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
*/
|
||||
public class BungeeCordMessage implements PluginMessageListener {
|
||||
|
||||
public AuthMe plugin;
|
||||
public final AuthMe plugin;
|
||||
|
||||
/**
|
||||
* Constructor for BungeeCordMessage.
|
||||
@ -27,6 +27,7 @@ public class BungeeCordMessage implements PluginMessageListener {
|
||||
* @param channel String
|
||||
* @param player Player
|
||||
* @param message byte[]
|
||||
*
|
||||
* @see org.bukkit.plugin.messaging.PluginMessageListener#onPluginMessageReceived(String, Player, byte[])
|
||||
*/
|
||||
@Override
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
||||
*/
|
||||
public class AuthMeBlockListener implements Listener {
|
||||
|
||||
public AuthMe instance;
|
||||
public final AuthMe instance;
|
||||
|
||||
/**
|
||||
* Constructor for AuthMeBlockListener.
|
||||
|
@ -20,7 +20,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
|
||||
private static Method getShooter;
|
||||
private static boolean shooterIsProjectileSource;
|
||||
public AuthMe instance;
|
||||
public final AuthMe instance;
|
||||
|
||||
/**
|
||||
* Constructor for AuthMeEntityListener.
|
||||
|
@ -57,6 +57,7 @@ public class AuthMeInventoryPacketAdapter extends PacketAdapter {
|
||||
* Method onPacketSending.
|
||||
*
|
||||
* @param packetEvent PacketEvent
|
||||
*
|
||||
* @see com.comphenix.protocol.events.PacketListener#onPacketSending(PacketEvent)
|
||||
*/
|
||||
@Override
|
||||
@ -66,7 +67,7 @@ public class AuthMeInventoryPacketAdapter extends PacketAdapter {
|
||||
|
||||
byte windowId = packet.getIntegers().read(0).byteValue();
|
||||
if (windowId == PLAYER_INVENTORY && Settings.protectInventoryBeforeLogInEnabled
|
||||
&& !PlayerCache.getInstance().isAuthenticated(player.getName())) {
|
||||
&& !PlayerCache.getInstance().isAuthenticated(player.getName())) {
|
||||
packetEvent.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -108,9 +109,9 @@ public class AuthMeInventoryPacketAdapter extends PacketAdapter {
|
||||
|
||||
//storedInventory and hotbar
|
||||
System.arraycopy(storedInventory, 0, completeInventory
|
||||
, playerCrafting.length + armorContents.length, storedInventory.length);
|
||||
, playerCrafting.length + armorContents.length, storedInventory.length);
|
||||
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);
|
||||
try {
|
||||
|
@ -37,12 +37,12 @@ import java.util.regex.PatternSyntaxException;
|
||||
*/
|
||||
public class AuthMePlayerListener implements Listener {
|
||||
|
||||
public static ConcurrentHashMap<String, GameMode> gameMode = new ConcurrentHashMap<>();
|
||||
public static ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>();
|
||||
public static ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
|
||||
public AuthMe plugin;
|
||||
private Messages m = Messages.getInstance();
|
||||
private List<String> antibot = new ArrayList<>();
|
||||
public static final ConcurrentHashMap<String, GameMode> gameMode = new ConcurrentHashMap<>();
|
||||
public static final ConcurrentHashMap<String, String> joinMessage = new ConcurrentHashMap<>();
|
||||
public static final ConcurrentHashMap<String, Boolean> causeByAuthMe = new ConcurrentHashMap<>();
|
||||
public final AuthMe plugin;
|
||||
private final Messages m = Messages.getInstance();
|
||||
private final List<String> antibot = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Constructor for AuthMePlayerListener.
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.event.player.PlayerEditBookEvent;
|
||||
*/
|
||||
public class AuthMePlayerListener16 implements Listener {
|
||||
|
||||
public AuthMe plugin;
|
||||
public final AuthMe plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AuthMePlayerListener16.
|
||||
|
@ -12,7 +12,7 @@ import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
*/
|
||||
public class AuthMePlayerListener18 implements Listener {
|
||||
|
||||
public AuthMe plugin;
|
||||
public final AuthMe plugin;
|
||||
|
||||
/**
|
||||
* Constructor for AuthMePlayerListener18.
|
||||
|
@ -17,8 +17,8 @@ import org.bukkit.plugin.Plugin;
|
||||
*/
|
||||
public class AuthMeServerListener implements Listener {
|
||||
|
||||
public AuthMe plugin;
|
||||
private Messages m = Messages.getInstance();
|
||||
public final AuthMe plugin;
|
||||
private final Messages m = Messages.getInstance();
|
||||
|
||||
/**
|
||||
* Constructor for AuthMeServerListener.
|
||||
|
@ -19,7 +19,7 @@ import java.util.jar.JarFile;
|
||||
*/
|
||||
public class ModuleManager {
|
||||
|
||||
private List<Module> modules = new ArrayList<>();
|
||||
private final List<Module> modules = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Constructor for ModuleManager.
|
||||
@ -33,6 +33,7 @@ public class ModuleManager {
|
||||
* Method isModuleEnabled.
|
||||
*
|
||||
* @param name String
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isModuleEnabled(String name) {
|
||||
@ -47,6 +48,7 @@ public class ModuleManager {
|
||||
* Method isModuleEnabled.
|
||||
*
|
||||
* @param type Module.ModuleType
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isModuleEnabled(Module.ModuleType type) {
|
||||
@ -61,6 +63,7 @@ public class ModuleManager {
|
||||
* Method getModule.
|
||||
*
|
||||
* @param name String
|
||||
*
|
||||
* @return Module
|
||||
*/
|
||||
public Module getModule(String name) {
|
||||
@ -75,6 +78,7 @@ public class ModuleManager {
|
||||
* Method getModule.
|
||||
*
|
||||
* @param type Module.ModuleType
|
||||
*
|
||||
* @return Module
|
||||
*/
|
||||
public Module getModule(Module.ModuleType type) {
|
||||
|
@ -29,10 +29,10 @@ import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* PermissionsManager.
|
||||
* <p>
|
||||
* <p/>
|
||||
* A permissions manager, to manage and use various permissions systems.
|
||||
* This manager supports dynamic plugin hooking and various other features.
|
||||
* <p>
|
||||
* <p/>
|
||||
* Written by Tim Visée.
|
||||
*
|
||||
* @author Tim Visée, http://timvisee.com
|
||||
@ -47,11 +47,11 @@ public class PermissionsManager {
|
||||
/**
|
||||
* Server instance.
|
||||
*/
|
||||
private Server server;
|
||||
private final Server server;
|
||||
/**
|
||||
* Plugin instance.
|
||||
*/
|
||||
private Plugin plugin;
|
||||
private final Plugin plugin;
|
||||
/**
|
||||
* Logger instance.
|
||||
*/
|
||||
@ -267,9 +267,9 @@ public class PermissionsManager {
|
||||
|
||||
// Check if any known permissions system is enabling
|
||||
if (pluginName.equals("PermissionsEx") || pluginName.equals("PermissionsBukkit") ||
|
||||
pluginName.equals("bPermissions") || pluginName.equals("GroupManager") ||
|
||||
pluginName.equals("zPermissions") || pluginName.equals("Vault") ||
|
||||
pluginName.equals("Permissions")) {
|
||||
pluginName.equals("bPermissions") || pluginName.equals("GroupManager") ||
|
||||
pluginName.equals("zPermissions") || pluginName.equals("Vault") ||
|
||||
pluginName.equals("Permissions")) {
|
||||
this.log.info(pluginName + " plugin enabled, dynamically updating permissions hooks!");
|
||||
setup();
|
||||
}
|
||||
@ -287,9 +287,9 @@ public class PermissionsManager {
|
||||
|
||||
// Is the WorldGuard plugin disabled
|
||||
if (pluginName.equals("PermissionsEx") || pluginName.equals("PermissionsBukkit") ||
|
||||
pluginName.equals("bPermissions") || pluginName.equals("GroupManager") ||
|
||||
pluginName.equals("zPermissions") || pluginName.equals("Vault") ||
|
||||
pluginName.equals("Permissions")) {
|
||||
pluginName.equals("bPermissions") || pluginName.equals("GroupManager") ||
|
||||
pluginName.equals("zPermissions") || pluginName.equals("Vault") ||
|
||||
pluginName.equals("Permissions")) {
|
||||
this.log.info(pluginName + " plugin disabled, updating hooks!");
|
||||
setup();
|
||||
}
|
||||
@ -318,6 +318,7 @@ public class PermissionsManager {
|
||||
*
|
||||
* @param player The player.
|
||||
* @param permsNode Permissions node.
|
||||
*
|
||||
* @return True if the player has permission.
|
||||
*/
|
||||
public boolean hasPermission(Player player, String permsNode) {
|
||||
@ -330,6 +331,7 @@ public class PermissionsManager {
|
||||
* @param player The player.
|
||||
* @param permsNode The permission node.
|
||||
* @param def Default returned if no permissions system is used.
|
||||
*
|
||||
* @return True if the player has permission.
|
||||
*/
|
||||
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.
|
||||
*
|
||||
* @param player The player.
|
||||
*
|
||||
* @return Permission groups, or an empty list if this feature is not supported.
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "rawtypes", "deprecation"})
|
||||
@ -489,6 +492,7 @@ public class PermissionsManager {
|
||||
* Get the primary group of a player, if available.
|
||||
*
|
||||
* @param player The player.
|
||||
*
|
||||
* @return The name of the primary permission group. Or null.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -542,6 +546,7 @@ public class PermissionsManager {
|
||||
*
|
||||
* @param player The player.
|
||||
* @param groupName The group name.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
@ -599,6 +604,7 @@ public class PermissionsManager {
|
||||
*
|
||||
* @param player The player
|
||||
* @param groupName The name of the group.
|
||||
*
|
||||
* @return True if succeed, false otherwise.
|
||||
* 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 groupNames The name of the groups to add.
|
||||
*
|
||||
* @return True if succeed, false otherwise.
|
||||
* 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 groupName The name of the group.
|
||||
*
|
||||
* @return True if succeed, false otherwise.
|
||||
* 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 groupNames The name of the groups to add.
|
||||
*
|
||||
* @return True if succeed, false otherwise.
|
||||
* 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 groupName The name of the group.
|
||||
*
|
||||
* @return True if succeed, false otherwise.
|
||||
* 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 groupNames The name of the groups to set.
|
||||
*
|
||||
* @return True if succeed, false otherwise.
|
||||
* 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.
|
||||
*
|
||||
* @param player The player to remove all groups from.
|
||||
*
|
||||
* @return True if succeed, false otherwise.
|
||||
* 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"),
|
||||
PERMISSIONS("Permissions");
|
||||
|
||||
public String name;
|
||||
public final String name;
|
||||
|
||||
/**
|
||||
* Constructor for PermissionsSystemType.
|
||||
@ -915,4 +927,4 @@ public class PermissionsManager {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,166 +1,166 @@
|
||||
package fr.xephi.authme.process;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.process.email.AsyncChangeEmail;
|
||||
import fr.xephi.authme.process.join.AsyncronousJoin;
|
||||
import fr.xephi.authme.process.login.AsyncronousLogin;
|
||||
import fr.xephi.authme.process.logout.AsyncronousLogout;
|
||||
import fr.xephi.authme.process.quit.AsyncronousQuit;
|
||||
import fr.xephi.authme.process.register.AsyncRegister;
|
||||
import fr.xephi.authme.process.unregister.AsyncronousUnregister;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
/**
|
||||
* @author Gabriele
|
||||
* @version $Revision: 1.0 $
|
||||
*/
|
||||
public class Management {
|
||||
|
||||
public static RandomString rdm = new RandomString(Settings.captchaLength);
|
||||
private final AuthMe plugin;
|
||||
private final BukkitScheduler sched;
|
||||
|
||||
/**
|
||||
* Constructor for Management.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public Management(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
this.sched = this.plugin.getServer().getScheduler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method performLogin.
|
||||
*
|
||||
* @param player Player
|
||||
* @param password String
|
||||
* @param forceLogin boolean
|
||||
*/
|
||||
public void performLogin(final Player player, final String password, final boolean forceLogin) {
|
||||
sched.runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsyncronousLogin(player, password, forceLogin, plugin, plugin.database).process();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Method performLogout.
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
public void performLogout(final Player player) {
|
||||
sched.runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsyncronousLogout(player, plugin, plugin.database).process();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Method performRegister.
|
||||
*
|
||||
* @param player Player
|
||||
* @param password String
|
||||
* @param email String
|
||||
*/
|
||||
public void performRegister(final Player player, final String password, final String email) {
|
||||
sched.runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsyncRegister(player, password, email, plugin, plugin.database).process();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Method performUnregister.
|
||||
*
|
||||
* @param player Player
|
||||
* @param password String
|
||||
* @param force boolean
|
||||
*/
|
||||
public void performUnregister(final Player player, final String password, final boolean force) {
|
||||
sched.runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsyncronousUnregister(player, password, force, plugin).process();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Method performJoin.
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
public void performJoin(final Player player) {
|
||||
sched.runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsyncronousJoin(player, plugin, plugin.database).process();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Method performQuit.
|
||||
*
|
||||
* @param player Player
|
||||
* @param isKick boolean
|
||||
*/
|
||||
public void performQuit(final Player player, final boolean isKick) {
|
||||
sched.runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsyncronousQuit(player, plugin, plugin.database, isKick).process();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Method performAddEmail.
|
||||
*
|
||||
* @param player Player
|
||||
* @param newEmail String
|
||||
* @param newEmailVerify String
|
||||
*/
|
||||
public void performAddEmail(final Player player, final String newEmail, final String newEmailVerify) {
|
||||
sched.runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
new AsyncChangeEmail(player, plugin, null, newEmail, newEmailVerify).process();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Method performChangeEmail.
|
||||
*
|
||||
* @param player Player
|
||||
* @param oldEmail String
|
||||
* @param newEmail String
|
||||
*/
|
||||
public void performChangeEmail(final Player player, final String oldEmail, final String newEmail) {
|
||||
sched.runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
new AsyncChangeEmail(player, plugin, oldEmail, newEmail).process();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
package fr.xephi.authme.process;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.process.email.AsyncChangeEmail;
|
||||
import fr.xephi.authme.process.join.AsynchronousJoin;
|
||||
import fr.xephi.authme.process.login.AsynchronousLogin;
|
||||
import fr.xephi.authme.process.logout.AsynchronousLogout;
|
||||
import fr.xephi.authme.process.quit.AsynchronousQuit;
|
||||
import fr.xephi.authme.process.register.AsyncRegister;
|
||||
import fr.xephi.authme.process.unregister.AsynchronousUnregister;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
/**
|
||||
* @author Gabriele
|
||||
* @version $Revision: 1.0 $
|
||||
*/
|
||||
public class Management {
|
||||
|
||||
public static RandomString rdm = new RandomString(Settings.captchaLength);
|
||||
private final AuthMe plugin;
|
||||
private final BukkitScheduler sched;
|
||||
|
||||
/**
|
||||
* Constructor for Management.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public Management(AuthMe plugin) {
|
||||
this.plugin = plugin;
|
||||
this.sched = this.plugin.getServer().getScheduler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method performLogin.
|
||||
*
|
||||
* @param player Player
|
||||
* @param password String
|
||||
* @param forceLogin boolean
|
||||
*/
|
||||
public void performLogin(final Player player, final String password, final boolean forceLogin) {
|
||||
sched.runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsynchronousLogin(player, password, forceLogin, plugin, plugin.database).process();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Method performLogout.
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
public void performLogout(final Player player) {
|
||||
sched.runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsynchronousLogout(player, plugin, plugin.database).process();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Method performRegister.
|
||||
*
|
||||
* @param player Player
|
||||
* @param password String
|
||||
* @param email String
|
||||
*/
|
||||
public void performRegister(final Player player, final String password, final String email) {
|
||||
sched.runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsyncRegister(player, password, email, plugin, plugin.database).process();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Method performUnregister.
|
||||
*
|
||||
* @param player Player
|
||||
* @param password String
|
||||
* @param force boolean
|
||||
*/
|
||||
public void performUnregister(final Player player, final String password, final boolean force) {
|
||||
sched.runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsynchronousUnregister(player, password, force, plugin).process();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Method performJoin.
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
public void performJoin(final Player player) {
|
||||
sched.runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsynchronousJoin(player, plugin, plugin.database).process();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Method performQuit.
|
||||
*
|
||||
* @param player Player
|
||||
* @param isKick boolean
|
||||
*/
|
||||
public void performQuit(final Player player, final boolean isKick) {
|
||||
sched.runTaskAsynchronously(plugin, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
new AsynchronousQuit(player, plugin, plugin.database, isKick).process();
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Method performAddEmail.
|
||||
*
|
||||
* @param player Player
|
||||
* @param newEmail String
|
||||
* @param newEmailVerify String
|
||||
*/
|
||||
public void performAddEmail(final Player player, final String newEmail, final String newEmailVerify) {
|
||||
sched.runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
new AsyncChangeEmail(player, plugin, null, newEmail, newEmailVerify).process();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Method performChangeEmail.
|
||||
*
|
||||
* @param player Player
|
||||
* @param oldEmail String
|
||||
* @param newEmail String
|
||||
*/
|
||||
public void performChangeEmail(final Player player, final String oldEmail, final String newEmail) {
|
||||
sched.runTaskAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
new AsyncChangeEmail(player, plugin, oldEmail, newEmail).process();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class AsyncronousJoin {
|
||||
public class AsynchronousJoin {
|
||||
|
||||
private final AuthMe plugin;
|
||||
private final Player player;
|
||||
@ -39,13 +39,13 @@ public class AsyncronousJoin {
|
||||
private final BukkitScheduler sched;
|
||||
|
||||
/**
|
||||
* Constructor for AsyncronousJoin.
|
||||
* Constructor for AsynchronousJoin.
|
||||
*
|
||||
* @param player Player
|
||||
* @param plugin AuthMe
|
||||
* @param database DataSource
|
||||
*/
|
||||
public AsyncronousJoin(Player player, AuthMe plugin, DataSource database) {
|
||||
public AsynchronousJoin(Player player, AuthMe plugin, DataSource database) {
|
||||
this.player = player;
|
||||
this.plugin = plugin;
|
||||
this.sched = plugin.getServer().getScheduler();
|
||||
@ -248,7 +248,7 @@ public class AsyncronousJoin {
|
||||
}
|
||||
|
||||
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));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgTask);
|
||||
}
|
||||
@ -261,10 +261,10 @@ public class AsyncronousJoin {
|
||||
private boolean needFirstSpawn() {
|
||||
if (player.hasPlayedBefore())
|
||||
return false;
|
||||
Location firstspawn = Spawn.getInstance().getFirstSpawn();
|
||||
if (firstspawn == null || firstspawn.getWorld() == null)
|
||||
Location firstSpawn = Spawn.getInstance().getFirstSpawn();
|
||||
if (firstSpawn == null || firstSpawn.getWorld() == null)
|
||||
return false;
|
||||
FirstSpawnTeleportEvent tpEvent = new FirstSpawnTeleportEvent(player, player.getLocation(), firstspawn);
|
||||
FirstSpawnTeleportEvent tpEvent = new FirstSpawnTeleportEvent(player, player.getLocation(), firstSpawn);
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if (!tpEvent.isCancelled()) {
|
||||
if (player.isOnline() && tpEvent.getTo() != null && tpEvent.getTo().getWorld() != null) {
|
||||
@ -306,7 +306,7 @@ public class AsyncronousJoin {
|
||||
Material cur = player.getLocation().getBlock().getType();
|
||||
Material top = player.getLocation().add(0D, 1D, 0D).getBlock().getType();
|
||||
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");
|
||||
player.teleport(spawnLoc);
|
||||
}
|
@ -23,20 +23,20 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class AsyncronousLogin {
|
||||
public class AsynchronousLogin {
|
||||
|
||||
private static RandomString rdm = new RandomString(Settings.captchaLength);
|
||||
protected Player player;
|
||||
protected String name;
|
||||
protected String realName;
|
||||
protected String password;
|
||||
protected boolean forceLogin;
|
||||
private AuthMe plugin;
|
||||
private DataSource database;
|
||||
private Messages m = Messages.getInstance();
|
||||
private static final RandomString rdm = new RandomString(Settings.captchaLength);
|
||||
protected final Player player;
|
||||
protected final String name;
|
||||
protected final String realName;
|
||||
protected final String password;
|
||||
protected final boolean forceLogin;
|
||||
private final AuthMe plugin;
|
||||
private final DataSource database;
|
||||
private final Messages m = Messages.getInstance();
|
||||
|
||||
/**
|
||||
* Constructor for AsyncronousLogin.
|
||||
* Constructor for AsynchronousLogin.
|
||||
*
|
||||
* @param player Player
|
||||
* @param password String
|
||||
@ -44,8 +44,8 @@ public class AsyncronousLogin {
|
||||
* @param plugin AuthMe
|
||||
* @param data DataSource
|
||||
*/
|
||||
public AsyncronousLogin(Player player, String password, boolean forceLogin,
|
||||
AuthMe plugin, DataSource data) {
|
||||
public AsynchronousLogin(Player player, String password, boolean forceLogin,
|
||||
AuthMe plugin, DataSource data) {
|
||||
this.player = player;
|
||||
this.password = password;
|
||||
name = player.getName().toLowerCase();
|
@ -24,14 +24,14 @@ import org.bukkit.potion.PotionEffectType;
|
||||
*/
|
||||
public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
|
||||
private LimboPlayer limbo;
|
||||
private Player player;
|
||||
private String name;
|
||||
private PlayerAuth auth;
|
||||
private AuthMe plugin;
|
||||
private DataSource database;
|
||||
private PluginManager pm;
|
||||
private JsonCache playerCache;
|
||||
private final LimboPlayer limbo;
|
||||
private final Player player;
|
||||
private final String name;
|
||||
private final PlayerAuth auth;
|
||||
private final AuthMe plugin;
|
||||
private final DataSource database;
|
||||
private final PluginManager pm;
|
||||
private final JsonCache playerCache;
|
||||
|
||||
/**
|
||||
* Constructor for ProcessSyncronousPlayerLogin.
|
||||
@ -194,11 +194,11 @@ public class ProcessSyncronousPlayerLogin implements Runnable {
|
||||
if (Settings.useWelcomeMessage)
|
||||
if (Settings.broadcastWelcomeMessage) {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
Bukkit.getServer().broadcastMessage(plugin.replaceAllInfos(s, player));
|
||||
Bukkit.getServer().broadcastMessage(plugin.replaceAllInfo(s, player));
|
||||
}
|
||||
} else {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
player.sendMessage(plugin.replaceAllInfos(s, player));
|
||||
player.sendMessage(plugin.replaceAllInfo(s, player));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,24 +13,24 @@ import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class AsyncronousLogout {
|
||||
public class AsynchronousLogout {
|
||||
|
||||
protected Player player;
|
||||
protected String name;
|
||||
protected AuthMe plugin;
|
||||
protected DataSource database;
|
||||
protected final Player player;
|
||||
protected final String name;
|
||||
protected final AuthMe plugin;
|
||||
protected final DataSource database;
|
||||
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 plugin AuthMe
|
||||
* @param database DataSource
|
||||
*/
|
||||
public AsyncronousLogout(Player player, AuthMe plugin,
|
||||
DataSource database) {
|
||||
public AsynchronousLogout(Player player, AuthMe plugin,
|
||||
DataSource database) {
|
||||
this.player = player;
|
||||
this.plugin = plugin;
|
||||
this.database = database;
|
||||
@ -49,7 +49,7 @@ public class AsyncronousLogout {
|
||||
if (!canLogout)
|
||||
return;
|
||||
final Player p = player;
|
||||
BukkitScheduler sched = p.getServer().getScheduler();
|
||||
BukkitScheduler scheduler = p.getServer().getScheduler();
|
||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(name);
|
||||
database.updateSession(auth);
|
||||
auth.setQuitLocX(p.getLocation().getX());
|
||||
@ -60,7 +60,7 @@ public class AsyncronousLogout {
|
||||
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
database.setUnlogged(name);
|
||||
sched.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
scheduler.scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Utils.teleportToSpawn(p);
|
||||
@ -71,6 +71,6 @@ public class AsyncronousLogout {
|
||||
LimboCache.getInstance().addLimboPlayer(player);
|
||||
Utils.setGroup(player, GroupType.NOTLOGGEDIN);
|
||||
|
||||
sched.scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerLogout(p, plugin));
|
||||
scheduler.scheduleSyncDelayedTask(plugin, new ProcessSyncronousPlayerLogout(p, plugin));
|
||||
}
|
||||
}
|
@ -1,77 +1,77 @@
|
||||
package fr.xephi.authme.process.logout;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.events.LogoutEvent;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.task.TimeoutTask;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ProcessSyncronousPlayerLogout implements Runnable {
|
||||
|
||||
protected Player player;
|
||||
protected AuthMe plugin;
|
||||
protected String name;
|
||||
private Messages m = Messages.getInstance();
|
||||
|
||||
/**
|
||||
* Constructor for ProcessSyncronousPlayerLogout.
|
||||
*
|
||||
* @param player Player
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public ProcessSyncronousPlayerLogout(Player player, AuthMe plugin) {
|
||||
this.player = player;
|
||||
this.plugin = plugin;
|
||||
this.name = player.getName().toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin.sessions.containsKey(name))
|
||||
plugin.sessions.get(name).cancel();
|
||||
plugin.sessions.remove(name);
|
||||
int delay = Settings.getRegistrationTimeout * 20;
|
||||
int interval = Settings.getWarnMessageInterval;
|
||||
BukkitScheduler sched = player.getServer().getScheduler();
|
||||
if (delay != 0) {
|
||||
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), delay);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||
}
|
||||
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||
if (player.isInsideVehicle() && player.getVehicle() != null)
|
||||
player.getVehicle().eject();
|
||||
if (Settings.applyBlindEffect)
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
|
||||
player.setOp(false);
|
||||
if (!Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
if (!Settings.isMovementAllowed && Settings.isRemoveSpeedEnabled) {
|
||||
player.setFlySpeed(0.0f);
|
||||
player.setWalkSpeed(0.0f);
|
||||
}
|
||||
}
|
||||
// Player is now logout... Time to fire event !
|
||||
Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player));
|
||||
m.send(player, "logout");
|
||||
ConsoleLogger.info(player.getName() + " logged out");
|
||||
}
|
||||
|
||||
}
|
||||
package fr.xephi.authme.process.logout;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.events.LogoutEvent;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.task.TimeoutTask;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ProcessSyncronousPlayerLogout implements Runnable {
|
||||
|
||||
protected final Player player;
|
||||
protected final AuthMe plugin;
|
||||
protected final String name;
|
||||
private final Messages m = Messages.getInstance();
|
||||
|
||||
/**
|
||||
* Constructor for ProcessSyncronousPlayerLogout.
|
||||
*
|
||||
* @param player Player
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public ProcessSyncronousPlayerLogout(Player player, AuthMe plugin) {
|
||||
this.player = player;
|
||||
this.plugin = plugin;
|
||||
this.name = player.getName().toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin.sessions.containsKey(name))
|
||||
plugin.sessions.get(name).cancel();
|
||||
plugin.sessions.remove(name);
|
||||
int delay = Settings.getRegistrationTimeout * 20;
|
||||
int interval = Settings.getWarnMessageInterval;
|
||||
BukkitScheduler sched = player.getServer().getScheduler();
|
||||
if (delay != 0) {
|
||||
BukkitTask id = sched.runTaskLaterAsynchronously(plugin, new TimeoutTask(plugin, name, player), delay);
|
||||
LimboCache.getInstance().getLimboPlayer(name).setTimeoutTaskId(id);
|
||||
}
|
||||
BukkitTask msgT = sched.runTaskAsynchronously(plugin, new MessageTask(plugin, name, m.send("login_msg"), interval));
|
||||
LimboCache.getInstance().getLimboPlayer(name).setMessageTaskId(msgT);
|
||||
if (player.isInsideVehicle() && player.getVehicle() != null)
|
||||
player.getVehicle().eject();
|
||||
if (Settings.applyBlindEffect)
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, Settings.getRegistrationTimeout * 20, 2));
|
||||
player.setOp(false);
|
||||
if (!Settings.isMovementAllowed) {
|
||||
player.setAllowFlight(true);
|
||||
player.setFlying(true);
|
||||
if (!Settings.isMovementAllowed && Settings.isRemoveSpeedEnabled) {
|
||||
player.setFlySpeed(0.0f);
|
||||
player.setWalkSpeed(0.0f);
|
||||
}
|
||||
}
|
||||
// Player is now logout... Time to fire event !
|
||||
Bukkit.getServer().getPluginManager().callEvent(new LogoutEvent(player));
|
||||
m.send(player, "logout");
|
||||
ConsoleLogger.info(player.getName() + " logged out");
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,27 +16,27 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class AsyncronousQuit {
|
||||
public class AsynchronousQuit {
|
||||
|
||||
protected AuthMe plugin;
|
||||
protected DataSource database;
|
||||
protected Player player;
|
||||
private String name;
|
||||
protected final AuthMe plugin;
|
||||
protected final DataSource database;
|
||||
protected final Player player;
|
||||
private final String name;
|
||||
private boolean isOp = false;
|
||||
private boolean isFlying = false;
|
||||
private boolean needToChange = false;
|
||||
private boolean isKick = false;
|
||||
|
||||
/**
|
||||
* Constructor for AsyncronousQuit.
|
||||
* Constructor for AsynchronousQuit.
|
||||
*
|
||||
* @param p Player
|
||||
* @param plugin AuthMe
|
||||
* @param database DataSource
|
||||
* @param isKick boolean
|
||||
*/
|
||||
public AsyncronousQuit(Player p, AuthMe plugin, DataSource database,
|
||||
boolean isKick) {
|
||||
public AsynchronousQuit(Player p, AuthMe plugin, DataSource database,
|
||||
boolean isKick) {
|
||||
this.player = p;
|
||||
this.plugin = plugin;
|
||||
this.database = database;
|
@ -9,11 +9,11 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public class ProcessSyncronousPlayerQuit implements Runnable {
|
||||
|
||||
protected AuthMe plugin;
|
||||
protected Player player;
|
||||
protected boolean isOp;
|
||||
protected boolean isFlying;
|
||||
protected boolean needToChange;
|
||||
protected final AuthMe plugin;
|
||||
protected final Player player;
|
||||
protected final boolean isOp;
|
||||
protected final boolean isFlying;
|
||||
protected final boolean needToChange;
|
||||
|
||||
/**
|
||||
* Constructor for ProcessSyncronousPlayerQuit.
|
||||
@ -25,8 +25,8 @@ public class ProcessSyncronousPlayerQuit implements Runnable {
|
||||
* @param needToChange boolean
|
||||
*/
|
||||
public ProcessSyncronousPlayerQuit(AuthMe plugin, Player player
|
||||
, boolean isOp, boolean isFlying
|
||||
, boolean needToChange) {
|
||||
, boolean isOp, boolean isFlying
|
||||
, boolean needToChange) {
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
this.isOp = isOp;
|
||||
@ -51,7 +51,7 @@ public class ProcessSyncronousPlayerQuit implements Runnable {
|
||||
}
|
||||
try {
|
||||
player.getVehicle().eject();
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,13 +17,13 @@ import java.util.Date;
|
||||
*/
|
||||
public class AsyncRegister {
|
||||
|
||||
protected Player player;
|
||||
protected String name;
|
||||
protected String password;
|
||||
protected final Player player;
|
||||
protected final String name;
|
||||
protected final String password;
|
||||
protected String email = "";
|
||||
private AuthMe plugin;
|
||||
private DataSource database;
|
||||
private Messages m = Messages.getInstance();
|
||||
private final AuthMe plugin;
|
||||
private final DataSource database;
|
||||
private final Messages m = Messages.getInstance();
|
||||
|
||||
/**
|
||||
* Constructor for AsyncRegister.
|
||||
@ -59,17 +59,17 @@ public class AsyncRegister {
|
||||
* @return boolean * @throws Exception
|
||||
*/
|
||||
protected boolean preRegisterCheck() throws Exception {
|
||||
String lowpass = password.toLowerCase();
|
||||
String passLow = password.toLowerCase();
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
m.send(player, "logged_in");
|
||||
return false;
|
||||
} else if (!Settings.isRegistrationEnabled) {
|
||||
m.send(player, "reg_disabled");
|
||||
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");
|
||||
return false;
|
||||
} else if (lowpass.equalsIgnoreCase(player.getName())) {
|
||||
} else if (passLow.equalsIgnoreCase(player.getName())) {
|
||||
m.send(player, "password_error_nick");
|
||||
return false;
|
||||
} else if (password.length() < Settings.getPasswordMinLen || password.length() > Settings.passwordMaxLength) {
|
||||
@ -125,8 +125,8 @@ public class AsyncRegister {
|
||||
}
|
||||
}
|
||||
PlayerAuth auth;
|
||||
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());
|
||||
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());
|
||||
if (PasswordSecurity.userSalt.containsKey(name)) {
|
||||
auth.setSalt(PasswordSecurity.userSalt.get(name));
|
||||
}
|
||||
@ -134,8 +134,8 @@ public class AsyncRegister {
|
||||
database.updateEmail(auth);
|
||||
database.updateSession(auth);
|
||||
plugin.mail.main(auth, password);
|
||||
ProcessSyncEmailRegister syncronous = new ProcessSyncEmailRegister(player, plugin);
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, syncronous);
|
||||
ProcessSyncEmailRegister sync = new ProcessSyncEmailRegister(player, plugin);
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, sync);
|
||||
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ public class AsyncRegister {
|
||||
database.setLogged(name);
|
||||
}
|
||||
plugin.otherAccounts.addPlayer(player.getUniqueId());
|
||||
ProcessSyncronousPasswordRegister syncronous = new ProcessSyncronousPasswordRegister(player, plugin);
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, syncronous);
|
||||
ProcessSyncronousPasswordRegister sync = new ProcessSyncronousPasswordRegister(player, plugin);
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, sync);
|
||||
}
|
||||
}
|
||||
|
@ -17,10 +17,10 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
*/
|
||||
public class ProcessSyncEmailRegister implements Runnable {
|
||||
|
||||
protected Player player;
|
||||
protected String name;
|
||||
private AuthMe plugin;
|
||||
private Messages m = Messages.getInstance();
|
||||
protected final Player player;
|
||||
protected final String name;
|
||||
private final AuthMe plugin;
|
||||
private final Messages m = Messages.getInstance();
|
||||
|
||||
/**
|
||||
* Constructor for ProcessSyncEmailRegister.
|
||||
|
@ -22,10 +22,10 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
*/
|
||||
public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
|
||||
protected Player player;
|
||||
protected String name;
|
||||
private AuthMe plugin;
|
||||
private Messages m = Messages.getInstance();
|
||||
protected final Player player;
|
||||
protected final String name;
|
||||
private final AuthMe plugin;
|
||||
private final Messages m = Messages.getInstance();
|
||||
|
||||
/**
|
||||
* Constructor for ProcessSyncronousPasswordRegister.
|
||||
@ -139,11 +139,11 @@ public class ProcessSyncronousPasswordRegister implements Runnable {
|
||||
if (Settings.useWelcomeMessage)
|
||||
if (Settings.broadcastWelcomeMessage) {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
plugin.getServer().broadcastMessage(plugin.replaceAllInfos(s, player));
|
||||
plugin.getServer().broadcastMessage(plugin.replaceAllInfo(s, player));
|
||||
}
|
||||
} else {
|
||||
for (String s : Settings.welcomeMsg) {
|
||||
player.sendMessage(plugin.replaceAllInfos(s, player));
|
||||
player.sendMessage(plugin.replaceAllInfo(s, player));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,26 +22,26 @@ import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class AsyncronousUnregister {
|
||||
public class AsynchronousUnregister {
|
||||
|
||||
protected Player player;
|
||||
protected String name;
|
||||
protected String password;
|
||||
protected boolean force;
|
||||
private AuthMe plugin;
|
||||
private Messages m = Messages.getInstance();
|
||||
private JsonCache playerCache;
|
||||
protected final Player player;
|
||||
protected final String name;
|
||||
protected final String password;
|
||||
protected final boolean force;
|
||||
private final AuthMe plugin;
|
||||
private final Messages m = Messages.getInstance();
|
||||
private final JsonCache playerCache;
|
||||
|
||||
/**
|
||||
* Constructor for AsyncronousUnregister.
|
||||
* Constructor for AsynchronousUnregister.
|
||||
*
|
||||
* @param player Player
|
||||
* @param password String
|
||||
* @param force boolean
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public AsyncronousUnregister(Player player, String password,
|
||||
boolean force, AuthMe plugin) {
|
||||
public AsynchronousUnregister(Player player, String password,
|
||||
boolean force, AuthMe plugin) {
|
||||
this.player = player;
|
||||
this.password = password;
|
||||
this.force = force;
|
||||
@ -75,12 +75,12 @@ public class AsyncronousUnregister {
|
||||
LimboCache.getInstance().addLimboPlayer(player);
|
||||
int delay = Settings.getRegistrationTimeout * 20;
|
||||
int interval = Settings.getWarnMessageInterval;
|
||||
BukkitScheduler sched = plugin.getServer().getScheduler();
|
||||
BukkitScheduler scheduler = plugin.getServer().getScheduler();
|
||||
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).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");
|
||||
ConsoleLogger.info(player.getDisplayName() + " unregistered himself");
|
||||
return;
|
@ -35,7 +35,7 @@ public enum HashAlgorithm {
|
||||
SALTEDSHA512(fr.xephi.authme.security.crypts.SALTEDSHA512.class),
|
||||
CUSTOM(Null.class);
|
||||
|
||||
Class<?> classe;
|
||||
final Class<?> classe;
|
||||
|
||||
/**
|
||||
* Constructor for HashAlgorithm.
|
||||
|
@ -18,17 +18,18 @@ import java.util.HashMap;
|
||||
*/
|
||||
public class PasswordSecurity {
|
||||
|
||||
public static HashMap<String, String> userSalt = new HashMap<>();
|
||||
private static SecureRandom rnd = new SecureRandom();
|
||||
public static final HashMap<String, String> userSalt = new HashMap<>();
|
||||
private static final SecureRandom rnd = new SecureRandom();
|
||||
|
||||
/**
|
||||
* Method createSalt.
|
||||
*
|
||||
* @param length int
|
||||
*
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
public static String createSalt(int length)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
byte[] msg = new byte[40];
|
||||
rnd.nextBytes(msg);
|
||||
MessageDigest sha1 = MessageDigest.getInstance("SHA1");
|
||||
@ -43,6 +44,7 @@ public class PasswordSecurity {
|
||||
* @param alg HashAlgorithm
|
||||
* @param password String
|
||||
* @param playerName String
|
||||
*
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
public static String getHash(HashAlgorithm alg, String password,
|
||||
@ -146,15 +148,16 @@ public class PasswordSecurity {
|
||||
* @param password String
|
||||
* @param hash String
|
||||
* @param playerName String
|
||||
*
|
||||
* @return boolean * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
public static boolean comparePasswordWithHash(String password, String hash,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
HashAlgorithm algo = Settings.getPasswordHash;
|
||||
HashAlgorithm algorithm = Settings.getPasswordHash;
|
||||
EncryptionMethod method;
|
||||
try {
|
||||
if (algo != HashAlgorithm.CUSTOM)
|
||||
method = (EncryptionMethod) algo.getclasse().newInstance();
|
||||
if (algorithm != HashAlgorithm.CUSTOM)
|
||||
method = (EncryptionMethod) algorithm.getclasse().newInstance();
|
||||
else
|
||||
method = null;
|
||||
|
||||
@ -184,10 +187,11 @@ public class PasswordSecurity {
|
||||
* @param password String
|
||||
* @param hash String
|
||||
* @param playerName String
|
||||
*
|
||||
* @return boolean * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static boolean compareWithAllEncryptionMethod(String password,
|
||||
String hash, String playerName) throws NoSuchAlgorithmException {
|
||||
String hash, String playerName) {
|
||||
for (HashAlgorithm algo : HashAlgorithm.values()) {
|
||||
if (algo != HashAlgorithm.CUSTOM) {
|
||||
try {
|
||||
|
@ -21,37 +21,37 @@ import java.security.SecureRandom;
|
||||
* BCrypt implements OpenBSD-style Blowfish password hashing using the scheme
|
||||
* described in "A Future-Adaptable Password Scheme" by Niels Provos and David
|
||||
* Mazieres.
|
||||
* <p>
|
||||
* <p/>
|
||||
* This password hashing system tries to thwart off-line password cracking using
|
||||
* a computationally-intensive hashing algorithm, based on Bruce Schneier's
|
||||
* Blowfish cipher. The work factor of the algorithm is parameterised, so it can
|
||||
* be increased as computers get faster.
|
||||
* <p>
|
||||
* <p/>
|
||||
* Usage is really simple. To hash a password for the first time, call the
|
||||
* hashpw method with a random salt, like this:
|
||||
* <p>
|
||||
* <p/>
|
||||
* <code>
|
||||
* String pw_hash = BCrypt.hashpw(plain_password, BCrypt.gensalt()); <br />
|
||||
* </code>
|
||||
* <p>
|
||||
* <p/>
|
||||
* To check whether a plaintext password matches one that has been hashed
|
||||
* previously, use the checkpw method:
|
||||
* <p>
|
||||
* <p/>
|
||||
* <code>
|
||||
* if (BCrypt.checkpw(candidate_password, stored_hash))<br />
|
||||
* System.out.println("It matches");<br />
|
||||
* else<br />
|
||||
* System.out.println("It does not match");<br />
|
||||
* </code>
|
||||
* <p>
|
||||
* <p/>
|
||||
* The gensalt() method takes an optional parameter (log_rounds) that determines
|
||||
* the computational complexity of the hashing:
|
||||
* <p>
|
||||
* <p/>
|
||||
* <code>
|
||||
* String strong_salt = BCrypt.gensalt(10)<br />
|
||||
* String stronger_salt = BCrypt.gensalt(12)<br />
|
||||
* </code>
|
||||
* <p>
|
||||
* <p/>
|
||||
* 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
|
||||
* to 31.
|
||||
@ -92,12 +92,13 @@ public class BCRYPT implements EncryptionMethod {
|
||||
*
|
||||
* @param d the byte array to encode
|
||||
* @param len the number of bytes to encode
|
||||
*
|
||||
* @return base64-encoded string * @throws IllegalArgumentException if the length is invalid * @throws IllegalArgumentException
|
||||
*/
|
||||
private static String encode_base64(byte d[], int len)
|
||||
throws IllegalArgumentException {
|
||||
throws IllegalArgumentException {
|
||||
int off = 0;
|
||||
StringBuffer rs = new StringBuffer();
|
||||
StringBuilder rs = new StringBuilder();
|
||||
int c1, c2;
|
||||
|
||||
if (len <= 0 || len > d.length)
|
||||
@ -132,6 +133,7 @@ public class BCRYPT implements EncryptionMethod {
|
||||
* range-checking againt conversion table
|
||||
*
|
||||
* @param x the base64-encoded value
|
||||
*
|
||||
* @return the decoded value of x
|
||||
*/
|
||||
private static byte char64(char x) {
|
||||
@ -147,11 +149,12 @@ public class BCRYPT implements EncryptionMethod {
|
||||
*
|
||||
* @param s the string 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
|
||||
*/
|
||||
private static byte[] decode_base64(String s, int maxolen)
|
||||
throws IllegalArgumentException {
|
||||
StringBuffer rs = new StringBuffer();
|
||||
throws IllegalArgumentException {
|
||||
StringBuilder rs = new StringBuilder();
|
||||
int off = 0, slen = s.length(), olen = 0;
|
||||
byte ret[];
|
||||
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 offp a "pointer" (as a one-entry array) to the current offset into
|
||||
* data
|
||||
*
|
||||
* @return the next word of material from data
|
||||
*/
|
||||
private static int streamtoword(byte data[], int offp[]) {
|
||||
@ -217,6 +221,7 @@ public class BCRYPT implements EncryptionMethod {
|
||||
*
|
||||
* @param password the password to hash
|
||||
* @param salt the salt to hash with (perhaps generated using BCrypt.gensalt)
|
||||
*
|
||||
* @return the hashed password
|
||||
*/
|
||||
public static String hashpw(String password, String salt) {
|
||||
@ -225,7 +230,7 @@ public class BCRYPT implements EncryptionMethod {
|
||||
byte passwordb[], saltb[], hashed[];
|
||||
char minor = (char) 0;
|
||||
int rounds, off = 0;
|
||||
StringBuffer rs = new StringBuffer();
|
||||
StringBuilder rs = new StringBuilder();
|
||||
|
||||
if (salt.charAt(0) != '$' || salt.charAt(1) != '2')
|
||||
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
|
||||
* work factor therefore increases as 2**log_rounds.
|
||||
* @param random an instance of SecureRandom to use
|
||||
*
|
||||
* @return an encoded salt value
|
||||
*/
|
||||
public static String gensalt(int log_rounds, SecureRandom random) {
|
||||
StringBuffer rs = new StringBuffer();
|
||||
StringBuilder rs = new StringBuilder();
|
||||
byte rnd[] = new byte[BCRYPT_SALT_LEN];
|
||||
|
||||
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
|
||||
* work factor therefore increases as 2**log_rounds.
|
||||
*
|
||||
* @return an encoded salt value
|
||||
*/
|
||||
public static String gensalt(int log_rounds) {
|
||||
@ -317,6 +324,7 @@ public class BCRYPT implements EncryptionMethod {
|
||||
*
|
||||
* @param plaintext the plaintext password to verify
|
||||
* @param hashed the previously-hashed password
|
||||
*
|
||||
* @return true if the passwords match, false otherwise
|
||||
*/
|
||||
public static boolean checkpw(String plaintext, String hashed) {
|
||||
@ -330,6 +338,7 @@ public class BCRYPT implements EncryptionMethod {
|
||||
* @param text plaintext or hashed text
|
||||
* @param hashed the previously-hashed password
|
||||
* @param rounds number of rounds to hash the password
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean checkpw(String text, String hashed, int rounds) {
|
||||
@ -355,6 +364,7 @@ public class BCRYPT implements EncryptionMethod {
|
||||
*
|
||||
* @param text String
|
||||
* @param salt String
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
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 log_rounds the binary logarithm of the number of rounds of hashing to
|
||||
* apply
|
||||
*
|
||||
* @return an array containing the binary hashed password
|
||||
*/
|
||||
private byte[] crypt_raw(byte password[], byte salt[], int log_rounds) {
|
||||
@ -509,11 +520,12 @@ public class BCRYPT implements EncryptionMethod {
|
||||
* @param password String
|
||||
* @param salt String
|
||||
* @param name 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)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return hashpw(password, salt);
|
||||
}
|
||||
|
||||
@ -523,6 +535,7 @@ public class BCRYPT implements EncryptionMethod {
|
||||
* @param hash String
|
||||
* @param password String
|
||||
* @param playerName String
|
||||
*
|
||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
||||
*/
|
||||
@Override
|
||||
|
@ -1,42 +1,44 @@
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class BCRYPT2Y implements EncryptionMethod {
|
||||
|
||||
/**
|
||||
* Method getHash.
|
||||
*
|
||||
* @param password String
|
||||
* @param salt String
|
||||
* @param name 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)
|
||||
throws NoSuchAlgorithmException {
|
||||
if (salt.length() == 22)
|
||||
salt = "$2y$10$" + salt;
|
||||
return (BCRYPT.hashpw(password, salt));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method comparePassword.
|
||||
*
|
||||
* @param hash String
|
||||
* @param password String
|
||||
* @param playerName String
|
||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
||||
*/
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String ok = hash.substring(0, 29);
|
||||
if (ok.length() != 29)
|
||||
return false;
|
||||
return hash.equals(getHash(password, ok, playerName));
|
||||
}
|
||||
|
||||
}
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class BCRYPT2Y implements EncryptionMethod {
|
||||
|
||||
/**
|
||||
* Method getHash.
|
||||
*
|
||||
* @param password String
|
||||
* @param salt String
|
||||
* @param name 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)
|
||||
throws NoSuchAlgorithmException {
|
||||
if (salt.length() == 22)
|
||||
salt = "$2y$10$" + salt;
|
||||
return (BCRYPT.hashpw(password, salt));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method comparePassword.
|
||||
*
|
||||
* @param hash String
|
||||
* @param password String
|
||||
* @param playerName String
|
||||
*
|
||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
||||
*/
|
||||
@Override
|
||||
public boolean comparePassword(String hash, String password,
|
||||
String playerName) throws NoSuchAlgorithmException {
|
||||
String ok = hash.substring(0, 29);
|
||||
if (ok.length() != 29)
|
||||
return false;
|
||||
return hash.equals(getHash(password, ok, playerName));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -32,11 +32,12 @@ public class CRAZYCRYPT1 implements EncryptionMethod {
|
||||
* @param password String
|
||||
* @param salt String
|
||||
* @param name 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)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
final String text = "ÜÄaeut//&/=I " + password + "7421€547" + name + "__+IÄIH§%NK " + password;
|
||||
try {
|
||||
final MessageDigest md = MessageDigest.getInstance("SHA-512");
|
||||
|
@ -4,6 +4,7 @@ import fr.xephi.authme.security.pbkdf2.PBKDF2Engine;
|
||||
import fr.xephi.authme.security.pbkdf2.PBKDF2Parameters;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -15,16 +16,17 @@ public class CryptPBKDF2 implements EncryptionMethod {
|
||||
* @param password String
|
||||
* @param salt String
|
||||
* @param name 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)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
String result = "pbkdf2_sha256$10000$" + salt + "$";
|
||||
PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 10000);
|
||||
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 password String
|
||||
* @param playerName String
|
||||
*
|
||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
||||
*/
|
||||
@Override
|
||||
@ -46,4 +49,4 @@ public class CryptPBKDF2 implements EncryptionMethod {
|
||||
return engine.verifyKey(password);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -16,11 +16,12 @@ public class CryptPBKDF2Django implements EncryptionMethod {
|
||||
* @param password String
|
||||
* @param salt String
|
||||
* @param name 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)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
String result = "pbkdf2_sha256$15000$" + salt + "$";
|
||||
PBKDF2Parameters params = new PBKDF2Parameters("HmacSHA256", "ASCII", salt.getBytes(), 15000);
|
||||
PBKDF2Engine engine = new PBKDF2Engine(params);
|
||||
@ -34,6 +35,7 @@ public class CryptPBKDF2Django implements EncryptionMethod {
|
||||
* @param hash String
|
||||
* @param password String
|
||||
* @param playerName String
|
||||
*
|
||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
||||
*/
|
||||
@Override
|
||||
|
@ -12,10 +12,11 @@ public class DOUBLEMD5 implements EncryptionMethod {
|
||||
* Method getMD5.
|
||||
*
|
||||
* @param message String
|
||||
*
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static String getMD5(String message)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
@ -29,11 +30,12 @@ public class DOUBLEMD5 implements EncryptionMethod {
|
||||
* @param password String
|
||||
* @param salt String
|
||||
* @param name 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)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return getMD5(getMD5(password));
|
||||
}
|
||||
|
||||
@ -43,6 +45,7 @@ public class DOUBLEMD5 implements EncryptionMethod {
|
||||
* @param hash String
|
||||
* @param password String
|
||||
* @param playerName String
|
||||
*
|
||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
||||
*/
|
||||
@Override
|
||||
|
@ -24,18 +24,20 @@ public interface EncryptionMethod {
|
||||
* @param salt (can be an other data like playerName;salt , playerName,
|
||||
* etc... for customs methods)
|
||||
* @param name String
|
||||
*
|
||||
* @return Hashing password * @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
String getHash(String password, String salt, String name)
|
||||
throws NoSuchAlgorithmException;
|
||||
throws NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* @param hash
|
||||
* @param password
|
||||
* @param playerName
|
||||
*
|
||||
* @return true if password match, false else * @throws NoSuchAlgorithmException * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
boolean comparePassword(String hash, String password, String playerName)
|
||||
throws NoSuchAlgorithmException;
|
||||
throws NoSuchAlgorithmException;
|
||||
|
||||
}
|
||||
|
@ -14,10 +14,11 @@ public class IPB3 implements EncryptionMethod {
|
||||
* Method getMD5.
|
||||
*
|
||||
* @param message String
|
||||
*
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static String getMD5(String message)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
@ -31,11 +32,12 @@ public class IPB3 implements EncryptionMethod {
|
||||
* @param password String
|
||||
* @param salt String
|
||||
* @param name 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)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return getMD5(getMD5(salt) + getMD5(password));
|
||||
}
|
||||
|
||||
@ -45,6 +47,7 @@ public class IPB3 implements EncryptionMethod {
|
||||
* @param hash String
|
||||
* @param password String
|
||||
* @param playerName String
|
||||
*
|
||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
||||
*/
|
||||
@Override
|
||||
|
@ -12,10 +12,11 @@ public class JOOMLA implements EncryptionMethod {
|
||||
* Method getMD5.
|
||||
*
|
||||
* @param message String
|
||||
*
|
||||
* @return String * @throws NoSuchAlgorithmException
|
||||
*/
|
||||
private static String getMD5(String message)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
MessageDigest md5 = MessageDigest.getInstance("MD5");
|
||||
md5.reset();
|
||||
md5.update(message.getBytes());
|
||||
@ -29,11 +30,12 @@ public class JOOMLA implements EncryptionMethod {
|
||||
* @param password String
|
||||
* @param salt String
|
||||
* @param name 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)
|
||||
throws NoSuchAlgorithmException {
|
||||
throws NoSuchAlgorithmException {
|
||||
return getMD5(password + salt) + ":" + salt;
|
||||
}
|
||||
|
||||
@ -43,6 +45,7 @@ public class JOOMLA implements EncryptionMethod {
|
||||
* @param hash String
|
||||
* @param password String
|
||||
* @param playerName String
|
||||
*
|
||||
* @return boolean * @throws NoSuchAlgorithmException * @see fr.xephi.authme.security.crypts.EncryptionMethod#comparePassword(String, String, String)
|
||||
*/
|
||||
@Override
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user