Skip to content

Commit

Permalink
build: update deps & build natively for java 8
Browse files Browse the repository at this point in the history
  • Loading branch information
darksaid98 committed May 28, 2024
1 parent 6fff17f commit f8a4036
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 71 deletions.
42 changes: 18 additions & 24 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ 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"
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()
}
Expand All @@ -27,48 +28,41 @@ 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")
api("net.kyori:adventure-text-serializer-gson:4.14.0")
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 {
Expand Down
11 changes: 11 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1 +1,12 @@
pluginManagement {
repositories {
gradlePluginPortal()
mavenCentral()
}
}

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version("0.8.0")
}

rootProject.name = "ColorParser"
96 changes: 49 additions & 47 deletions src/main/java/com/github/milkdrinkers/colorparser/ColorParser.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<String, String> legacyToMiniMessage = Map.ofEntries(
Map.entry("§0", "<black>"),
Map.entry("§1", "<dark_blue>"),
Map.entry("§2", "<dark_green>"),
Map.entry("§3", "<dark_aqua>"),
Map.entry("§4", "<dark_red>"),
Map.entry("§5", "<dark_purple>"),
Map.entry("§6", "<gold>"),
Map.entry("§7", "<gray>"),
Map.entry("§8", "<dark_gray>"),
Map.entry("§9", "<blue>"),
Map.entry("§a", "<green>"),
Map.entry("§b", "<aqua>"),
Map.entry("§c", "<red>"),
Map.entry("§d", "<light_purple>"),
Map.entry("§e", "<yellow>"),
Map.entry("§f", "<white>"),
Map.entry("§k", "<obfuscated>"),
Map.entry("§l", "<bold>"),
Map.entry("§m", "<strikethrough>"),
Map.entry("§n", "<underlined>"),
Map.entry("§o", "<italic>"),
Map.entry("§r", "<reset>"),
Map.entry("&0", "<black>"),
Map.entry("&1", "<dark_blue>"),
Map.entry("&2", "<dark_green>"),
Map.entry("&3", "<dark_aqua>"),
Map.entry("&4", "<dark_red>"),
Map.entry("&5", "<dark_purple>"),
Map.entry("&6", "<gold>"),
Map.entry("&7", "<gray>"),
Map.entry("&8", "<dark_gray>"),
Map.entry("&9", "<blue>"),
Map.entry("&a", "<green>"),
Map.entry("&b", "<aqua>"),
Map.entry("&c", "<red>"),
Map.entry("&d", "<light_purple>"),
Map.entry("&e", "<yellow>"),
Map.entry("&f", "<white>"),
Map.entry("&k", "<obfuscated>"),
Map.entry("&l", "<bold>"),
Map.entry("&m", "<strikethrough>"),
Map.entry("&n", "<underlined>"),
Map.entry("&o", "<italic>"),
Map.entry("&r", "<reset>")
);
private static final Map<String, String> legacyToMiniMessage;
static {
legacyToMiniMessage = new HashMap<>();
legacyToMiniMessage.put("§0", "<black>");
legacyToMiniMessage.put("§1", "<dark_blue>");
legacyToMiniMessage.put("§2", "<dark_green>");
legacyToMiniMessage.put("§3", "<dark_aqua>");
legacyToMiniMessage.put("§4", "<dark_red>");
legacyToMiniMessage.put("§5", "<dark_purple>");
legacyToMiniMessage.put("§6", "<gold>");
legacyToMiniMessage.put("§7", "<gray>");
legacyToMiniMessage.put("§8", "<dark_gray>");
legacyToMiniMessage.put("§9", "<blue>");
legacyToMiniMessage.put("§a", "<green>");
legacyToMiniMessage.put("§b", "<aqua>");
legacyToMiniMessage.put("§c", "<red>");
legacyToMiniMessage.put("§d", "<light_purple>");
legacyToMiniMessage.put("§e", "<yellow>");
legacyToMiniMessage.put("§f", "<white>");
legacyToMiniMessage.put("§k", "<obfuscated>");
legacyToMiniMessage.put("§l", "<bold>");
legacyToMiniMessage.put("§m", "<strikethrough>");
legacyToMiniMessage.put("§n", "<underlined>");
legacyToMiniMessage.put("§o", "<italic>");
legacyToMiniMessage.put("§r", "<reset>");
legacyToMiniMessage.put("&0", "<black>");
legacyToMiniMessage.put("&1", "<dark_blue>");
legacyToMiniMessage.put("&2", "<dark_green>");
legacyToMiniMessage.put("&3", "<dark_aqua>");
legacyToMiniMessage.put("&4", "<dark_red>");
legacyToMiniMessage.put("&5", "<dark_purple>");
legacyToMiniMessage.put("&6", "<gold>");
legacyToMiniMessage.put("&7", "<gray>");
legacyToMiniMessage.put("&8", "<dark_gray>");
legacyToMiniMessage.put("&9", "<blue>");
legacyToMiniMessage.put("&a", "<green>");
legacyToMiniMessage.put("&b", "<aqua>");
legacyToMiniMessage.put("&c", "<red>");
legacyToMiniMessage.put("&d", "<light_purple>");
legacyToMiniMessage.put("&e", "<yellow>");
legacyToMiniMessage.put("&f", "<white>");
legacyToMiniMessage.put("&k", "<obfuscated>");
legacyToMiniMessage.put("&l", "<bold>");
legacyToMiniMessage.put("&m", "<strikethrough>");
legacyToMiniMessage.put("&n", "<underlined>");
legacyToMiniMessage.put("&o", "<italic>");
legacyToMiniMessage.put("&r", "<reset>");
}
private final List<TagResolver> minimessagePlaceholders = new ArrayList<>(); // Store MiniMessage placeholders to be applied
private String text;

Expand Down

0 comments on commit f8a4036

Please sign in to comment.