mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-11-30 20:39:53 -05:00
Fix Commands & Sync
This commit is contained in:
1 parent
1b7620bfc2
commit
dde92ed8ed
5 files changed
+54
-55
No files matched your search
@@ -121,10 +121,7 @@ public class ClientCommunication {
|
||||
|
||||
if(clientInfo != null && clientInfo.getName() != null) {
|
||||
List<GeneralBlacklist> serverBlacklists = Storage.Blacklist.getBlacklists(clientInfo.getName());
|
||||
serverBlacklists.stream().filter(serverBlacklist -> serverBlacklist != null && serverBlacklist.getCommands() != null).forEach(serverBlacklist -> {
|
||||
commands.addAll(serverBlacklist.getCommands());
|
||||
System.out.println("ADDING EXTRA SERVER COMMANDS " + serverBlacklist.getNavigatePath());
|
||||
});
|
||||
serverBlacklists.stream().filter(serverBlacklist -> serverBlacklist != null && serverBlacklist.getCommands() != null).forEach(serverBlacklist -> commands.addAll(serverBlacklist.getCommands()));
|
||||
}
|
||||
|
||||
String serverName = clientInfo.getName();
|
||||
@@ -142,6 +139,7 @@ public class ClientCommunication {
|
||||
|
||||
public static void sendRequest() {
|
||||
if(System.currentTimeMillis() - LAST_SENT_REQUEST >= 5000) {
|
||||
System.out.println("SEND REQUEST");
|
||||
LAST_SENT_REQUEST = System.currentTimeMillis();
|
||||
sendPacket(new DataConverter.RequestPacket(Storage.TOKEN, SERVER_ID.toString()));
|
||||
}
|
||||
|
||||
@@ -116,6 +116,10 @@ public class Storage {
|
||||
});
|
||||
}
|
||||
|
||||
public static List<String> getBlacklistServers() {
|
||||
return new ArrayList<>(SERVER_BLACKLISTS.keySet());
|
||||
}
|
||||
|
||||
public static GeneralBlacklist getBlacklist() {
|
||||
return BLACKLIST;
|
||||
}
|
||||
|
||||
@@ -22,12 +22,12 @@ public class BlacklistCreator {
|
||||
}
|
||||
|
||||
public static boolean exist(String server) {
|
||||
Object obj = Storage.Blacklist.getBlacklist().getConfig().get("general." + (server != null ? ".servers." + server : ".commands"));
|
||||
Object obj = Storage.Blacklist.getBlacklist().getConfig().get("general." + (server != null ? "servers." + server + "." : "") + "commands");
|
||||
return obj != null;
|
||||
}
|
||||
|
||||
public static boolean exist(String group, String server) {
|
||||
Object obj = Storage.Blacklist.getBlacklist().getConfig().get("groups." + group + "." + (server != null ? ".servers." + server : ".commands"));
|
||||
Object obj = Storage.Blacklist.getBlacklist().getConfig().get("groups." + group + "." + (server != null ? "servers." + server + "." : "") + "commands");
|
||||
return obj != null;
|
||||
}
|
||||
}
|
||||
@@ -53,8 +53,8 @@ public class BukkitLoader extends JavaPlugin {
|
||||
|
||||
if(Storage.ConfigSections.Settings.HANDLE_THROUGH_PROXY.ENABLED)
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> {
|
||||
if(Bukkit.getOnlinePlayers().size() != 0 || loaded) ClientCommunication.sendRequest();
|
||||
}, Bukkit.getOnlinePlayers().size() != 0 ? 5 : 40, 20 * 10);
|
||||
if(Bukkit.getOnlinePlayers().size() >= 1 || loaded) ClientCommunication.sendRequest();
|
||||
}, Bukkit.getOnlinePlayers().size() >= 1 ? 20 : 40, 20 * 10);
|
||||
|
||||
else {
|
||||
GroupManager.initialize();
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.rayzs.pat.plugin.process;
|
||||
|
||||
import de.rayzs.pat.api.communication.client.ClientInfo;
|
||||
import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.api.storage.blacklist.BlacklistCreator;
|
||||
import de.rayzs.pat.api.storage.blacklist.impl.GeneralBlacklist;
|
||||
import de.rayzs.pat.plugin.BukkitLoader;
|
||||
import de.rayzs.pat.plugin.listeners.bukkit.BukkitAntiTabListener;
|
||||
@@ -282,6 +283,36 @@ public class CommandProcess {
|
||||
return;
|
||||
}
|
||||
|
||||
if(args[0].equals("serv") || args[0].equals("server")) {
|
||||
task = args[1].toLowerCase();
|
||||
sub = args[2].toLowerCase();
|
||||
|
||||
switch (task) {
|
||||
case "clear":
|
||||
if (!Reflection.isProxyServer()) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.NO_PROXY.MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!BlacklistCreator.exist(sub)) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.BLACKLIST.CLEAR_SERVER_NOT_FOUND.replace("%server%", sub));
|
||||
return;
|
||||
}
|
||||
|
||||
confirmationString = "clear-server " + sub;
|
||||
|
||||
if (CONFIRMATION.getOrDefault(sender.getUniqueId(), "").equals(confirmationString)) {
|
||||
Storage.Blacklist.getBlacklist(sub).clear().save();
|
||||
handleChange();
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.BLACKLIST.CLEAR_SERVER.replace("%server%", sub));
|
||||
} else {
|
||||
CONFIRMATION.put(uuid, confirmationString);
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.BLACKLIST.CLEAR_SERVER_CONFIRM.replace("%server%", sub));
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
task = args[0].toLowerCase();
|
||||
sub = args[1].toLowerCase();
|
||||
extra = args[2].toLowerCase();
|
||||
@@ -315,25 +346,6 @@ public class CommandProcess {
|
||||
}
|
||||
sender.sendMessage((!bool ? Storage.ConfigSections.Messages.GROUP.REMOVE_FAILED : Storage.ConfigSections.Messages.GROUP.REMOVE_SUCCESS).replace("%command%", sub).replace("%group%", extra));
|
||||
return;
|
||||
|
||||
case "clear":
|
||||
if(!Reflection.isProxyServer()) {
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.NO_PROXY.MESSAGE);
|
||||
return;
|
||||
}
|
||||
|
||||
confirmationString = "clear-server " + sub;
|
||||
|
||||
if(CONFIRMATION.getOrDefault(sender.getUniqueId(), "").equals(confirmationString)) {
|
||||
Storage.Blacklist.getBlacklist(sub).clear().save();
|
||||
handleChange();
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.BLACKLIST.CLEAR_SERVER.replace("%server%", sub));
|
||||
} else {
|
||||
CONFIRMATION.put(uuid, confirmationString);
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.BLACKLIST.CLEAR_SERVER_CONFIRM.replace("%server%", sub));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
case 4:
|
||||
@@ -381,17 +393,18 @@ public class CommandProcess {
|
||||
return;
|
||||
|
||||
case "clear":
|
||||
confirmationString = "clear-server " + sub + " " + extra;
|
||||
confirmationString = "clear-server-group " + sub + " " + extra;
|
||||
|
||||
if (CONFIRMATION.getOrDefault(sender.getUniqueId(), "").equals(confirmationString)) {
|
||||
Storage.Blacklist.getBlacklist(sub).clear();
|
||||
for (Group groups : GroupManager.getGroupsByServer(sub))
|
||||
groups.clear(sub);
|
||||
|
||||
handleChange();
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.BLACKLIST.CLEAR_SERVER.replace("%server%", sub));
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.GROUP.CLEAR_SERVER.replace("%group%", extra).replace("%server%", sub));
|
||||
} else {
|
||||
CONFIRMATION.put(uuid, confirmationString);
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.BLACKLIST.CLEAR_SERVER_CONFIRM.replace("%server%", sub));
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.GROUP.CLEAR_SERVER_CONFIRM.replace("%group%", extra).replace("%server%", sub));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -431,7 +444,7 @@ public class CommandProcess {
|
||||
}
|
||||
|
||||
sender.sendMessage((bool ? Storage.ConfigSections.Messages.GROUP.ADD_SERVER_FAILED : Storage.ConfigSections.Messages.GROUP.ADD_SERVER_SUCCESS).replace("%server%", sub).replace("%command%", extra).replace("%group%", subExtra));
|
||||
break;
|
||||
return;
|
||||
|
||||
case "remove": case "rem": case "rm":
|
||||
if (!PermissionUtil.hasPermissionWithResponse(sender, "remove")) return;
|
||||
@@ -450,22 +463,6 @@ public class CommandProcess {
|
||||
|
||||
sender.sendMessage((bool ? Storage.ConfigSections.Messages.GROUP.REMOVE_SERVER_FAILED : Storage.ConfigSections.Messages.GROUP.REMOVE_SERVER_SUCCESS).replace("%server%", sub).replace("%command%", extra).replace("%group%", subExtra));
|
||||
return;
|
||||
|
||||
case "clear":
|
||||
confirmationString = "clear-server-group " + sub + " " + extra;
|
||||
|
||||
if (CONFIRMATION.getOrDefault(sender.getUniqueId(), "").equals(confirmationString)) {
|
||||
for (Group groups : GroupManager.getGroupsByServer(sub))
|
||||
groups.clear(sub);
|
||||
|
||||
handleChange();
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.GROUP.CLEAR_SERVER.replace("%group%", extra).replace("%server%", sub));
|
||||
} else {
|
||||
CONFIRMATION.put(uuid, confirmationString);
|
||||
sender.sendMessage(Storage.ConfigSections.Messages.GROUP.CLEAR_SERVER_CONFIRM.replace("%group%", extra).replace("%server%", sub));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
default:
|
||||
@@ -533,28 +530,28 @@ public class CommandProcess {
|
||||
suggestions.addAll(GroupManager.getGroupsByNameOnlyIncludingCommand(args[1]));
|
||||
if (Reflection.isProxyServer() && Arrays.asList("serv", "server").contains(args[0].toLowerCase())) {
|
||||
if (args[1].equals("add") && PermissionUtil.hasPermission(sender, "add"))
|
||||
suggestions.addAll(ClientCommunication.getRegisteredServerNames());
|
||||
suggestions.addAll(Storage.Blacklist.getBlacklistServers());
|
||||
if (Arrays.asList("remove", "rem", "rm").contains(args[1].toLowerCase()) && PermissionUtil.hasPermission(sender, "remove"))
|
||||
suggestions.addAll(ClientCommunication.getRegisteredServerNames());
|
||||
suggestions.addAll(Storage.Blacklist.getBlacklistServers());
|
||||
if (args[1].equals("clear") && PermissionUtil.hasPermission(sender, "clear"))
|
||||
suggestions.addAll(ClientCommunication.getRegisteredServerNames());
|
||||
suggestions.addAll(Storage.Blacklist.getBlacklistServers());
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (Reflection.isProxyServer() && Arrays.asList("serv", "server").contains(args[0].toLowerCase())) {
|
||||
if (Arrays.asList("remove", "rem", "rm").contains(args[1].toLowerCase()) && PermissionUtil.hasPermission(sender, "remove")) {
|
||||
suggestions.addAll(Storage.Blacklist.getBlacklist(args[3]).getCommands());
|
||||
suggestions.addAll(Storage.Blacklist.getBlacklist(args[2]).getCommands());
|
||||
}
|
||||
if (args[1].equals("clear") && PermissionUtil.hasPermission(sender, "clear"))
|
||||
suggestions.addAll(GroupManager.getGroupNames(args[3]));
|
||||
suggestions.addAll(GroupManager.getGroupNames(args[2]));
|
||||
}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if (Reflection.isProxyServer() && Arrays.asList("serv", "server").contains(args[0].toLowerCase())) {
|
||||
if (args[1].equals("clear") && PermissionUtil.hasPermission(sender, "clear"))
|
||||
suggestions.addAll(GroupManager.getGroupNames(args[3]));
|
||||
suggestions.addAll(GroupManager.getGroupNames(args[2]));
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
Reference in new issue
Block a user