mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-01-02 22:17:51 +01:00
Stuff from the common floobits workspace
Author: AuthMe-Team <AuthMeTeam@123NoEmail.com>
This commit is contained in:
parent
69a09aec17
commit
9ec2d6d059
3
.floo
Normal file
3
.floo
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"url": "https://floobits.com/AuthMe-Team/AuthMeReloaded"
|
||||
}
|
123
.flooignore
Normal file
123
.flooignore
Normal file
@ -0,0 +1,123 @@
|
||||
### Java ###
|
||||
*.class
|
||||
|
||||
# Mobile Tools for Java (J2ME)
|
||||
.mtj.tmp/
|
||||
|
||||
# Package Files #
|
||||
#*.jar
|
||||
*.war
|
||||
*.ear
|
||||
|
||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||
hs_err_pid*
|
||||
|
||||
|
||||
### Intellij ###
|
||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
|
||||
|
||||
*.iml
|
||||
|
||||
## Directory-based project format:
|
||||
.idea/
|
||||
# if you remove the above rule, at least ignore the following:
|
||||
|
||||
# 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:
|
||||
*.ipr
|
||||
*.iws
|
||||
|
||||
## Plugin-specific files:
|
||||
|
||||
# IntelliJ
|
||||
/out/
|
||||
|
||||
# mpeltonen/sbt-idea plugin
|
||||
.idea_modules/
|
||||
|
||||
# JIRA plugin
|
||||
atlassian-ide-plugin.xml
|
||||
|
||||
# Crashlytics plugin (for Android Studio and IntelliJ)
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
|
||||
|
||||
### Eclipse ###
|
||||
*.pydevproject
|
||||
.metadata
|
||||
.gradle
|
||||
bin/
|
||||
tmp/
|
||||
*.tmp
|
||||
*.bak
|
||||
*.swp
|
||||
*~.nib
|
||||
local.properties
|
||||
.settings/
|
||||
.loadpath
|
||||
|
||||
# Eclipse Core
|
||||
.project
|
||||
|
||||
# External tool builders
|
||||
.externalToolBuilders/
|
||||
|
||||
# Locally stored "Eclipse launch configurations"
|
||||
*.launch
|
||||
|
||||
# CDT-specific
|
||||
.cproject
|
||||
|
||||
# JDT-specific (Eclipse Java Development Tools)
|
||||
.classpath
|
||||
|
||||
# PDT-specific
|
||||
.buildpath
|
||||
|
||||
# sbteclipse plugin
|
||||
.target
|
||||
|
||||
# TeXlipse plugin
|
||||
.texlipse
|
||||
|
||||
|
||||
### Maven ###
|
||||
target/
|
||||
pom.xml.tag
|
||||
pom.xml.releaseBackup
|
||||
pom.xml.versionsBackup
|
||||
pom.xml.next
|
||||
release.properties
|
||||
dependency-reduced-pom.xml
|
||||
buildNumber.properties
|
||||
|
||||
|
||||
### NetBeans ###
|
||||
nbproject/private/
|
||||
build/
|
||||
nbbuild/
|
||||
dist/
|
||||
nbdist/
|
||||
nbactions.xml
|
||||
nb-configuration.xml
|
||||
.nb-gradle/
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,3 @@
|
||||
# Created by https://www.gitignore.io
|
||||
|
||||
### Java ###
|
||||
*.class
|
||||
|
||||
|
2
pom.xml
2
pom.xml
@ -46,7 +46,7 @@
|
||||
<!-- Project Properties -->
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<mainClass>fr.xephi.authme.AuthMe</mainClass>
|
||||
<buildNumber>CustomBuild</buildNumber>
|
||||
<buildNumber>100</buildNumber>
|
||||
<pluginAuthors>[Xephi, sgdc3, DNx5, timvisee, games647, ljacqu]</pluginAuthors>
|
||||
|
||||
<!-- Change Compiler Version (JDK) HERE! -->
|
||||
|
@ -1,18 +1,31 @@
|
||||
package fr.xephi.authme;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.api.NewAPI;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.backup.JsonCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.command.CommandHandler;
|
||||
import fr.xephi.authme.converter.Converter;
|
||||
import fr.xephi.authme.converter.ForceFlatToSqlite;
|
||||
import fr.xephi.authme.datasource.*;
|
||||
import fr.xephi.authme.hooks.BungeeCordMessage;
|
||||
import fr.xephi.authme.hooks.EssSpawn;
|
||||
import fr.xephi.authme.listener.*;
|
||||
import fr.xephi.authme.modules.ModuleManager;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.OtherAccounts;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.Spawn;
|
||||
import fr.xephi.authme.util.GeoLiteAPI;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import net.minelink.ctplus.CombatTagPlus;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -27,99 +40,148 @@ import org.bukkit.scheduler.BukkitTask;
|
||||
import org.mcstats.Metrics;
|
||||
import org.mcstats.Metrics.Graph;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||
|
||||
import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.api.NewAPI;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.backup.JsonCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.command.CommandHandler;
|
||||
import fr.xephi.authme.converter.Converter;
|
||||
import fr.xephi.authme.converter.ForceFlatToSqlite;
|
||||
import fr.xephi.authme.datasource.CacheDataSource;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.datasource.DatabaseCalls;
|
||||
import fr.xephi.authme.datasource.FlatFile;
|
||||
import fr.xephi.authme.datasource.MySQL;
|
||||
import fr.xephi.authme.datasource.SQLite;
|
||||
import fr.xephi.authme.hooks.BungeeCordMessage;
|
||||
import fr.xephi.authme.hooks.EssSpawn;
|
||||
import fr.xephi.authme.modules.ModuleManager;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.OtherAccounts;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.Spawn;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import net.minelink.ctplus.CombatTagPlus;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Calendar;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
/**
|
||||
* The AuthMe main class.
|
||||
*/
|
||||
public class AuthMe extends JavaPlugin {
|
||||
|
||||
/** Defines the name of the plugin. */
|
||||
// TODO: Create a getter method for this constant, and make it private
|
||||
public static final String PLUGIN_NAME = "AuthMeReloaded";
|
||||
/** Defines the current AuthMeReloaded version name. */
|
||||
/**
|
||||
* Defines the name of the plugin.
|
||||
*/
|
||||
private static final String PLUGIN_NAME = "AuthMeReloaded";
|
||||
/**
|
||||
* Defines the current AuthMeReloaded version name.
|
||||
*/
|
||||
private static final String PLUGIN_VERSION_NAME = "5.1-SNAPSHOT";
|
||||
/** Defines the current AuthMeReloaded version code. */
|
||||
// Increase this number by one when an update is released
|
||||
/**
|
||||
* Defines the current AuthMeReloaded version code.
|
||||
*/
|
||||
// TODO: Increase this number by one when an update is release
|
||||
// TODO: Increase the count via maven
|
||||
private static final int PLUGIN_VERSION_CODE = 100;
|
||||
|
||||
private static AuthMe plugin;
|
||||
private static Server server;
|
||||
private Logger authmeLogger;
|
||||
|
||||
// TODO: Move this to a better place! -- timvisee
|
||||
private CommandHandler commandHandler = null;
|
||||
private PermissionsManager permsMan = null;
|
||||
|
||||
public Management management;
|
||||
public NewAPI api;
|
||||
public SendMailSSL mail;
|
||||
private Settings settings;
|
||||
private Messages m;
|
||||
public DataManager dataManager;
|
||||
public DataSource database;
|
||||
private JsonCache playerBackup;
|
||||
public OtherAccounts otherAccounts;
|
||||
public Location essentialsSpawn;
|
||||
public boolean antibotMod = false;
|
||||
public boolean delayedAntiBot = true;
|
||||
|
||||
// Hooks TODO: move into modules
|
||||
public Essentials ess;
|
||||
public MultiverseCore multiverse;
|
||||
public CombatTagPlus combatTagPlus;
|
||||
public AuthMeInventoryPacketAdapter inventoryProtector;
|
||||
|
||||
// Module manager
|
||||
private ModuleManager moduleManager;
|
||||
|
||||
// TODO: Create Manager for fields below
|
||||
// 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<>();
|
||||
|
||||
// In case we need to cache PlayerAuths, prevent connection before it's done
|
||||
// AntiBot Status
|
||||
// TODO: Create Manager for this
|
||||
public boolean antiBotMod = false;
|
||||
public boolean delayedAntiBot = true;
|
||||
private CommandHandler commandHandler = null;
|
||||
private PermissionsManager permsMan = null;
|
||||
private Settings settings;
|
||||
private Messages messages;
|
||||
private JsonCache playerBackup;
|
||||
private ModuleManager moduleManager;
|
||||
// If cache is enabled, prevent any connection before the players data caching is completed.
|
||||
// TODO: Move somewhere
|
||||
private boolean canConnect = true;
|
||||
|
||||
/**
|
||||
* Method canConnect.
|
||||
* Returns the plugin's instance.
|
||||
*
|
||||
* @return AuthMe
|
||||
*/
|
||||
public static AuthMe getInstance() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
* @return boolean */
|
||||
/**
|
||||
* Get the plugin's name.
|
||||
*
|
||||
* @return Plugin name.
|
||||
*/
|
||||
public static String getPluginName() {
|
||||
return PLUGIN_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current installed AuthMeReloaded version name.
|
||||
*
|
||||
* @return The version name of the currently installed AuthMeReloaded instance.
|
||||
*/
|
||||
public static String getVersionName() {
|
||||
return PLUGIN_VERSION_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current installed AuthMeReloaded version code.
|
||||
*
|
||||
* @return The version code of the currently installed AuthMeReloaded instance.
|
||||
*/
|
||||
public static int getVersionCode() {
|
||||
return PLUGIN_VERSION_CODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the plugin's Settings.
|
||||
*
|
||||
* @return Settings
|
||||
*/
|
||||
public Settings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Messages instance.
|
||||
*
|
||||
* @return Messages
|
||||
*/
|
||||
|
||||
public Messages getMessages() {
|
||||
return messages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Messages instance.
|
||||
*
|
||||
* @param m Messages
|
||||
*/
|
||||
public void setMessages(Messages m) {
|
||||
this.messages = m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if players are allowed to join the server.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean canConnect() {
|
||||
return canConnect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setCanConnect.
|
||||
* Define if players are allowed to join the server.
|
||||
*
|
||||
* @param canConnect boolean
|
||||
*/
|
||||
public void setCanConnect(boolean canConnect) {
|
||||
@ -127,69 +189,246 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getInstance.
|
||||
|
||||
* @return AuthMe */
|
||||
public static AuthMe getInstance() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getSettings.
|
||||
|
||||
* @return Settings */
|
||||
public Settings getSettings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setMessages.
|
||||
* @param m Messages
|
||||
*/
|
||||
public void setMessages(Messages m) {
|
||||
this.m = m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getMessages.
|
||||
|
||||
* @return Messages */
|
||||
public Messages getMessages() {
|
||||
return m;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method onEnable.
|
||||
* Method called when the server enables the plugin.
|
||||
*
|
||||
* @see org.bukkit.plugin.Plugin#onEnable()
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
// Set the Instance
|
||||
// Set various instances
|
||||
server = getServer();
|
||||
authmeLogger = Logger.getLogger("AuthMe");
|
||||
plugin = this;
|
||||
|
||||
// Set up the permissions manager
|
||||
setupPermissionsManager();
|
||||
|
||||
// Set up and initialize the command handler
|
||||
setupCommandHandler();
|
||||
|
||||
// Set up the module manager
|
||||
setupModuleManager();
|
||||
|
||||
// Load settings and custom configurations, if it fails, stop the server due to security reasons.
|
||||
if (loadSettings()) {
|
||||
server.shutdown();
|
||||
setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Setup otherAccounts file
|
||||
this.otherAccounts = OtherAccounts.getInstance();
|
||||
|
||||
// Setup messages
|
||||
this.messages = Messages.getInstance();
|
||||
|
||||
// Set up Metrics
|
||||
setupMetrics();
|
||||
|
||||
// Set console filter
|
||||
setupConsoleFilter();
|
||||
|
||||
// AntiBot delay
|
||||
setupAntiBotDelay();
|
||||
|
||||
// Download and load GeoIp.dat file if absent
|
||||
GeoLiteAPI.isDataAvailable();
|
||||
|
||||
// Set up the mail API
|
||||
setupMailApi();
|
||||
|
||||
// Hooks
|
||||
// Check Combat Tag Plus Version
|
||||
checkCombatTagPlus();
|
||||
|
||||
// Check Multiverse
|
||||
checkMultiverse();
|
||||
|
||||
// Check Essentials
|
||||
checkEssentials();
|
||||
|
||||
// Check if the protocollib is available. If so we could listen for
|
||||
// inventory protection
|
||||
checkProtocolLib();
|
||||
// End of Hooks
|
||||
|
||||
// Do a backup on start
|
||||
new PerformBackup(plugin).doBackup(PerformBackup.BackupCause.START);
|
||||
|
||||
// Connect to the database and setup tables
|
||||
try {
|
||||
setupDatabase();
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.writeStackTrace(e);
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
ConsoleLogger.showError("Fatal error occurred during database connection! Authme initialization ABORTED!");
|
||||
stopOrUnload();
|
||||
return;
|
||||
}
|
||||
|
||||
// Setup the inventory backup
|
||||
playerBackup = new JsonCache();
|
||||
|
||||
// Set the DataManager
|
||||
dataManager = new DataManager(this);
|
||||
|
||||
// Set up the new API
|
||||
setupApi();
|
||||
|
||||
// Set up the management
|
||||
management = new Management(this);
|
||||
|
||||
// Set up the Bungeecord hook
|
||||
setupBungeecordHook();
|
||||
|
||||
// Reload support hook
|
||||
reloadSupportHook();
|
||||
|
||||
// Register event listeners
|
||||
registerEventListeners();
|
||||
|
||||
// Purge on start if enabled
|
||||
autoPurge();
|
||||
|
||||
// Start Email recall task if needed
|
||||
recallEmail();
|
||||
|
||||
// Show settings warnings
|
||||
showSettingsWarnings();
|
||||
|
||||
// Sponsor messages
|
||||
ConsoleLogger.info("AuthMe hooks perfectly with the VeryGames server hosting!");
|
||||
ConsoleLogger.info("Development builds are available on our jenkins, thanks to f14stelt.");
|
||||
ConsoleLogger.info("Do you want a good game server? Look at our sponsor GameHosting.it leader in Italy as Game Server Provider!");
|
||||
|
||||
// Successful message
|
||||
ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " correctly enabled!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the module manager.
|
||||
*/
|
||||
private void setupModuleManager() {
|
||||
// TODO: Clean this up!
|
||||
// TODO: split the plugin in more modules
|
||||
// TODO: log number of loaded modules
|
||||
|
||||
// Define the module manager instance
|
||||
moduleManager = new ModuleManager(this);
|
||||
|
||||
// Load the modules
|
||||
// int loaded = moduleManager.loadModules();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the mail API, if enabled.
|
||||
*/
|
||||
private void setupMailApi() {
|
||||
// Make sure the mail API is enabled
|
||||
if (Settings.getmailAccount.isEmpty() || Settings.getmailPassword.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Set up the mail API
|
||||
this.mail = new SendMailSSL(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the settings warnings, for various risky settings.
|
||||
*/
|
||||
private void showSettingsWarnings() {
|
||||
// Force single session disabled
|
||||
if (!Settings.isForceSingleSessionEnabled) {
|
||||
ConsoleLogger.showError("WARNING!!! By disabling ForceSingleSession, your server protection is inadequate!");
|
||||
}
|
||||
|
||||
// Session timeout disabled
|
||||
if (Settings.getSessionTimeout == 0 && Settings.isSessionsEnabled) {
|
||||
ConsoleLogger.showError("WARNING!!! You set session timeout to 0, this may cause security issues!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Register all event listeners.
|
||||
*/
|
||||
private void registerEventListeners() {
|
||||
// Get the plugin manager instance
|
||||
PluginManager pluginManager = server.getPluginManager();
|
||||
|
||||
// Register event listeners
|
||||
pluginManager.registerEvents(new AuthMePlayerListener(this), this);
|
||||
pluginManager.registerEvents(new AuthMeBlockListener(this), this);
|
||||
pluginManager.registerEvents(new AuthMeEntityListener(this), this);
|
||||
pluginManager.registerEvents(new AuthMeServerListener(this), this);
|
||||
|
||||
// Try to register 1.6 player listeners
|
||||
try {
|
||||
Class.forName("org.bukkit.event.player.PlayerEditBookEvent");
|
||||
pluginManager.registerEvents(new AuthMePlayerListener16(this), this);
|
||||
} catch (ClassNotFoundException ignore) {
|
||||
}
|
||||
|
||||
// Try to register 1.8 player listeners
|
||||
try {
|
||||
Class.forName("org.bukkit.event.player.PlayerInteractAtEntityEvent");
|
||||
pluginManager.registerEvents(new AuthMePlayerListener18(this), this);
|
||||
} catch (ClassNotFoundException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
private void reloadSupportHook() {
|
||||
if (database != null) {
|
||||
int playersOnline = Utils.getOnlinePlayers().size();
|
||||
if (playersOnline < 1) {
|
||||
database.purgeLogged();
|
||||
} else if (Settings.reloadSupport) {
|
||||
for (PlayerAuth auth : database.getLoggedPlayers()) {
|
||||
if (auth == null) {
|
||||
continue;
|
||||
}
|
||||
auth.setLastLogin(new Date().getTime());
|
||||
database.updateSession(auth);
|
||||
PlayerCache.getInstance().addPlayer(auth);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the Bungecoord hook.
|
||||
*/
|
||||
private void setupBungeecordHook() {
|
||||
if (Settings.bungee) {
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeCordMessage(this));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the API. This sets up the new and the old API.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
private void setupApi() {
|
||||
// Set up the API
|
||||
api = new NewAPI(this);
|
||||
|
||||
// Setup the old deprecated API
|
||||
new API(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set up the command handler.
|
||||
*/
|
||||
private void setupCommandHandler() {
|
||||
this.commandHandler = new CommandHandler(false);
|
||||
this.commandHandler.init();
|
||||
}
|
||||
|
||||
// TODO: split the plugin in more modules
|
||||
moduleManager = new ModuleManager(this);
|
||||
@SuppressWarnings("unused")
|
||||
int loaded = moduleManager.loadModules();
|
||||
|
||||
// TODO: remove vault as hard dependency
|
||||
PluginManager pm = server.getPluginManager();
|
||||
|
||||
// Setup the Logger
|
||||
if (authmeLogger == null)
|
||||
authmeLogger = this.getLogger();
|
||||
else authmeLogger.setParent(this.getLogger());
|
||||
|
||||
// Load settings and custom configurations
|
||||
/**
|
||||
* Load the plugin's settings.
|
||||
*
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
private boolean loadSettings() {
|
||||
// TODO: new configuration style (more files)
|
||||
try {
|
||||
settings = new Settings(this);
|
||||
@ -198,16 +437,48 @@ public class AuthMe extends JavaPlugin {
|
||||
ConsoleLogger.writeStackTrace(e);
|
||||
ConsoleLogger.showError("Can't load the configuration file... Something went wrong, to avoid security issues the server will shutdown!");
|
||||
server.shutdown();
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setup otherAccounts file
|
||||
otherAccounts = OtherAccounts.getInstance();
|
||||
/**
|
||||
* Set up the antibot delay.
|
||||
*/
|
||||
private void setupAntiBotDelay() {
|
||||
if (Settings.enableAntiBot) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
delayedAntiBot = false;
|
||||
}
|
||||
}, 2400);
|
||||
}
|
||||
}
|
||||
|
||||
// Setup messages
|
||||
m = Messages.getInstance();
|
||||
/**
|
||||
* Set up the console filter.
|
||||
*/
|
||||
private void setupConsoleFilter() {
|
||||
if (Settings.removePassword) {
|
||||
ConsoleFilter filter = new ConsoleFilter();
|
||||
ConsoleLogger.getLogger().setFilter(filter);
|
||||
Bukkit.getLogger().setFilter(filter);
|
||||
Logger.getLogger("Minecraft").setFilter(filter);
|
||||
// Set Log4J Filter
|
||||
try {
|
||||
Class.forName("org.apache.logging.log4j.core.Filter");
|
||||
setLog4JFilter();
|
||||
} catch (ClassNotFoundException | NoClassDefFoundError e) {
|
||||
ConsoleLogger.info("You're using Minecraft 1.6.x or older, Log4J support will be disabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Start the metrics service
|
||||
/**
|
||||
* Set up Metrics.
|
||||
*/
|
||||
private void setupMetrics() {
|
||||
try {
|
||||
Metrics metrics = new Metrics(this);
|
||||
Graph messagesLanguage = metrics.createGraph("Messages language");
|
||||
@ -238,155 +509,14 @@ public class AuthMe extends JavaPlugin {
|
||||
ConsoleLogger.writeStackTrace(e);
|
||||
ConsoleLogger.showError("Can't start Metrics! The plugin will work anyway...");
|
||||
}
|
||||
|
||||
// Set Console Filter
|
||||
if (Settings.removePassword) {
|
||||
ConsoleFilter filter = new ConsoleFilter();
|
||||
this.getLogger().setFilter(filter);
|
||||
Bukkit.getLogger().setFilter(filter);
|
||||
Logger.getLogger("Minecraft").setFilter(filter);
|
||||
authmeLogger.setFilter(filter);
|
||||
// Set Log4J Filter
|
||||
try {
|
||||
Class.forName("org.apache.logging.log4j.core.Filter");
|
||||
setLog4JFilter();
|
||||
} catch (ClassNotFoundException | NoClassDefFoundError e) {
|
||||
ConsoleLogger.info("You're using Minecraft 1.6.x or older, Log4J support will be disabled");
|
||||
}
|
||||
}
|
||||
|
||||
// AntiBot delay
|
||||
if (Settings.enableAntiBot) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
delayedAntiBot = false;
|
||||
}
|
||||
}, 2400);
|
||||
}
|
||||
|
||||
// Download GeoIp.dat file
|
||||
Utils.checkGeoIP();
|
||||
|
||||
// Load MailApi if needed
|
||||
if (!Settings.getmailAccount.isEmpty() && !Settings.getmailPassword.isEmpty()) {
|
||||
mail = new SendMailSSL(this);
|
||||
}
|
||||
|
||||
// Check Combat Tag Plus Version
|
||||
checkCombatTagPlus();
|
||||
|
||||
// Check Multiverse
|
||||
checkMultiverse();
|
||||
|
||||
// Check Essentials
|
||||
checkEssentials();
|
||||
|
||||
// Check if the protocollib is available. If so we could listen for
|
||||
// inventory protection
|
||||
checkProtocolLib();
|
||||
|
||||
// Do backup on start if enabled
|
||||
if (Settings.isBackupActivated && Settings.isBackupOnStart) {
|
||||
// Do backup and check return value!
|
||||
if (new PerformBackup(this).doBackup()) {
|
||||
ConsoleLogger.info("Backup performed correctly");
|
||||
} else {
|
||||
ConsoleLogger.showError("Error while performing the backup!");
|
||||
}
|
||||
}
|
||||
|
||||
// Connect to the database and setup tables
|
||||
try {
|
||||
setupDatabase();
|
||||
} catch (Exception e) {
|
||||
ConsoleLogger.writeStackTrace(e);
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
ConsoleLogger.showError("Fatal error occurred during database connection! Authme initialization ABORTED!");
|
||||
stopOrUnload();
|
||||
return;
|
||||
}
|
||||
|
||||
// Setup the inventory backup
|
||||
playerBackup = new JsonCache();
|
||||
|
||||
// Set the DataManager
|
||||
dataManager = new DataManager(this);
|
||||
|
||||
// Setup the new API
|
||||
api = new NewAPI(this);
|
||||
// Setup the old deprecated API
|
||||
new API(this);
|
||||
|
||||
// Setup Management
|
||||
management = new Management(this);
|
||||
|
||||
// Bungeecord hook
|
||||
if (Settings.bungee) {
|
||||
Bukkit.getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
Bukkit.getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new BungeeCordMessage(this));
|
||||
}
|
||||
|
||||
// Reload support hook
|
||||
if (database != null) {
|
||||
int playersOnline = Utils.getOnlinePlayers().size();
|
||||
if (playersOnline < 1) {
|
||||
database.purgeLogged();
|
||||
} else if (Settings.reloadSupport) {
|
||||
for (PlayerAuth auth : database.getLoggedPlayers()) {
|
||||
if (auth == null)
|
||||
continue;
|
||||
auth.setLastLogin(new Date().getTime());
|
||||
database.updateSession(auth);
|
||||
PlayerCache.getInstance().addPlayer(auth);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Register events
|
||||
pm.registerEvents(new AuthMePlayerListener(this), this);
|
||||
// Try to register 1.6 player listeners
|
||||
try {
|
||||
Class.forName("org.bukkit.event.player.PlayerEditBookEvent");
|
||||
pm.registerEvents(new AuthMePlayerListener16(this), this);
|
||||
} catch (ClassNotFoundException ignore) {
|
||||
}
|
||||
// Try to register 1.8 player listeners
|
||||
try {
|
||||
Class.forName("org.bukkit.event.player.PlayerInteractAtEntityEvent");
|
||||
pm.registerEvents(new AuthMePlayerListener18(this), this);
|
||||
} catch (ClassNotFoundException ignore) {
|
||||
}
|
||||
pm.registerEvents(new AuthMeBlockListener(this), this);
|
||||
pm.registerEvents(new AuthMeEntityListener(this), this);
|
||||
pm.registerEvents(new AuthMeServerListener(this), this);
|
||||
|
||||
// Purge on start if enabled
|
||||
autoPurge();
|
||||
|
||||
// Start Email recall task if needed
|
||||
recallEmail();
|
||||
|
||||
// Configuration Security Warnings
|
||||
if (!Settings.isForceSingleSessionEnabled) {
|
||||
ConsoleLogger.showError("WARNING!!! By disabling ForceSingleSession, your server protection is inadequate!");
|
||||
}
|
||||
if (Settings.getSessionTimeout == 0 && Settings.isSessionsEnabled) {
|
||||
ConsoleLogger.showError("WARNING!!! You set session timeout to 0, this may cause security issues!");
|
||||
}
|
||||
|
||||
// Sponsor messages
|
||||
ConsoleLogger.info("AuthMe hooks perfectly with the VERYGAMES server hosting!");
|
||||
ConsoleLogger.info("Development builds are available on our jenkins, thanks to f14stelt.");
|
||||
ConsoleLogger.info("Do you want a good gameserver? Look at our sponsor GameHosting.it leader in Italy as Game Server Provider!");
|
||||
|
||||
// Successful message
|
||||
ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " correctly enabled!");
|
||||
}
|
||||
// Show the exception message and stop/unload the server/plugin as defined
|
||||
// in the configuration
|
||||
|
||||
/**
|
||||
* Method onDisable.
|
||||
*
|
||||
* @see org.bukkit.plugin.Plugin#onDisable()
|
||||
*/
|
||||
@Override
|
||||
@ -400,12 +530,7 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
|
||||
// Do backup on stop if enabled
|
||||
if (Settings.isBackupActivated && Settings.isBackupOnStop) {
|
||||
boolean Backup = new PerformBackup(this).doBackup();
|
||||
if (Backup)
|
||||
ConsoleLogger.info("Backup performed correctly.");
|
||||
else ConsoleLogger.showError("Error while performing the backup!");
|
||||
}
|
||||
new PerformBackup(plugin).doBackup(PerformBackup.BackupCause.STOP);
|
||||
|
||||
// Unload modules
|
||||
moduleManager.unloadModules();
|
||||
@ -419,6 +544,8 @@ public class AuthMe extends JavaPlugin {
|
||||
ConsoleLogger.info("AuthMe " + this.getDescription().getVersion() + " disabled!");
|
||||
}
|
||||
|
||||
// Initialize and setup the database
|
||||
|
||||
// Stop/unload the server/plugin as defined in the configuration
|
||||
public void stopOrUnload() {
|
||||
if (Settings.isStopEnabled) {
|
||||
@ -429,22 +556,9 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
// Show the exception message and stop/unload the server/plugin as defined
|
||||
// in the configuration
|
||||
/**
|
||||
* Method stopOrUnload.
|
||||
* @param e Exception
|
||||
*/
|
||||
public void stopOrUnload(Exception e) {
|
||||
ConsoleLogger.showError(e.getMessage());
|
||||
stopOrUnload();
|
||||
}
|
||||
|
||||
// Initialize and setup the database
|
||||
/**
|
||||
* Method setupDatabase.
|
||||
|
||||
* @throws Exception */
|
||||
*/
|
||||
public void setupDatabase() throws Exception {
|
||||
if (database != null)
|
||||
database.close();
|
||||
@ -584,49 +698,6 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a player/command sender have a permission
|
||||
*
|
||||
* @deprecated Deprecated since v5.1. Use the permissions manager instead! See: getPermissionsManager()
|
||||
*
|
||||
* @param player
|
||||
* @param perm
|
||||
|
||||
|
||||
* @return boolean */
|
||||
public boolean authmePermissible(Player player, String perm) {
|
||||
// New code:
|
||||
return getPermissionsManager().hasPermission(player, perm);
|
||||
|
||||
// Legacy code:
|
||||
/*if (player.hasPermission(perm)) {
|
||||
return true;
|
||||
} else if (permission != null) {
|
||||
return permission.playerHas(player, perm);
|
||||
}
|
||||
return false;*/
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Deprecated since v5.1. Use the permissions manager instead! See: getPermissionsManager()
|
||||
*
|
||||
* @param sender
|
||||
* @param perm
|
||||
|
||||
|
||||
* @return boolean */
|
||||
public boolean authmePermissible(CommandSender sender, String perm) {
|
||||
// Handle players with the permissions manager
|
||||
if(sender instanceof Player) {
|
||||
// Get the player instance
|
||||
Player player = (Player) sender;
|
||||
|
||||
// Check whether the player has permission, return the result
|
||||
return getPermissionsManager().hasPermission(player, perm);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Save Player Data
|
||||
public void savePlayer(Player player) {
|
||||
if ((Utils.isNPC(player)) || (Utils.isUnrestricted(player))) {
|
||||
@ -754,12 +825,12 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
|
||||
public void switchAntiBotMod(boolean mode) {
|
||||
this.antibotMod = mode;
|
||||
this.antiBotMod = mode;
|
||||
Settings.switchAntiBotMod(mode);
|
||||
}
|
||||
|
||||
public boolean getAntiBotModMode() {
|
||||
return this.antibotMod;
|
||||
return this.antiBotMod;
|
||||
}
|
||||
|
||||
private void recallEmail() {
|
||||
@ -776,7 +847,7 @@ public class AuthMe extends JavaPlugin {
|
||||
if (PlayerCache.getInstance().isAuthenticated(name)) {
|
||||
String email = database.getAuth(name).getEmail();
|
||||
if (email == null || email.isEmpty() || email.equalsIgnoreCase("your@email.com"))
|
||||
m.send(player, "add_email");
|
||||
messages.send(player, "add_email");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -784,7 +855,6 @@ public class AuthMe extends JavaPlugin {
|
||||
}, 1, 1200 * Settings.delayRecall);
|
||||
}
|
||||
|
||||
|
||||
public String replaceAllInfos(String message, Player player) {
|
||||
int playersOnline = Utils.getOnlinePlayers().size();
|
||||
message = message.replace("&", "\u00a7");
|
||||
@ -796,11 +866,10 @@ public class AuthMe extends JavaPlugin {
|
||||
message = message.replace("{WORLD}", player.getWorld().getName());
|
||||
message = message.replace("{SERVER}", server.getServerName());
|
||||
message = message.replace("{VERSION}", server.getBukkitVersion());
|
||||
message = message.replace("{COUNTRY}", Utils.getCountryName(getIP(player)));
|
||||
message = message.replace("{COUNTRY}", GeoLiteAPI.getCountryName(getIP(player)));
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
public String getIP(Player player) {
|
||||
String name = player.getName().toLowerCase();
|
||||
String ip = player.getAddress().getAddress().getHostAddress();
|
||||
@ -814,7 +883,6 @@ public class AuthMe extends JavaPlugin {
|
||||
return ip;
|
||||
}
|
||||
|
||||
|
||||
public boolean isLoggedIp(String name, String ip) {
|
||||
int count = 0;
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
@ -824,7 +892,6 @@ public class AuthMe extends JavaPlugin {
|
||||
return count >= Settings.getMaxLoginPerIp;
|
||||
}
|
||||
|
||||
|
||||
public boolean hasJoinedIp(String name, String ip) {
|
||||
int count = 0;
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
@ -834,7 +901,6 @@ public class AuthMe extends JavaPlugin {
|
||||
return count >= Settings.getMaxJoinPerIp;
|
||||
}
|
||||
|
||||
|
||||
public ModuleManager getModuleManager() {
|
||||
return moduleManager;
|
||||
}
|
||||
@ -843,7 +909,6 @@ 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
|
||||
*/
|
||||
@Deprecated
|
||||
@ -864,19 +929,6 @@ public class AuthMe extends JavaPlugin {
|
||||
return realIP;
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public String getCountryCode(String ip) {
|
||||
return Utils.getCountryCode(ip);
|
||||
}
|
||||
|
||||
|
||||
@Deprecated
|
||||
public String getCountryName(String ip) {
|
||||
return Utils.getCountryName(ip);
|
||||
}
|
||||
|
||||
|
||||
public CommandHandler getCommandHandler() {
|
||||
return this.commandHandler;
|
||||
}
|
||||
@ -884,15 +936,10 @@ public class AuthMe extends JavaPlugin {
|
||||
/**
|
||||
* Handle Bukkit commands.
|
||||
*
|
||||
* @param sender
|
||||
* The command sender (Bukkit).
|
||||
* @param cmd
|
||||
* The command (Bukkit).
|
||||
* @param commandLabel
|
||||
* The command label (Bukkit).
|
||||
* @param args
|
||||
* The command arguments (Bukkit).
|
||||
*
|
||||
* @param sender The command sender (Bukkit).
|
||||
* @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
|
||||
@ -908,37 +955,20 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current installed AuthMeReloaded version name.
|
||||
*
|
||||
* @return The version name of the currently installed AuthMeReloaded
|
||||
* instance.
|
||||
* Returns the management instance.
|
||||
*/
|
||||
public static String getVersionName() {
|
||||
return PLUGIN_VERSION_NAME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current installed AuthMeReloaded version code.
|
||||
*
|
||||
* @return The version code of the currently installed AuthMeReloaded
|
||||
* instance.
|
||||
*/
|
||||
public static int getVersionCode() {
|
||||
return PLUGIN_VERSION_CODE;
|
||||
}
|
||||
|
||||
/** Returns the management instance. */
|
||||
public Management getManagement() {
|
||||
return management;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the server instance running this plugin. Use this method in favor of
|
||||
* {@link AuthMe#getServer()} for testability purposes.
|
||||
* Returns the server instance running this plugin. Use this method in favor of {@link
|
||||
* AuthMe#getServer()} for testability purposes.
|
||||
*
|
||||
* @return the server instance
|
||||
*/
|
||||
public Server getGameServer() {
|
||||
return super.getServer();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import java.util.logging.Filter;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
/**
|
||||
* Console filter Class
|
||||
*
|
||||
* @author Xephi59
|
||||
* @version $Revision: 1.0 $
|
||||
@ -15,10 +16,10 @@ public class ConsoleFilter implements Filter {
|
||||
|
||||
/**
|
||||
* Method isLoggable.
|
||||
*
|
||||
* @param record LogRecord
|
||||
|
||||
|
||||
* @return boolean * @see java.util.logging.Filter#isLoggable(LogRecord) */
|
||||
* @return boolean * @see java.util.logging.Filter#isLoggable(LogRecord)
|
||||
*/
|
||||
@Override
|
||||
public boolean isLoggable(LogRecord record) {
|
||||
try {
|
||||
|
@ -1,5 +1,9 @@
|
||||
package fr.xephi.authme;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
@ -8,12 +12,8 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.google.common.base.Throwables;
|
||||
|
||||
import fr.xephi.authme.api.NewAPI;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
/**
|
||||
* The plugin's static logger.
|
||||
*/
|
||||
public class ConsoleLogger {
|
||||
|
||||
@ -21,42 +21,52 @@ public class ConsoleLogger {
|
||||
private static final DateFormat df = new SimpleDateFormat("[MM-dd HH:mm:ss]");
|
||||
|
||||
/**
|
||||
* Method info.
|
||||
* Returns the plugin's logger.
|
||||
*
|
||||
* @return Logger
|
||||
*/
|
||||
public static Logger getLogger() {
|
||||
return log;
|
||||
}
|
||||
|
||||
/**
|
||||
* Print an info message.
|
||||
*
|
||||
* @param message String
|
||||
*/
|
||||
public static void info(String message) {
|
||||
log.info("[AuthMe] " + message);
|
||||
if (Settings.useLogging) {
|
||||
String dateTime;
|
||||
synchronized (df) {
|
||||
dateTime = df.format(new Date());
|
||||
}
|
||||
writeLog(dateTime + " " + message);
|
||||
log.info(message);
|
||||
if (!Settings.useLogging) {
|
||||
return;
|
||||
}
|
||||
writeLog("" + message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method showError.
|
||||
* Print an error message.
|
||||
*
|
||||
* @param message String
|
||||
*/
|
||||
public static void showError(String message) {
|
||||
log.warning("[AuthMe] " + message);
|
||||
if (Settings.useLogging) {
|
||||
log.warning(message);
|
||||
if (!Settings.useLogging) {
|
||||
return;
|
||||
}
|
||||
writeLog("ERROR: " + message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write a message into the log file with a TimeStamp.
|
||||
*
|
||||
* @param message String
|
||||
*/
|
||||
private static void writeLog(String message) {
|
||||
String dateTime;
|
||||
synchronized (df) {
|
||||
dateTime = df.format(new Date());
|
||||
}
|
||||
writeLog(dateTime + " ERROR: " + message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method writeLog.
|
||||
* @param message String
|
||||
*/
|
||||
public static void writeLog(String message) {
|
||||
try {
|
||||
Files.write(Settings.LOG_FILE.toPath(), (message + NewAPI.newline).getBytes(),
|
||||
Files.write(Settings.LOG_FILE.toPath(), (dateTime + ": " + message + StringUtils.newline).getBytes(),
|
||||
StandardOpenOption.APPEND,
|
||||
StandardOpenOption.CREATE);
|
||||
} catch (IOException ignored) {
|
||||
@ -64,16 +74,14 @@ public class ConsoleLogger {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method writeStackTrace.
|
||||
* Write a StackTrace into the log.
|
||||
*
|
||||
* @param ex Exception
|
||||
*/
|
||||
public static void writeStackTrace(Exception ex) {
|
||||
if (Settings.useLogging) {
|
||||
String dateTime;
|
||||
synchronized (df) {
|
||||
dateTime = df.format(new Date());
|
||||
}
|
||||
writeLog(dateTime + " " + Throwables.getStackTraceAsString(ex));
|
||||
if (!Settings.useLogging) {
|
||||
return;
|
||||
}
|
||||
writeLog("" + Throwables.getStackTraceAsString(ex));
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,12 @@
|
||||
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;
|
||||
@ -7,14 +14,6 @@ import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class DataManager {
|
||||
@ -23,6 +22,7 @@ public class DataManager {
|
||||
|
||||
/**
|
||||
* Constructor for DataManager.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public DataManager(AuthMe plugin) {
|
||||
@ -34,9 +34,10 @@ public class DataManager {
|
||||
|
||||
/**
|
||||
* Method getOfflinePlayer.
|
||||
*
|
||||
* @param name String
|
||||
|
||||
* @return OfflinePlayer */
|
||||
* @return OfflinePlayer
|
||||
*/
|
||||
public synchronized OfflinePlayer getOfflinePlayer(final String name) {
|
||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
||||
Future<OfflinePlayer> result = executor.submit(new Callable<OfflinePlayer>() {
|
||||
@ -65,6 +66,7 @@ public class DataManager {
|
||||
|
||||
/**
|
||||
* Method purgeAntiXray.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
public synchronized void purgeAntiXray(List<String> cleared) {
|
||||
@ -88,6 +90,7 @@ public class DataManager {
|
||||
|
||||
/**
|
||||
* Method purgeLimitedCreative.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
public synchronized void purgeLimitedCreative(List<String> cleared) {
|
||||
@ -121,6 +124,7 @@ public class DataManager {
|
||||
|
||||
/**
|
||||
* Method purgeDat.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
public synchronized void purgeDat(List<String> cleared) {
|
||||
@ -151,6 +155,7 @@ public class DataManager {
|
||||
|
||||
/**
|
||||
* Method purgeEssentials.
|
||||
*
|
||||
* @param cleared List<String>
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -173,6 +178,7 @@ public class DataManager {
|
||||
}
|
||||
|
||||
// TODO: What is this method for? Is it correct?
|
||||
|
||||
/**
|
||||
* @param cleared Cleared players.
|
||||
*/
|
||||
@ -209,10 +215,11 @@ public class DataManager {
|
||||
|
||||
/**
|
||||
* Method isOnline.
|
||||
*
|
||||
* @param player Player
|
||||
* @param name String
|
||||
|
||||
* @return boolean */
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isOnline(Player player, final String name) {
|
||||
if (player.isOnline())
|
||||
return true;
|
||||
@ -239,9 +246,10 @@ public class DataManager {
|
||||
|
||||
/**
|
||||
* Method getOnlinePlayerLower.
|
||||
*
|
||||
* @param name String
|
||||
|
||||
* @return Player */
|
||||
* @return Player
|
||||
*/
|
||||
public Player getOnlinePlayerLower(String name) {
|
||||
name = name.toLowerCase();
|
||||
for (Player player : Utils.getOnlinePlayers()) {
|
||||
|
@ -1,9 +1,6 @@
|
||||
package fr.xephi.authme;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.awt.GradientPaint;
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
|
||||
/**
|
||||
@ -11,8 +8,10 @@ import java.awt.image.BufferedImage;
|
||||
public class ImageGenerator {
|
||||
|
||||
private String pass;
|
||||
|
||||
/**
|
||||
* Constructor for ImageGenerator.
|
||||
*
|
||||
* @param pass String
|
||||
*/
|
||||
public ImageGenerator(String pass) {
|
||||
@ -21,8 +20,9 @@ public class ImageGenerator {
|
||||
|
||||
/**
|
||||
* Method generateImage.
|
||||
|
||||
* @return BufferedImage */
|
||||
*
|
||||
* @return BufferedImage
|
||||
*/
|
||||
public BufferedImage generateImage() {
|
||||
BufferedImage image = new BufferedImage(200, 60, BufferedImage.TYPE_BYTE_INDEXED);
|
||||
Graphics2D graphics = image.createGraphics();
|
||||
|
@ -1,29 +1,68 @@
|
||||
package fr.xephi.authme;
|
||||
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import org.apache.logging.log4j.Level;
|
||||
import org.apache.logging.log4j.Marker;
|
||||
import org.apache.logging.log4j.core.LogEvent;
|
||||
import org.apache.logging.log4j.core.Logger;
|
||||
import org.apache.logging.log4j.message.Message;
|
||||
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Implements a filter for Log4j to skip sensitive AuthMe commands.
|
||||
*
|
||||
* @author Xephi59
|
||||
* @version $Revision: 1.0 $
|
||||
*/
|
||||
public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
|
||||
|
||||
/** List of commands (lower-case) to skip. */
|
||||
/**
|
||||
* List of commands (lower-case) to skip.
|
||||
*/
|
||||
private static final String[] COMMANDS_TO_SKIP = {"/login ", "/l ", "/reg ", "/changepassword ",
|
||||
"/unregister ", "/authme register ", "/authme changepassword ", "/authme reg ", "/authme cp ",
|
||||
"/register "};
|
||||
|
||||
/** Constructor. */
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public Log4JFilter() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a Message instance and returns the {@link Result} value
|
||||
* depending depending on whether the message contains sensitive AuthMe
|
||||
* data.
|
||||
*
|
||||
* @param message the Message object to verify
|
||||
* @return the Result value
|
||||
*/
|
||||
private static Result validateMessage(Message message) {
|
||||
if (message == null) {
|
||||
return Result.NEUTRAL;
|
||||
}
|
||||
return validateMessage(message.getFormattedMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a message and returns the {@link Result} value depending
|
||||
* 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) {
|
||||
if (message == null) {
|
||||
return Result.NEUTRAL;
|
||||
}
|
||||
|
||||
String lowerMessage = message.toLowerCase();
|
||||
if (lowerMessage.contains("issued server command:")
|
||||
&& StringUtils.containsAny(lowerMessage, COMMANDS_TO_SKIP)) {
|
||||
return Result.DENY;
|
||||
}
|
||||
return Result.NEUTRAL;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result filter(LogEvent record) {
|
||||
if (record == null) {
|
||||
@ -63,41 +102,4 @@ public class Log4JFilter implements org.apache.logging.log4j.core.Filter {
|
||||
return Result.NEUTRAL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a Message instance and returns the {@link Result} value
|
||||
* depending depending on whether the message contains sensitive AuthMe
|
||||
* data.
|
||||
*
|
||||
* @param message the Message object to verify
|
||||
*
|
||||
* @return the Result value
|
||||
*/
|
||||
private static Result validateMessage(Message message) {
|
||||
if (message == null) {
|
||||
return Result.NEUTRAL;
|
||||
}
|
||||
return validateMessage(message.getFormattedMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates a message and returns the {@link Result} value depending
|
||||
* 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) {
|
||||
if (message == null) {
|
||||
return Result.NEUTRAL;
|
||||
}
|
||||
|
||||
String lowerMessage = message.toLowerCase();
|
||||
if (lowerMessage.contains("issued server command:")
|
||||
&& StringUtils.containsAny(lowerMessage, COMMANDS_TO_SKIP)) {
|
||||
return Result.DENY;
|
||||
}
|
||||
return Result.NEUTRAL;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,34 +1,31 @@
|
||||
package fr.xephi.authme;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
import java.io.*;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* The backup management class
|
||||
*
|
||||
* @author stefano
|
||||
* @version $Revision: 1.0 $
|
||||
*/
|
||||
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;
|
||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd_HH-mm");
|
||||
String dateString = format.format(new Date());
|
||||
private String path = AuthMe.getInstance().getDataFolder() + File.separator + "backups" + File.separator + "backup" + dateString;
|
||||
private AuthMe instance;
|
||||
|
||||
/**
|
||||
* Constructor for PerformBackup.
|
||||
*
|
||||
* @param instance AuthMe
|
||||
*/
|
||||
public PerformBackup(AuthMe instance) {
|
||||
@ -36,9 +33,34 @@ public class PerformBackup {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method doBackup.
|
||||
*
|
||||
*/
|
||||
public void doBackup(BackupCause cause) {
|
||||
// Check whether a backup should be made at the specified point in time
|
||||
switch (cause) {
|
||||
case START:
|
||||
if (!Settings.isBackupOnStart)
|
||||
return;
|
||||
case STOP:
|
||||
if (!Settings.isBackupOnStop)
|
||||
return;
|
||||
case COMMAND:
|
||||
case OTHER:
|
||||
}
|
||||
|
||||
* @return boolean */
|
||||
// Do backup and check return value!
|
||||
if (doBackup()) {
|
||||
ConsoleLogger.info("A backup has been performed successfully");
|
||||
} else {
|
||||
ConsoleLogger.showError("Error while performing a backup!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method doBackup.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean doBackup() {
|
||||
|
||||
switch (Settings.getDataSource) {
|
||||
@ -55,8 +77,9 @@ public class PerformBackup {
|
||||
|
||||
/**
|
||||
* Method MySqlBackup.
|
||||
|
||||
* @return boolean */
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private boolean MySqlBackup() {
|
||||
File dirBackup = new File(AuthMe.getInstance().getDataFolder() + "/backups");
|
||||
|
||||
@ -98,9 +121,10 @@ public class PerformBackup {
|
||||
|
||||
/**
|
||||
* Method FileBackup.
|
||||
*
|
||||
* @param backend String
|
||||
|
||||
* @return boolean */
|
||||
* @return boolean
|
||||
*/
|
||||
private boolean FileBackup(String backend) {
|
||||
File dirBackup = new File(AuthMe.getInstance().getDataFolder() + "/backups");
|
||||
|
||||
@ -117,15 +141,12 @@ public class PerformBackup {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if we are under Windows and correct location of mysqldump.exe
|
||||
* otherwise return error.
|
||||
*/
|
||||
/**
|
||||
* Method checkWindows.
|
||||
*
|
||||
* @param windowsPath String
|
||||
|
||||
* @return boolean */
|
||||
* @return boolean
|
||||
*/
|
||||
private boolean checkWindows(String windowsPath) {
|
||||
String isWin = System.getProperty("os.name").toLowerCase();
|
||||
if (isWin.indexOf("win") >= 0) {
|
||||
@ -139,14 +160,17 @@ public class PerformBackup {
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyr src bytefile into dst file
|
||||
* Check if we are under Windows and correct location of mysqldump.exe
|
||||
* otherwise return error.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Method copy.
|
||||
*
|
||||
* @param src File
|
||||
* @param dst File
|
||||
|
||||
* @throws IOException */
|
||||
* @throws IOException
|
||||
*/
|
||||
void copy(File src, File dst) throws IOException {
|
||||
InputStream in = new FileInputStream(src);
|
||||
OutputStream out = new FileOutputStream(dst);
|
||||
@ -161,8 +185,22 @@ public class PerformBackup {
|
||||
out.close();
|
||||
}
|
||||
|
||||
/*
|
||||
* Copyr src bytefile into dst file
|
||||
*/
|
||||
|
||||
/**
|
||||
* Method getInstance.
|
||||
*
|
||||
* @return AuthMe
|
||||
*/
|
||||
public AuthMe getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setInstance.
|
||||
*
|
||||
* @param instance AuthMe
|
||||
*/
|
||||
public void setInstance(AuthMe instance) {
|
||||
@ -170,11 +208,13 @@ public class PerformBackup {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getInstance.
|
||||
|
||||
* @return AuthMe */
|
||||
public AuthMe getInstance() {
|
||||
return instance;
|
||||
* Possible backup causes.
|
||||
*/
|
||||
public enum BackupCause {
|
||||
START,
|
||||
STOP,
|
||||
COMMAND,
|
||||
OTHER,
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,19 +1,16 @@
|
||||
package fr.xephi.authme;
|
||||
|
||||
import java.io.File;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.apache.commons.mail.HtmlEmail;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import javax.activation.DataSource;
|
||||
import javax.activation.FileDataSource;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import org.apache.commons.mail.HtmlEmail;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
* @version $Revision: 1.0 $
|
||||
*/
|
||||
@ -23,6 +20,7 @@ public class SendMailSSL {
|
||||
|
||||
/**
|
||||
* Constructor for SendMailSSL.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public SendMailSSL(AuthMe plugin) {
|
||||
@ -31,6 +29,7 @@ public class SendMailSSL {
|
||||
|
||||
/**
|
||||
* Method main.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
* @param newPass String
|
||||
*/
|
||||
|
@ -1,19 +1,18 @@
|
||||
package fr.xephi.authme.api;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -24,6 +23,7 @@ public class API {
|
||||
|
||||
/**
|
||||
* Constructor for API.
|
||||
*
|
||||
* @param instance AuthMe
|
||||
*/
|
||||
@Deprecated
|
||||
@ -34,8 +34,8 @@ public class API {
|
||||
/**
|
||||
* Hook into AuthMe
|
||||
*
|
||||
|
||||
* @return AuthMe instance */
|
||||
* @return AuthMe instance
|
||||
*/
|
||||
@Deprecated
|
||||
public static AuthMe hookAuthMe() {
|
||||
if (instance != null)
|
||||
@ -49,49 +49,18 @@ public class API {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getPlugin.
|
||||
|
||||
* @return AuthMe */
|
||||
@Deprecated
|
||||
public AuthMe getPlugin() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
|
||||
* @return true if player is authenticate */
|
||||
* @return true if player is authenticate
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isAuthenticated(Player player) {
|
||||
return PlayerCache.getInstance().isAuthenticated(player.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
|
||||
* @return true if player is a npc */
|
||||
@Deprecated
|
||||
public boolean isaNPC(Player player) {
|
||||
return Utils.isNPC(player);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
|
||||
* @return true if player is a npc */
|
||||
@Deprecated
|
||||
public boolean isNPC(Player player) {
|
||||
return Utils.isNPC(player);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
|
||||
* @return true if the player is unrestricted */
|
||||
* @return true if the player is unrestricted
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isUnrestricted(Player player) {
|
||||
return Utils.isUnrestricted(player);
|
||||
@ -99,9 +68,10 @@ public class API {
|
||||
|
||||
/**
|
||||
* Method getLastLocation.
|
||||
*
|
||||
* @param player Player
|
||||
|
||||
* @return Location */
|
||||
* @return Location
|
||||
*/
|
||||
@Deprecated
|
||||
public static Location getLastLocation(Player player) {
|
||||
try {
|
||||
@ -121,6 +91,7 @@ public class API {
|
||||
|
||||
/**
|
||||
* Method setPlayerInventory.
|
||||
*
|
||||
* @param player Player
|
||||
* @param content ItemStack[]
|
||||
* @param armor ItemStack[]
|
||||
@ -136,10 +107,9 @@ public class API {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param playerName
|
||||
|
||||
* @return true if player is registered */
|
||||
* @return true if player is registered
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean isRegistered(String playerName) {
|
||||
String player = playerName.toLowerCase();
|
||||
@ -147,11 +117,10 @@ public class API {
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
|
||||
* @param playerName String
|
||||
* @param passwordToCheck String
|
||||
* @return true if the password is correct , false else */
|
||||
* @return true if the password is correct , false else
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean checkPassword(String playerName,
|
||||
String passwordToCheck) {
|
||||
@ -169,11 +138,10 @@ public class API {
|
||||
/**
|
||||
* Register a player
|
||||
*
|
||||
|
||||
|
||||
* @param playerName String
|
||||
* @param password String
|
||||
* @return true if the player is register correctly */
|
||||
* @return true if the player is register correctly
|
||||
*/
|
||||
@Deprecated
|
||||
public static boolean registerPlayer(String playerName, String password) {
|
||||
try {
|
||||
@ -195,7 +163,6 @@ public class API {
|
||||
/**
|
||||
* Force a player to login
|
||||
*
|
||||
|
||||
* @param player * player
|
||||
*/
|
||||
@Deprecated
|
||||
@ -203,4 +170,32 @@ public class API {
|
||||
instance.management.performLogin(player, "dontneed", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getPlugin.
|
||||
*
|
||||
* @return AuthMe
|
||||
*/
|
||||
@Deprecated
|
||||
public AuthMe getPlugin() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @return true if player is a npc
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isaNPC(Player player) {
|
||||
return Utils.isNPC(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @return true if player is a npc
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isNPC(Player player) {
|
||||
return Utils.isNPC(player);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,30 +1,29 @@
|
||||
package fr.xephi.authme.api;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class NewAPI {
|
||||
|
||||
public static final String newline = System.getProperty("line.separator");
|
||||
public static NewAPI singleton;
|
||||
public AuthMe plugin;
|
||||
|
||||
/**
|
||||
* Constructor for NewAPI.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public NewAPI(AuthMe plugin) {
|
||||
@ -33,6 +32,7 @@ public class NewAPI {
|
||||
|
||||
/**
|
||||
* Constructor for NewAPI.
|
||||
*
|
||||
* @param serv Server
|
||||
*/
|
||||
public NewAPI(Server serv) {
|
||||
@ -42,8 +42,8 @@ public class NewAPI {
|
||||
/**
|
||||
* Hook into AuthMe
|
||||
*
|
||||
|
||||
* @return AuthMe plugin */
|
||||
* @return AuthMe plugin
|
||||
*/
|
||||
public static NewAPI getInstance() {
|
||||
if (singleton != null)
|
||||
return singleton;
|
||||
@ -58,44 +58,43 @@ public class NewAPI {
|
||||
|
||||
/**
|
||||
* Method getPlugin.
|
||||
|
||||
* @return AuthMe */
|
||||
*
|
||||
* @return AuthMe
|
||||
*/
|
||||
public AuthMe getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
|
||||
* @return true if player is authenticate */
|
||||
* @return true if player is authenticate
|
||||
*/
|
||||
public boolean isAuthenticated(Player player) {
|
||||
return PlayerCache.getInstance().isAuthenticated(player.getName());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
|
||||
* @return true if player is a npc */
|
||||
* @return true if player is a npc
|
||||
*/
|
||||
public boolean isNPC(Player player) {
|
||||
return Utils.isNPC(player);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
|
||||
* @return true if the player is unrestricted */
|
||||
* @return true if the player is unrestricted
|
||||
*/
|
||||
public boolean isUnrestricted(Player player) {
|
||||
return Utils.isUnrestricted(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getLastLocation.
|
||||
*
|
||||
* @param player Player
|
||||
|
||||
* @return Location */
|
||||
* @return Location
|
||||
*/
|
||||
public Location getLastLocation(Player player) {
|
||||
try {
|
||||
PlayerAuth auth = PlayerCache.getInstance().getAuth(player.getName().toLowerCase());
|
||||
@ -112,21 +111,19 @@ public class NewAPI {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param playerName
|
||||
|
||||
* @return true if player is registered */
|
||||
* @return true if player is registered
|
||||
*/
|
||||
public boolean isRegistered(String playerName) {
|
||||
String player = playerName.toLowerCase();
|
||||
return plugin.database.isAuthAvailable(player);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
|
||||
* @param playerName String
|
||||
* @param passwordToCheck String
|
||||
* @return true if the password is correct , false else */
|
||||
* @return true if the password is correct , false else
|
||||
*/
|
||||
public boolean checkPassword(String playerName, String passwordToCheck) {
|
||||
if (!isRegistered(playerName))
|
||||
return false;
|
||||
@ -142,11 +139,10 @@ public class NewAPI {
|
||||
/**
|
||||
* Register a player
|
||||
*
|
||||
|
||||
|
||||
* @param playerName String
|
||||
* @param password String
|
||||
* @return true if the player is register correctly */
|
||||
* @return true if the player is register correctly
|
||||
*/
|
||||
public boolean registerPlayer(String playerName, String password) {
|
||||
try {
|
||||
String name = playerName.toLowerCase();
|
||||
@ -164,7 +160,6 @@ public class NewAPI {
|
||||
/**
|
||||
* Force a player to login
|
||||
*
|
||||
|
||||
* @param player * player
|
||||
*/
|
||||
public void forceLogin(Player player) {
|
||||
@ -174,35 +169,28 @@ public class NewAPI {
|
||||
/**
|
||||
* Force a player to logout
|
||||
*
|
||||
|
||||
* @param player * player
|
||||
*/
|
||||
public void forceLogout(Player player)
|
||||
{
|
||||
public void forceLogout(Player player) {
|
||||
plugin.management.performLogout(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Force a player to register
|
||||
*
|
||||
|
||||
|
||||
* @param player * player
|
||||
* @param password String
|
||||
*/
|
||||
public void forceRegister(Player player, String password)
|
||||
{
|
||||
public void forceRegister(Player player, String password) {
|
||||
plugin.management.performRegister(player, password, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Force a player to unregister
|
||||
*
|
||||
|
||||
* @param player * player
|
||||
*/
|
||||
public void forceUnregister(Player player)
|
||||
{
|
||||
public void forceUnregister(Player player) {
|
||||
plugin.management.performUnregister(player, "", true);
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,7 @@ public class PlayerAuth {
|
||||
|
||||
/**
|
||||
* Constructor for PlayerAuth.
|
||||
*
|
||||
* @param nickname String
|
||||
* @param ip String
|
||||
* @param lastLogin long
|
||||
@ -33,6 +34,7 @@ public class PlayerAuth {
|
||||
|
||||
/**
|
||||
* Constructor for PlayerAuth.
|
||||
*
|
||||
* @param nickname String
|
||||
* @param x double
|
||||
* @param y double
|
||||
@ -46,6 +48,7 @@ public class PlayerAuth {
|
||||
|
||||
/**
|
||||
* Constructor for PlayerAuth.
|
||||
*
|
||||
* @param nickname String
|
||||
* @param hash String
|
||||
* @param ip String
|
||||
@ -58,6 +61,7 @@ public class PlayerAuth {
|
||||
|
||||
/**
|
||||
* Constructor for PlayerAuth.
|
||||
*
|
||||
* @param nickname String
|
||||
* @param hash String
|
||||
* @param ip String
|
||||
@ -71,6 +75,7 @@ public class PlayerAuth {
|
||||
|
||||
/**
|
||||
* Constructor for PlayerAuth.
|
||||
*
|
||||
* @param nickname String
|
||||
* @param hash String
|
||||
* @param salt String
|
||||
@ -84,6 +89,7 @@ public class PlayerAuth {
|
||||
|
||||
/**
|
||||
* Constructor for PlayerAuth.
|
||||
*
|
||||
* @param nickname String
|
||||
* @param hash String
|
||||
* @param ip String
|
||||
@ -101,6 +107,7 @@ public class PlayerAuth {
|
||||
|
||||
/**
|
||||
* Constructor for PlayerAuth.
|
||||
*
|
||||
* @param nickname String
|
||||
* @param hash String
|
||||
* @param salt String
|
||||
@ -119,6 +126,7 @@ public class PlayerAuth {
|
||||
|
||||
/**
|
||||
* Constructor for PlayerAuth.
|
||||
*
|
||||
* @param nickname String
|
||||
* @param hash String
|
||||
* @param salt String
|
||||
@ -133,6 +141,7 @@ public class PlayerAuth {
|
||||
|
||||
/**
|
||||
* Constructor for PlayerAuth.
|
||||
*
|
||||
* @param nickname String
|
||||
* @param hash String
|
||||
* @param salt String
|
||||
@ -163,6 +172,7 @@ public class PlayerAuth {
|
||||
|
||||
/**
|
||||
* Method set.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
*/
|
||||
public void set(PlayerAuth auth) {
|
||||
@ -181,6 +191,7 @@ public class PlayerAuth {
|
||||
|
||||
/**
|
||||
* Method setName.
|
||||
*
|
||||
* @param nickname String
|
||||
*/
|
||||
public void setName(String nickname) {
|
||||
@ -189,22 +200,25 @@ public class PlayerAuth {
|
||||
|
||||
/**
|
||||
* Method getNickname.
|
||||
|
||||
* @return String */
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getNickname() {
|
||||
return nickname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getRealName.
|
||||
|
||||
* @return String */
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getRealName() {
|
||||
return realName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setRealName.
|
||||
*
|
||||
* @param realName String
|
||||
*/
|
||||
public void setRealName(String realName) {
|
||||
@ -213,14 +227,25 @@ public class PlayerAuth {
|
||||
|
||||
/**
|
||||
* Method getGroupId.
|
||||
|
||||
* @return int */
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getQuitLocX.
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public double getQuitLocX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setQuitLocX.
|
||||
*
|
||||
* @param d double
|
||||
*/
|
||||
public void setQuitLocX(double d) {
|
||||
@ -228,15 +253,17 @@ public class PlayerAuth {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getQuitLocX.
|
||||
|
||||
* @return double */
|
||||
public double getQuitLocX() {
|
||||
return x;
|
||||
* Method getQuitLocY.
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public double getQuitLocY() {
|
||||
return y;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setQuitLocY.
|
||||
*
|
||||
* @param d double
|
||||
*/
|
||||
public void setQuitLocY(double d) {
|
||||
@ -244,15 +271,17 @@ public class PlayerAuth {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getQuitLocY.
|
||||
|
||||
* @return double */
|
||||
public double getQuitLocY() {
|
||||
return y;
|
||||
* Method getQuitLocZ.
|
||||
*
|
||||
* @return double
|
||||
*/
|
||||
public double getQuitLocZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setQuitLocZ.
|
||||
*
|
||||
* @param d double
|
||||
*/
|
||||
public void setQuitLocZ(double d) {
|
||||
@ -260,15 +289,17 @@ public class PlayerAuth {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getQuitLocZ.
|
||||
|
||||
* @return double */
|
||||
public double getQuitLocZ() {
|
||||
return z;
|
||||
* Method getWorld.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setWorld.
|
||||
*
|
||||
* @param world String
|
||||
*/
|
||||
public void setWorld(String world) {
|
||||
@ -276,15 +307,17 @@ public class PlayerAuth {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getWorld.
|
||||
|
||||
* @return String */
|
||||
public String getWorld() {
|
||||
return world;
|
||||
* Method getIp.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setIp.
|
||||
*
|
||||
* @param ip String
|
||||
*/
|
||||
public void setIp(String ip) {
|
||||
@ -292,15 +325,17 @@ public class PlayerAuth {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getIp.
|
||||
|
||||
* @return String */
|
||||
public String getIp() {
|
||||
return ip;
|
||||
* Method getLastLogin.
|
||||
*
|
||||
* @return long
|
||||
*/
|
||||
public long getLastLogin() {
|
||||
return lastLogin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setLastLogin.
|
||||
*
|
||||
* @param lastLogin long
|
||||
*/
|
||||
public void setLastLogin(long lastLogin) {
|
||||
@ -308,15 +343,17 @@ public class PlayerAuth {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getLastLogin.
|
||||
|
||||
* @return long */
|
||||
public long getLastLogin() {
|
||||
return lastLogin;
|
||||
* Method getEmail.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setEmail.
|
||||
*
|
||||
* @param email String
|
||||
*/
|
||||
public void setEmail(String email) {
|
||||
@ -324,41 +361,28 @@ public class PlayerAuth {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getEmail.
|
||||
|
||||
* @return String */
|
||||
public String getEmail() {
|
||||
return email;
|
||||
* Method getSalt.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getSalt() {
|
||||
return this.salt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setSalt.
|
||||
*
|
||||
* @param salt String
|
||||
*/
|
||||
public void setSalt(String salt) {
|
||||
this.salt = salt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getSalt.
|
||||
|
||||
* @return String */
|
||||
public String getSalt() {
|
||||
return this.salt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setHash.
|
||||
* @param hash String
|
||||
*/
|
||||
public void setHash(String hash) {
|
||||
this.hash = hash;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getHash.
|
||||
|
||||
* @return String */
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getHash() {
|
||||
if (Settings.getPasswordHash == HashAlgorithm.MD5VB) {
|
||||
if (salt != null && !salt.isEmpty() && Settings.getPasswordHash == HashAlgorithm.MD5VB) {
|
||||
@ -369,10 +393,20 @@ public class PlayerAuth {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method equals.
|
||||
* @param obj Object
|
||||
* Method setHash.
|
||||
*
|
||||
* @param hash String
|
||||
*/
|
||||
public void setHash(String hash) {
|
||||
this.hash = hash;
|
||||
}
|
||||
|
||||
* @return boolean */
|
||||
/**
|
||||
* Method equals.
|
||||
*
|
||||
* @param obj Object
|
||||
* @return boolean
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof PlayerAuth)) {
|
||||
@ -384,8 +418,9 @@ public class PlayerAuth {
|
||||
|
||||
/**
|
||||
* Method hashCode.
|
||||
|
||||
* @return int */
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hashCode = 7;
|
||||
@ -396,8 +431,9 @@ public class PlayerAuth {
|
||||
|
||||
/**
|
||||
* Method toString.
|
||||
|
||||
* @return String */
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return ("Player : " + nickname + " | " + realName
|
||||
|
@ -13,8 +13,21 @@ public class PlayerCache {
|
||||
cache = new ConcurrentHashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getInstance.
|
||||
*
|
||||
* @return PlayerCache
|
||||
*/
|
||||
public static PlayerCache getInstance() {
|
||||
if (singleton == null) {
|
||||
singleton = new PlayerCache();
|
||||
}
|
||||
return singleton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method addPlayer.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
*/
|
||||
public void addPlayer(PlayerAuth auth) {
|
||||
@ -23,6 +36,7 @@ public class PlayerCache {
|
||||
|
||||
/**
|
||||
* Method updatePlayer.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
*/
|
||||
public void updatePlayer(PlayerAuth auth) {
|
||||
@ -32,6 +46,7 @@ public class PlayerCache {
|
||||
|
||||
/**
|
||||
* Method removePlayer.
|
||||
*
|
||||
* @param user String
|
||||
*/
|
||||
public void removePlayer(String user) {
|
||||
@ -40,45 +55,38 @@ public class PlayerCache {
|
||||
|
||||
/**
|
||||
* Method isAuthenticated.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @return boolean */
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isAuthenticated(String user) {
|
||||
return cache.containsKey(user.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getAuth.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @return PlayerAuth */
|
||||
* @return PlayerAuth
|
||||
*/
|
||||
public PlayerAuth getAuth(String user) {
|
||||
return cache.get(user.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getInstance.
|
||||
|
||||
* @return PlayerCache */
|
||||
public static PlayerCache getInstance() {
|
||||
if (singleton == null) {
|
||||
singleton = new PlayerCache();
|
||||
}
|
||||
return singleton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getLogged.
|
||||
|
||||
* @return int */
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public int getLogged() {
|
||||
return cache.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getCache.
|
||||
|
||||
* @return ConcurrentHashMap<String,PlayerAuth> */
|
||||
*
|
||||
* @return ConcurrentHashMap<String,PlayerAuth>
|
||||
*/
|
||||
public ConcurrentHashMap<String, PlayerAuth> getCache() {
|
||||
return this.cache;
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ public class DataFileCache {
|
||||
|
||||
/**
|
||||
* Constructor for DataFileCache.
|
||||
*
|
||||
* @param group String
|
||||
* @param operator boolean
|
||||
* @param flying boolean
|
||||
@ -22,24 +23,27 @@ public class DataFileCache {
|
||||
|
||||
/**
|
||||
* Method getGroup.
|
||||
|
||||
* @return String */
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getOperator.
|
||||
|
||||
* @return boolean */
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method isFlying.
|
||||
|
||||
* @return boolean */
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isFlying() {
|
||||
return flying;
|
||||
}
|
||||
|
@ -1,27 +1,17 @@
|
||||
package fr.xephi.authme.cache.backup;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.gson.*;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.Files;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonDeserializationContext;
|
||||
import com.google.gson.JsonDeserializer;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParseException;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class JsonCache {
|
||||
@ -43,6 +33,7 @@ public class JsonCache {
|
||||
|
||||
/**
|
||||
* Method createCache.
|
||||
*
|
||||
* @param player Player
|
||||
* @param playerData DataFileCache
|
||||
*/
|
||||
@ -77,9 +68,10 @@ public class JsonCache {
|
||||
|
||||
/**
|
||||
* Method readCache.
|
||||
*
|
||||
* @param player Player
|
||||
|
||||
* @return DataFileCache */
|
||||
* @return DataFileCache
|
||||
*/
|
||||
public DataFileCache readCache(Player player) {
|
||||
String path;
|
||||
try {
|
||||
@ -103,24 +95,41 @@ public class JsonCache {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method removeCache.
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
private class PlayerDataSerializer implements JsonSerializer<DataFileCache> {
|
||||
/**
|
||||
* Method serialize.
|
||||
* @param dataFileCache DataFileCache
|
||||
* @param type Type
|
||||
* @param jsonSerializationContext JsonSerializationContext
|
||||
|
||||
* @return JsonElement */
|
||||
@Override
|
||||
public JsonElement serialize(DataFileCache dataFileCache, Type type, JsonSerializationContext jsonSerializationContext) {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("group", dataFileCache.getGroup());
|
||||
jsonObject.addProperty("operator", dataFileCache.getOperator());
|
||||
jsonObject.addProperty("flying", dataFileCache.isFlying());
|
||||
|
||||
return jsonObject;
|
||||
public void removeCache(Player player) {
|
||||
String path;
|
||||
try {
|
||||
path = player.getUniqueId().toString();
|
||||
} catch (Exception | Error e) {
|
||||
path = player.getName().toLowerCase();
|
||||
}
|
||||
File file = new File(cacheDir, path);
|
||||
if (file.exists()) {
|
||||
Utils.purgeDirectory(file);
|
||||
if (!file.delete()) {
|
||||
ConsoleLogger.showError("Failed to remove" + player.getName() + "cache.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method doesCacheExist.
|
||||
*
|
||||
* @param player Player
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean doesCacheExist(Player player) {
|
||||
String path;
|
||||
try {
|
||||
path = player.getUniqueId().toString();
|
||||
} catch (Exception | Error e) {
|
||||
path = player.getName().toLowerCase();
|
||||
}
|
||||
File file = new File(cacheDir, path + File.separator + "cache.json");
|
||||
return file.exists();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,13 +137,12 @@ public class JsonCache {
|
||||
private static class PlayerDataDeserializer implements JsonDeserializer<DataFileCache> {
|
||||
/**
|
||||
* Method deserialize.
|
||||
*
|
||||
* @param jsonElement JsonElement
|
||||
* @param type Type
|
||||
* @param jsonDeserializationContext JsonDeserializationContext
|
||||
|
||||
|
||||
|
||||
* @return DataFileCache * @throws JsonParseException * @see com.google.gson.JsonDeserializer#deserialize(JsonElement, Type, JsonDeserializationContext) */
|
||||
* @return DataFileCache * @throws JsonParseException * @see com.google.gson.JsonDeserializer#deserialize(JsonElement, Type, JsonDeserializationContext)
|
||||
*/
|
||||
@Override
|
||||
public DataFileCache deserialize(JsonElement jsonElement, Type type, JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
|
||||
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||
@ -161,39 +169,25 @@ public class JsonCache {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method removeCache.
|
||||
* @param player Player
|
||||
*/
|
||||
public void removeCache(Player player) {
|
||||
String path;
|
||||
try {
|
||||
path = player.getUniqueId().toString();
|
||||
} catch (Exception | Error e) {
|
||||
path = player.getName().toLowerCase();
|
||||
}
|
||||
File file = new File(cacheDir, path);
|
||||
if (file.exists()) {
|
||||
Utils.purgeDirectory(file);
|
||||
if (!file.delete()) {
|
||||
ConsoleLogger.showError("Failed to remove" + player.getName() + "cache.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class PlayerDataSerializer implements JsonSerializer<DataFileCache> {
|
||||
/**
|
||||
* Method doesCacheExist.
|
||||
* @param player Player
|
||||
* Method serialize.
|
||||
*
|
||||
* @param dataFileCache DataFileCache
|
||||
* @param type Type
|
||||
* @param jsonSerializationContext JsonSerializationContext
|
||||
* @return JsonElement
|
||||
*/
|
||||
@Override
|
||||
public JsonElement serialize(DataFileCache dataFileCache, Type type, JsonSerializationContext jsonSerializationContext) {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("group", dataFileCache.getGroup());
|
||||
jsonObject.addProperty("operator", dataFileCache.getOperator());
|
||||
jsonObject.addProperty("flying", dataFileCache.isFlying());
|
||||
|
||||
* @return boolean */
|
||||
public boolean doesCacheExist(Player player) {
|
||||
String path;
|
||||
try {
|
||||
path = player.getUniqueId().toString();
|
||||
} catch (Exception | Error e) {
|
||||
path = player.getName().toLowerCase();
|
||||
return jsonObject;
|
||||
}
|
||||
File file = new File(cacheDir, path + File.separator + "cache.json");
|
||||
return file.exists();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,19 +1,18 @@
|
||||
package fr.xephi.authme.cache.limbo;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.backup.DataFileCache;
|
||||
import fr.xephi.authme.cache.backup.JsonCache;
|
||||
import fr.xephi.authme.events.ResetInventoryEvent;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -21,11 +20,12 @@ public class LimboCache {
|
||||
|
||||
private volatile static LimboCache singleton;
|
||||
public ConcurrentHashMap<String, LimboPlayer> cache;
|
||||
private JsonCache playerData;
|
||||
public AuthMe plugin;
|
||||
private JsonCache playerData;
|
||||
|
||||
/**
|
||||
* Constructor for LimboCache.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
private LimboCache(AuthMe plugin) {
|
||||
@ -34,6 +34,18 @@ public class LimboCache {
|
||||
this.playerData = new JsonCache();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getInstance.
|
||||
*
|
||||
* @return LimboCache
|
||||
*/
|
||||
public static LimboCache getInstance() {
|
||||
if (singleton == null) {
|
||||
singleton = new LimboCache(AuthMe.getInstance());
|
||||
}
|
||||
return singleton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a limbo player.
|
||||
*
|
||||
@ -91,6 +103,7 @@ public class LimboCache {
|
||||
|
||||
/**
|
||||
* Method addLimboPlayer.
|
||||
*
|
||||
* @param player Player
|
||||
* @param group String
|
||||
*/
|
||||
@ -100,6 +113,7 @@ public class LimboCache {
|
||||
|
||||
/**
|
||||
* Method deleteLimboPlayer.
|
||||
*
|
||||
* @param name String
|
||||
*/
|
||||
public void deleteLimboPlayer(String name) {
|
||||
@ -108,35 +122,27 @@ public class LimboCache {
|
||||
|
||||
/**
|
||||
* Method getLimboPlayer.
|
||||
*
|
||||
* @param name String
|
||||
|
||||
* @return LimboPlayer */
|
||||
* @return LimboPlayer
|
||||
*/
|
||||
public LimboPlayer getLimboPlayer(String name) {
|
||||
return cache.get(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method hasLimboPlayer.
|
||||
*
|
||||
* @param name String
|
||||
|
||||
* @return boolean */
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean hasLimboPlayer(String name) {
|
||||
return cache.containsKey(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getInstance.
|
||||
|
||||
* @return LimboCache */
|
||||
public static LimboCache getInstance() {
|
||||
if (singleton == null) {
|
||||
singleton = new LimboCache(AuthMe.getInstance());
|
||||
}
|
||||
return singleton;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method updateLimboPlayer.
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
public void updateLimboPlayer(Player player) {
|
||||
|
@ -19,6 +19,7 @@ public class LimboPlayer {
|
||||
|
||||
/**
|
||||
* Constructor for LimboPlayer.
|
||||
*
|
||||
* @param name String
|
||||
* @param loc Location
|
||||
* @param gameMode GameMode
|
||||
@ -38,6 +39,7 @@ public class LimboPlayer {
|
||||
|
||||
/**
|
||||
* Constructor for LimboPlayer.
|
||||
*
|
||||
* @param name String
|
||||
* @param group String
|
||||
*/
|
||||
@ -48,46 +50,61 @@ public class LimboPlayer {
|
||||
|
||||
/**
|
||||
* Method getName.
|
||||
|
||||
* @return String */
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getLoc.
|
||||
|
||||
* @return Location */
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public Location getLoc() {
|
||||
return loc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getGameMode.
|
||||
|
||||
* @return GameMode */
|
||||
*
|
||||
* @return GameMode
|
||||
*/
|
||||
public GameMode getGameMode() {
|
||||
return gameMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getOperator.
|
||||
|
||||
* @return boolean */
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getGroup.
|
||||
|
||||
* @return String */
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getGroup() {
|
||||
return group;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getTimeoutTaskId.
|
||||
*
|
||||
* @return BukkitTask
|
||||
*/
|
||||
public BukkitTask getTimeoutTaskId() {
|
||||
return timeoutTaskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setTimeoutTaskId.
|
||||
*
|
||||
* @param i BukkitTask
|
||||
*/
|
||||
public void setTimeoutTaskId(BukkitTask i) {
|
||||
@ -97,15 +114,17 @@ public class LimboPlayer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getTimeoutTaskId.
|
||||
|
||||
* @return BukkitTask */
|
||||
public BukkitTask getTimeoutTaskId() {
|
||||
return timeoutTaskId;
|
||||
* Method getMessageTaskId.
|
||||
*
|
||||
* @return BukkitTask
|
||||
*/
|
||||
public BukkitTask getMessageTaskId() {
|
||||
return messageTaskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setMessageTaskId.
|
||||
*
|
||||
* @param messageTaskId BukkitTask
|
||||
*/
|
||||
public void setMessageTaskId(BukkitTask messageTaskId) {
|
||||
@ -114,18 +133,11 @@ public class LimboPlayer {
|
||||
this.messageTaskId = messageTaskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getMessageTaskId.
|
||||
|
||||
* @return BukkitTask */
|
||||
public BukkitTask getMessageTaskId() {
|
||||
return messageTaskId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method isFlying.
|
||||
|
||||
* @return boolean */
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isFlying() {
|
||||
return flying;
|
||||
}
|
||||
|
@ -6,11 +6,17 @@ public class CommandArgumentDescription {
|
||||
|
||||
// TODO: Allow argument to consist of infinite parts. <label ...>
|
||||
|
||||
/** Argument label. */
|
||||
/**
|
||||
* Argument label.
|
||||
*/
|
||||
private String label;
|
||||
/** Argument description. */
|
||||
/**
|
||||
* Argument description.
|
||||
*/
|
||||
private String description;
|
||||
/** Defines whether the argument is optional. */
|
||||
/**
|
||||
* Defines whether the argument is optional.
|
||||
*/
|
||||
private boolean optional = false;
|
||||
|
||||
/**
|
||||
|
@ -1,35 +1,52 @@
|
||||
package fr.xephi.authme.command;
|
||||
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class CommandDescription {
|
||||
|
||||
/** Defines the acceptable labels. */
|
||||
/**
|
||||
* Defines the acceptable labels.
|
||||
*/
|
||||
private List<String> labels = new ArrayList<>();
|
||||
/** Command description. */
|
||||
/**
|
||||
* Command description.
|
||||
*/
|
||||
private String description = "";
|
||||
/** Detailed description. */
|
||||
/**
|
||||
* Detailed description.
|
||||
*/
|
||||
private String detailedDescription = "";
|
||||
/** The executable command instance. */
|
||||
/**
|
||||
* The executable command instance.
|
||||
*/
|
||||
private ExecutableCommand executableCommand;
|
||||
/** The parent command. */
|
||||
/**
|
||||
* The parent command.
|
||||
*/
|
||||
private CommandDescription parent = null;
|
||||
/** The child labels. */
|
||||
/**
|
||||
* The child labels.
|
||||
*/
|
||||
private List<CommandDescription> children = new ArrayList<>();
|
||||
/** The command arguments. */
|
||||
/**
|
||||
* The command arguments.
|
||||
*/
|
||||
private List<CommandArgumentDescription> arguments = new ArrayList<>();
|
||||
/** Defines whether there is an argument maximum or not. */
|
||||
/**
|
||||
* Defines whether there is an argument maximum or not.
|
||||
*/
|
||||
private boolean noArgumentMaximum = false;
|
||||
/** Defines the command permissions. */
|
||||
/**
|
||||
* Defines the command permissions.
|
||||
*/
|
||||
private CommandPermissions permissions = new CommandPermissions();
|
||||
|
||||
/**
|
||||
@ -96,11 +113,49 @@ public class CommandDescription {
|
||||
setArguments(arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
// Make sure the label isn't null
|
||||
if (label == null)
|
||||
return false;
|
||||
|
||||
// Trim the label
|
||||
label = label.trim();
|
||||
|
||||
// Make sure the label is at least one character long
|
||||
if (label.length() <= 0)
|
||||
return false;
|
||||
|
||||
// Make sure the label doesn't contain any spaces, return the result
|
||||
return !label.contains(" ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether two labels equal to each other.
|
||||
*
|
||||
* @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) {
|
||||
// Trim the command labels from unwanted whitespaces
|
||||
commandLabel = commandLabel.trim();
|
||||
otherCommandLabel = otherCommandLabel.trim();
|
||||
|
||||
// Check whether the the two command labels are equal (case insensitive)
|
||||
return (commandLabel.equalsIgnoreCase(otherCommandLabel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first relative command label.
|
||||
*
|
||||
|
||||
* @return First relative command label. */
|
||||
* @return First relative command label.
|
||||
*/
|
||||
public String getLabel() {
|
||||
// Ensure there's any item in the command list
|
||||
if (this.labels.size() == 0)
|
||||
@ -110,13 +165,21 @@ public class CommandDescription {
|
||||
return this.labels.get(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the command label, this will append the command label to already existing ones.
|
||||
*
|
||||
* @param commandLabel Command label to set or add.
|
||||
*/
|
||||
public void setLabel(String commandLabel) {
|
||||
setLabel(commandLabel, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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. */
|
||||
* @return The most similar label, or the first label. An empty label will be returned if no label was set.
|
||||
*/
|
||||
public String getLabel(CommandParts reference) {
|
||||
// Ensure there's any item in the command list
|
||||
if (this.labels.size() == 0)
|
||||
@ -147,8 +210,8 @@ public class CommandDescription {
|
||||
/**
|
||||
* Get all relative command labels.
|
||||
*
|
||||
|
||||
* @return All relative labels labels. */
|
||||
* @return All relative labels labels.
|
||||
*/
|
||||
public List<String> getLabels() {
|
||||
return this.labels;
|
||||
}
|
||||
@ -167,24 +230,14 @@ public class CommandDescription {
|
||||
this.labels = labels;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the command label, this will append the command label to already existing ones.
|
||||
*
|
||||
* @param commandLabel Command label to set or add.
|
||||
*/
|
||||
public void setLabel(String commandLabel) {
|
||||
setLabel(commandLabel, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the command label.
|
||||
*
|
||||
* @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. */
|
||||
* @return Trie if the command label is added, or if it was added already. False on failure.
|
||||
*/
|
||||
public boolean setLabel(String commandLabel, boolean overwrite) {
|
||||
// Check whether this new command should overwrite the previous ones
|
||||
if (!overwrite)
|
||||
@ -199,9 +252,8 @@ 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. */
|
||||
* @return True if the label was added, or if it was added already. False on error.
|
||||
*/
|
||||
public boolean addLabel(String commandLabel) {
|
||||
// Verify the label
|
||||
if (!isValidLabel(commandLabel))
|
||||
@ -219,9 +271,8 @@ public class CommandDescription {
|
||||
* Add a list of command labels.
|
||||
*
|
||||
* @param commandLabels List of command labels to add.
|
||||
*
|
||||
|
||||
* @return True if succeed, false on failure. */
|
||||
* @return True if succeed, false on failure.
|
||||
*/
|
||||
public boolean addLabels(List<String> commandLabels) {
|
||||
// Add each command label separately
|
||||
for (String cmd : commandLabels)
|
||||
@ -234,9 +285,8 @@ 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. */
|
||||
* @return True if this command label equals to the param command.
|
||||
*/
|
||||
public boolean hasLabel(String commandLabel) {
|
||||
// Check whether any command matches with the argument
|
||||
for (String entry : this.labels)
|
||||
@ -249,9 +299,10 @@ public class CommandDescription {
|
||||
|
||||
/**
|
||||
* Check whether this command description has a list of labels
|
||||
*
|
||||
* @param commandLabels List of labels
|
||||
|
||||
* @return True if all labels match, false otherwise */
|
||||
* @return True if all labels match, false otherwise
|
||||
*/
|
||||
public boolean hasLabels(List<String> commandLabels) {
|
||||
// Check if there's a match for every command
|
||||
for (String cmd : commandLabels)
|
||||
@ -267,9 +318,8 @@ 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. */
|
||||
* @return True if the command reference is suitable to this command label, false otherwise.
|
||||
*/
|
||||
public boolean isSuitableLabel(CommandParts commandReference) {
|
||||
// Make sure the command reference is valid
|
||||
if (commandReference.getCount() <= 0)
|
||||
@ -282,33 +332,11 @@ public class CommandDescription {
|
||||
return hasLabel(element);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
// Make sure the label isn't null
|
||||
if(label == null)
|
||||
return false;
|
||||
|
||||
// Trim the label
|
||||
label = label.trim();
|
||||
|
||||
// Make sure the label is at least one character long
|
||||
if(label.length() <= 0)
|
||||
return false;
|
||||
|
||||
// Make sure the label doesn't contain any spaces, return the result
|
||||
return !label.contains(" ");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the absolute command label, without a slash.
|
||||
|
||||
* @return String */
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getAbsoluteLabel() {
|
||||
return getAbsoluteLabel(false);
|
||||
}
|
||||
@ -316,9 +344,9 @@ public class CommandDescription {
|
||||
/**
|
||||
* Get the absolute command label.
|
||||
*
|
||||
|
||||
* @param includeSlash boolean
|
||||
* @return Absolute command label. */
|
||||
* @return Absolute command label.
|
||||
*/
|
||||
public String getAbsoluteLabel(boolean includeSlash) {
|
||||
return getAbsoluteLabel(includeSlash, null);
|
||||
}
|
||||
@ -326,10 +354,10 @@ public class CommandDescription {
|
||||
/**
|
||||
* Get the absolute command label.
|
||||
*
|
||||
|
||||
* @param includeSlash boolean
|
||||
* @param reference CommandParts
|
||||
* @return Absolute command label. */
|
||||
* @return Absolute command label.
|
||||
*/
|
||||
public String getAbsoluteLabel(boolean includeSlash, CommandParts reference) {
|
||||
// Get the command reference, and make sure it is valid
|
||||
CommandParts out = getCommandReference(reference);
|
||||
@ -344,9 +372,8 @@ 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. */
|
||||
* @return Command reference.
|
||||
*/
|
||||
public CommandParts getCommandReference(CommandParts reference) {
|
||||
// Build the reference
|
||||
List<String> referenceList = new ArrayList<>();
|
||||
@ -366,9 +393,8 @@ 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. */
|
||||
* @return The command difference. Zero if there's no difference. A negative number on error.
|
||||
*/
|
||||
public double getCommandDifference(CommandParts other) {
|
||||
return getCommandDifference(other, false);
|
||||
}
|
||||
@ -378,9 +404,8 @@ public class CommandDescription {
|
||||
*
|
||||
* @param other The other command reference.
|
||||
* @param fullCompare True to fully compare both command references.
|
||||
*
|
||||
|
||||
* @return The command difference. Zero if there's no difference. A negative number on error. */
|
||||
* @return The command difference. Zero if there's no difference. A negative number on error.
|
||||
*/
|
||||
public double getCommandDifference(CommandParts other, boolean fullCompare) {
|
||||
// Make sure the reference is valid
|
||||
if (other == null)
|
||||
@ -396,8 +421,8 @@ public class CommandDescription {
|
||||
/**
|
||||
* Get the executable command.
|
||||
*
|
||||
|
||||
* @return The executable command. */
|
||||
* @return The executable command.
|
||||
*/
|
||||
public ExecutableCommand getExecutableCommand() {
|
||||
return this.executableCommand;
|
||||
}
|
||||
@ -414,8 +439,8 @@ public class CommandDescription {
|
||||
/**
|
||||
* Check whether this command is executable, based on the assigned executable command.
|
||||
*
|
||||
|
||||
* @return True if this command is executable. */
|
||||
* @return True if this command is executable.
|
||||
*/
|
||||
public boolean isExecutable() {
|
||||
return this.executableCommand != null;
|
||||
}
|
||||
@ -426,9 +451,8 @@ 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. */
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
public boolean execute(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// Make sure the command is executable
|
||||
if (!isExecutable())
|
||||
@ -441,8 +465,8 @@ public class CommandDescription {
|
||||
/**
|
||||
* Get the parent command if this command description has a parent.
|
||||
*
|
||||
|
||||
* @return Parent command, or null */
|
||||
* @return Parent command, or null
|
||||
*/
|
||||
public CommandDescription getParent() {
|
||||
return this.parent;
|
||||
}
|
||||
@ -450,8 +474,8 @@ public class CommandDescription {
|
||||
/**
|
||||
* Get the number of parent this description has.
|
||||
*
|
||||
|
||||
* @return The number of parents. */
|
||||
* @return The number of parents.
|
||||
*/
|
||||
public int getParentCount() {
|
||||
// Check whether the this description has a parent
|
||||
if (!hasParent())
|
||||
@ -465,9 +489,8 @@ public class CommandDescription {
|
||||
* Set the parent command.
|
||||
*
|
||||
* @param parent Parent command.
|
||||
*
|
||||
|
||||
* @return True on success, false on failure. */
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
public boolean setParent(CommandDescription parent) {
|
||||
// Make sure the parent is different
|
||||
if (this.parent == parent)
|
||||
@ -487,8 +510,8 @@ public class CommandDescription {
|
||||
/**
|
||||
* Check whether the plugin description has a parent command.
|
||||
*
|
||||
|
||||
* @return True if the description has a parent command, false otherwise. */
|
||||
* @return True if the description has a parent command, false otherwise.
|
||||
*/
|
||||
public boolean hasParent() {
|
||||
return this.parent != null;
|
||||
}
|
||||
@ -496,19 +519,32 @@ public class CommandDescription {
|
||||
/**
|
||||
* Get all command children.
|
||||
*
|
||||
|
||||
* @return Command children. */
|
||||
* @return Command children.
|
||||
*/
|
||||
public List<CommandDescription> getChildren() {
|
||||
return this.children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the children of this command.
|
||||
*
|
||||
* @param children New command children. Null to remove all children.
|
||||
*/
|
||||
public void setChildren(List<CommandDescription> children) {
|
||||
// Check whether the children list should be cleared
|
||||
if (children == null)
|
||||
this.children.clear();
|
||||
|
||||
else
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a child to the command description.
|
||||
*
|
||||
* @param commandDescription The child to add.
|
||||
*
|
||||
|
||||
* @return True on success, false on failure. */
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
public boolean addChild(CommandDescription commandDescription) {
|
||||
// Make sure the description is valid
|
||||
if (commandDescription == null)
|
||||
@ -528,25 +564,11 @@ public class CommandDescription {
|
||||
return commandDescription.setParent(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the children of this command.
|
||||
*
|
||||
* @param children New command children. Null to remove all children.
|
||||
*/
|
||||
public void setChildren(List<CommandDescription> children) {
|
||||
// Check whether the children list should be cleared
|
||||
if(children == null)
|
||||
this.children.clear();
|
||||
|
||||
else
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether this command has any child labels.
|
||||
*
|
||||
|
||||
* @return True if this command has any child labels. */
|
||||
* @return True if this command has any child labels.
|
||||
*/
|
||||
public boolean hasChilds() {
|
||||
return (this.children.size() != 0);
|
||||
}
|
||||
@ -555,9 +577,8 @@ 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. */
|
||||
* @return True if this command description has the specific child, false otherwise.
|
||||
*/
|
||||
public boolean isChild(CommandDescription commandDescription) {
|
||||
// Make sure the description is valid
|
||||
if (commandDescription == null)
|
||||
@ -573,9 +594,8 @@ public class CommandDescription {
|
||||
* Add an argument.
|
||||
*
|
||||
* @param argument The argument to add.
|
||||
*
|
||||
|
||||
* @return True if succeed, false if failed. */
|
||||
* @return True if succeed, false if failed.
|
||||
*/
|
||||
public boolean addArgument(CommandArgumentDescription argument) {
|
||||
// Make sure the argument is valid
|
||||
if (argument == null)
|
||||
@ -592,8 +612,8 @@ public class CommandDescription {
|
||||
/**
|
||||
* Get all command arguments.
|
||||
*
|
||||
|
||||
* @return Command arguments. */
|
||||
* @return Command arguments.
|
||||
*/
|
||||
public List<CommandArgumentDescription> getArguments() {
|
||||
return this.arguments;
|
||||
}
|
||||
@ -616,9 +636,8 @@ public class CommandDescription {
|
||||
* Check whether an argument exists.
|
||||
*
|
||||
* @param argument The argument to check for.
|
||||
*
|
||||
|
||||
* @return True if this argument already exists, false otherwise. */
|
||||
* @return True if this argument already exists, false otherwise.
|
||||
*/
|
||||
public boolean hasArgument(CommandArgumentDescription argument) {
|
||||
// Make sure the argument is valid
|
||||
if (argument == null)
|
||||
@ -631,8 +650,8 @@ public class CommandDescription {
|
||||
/**
|
||||
* Check whether this command has any arguments.
|
||||
*
|
||||
|
||||
* @return True if this command has any arguments. */
|
||||
* @return True if this command has any arguments.
|
||||
*/
|
||||
public boolean hasArguments() {
|
||||
return (this.arguments.size() != 0);
|
||||
}
|
||||
@ -640,8 +659,8 @@ public class CommandDescription {
|
||||
/**
|
||||
* The minimum number of arguments required for this command.
|
||||
*
|
||||
|
||||
* @return The minimum number of required arguments. */
|
||||
* @return The minimum number of required arguments.
|
||||
*/
|
||||
public int getMinimumArguments() {
|
||||
// Get the number of required and optional arguments
|
||||
int requiredArguments = 0;
|
||||
@ -665,8 +684,8 @@ public class CommandDescription {
|
||||
/**
|
||||
* Get the maximum number of arguments.
|
||||
*
|
||||
|
||||
* @return The maximum number of arguments. A negative number will be returned if there's no maximum. */
|
||||
* @return The maximum number of arguments. A negative number will be returned if there's no maximum.
|
||||
*/
|
||||
public int getMaximumArguments() {
|
||||
// Check whether there is a maximum set
|
||||
if (this.noArgumentMaximum)
|
||||
@ -689,8 +708,8 @@ public class CommandDescription {
|
||||
/**
|
||||
* Get the command description.
|
||||
*
|
||||
|
||||
* @return Command description. */
|
||||
* @return Command description.
|
||||
*/
|
||||
public String getDescription() {
|
||||
return hasDescription() ? this.description : this.detailedDescription;
|
||||
}
|
||||
@ -711,8 +730,8 @@ public class CommandDescription {
|
||||
/**
|
||||
* Check whether this command has any description.
|
||||
*
|
||||
|
||||
* @return True if this command has any description. */
|
||||
* @return True if this command has any description.
|
||||
*/
|
||||
public boolean hasDescription() {
|
||||
return (this.description.trim().length() != 0);
|
||||
}
|
||||
@ -720,8 +739,8 @@ public class CommandDescription {
|
||||
/**
|
||||
* Get the command detailed description.
|
||||
*
|
||||
|
||||
* @return Command detailed description. */
|
||||
* @return Command detailed description.
|
||||
*/
|
||||
public String getDetailedDescription() {
|
||||
return hasDetailedDescription() ? this.detailedDescription : this.description;
|
||||
}
|
||||
@ -742,8 +761,8 @@ public class CommandDescription {
|
||||
/**
|
||||
* Check whether this command has any detailed description.
|
||||
*
|
||||
|
||||
* @return True if this command has any detailed description. */
|
||||
* @return True if this command has any detailed description.
|
||||
*/
|
||||
public boolean hasDetailedDescription() {
|
||||
return (this.detailedDescription.trim().length() != 0);
|
||||
}
|
||||
@ -752,9 +771,8 @@ 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. */
|
||||
* @return The command found, or null.
|
||||
*/
|
||||
public FoundCommandResult findCommand(final CommandParts queryReference) {
|
||||
// Make sure the command reference is valid
|
||||
if (queryReference.getCount() <= 0)
|
||||
@ -814,9 +832,8 @@ 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. */
|
||||
* @return True if so, false otherwise.
|
||||
*/
|
||||
public boolean hasSuitableCommand(CommandParts commandReference) {
|
||||
return findCommand(commandReference) != null;
|
||||
}
|
||||
@ -825,9 +842,8 @@ 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. */
|
||||
* @return True if the arguments are suitable, false otherwise.
|
||||
*/
|
||||
public boolean hasSuitableArguments(CommandParts commandReference) {
|
||||
return getSuitableArgumentsDifference(commandReference) == 0;
|
||||
}
|
||||
@ -837,9 +853,8 @@ 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. */
|
||||
* @return The difference in argument count between the reference and the actual command.
|
||||
*/
|
||||
public int getSuitableArgumentsDifference(CommandParts commandReference) {
|
||||
// Make sure the command reference is valid
|
||||
if (commandReference.getCount() <= 0)
|
||||
@ -863,8 +878,8 @@ public class CommandDescription {
|
||||
/**
|
||||
* Get the command permissions.
|
||||
*
|
||||
|
||||
* @return The command permissions. */
|
||||
* @return The command permissions.
|
||||
*/
|
||||
public CommandPermissions getCommandPermissions() {
|
||||
return this.permissions;
|
||||
}
|
||||
@ -888,28 +903,11 @@ public class CommandDescription {
|
||||
this.permissions = new CommandPermissions(permissionNode, defaultPermission);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether two labels equal to each other.
|
||||
*
|
||||
* @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) {
|
||||
// Trim the command labels from unwanted whitespaces
|
||||
commandLabel = commandLabel.trim();
|
||||
otherCommandLabel = otherCommandLabel.trim();
|
||||
|
||||
// Check whether the the two command labels are equal (case insensitive)
|
||||
return (commandLabel.equalsIgnoreCase(otherCommandLabel));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether the command description has been set up properly.
|
||||
*
|
||||
|
||||
* @return True if the command description is valid, false otherwise. */
|
||||
* @return True if the command description is valid, false otherwise.
|
||||
*/
|
||||
public boolean isValid() {
|
||||
// Make sure any command label is set
|
||||
if (getLabels().size() == 0)
|
||||
|
@ -1,20 +1,21 @@
|
||||
package fr.xephi.authme.command;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.help.HelpProvider;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.help.HelpProvider;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class CommandHandler {
|
||||
|
||||
/** The command manager instance. */
|
||||
/**
|
||||
* The command manager instance.
|
||||
*/
|
||||
private CommandManager commandManager;
|
||||
|
||||
/**
|
||||
@ -31,9 +32,9 @@ public class CommandHandler {
|
||||
/**
|
||||
* Initialize the command handler.
|
||||
*
|
||||
|
||||
* @return True if succeed, false on failure. True will also be returned if the command handler was already
|
||||
* initialized. */
|
||||
* initialized.
|
||||
*/
|
||||
public boolean init() {
|
||||
// Make sure the handler isn't initialized already
|
||||
if (isInit())
|
||||
@ -50,8 +51,8 @@ public class CommandHandler {
|
||||
/**
|
||||
* Check whether the command handler is initialized.
|
||||
*
|
||||
|
||||
* @return True if the command handler is initialized. */
|
||||
* @return True if the command handler is initialized.
|
||||
*/
|
||||
public boolean isInit() {
|
||||
return this.commandManager != null;
|
||||
}
|
||||
@ -59,9 +60,9 @@ public class CommandHandler {
|
||||
/**
|
||||
* Destroy the command handler.
|
||||
*
|
||||
|
||||
* @return True if the command handler was destroyed successfully, false otherwise. True will also be returned if
|
||||
* the command handler wasn't initialized. */
|
||||
* the command handler wasn't initialized.
|
||||
*/
|
||||
public boolean destroy() {
|
||||
// Make sure the command handler is initialized
|
||||
if (!isInit())
|
||||
@ -75,8 +76,8 @@ public class CommandHandler {
|
||||
/**
|
||||
* Get the command manager.
|
||||
*
|
||||
|
||||
* @return Command manager instance. */
|
||||
* @return Command manager instance.
|
||||
*/
|
||||
public CommandManager getCommandManager() {
|
||||
return this.commandManager;
|
||||
}
|
||||
@ -88,9 +89,8 @@ 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. */
|
||||
* @return True if the command was executed, false otherwise.
|
||||
*/
|
||||
public boolean onCommand(CommandSender sender, org.bukkit.command.Command bukkitCommand, String bukkitCommandLabel, String[] bukkitArgs) {
|
||||
// Process the arguments
|
||||
List<String> args = processArguments(bukkitArgs);
|
||||
@ -103,7 +103,7 @@ public class CommandHandler {
|
||||
// Get a suitable command for this reference, and make sure it isn't null
|
||||
FoundCommandResult result = this.commandManager.findCommand(commandReference);
|
||||
if (result == null) {
|
||||
sender.sendMessage(ChatColor.DARK_RED + "Failed to parse " + AuthMe.PLUGIN_NAME + " command!");
|
||||
sender.sendMessage(ChatColor.DARK_RED + "Failed to parse " + AuthMe.getPluginName() + " command!");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -181,9 +181,8 @@ 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. */
|
||||
* @return The processed command arguments.
|
||||
*/
|
||||
private List<String> processArguments(String[] args) {
|
||||
// Convert the array into a list of arguments
|
||||
List<String> arguments = new ArrayList<>(Arrays.asList(args));
|
||||
|
@ -1,29 +1,7 @@
|
||||
package fr.xephi.authme.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import fr.xephi.authme.command.executable.HelpCommand;
|
||||
import fr.xephi.authme.command.executable.authme.AccountsCommand;
|
||||
import fr.xephi.authme.command.executable.authme.AuthMeCommand;
|
||||
import fr.xephi.authme.command.executable.authme.ChangePasswordCommand;
|
||||
import fr.xephi.authme.command.executable.authme.FirstSpawnCommand;
|
||||
import fr.xephi.authme.command.executable.authme.ForceLoginCommand;
|
||||
import fr.xephi.authme.command.executable.authme.GetEmailCommand;
|
||||
import fr.xephi.authme.command.executable.authme.GetIpCommand;
|
||||
import fr.xephi.authme.command.executable.authme.LastLoginCommand;
|
||||
import fr.xephi.authme.command.executable.authme.PurgeBannedPlayersCommand;
|
||||
import fr.xephi.authme.command.executable.authme.PurgeCommand;
|
||||
import fr.xephi.authme.command.executable.authme.PurgeLastPositionCommand;
|
||||
import fr.xephi.authme.command.executable.authme.RegisterCommand;
|
||||
import fr.xephi.authme.command.executable.authme.ReloadCommand;
|
||||
import fr.xephi.authme.command.executable.authme.SetEmailCommand;
|
||||
import fr.xephi.authme.command.executable.authme.SetFirstSpawnCommand;
|
||||
import fr.xephi.authme.command.executable.authme.SetSpawnCommand;
|
||||
import fr.xephi.authme.command.executable.authme.SpawnCommand;
|
||||
import fr.xephi.authme.command.executable.authme.SwitchAntiBotCommand;
|
||||
import fr.xephi.authme.command.executable.authme.UnregisterCommand;
|
||||
import fr.xephi.authme.command.executable.authme.VersionCommand;
|
||||
import fr.xephi.authme.command.executable.authme.*;
|
||||
import fr.xephi.authme.command.executable.captcha.CaptchaCommand;
|
||||
import fr.xephi.authme.command.executable.converter.ConverterCommand;
|
||||
import fr.xephi.authme.command.executable.email.AddEmailCommand;
|
||||
@ -32,18 +10,22 @@ import fr.xephi.authme.command.executable.email.RecoverEmailCommand;
|
||||
import fr.xephi.authme.command.executable.login.LoginCommand;
|
||||
import fr.xephi.authme.command.executable.logout.LogoutCommand;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class CommandManager {
|
||||
|
||||
/** The list of commandDescriptions. */
|
||||
/**
|
||||
* The list of commandDescriptions.
|
||||
*/
|
||||
private List<CommandDescription> commandDescriptions = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param registerCommands
|
||||
* True to register the commands, false otherwise.
|
||||
* @param registerCommands True to register the commands, false otherwise.
|
||||
*/
|
||||
public CommandManager(boolean registerCommands) {
|
||||
// Register the commands
|
||||
@ -574,8 +556,8 @@ public class CommandManager {
|
||||
/**
|
||||
* Get the list of command descriptions
|
||||
*
|
||||
|
||||
* @return List of command descriptions. */
|
||||
* @return List of command descriptions.
|
||||
*/
|
||||
public List<CommandDescription> getCommandDescriptions() {
|
||||
return this.commandDescriptions;
|
||||
}
|
||||
@ -583,8 +565,8 @@ public class CommandManager {
|
||||
/**
|
||||
* Get the number of command description count.
|
||||
*
|
||||
|
||||
* @return Command description count. */
|
||||
* @return Command description count.
|
||||
*/
|
||||
public int getCommandDescriptionCount() {
|
||||
return this.getCommandDescriptions().size();
|
||||
}
|
||||
@ -592,11 +574,9 @@ 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. */
|
||||
* @param queryReference The query reference to find a command for.
|
||||
* @return The command found, or null.
|
||||
*/
|
||||
public FoundCommandResult findCommand(CommandParts queryReference) {
|
||||
// Make sure the command reference is valid
|
||||
if (queryReference.getCount() <= 0)
|
||||
|
@ -1,21 +1,24 @@
|
||||
package fr.xephi.authme.command;
|
||||
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class CommandParts {
|
||||
|
||||
/** The list of parts for this command. */
|
||||
/**
|
||||
* The list of parts for this command.
|
||||
*/
|
||||
private List<String> parts = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public CommandParts() { }
|
||||
public CommandParts() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -58,8 +61,8 @@ public class CommandParts {
|
||||
/**
|
||||
* Get the command parts.
|
||||
*
|
||||
|
||||
* @return Command parts. */
|
||||
* @return Command parts.
|
||||
*/
|
||||
public List<String> getList() {
|
||||
return this.parts;
|
||||
}
|
||||
@ -68,9 +71,8 @@ public class CommandParts {
|
||||
* Add a part.
|
||||
*
|
||||
* @param part The part to add.
|
||||
*
|
||||
|
||||
* @return The result. */
|
||||
* @return The result.
|
||||
*/
|
||||
public boolean add(String part) {
|
||||
return this.parts.add(part);
|
||||
}
|
||||
@ -79,9 +81,8 @@ public class CommandParts {
|
||||
* Add some parts.
|
||||
*
|
||||
* @param parts The parts to add.
|
||||
*
|
||||
|
||||
* @return The result. */
|
||||
* @return The result.
|
||||
*/
|
||||
public boolean add(List<String> parts) {
|
||||
return this.parts.addAll(parts);
|
||||
}
|
||||
@ -90,9 +91,8 @@ public class CommandParts {
|
||||
* Add some parts.
|
||||
*
|
||||
* @param parts The parts to add.
|
||||
*
|
||||
|
||||
* @return The result. */
|
||||
* @return The result.
|
||||
*/
|
||||
public boolean add(String[] parts) {
|
||||
for (String entry : parts)
|
||||
add(entry);
|
||||
@ -102,8 +102,8 @@ public class CommandParts {
|
||||
/**
|
||||
* Get the number of parts.
|
||||
*
|
||||
|
||||
* @return Part count. */
|
||||
* @return Part count.
|
||||
*/
|
||||
public int getCount() {
|
||||
return this.parts.size();
|
||||
}
|
||||
@ -112,9 +112,8 @@ public class CommandParts {
|
||||
* Get a part by it's index.
|
||||
*
|
||||
* @param i Part index.
|
||||
*
|
||||
|
||||
* @return The part. */
|
||||
* @return The part.
|
||||
*/
|
||||
public String get(int i) {
|
||||
// Make sure the index is in-bound
|
||||
if (i < 0 || i >= getCount())
|
||||
@ -128,9 +127,8 @@ 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. */
|
||||
* @return The parts range. Arguments that were out of bound are not included.
|
||||
*/
|
||||
public List<String> getRange(int start) {
|
||||
return getRange(start, getCount() - start);
|
||||
}
|
||||
@ -140,9 +138,8 @@ public class CommandParts {
|
||||
*
|
||||
* @param start The starting index.
|
||||
* @param count The number of parts to get.
|
||||
*
|
||||
|
||||
* @return The parts range. Parts that were out of bound are not included. */
|
||||
* @return The parts range. Parts that were out of bound are not included.
|
||||
*/
|
||||
public List<String> getRange(int start, int count) {
|
||||
// Create a new list to put the range into
|
||||
List<String> elements = new ArrayList<>();
|
||||
@ -163,7 +160,6 @@ 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) {
|
||||
@ -175,7 +171,6 @@ 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) {
|
||||
|
@ -1,29 +1,34 @@
|
||||
package fr.xephi.authme.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
//import com.timvisee.dungeonmaze.Core;
|
||||
//import com.timvisee.dungeonmaze.permission.PermissionsManager;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class CommandPermissions {
|
||||
|
||||
/** Defines the permission nodes required to have permission to execute this command. */
|
||||
/**
|
||||
* Defines the permission nodes required to have permission to execute this command.
|
||||
*/
|
||||
private List<String> permissionNodes = new ArrayList<>();
|
||||
/** Defines the default permission if the permission nodes couldn't be used. */
|
||||
/**
|
||||
* Defines the default permission if the permission nodes couldn't be used.
|
||||
*/
|
||||
private DefaultPermission defaultPermission = DefaultPermission.NOT_ALLOWED;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public CommandPermissions() { }
|
||||
public CommandPermissions() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -50,9 +55,8 @@ 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. */
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
public boolean addPermissionNode(String permissionNode) {
|
||||
// Trim the permission node
|
||||
permissionNode = permissionNode.trim();
|
||||
@ -73,9 +77,8 @@ 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. */
|
||||
* @return True if this permission node is required, false if not.
|
||||
*/
|
||||
public boolean hasPermissionNode(String permissionNode) {
|
||||
return this.permissionNodes.contains(permissionNode);
|
||||
}
|
||||
@ -83,21 +86,12 @@ public class CommandPermissions {
|
||||
/**
|
||||
* Get the permission nodes required to execute this command.
|
||||
*
|
||||
|
||||
* @return The permission nodes required to execute this command. */
|
||||
* @return The permission nodes required to execute this command.
|
||||
*/
|
||||
public List<String> getPermissionNodes() {
|
||||
return this.permissionNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of permission nodes set.
|
||||
*
|
||||
|
||||
* @return Permission node count. */
|
||||
public int getPermissionNodeCount() {
|
||||
return this.permissionNodes.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the permission nodes required to execute this command.
|
||||
*
|
||||
@ -107,12 +101,21 @@ public class CommandPermissions {
|
||||
this.permissionNodes = permissionNodes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of permission nodes set.
|
||||
*
|
||||
* @return Permission node count.
|
||||
*/
|
||||
public int getPermissionNodeCount() {
|
||||
return this.permissionNodes.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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. */
|
||||
* @return True if this command requires any permission to be executed by a player.
|
||||
*/
|
||||
public boolean hasPermission(CommandSender sender) {
|
||||
// Make sure any permission node is set
|
||||
if (getPermissionNodeCount() == 0)
|
||||
@ -143,8 +146,8 @@ public class CommandPermissions {
|
||||
/**
|
||||
* Get the default permission if the permission nodes couldn't be used.
|
||||
*
|
||||
|
||||
* @return The default permission. */
|
||||
* @return The default permission.
|
||||
*/
|
||||
public DefaultPermission getDefaultPermission() {
|
||||
return this.defaultPermission;
|
||||
}
|
||||
@ -162,9 +165,8 @@ 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. */
|
||||
* @return True if the command sender has permission by default, false otherwise.
|
||||
*/
|
||||
public boolean getDefaultPermissionCommandSender(CommandSender sender) {
|
||||
switch (getDefaultPermission()) {
|
||||
case ALLOWED:
|
||||
|
@ -13,7 +13,6 @@ 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);
|
||||
|
@ -6,13 +6,21 @@ import org.bukkit.command.CommandSender;
|
||||
*/
|
||||
public class FoundCommandResult {
|
||||
|
||||
/** The command description instance. */
|
||||
/**
|
||||
* The command description instance.
|
||||
*/
|
||||
private CommandDescription commandDescription;
|
||||
/** The command reference. */
|
||||
/**
|
||||
* The command reference.
|
||||
*/
|
||||
private CommandParts commandReference;
|
||||
/** The command arguments. */
|
||||
/**
|
||||
* The command arguments.
|
||||
*/
|
||||
private CommandParts commandArguments;
|
||||
/** The original search query reference. */
|
||||
/**
|
||||
* The original search query reference.
|
||||
*/
|
||||
private CommandParts queryReference;
|
||||
|
||||
/**
|
||||
@ -33,8 +41,8 @@ public class FoundCommandResult {
|
||||
/**
|
||||
* Check whether the command was suitable.
|
||||
*
|
||||
|
||||
* @return True if the command was suitable, false otherwise. */
|
||||
* @return True if the command was suitable, false otherwise.
|
||||
*/
|
||||
public boolean hasProperArguments() {
|
||||
// Make sure the command description is set
|
||||
if (this.commandDescription == null)
|
||||
@ -47,8 +55,8 @@ public class FoundCommandResult {
|
||||
/**
|
||||
* Get the command description.
|
||||
*
|
||||
|
||||
* @return Command description. */
|
||||
* @return Command description.
|
||||
*/
|
||||
public CommandDescription getCommandDescription() {
|
||||
return this.commandDescription;
|
||||
}
|
||||
@ -57,7 +65,6 @@ public class FoundCommandResult {
|
||||
* Set the command description.
|
||||
*
|
||||
* @param commandDescription The command description.
|
||||
*
|
||||
*/
|
||||
public void setCommandDescription(CommandDescription commandDescription) {
|
||||
this.commandDescription = commandDescription;
|
||||
@ -66,8 +73,8 @@ public class FoundCommandResult {
|
||||
/**
|
||||
* Check whether the command is executable.
|
||||
*
|
||||
|
||||
* @return True if the command is executable, false otherwise. */
|
||||
* @return True if the command is executable, false otherwise.
|
||||
*/
|
||||
public boolean isExecutable() {
|
||||
// Make sure the command description is valid
|
||||
if (this.commandDescription == null)
|
||||
@ -81,9 +88,8 @@ public class FoundCommandResult {
|
||||
* Execute the command.
|
||||
*
|
||||
* @param sender The command sender that executed the command.
|
||||
*
|
||||
|
||||
* @return True on success, false on failure. */
|
||||
* @return True on success, false on failure.
|
||||
*/
|
||||
public boolean executeCommand(CommandSender sender) {
|
||||
// Make sure the command description is valid
|
||||
if (this.commandDescription == null)
|
||||
@ -97,9 +103,8 @@ 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. */
|
||||
* @return True if the command sender has permission, false otherwise.
|
||||
*/
|
||||
public boolean hasPermission(CommandSender sender) {
|
||||
// Make sure the command description is valid
|
||||
if (this.commandDescription == null)
|
||||
@ -112,8 +117,8 @@ public class FoundCommandResult {
|
||||
/**
|
||||
* Get the command reference.
|
||||
*
|
||||
|
||||
* @return The command reference. */
|
||||
* @return The command reference.
|
||||
*/
|
||||
public CommandParts getCommandReference() {
|
||||
return this.commandReference;
|
||||
}
|
||||
@ -121,8 +126,8 @@ public class FoundCommandResult {
|
||||
/**
|
||||
* Get the command arguments.
|
||||
*
|
||||
|
||||
* @return The command arguments. */
|
||||
* @return The command arguments.
|
||||
*/
|
||||
public CommandParts getCommandArguments() {
|
||||
return this.commandArguments;
|
||||
}
|
||||
@ -130,8 +135,8 @@ public class FoundCommandResult {
|
||||
/**
|
||||
* Get the original query reference.
|
||||
*
|
||||
|
||||
* @return Original query reference. */
|
||||
* @return Original query reference.
|
||||
*/
|
||||
public CommandParts getQueryReference() {
|
||||
return this.queryReference;
|
||||
}
|
||||
@ -139,8 +144,8 @@ public class FoundCommandResult {
|
||||
/**
|
||||
* Get the difference value between the original query and the result reference.
|
||||
*
|
||||
|
||||
* @return The difference value. */
|
||||
* @return The difference value.
|
||||
*/
|
||||
public double getDifference() {
|
||||
// Get the difference through the command found
|
||||
if (this.commandDescription != null)
|
||||
|
@ -1,10 +1,9 @@
|
||||
package fr.xephi.authme.command.executable;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.command.help.HelpProvider;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -1,16 +1,15 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -1,11 +1,10 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -14,7 +13,7 @@ public class AuthMeCommand extends ExecutableCommand {
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// Show some version info
|
||||
sender.sendMessage(ChatColor.GREEN + "This server is running " + AuthMe.PLUGIN_NAME + " v" + AuthMe.getVersionName() + "! " + ChatColor.RED + "<3");
|
||||
sender.sendMessage(ChatColor.GREEN + "This server is running " + AuthMe.getPluginName() + " v" + AuthMe.getVersionName() + "! " + ChatColor.RED + "<3");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Use the command " + ChatColor.GOLD + "/" + commandReference.get(0) + " help" + ChatColor.YELLOW + " to view help.");
|
||||
sender.sendMessage(ChatColor.YELLOW + "Use the command " + ChatColor.GOLD + "/" + commandReference.get(0) + " about" + ChatColor.YELLOW + " to view about.");
|
||||
return true;
|
||||
|
@ -1,10 +1,5 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
@ -14,6 +9,10 @@ import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -1,12 +1,11 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Spawn;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -1,12 +1,11 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -1,12 +1,11 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -18,9 +17,8 @@ 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. */
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// Get the player name
|
||||
|
@ -1,12 +1,11 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -1,14 +1,13 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -1,15 +1,14 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -21,9 +20,8 @@ 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. */
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// AuthMe plugin instance
|
||||
|
@ -1,15 +1,14 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -21,9 +20,8 @@ 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. */
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// AuthMe plugin instance
|
||||
|
@ -1,14 +1,13 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -20,9 +19,8 @@ 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. */
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// AuthMe plugin instance
|
||||
|
@ -1,10 +1,5 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
@ -13,6 +8,10 @@ import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -24,9 +23,8 @@ 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. */
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// AuthMe plugin instance
|
||||
|
@ -1,7 +1,6 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
//import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
@ -10,6 +9,7 @@ import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.Profiler;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -21,9 +21,8 @@ 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. */
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// Profile the reload process
|
||||
|
@ -1,14 +1,13 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -20,9 +19,8 @@ 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. */
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// AuthMe plugin instance
|
||||
|
@ -1,7 +1,5 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
@ -9,6 +7,7 @@ import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -20,9 +19,8 @@ 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. */
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// AuthMe plugin instance
|
||||
|
@ -1,12 +1,11 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Spawn;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -18,9 +17,8 @@ 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. */
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
try {
|
||||
|
@ -1,12 +1,11 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Spawn;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -18,9 +17,8 @@ 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. */
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// Make sure the command executor is a player
|
||||
|
@ -1,12 +1,11 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Spawn;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -18,9 +17,8 @@ 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. */
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// Make sure the command executor is a player
|
||||
|
@ -1,12 +1,11 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.command.help.HelpProvider;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -18,9 +17,8 @@ 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. */
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// AuthMe plugin instance
|
||||
|
@ -1,13 +1,5 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
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;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
@ -19,6 +11,13 @@ import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.task.MessageTask;
|
||||
import fr.xephi.authme.task.TimeoutTask;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
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;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -30,8 +29,8 @@ public class UnregisterCommand extends ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
|
||||
* @return True if the command was executed successfully, false otherwise. */
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean executeCommand(final CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// AuthMe plugin instance
|
||||
|
@ -1,13 +1,12 @@
|
||||
package fr.xephi.authme.command.executable.authme;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -19,14 +18,13 @@ 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. */
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// Show some version info
|
||||
sender.sendMessage(ChatColor.GOLD + "==========[ " + AuthMe.PLUGIN_NAME.toUpperCase() + " ABOUT ]==========");
|
||||
sender.sendMessage(ChatColor.GOLD + "Version: " + ChatColor.WHITE + AuthMe.PLUGIN_NAME + " v" + AuthMe.getVersionName() + ChatColor.GRAY + " (code: " + AuthMe.getVersionCode() + ")");
|
||||
sender.sendMessage(ChatColor.GOLD + "==========[ " + AuthMe.getPluginName().toUpperCase() + " ABOUT ]==========");
|
||||
sender.sendMessage(ChatColor.GOLD + "Version: " + ChatColor.WHITE + AuthMe.getPluginName() + " v" + AuthMe.getVersionName() + ChatColor.GRAY + " (code: " + AuthMe.getVersionCode() + ")");
|
||||
sender.sendMessage(ChatColor.GOLD + "Developers:");
|
||||
printDeveloper(sender, "Xephi", "xephi59", "Lead Developer");
|
||||
printDeveloper(sender, "DNx5", "DNx5", "Developer");
|
||||
@ -72,7 +70,6 @@ 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) {
|
||||
|
@ -1,8 +1,5 @@
|
||||
package fr.xephi.authme.command.executable.captcha;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
@ -10,6 +7,8 @@ import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -21,9 +20,8 @@ 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. */
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// AuthMe plugin instance
|
||||
@ -75,7 +73,8 @@ public class CaptchaCommand extends ExecutableCommand {
|
||||
try {
|
||||
plugin.captcha.remove(playerNameLowerCase);
|
||||
plugin.cap.remove(playerNameLowerCase);
|
||||
} catch (NullPointerException ignored) { }
|
||||
} catch (NullPointerException ignored) {
|
||||
}
|
||||
|
||||
// Show a status message
|
||||
m.send(player, "valid_captcha");
|
||||
|
@ -1,8 +1,5 @@
|
||||
package fr.xephi.authme.command.executable.changepassword;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
@ -10,6 +7,8 @@ import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.task.ChangePasswordTask;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -1,21 +1,12 @@
|
||||
package fr.xephi.authme.command.executable.converter;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.converter.Converter;
|
||||
import fr.xephi.authme.converter.CrazyLoginConverter;
|
||||
import fr.xephi.authme.converter.FlatToSql;
|
||||
import fr.xephi.authme.converter.FlatToSqlite;
|
||||
import fr.xephi.authme.converter.RakamakConverter;
|
||||
import fr.xephi.authme.converter.RoyalAuthConverter;
|
||||
import fr.xephi.authme.converter.SqlToFlat;
|
||||
import fr.xephi.authme.converter.vAuthConverter;
|
||||
import fr.xephi.authme.converter.xAuthConverter;
|
||||
import fr.xephi.authme.converter.*;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -27,9 +18,8 @@ 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. */
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// AuthMe plugin instance
|
||||
@ -103,25 +93,19 @@ public class ConverterCommand extends ExecutableCommand {
|
||||
|
||||
/**
|
||||
* Constructor for ConvertType.
|
||||
*
|
||||
* @param name String
|
||||
*/
|
||||
ConvertType(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getName.
|
||||
|
||||
* @return String */
|
||||
String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method fromName.
|
||||
*
|
||||
* @param name String
|
||||
|
||||
* @return ConvertType */
|
||||
* @return ConvertType
|
||||
*/
|
||||
public static ConvertType fromName(String name) {
|
||||
for (ConvertType type : ConvertType.values()) {
|
||||
if (type.getName().equalsIgnoreCase(name))
|
||||
@ -129,5 +113,14 @@ public class ConverterCommand extends ExecutableCommand {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getName.
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,10 @@
|
||||
package fr.xephi.authme.command.executable.email;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -1,11 +1,10 @@
|
||||
package fr.xephi.authme.command.executable.email;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -1,10 +1,5 @@
|
||||
package fr.xephi.authme.command.executable.email;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
@ -15,6 +10,10 @@ import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -1,11 +1,10 @@
|
||||
package fr.xephi.authme.command.executable.login;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -1,11 +1,10 @@
|
||||
package fr.xephi.authme.command.executable.logout;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -1,15 +1,14 @@
|
||||
package fr.xephi.authme.command.executable.register;
|
||||
|
||||
import fr.xephi.authme.process.Management;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.process.Management;
|
||||
import fr.xephi.authme.security.RandomString;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -1,13 +1,12 @@
|
||||
package fr.xephi.authme.command.executable.unregister;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.ExecutableCommand;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -19,9 +18,8 @@ public class UnregisterCommand extends ExecutableCommand {
|
||||
* @param sender The command sender.
|
||||
* @param commandReference The command reference.
|
||||
* @param commandArguments The command arguments.
|
||||
*
|
||||
|
||||
* @return True if the command was executed successfully, false otherwise. */
|
||||
* @return True if the command was executed successfully, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean executeCommand(CommandSender sender, CommandParts commandReference, CommandParts commandArguments) {
|
||||
// AuthMe plugin instance
|
||||
|
@ -1,20 +1,19 @@
|
||||
package fr.xephi.authme.command.help;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandArgumentDescription;
|
||||
import fr.xephi.authme.command.CommandDescription;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.CommandPermissions;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
|
@ -1,12 +1,11 @@
|
||||
package fr.xephi.authme.command.help;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.command.CommandDescription;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.command.FoundCommandResult;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -100,7 +99,7 @@ public class HelpProvider {
|
||||
}
|
||||
|
||||
// Print the help header
|
||||
sender.sendMessage(ChatColor.GOLD + "==========[ " + AuthMe.PLUGIN_NAME.toUpperCase() + " HELP ]==========");
|
||||
sender.sendMessage(ChatColor.GOLD + "==========[ " + AuthMe.getPluginName().toUpperCase() + " HELP ]==========");
|
||||
|
||||
// Print the command help information
|
||||
if (showCommand)
|
||||
|
@ -1,11 +1,10 @@
|
||||
package fr.xephi.authme.command.help;
|
||||
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import fr.xephi.authme.command.CommandArgumentDescription;
|
||||
import fr.xephi.authme.command.CommandDescription;
|
||||
import fr.xephi.authme.command.CommandParts;
|
||||
import fr.xephi.authme.util.StringUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
/**
|
||||
* Helper class for formatting a command's structure (name and arguments)
|
||||
@ -24,7 +23,6 @@ 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,
|
||||
|
@ -1,17 +1,16 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* @author Xephi59
|
||||
@ -25,6 +24,7 @@ public class CrazyLoginConverter implements Converter {
|
||||
|
||||
/**
|
||||
* Constructor for CrazyLoginConverter.
|
||||
*
|
||||
* @param instance AuthMe
|
||||
* @param sender CommandSender
|
||||
*/
|
||||
@ -36,14 +36,16 @@ public class CrazyLoginConverter implements Converter {
|
||||
|
||||
/**
|
||||
* Method getInstance.
|
||||
|
||||
* @return CrazyLoginConverter */
|
||||
*
|
||||
* @return CrazyLoginConverter
|
||||
*/
|
||||
public CrazyLoginConverter getInstance() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
|
@ -1,16 +1,11 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* @author Xephi59
|
||||
* @version $Revision: 1.0 $
|
||||
@ -47,6 +42,7 @@ public class FlatToSql implements Converter {
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
|
@ -1,20 +1,14 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import java.sql.*;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -34,8 +28,10 @@ public class FlatToSqlite implements Converter {
|
||||
private String database;
|
||||
private String columnID;
|
||||
private Connection con;
|
||||
|
||||
/**
|
||||
* Constructor for FlatToSqlite.
|
||||
*
|
||||
* @param sender CommandSender
|
||||
*/
|
||||
public FlatToSqlite(CommandSender sender) {
|
||||
@ -44,6 +40,7 @@ public class FlatToSqlite implements Converter {
|
||||
|
||||
/**
|
||||
* Method close.
|
||||
*
|
||||
* @param o AutoCloseable
|
||||
*/
|
||||
private static void close(AutoCloseable o) {
|
||||
@ -58,6 +55,7 @@ public class FlatToSqlite implements Converter {
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
@ -121,9 +119,9 @@ public class FlatToSqlite implements Converter {
|
||||
|
||||
/**
|
||||
* Method connect.
|
||||
|
||||
|
||||
* @throws ClassNotFoundException * @throws SQLException */
|
||||
*
|
||||
* @throws ClassNotFoundException * @throws SQLException
|
||||
*/
|
||||
private synchronized void connect() throws ClassNotFoundException, SQLException {
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
con = DriverManager.getConnection("jdbc:sqlite:plugins/AuthMe/" + database + ".db");
|
||||
@ -131,8 +129,9 @@ public class FlatToSqlite implements Converter {
|
||||
|
||||
/**
|
||||
* Method setup.
|
||||
|
||||
* @throws SQLException */
|
||||
*
|
||||
* @throws SQLException
|
||||
*/
|
||||
private synchronized void setup() throws SQLException {
|
||||
Statement st = null;
|
||||
ResultSet rs = null;
|
||||
@ -178,9 +177,10 @@ public class FlatToSqlite implements Converter {
|
||||
|
||||
/**
|
||||
* Method saveAuth.
|
||||
*
|
||||
* @param s String
|
||||
|
||||
* @return boolean */
|
||||
* @return boolean
|
||||
*/
|
||||
private synchronized boolean saveAuth(String s) {
|
||||
PreparedStatement pst = null;
|
||||
try {
|
||||
|
@ -12,8 +12,10 @@ import fr.xephi.authme.settings.Settings;
|
||||
public class ForceFlatToSqlite implements Converter {
|
||||
|
||||
private DataSource data;
|
||||
|
||||
/**
|
||||
* Constructor for ForceFlatToSqlite.
|
||||
*
|
||||
* @param data DataSource
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
@ -23,6 +25,7 @@ public class ForceFlatToSqlite implements Converter {
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
|
@ -1,15 +1,5 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
@ -17,6 +7,15 @@ import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.security.HashAlgorithm;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* @author Xephi59
|
||||
@ -30,6 +29,7 @@ public class RakamakConverter implements Converter {
|
||||
|
||||
/**
|
||||
* Constructor for RakamakConverter.
|
||||
*
|
||||
* @param instance AuthMe
|
||||
* @param sender CommandSender
|
||||
*/
|
||||
@ -41,14 +41,16 @@ public class RakamakConverter implements Converter {
|
||||
|
||||
/**
|
||||
* Method getInstance.
|
||||
|
||||
* @return RakamakConverter */
|
||||
*
|
||||
* @return RakamakConverter
|
||||
*/
|
||||
public RakamakConverter getInstance() {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
|
@ -1,13 +1,12 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -18,6 +17,7 @@ public class RoyalAuthConverter implements Converter {
|
||||
|
||||
/**
|
||||
* Constructor for RoyalAuthConverter.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public RoyalAuthConverter(AuthMe plugin) {
|
||||
@ -27,6 +27,7 @@ public class RoyalAuthConverter implements Converter {
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
|
@ -1,15 +1,16 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import fr.xephi.authme.settings.CustomConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class RoyalAuthYamlReader extends CustomConfiguration {
|
||||
|
||||
/**
|
||||
* Constructor for RoyalAuthYamlReader.
|
||||
*
|
||||
* @param file File
|
||||
*/
|
||||
public RoyalAuthYamlReader(File file) {
|
||||
@ -20,16 +21,18 @@ public class RoyalAuthYamlReader extends CustomConfiguration {
|
||||
|
||||
/**
|
||||
* Method getLastLogin.
|
||||
|
||||
* @return long */
|
||||
*
|
||||
* @return long
|
||||
*/
|
||||
public long getLastLogin() {
|
||||
return getLong("timestamps.quit");
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getHash.
|
||||
|
||||
* @return String */
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getHash() {
|
||||
return getString("login.password");
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.datasource.FlatFile;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -21,6 +20,7 @@ public class SqlToFlat implements Converter {
|
||||
|
||||
/**
|
||||
* Constructor for SqlToFlat.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
* @param sender CommandSender
|
||||
*/
|
||||
@ -32,6 +32,7 @@ public class SqlToFlat implements Converter {
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
|
@ -1,10 +1,9 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -16,6 +15,7 @@ public class vAuthConverter implements Converter {
|
||||
|
||||
/**
|
||||
* Constructor for vAuthConverter.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
* @param sender CommandSender
|
||||
*/
|
||||
@ -27,6 +27,7 @@ public class vAuthConverter implements Converter {
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
|
@ -1,18 +1,17 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Scanner;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Scanner;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -24,6 +23,7 @@ public class vAuthFileReader {
|
||||
|
||||
/**
|
||||
* Constructor for vAuthFileReader.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
* @param sender CommandSender
|
||||
*/
|
||||
@ -35,8 +35,9 @@ public class vAuthFileReader {
|
||||
|
||||
/**
|
||||
* Method convert.
|
||||
|
||||
* @throws IOException */
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public void convert() throws IOException {
|
||||
final File file = new File(plugin.getDataFolder().getParent() + "" + File.separator + "vAuth" + File.separator + "passwords.yml");
|
||||
Scanner scanner;
|
||||
@ -70,9 +71,10 @@ public class vAuthFileReader {
|
||||
|
||||
/**
|
||||
* Method isUUIDinstance.
|
||||
*
|
||||
* @param s String
|
||||
|
||||
* @return boolean */
|
||||
* @return boolean
|
||||
*/
|
||||
private boolean isUUIDinstance(String s) {
|
||||
if (String.valueOf(s.charAt(8)).equalsIgnoreCase("-"))
|
||||
return true;
|
||||
@ -81,9 +83,10 @@ public class vAuthFileReader {
|
||||
|
||||
/**
|
||||
* Method getName.
|
||||
*
|
||||
* @param uuid UUID
|
||||
|
||||
* @return String */
|
||||
* @return String
|
||||
*/
|
||||
private String getName(UUID uuid) {
|
||||
try {
|
||||
for (OfflinePlayer op : Bukkit.getOfflinePlayers()) {
|
||||
|
@ -1,8 +1,7 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -13,6 +12,7 @@ public class xAuthConverter implements Converter {
|
||||
|
||||
/**
|
||||
* Constructor for xAuthConverter.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
* @param sender CommandSender
|
||||
*/
|
||||
@ -23,6 +23,7 @@ public class xAuthConverter implements Converter {
|
||||
|
||||
/**
|
||||
* Method run.
|
||||
*
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
|
@ -1,5 +1,13 @@
|
||||
package fr.xephi.authme.converter;
|
||||
|
||||
import de.luricos.bukkit.xAuth.database.DatabaseTables;
|
||||
import de.luricos.bukkit.xAuth.utils.xAuthLog;
|
||||
import de.luricos.bukkit.xAuth.xAuth;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
@ -8,15 +16,6 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import de.luricos.bukkit.xAuth.xAuth;
|
||||
import de.luricos.bukkit.xAuth.database.DatabaseTables;
|
||||
import de.luricos.bukkit.xAuth.utils.xAuthLog;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class xAuthToFlat {
|
||||
@ -27,6 +26,7 @@ public class xAuthToFlat {
|
||||
|
||||
/**
|
||||
* Constructor for xAuthToFlat.
|
||||
*
|
||||
* @param instance AuthMe
|
||||
* @param sender CommandSender
|
||||
*/
|
||||
@ -38,8 +38,9 @@ public class xAuthToFlat {
|
||||
|
||||
/**
|
||||
* Method convert.
|
||||
|
||||
* @return boolean */
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean convert() {
|
||||
if (instance.getServer().getPluginManager().getPlugin("xAuth") == null) {
|
||||
sender.sendMessage("[AuthMe] xAuth plugin not found");
|
||||
@ -72,9 +73,10 @@ public class xAuthToFlat {
|
||||
|
||||
/**
|
||||
* Method getIdPlayer.
|
||||
*
|
||||
* @param id int
|
||||
|
||||
* @return String */
|
||||
* @return String
|
||||
*/
|
||||
public String getIdPlayer(int id) {
|
||||
String realPass = "";
|
||||
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
|
||||
@ -99,8 +101,9 @@ public class xAuthToFlat {
|
||||
|
||||
/**
|
||||
* Method getXAuthPlayers.
|
||||
|
||||
* @return List<Integer> */
|
||||
*
|
||||
* @return List<Integer>
|
||||
*/
|
||||
public List<Integer> getXAuthPlayers() {
|
||||
List<Integer> xP = new ArrayList<>();
|
||||
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
|
||||
@ -124,9 +127,10 @@ public class xAuthToFlat {
|
||||
|
||||
/**
|
||||
* Method getPassword.
|
||||
*
|
||||
* @param accountId int
|
||||
|
||||
* @return String */
|
||||
* @return String
|
||||
*/
|
||||
public String getPassword(int accountId) {
|
||||
String realPass = "";
|
||||
Connection conn = xAuth.getPlugin().getDatabaseController().getConnection();
|
||||
|
@ -1,5 +1,11 @@
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -8,13 +14,6 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class CacheDataSource implements DataSource {
|
||||
@ -25,6 +24,7 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Constructor for CacheDataSource.
|
||||
*
|
||||
* @param pl AuthMe
|
||||
* @param src DataSource
|
||||
*/
|
||||
@ -51,10 +51,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isAuthAvailable.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean isAuthAvailable(String user) {
|
||||
return cache.containsKey(user.toLowerCase());
|
||||
@ -62,10 +62,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAuth.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String) */
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized PlayerAuth getAuth(String user) {
|
||||
user = user.toLowerCase();
|
||||
@ -77,10 +77,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method saveAuth.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean saveAuth(final PlayerAuth auth) {
|
||||
cache.put(auth.getNickname(), auth);
|
||||
@ -97,10 +97,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updatePassword.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updatePassword(final PlayerAuth auth) {
|
||||
if (!cache.containsKey(auth.getNickname())) {
|
||||
@ -123,10 +123,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSession.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateSession(final PlayerAuth auth) {
|
||||
if (!cache.containsKey(auth.getNickname())) {
|
||||
@ -158,10 +158,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateQuitLoc.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateQuitLoc(final PlayerAuth auth) {
|
||||
if (!cache.containsKey(auth.getNickname())) {
|
||||
@ -196,10 +196,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getIps.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String)
|
||||
*/
|
||||
@Override
|
||||
public int getIps(String ip) {
|
||||
int count = 0;
|
||||
@ -213,10 +213,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public int purgeDatabase(long until) {
|
||||
int cleared = source.purgeDatabase(until);
|
||||
@ -232,10 +232,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method autoPurgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public List<String> autoPurgeDatabase(long until) {
|
||||
List<String> cleared = source.autoPurgeDatabase(until);
|
||||
@ -251,10 +251,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method removeAuth.
|
||||
*
|
||||
* @param username String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean removeAuth(String username) {
|
||||
final String user = username.toLowerCase();
|
||||
@ -273,6 +273,7 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method close.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#close()
|
||||
*/
|
||||
@Override
|
||||
@ -283,6 +284,7 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method reload.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#reload()
|
||||
*/
|
||||
@Override
|
||||
@ -305,10 +307,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateEmail.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateEmail(final PlayerAuth auth) {
|
||||
try {
|
||||
@ -324,10 +326,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSalt.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateSalt(final PlayerAuth auth) {
|
||||
if (!cache.containsKey(auth.getNickname())) {
|
||||
@ -351,10 +353,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByName.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> getAllAuthsByName(PlayerAuth auth) {
|
||||
List<String> result = new ArrayList<>();
|
||||
@ -368,11 +370,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByIp.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
|
||||
* @return List<String> * @throws Exception * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String) */
|
||||
* @return List<String> * @throws Exception * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> getAllAuthsByIp(final String ip) throws Exception {
|
||||
return exec.submit(new Callable<List<String>>() {
|
||||
@ -384,11 +385,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByEmail.
|
||||
*
|
||||
* @param email String
|
||||
|
||||
|
||||
|
||||
* @return List<String> * @throws Exception * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String) */
|
||||
* @return List<String> * @throws Exception * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> getAllAuthsByEmail(final String email) throws Exception {
|
||||
return exec.submit(new Callable<List<String>>() {
|
||||
@ -400,9 +400,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeBanned.
|
||||
*
|
||||
* @param banned List<String>
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
|
||||
*/
|
||||
@Override
|
||||
public synchronized void purgeBanned(final List<String> banned) {
|
||||
exec.execute(new Runnable() {
|
||||
@ -420,9 +421,9 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getType.
|
||||
|
||||
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType() */
|
||||
*
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType()
|
||||
*/
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return source.getType();
|
||||
@ -430,10 +431,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
user = user.toLowerCase();
|
||||
@ -442,9 +443,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public void setLogged(final String user) {
|
||||
exec.execute(new Runnable() {
|
||||
@ -457,9 +459,10 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setUnlogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
|
||||
*/
|
||||
@Override
|
||||
public void setUnlogged(final String user) {
|
||||
exec.execute(new Runnable() {
|
||||
@ -472,6 +475,7 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeLogged.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
|
||||
*/
|
||||
@Override
|
||||
@ -486,9 +490,9 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAccountsRegistered.
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered() */
|
||||
*
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
|
||||
*/
|
||||
@Override
|
||||
public int getAccountsRegistered() {
|
||||
return cache.size();
|
||||
@ -496,10 +500,11 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateName.
|
||||
*
|
||||
* @param oldone String
|
||||
* @param newone String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
|
||||
*/
|
||||
@Override
|
||||
public void updateName(final String oldone, final String newone) {
|
||||
if (cache.containsKey(oldone)) {
|
||||
@ -516,9 +521,9 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuths.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths()
|
||||
*/
|
||||
@Override
|
||||
public List<PlayerAuth> getAllAuths() {
|
||||
return new ArrayList<>(cache.values());
|
||||
@ -526,9 +531,9 @@ public class CacheDataSource implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getLoggedPlayers.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
|
||||
*/
|
||||
@Override
|
||||
public List<PlayerAuth> getLoggedPlayers() {
|
||||
return new ArrayList<>(PlayerCache.getInstance().getCache().values());
|
||||
|
@ -1,13 +1,204 @@
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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 {
|
||||
@ -16,173 +207,4 @@ public interface DataSource {
|
||||
SQLITE
|
||||
}
|
||||
|
||||
/**
|
||||
* Method isAuthAvailable.
|
||||
* @param user String
|
||||
|
||||
* @return boolean */
|
||||
boolean isAuthAvailable(String user);
|
||||
|
||||
/**
|
||||
* Method getAuth.
|
||||
* @param user String
|
||||
|
||||
* @return PlayerAuth */
|
||||
PlayerAuth getAuth(String user);
|
||||
|
||||
/**
|
||||
* Method saveAuth.
|
||||
* @param auth PlayerAuth
|
||||
|
||||
* @return boolean */
|
||||
boolean saveAuth(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method updateSession.
|
||||
* @param auth PlayerAuth
|
||||
|
||||
* @return boolean */
|
||||
boolean updateSession(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method updatePassword.
|
||||
* @param auth PlayerAuth
|
||||
|
||||
* @return boolean */
|
||||
boolean updatePassword(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method purgeDatabase.
|
||||
* @param until long
|
||||
|
||||
* @return int */
|
||||
int purgeDatabase(long until);
|
||||
|
||||
/**
|
||||
* Method autoPurgeDatabase.
|
||||
* @param until long
|
||||
|
||||
* @return List<String> */
|
||||
List<String> autoPurgeDatabase(long until);
|
||||
|
||||
/**
|
||||
* Method removeAuth.
|
||||
* @param user String
|
||||
|
||||
* @return boolean */
|
||||
boolean removeAuth(String user);
|
||||
|
||||
/**
|
||||
* Method updateQuitLoc.
|
||||
* @param auth PlayerAuth
|
||||
|
||||
* @return boolean */
|
||||
boolean updateQuitLoc(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method getIps.
|
||||
* @param ip String
|
||||
|
||||
* @return int */
|
||||
int getIps(String ip);
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByName.
|
||||
* @param auth PlayerAuth
|
||||
|
||||
* @return List<String> */
|
||||
List<String> getAllAuthsByName(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByIp.
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return List<String> * @throws Exception */
|
||||
List<String> getAllAuthsByIp(String ip) throws Exception;
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByEmail.
|
||||
* @param email String
|
||||
|
||||
|
||||
* @return List<String> * @throws Exception */
|
||||
List<String> getAllAuthsByEmail(String email) throws Exception;
|
||||
|
||||
/**
|
||||
* Method updateEmail.
|
||||
* @param auth PlayerAuth
|
||||
|
||||
* @return boolean */
|
||||
boolean updateEmail(PlayerAuth auth);
|
||||
|
||||
/**
|
||||
* Method updateSalt.
|
||||
* @param auth PlayerAuth
|
||||
|
||||
* @return boolean */
|
||||
boolean updateSalt(PlayerAuth auth);
|
||||
|
||||
void close();
|
||||
|
||||
void reload();
|
||||
|
||||
/**
|
||||
* Method purgeBanned.
|
||||
* @param banned List<String>
|
||||
*/
|
||||
void purgeBanned(List<String> banned);
|
||||
|
||||
/**
|
||||
* Method getType.
|
||||
|
||||
* @return DataSourceType */
|
||||
DataSourceType getType();
|
||||
|
||||
/**
|
||||
* Method isLogged.
|
||||
* @param user String
|
||||
|
||||
* @return boolean */
|
||||
boolean isLogged(String user);
|
||||
|
||||
/**
|
||||
* Method setLogged.
|
||||
* @param user String
|
||||
*/
|
||||
void setLogged(String user);
|
||||
|
||||
/**
|
||||
* Method setUnlogged.
|
||||
* @param user String
|
||||
*/
|
||||
void setUnlogged(String user);
|
||||
|
||||
void purgeLogged();
|
||||
|
||||
/**
|
||||
* Method getAccountsRegistered.
|
||||
|
||||
* @return int */
|
||||
int getAccountsRegistered();
|
||||
|
||||
/**
|
||||
* Method updateName.
|
||||
* @param oldone String
|
||||
* @param newone String
|
||||
*/
|
||||
void updateName(String oldone, String newone);
|
||||
|
||||
/**
|
||||
* Method getAllAuths.
|
||||
|
||||
* @return List<PlayerAuth> */
|
||||
List<PlayerAuth> getAllAuths();
|
||||
|
||||
/**
|
||||
* Method getLoggedPlayers.
|
||||
|
||||
* @return List<PlayerAuth> */
|
||||
List<PlayerAuth> getLoggedPlayers();
|
||||
|
||||
}
|
||||
|
@ -1,22 +1,23 @@
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class DatabaseCalls implements DataSource {
|
||||
|
||||
private DataSource database;
|
||||
private final ExecutorService exec;
|
||||
private DataSource database;
|
||||
|
||||
/**
|
||||
* Constructor for DatabaseCalls.
|
||||
*
|
||||
* @param database DataSource
|
||||
*/
|
||||
public DatabaseCalls(DataSource database) {
|
||||
@ -26,10 +27,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isAuthAvailable.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean isAuthAvailable(final String user) {
|
||||
try {
|
||||
@ -45,10 +46,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAuth.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String) */
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized PlayerAuth getAuth(final String user) {
|
||||
try {
|
||||
@ -64,10 +65,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method saveAuth.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean saveAuth(final PlayerAuth auth) {
|
||||
try {
|
||||
@ -83,10 +84,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSession.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateSession(final PlayerAuth auth) {
|
||||
try {
|
||||
@ -102,10 +103,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updatePassword.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updatePassword(final PlayerAuth auth) {
|
||||
try {
|
||||
@ -121,10 +122,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public synchronized int purgeDatabase(final long until) {
|
||||
try {
|
||||
@ -140,10 +141,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method autoPurgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> autoPurgeDatabase(final long until) {
|
||||
try {
|
||||
@ -159,10 +160,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method removeAuth.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean removeAuth(final String user) {
|
||||
try {
|
||||
@ -178,10 +179,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateQuitLoc.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateQuitLoc(final PlayerAuth auth) {
|
||||
try {
|
||||
@ -197,10 +198,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getIps.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized int getIps(final String ip) {
|
||||
try {
|
||||
@ -217,10 +218,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByName.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> getAllAuthsByName(final PlayerAuth auth) {
|
||||
try {
|
||||
@ -236,10 +237,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByIp.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> getAllAuthsByIp(final String ip) {
|
||||
try {
|
||||
@ -255,10 +256,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByEmail.
|
||||
*
|
||||
* @param email String
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> getAllAuthsByEmail(final String email) {
|
||||
try {
|
||||
@ -274,10 +275,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateEmail.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateEmail(final PlayerAuth auth) {
|
||||
try {
|
||||
@ -293,10 +294,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSalt.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateSalt(final PlayerAuth auth) {
|
||||
try {
|
||||
@ -312,6 +313,7 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method close.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#close()
|
||||
*/
|
||||
@Override
|
||||
@ -322,6 +324,7 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method reload.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#reload()
|
||||
*/
|
||||
@Override
|
||||
@ -331,9 +334,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeBanned.
|
||||
*
|
||||
* @param banned List<String>
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
|
||||
*/
|
||||
@Override
|
||||
public synchronized void purgeBanned(final List<String> banned) {
|
||||
new Thread(new Runnable() {
|
||||
@ -345,9 +349,9 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getType.
|
||||
|
||||
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType() */
|
||||
*
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType()
|
||||
*/
|
||||
@Override
|
||||
public synchronized DataSourceType getType() {
|
||||
return database.getType();
|
||||
@ -355,10 +359,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean isLogged(final String user) {
|
||||
try {
|
||||
@ -374,9 +378,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized void setLogged(final String user) {
|
||||
exec.execute(new Runnable() {
|
||||
@ -388,9 +393,10 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setUnlogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized void setUnlogged(final String user) {
|
||||
exec.execute(new Runnable() {
|
||||
@ -402,6 +408,7 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeLogged.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
|
||||
*/
|
||||
@Override
|
||||
@ -415,9 +422,9 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAccountsRegistered.
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered() */
|
||||
*
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
|
||||
*/
|
||||
@Override
|
||||
public synchronized int getAccountsRegistered() {
|
||||
try {
|
||||
@ -433,10 +440,11 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateName.
|
||||
*
|
||||
* @param oldone String
|
||||
* @param newone String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized void updateName(final String oldone, final String newone) {
|
||||
exec.execute(new Runnable() {
|
||||
@ -448,9 +456,9 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuths.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths()
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<PlayerAuth> getAllAuths() {
|
||||
try {
|
||||
@ -466,9 +474,9 @@ public class DatabaseCalls implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getLoggedPlayers.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
|
||||
*/
|
||||
@Override
|
||||
public List<PlayerAuth> getLoggedPlayers() {
|
||||
try {
|
||||
|
@ -1,21 +1,15 @@
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class FlatFile implements DataSource {
|
||||
@ -52,10 +46,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isAuthAvailable.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean isAuthAvailable(String user) {
|
||||
BufferedReader br = null;
|
||||
@ -87,10 +81,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method saveAuth.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean saveAuth(PlayerAuth auth) {
|
||||
if (isAuthAvailable(auth.getNickname())) {
|
||||
@ -116,10 +110,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updatePassword.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updatePassword(PlayerAuth auth) {
|
||||
if (!isAuthAvailable(auth.getNickname())) {
|
||||
@ -181,10 +175,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSession.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateSession(PlayerAuth auth) {
|
||||
if (!isAuthAvailable(auth.getNickname())) {
|
||||
@ -246,10 +240,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateQuitLoc.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateQuitLoc(PlayerAuth auth) {
|
||||
if (!isAuthAvailable(auth.getNickname())) {
|
||||
@ -290,10 +284,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getIps.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String)
|
||||
*/
|
||||
@Override
|
||||
public int getIps(String ip) {
|
||||
BufferedReader br = null;
|
||||
@ -326,10 +320,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public int purgeDatabase(long until) {
|
||||
BufferedReader br = null;
|
||||
@ -378,10 +372,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method autoPurgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public List<String> autoPurgeDatabase(long until) {
|
||||
BufferedReader br = null;
|
||||
@ -430,10 +424,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method removeAuth.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean removeAuth(String user) {
|
||||
if (!isAuthAvailable(user)) {
|
||||
@ -480,10 +474,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAuth.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String) */
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized PlayerAuth getAuth(String user) {
|
||||
BufferedReader br = null;
|
||||
@ -528,6 +522,7 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method close.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#close()
|
||||
*/
|
||||
@Override
|
||||
@ -536,6 +531,7 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method reload.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#reload()
|
||||
*/
|
||||
@Override
|
||||
@ -544,10 +540,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateEmail.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateEmail(PlayerAuth auth) {
|
||||
if (!isAuthAvailable(auth.getNickname())) {
|
||||
@ -588,10 +584,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSalt.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateSalt(PlayerAuth auth) {
|
||||
return false;
|
||||
@ -599,10 +595,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByName.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public List<String> getAllAuthsByName(PlayerAuth auth) {
|
||||
BufferedReader br = null;
|
||||
@ -635,10 +631,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByIp.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
|
||||
*/
|
||||
@Override
|
||||
public List<String> getAllAuthsByIp(String ip) {
|
||||
BufferedReader br = null;
|
||||
@ -671,10 +667,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByEmail.
|
||||
*
|
||||
* @param email String
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
|
||||
*/
|
||||
@Override
|
||||
public List<String> getAllAuthsByEmail(String email) {
|
||||
BufferedReader br = null;
|
||||
@ -707,9 +703,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeBanned.
|
||||
*
|
||||
* @param banned List<String>
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
|
||||
*/
|
||||
@Override
|
||||
public void purgeBanned(List<String> banned) {
|
||||
BufferedReader br = null;
|
||||
@ -756,9 +753,9 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getType.
|
||||
|
||||
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType() */
|
||||
*
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType()
|
||||
*/
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return DataSourceType.FILE;
|
||||
@ -766,10 +763,10 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
return PlayerCache.getInstance().isAuthenticated(user);
|
||||
@ -777,24 +774,27 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setUnlogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
|
||||
*/
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method purgeLogged.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
|
||||
*/
|
||||
@Override
|
||||
@ -803,9 +803,9 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAccountsRegistered.
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered() */
|
||||
*
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
|
||||
*/
|
||||
@Override
|
||||
public int getAccountsRegistered() {
|
||||
BufferedReader br = null;
|
||||
@ -831,10 +831,11 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateName.
|
||||
*
|
||||
* @param oldone String
|
||||
* @param newone String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
|
||||
*/
|
||||
@Override
|
||||
public void updateName(String oldone, String newone) {
|
||||
PlayerAuth auth = this.getAuth(oldone);
|
||||
@ -845,9 +846,9 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuths.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths()
|
||||
*/
|
||||
@Override
|
||||
public List<PlayerAuth> getAllAuths() {
|
||||
BufferedReader br = null;
|
||||
@ -897,9 +898,9 @@ public class FlatFile implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getLoggedPlayers.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
|
||||
*/
|
||||
@Override
|
||||
public List<PlayerAuth> getLoggedPlayers() {
|
||||
return new ArrayList<>();
|
||||
|
@ -1,24 +1,18 @@
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import java.sql.Blob;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.zaxxer.hikari.HikariConfig;
|
||||
import com.zaxxer.hikari.HikariDataSource;
|
||||
import com.zaxxer.hikari.pool.PoolInitializationException;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.security.HashAlgorithm;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class MySQL implements DataSource {
|
||||
@ -49,10 +43,9 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Constructor for MySQL.
|
||||
|
||||
|
||||
|
||||
* @throws ClassNotFoundException * @throws SQLException * @throws PoolInitializationException */
|
||||
*
|
||||
* @throws ClassNotFoundException * @throws SQLException * @throws PoolInitializationException
|
||||
*/
|
||||
public MySQL() throws ClassNotFoundException, SQLException, PoolInitializationException {
|
||||
this.host = Settings.getMySQLHost;
|
||||
this.port = Settings.getMySQLPort;
|
||||
@ -108,9 +101,9 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setConnectionArguments.
|
||||
|
||||
|
||||
* @throws ClassNotFoundException * @throws IllegalArgumentException */
|
||||
*
|
||||
* @throws ClassNotFoundException * @throws IllegalArgumentException
|
||||
*/
|
||||
private synchronized void setConnectionArguments()
|
||||
throws ClassNotFoundException, IllegalArgumentException {
|
||||
HikariConfig config = new HikariConfig();
|
||||
@ -132,9 +125,9 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method reloadArguments.
|
||||
|
||||
|
||||
* @throws ClassNotFoundException * @throws IllegalArgumentException */
|
||||
*
|
||||
* @throws ClassNotFoundException * @throws IllegalArgumentException
|
||||
*/
|
||||
private synchronized void reloadArguments()
|
||||
throws ClassNotFoundException, IllegalArgumentException {
|
||||
if (ds != null) {
|
||||
@ -146,17 +139,18 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getConnection.
|
||||
|
||||
|
||||
* @return Connection * @throws SQLException */
|
||||
*
|
||||
* @return Connection * @throws SQLException
|
||||
*/
|
||||
private synchronized Connection getConnection() throws SQLException {
|
||||
return ds.getConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setupConnection.
|
||||
|
||||
* @throws SQLException */
|
||||
*
|
||||
* @throws SQLException
|
||||
*/
|
||||
private synchronized void setupConnection() throws SQLException {
|
||||
Connection con = null;
|
||||
Statement st = null;
|
||||
@ -222,10 +216,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isAuthAvailable.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean isAuthAvailable(String user) {
|
||||
Connection con = null;
|
||||
@ -250,10 +244,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAuth.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String) */
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized PlayerAuth getAuth(String user) {
|
||||
Connection con = null;
|
||||
@ -309,10 +303,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method saveAuth.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean saveAuth(PlayerAuth auth) {
|
||||
Connection con = null;
|
||||
@ -522,10 +516,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updatePassword.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updatePassword(PlayerAuth auth) {
|
||||
Connection con = null;
|
||||
@ -573,10 +567,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSession.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateSession(PlayerAuth auth) {
|
||||
Connection con = null;
|
||||
@ -602,10 +596,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public synchronized int purgeDatabase(long until) {
|
||||
Connection con = null;
|
||||
@ -627,10 +621,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method autoPurgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> autoPurgeDatabase(long until) {
|
||||
Connection con = null;
|
||||
@ -663,10 +657,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method removeAuth.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean removeAuth(String user) {
|
||||
Connection con = null;
|
||||
@ -706,10 +700,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateQuitLoc.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateQuitLoc(PlayerAuth auth) {
|
||||
Connection con = null;
|
||||
@ -736,10 +730,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getIps.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized int getIps(String ip) {
|
||||
Connection con = null;
|
||||
@ -768,10 +762,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateEmail.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateEmail(PlayerAuth auth) {
|
||||
Connection con = null;
|
||||
@ -796,10 +790,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSalt.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updateSalt(PlayerAuth auth) {
|
||||
if (columnSalt.isEmpty()) {
|
||||
@ -826,6 +820,7 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method reload.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#reload()
|
||||
*/
|
||||
@Override
|
||||
@ -845,6 +840,7 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method close.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#close()
|
||||
*/
|
||||
@Override
|
||||
@ -855,6 +851,7 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method close.
|
||||
*
|
||||
* @param o AutoCloseable
|
||||
*/
|
||||
private void close(AutoCloseable o) {
|
||||
@ -870,10 +867,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByName.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> getAllAuthsByName(PlayerAuth auth) {
|
||||
Connection con = null;
|
||||
@ -902,10 +899,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByIp.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> getAllAuthsByIp(String ip) {
|
||||
Connection con = null;
|
||||
@ -934,11 +931,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByEmail.
|
||||
*
|
||||
* @param email String
|
||||
|
||||
|
||||
|
||||
* @return List<String> * @throws SQLException * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String) */
|
||||
* @return List<String> * @throws SQLException * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized List<String> getAllAuthsByEmail(String email) throws SQLException {
|
||||
final Connection con = getConnection();
|
||||
@ -963,9 +959,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeBanned.
|
||||
*
|
||||
* @param banned List<String>
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
|
||||
*/
|
||||
@Override
|
||||
public synchronized void purgeBanned(List<String> banned) {
|
||||
Connection con = null;
|
||||
@ -988,9 +985,9 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getType.
|
||||
|
||||
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType() */
|
||||
*
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType()
|
||||
*/
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return DataSourceType.MYSQL;
|
||||
@ -998,10 +995,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
Connection con = null;
|
||||
@ -1028,9 +1025,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
Connection con = null;
|
||||
@ -1052,9 +1050,10 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setUnlogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
|
||||
*/
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
Connection con = null;
|
||||
@ -1077,6 +1076,7 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeLogged.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
|
||||
*/
|
||||
@Override
|
||||
@ -1100,9 +1100,9 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAccountsRegistered.
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered() */
|
||||
*
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
|
||||
*/
|
||||
@Override
|
||||
public int getAccountsRegistered() {
|
||||
int result = 0;
|
||||
@ -1129,10 +1129,11 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateName.
|
||||
*
|
||||
* @param oldone String
|
||||
* @param newone String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
|
||||
*/
|
||||
@Override
|
||||
public void updateName(String oldone, String newone) {
|
||||
Connection con = null;
|
||||
@ -1154,9 +1155,9 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuths.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths()
|
||||
*/
|
||||
@Override
|
||||
public List<PlayerAuth> getAllAuths() {
|
||||
List<PlayerAuth> auths = new ArrayList<>();
|
||||
@ -1210,9 +1211,9 @@ public class MySQL implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getLoggedPlayers.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
|
||||
*/
|
||||
@Override
|
||||
public List<PlayerAuth> getLoggedPlayers() {
|
||||
List<PlayerAuth> auths = new ArrayList<>();
|
||||
|
@ -1,18 +1,13 @@
|
||||
package fr.xephi.authme.datasource;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class SQLite implements DataSource {
|
||||
@ -37,9 +32,9 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Constructor for SQLite.
|
||||
|
||||
|
||||
* @throws ClassNotFoundException * @throws SQLException */
|
||||
*
|
||||
* @throws ClassNotFoundException * @throws SQLException
|
||||
*/
|
||||
public SQLite() throws ClassNotFoundException, SQLException {
|
||||
this.database = Settings.getMySQLDatabase;
|
||||
this.tableName = Settings.getMySQLTablename;
|
||||
@ -69,9 +64,9 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method connect.
|
||||
|
||||
|
||||
* @throws ClassNotFoundException * @throws SQLException */
|
||||
*
|
||||
* @throws ClassNotFoundException * @throws SQLException
|
||||
*/
|
||||
private synchronized void connect() throws ClassNotFoundException, SQLException {
|
||||
Class.forName("org.sqlite.JDBC");
|
||||
ConsoleLogger.info("SQLite driver loaded");
|
||||
@ -81,8 +76,9 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setup.
|
||||
|
||||
* @throws SQLException */
|
||||
*
|
||||
* @throws SQLException
|
||||
*/
|
||||
private synchronized void setup() throws SQLException {
|
||||
Statement st = null;
|
||||
ResultSet rs = null;
|
||||
@ -139,10 +135,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isAuthAvailable.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isAuthAvailable(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean isAuthAvailable(String user) {
|
||||
PreparedStatement pst = null;
|
||||
@ -163,10 +159,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAuth.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String) */
|
||||
* @return PlayerAuth * @see fr.xephi.authme.datasource.DataSource#getAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized PlayerAuth getAuth(String user) {
|
||||
PreparedStatement pst = null;
|
||||
@ -199,10 +195,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method saveAuth.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#saveAuth(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean saveAuth(PlayerAuth auth) {
|
||||
PreparedStatement pst = null;
|
||||
@ -236,10 +232,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updatePassword.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updatePassword(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean updatePassword(PlayerAuth auth) {
|
||||
PreparedStatement pst = null;
|
||||
@ -259,10 +255,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSession.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSession(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateSession(PlayerAuth auth) {
|
||||
PreparedStatement pst = null;
|
||||
@ -284,10 +280,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#purgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public int purgeDatabase(long until) {
|
||||
PreparedStatement pst = null;
|
||||
@ -306,10 +302,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method autoPurgeDatabase.
|
||||
*
|
||||
* @param until long
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#autoPurgeDatabase(long)
|
||||
*/
|
||||
@Override
|
||||
public List<String> autoPurgeDatabase(long until) {
|
||||
PreparedStatement pst = null;
|
||||
@ -334,10 +330,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method removeAuth.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#removeAuth(String)
|
||||
*/
|
||||
@Override
|
||||
public synchronized boolean removeAuth(String user) {
|
||||
PreparedStatement pst = null;
|
||||
@ -356,10 +352,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateQuitLoc.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateQuitLoc(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateQuitLoc(PlayerAuth auth) {
|
||||
PreparedStatement pst = null;
|
||||
@ -382,10 +378,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getIps.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String) */
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getIps(String)
|
||||
*/
|
||||
@Override
|
||||
public int getIps(String ip) {
|
||||
PreparedStatement pst = null;
|
||||
@ -410,10 +406,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateEmail.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateEmail(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateEmail(PlayerAuth auth) {
|
||||
PreparedStatement pst = null;
|
||||
@ -433,10 +429,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateSalt.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#updateSalt(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public boolean updateSalt(PlayerAuth auth) {
|
||||
if (columnSalt.isEmpty()) {
|
||||
@ -459,6 +455,7 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method close.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#close()
|
||||
*/
|
||||
@Override
|
||||
@ -472,6 +469,7 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method reload.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#reload()
|
||||
*/
|
||||
@Override
|
||||
@ -480,6 +478,7 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method close.
|
||||
*
|
||||
* @param st Statement
|
||||
*/
|
||||
private void close(Statement st) {
|
||||
@ -494,6 +493,7 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method close.
|
||||
*
|
||||
* @param rs ResultSet
|
||||
*/
|
||||
private void close(ResultSet rs) {
|
||||
@ -508,10 +508,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByName.
|
||||
*
|
||||
* @param auth PlayerAuth
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByName(PlayerAuth)
|
||||
*/
|
||||
@Override
|
||||
public List<String> getAllAuthsByName(PlayerAuth auth) {
|
||||
PreparedStatement pst = null;
|
||||
@ -538,10 +538,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByIp.
|
||||
*
|
||||
* @param ip String
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByIp(String)
|
||||
*/
|
||||
@Override
|
||||
public List<String> getAllAuthsByIp(String ip) {
|
||||
PreparedStatement pst = null;
|
||||
@ -568,10 +568,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuthsByEmail.
|
||||
*
|
||||
* @param email String
|
||||
|
||||
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String) */
|
||||
* @return List<String> * @see fr.xephi.authme.datasource.DataSource#getAllAuthsByEmail(String)
|
||||
*/
|
||||
@Override
|
||||
public List<String> getAllAuthsByEmail(String email) {
|
||||
PreparedStatement pst = null;
|
||||
@ -598,9 +598,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeBanned.
|
||||
*
|
||||
* @param banned List<String>
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeBanned(List<String>)
|
||||
*/
|
||||
@Override
|
||||
public void purgeBanned(List<String> banned) {
|
||||
PreparedStatement pst = null;
|
||||
@ -619,9 +620,9 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getType.
|
||||
|
||||
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType() */
|
||||
*
|
||||
* @return DataSourceType * @see fr.xephi.authme.datasource.DataSource#getType()
|
||||
*/
|
||||
@Override
|
||||
public DataSourceType getType() {
|
||||
return DataSourceType.SQLITE;
|
||||
@ -629,10 +630,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method isLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String) */
|
||||
* @return boolean * @see fr.xephi.authme.datasource.DataSource#isLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public boolean isLogged(String user) {
|
||||
PreparedStatement pst = null;
|
||||
@ -655,9 +656,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setLogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setLogged(String)
|
||||
*/
|
||||
@Override
|
||||
public void setLogged(String user) {
|
||||
PreparedStatement pst = null;
|
||||
@ -675,9 +677,10 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method setUnlogged.
|
||||
*
|
||||
* @param user String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#setUnlogged(String)
|
||||
*/
|
||||
@Override
|
||||
public void setUnlogged(String user) {
|
||||
PreparedStatement pst = null;
|
||||
@ -696,6 +699,7 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method purgeLogged.
|
||||
*
|
||||
* @see fr.xephi.authme.datasource.DataSource#purgeLogged()
|
||||
*/
|
||||
@Override
|
||||
@ -715,9 +719,9 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAccountsRegistered.
|
||||
|
||||
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered() */
|
||||
*
|
||||
* @return int * @see fr.xephi.authme.datasource.DataSource#getAccountsRegistered()
|
||||
*/
|
||||
@Override
|
||||
public int getAccountsRegistered() {
|
||||
int result = 0;
|
||||
@ -740,10 +744,11 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method updateName.
|
||||
*
|
||||
* @param oldone String
|
||||
* @param newone String
|
||||
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String) */
|
||||
* @see fr.xephi.authme.datasource.DataSource#updateName(String, String)
|
||||
*/
|
||||
@Override
|
||||
public void updateName(String oldone, String newone) {
|
||||
PreparedStatement pst = null;
|
||||
@ -761,9 +766,9 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getAllAuths.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getAllAuths()
|
||||
*/
|
||||
@Override
|
||||
public List<PlayerAuth> getAllAuths() {
|
||||
List<PlayerAuth> auths = new ArrayList<>();
|
||||
@ -796,9 +801,9 @@ public class SQLite implements DataSource {
|
||||
|
||||
/**
|
||||
* Method getLoggedPlayers.
|
||||
|
||||
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers() */
|
||||
*
|
||||
* @return List<PlayerAuth> * @see fr.xephi.authme.datasource.DataSource#getLoggedPlayers()
|
||||
*/
|
||||
@Override
|
||||
public List<PlayerAuth> getLoggedPlayers() {
|
||||
List<PlayerAuth> auths = new ArrayList<>();
|
||||
|
@ -5,7 +5,6 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
*
|
||||
* This event is call when a player try to /login
|
||||
*
|
||||
* @author Xephi59
|
||||
@ -13,12 +12,13 @@ import org.bukkit.event.HandlerList;
|
||||
*/
|
||||
public class AuthMeAsyncPreLoginEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Player player;
|
||||
private boolean canLogin = true;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Constructor for AuthMeAsyncPreLoginEvent.
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
public AuthMeAsyncPreLoginEvent(Player player) {
|
||||
@ -28,22 +28,25 @@ public class AuthMeAsyncPreLoginEvent extends Event {
|
||||
|
||||
/**
|
||||
* Method getPlayer.
|
||||
|
||||
* @return Player */
|
||||
*
|
||||
* @return Player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method canLogin.
|
||||
|
||||
* @return boolean */
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean canLogin() {
|
||||
return canLogin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setCanLogin.
|
||||
*
|
||||
* @param canLogin boolean
|
||||
*/
|
||||
public void setCanLogin(boolean canLogin) {
|
||||
@ -52,8 +55,9 @@ public class AuthMeAsyncPreLoginEvent extends Event {
|
||||
|
||||
/**
|
||||
* Method getHandlers.
|
||||
|
||||
* @return HandlerList */
|
||||
*
|
||||
* @return HandlerList
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* This event is call when AuthMe try to teleport a player
|
||||
*
|
||||
* @author Xephi59
|
||||
@ -18,6 +17,7 @@ public class AuthMeTeleportEvent extends CustomEvent {
|
||||
|
||||
/**
|
||||
* Constructor for AuthMeTeleportEvent.
|
||||
*
|
||||
* @param player Player
|
||||
* @param to Location
|
||||
*/
|
||||
@ -29,32 +29,36 @@ public class AuthMeTeleportEvent extends CustomEvent {
|
||||
|
||||
/**
|
||||
* Method getPlayer.
|
||||
|
||||
* @return Player */
|
||||
*
|
||||
* @return Player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getTo.
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public Location getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setTo.
|
||||
*
|
||||
* @param to Location
|
||||
*/
|
||||
public void setTo(Location to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getTo.
|
||||
|
||||
* @return Location */
|
||||
public Location getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getFrom.
|
||||
|
||||
* @return Location */
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public Location getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
@ -5,14 +5,13 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
* @version $Revision: 1.0 $
|
||||
*/
|
||||
public class CustomEvent extends Event implements Cancellable {
|
||||
|
||||
private boolean isCancelled;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private boolean isCancelled;
|
||||
|
||||
public CustomEvent() {
|
||||
super(false);
|
||||
@ -20,42 +19,46 @@ public class CustomEvent extends Event implements Cancellable {
|
||||
|
||||
/**
|
||||
* Constructor for CustomEvent.
|
||||
*
|
||||
* @param b boolean
|
||||
*/
|
||||
public CustomEvent(boolean b) {
|
||||
super(b);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getHandlers.
|
||||
|
||||
* @return HandlerList */
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getHandlerList.
|
||||
|
||||
* @return HandlerList */
|
||||
*
|
||||
* @return HandlerList
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getHandlers.
|
||||
*
|
||||
* @return HandlerList
|
||||
*/
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method isCancelled.
|
||||
|
||||
|
||||
* @return boolean * @see org.bukkit.event.Cancellable#isCancelled() */
|
||||
*
|
||||
* @return boolean * @see org.bukkit.event.Cancellable#isCancelled()
|
||||
*/
|
||||
public boolean isCancelled() {
|
||||
return this.isCancelled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setCancelled.
|
||||
*
|
||||
* @param cancelled boolean
|
||||
|
||||
* @see org.bukkit.event.Cancellable#setCancelled(boolean) */
|
||||
* @see org.bukkit.event.Cancellable#setCancelled(boolean)
|
||||
*/
|
||||
public void setCancelled(boolean cancelled) {
|
||||
this.isCancelled = cancelled;
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* Called if a player is teleported to the authme first spawn
|
||||
*
|
||||
* @author Xephi59
|
||||
@ -18,6 +17,7 @@ public class FirstSpawnTeleportEvent extends CustomEvent {
|
||||
|
||||
/**
|
||||
* Constructor for FirstSpawnTeleportEvent.
|
||||
*
|
||||
* @param player Player
|
||||
* @param from Location
|
||||
* @param to Location
|
||||
@ -31,32 +31,36 @@ public class FirstSpawnTeleportEvent extends CustomEvent {
|
||||
|
||||
/**
|
||||
* Method getPlayer.
|
||||
|
||||
* @return Player */
|
||||
*
|
||||
* @return Player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getTo.
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public Location getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setTo.
|
||||
*
|
||||
* @param to Location
|
||||
*/
|
||||
public void setTo(Location to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getTo.
|
||||
|
||||
* @return Location */
|
||||
public Location getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getFrom.
|
||||
|
||||
* @return Location */
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public Location getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
*
|
||||
* This event is called when a player login or register through AuthMe. The
|
||||
* boolean 'isLogin' will be false if, and only if, login/register failed.
|
||||
*
|
||||
@ -14,12 +13,13 @@ import org.bukkit.event.HandlerList;
|
||||
*/
|
||||
public class LoginEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Player player;
|
||||
private boolean isLogin;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
|
||||
/**
|
||||
* Constructor for LoginEvent.
|
||||
*
|
||||
* @param player Player
|
||||
* @param isLogin boolean
|
||||
*/
|
||||
@ -29,23 +29,44 @@ public class LoginEvent extends Event {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getPlayer.
|
||||
* Method getHandlerList.
|
||||
*
|
||||
* @return HandlerList
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
* @return Player */
|
||||
/**
|
||||
* Method getPlayer.
|
||||
*
|
||||
* @return Player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setPlayer.
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
public void setPlayer(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method isLogin.
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isLogin() {
|
||||
return isLogin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setLogin.
|
||||
*
|
||||
* @param isLogin boolean
|
||||
*/
|
||||
@Deprecated
|
||||
@ -53,29 +74,14 @@ public class LoginEvent extends Event {
|
||||
this.isLogin = isLogin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method isLogin.
|
||||
|
||||
* @return boolean */
|
||||
public boolean isLogin() {
|
||||
return isLogin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getHandlers.
|
||||
|
||||
* @return HandlerList */
|
||||
*
|
||||
* @return HandlerList
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getHandlerList.
|
||||
|
||||
* @return HandlerList */
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
/**
|
||||
*
|
||||
* This event is called when a player logout through AuthMe.
|
||||
*
|
||||
* @author Xephi59
|
||||
@ -13,11 +12,12 @@ import org.bukkit.event.HandlerList;
|
||||
*/
|
||||
public class LogoutEvent extends Event {
|
||||
|
||||
private Player player;
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private Player player;
|
||||
|
||||
/**
|
||||
* Constructor for LogoutEvent.
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
public LogoutEvent(Player player) {
|
||||
@ -25,15 +25,26 @@ public class LogoutEvent extends Event {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getPlayer.
|
||||
* Method getHandlerList.
|
||||
*
|
||||
* @return HandlerList
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
* @return Player */
|
||||
/**
|
||||
* Method getPlayer.
|
||||
*
|
||||
* @return Player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setPlayer.
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
public void setPlayer(Player player) {
|
||||
@ -42,19 +53,12 @@ public class LogoutEvent extends Event {
|
||||
|
||||
/**
|
||||
* Method getHandlers.
|
||||
|
||||
* @return HandlerList */
|
||||
*
|
||||
* @return HandlerList
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getHandlerList.
|
||||
|
||||
* @return HandlerList */
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,20 +1,18 @@
|
||||
package fr.xephi.authme.events;
|
||||
|
||||
import fr.xephi.authme.security.crypts.EncryptionMethod;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import fr.xephi.authme.security.crypts.EncryptionMethod;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* This event is called when we need to compare or get an hash password, for set
|
||||
* a custom EncryptionMethod
|
||||
* </p>
|
||||
*
|
||||
* @see fr.xephi.authme.security.crypts.EncryptionMethod
|
||||
*
|
||||
* @author Xephi59
|
||||
* @version $Revision: 1.0 $
|
||||
* @see fr.xephi.authme.security.crypts.EncryptionMethod
|
||||
*/
|
||||
public class PasswordEncryptionEvent extends Event {
|
||||
|
||||
@ -24,6 +22,7 @@ public class PasswordEncryptionEvent extends Event {
|
||||
|
||||
/**
|
||||
* Constructor for PasswordEncryptionEvent.
|
||||
*
|
||||
* @param method EncryptionMethod
|
||||
* @param playerName String
|
||||
*/
|
||||
@ -34,44 +33,49 @@ public class PasswordEncryptionEvent extends Event {
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getHandlers.
|
||||
* Method getHandlerList.
|
||||
*
|
||||
* @return HandlerList
|
||||
*/
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
* @return HandlerList */
|
||||
/**
|
||||
* Method getHandlers.
|
||||
*
|
||||
* @return HandlerList
|
||||
*/
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getMethod.
|
||||
*
|
||||
* @return EncryptionMethod
|
||||
*/
|
||||
public EncryptionMethod getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setMethod.
|
||||
*
|
||||
* @param method EncryptionMethod
|
||||
*/
|
||||
public void setMethod(EncryptionMethod method) {
|
||||
this.method = method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getMethod.
|
||||
|
||||
* @return EncryptionMethod */
|
||||
public EncryptionMethod getMethod() {
|
||||
return method;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getPlayerName.
|
||||
|
||||
* @return String */
|
||||
*
|
||||
* @return String
|
||||
*/
|
||||
public String getPlayerName() {
|
||||
return playerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getHandlerList.
|
||||
|
||||
* @return HandlerList */
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
/**
|
||||
*
|
||||
* This event is call just after store inventory into cache and will empty the
|
||||
* player inventory.
|
||||
*
|
||||
@ -21,6 +20,7 @@ public class ProtectInventoryEvent extends CustomEvent {
|
||||
|
||||
/**
|
||||
* Constructor for ProtectInventoryEvent.
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
public ProtectInventoryEvent(Player player) {
|
||||
@ -34,30 +34,34 @@ public class ProtectInventoryEvent extends CustomEvent {
|
||||
|
||||
/**
|
||||
* Method getStoredInventory.
|
||||
|
||||
* @return ItemStack[] */
|
||||
*
|
||||
* @return ItemStack[]
|
||||
*/
|
||||
public ItemStack[] getStoredInventory() {
|
||||
return this.storedinventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getStoredArmor.
|
||||
|
||||
* @return ItemStack[] */
|
||||
*
|
||||
* @return ItemStack[]
|
||||
*/
|
||||
public ItemStack[] getStoredArmor() {
|
||||
return this.storedarmor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getPlayer.
|
||||
|
||||
* @return Player */
|
||||
*
|
||||
* @return Player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setNewInventory.
|
||||
*
|
||||
* @param emptyInventory ItemStack[]
|
||||
*/
|
||||
public void setNewInventory(ItemStack[] emptyInventory) {
|
||||
@ -66,14 +70,16 @@ public class ProtectInventoryEvent extends CustomEvent {
|
||||
|
||||
/**
|
||||
* Method getEmptyInventory.
|
||||
|
||||
* @return ItemStack[] */
|
||||
*
|
||||
* @return ItemStack[]
|
||||
*/
|
||||
public ItemStack[] getEmptyInventory() {
|
||||
return this.emptyInventory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setNewArmor.
|
||||
*
|
||||
* @param emptyArmor ItemStack[]
|
||||
*/
|
||||
public void setNewArmor(ItemStack[] emptyArmor) {
|
||||
@ -82,8 +88,9 @@ public class ProtectInventoryEvent extends CustomEvent {
|
||||
|
||||
/**
|
||||
* Method getEmptyArmor.
|
||||
|
||||
* @return ItemStack[] */
|
||||
*
|
||||
* @return ItemStack[]
|
||||
*/
|
||||
public ItemStack[] getEmptyArmor() {
|
||||
return this.emptyArmor;
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* This event is call if, and only if, a player is teleported just after a
|
||||
* register.
|
||||
*
|
||||
@ -19,6 +18,7 @@ public class RegisterTeleportEvent extends CustomEvent {
|
||||
|
||||
/**
|
||||
* Constructor for RegisterTeleportEvent.
|
||||
*
|
||||
* @param player Player
|
||||
* @param to Location
|
||||
*/
|
||||
@ -30,32 +30,36 @@ public class RegisterTeleportEvent extends CustomEvent {
|
||||
|
||||
/**
|
||||
* Method getPlayer.
|
||||
|
||||
* @return Player */
|
||||
*
|
||||
* @return Player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getTo.
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public Location getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setTo.
|
||||
*
|
||||
* @param to Location
|
||||
*/
|
||||
public void setTo(Location to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getTo.
|
||||
|
||||
* @return Location */
|
||||
public Location getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getFrom.
|
||||
|
||||
* @return Location */
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public Location getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package fr.xephi.authme.events;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* This event is call when a creative inventory is reseted.
|
||||
*
|
||||
* @author Xephi59
|
||||
@ -15,6 +14,7 @@ public class ResetInventoryEvent extends CustomEvent {
|
||||
|
||||
/**
|
||||
* Constructor for ResetInventoryEvent.
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
public ResetInventoryEvent(Player player) {
|
||||
@ -24,14 +24,16 @@ public class ResetInventoryEvent extends CustomEvent {
|
||||
|
||||
/**
|
||||
* Method getPlayer.
|
||||
|
||||
* @return Player */
|
||||
*
|
||||
* @return Player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setPlayer.
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
public void setPlayer(Player player) {
|
||||
|
@ -14,6 +14,7 @@ public class RestoreInventoryEvent extends CustomEvent {
|
||||
|
||||
/**
|
||||
* Constructor for RestoreInventoryEvent.
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
public RestoreInventoryEvent(Player player) {
|
||||
@ -22,6 +23,7 @@ public class RestoreInventoryEvent extends CustomEvent {
|
||||
|
||||
/**
|
||||
* Constructor for RestoreInventoryEvent.
|
||||
*
|
||||
* @param player Player
|
||||
* @param async boolean
|
||||
*/
|
||||
@ -32,14 +34,16 @@ public class RestoreInventoryEvent extends CustomEvent {
|
||||
|
||||
/**
|
||||
* Method getPlayer.
|
||||
|
||||
* @return Player */
|
||||
*
|
||||
* @return Player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return this.player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setPlayer.
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
public void setPlayer(Player player) {
|
||||
|
@ -4,7 +4,6 @@ import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* Called if a player is teleported to a specific spawn
|
||||
*
|
||||
* @author Xephi59
|
||||
@ -19,6 +18,7 @@ public class SpawnTeleportEvent extends CustomEvent {
|
||||
|
||||
/**
|
||||
* Constructor for SpawnTeleportEvent.
|
||||
*
|
||||
* @param player Player
|
||||
* @param from Location
|
||||
* @param to Location
|
||||
@ -34,40 +34,45 @@ public class SpawnTeleportEvent extends CustomEvent {
|
||||
|
||||
/**
|
||||
* Method getPlayer.
|
||||
|
||||
* @return Player */
|
||||
*
|
||||
* @return Player
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getTo.
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public Location getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setTo.
|
||||
*
|
||||
* @param to Location
|
||||
*/
|
||||
public void setTo(Location to) {
|
||||
this.to = to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getTo.
|
||||
|
||||
* @return Location */
|
||||
public Location getTo() {
|
||||
return to;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getFrom.
|
||||
|
||||
* @return Location */
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public Location getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method isAuthenticated.
|
||||
|
||||
* @return boolean */
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean isAuthenticated() {
|
||||
return isAuthenticated;
|
||||
}
|
||||
|
@ -1,12 +1,10 @@
|
||||
package fr.xephi.authme.hooks;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.messaging.PluginMessageListener;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -16,6 +14,7 @@ public class BungeeCordMessage implements PluginMessageListener {
|
||||
|
||||
/**
|
||||
* Constructor for BungeeCordMessage.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public BungeeCordMessage(AuthMe plugin) {
|
||||
@ -24,11 +23,12 @@ public class BungeeCordMessage implements PluginMessageListener {
|
||||
|
||||
/**
|
||||
* Method onPluginMessageReceived.
|
||||
*
|
||||
* @param channel String
|
||||
* @param player Player
|
||||
* @param message byte[]
|
||||
|
||||
* @see org.bukkit.plugin.messaging.PluginMessageListener#onPluginMessageReceived(String, Player, byte[]) */
|
||||
* @see org.bukkit.plugin.messaging.PluginMessageListener#onPluginMessageReceived(String, Player, byte[])
|
||||
*/
|
||||
@Override
|
||||
public void onPluginMessageReceived(String channel, Player player,
|
||||
byte[] message) {
|
||||
|
@ -1,11 +1,10 @@
|
||||
package fr.xephi.authme.hooks;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import fr.xephi.authme.settings.CustomConfiguration;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
|
||||
import fr.xephi.authme.settings.CustomConfiguration;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -21,8 +20,9 @@ public class EssSpawn extends CustomConfiguration {
|
||||
|
||||
/**
|
||||
* Method getInstance.
|
||||
|
||||
* @return EssSpawn */
|
||||
*
|
||||
* @return EssSpawn
|
||||
*/
|
||||
public static EssSpawn getInstance() {
|
||||
if (spawn == null) {
|
||||
spawn = new EssSpawn();
|
||||
@ -32,8 +32,9 @@ public class EssSpawn extends CustomConfiguration {
|
||||
|
||||
/**
|
||||
* Method getLocation.
|
||||
|
||||
* @return Location */
|
||||
*
|
||||
* @return Location
|
||||
*/
|
||||
public Location getLocation() {
|
||||
try {
|
||||
if (!this.contains("spawns.default.world"))
|
||||
|
@ -1,14 +1,13 @@
|
||||
package fr.xephi.authme.listener;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class AuthMeBlockListener implements Listener {
|
||||
@ -17,6 +16,7 @@ public class AuthMeBlockListener implements Listener {
|
||||
|
||||
/**
|
||||
* Constructor for AuthMeBlockListener.
|
||||
*
|
||||
* @param instance AuthMe
|
||||
*/
|
||||
public AuthMeBlockListener(AuthMe instance) {
|
||||
@ -26,6 +26,7 @@ public class AuthMeBlockListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onBlockPlace.
|
||||
*
|
||||
* @param event BlockPlaceEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
@ -37,6 +38,7 @@ public class AuthMeBlockListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onBlockBreak.
|
||||
*
|
||||
* @param event BlockBreakEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
|
@ -1,7 +1,7 @@
|
||||
package fr.xephi.authme.listener;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -9,29 +9,22 @@ import org.bukkit.entity.Projectile;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityInteractEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.event.entity.EntityTargetEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class AuthMeEntityListener implements Listener {
|
||||
|
||||
public AuthMe instance;
|
||||
private static Method getShooter;
|
||||
private static boolean shooterIsProjectileSource;
|
||||
public AuthMe instance;
|
||||
|
||||
/**
|
||||
* Constructor for AuthMeEntityListener.
|
||||
*
|
||||
* @param instance AuthMe
|
||||
*/
|
||||
public AuthMeEntityListener(AuthMe instance) {
|
||||
@ -45,6 +38,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onEntityDamage.
|
||||
*
|
||||
* @param event EntityDamageEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
@ -65,6 +59,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onEntityTarget.
|
||||
*
|
||||
* @param event EntityTargetEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
@ -84,6 +79,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onDmg.
|
||||
*
|
||||
* @param event EntityDamageByEntityEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
@ -103,6 +99,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onFoodLevelChange.
|
||||
*
|
||||
* @param event FoodLevelChangeEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
@ -121,6 +118,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method entityRegainHealthEvent.
|
||||
*
|
||||
* @param event EntityRegainHealthEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
@ -140,6 +138,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onEntityInteract.
|
||||
*
|
||||
* @param event EntityInteractEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
@ -158,6 +157,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onLowestEntityInteract.
|
||||
*
|
||||
* @param event EntityInteractEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
@ -175,8 +175,10 @@ public class AuthMeEntityListener implements Listener {
|
||||
}
|
||||
|
||||
// TODO: Need to check this, player can't throw snowball but the item is taken.
|
||||
|
||||
/**
|
||||
* Method onProjectileLaunch.
|
||||
*
|
||||
* @param event ProjectileLaunchEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
@ -213,6 +215,7 @@ public class AuthMeEntityListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onShoot.
|
||||
*
|
||||
* @param event EntityShootBowEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||
|
@ -16,25 +16,23 @@
|
||||
*/
|
||||
package fr.xephi.authme.listener;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.ProtocolManager;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketContainer;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
*/
|
||||
@ -48,6 +46,7 @@ public class AuthMeInventoryPacketAdapter extends PacketAdapter {
|
||||
|
||||
/**
|
||||
* Constructor for AuthMeInventoryPacketAdapter.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public AuthMeInventoryPacketAdapter(AuthMe plugin) {
|
||||
@ -56,9 +55,10 @@ public class AuthMeInventoryPacketAdapter extends PacketAdapter {
|
||||
|
||||
/**
|
||||
* Method onPacketSending.
|
||||
*
|
||||
* @param packetEvent PacketEvent
|
||||
|
||||
* @see com.comphenix.protocol.events.PacketListener#onPacketSending(PacketEvent) */
|
||||
* @see com.comphenix.protocol.events.PacketListener#onPacketSending(PacketEvent)
|
||||
*/
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent packetEvent) {
|
||||
Player player = packetEvent.getPlayer();
|
||||
@ -77,6 +77,7 @@ public class AuthMeInventoryPacketAdapter extends PacketAdapter {
|
||||
|
||||
/**
|
||||
* Method sendInventoryPacket.
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
public void sendInventoryPacket(Player player) {
|
||||
|
@ -1,12 +1,18 @@
|
||||
package fr.xephi.authme.listener;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.GeoLiteAPI;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
@ -19,52 +25,28 @@ import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerFishEvent;
|
||||
import org.bukkit.event.player.PlayerGameModeChangeEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerItemConsumeEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerShearEntityEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.settings.Messages;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class AuthMePlayerListener implements Listener {
|
||||
|
||||
public AuthMe plugin;
|
||||
private Messages m = Messages.getInstance();
|
||||
|
||||
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<>();
|
||||
|
||||
/**
|
||||
* Constructor for AuthMePlayerListener.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public AuthMePlayerListener(AuthMe plugin) {
|
||||
@ -73,6 +55,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method handleChat.
|
||||
*
|
||||
* @param event AsyncPlayerChatEvent
|
||||
*/
|
||||
private void handleChat(AsyncPlayerChatEvent event) {
|
||||
@ -99,6 +82,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerCommandPreprocess.
|
||||
*
|
||||
* @param event PlayerCommandPreprocessEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
@ -115,6 +99,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerNormalChat.
|
||||
*
|
||||
* @param event AsyncPlayerChatEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||
@ -124,6 +109,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerHighChat.
|
||||
*
|
||||
* @param event AsyncPlayerChatEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
|
||||
@ -133,6 +119,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerChat.
|
||||
*
|
||||
* @param event AsyncPlayerChatEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
@ -142,6 +129,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerHighestChat.
|
||||
*
|
||||
* @param event AsyncPlayerChatEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
@ -151,6 +139,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerEarlyChat.
|
||||
*
|
||||
* @param event AsyncPlayerChatEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
@ -160,6 +149,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerLowChat.
|
||||
*
|
||||
* @param event AsyncPlayerChatEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
|
||||
@ -169,6 +159,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerMove.
|
||||
*
|
||||
* @param event PlayerMoveEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
@ -207,10 +198,11 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method checkAntiBotMod.
|
||||
*
|
||||
* @param player Player
|
||||
*/
|
||||
private void checkAntiBotMod(final Player player) {
|
||||
if (plugin.delayedAntiBot || plugin.antibotMod)
|
||||
if (plugin.delayedAntiBot || plugin.antiBotMod)
|
||||
return;
|
||||
if (plugin.getPermissionsManager().hasPermission(player, "authme.bypassantibot"))
|
||||
return;
|
||||
@ -222,7 +214,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (plugin.antibotMod) {
|
||||
if (plugin.antiBotMod) {
|
||||
plugin.switchAntiBotMod(false);
|
||||
antibot.clear();
|
||||
for (String s : m.send("antibot_auto_disabled"))
|
||||
@ -244,6 +236,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerJoin.
|
||||
*
|
||||
* @param event PlayerJoinEvent
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@ -275,6 +268,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPreLogin.
|
||||
*
|
||||
* @param event AsyncPlayerPreLoginEvent
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@ -306,6 +300,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerLogin.
|
||||
*
|
||||
* @param event PlayerLoginEvent
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@ -329,7 +324,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
boolean isAuthAvailable = plugin.database.isAuthAvailable(name);
|
||||
if (!Settings.countriesBlacklist.isEmpty() && !isAuthAvailable && !permsMan.hasPermission(player, "authme.bypassantibot")) {
|
||||
String code = Utils.getCountryCode(event.getAddress().getHostAddress());
|
||||
String code = GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress());
|
||||
if (((code == null) || Settings.countriesBlacklist.contains(code))) {
|
||||
event.setKickMessage(m.send("country_banned")[0]);
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
@ -337,7 +332,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
if (Settings.enableProtection && !Settings.countries.isEmpty() && !isAuthAvailable && !permsMan.hasPermission(player, "authme.bypassantibot")) {
|
||||
String code = Utils.getCountryCode(event.getAddress().getHostAddress());
|
||||
String code = GeoLiteAPI.getCountryCode(event.getAddress().getHostAddress());
|
||||
if (((code == null) || !Settings.countries.contains(code))) {
|
||||
event.setKickMessage(m.send("country_banned")[0]);
|
||||
event.setResult(PlayerLoginEvent.Result.KICK_OTHER);
|
||||
@ -429,6 +424,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerQuit.
|
||||
*
|
||||
* @param event PlayerQuitEvent
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@ -448,6 +444,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerKick.
|
||||
*
|
||||
* @param event PlayerKickEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
|
||||
@ -467,6 +464,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerPickupItem.
|
||||
*
|
||||
* @param event PlayerPickupItemEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
@ -478,6 +476,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerInteract.
|
||||
*
|
||||
* @param event PlayerInteractEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
@ -490,6 +489,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerConsumeItem.
|
||||
*
|
||||
* @param event PlayerItemConsumeEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||
@ -501,6 +501,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerInventoryOpen.
|
||||
*
|
||||
* @param event InventoryOpenEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
@ -525,6 +526,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerInventoryClick.
|
||||
*
|
||||
* @param event InventoryClickEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
@ -540,6 +542,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method playerHitPlayerEvent.
|
||||
*
|
||||
* @param event EntityDamageByEntityEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
@ -556,6 +559,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerInteractEntity.
|
||||
*
|
||||
* @param event PlayerInteractEntityEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
@ -568,6 +572,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerDropItem.
|
||||
*
|
||||
* @param event PlayerDropItemEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
@ -579,6 +584,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerBedEnter.
|
||||
*
|
||||
* @param event PlayerBedEnterEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
@ -590,6 +596,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onSignChange.
|
||||
*
|
||||
* @param event SignChangeEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||
@ -601,6 +608,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerRespawn.
|
||||
*
|
||||
* @param event PlayerRespawnEvent
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@ -621,6 +629,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerGameModeChange.
|
||||
*
|
||||
* @param event PlayerGameModeChangeEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
|
||||
@ -643,6 +652,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerShear.
|
||||
*
|
||||
* @param event PlayerShearEntityEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||
@ -655,6 +665,7 @@ public class AuthMePlayerListener implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerFish.
|
||||
*
|
||||
* @param event PlayerFishEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||
|
@ -1,14 +1,13 @@
|
||||
package fr.xephi.authme.listener;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerEditBookEvent;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.util.Utils;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class AuthMePlayerListener16 implements Listener {
|
||||
@ -17,6 +16,7 @@ public class AuthMePlayerListener16 implements Listener {
|
||||
|
||||
/**
|
||||
* Constructor for AuthMePlayerListener16.
|
||||
*
|
||||
* @param plugin AuthMe
|
||||
*/
|
||||
public AuthMePlayerListener16(AuthMe plugin) {
|
||||
@ -25,6 +25,7 @@ public class AuthMePlayerListener16 implements Listener {
|
||||
|
||||
/**
|
||||
* Method onPlayerEditBook.
|
||||
*
|
||||
* @param event PlayerEditBookEvent
|
||||
*/
|
||||
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user