mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 06:28:54 +00:00
Add permission to url link handling
This commit is contained in:
1 parent
cbd1d66f60
commit
f1703b6b1d
1 file changed
+4
-3
+4
-3
@@ -11,10 +11,11 @@ public class UrlLinkHandler {
|
||||
private static final Pattern URL_PATTERN = Pattern.compile("((?:(https?)://)?([-\\w_.]+\\.\\w{2,})(/\\S*)?)");
|
||||
|
||||
public UrlLinkHandler() {
|
||||
// TODO: permission to make links clickable, maybe?
|
||||
CarbonEvents.register(ChatFormatEvent.class, PostOrders.NORMAL, true, event -> {
|
||||
event.message(URL_PATTERN.matcher(event.message()).replaceAll("<click:open_url:'$1'>$1</click>"));
|
||||
// Reminder: Do not use this on event.format(), this breaks hover events when they contain URLs
|
||||
if (event.sender().hasPermission("carbonchat.autourl")) {
|
||||
event.message(URL_PATTERN.matcher(event.message()).replaceAll("<click:open_url:'$1'>$1</click>"));
|
||||
// Reminder: Do not use this on event.format(), this breaks hover events when they contain URLs
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user