mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-11-30 20:39:53 -05:00
Reverse
This commit is contained in:
1 parent
6b6faa5eb8
commit
d058b29898
8 files changed
+44
-18
No files matched your search
@@ -96,6 +96,7 @@ public class Communicator {
|
||||
CommunicationPackets.PacketBundle packetBundle = (CommunicationPackets.PacketBundle) packet;
|
||||
if(!packetBundle.isToken(Storage.TOKEN) || !packetBundle.isId(SERVER_ID.toString())) return;
|
||||
|
||||
Storage.USE_VELOCITY = packetBundle.isVelocity();
|
||||
LAST_BUKKIT_SYNC = System.currentTimeMillis();
|
||||
BukkitLoader.synchronize(packetBundle);
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ public class BukkitPacketAnalyzer {
|
||||
}
|
||||
|
||||
public static boolean inject(Player player) {
|
||||
if(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) return true;
|
||||
if(Storage.USE_VELOCITY) return true;
|
||||
|
||||
try {
|
||||
Channel channel = Reflection.getPlayerChannel(player);
|
||||
@@ -47,7 +47,7 @@ public class BukkitPacketAnalyzer {
|
||||
}
|
||||
|
||||
public static void uninject(UUID uuid) {
|
||||
if(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) return;
|
||||
if(Storage.USE_VELOCITY) return;
|
||||
|
||||
if(BukkitPacketAnalyzer.INJECTED_PLAYERS.containsKey(uuid)) {
|
||||
Channel channel = BukkitPacketAnalyzer.INJECTED_PLAYERS.get(uuid);
|
||||
|
||||
@@ -126,13 +126,13 @@ public class BungeePacketAnalyzer {
|
||||
private static void modifyCommands(ProxiedPlayer player, Commands commands, List<String> list) {
|
||||
list.clear();
|
||||
|
||||
boolean blocked, turn = Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED;
|
||||
for (Map.Entry<String, Command> command : ProxyServer.getInstance().getPluginManager().getCommands()) {
|
||||
if (!ProxyServer.getInstance().getDisabledCommands().contains(command.getKey()) && commands.getRoot().getChild(command.getKey()) == null && command.getValue().hasPermission(player)) {
|
||||
if (Storage.Blacklist.isBlocked(player, command.getKey(), !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED))
|
||||
continue;
|
||||
blocked = Storage.Blacklist.isBlocked(player, command.getKey(), !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
|
||||
if(turn && blocked || !turn && !blocked) continue;
|
||||
|
||||
list.add(command.getKey());
|
||||
|
||||
CommandNode dummy = LiteralArgumentBuilder.literal(command.getKey())
|
||||
.executes(DUMMY_COMMAND)
|
||||
.then(RequiredArgumentBuilder.argument("args", StringArgumentType.greedyString())
|
||||
@@ -166,8 +166,6 @@ public class BungeePacketAnalyzer {
|
||||
|
||||
Commands response = (Commands) wrapper.packet;
|
||||
modifyCommands(player, response, commands);
|
||||
player.getPendingConnection().unsafe().sendPacket(response);
|
||||
return;
|
||||
} else if (wrapper.packet instanceof TabCompleteResponse) {
|
||||
TabCompleteResponse response = (TabCompleteResponse) wrapper.packet;
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ public class Storage {
|
||||
public static String TOKEN = "", SERVER_NAME = null, CURRENT_VERSION = "", NEWER_VERSION = "";
|
||||
public static boolean OUTDATED = false, SEND_CONSOLE_NOTIFICATION = true;
|
||||
public static Object PLUGIN_OBJECT;
|
||||
public static boolean USE_LUCKPERMS = false, USE_VIAVERSION = false;
|
||||
public static boolean USE_LUCKPERMS = false, USE_VIAVERSION = false, USE_VELOCITY = false;
|
||||
|
||||
public static void loadAll(boolean loadBlacklist) {
|
||||
loadConfig();
|
||||
|
||||
@@ -59,13 +59,11 @@ public class BukkitLoader extends JavaPlugin {
|
||||
loaded = true;
|
||||
GroupManager.initialize();
|
||||
BukkitPacketAnalyzer.injectAll();
|
||||
if(Reflection.getMinor() >= 16)
|
||||
manager.registerEvents(new BukkitAntiTabListener(), this);
|
||||
|
||||
} else BackendUpdater.handle();
|
||||
|
||||
manager.registerEvents(new BukkitPlayerConnectionListener(), this);
|
||||
manager.registerEvents(new BukkitBlockCommandListener(), this);
|
||||
if(Reflection.getMinor() >= 16) manager.registerEvents(new BukkitAntiTabListener(), this);
|
||||
|
||||
registerCommand("proantitab", "pat");
|
||||
startUpdaterTask();
|
||||
@@ -126,15 +124,38 @@ public class BukkitLoader extends JavaPlugin {
|
||||
|
||||
public static void synchronize(CommunicationPackets.PacketBundle packetBundle) {
|
||||
Communicator.sendFeedback();
|
||||
|
||||
CommunicationPackets.UnknownCommandPacket unknownCommandPacket = packetBundle.getUnknownCommandPacket();
|
||||
|
||||
if(!Storage.USE_VELOCITY) {
|
||||
CommunicationPackets.CommandsPacket commandsPacket = packetBundle.getCommandsPacket();
|
||||
CommunicationPackets.GroupsPacket groupsPacket = packetBundle.getGroupsPacket();
|
||||
|
||||
if (commandsPacket.getCommands() == null || commandsPacket.getCommands().isEmpty())
|
||||
Storage.Blacklist.getBlacklist().setList(new ArrayList<>());
|
||||
else if (!Storage.Blacklist.getBlacklist().getCommands().containsAll(commandsPacket.getCommands()) || !commandsPacket.getCommands().containsAll(Storage.Blacklist.getBlacklist().getCommands()))
|
||||
Storage.Blacklist.getBlacklist().setList(commandsPacket.getCommands());
|
||||
|
||||
if (Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED != commandsPacket.turnBlacklistToWhitelistEnabled())
|
||||
Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED = commandsPacket.turnBlacklistToWhitelistEnabled();
|
||||
|
||||
GroupManager.clearAllGroups();
|
||||
groupsPacket.getGroups().forEach(group -> GroupManager.setGroup(group.getGroupName(), group.getCommands()));
|
||||
}
|
||||
|
||||
Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.MESSAGE = unknownCommandPacket.getMessage();
|
||||
if(Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.ENABLED != unknownCommandPacket.isEnabled())
|
||||
Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.ENABLED = unknownCommandPacket.isEnabled();
|
||||
Storage.ConfigSections.Settings.CUSTOM_UNKNOWN_COMMAND.MESSAGE = unknownCommandPacket.getMessage();
|
||||
|
||||
if(Reflection.getMinor() >= 16) BukkitAntiTabListener.updateCommands();
|
||||
if(!loaded) loaded = true;
|
||||
|
||||
if(Reflection.getMinor() < 16) return;
|
||||
|
||||
if(Storage.USE_VELOCITY) {
|
||||
BukkitAntiTabListener.updateCommands();
|
||||
return;
|
||||
}
|
||||
|
||||
BukkitAntiTabListener.handleTabCompletion(Storage.Blacklist.getBlacklist().getCommands());
|
||||
}
|
||||
|
||||
public static List<String> getNotBlockedCommands() {
|
||||
|
||||
@@ -18,7 +18,7 @@ public class BukkitAntiTabListener implements Listener {
|
||||
|
||||
@EventHandler (priority = EventPriority.LOWEST)
|
||||
public void onPlayerCommandSend(PlayerCommandSendEvent event) {
|
||||
if(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) return;
|
||||
if(Storage.USE_VELOCITY) return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
UUID uuid = player.getUniqueId();
|
||||
@@ -67,7 +67,7 @@ public class BukkitAntiTabListener implements Listener {
|
||||
}
|
||||
|
||||
public static void handleTabCompletion(List<String> commands) {
|
||||
if(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) return;
|
||||
if(Storage.USE_VELOCITY) return;
|
||||
COMMANDS = null;
|
||||
Bukkit.getOnlinePlayers().forEach(player -> handleTabCompletion(player, commands));
|
||||
}
|
||||
@@ -89,7 +89,7 @@ public class BukkitAntiTabListener implements Listener {
|
||||
}
|
||||
|
||||
public static void handleTabCompletion(Player player, List<String> commands) {
|
||||
if(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED) return;
|
||||
if(Storage.USE_VELOCITY) return;
|
||||
if(notUpdatablePlayer(player.getUniqueId())) return;
|
||||
|
||||
List<String> dummy = new ArrayList<>(commands);
|
||||
|
||||
@@ -17,6 +17,6 @@ public class WaterfallAntiTabListener implements Listener {
|
||||
ProxiedPlayer player = (ProxiedPlayer) event.getReceiver();
|
||||
if(PermissionUtil.hasBypassPermission(player)) return;
|
||||
|
||||
event.getCommands().entrySet().removeIf(entry -> Storage.Blacklist.isBlocked(player, entry.getKey(), player.getServer().getInfo().getName()));
|
||||
event.getCommands().entrySet().removeIf(command -> Storage.Blacklist.isBlocked(player, command.getKey(), !Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED, player.getServer().getInfo().getName()));
|
||||
}
|
||||
}
|
||||
@@ -128,6 +128,7 @@ public class CommunicationPackets {
|
||||
private final GroupsPacket groupsPacket;
|
||||
private final UnknownCommandPacket unknownCommandPacket;
|
||||
private final String proxyToken, serverId;
|
||||
private final boolean velocity;
|
||||
|
||||
public PacketBundle(String proxyToken, String serverId, CommandsPacket commandsPacket, GroupsPacket groupsPacket) {
|
||||
this.proxyToken = proxyToken;
|
||||
@@ -135,6 +136,11 @@ public class CommunicationPackets {
|
||||
this.commandsPacket = commandsPacket;
|
||||
this.groupsPacket = groupsPacket;
|
||||
this.unknownCommandPacket = new UnknownCommandPacket();
|
||||
this.velocity = Reflection.isVelocityServer();
|
||||
}
|
||||
|
||||
public boolean isVelocity() {
|
||||
return velocity;
|
||||
}
|
||||
|
||||
public boolean isToken(String token) {
|
||||
|
||||
Reference in new issue
Block a user