#604 - Move ProtocolLib adapters to new package and add ProtocolLibService

This commit is contained in:
Gnat008
2016-06-27 15:38:43 -04:00
parent 1361174892
commit 23836cda6a
10 changed files with 188 additions and 109 deletions
@@ -9,6 +9,7 @@ import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.ProtectInventoryEvent;
import fr.xephi.authme.hooks.PluginHooks;
import fr.xephi.authme.listener.protocollib.ProtocolLibService;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.permission.PlayerStatePermission;
@@ -68,6 +69,9 @@ public class AsynchronousJoin implements AsynchronousProcess {
@Inject
private BukkitService bukkitService;
@Inject
private ProtocolLibService protocolLibService;
@Inject
private LimboPlayerTaskManager limboPlayerTaskManager;
@@ -126,11 +130,11 @@ public class AsynchronousJoin implements AsynchronousProcess {
limboCache.updateLimboPlayer(player);
// Protect inventory
if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN) && plugin.getInventoryProtector() != null) {
if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN)) {
ProtectInventoryEvent ev = new ProtectInventoryEvent(player);
bukkitService.callEvent(ev);
if (ev.isCancelled()) {
plugin.getInventoryProtector().sendInventoryPacket(player);
protocolLibService.sendInventoryPacket(player);
if (!service.getProperty(SecuritySettings.REMOVE_SPAM_FROM_CONSOLE)) {
ConsoleLogger.info("ProtectInventoryEvent has been cancelled for " + player.getName() + "...");
}
@@ -10,6 +10,7 @@ import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.LoginEvent;
import fr.xephi.authme.events.RestoreInventoryEvent;
import fr.xephi.authme.listener.AuthMePlayerListener;
import fr.xephi.authme.listener.protocollib.ProtocolLibService;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.process.SynchronousProcess;
@@ -50,6 +51,9 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
@Inject
private BukkitService bukkitService;
@Inject
private ProtocolLibService protocolLibService;
@Inject
private PluginManager pluginManager;
@@ -106,8 +110,8 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
restoreInventory(player);
}
if (service.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN) && plugin.getTablistHider() != null) {
plugin.getTablistHider().sendTablist(player);
if (service.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN)) {
protocolLibService.sendTabList(player);
}
// Clean up no longer used temporary data
@@ -6,6 +6,7 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.SessionManager;
import fr.xephi.authme.events.LogoutEvent;
import fr.xephi.authme.listener.protocollib.ProtocolLibService;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.process.SynchronousProcess;
@@ -34,6 +35,9 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
@Inject
private BukkitService bukkitService;
@Inject
private ProtocolLibService protocolLibService;
@Inject
private LimboPlayerTaskManager limboPlayerTaskManager;
@@ -66,7 +70,7 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
sessionManager.cancelSession(name);
}
if (service.getProperty(RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN)) {
plugin.getInventoryProtector().sendBlankInventoryPacket(player);
protocolLibService.sendBlankInventoryPacket(player);
}
limboPlayerTaskManager.registerTimeoutTask(player);
@@ -8,6 +8,7 @@ import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.LimboPlayer;
import fr.xephi.authme.events.LoginEvent;
import fr.xephi.authme.events.RestoreInventoryEvent;
import fr.xephi.authme.listener.protocollib.ProtocolLibService;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.process.ProcessService;
@@ -42,6 +43,9 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
@Inject
private BukkitService bukkitService;
@Inject
private ProtocolLibService protocolLibService;
@Inject
private LimboCache limboCache;
@@ -92,17 +96,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.getTablistHider() != null) {
plugin.getTablistHider().sendTablist(player);
if (service.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN)) {
protocolLibService.sendTabList(player);
}
Utils.teleportToSpawn(player);
if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN) && plugin.getInventoryProtector() != null) {
if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN)) {
RestoreInventoryEvent event = new RestoreInventoryEvent(player);
bukkitService.callEvent(event);
if (!event.isCancelled()) {
plugin.getInventoryProtector().sendInventoryPacket(player);
protocolLibService.sendInventoryPacket(player);
}
}