mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-18 16:25:11 +01:00
Add TabComplete support through ProtocolLib
This commit is contained in:
parent
ac0225c621
commit
edffae3a36
@ -31,6 +31,7 @@ import fr.xephi.authme.listener.AuthMePlayerListener16;
|
||||
import fr.xephi.authme.listener.AuthMePlayerListener18;
|
||||
import fr.xephi.authme.listener.AuthMeServerListener;
|
||||
import fr.xephi.authme.listener.AuthMeServerStop;
|
||||
import fr.xephi.authme.listener.AuthMeTabCompletePacketAdapter;
|
||||
import fr.xephi.authme.mail.SendMailSSL;
|
||||
import fr.xephi.authme.modules.ModuleManager;
|
||||
import fr.xephi.authme.output.ConsoleFilter;
|
||||
@ -117,6 +118,7 @@ public class AuthMe extends JavaPlugin {
|
||||
public MultiverseCore multiverse;
|
||||
public CombatTagPlus combatTagPlus;
|
||||
public AuthMeInventoryPacketAdapter inventoryProtector;
|
||||
public AuthMeTabCompletePacketAdapter tabComplete;
|
||||
|
||||
/*
|
||||
* Maps and stuff
|
||||
@ -710,6 +712,11 @@ public class AuthMe extends JavaPlugin {
|
||||
inventoryProtector = null;
|
||||
}
|
||||
}
|
||||
if (tabComplete == null)
|
||||
{
|
||||
tabComplete = new AuthMeTabCompletePacketAdapter(this);
|
||||
tabComplete.register();
|
||||
}
|
||||
}
|
||||
|
||||
// Save Player Data
|
||||
|
@ -0,0 +1,45 @@
|
||||
package fr.xephi.authme.listener;
|
||||
|
||||
import com.comphenix.protocol.PacketType;
|
||||
import com.comphenix.protocol.ProtocolLibrary;
|
||||
import com.comphenix.protocol.events.ListenerPriority;
|
||||
import com.comphenix.protocol.events.PacketAdapter;
|
||||
import com.comphenix.protocol.events.PacketEvent;
|
||||
import com.comphenix.protocol.reflect.FieldAccessException;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
|
||||
public class AuthMeTabCompletePacketAdapter extends PacketAdapter {
|
||||
|
||||
public AuthMeTabCompletePacketAdapter(AuthMe plugin) {
|
||||
super(plugin, ListenerPriority.NORMAL, PacketType.Play.Client.TAB_COMPLETE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketReceiving(PacketEvent event)
|
||||
{
|
||||
if (event.getPacketType() == PacketType.Play.Client.TAB_COMPLETE) {
|
||||
try
|
||||
{
|
||||
String message = ((String)event.getPacket().getSpecificModifier(String.class).read(0)).toLowerCase();
|
||||
if ((message.startsWith("")) && (!message.contains(" ")) && !PlayerCache.getInstance().isAuthenticated(event.getPlayer().getName().toLowerCase())) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
catch (FieldAccessException e)
|
||||
{
|
||||
ConsoleLogger.showError("Couldn't access field.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void register() {
|
||||
ProtocolLibrary.getProtocolManager().addPacketListener(this);
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
ProtocolLibrary.getProtocolManager().removePacketListener(this);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user