From c9c7c5144a037dae5b05610f3c470ea32d052f05 Mon Sep 17 00:00:00 2001 From: Ayham Al-Ali <20037329+AyhamAl-Ali@users.noreply.github.com> Date: Mon, 1 Apr 2024 12:52:34 +0300 Subject: [PATCH] fix homepage --- src/main/java/ch/njol/skript/doc/HTMLGenerator.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/ch/njol/skript/doc/HTMLGenerator.java b/src/main/java/ch/njol/skript/doc/HTMLGenerator.java index 9789a266c39..5f08d9181e7 100644 --- a/src/main/java/ch/njol/skript/doc/HTMLGenerator.java +++ b/src/main/java/ch/njol/skript/doc/HTMLGenerator.java @@ -51,6 +51,7 @@ import java.util.Iterator; import java.util.List; import java.util.Locale; +import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; @@ -374,11 +375,15 @@ else if (!filesInside.getName().matches("(?i)(.*)\\.(html?|js|css|json)")) { // skwipt String ogTitle = "Skript Documentation"; - String ogDesc = "Skript is a Bukkit plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them."; - String exampleCode = " command /sethome:\n     permission: skript.home # Permission required for this command\n     description: Set your home # Description of this command\n     executable by: players # Console won't be able to run this command\n     trigger: # The actual trigger/code that will run when someone do /sethome\n         # Set a unique variable to sender's location\n         set {home::%uuid of player%} to location of player\n         # Send a message to the sender\n         message \"Set your home to <grey>%location of player%<reset>\"\n \n command /home:\n     permission: skript.home\n     description: Teleport yourself to your home\n     trigger:\n         # Check if that variable we used in /sethome has been set (in other words, if player ever ran /sethome)\n         if {home::%uuid of player%} is not set:\n             message \"You have not set your home yet!\"\n             stop trigger # stop the code here, lines below won't run\n         # Teleport the player to their home\n         teleport player to {home::%uuid of player%}\n         send \"&aYou have been teleported.\"\n "; + String ogDesc = "is a Bukkit plugin which allows server admins to customize their server easily, but without the hassle of programming a plugin or asking/paying someone to program a plugin for them."; + Pattern exampleCode = Pattern.compile("command /sethome:.*?You have been teleported."); + Pattern skriptPattern = Pattern.compile("(?<=[a-zA-Z0-9]|^|>)([Ss]kript)"); page = page.replace(ogTitle, introduceSkwipt(ogTitle)); page = page.replace(ogDesc, introduceSkwipt(ogDesc)); - page = page.replace(exampleCode, introduceSkwipt(exampleCode)); + Matcher exampleMatcher = exampleCode.matcher(page); + Matcher skriptMatcher = skriptPattern.matcher(page); + page = exampleMatcher.replaceAll(introduceSkwipt(exampleMatcher.group(0))); + page = skriptMatcher.replaceAll(introduceSkwipt(skriptMatcher.group(1))); generate = page.indexOf("${generate", nextBracket); }