Skip to content

Commit 669eafb

Browse files
committed
Updated chat and sign permissions
1 parent 146f426 commit 669eafb

File tree

3 files changed

+62
-5
lines changed

3 files changed

+62
-5
lines changed

build.gradle

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,15 +331,37 @@ bukkit {
331331
description = 'Gives access to tutorialinfo command'
332332
}
333333
'parallelutils.chat' {
334-
description = 'Gives access to chat elemets'
335-
childrenMap = ['parallelutils.chat.colors': true, 'parallelutils.chat.formats': true,]
334+
description = 'Gives access to chat elements'
335+
childrenMap = ['parallelutils.chat.colors': true, 'parallelutils.chat.formats': true,'parallelutils.chat.hex': true,'parallelutils.chat.magic': true,]
336336
}
337337
'parallelutils.chat.colors' {
338338
description = 'Gives access to chat colors'
339339
}
340340
'parallelutils.chat.formats' {
341341
description = 'Gives access to chat formatting'
342342
}
343+
'parallelutils.chat.hex' {
344+
description = 'Gives access to chat hex colors'
345+
}
346+
'parallelutils.chat.magic' {
347+
description = 'Gives access to magic chat formatting'
348+
}
349+
'parallelutils.sign' {
350+
description = 'Gives access to chat elements on signs'
351+
childrenMap = ['parallelutils.sign.colors': true, 'parallelutils.sign.formats': true,'parallelutils.sign.hex': true,'parallelutils.sign.magic': true,]
352+
}
353+
'parallelutils.sign.colors' {
354+
description = 'Gives access to chat colors on signs'
355+
}
356+
'parallelutils.sign.formats' {
357+
description = 'Gives access to chat formatting on signs'
358+
}
359+
'parallelutils.sign.hex' {
360+
description = 'Gives access to chat hex colors on signs'
361+
}
362+
'parallelutils.sign.magic' {
363+
description = 'Gives access to magic chat formatting on signs'
364+
}
343365
'parallelutils.bypass' {
344366
description = 'Bypasses some ParallelUtils modules'
345367
childrenMap = ['parallelutils.bypass.anticaps': true, 'parallelutils.bypass.antislur': true, 'parallelutils.bypass.clearchat': true, 'parallelutils.bypass.socialspy': true, 'parallelutils.bypass.commandspy': true, 'parallelutils.bypass.mutechat': true,'parallelutils.bypass.chestshops': true, 'parallelutils.bypass.chatroomspy': true]

src/main/java/parallelmc/parallelutils/modules/parallelchat/events/OnChatMessage.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,19 @@ public void onChatMessage(AsyncChatEvent event) {
4949
event.message(Component.text(msgStr.replaceAll("&[[0-9][a-f]]", "")));
5050
}
5151

52+
// check hex permission
53+
if (!player.hasPermission("parallelutils.chat.hex")) {
54+
event.message(Component.text(msgStr.replaceAll("&#(.{6})", "")));
55+
}
56+
5257
// check formats permission
5358
if (!player.hasPermission("parallelutils.chat.formats")) {
54-
event.message(Component.text(msgStr.replaceAll("&[[k-o]r]", "")));
59+
event.message(Component.text(msgStr.replaceAll("&[[l-o]r]", "")));
60+
}
61+
62+
// check magic permission
63+
if (!player.hasPermission("parallel.chat.magic")) {
64+
event.message(Component.text(msgStr.replaceAll("&k", "")));
5565
}
5666

5767
// Chat Logger

src/main/java/parallelmc/parallelutils/modules/parallelchat/events/OnSignTextSet.java

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package parallelmc.parallelutils.modules.parallelchat.events;
22

3+
import net.kyori.adventure.text.Component;
34
import org.bukkit.block.Sign;
5+
import org.bukkit.entity.Player;
46
import org.bukkit.event.EventHandler;
57
import org.bukkit.event.EventPriority;
68
import org.bukkit.event.Listener;
@@ -10,13 +12,36 @@
1012
public class OnSignTextSet implements Listener {
1113
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
1214
public void onSignTextSet(SignChangeEvent event) {
13-
if (!event.getPlayer().hasPermission("parallelutils.bypass.antislur")) {
15+
Player player = event.getPlayer();
16+
if (!player.hasPermission("parallelutils.bypass.antislur")) {
1417
// fuck u paper im not iterating through components
1518
String text = String.join("\n", event.getLines());
1619
text = text.toLowerCase().replace(" ", "");
1720
if (ParallelChat.get().bannedWords.stream().anyMatch(text::contains)) {
1821
event.setCancelled(true);
19-
ParallelChat.sendParallelMessageTo(event.getPlayer(), "Please do not say that on signs.");
22+
ParallelChat.sendParallelMessageTo(player, "Please do not say that on signs.");
23+
}
24+
}
25+
// foreach was acting weird so regular for loop tally-ho
26+
// also rip running these checks for every line
27+
for (int i = 0; i < event.lines().size(); i++) {
28+
// check sign colors permission
29+
if (!player.hasPermission("parallelutils.chat.colors")) {
30+
event.line(i, event.lines().get(i).replaceText(x -> x.match("&[[0-9][a-f]]").replacement("")));
31+
}
32+
// check sign hex permission
33+
if (!player.hasPermission("parallelutils.chat.hex")) {
34+
event.line(i, event.lines().get(i).replaceText(x -> x.match("&#(.{6})").replacement("")));
35+
}
36+
37+
// check sign formats permission
38+
if (!player.hasPermission("parallelutils.chat.formats")) {
39+
event.line(i, event.lines().get(i).replaceText(x -> x.match("&[[l-o]r]").replacement("")));
40+
}
41+
42+
// check sign magic permission
43+
if (!player.hasPermission("parallel.chat.magic")) {
44+
event.line(i, event.lines().get(i).replaceText(x -> x.match("&k").replacement("")));
2045
}
2146
}
2247
}

0 commit comments

Comments
 (0)