mirror of
https://github.com/RayzsYT/ProAntiTab.git
synced 2026-11-30 20:39:53 -05:00
Fix Group Sync
This commit is contained in:
1 parent
de3fead8a7
commit
155997dc21
8 files changed
+49
-11
No files matched your search
@@ -12,6 +12,7 @@ import de.rayzs.pat.api.storage.Storage;
|
||||
import de.rayzs.pat.utils.DataConverter;
|
||||
import de.rayzs.pat.utils.ExpireCache;
|
||||
import de.rayzs.pat.utils.Reflection;
|
||||
import de.rayzs.pat.utils.TinyGroup;
|
||||
import de.rayzs.pat.utils.group.Group;
|
||||
import de.rayzs.pat.utils.group.GroupManager;
|
||||
|
||||
@@ -125,10 +126,12 @@ public class ClientCommunication {
|
||||
}
|
||||
|
||||
String serverName = clientInfo.getName();
|
||||
List<Group> groups = GroupManager.getGroupsByServer(serverName),
|
||||
newGroupList = new ArrayList<>();
|
||||
groups.forEach(oldGroup -> newGroupList.add(new Group(oldGroup.getGroupName(), oldGroup.getCommands(serverName))));
|
||||
groupsPacket = new DataConverter.GroupsPacket(GroupManager.getGroups());
|
||||
List<Group> groups = GroupManager.getGroupsByServer(serverName);
|
||||
GroupManager.getGroups().stream().filter(group -> !groups.contains(group)).forEach(groups::add);
|
||||
List<TinyGroup> newGroupList = new ArrayList<>();
|
||||
|
||||
groups.forEach(oldGroup -> newGroupList.add(GroupManager.convertToTinyGroup(oldGroup.getGroupName(), oldGroup.getCommands(serverName))));
|
||||
groupsPacket = new DataConverter.GroupsPacket(newGroupList);
|
||||
|
||||
commandsPacket.setTurnBlacklistToWhitelist(Storage.ConfigSections.Settings.TURN_BLACKLIST_TO_WHITELIST.ENABLED);
|
||||
commandsPacket.setCommands(commands);
|
||||
|
||||
@@ -2,7 +2,9 @@ package de.rayzs.pat.api.storage;
|
||||
|
||||
import de.rayzs.pat.utils.configuration.*;
|
||||
|
||||
public abstract class StorageTemplate {
|
||||
import java.io.Serializable;
|
||||
|
||||
public abstract class StorageTemplate implements Serializable {
|
||||
|
||||
private final String navigatePath;
|
||||
private final ConfigurationBuilder configuration;
|
||||
|
||||
@@ -3,9 +3,10 @@ package de.rayzs.pat.api.storage.blacklist.impl;
|
||||
import de.rayzs.pat.api.storage.StorageTemplate;
|
||||
import de.rayzs.pat.api.storage.storages.BlacklistStorage;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class GroupBlacklist extends BlacklistStorage {
|
||||
public class GroupBlacklist extends BlacklistStorage implements Serializable {
|
||||
|
||||
public GroupBlacklist(String group, String navigatePath) { super("groups." + group + navigatePath); }
|
||||
|
||||
|
||||
@@ -3,9 +3,10 @@ package de.rayzs.pat.api.storage.storages;
|
||||
import de.rayzs.pat.api.storage.*;
|
||||
import de.rayzs.pat.utils.PermissionUtil;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
public class BlacklistStorage extends StorageTemplate {
|
||||
public class BlacklistStorage extends StorageTemplate implements Serializable {
|
||||
|
||||
private List<String> commands = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -557,7 +557,7 @@ public class CommandProcess {
|
||||
|
||||
case 6:
|
||||
if (Reflection.isProxyServer() && Arrays.asList("serv", "server").contains(args[0].toLowerCase())) {
|
||||
if (args[1].equals("add") && PermissionUtil.hasPermission(sender, "add")) suggestions.addAll(GroupManager.getGroupNames(args[2]));
|
||||
if (args[1].equals("add") && PermissionUtil.hasPermission(sender, "add")) suggestions.addAll(GroupManager.getGroupNames());
|
||||
if (Arrays.asList("remove", "rem", "rm").contains(args[1].toLowerCase()) && PermissionUtil.hasPermission(sender, "remove")) suggestions.addAll(GroupManager.getGroupNames(args[2]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,13 +183,13 @@ public class DataConverter {
|
||||
|
||||
public static class GroupsPacket implements Serializable {
|
||||
|
||||
private final List<Group> groups;
|
||||
private final List<TinyGroup> groups;
|
||||
|
||||
public GroupsPacket(List<Group> groups) {
|
||||
public GroupsPacket(List<TinyGroup> groups) {
|
||||
this.groups = groups;
|
||||
}
|
||||
|
||||
public List<Group> getGroups() {
|
||||
public List<TinyGroup> getGroups() {
|
||||
return groups;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package de.rayzs.pat.utils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
public class TinyGroup implements Serializable {
|
||||
|
||||
private final String groupName;
|
||||
private final List<String> commands;
|
||||
|
||||
public TinyGroup(String groupName, List<String> commands) {
|
||||
this.groupName = groupName;
|
||||
this.commands = commands;
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return groupName;
|
||||
}
|
||||
|
||||
public List<String> getCommands() {
|
||||
return commands;
|
||||
}
|
||||
}
|
||||
@@ -134,6 +134,14 @@ public class GroupManager {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static TinyGroup convertToTinyGroup(String groupName, List<String> commands) {
|
||||
return new TinyGroup(groupName, commands);
|
||||
}
|
||||
|
||||
public static Group convertToGroup(TinyGroup group) {
|
||||
return new Group(group.getGroupName(), group.getCommands());
|
||||
}
|
||||
|
||||
public static void clearAllGroups() {
|
||||
GROUPS.clear();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user