Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
Formatting: add markdown url support
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFaser committed Dec 15, 2023
1 parent ebd4406 commit d3b2dcf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,20 @@ private void splitStringToWordParams(@Nullable Player sender, @NotNull String co
}

if (formattingMap.containsKey("url")) {

if (config.getVaultBoolean(sender, this + ".list.url.markdown-support")) {
Matcher urlMatcher = Pattern.compile("\\[(?<text>[^\\]]*)\\]\\((?<link>[^\\)]*)\\)").matcher(word);
if (urlMatcher.find()) {
wordParams.setUrlText(urlMatcher.group(2));
wordParams.setUrl(true);

word = config.getVaultString(sender, this + ".list.url.format")
.replace("<message>", urlMatcher.group(1));
wordParams.setText(word);
return wordParams;
}
}

Matcher urlMatcher = Pattern.compile(formattingMap.get("url")).matcher(word);
if (urlMatcher.find()) {
wordParams.setUrlText(word.substring(urlMatcher.start(0), urlMatcher.end(0)));
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,11 @@ default:
hover:
enable: true
clickable: true

markdown-support: true

trigger: ((https?|ftp|gopher|telnet|file):((//)|(\\))+[\w:#@%/;$()~_?+-=\\.&]*)

format: "&&1<message>"

item:
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ permissions:
default: true
flectonechat.player-message.formatting.url:
default: true
flectonechat.player-message.formatting.markdown-url:
default: true
flectonechat.player-message.formatting.item:
default: true
flectonechat.player-message.formatting.mention:
Expand Down

0 comments on commit d3b2dcf

Please sign in to comment.