diff --git a/build.gradle.kts b/build.gradle.kts index 6aa5c93..1f5aef0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -2,7 +2,8 @@ plugins { `java-library` `maven-publish` -// id("com.github.johnrengelman.shadow") version "8.1.1" // Shades and relocates dependencies, See https://imperceptiblethoughts.com/shadow/introduction/ + eclipse + idea } group = "com.github.milkdrinkers" @@ -10,7 +11,7 @@ version = "2.0.0" description = "" java { - toolchain.languageVersion.set(JavaLanguageVersion.of(17)) // Configure the java toolchain. This allows gradle to auto-provision JDK 17 on systems that only have JDK 8 installed for example. + toolchain.languageVersion.set(JavaLanguageVersion.of(21)) withJavadocJar() withSourcesJar() } @@ -27,17 +28,14 @@ repositories { maven("https://oss.sonatype.org/content/repositories/snapshots") // Required for Spigots Bungeecord dependency maven("https://oss.sonatype.org/content/repositories/central") // Required for Spigots Bungeecord dependency -// maven("https://papermc.io/repo/repository/maven-public/") - maven("https://repo.extendedclip.com/content/repositories/placeholderapi/") { content { includeGroup("me.clip") } } - -// maven("https://jitpack.io/") { content {} } } dependencies { - compileOnly("org.jetbrains:annotations:24.0.1") + compileOnly("org.jetbrains:annotations:24.1.0") + annotationProcessor("org.jetbrains:annotations:24.1.0") api("net.kyori:adventure-api:4.14.0") api("net.kyori:adventure-text-minimessage:4.14.0") @@ -45,30 +43,26 @@ dependencies { api("net.kyori:adventure-text-serializer-legacy:4.14.0") api("net.kyori:adventure-text-serializer-plain:4.14.0") - compileOnly("org.spigotmc:spigot-api:1.20.1-R0.1-SNAPSHOT") -// compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT") + compileOnly("org.spigotmc:spigot-api:1.20.6-R0.1-SNAPSHOT") - compileOnly("me.clip:placeholderapi:2.11.3") + compileOnly("me.clip:placeholderapi:2.11.6") } tasks { - /*build { - dependsOn(shadowJar) - }*/ - compileJava { - options.encoding = Charsets.UTF_8.name() // We want UTF-8 for everything - sourceCompatibility = "${JavaVersion.VERSION_1_8}" + options.encoding = Charsets.UTF_8.name() + options.release.set(8) } - /*shadowJar { - archiveBaseName.set(project.name) - archiveClassifier.set("") - - // Shadow classes - // helper function to relocate a package into our package - fun reloc(originPkg: String, targetPkg: String) = relocate(originPkg, "${project.group}.colorparser.${targetPkg}") - }*/ + javadoc { + isFailOnError = false + val options = options as StandardJavadocDocletOptions + options.encoding = Charsets.UTF_8.name() + options.overview = "src/main/javadoc/overview.html" + options.isDocFilesSubDirs = true + options.tags("apiNote:a:API Note:", "implNote:a:Implementation Note:", "implSpec:a:Implementation Requirements:") + options.use() + } } publishing { diff --git a/settings.gradle.kts b/settings.gradle.kts index c412712..019c84e 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1 +1,12 @@ +pluginManagement { + repositories { + gradlePluginPortal() + mavenCentral() + } +} + +plugins { + id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0") +} + rootProject.name = "ColorParser" diff --git a/src/main/java/com/github/milkdrinkers/colorparser/ColorParser.java b/src/main/java/com/github/milkdrinkers/colorparser/ColorParser.java index 63c07ea..8088294 100644 --- a/src/main/java/com/github/milkdrinkers/colorparser/ColorParser.java +++ b/src/main/java/com/github/milkdrinkers/colorparser/ColorParser.java @@ -1,6 +1,7 @@ package com.github.milkdrinkers.colorparser; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.regex.Matcher; @@ -21,55 +22,56 @@ * Builder Utility for easily turning strings into Adventure Components. */ public class ColorParser { - private static final MiniMessage mm = MiniMessage.miniMessage(); private static final Pattern legacyRegex = Pattern.compile("[§&][0-9a-fk-or]"); - private static final Map legacyToMiniMessage = Map.ofEntries( - Map.entry("§0", ""), - Map.entry("§1", ""), - Map.entry("§2", ""), - Map.entry("§3", ""), - Map.entry("§4", ""), - Map.entry("§5", ""), - Map.entry("§6", ""), - Map.entry("§7", ""), - Map.entry("§8", ""), - Map.entry("§9", ""), - Map.entry("§a", ""), - Map.entry("§b", ""), - Map.entry("§c", ""), - Map.entry("§d", ""), - Map.entry("§e", ""), - Map.entry("§f", ""), - Map.entry("§k", ""), - Map.entry("§l", ""), - Map.entry("§m", ""), - Map.entry("§n", ""), - Map.entry("§o", ""), - Map.entry("§r", ""), - Map.entry("&0", ""), - Map.entry("&1", ""), - Map.entry("&2", ""), - Map.entry("&3", ""), - Map.entry("&4", ""), - Map.entry("&5", ""), - Map.entry("&6", ""), - Map.entry("&7", ""), - Map.entry("&8", ""), - Map.entry("&9", ""), - Map.entry("&a", ""), - Map.entry("&b", ""), - Map.entry("&c", ""), - Map.entry("&d", ""), - Map.entry("&e", ""), - Map.entry("&f", ""), - Map.entry("&k", ""), - Map.entry("&l", ""), - Map.entry("&m", ""), - Map.entry("&n", ""), - Map.entry("&o", ""), - Map.entry("&r", "") - ); + private static final Map legacyToMiniMessage; + static { + legacyToMiniMessage = new HashMap<>(); + legacyToMiniMessage.put("§0", ""); + legacyToMiniMessage.put("§1", ""); + legacyToMiniMessage.put("§2", ""); + legacyToMiniMessage.put("§3", ""); + legacyToMiniMessage.put("§4", ""); + legacyToMiniMessage.put("§5", ""); + legacyToMiniMessage.put("§6", ""); + legacyToMiniMessage.put("§7", ""); + legacyToMiniMessage.put("§8", ""); + legacyToMiniMessage.put("§9", ""); + legacyToMiniMessage.put("§a", ""); + legacyToMiniMessage.put("§b", ""); + legacyToMiniMessage.put("§c", ""); + legacyToMiniMessage.put("§d", ""); + legacyToMiniMessage.put("§e", ""); + legacyToMiniMessage.put("§f", ""); + legacyToMiniMessage.put("§k", ""); + legacyToMiniMessage.put("§l", ""); + legacyToMiniMessage.put("§m", ""); + legacyToMiniMessage.put("§n", ""); + legacyToMiniMessage.put("§o", ""); + legacyToMiniMessage.put("§r", ""); + legacyToMiniMessage.put("&0", ""); + legacyToMiniMessage.put("&1", ""); + legacyToMiniMessage.put("&2", ""); + legacyToMiniMessage.put("&3", ""); + legacyToMiniMessage.put("&4", ""); + legacyToMiniMessage.put("&5", ""); + legacyToMiniMessage.put("&6", ""); + legacyToMiniMessage.put("&7", ""); + legacyToMiniMessage.put("&8", ""); + legacyToMiniMessage.put("&9", ""); + legacyToMiniMessage.put("&a", ""); + legacyToMiniMessage.put("&b", ""); + legacyToMiniMessage.put("&c", ""); + legacyToMiniMessage.put("&d", ""); + legacyToMiniMessage.put("&e", ""); + legacyToMiniMessage.put("&f", ""); + legacyToMiniMessage.put("&k", ""); + legacyToMiniMessage.put("&l", ""); + legacyToMiniMessage.put("&m", ""); + legacyToMiniMessage.put("&n", ""); + legacyToMiniMessage.put("&o", ""); + legacyToMiniMessage.put("&r", ""); + } private final List minimessagePlaceholders = new ArrayList<>(); // Store MiniMessage placeholders to be applied private String text;