mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-24 22:26:45 +01:00
Prevent users defining their own click events in descriptions/farewells/greetings by default
This commit is contained in:
parent
fbde60fcf9
commit
51ff043af9
@ -498,6 +498,11 @@ public class Settings extends Config {
|
||||
"notify-enter, notify-leave, greeting or farewell flag."})
|
||||
public static boolean NOTIFICATION_AS_ACTIONBAR = false;
|
||||
|
||||
@Comment({"Whether to strip any possible <click_event> components from user-defined messages, e.g. plot greeting",
|
||||
"This can allow players to use commands to give themselves ranks as commands ran in this fashion cannot be prevent by " +
|
||||
"permissions etc."})
|
||||
public static boolean REMOVE_USER_DEFINED_CLICK_EVENTS = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -169,8 +169,11 @@ public class PlotListener {
|
||||
titles = titleFlag == TitlesFlag.TitlesFlagValue.TRUE;
|
||||
}
|
||||
|
||||
final String greeting = plot.getFlag(GreetingFlag.class);
|
||||
String greeting = plot.getFlag(GreetingFlag.class);
|
||||
if (!greeting.isEmpty()) {
|
||||
if (Settings.Chat.REMOVE_USER_DEFINED_CLICK_EVENTS) {
|
||||
greeting = greeting.replaceAll(".([c-lC-L]{5}):([a-uA-U_]{11}):[^\\/]*[^>]*>>", "").replace("</click>", "");
|
||||
}
|
||||
if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) {
|
||||
plot.format(StaticCaption.of(greeting), player, false).thenAcceptAsync(player::sendMessage);
|
||||
} else {
|
||||
@ -390,8 +393,11 @@ public class PlotListener {
|
||||
}
|
||||
}
|
||||
|
||||
final String farewell = plot.getFlag(FarewellFlag.class);
|
||||
String farewell = plot.getFlag(FarewellFlag.class);
|
||||
if (!farewell.isEmpty()) {
|
||||
if (Settings.Chat.REMOVE_USER_DEFINED_CLICK_EVENTS) {
|
||||
farewell = farewell.replaceAll(".([c-lC-L]{5}):([a-uA-U_]{11}):[^\\/]*[^>]*>", "").replace("</click>", "");
|
||||
}
|
||||
if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) {
|
||||
plot.format(StaticCaption.of(farewell), player, false).thenAcceptAsync(player::sendMessage);
|
||||
} else {
|
||||
|
@ -2785,6 +2785,9 @@ public class Plot {
|
||||
String description = this.getFlag(DescriptionFlag.class);
|
||||
if (description.isEmpty()) {
|
||||
description = TranslatableCaption.of("info.plot_no_description").getComponent(player);
|
||||
} else if (Settings.Chat.REMOVE_USER_DEFINED_CLICK_EVENTS) {
|
||||
description = description.replaceAll(".([c-lC-L]{5}):([a-uA-U_]{11}):[^\\/]*[^>]*>", "").replace("</click>",
|
||||
"");
|
||||
}
|
||||
|
||||
Component flags;
|
||||
|
Loading…
Reference in New Issue
Block a user