Fix ProtocolLib services are disabling after authme reload

Using the previous else branch we would always call unregister if the feature
was enabled before.
This commit is contained in:
games647 2018-03-04 14:29:08 +01:00
parent 930f5609bf
commit 914c4adc0b
No known key found for this signature in database
GPG Key ID: BFC68C8708713A88

View File

@ -5,9 +5,9 @@ import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger; import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.data.auth.PlayerCache; import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.initialization.SettingsDependent; import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.settings.Settings; import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.RestrictionSettings; import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.service.BukkitService;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import javax.inject.Inject; import javax.inject.Inject;
@ -56,16 +56,21 @@ public class ProtocolLibService implements SettingsDependent {
} }
// Set up packet adapters // Set up packet adapters
if (protectInvBeforeLogin && inventoryPacketAdapter == null) { if (protectInvBeforeLogin) {
if (inventoryPacketAdapter == null) {
inventoryPacketAdapter = new InventoryPacketAdapter(plugin, playerCache); inventoryPacketAdapter = new InventoryPacketAdapter(plugin, playerCache);
inventoryPacketAdapter.register(); inventoryPacketAdapter.register();
}
} else if (inventoryPacketAdapter != null) { } else if (inventoryPacketAdapter != null) {
inventoryPacketAdapter.unregister(); inventoryPacketAdapter.unregister();
inventoryPacketAdapter = null; inventoryPacketAdapter = null;
} }
if (denyTabCompleteBeforeLogin && tabCompletePacketAdapter == null) {
if (denyTabCompleteBeforeLogin) {
if (tabCompletePacketAdapter == null) {
tabCompletePacketAdapter = new TabCompletePacketAdapter(plugin, playerCache); tabCompletePacketAdapter = new TabCompletePacketAdapter(plugin, playerCache);
tabCompletePacketAdapter.register(); tabCompletePacketAdapter.register();
}
} else if (tabCompletePacketAdapter != null) { } else if (tabCompletePacketAdapter != null) {
tabCompletePacketAdapter.unregister(); tabCompletePacketAdapter.unregister();
tabCompletePacketAdapter = null; tabCompletePacketAdapter = null;
@ -106,7 +111,7 @@ public class ProtocolLibService implements SettingsDependent {
this.denyTabCompleteBeforeLogin = settings.getProperty(RestrictionSettings.DENY_TABCOMPLETE_BEFORE_LOGIN); this.denyTabCompleteBeforeLogin = settings.getProperty(RestrictionSettings.DENY_TABCOMPLETE_BEFORE_LOGIN);
//it was true and will be deactivated now, so we need to restore the inventory for every player //it was true and will be deactivated now, so we need to restore the inventory for every player
if (oldProtectInventory && !protectInvBeforeLogin) { if (oldProtectInventory && !protectInvBeforeLogin && inventoryPacketAdapter != null) {
inventoryPacketAdapter.unregister(); inventoryPacketAdapter.unregister();
for (Player onlinePlayer : bukkitService.getOnlinePlayers()) { for (Player onlinePlayer : bukkitService.getOnlinePlayers()) {
if (!playerCache.isAuthenticated(onlinePlayer.getName())) { if (!playerCache.isAuthenticated(onlinePlayer.getName())) {