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