This commit is contained in:
kento2 2026-07-07 21:38:52 +02:00
parent 7e5bd1bb6d
commit 5073d933d2
24 changed files with 168 additions and 111 deletions

View file

@ -13,7 +13,9 @@ dependencies {
compileOnly(libs.adventure.api)
compileOnly(libs.adventure.minimessage)
api(libs.bson)
api(libs.scrow.commandapi.core)
api(libs.scrow.commandapi.core) {
this.isChanging = true
}
}
publishing {

View file

@ -0,0 +1,23 @@
package de.kentoj.scrowlib.utils;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextReplacementConfig;
import net.kyori.adventure.text.event.ClickEvent;
import java.util.regex.Pattern;
@NoArgsConstructor(access = AccessLevel.NONE)
public class ComponentUtils {
private static final Pattern URL_REGEX = Pattern.compile("(https?://)?[a-z0-9]+(\\.[a-z0-9]+)*(\\.[a-z0-9]{1,10})((/+)[^/ ]*)*", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE);
private static final TextReplacementConfig REPLACER = TextReplacementConfig.builder()
.match(URL_REGEX)
.replacement((c) -> c.clickEvent(ClickEvent.openUrl(c.content().startsWith("http") ? c.content() : "https://" + c.content())))
.build();
public static Component resolveURLS(Component component) {
return component.replaceText(REPLACER);
}
}