mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-21 11:45:19 +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."})
|
"notify-enter, notify-leave, greeting or farewell flag."})
|
||||||
public static boolean NOTIFICATION_AS_ACTIONBAR = false;
|
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;
|
titles = titleFlag == TitlesFlag.TitlesFlagValue.TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String greeting = plot.getFlag(GreetingFlag.class);
|
String greeting = plot.getFlag(GreetingFlag.class);
|
||||||
if (!greeting.isEmpty()) {
|
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) {
|
if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) {
|
||||||
plot.format(StaticCaption.of(greeting), player, false).thenAcceptAsync(player::sendMessage);
|
plot.format(StaticCaption.of(greeting), player, false).thenAcceptAsync(player::sendMessage);
|
||||||
} else {
|
} 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 (!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) {
|
if (!Settings.Chat.NOTIFICATION_AS_ACTIONBAR) {
|
||||||
plot.format(StaticCaption.of(farewell), player, false).thenAcceptAsync(player::sendMessage);
|
plot.format(StaticCaption.of(farewell), player, false).thenAcceptAsync(player::sendMessage);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2785,6 +2785,9 @@ public class Plot {
|
|||||||
String description = this.getFlag(DescriptionFlag.class);
|
String description = this.getFlag(DescriptionFlag.class);
|
||||||
if (description.isEmpty()) {
|
if (description.isEmpty()) {
|
||||||
description = TranslatableCaption.of("info.plot_no_description").getComponent(player);
|
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;
|
Component flags;
|
||||||
|
Loading…
Reference in New Issue
Block a user