Skip to content

Commit ef018c1

Browse files
committed
First attempt to add permissions in chat control
1 parent c3290e9 commit ef018c1

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

multichat/src/main/java/xyz/olivermartin/multichat/bungee/ChatControl.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ public static void setIgnoreMap(Map<UUID, Set<UUID>> ignoreMap) {
5858
Configuration config = ConfigManager.getInstance().getHandler("chatcontrol.yml").getConfig();
5959
boolean cancel = false;
6060

61+
ProxiedPlayer pp = ProxyServer.getInstance().getPlayer(playerName);
62+
6163
if (config.contains("apply_rules_to." + chatType)) {
6264
if (config.getBoolean("apply_rules_to." + chatType)) {
6365

@@ -66,6 +68,19 @@ public static void setIgnoreMap(Map<UUID, Set<UUID>> ignoreMap) {
6668
if (rules != null) {
6769
for (Object rule : rules) {
6870
Map dictionary = (Map) rule;
71+
72+
if (pp != null) {
73+
if (dictionary.containsKey("permission")) {
74+
String permission = String.valueOf(dictionary.get("permission"));
75+
if (permission.startsWith("!")) {
76+
permission = permission.substring(1);
77+
if (pp.hasPermission(permission)) continue;
78+
} else {
79+
if (!pp.hasPermission(permission)) continue;
80+
}
81+
}
82+
}
83+
6984
input = input.replaceAll(String.valueOf( dictionary.get("look_for")), String.valueOf(dictionary.get("replace_with") ));
7085
}
7186
}
@@ -84,6 +99,18 @@ public static void setIgnoreMap(Map<UUID, Set<UUID>> ignoreMap) {
8499

85100
if (input.matches(String.valueOf(dictionary.get("look_for")))) {
86101

102+
if (pp != null) {
103+
if (dictionary.containsKey("permission")) {
104+
String permission = String.valueOf(dictionary.get("permission"));
105+
if (permission.startsWith("!")) {
106+
permission = permission.substring(1);
107+
if (pp.hasPermission(permission)) continue;
108+
} else {
109+
if (!pp.hasPermission(permission)) continue;
110+
}
111+
}
112+
}
113+
87114
if ((Boolean) dictionary.get("cancel")) {
88115
cancel = true;
89116
}

0 commit comments

Comments
 (0)