mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-27 12:45:57 +01:00
parent
99704e7c29
commit
0c96a3113b
@ -5,7 +5,6 @@ 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;
|
||||
@ -119,17 +118,13 @@ public class AuthMe extends JavaPlugin {
|
||||
private AuthMeServiceInitializer initializer;
|
||||
|
||||
/*
|
||||
* Public instances
|
||||
* Private instances (sessions, mail, and ProtocolLib)
|
||||
*/
|
||||
|
||||
// TODO: Encapsulate session management
|
||||
public final ConcurrentHashMap<String, BukkitTask> sessions = new ConcurrentHashMap<>();
|
||||
// TODO #655: Encapsulate mail
|
||||
public SendMailSSL mail;
|
||||
// TODO #604: Encapsulate ProtocolLib members
|
||||
public AuthMeInventoryPacketAdapter inventoryProtector;
|
||||
public AuthMeTabCompletePacketAdapter tabComplete;
|
||||
public AuthMeTablistPacketAdapter tablistHider;
|
||||
private final ConcurrentHashMap<String, BukkitTask> sessions = new ConcurrentHashMap<>();
|
||||
private SendMailSSL mail;
|
||||
private AuthMeInventoryPacketAdapter inventoryProtector;
|
||||
private AuthMeTabCompletePacketAdapter tabComplete;
|
||||
private AuthMeTablistPacketAdapter tablistHider;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -713,6 +708,60 @@ public class AuthMe extends JavaPlugin {
|
||||
return commandHandler.processCommand(sender, commandLabel, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all current player sessions.
|
||||
*
|
||||
* @return A concurrent hashmap containing the sessions.
|
||||
*/
|
||||
public ConcurrentHashMap<String, BukkitTask> getSessions() {
|
||||
return this.sessions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the mailing instance.
|
||||
*
|
||||
* @return The send mail instance.
|
||||
*/
|
||||
public SendMailSSL getMail() {
|
||||
return this.mail;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ProtocolLib inventory packet adapter.
|
||||
*
|
||||
* @return The inventory packet adapter.
|
||||
*/
|
||||
public AuthMeInventoryPacketAdapter getInventoryProtector() {
|
||||
return inventoryProtector;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ProtocolLib tab complete packet adapter.
|
||||
*
|
||||
* @return The tab complete packet adapter.
|
||||
*/
|
||||
public AuthMeTabCompletePacketAdapter getTabComplete() {
|
||||
return tabComplete;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ProtocolLib tab list packet adapter.
|
||||
*
|
||||
* @return The tab list packet adapter.
|
||||
*/
|
||||
public AuthMeTablistPacketAdapter getTablistHider() {
|
||||
return tablistHider;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disables instances should the ProtocolLib plugin be disabled on the server.
|
||||
*/
|
||||
public void disableProtocolLib() {
|
||||
this.inventoryProtector = null;
|
||||
this.tablistHider = null;
|
||||
this.tabComplete = null;
|
||||
}
|
||||
|
||||
// -------------
|
||||
// Service getters (deprecated)
|
||||
// Use @Inject fields instead
|
||||
|
@ -41,7 +41,7 @@ public class RecoverEmailCommand extends PlayerCommand {
|
||||
final String playerMail = arguments.get(0);
|
||||
final String playerName = player.getName();
|
||||
|
||||
if (plugin.mail == null) {
|
||||
if (plugin.getMail() == null) {
|
||||
ConsoleLogger.showError("Mail API is not set");
|
||||
commandService.send(player, MessageKey.ERROR);
|
||||
return;
|
||||
@ -76,7 +76,7 @@ public class RecoverEmailCommand extends PlayerCommand {
|
||||
}
|
||||
auth.setPassword(hashNew);
|
||||
dataSource.updatePassword(auth);
|
||||
plugin.mail.main(auth, thePass);
|
||||
plugin.getMail().main(auth, thePass);
|
||||
commandService.send(player, MessageKey.RECOVERY_EMAIL_SENT_MESSAGE);
|
||||
} else {
|
||||
commandService.send(player, MessageKey.REGISTER_EMAIL_MESSAGE);
|
||||
|
@ -61,9 +61,9 @@ public class BungeeCordMessage implements PluginMessageListener {
|
||||
playerCache.updatePlayer(auth);
|
||||
dataSource.setLogged(name);
|
||||
//START 03062016 sgdc3: should fix #731 but we need to recode this mess
|
||||
if (plugin.sessions.containsKey(name)) {
|
||||
plugin.sessions.get(name).cancel();
|
||||
plugin.sessions.remove(name);
|
||||
if (plugin.getSessions().containsKey(name)) {
|
||||
plugin.getSessions().get(name).cancel();
|
||||
plugin.getSessions().remove(name);
|
||||
}
|
||||
//END
|
||||
|
||||
|
@ -75,9 +75,7 @@ public class AuthMeServerListener implements Listener {
|
||||
}
|
||||
|
||||
if (pluginName.equalsIgnoreCase("ProtocolLib")) {
|
||||
plugin.inventoryProtector = null;
|
||||
plugin.tablistHider = null;
|
||||
plugin.tabComplete = null;
|
||||
plugin.disableProtocolLib();
|
||||
ConsoleLogger.showError("ProtocolLib has been disabled, unhook packet inventory protection!");
|
||||
}
|
||||
}
|
||||
|
@ -122,11 +122,11 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
||||
limboCache.updateLimboPlayer(player);
|
||||
|
||||
// Protect inventory
|
||||
if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN) && plugin.inventoryProtector != null) {
|
||||
if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN) && plugin.getInventoryProtector() != null) {
|
||||
ProtectInventoryEvent ev = new ProtectInventoryEvent(player);
|
||||
bukkitService.callEvent(ev);
|
||||
if (ev.isCancelled()) {
|
||||
plugin.inventoryProtector.sendInventoryPacket(player);
|
||||
plugin.getInventoryProtector().sendInventoryPacket(player);
|
||||
if (!service.getProperty(SecuritySettings.REMOVE_SPAM_FROM_CONSOLE)) {
|
||||
ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + "...");
|
||||
}
|
||||
@ -135,9 +135,9 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
||||
|
||||
// Session logic
|
||||
if (service.getProperty(PluginSettings.SESSIONS_ENABLED) && (playerCache.isAuthenticated(name) || database.isLogged(name))) {
|
||||
if (plugin.sessions.containsKey(name)) {
|
||||
plugin.sessions.get(name).cancel();
|
||||
plugin.sessions.remove(name);
|
||||
if (plugin.getSessions().containsKey(name)) {
|
||||
plugin.getSessions().get(name).cancel();
|
||||
plugin.getSessions().remove(name);
|
||||
}
|
||||
PlayerAuth auth = database.getAuth(name);
|
||||
database.setUnlogged(name);
|
||||
|
@ -106,8 +106,8 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
||||
restoreInventory(player);
|
||||
}
|
||||
|
||||
if (service.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN) && plugin.tablistHider != null) {
|
||||
plugin.tablistHider.sendTablist(player);
|
||||
if (service.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN) && plugin.getTablistHider() != null) {
|
||||
plugin.getTablistHider().sendTablist(player);
|
||||
}
|
||||
|
||||
// Clean up no longer used temporary data
|
||||
|
@ -58,12 +58,12 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
|
||||
|
||||
public void processSyncLogout(Player player) {
|
||||
final String name = player.getName().toLowerCase();
|
||||
if (plugin.sessions.containsKey(name)) {
|
||||
plugin.sessions.get(name).cancel();
|
||||
plugin.sessions.remove(name);
|
||||
if (plugin.getSessions().containsKey(name)) {
|
||||
plugin.getSessions().get(name).cancel();
|
||||
plugin.getSessions().remove(name);
|
||||
}
|
||||
if (service.getProperty(RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN)) {
|
||||
plugin.inventoryProtector.sendBlankInventoryPacket(player);
|
||||
plugin.getInventoryProtector().sendBlankInventoryPacket(player);
|
||||
}
|
||||
|
||||
limboPlayerTaskManager.registerTimeoutTask(player);
|
||||
|
@ -94,7 +94,7 @@ public class AsynchronousQuit implements AsynchronousProcess {
|
||||
|
||||
}, Settings.getSessionTimeout * TICKS_PER_MINUTE);
|
||||
|
||||
plugin.sessions.put(name, task);
|
||||
plugin.getSessions().put(name, task);
|
||||
} else {
|
||||
//plugin is disabled; we cannot schedule more tasks so run it directly here
|
||||
postLogout(name);
|
||||
@ -117,6 +117,6 @@ public class AsynchronousQuit implements AsynchronousProcess {
|
||||
private void postLogout(String name) {
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
database.setUnlogged(name);
|
||||
plugin.sessions.remove(name);
|
||||
plugin.getSessions().remove(name);
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ public class AsyncRegister implements AsynchronousProcess {
|
||||
}
|
||||
database.updateEmail(auth);
|
||||
database.updateSession(auth);
|
||||
plugin.mail.main(auth, password);
|
||||
plugin.getMail().main(auth, password);
|
||||
syncProcessManager.processSyncEmailRegister(player);
|
||||
}
|
||||
|
||||
|
@ -92,17 +92,17 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
|
||||
final String name = player.getName().toLowerCase();
|
||||
LimboPlayer limbo = limboCache.getLimboPlayer(name);
|
||||
if (limbo != null) {
|
||||
if (service.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN) && plugin.tablistHider != null) {
|
||||
plugin.tablistHider.sendTablist(player);
|
||||
if (service.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN) && plugin.getTablistHider() != null) {
|
||||
plugin.getTablistHider().sendTablist(player);
|
||||
}
|
||||
|
||||
Utils.teleportToSpawn(player);
|
||||
|
||||
if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN) && plugin.inventoryProtector != null) {
|
||||
if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN) && plugin.getInventoryProtector() != null) {
|
||||
RestoreInventoryEvent event = new RestoreInventoryEvent(player);
|
||||
bukkitService.callEvent(event);
|
||||
if (!event.isCancelled()) {
|
||||
plugin.inventoryProtector.sendInventoryPacket(player);
|
||||
plugin.getInventoryProtector().sendInventoryPacket(player);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user