mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-11-30 20:39:53 -05:00
Update Import
This commit is contained in:
1 parent
c45ea922e7
commit
49fa0cbe8f
5 files changed
+36
-36
No files matched your search
@@ -7,7 +7,7 @@ import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.api.communication.impl.*;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.PacketUtil;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.group.TinyGroup;
|
||||
@@ -31,12 +31,12 @@ public class ClientCommunication {
|
||||
}
|
||||
|
||||
public static void sendPacket(ClientInfo clientInfo, Object packet) {
|
||||
clientInfo.sendBytes(PacketUtil.convertToBytes(packet));
|
||||
clientInfo.sendBytes(CommunicationPackets.convertToBytes(packet));
|
||||
}
|
||||
|
||||
public static void receiveInformation(String serverName, Object packet) {
|
||||
if(packet instanceof PacketUtil.RequestPacket) {
|
||||
PacketUtil.RequestPacket requestPacket = (PacketUtil.RequestPacket) packet;
|
||||
if(packet instanceof CommunicationPackets.RequestPacket) {
|
||||
CommunicationPackets.RequestPacket requestPacket = (CommunicationPackets.RequestPacket) packet;
|
||||
if (!requestPacket.isToken(Storage.TOKEN)) return;
|
||||
|
||||
ClientInfo client = getClientByName(serverName);
|
||||
@@ -51,15 +51,15 @@ public class ClientCommunication {
|
||||
return;
|
||||
}
|
||||
|
||||
if(packet instanceof PacketUtil.BackendDataPacket) {
|
||||
PacketUtil.BackendDataPacket backendDataPacket = (PacketUtil.BackendDataPacket) packet;
|
||||
if(packet instanceof CommunicationPackets.BackendDataPacket) {
|
||||
CommunicationPackets.BackendDataPacket backendDataPacket = (CommunicationPackets.BackendDataPacket) packet;
|
||||
if (!backendDataPacket.isToken(Storage.TOKEN)) return;
|
||||
Storage.SERVER_NAME = backendDataPacket.getServerName();
|
||||
return;
|
||||
}
|
||||
|
||||
if(packet instanceof PacketUtil.FeedbackPacket) {
|
||||
PacketUtil.FeedbackPacket feedbackPacket = (PacketUtil.FeedbackPacket) packet;
|
||||
if(packet instanceof CommunicationPackets.FeedbackPacket) {
|
||||
CommunicationPackets.FeedbackPacket feedbackPacket = (CommunicationPackets.FeedbackPacket) packet;
|
||||
if (!feedbackPacket.isToken(Storage.TOKEN)) return;
|
||||
String serverId = feedbackPacket.getServerId();
|
||||
|
||||
@@ -75,18 +75,18 @@ public class ClientCommunication {
|
||||
client.syncTime();
|
||||
SERVER_DATA_SYNC_COUNT++;
|
||||
|
||||
PacketUtil.BackendDataPacket backendDataPacket = new PacketUtil.BackendDataPacket(Storage.TOKEN, serverId, serverName);
|
||||
CommunicationPackets.BackendDataPacket backendDataPacket = new CommunicationPackets.BackendDataPacket(Storage.TOKEN, serverId, serverName);
|
||||
sendPacket(client, backendDataPacket);
|
||||
return;
|
||||
}
|
||||
|
||||
if(packet instanceof PacketUtil.PacketBundle) {
|
||||
PacketUtil.PacketBundle packetBundle = (PacketUtil.PacketBundle) packet;
|
||||
if(packet instanceof CommunicationPackets.PacketBundle) {
|
||||
CommunicationPackets.PacketBundle packetBundle = (CommunicationPackets.PacketBundle) packet;
|
||||
if(!packetBundle.isToken(Storage.TOKEN) || !packetBundle.isId(SERVER_ID.toString())) return;
|
||||
|
||||
PacketUtil.CommandsPacket commandsPacket = packetBundle.getCommandsPacket();
|
||||
PacketUtil.GroupsPacket groupsPacket = packetBundle.getGroupsPacket();
|
||||
PacketUtil.UnknownCommandPacket unknownCommandPacket = packetBundle.getUnknownCommandPacket();
|
||||
CommunicationPackets.CommandsPacket commandsPacket = packetBundle.getCommandsPacket();
|
||||
CommunicationPackets.GroupsPacket groupsPacket = packetBundle.getGroupsPacket();
|
||||
CommunicationPackets.UnknownCommandPacket unknownCommandPacket = packetBundle.getUnknownCommandPacket();
|
||||
|
||||
LAST_BUKKIT_SYNC = System.currentTimeMillis();
|
||||
BukkitLoader.synchronizeCommandData(commandsPacket, unknownCommandPacket);
|
||||
@@ -113,9 +113,9 @@ public class ClientCommunication {
|
||||
if(SERVER_DATA_SYNC_COUNT <= 0) SERVER_DATA_SYNC_COUNT = 0;
|
||||
}
|
||||
|
||||
PacketUtil.CommandsPacket commandsPacket = new PacketUtil.CommandsPacket();
|
||||
PacketUtil.GroupsPacket groupsPacket;
|
||||
PacketUtil.PacketBundle bundle;
|
||||
CommunicationPackets.CommandsPacket commandsPacket = new CommunicationPackets.CommandsPacket();
|
||||
CommunicationPackets.GroupsPacket groupsPacket;
|
||||
CommunicationPackets.PacketBundle bundle;
|
||||
List<String> commands = new ArrayList<>(Storage.Blacklist.getBlacklist().getCommands());
|
||||
|
||||
if(clientInfo != null && clientInfo.getName() != null) {
|
||||
@@ -129,24 +129,24 @@ public class ClientCommunication {
|
||||
List<TinyGroup> newGroupList = new ArrayList<>();
|
||||
|
||||
groups.forEach(oldGroup -> newGroupList.add(GroupManager.convertToTinyGroup(oldGroup.getGroupName(), oldGroup.getCommands(serverName))));
|
||||
groupsPacket = new PacketUtil.GroupsPacket(newGroupList);
|
||||
groupsPacket = new CommunicationPackets.GroupsPacket(newGroupList);
|
||||
|
||||
commandsPacket.setTurnBlacklistToWhitelist(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
|
||||
commandsPacket.setCommands(commands);
|
||||
|
||||
bundle = new PacketUtil.PacketBundle(Storage.TOKEN, serverId, commandsPacket, groupsPacket);
|
||||
clientInfo.sendBytes(PacketUtil.convertToBytes(bundle));
|
||||
bundle = new CommunicationPackets.PacketBundle(Storage.TOKEN, serverId, commandsPacket, groupsPacket);
|
||||
clientInfo.sendBytes(CommunicationPackets.convertToBytes(bundle));
|
||||
}
|
||||
|
||||
public static void sendRequest() {
|
||||
if(System.currentTimeMillis() - LAST_SENT_REQUEST >= 5000) {
|
||||
LAST_SENT_REQUEST = System.currentTimeMillis();
|
||||
sendPacket(new PacketUtil.RequestPacket(Storage.TOKEN, SERVER_ID.toString()));
|
||||
sendPacket(new CommunicationPackets.RequestPacket(Storage.TOKEN, SERVER_ID.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public static void sendFeedback() {
|
||||
sendPacket(new PacketUtil.FeedbackPacket(Storage.TOKEN, SERVER_ID.toString()));
|
||||
sendPacket(new CommunicationPackets.FeedbackPacket(Storage.TOKEN, SERVER_ID.toString()));
|
||||
}
|
||||
|
||||
public static Client getClient() {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.api.communication.impl;
|
||||
|
||||
import de.rayzs.pat.utils.PacketUtil;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
@@ -18,7 +18,7 @@ public class BukkitClient implements Client, PluginMessageListener {
|
||||
|
||||
@Override
|
||||
public void send(Object packet) {
|
||||
try { SERVER.sendPluginMessage(BukkitLoader.getPlugin(), CHANNEL_NAME, PacketUtil.convertToBytes(packet));
|
||||
try { SERVER.sendPluginMessage(BukkitLoader.getPlugin(), CHANNEL_NAME, CommunicationPackets.convertToBytes(packet));
|
||||
} catch (Throwable throwable) { throwable.printStackTrace(); }
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ public class BukkitClient implements Client, PluginMessageListener {
|
||||
public void onPluginMessageReceived(String channel, Player player, byte[] bytes) {
|
||||
if(!channel.equals(CHANNEL_NAME)) return;
|
||||
try {
|
||||
Object packetObj = PacketUtil.buildFromBytes(bytes);
|
||||
if(!PacketUtil.isPacket(packetObj)) return;
|
||||
Object packetObj = CommunicationPackets.buildFromBytes(bytes);
|
||||
if(!CommunicationPackets.isPacket(packetObj)) return;
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(BukkitLoader.getPlugin(), () -> ClientCommunication.receiveInformation("proxy", packetObj));
|
||||
} catch (Throwable throwable) { throwable.printStackTrace(); }
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package de.rayzs.pat.api.communication.impl;
|
||||
|
||||
import de.rayzs.pat.utils.PacketUtil;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import de.rayzs.pat.plugin.BungeeLoader;
|
||||
import de.rayzs.pat.api.communication.*;
|
||||
@@ -22,7 +22,7 @@ public class BungeeClient implements Client, Listener {
|
||||
@Override
|
||||
public void send(Object packet) {
|
||||
for(ServerInfo serverInfo : ProxyServer.getInstance().getServers().values()) {
|
||||
try { serverInfo.sendData(CHANNEL_NAME, PacketUtil.convertToBytes(packet));
|
||||
try { serverInfo.sendData(CHANNEL_NAME, CommunicationPackets.convertToBytes(packet));
|
||||
} catch (Throwable throwable) { throwable.printStackTrace(); }
|
||||
}
|
||||
}
|
||||
@@ -31,8 +31,8 @@ public class BungeeClient implements Client, Listener {
|
||||
public void onQueryReceive(PluginMessageEvent event) {
|
||||
if (!event.getTag().equalsIgnoreCase(CHANNEL_NAME)) return;
|
||||
try {
|
||||
Object packetObj = PacketUtil.buildFromBytes(event.getData());
|
||||
if(!PacketUtil.isPacket(packetObj)) return;
|
||||
Object packetObj = CommunicationPackets.buildFromBytes(event.getData());
|
||||
if(!CommunicationPackets.isPacket(packetObj)) return;
|
||||
|
||||
Server server = (Server) event.getSender();
|
||||
ClientCommunication.receiveInformation(server.getInfo().getName(), packetObj);
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.velocitypowered.api.proxy.server.RegisteredServer;
|
||||
import de.rayzs.pat.plugin.VelocityLoader;
|
||||
import de.rayzs.pat.api.communication.Client;
|
||||
import de.rayzs.pat.api.communication.ClientCommunication;
|
||||
import de.rayzs.pat.utils.PacketUtil;
|
||||
import de.rayzs.pat.utils.CommunicationPackets;
|
||||
|
||||
public class VelocityClient implements Client {
|
||||
|
||||
@@ -24,7 +24,7 @@ public class VelocityClient implements Client {
|
||||
@Override
|
||||
public void send(Object packet) {
|
||||
for (RegisteredServer registeredServer : SERVER.getAllServers()) {
|
||||
try { registeredServer.sendPluginMessage(IDENTIFIER, PacketUtil.convertToBytes(packet));
|
||||
try { registeredServer.sendPluginMessage(IDENTIFIER, CommunicationPackets.convertToBytes(packet));
|
||||
} catch (Throwable throwable) { throwable.printStackTrace(); }
|
||||
}
|
||||
}
|
||||
@@ -32,8 +32,8 @@ public class VelocityClient implements Client {
|
||||
@Subscribe
|
||||
public void onQueryReceive(PluginMessageEvent event) {
|
||||
if (event.getIdentifier() != IDENTIFIER) return;
|
||||
Object packetObj = PacketUtil.buildFromBytes(event.getData());
|
||||
if(!PacketUtil.isPacket(packetObj)) return;
|
||||
Object packetObj = CommunicationPackets.buildFromBytes(event.getData());
|
||||
if(!CommunicationPackets.isPacket(packetObj)) return;
|
||||
|
||||
ServerConnection server = (ServerConnection) event.getSource();
|
||||
ClientCommunication.receiveInformation(server.getServerInfo().getName(), packetObj);
|
||||
|
||||
@@ -108,7 +108,7 @@ public class BukkitLoader extends JavaPlugin {
|
||||
}, 20L, 20L * Storage.ConfigSections.Settings.UPDATE.PERIOD);
|
||||
}
|
||||
|
||||
public static void synchronizeCommandData(PacketUtil.CommandsPacket packet, PacketUtil.UnknownCommandPacket unknownCommandPacket) {
|
||||
public static void synchronizeCommandData(CommunicationPackets.CommandsPacket packet, CommunicationPackets.UnknownCommandPacket unknownCommandPacket) {
|
||||
ClientCommunication.sendFeedback();
|
||||
|
||||
if(packet.getCommands() == null || packet.getCommands().isEmpty())
|
||||
@@ -128,7 +128,7 @@ public class BukkitLoader extends JavaPlugin {
|
||||
if(!loaded) loaded = true;
|
||||
}
|
||||
|
||||
public static void synchronizeGroupData(PacketUtil.GroupsPacket packet) {
|
||||
public static void synchronizeGroupData(CommunicationPackets.GroupsPacket packet) {
|
||||
GroupManager.clearAllGroups();
|
||||
packet.getGroups().forEach(group -> GroupManager.setGroup(group.getGroupName(), group.getCommands()));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user