more ProtocolLib reload support.
This commit is contained in:
parent
fd12efa2c0
commit
757f231ceb
@ -677,13 +677,19 @@ public class AuthMe extends JavaPlugin {
|
|||||||
inventoryProtector.unregister();
|
inventoryProtector.unregister();
|
||||||
inventoryProtector = null;
|
inventoryProtector = null;
|
||||||
}
|
}
|
||||||
if (tabComplete == null && newSettings.getProperty(RestrictionSettings.DENY_TABCOMPLETE_BEFORE_LOGIN)) {
|
if (newSettings.getProperty(RestrictionSettings.DENY_TABCOMPLETE_BEFORE_LOGIN) && tabComplete == null) {
|
||||||
tabComplete = new AuthMeTabCompletePacketAdapter(this);
|
tabComplete = new AuthMeTabCompletePacketAdapter(this);
|
||||||
tabComplete.register();
|
tabComplete.register();
|
||||||
|
} else if (inventoryProtector != null) {
|
||||||
|
tabComplete.unregister();
|
||||||
|
tabComplete = null;
|
||||||
}
|
}
|
||||||
if (tablistHider == null && newSettings.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN)) {
|
if (newSettings.getProperty(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN) && tablistHider == null) {
|
||||||
tablistHider = new AuthMeTablistPacketAdapter(this);
|
tablistHider = new AuthMeTablistPacketAdapter(this);
|
||||||
tablistHider.register();
|
tablistHider.register();
|
||||||
|
} else if (inventoryProtector != null) {
|
||||||
|
tablistHider.unregister();
|
||||||
|
tablistHider = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -81,6 +81,8 @@ public class AuthMeServerListener implements Listener {
|
|||||||
}
|
}
|
||||||
if (pluginName.equalsIgnoreCase("ProtocolLib")) {
|
if (pluginName.equalsIgnoreCase("ProtocolLib")) {
|
||||||
plugin.inventoryProtector = null;
|
plugin.inventoryProtector = null;
|
||||||
|
plugin.tablistHider = null;
|
||||||
|
plugin.tabComplete = null;
|
||||||
ConsoleLogger.showError("ProtocolLib has been disabled, unhook packet inventory protection!");
|
ConsoleLogger.showError("ProtocolLib has been disabled, unhook packet inventory protection!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,32 +6,27 @@ import com.comphenix.protocol.events.ListenerPriority;
|
|||||||
import com.comphenix.protocol.events.PacketAdapter;
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.comphenix.protocol.reflect.FieldAccessException;
|
import com.comphenix.protocol.reflect.FieldAccessException;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
|
|
||||||
public class AuthMeTabCompletePacketAdapter extends PacketAdapter {
|
public class AuthMeTabCompletePacketAdapter extends PacketAdapter {
|
||||||
|
|
||||||
public AuthMeTabCompletePacketAdapter(AuthMe plugin) {
|
public AuthMeTabCompletePacketAdapter(AuthMe plugin) {
|
||||||
super(plugin, ListenerPriority.NORMAL, PacketType.Play.Client.TAB_COMPLETE);
|
super(plugin, ListenerPriority.NORMAL, PacketType.Play.Client.TAB_COMPLETE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPacketReceiving(PacketEvent event)
|
public void onPacketReceiving(PacketEvent event) {
|
||||||
{
|
if (event.getPacketType() == PacketType.Play.Client.TAB_COMPLETE) {
|
||||||
if (event.getPacketType() == PacketType.Play.Client.TAB_COMPLETE) {
|
try {
|
||||||
try
|
if (!PlayerCache.getInstance().isAuthenticated(event.getPlayer().getName().toLowerCase())) {
|
||||||
{
|
event.setCancelled(true);
|
||||||
if (!PlayerCache.getInstance().isAuthenticated(event.getPlayer().getName().toLowerCase())) {
|
}
|
||||||
event.setCancelled(true);
|
} catch (FieldAccessException e) {
|
||||||
}
|
ConsoleLogger.showError("Couldn't access field.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (FieldAccessException e)
|
|
||||||
{
|
|
||||||
ConsoleLogger.showError("Couldn't access field.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
|
|||||||
@ -6,32 +6,27 @@ import com.comphenix.protocol.events.ListenerPriority;
|
|||||||
import com.comphenix.protocol.events.PacketAdapter;
|
import com.comphenix.protocol.events.PacketAdapter;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import com.comphenix.protocol.reflect.FieldAccessException;
|
import com.comphenix.protocol.reflect.FieldAccessException;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||||
|
|
||||||
public class AuthMeTablistPacketAdapter extends PacketAdapter {
|
public class AuthMeTablistPacketAdapter extends PacketAdapter {
|
||||||
|
|
||||||
public AuthMeTablistPacketAdapter(AuthMe plugin) {
|
public AuthMeTablistPacketAdapter(AuthMe plugin) {
|
||||||
super(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.PLAYER_INFO);
|
super(plugin, ListenerPriority.NORMAL, PacketType.Play.Server.PLAYER_INFO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent event)
|
public void onPacketSending(PacketEvent event) {
|
||||||
{
|
if (event.getPacketType() == PacketType.Play.Server.PLAYER_INFO) {
|
||||||
if (event.getPacketType() == PacketType.Play.Server.PLAYER_INFO) {
|
try {
|
||||||
try
|
if (!PlayerCache.getInstance().isAuthenticated(event.getPlayer().getName().toLowerCase())) {
|
||||||
{
|
event.setCancelled(true);
|
||||||
if (!PlayerCache.getInstance().isAuthenticated(event.getPlayer().getName().toLowerCase())) {
|
}
|
||||||
event.setCancelled(true);
|
} catch (FieldAccessException e) {
|
||||||
}
|
ConsoleLogger.showError("Couldn't access field.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (FieldAccessException e)
|
|
||||||
{
|
|
||||||
ConsoleLogger.showError("Couldn't access field.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void register() {
|
public void register() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user