diff --git a/src/main/kotlin/ley/anvil/modpacktools/commands/CreateModlist.kt b/src/main/kotlin/ley/anvil/modpacktools/commands/CreateModlist.kt index 1b442dd..3a24537 100644 --- a/src/main/kotlin/ley/anvil/modpacktools/commands/CreateModlist.kt +++ b/src/main/kotlin/ley/anvil/modpacktools/commands/CreateModlist.kt @@ -1,6 +1,7 @@ package ley.anvil.modpacktools.commands import j2html.TagCreator.* +import j2html.utils.CSSMin.compressCss import ley.anvil.addonscript.maven.ArtifactDestination import ley.anvil.addonscript.wrapper.ASWrapper import ley.anvil.addonscript.wrapper.MetaData @@ -12,8 +13,10 @@ import ley.anvil.modpacktools.command.ICommand import ley.anvil.modpacktools.command.LoadCommand import org.apache.commons.csv.CSVFormat import org.apache.commons.csv.CSVPrinter +import org.apache.commons.io.IOUtils import java.io.File import java.io.FileWriter +import java.nio.charset.StandardCharsets @LoadCommand object CreateModlist : ICommand { @@ -61,30 +64,7 @@ object CreateModlist : ICommand { head( style( //Fancy css! - """ -a:link { - color: #ff5555; -} -a:visited { - color: #cc55cc; -} -body { - background-color: #333333; - color: #ffffff -} -.img { - width:100px; -} -td { - border: #999999 3px; - border-style: solid; -} -.description { - width: 100% -} -""" - //trim unnecessary chars - .trimIndent().filter {it != '\n'} + compressCss(IOUtils.toString(ClassLoader.getSystemResourceAsStream("commands/createmodlist/style.css"), StandardCharsets.UTF_8)) ) ), body( diff --git a/src/main/kotlin/ley/anvil/modpacktools/util/CustomToml.kt b/src/main/kotlin/ley/anvil/modpacktools/util/CustomToml.kt index e6ee283..1c065a3 100644 --- a/src/main/kotlin/ley/anvil/modpacktools/util/CustomToml.kt +++ b/src/main/kotlin/ley/anvil/modpacktools/util/CustomToml.kt @@ -1,17 +1,14 @@ package ley.anvil.modpacktools.util import com.moandjiezana.toml.Toml -import kotlin.reflect.full.functions -import kotlin.reflect.jvm.isAccessible class CustomToml : Toml() { companion object { @JvmStatic fun Toml.get(key: String): Any? { //Getting Around things being private for no reason 101 (dont look :P) - val getFunc = this::class.functions.reduce {a, b -> if(b.name == "get") b else a} - getFunc.isAccessible = true - return getFunc.call(this, key) + val getFunc by lazy {Toml::class.getFun("get")} + return getFunc?.call(this, key) } } diff --git a/src/main/kotlin/ley/anvil/modpacktools/util/Util.kt b/src/main/kotlin/ley/anvil/modpacktools/util/Util.kt index 1de96dd..16ffdea 100644 --- a/src/main/kotlin/ley/anvil/modpacktools/util/Util.kt +++ b/src/main/kotlin/ley/anvil/modpacktools/util/Util.kt @@ -14,6 +14,10 @@ import java.io.FileReader import java.io.IOException import java.net.URI import java.net.URL +import kotlin.reflect.KClass +import kotlin.reflect.KFunction +import kotlin.reflect.full.functions +import kotlin.reflect.jvm.isAccessible /** * Reads a Json File @@ -87,4 +91,12 @@ fun URL.sanitize(): URL? { } catch(e: Exception) { null } -} \ No newline at end of file +} + +/** + * gets a function from the receiver and makes it accessible + * + * @param name the name of the function to get + * @receiver the class to get the function from + */ +fun KClass<*>.getFun(name: String): KFunction<*>? = this.functions.find {it.name == name}?.apply {isAccessible = true} \ No newline at end of file diff --git a/src/main/resources/commands/createmodlist/style.css b/src/main/resources/commands/createmodlist/style.css new file mode 100644 index 0000000..cb8d376 --- /dev/null +++ b/src/main/resources/commands/createmodlist/style.css @@ -0,0 +1,20 @@ +a:link { + color: #ff5555; +} +a:visited { + color: #cc55cc; +} +body { + background-color: #333333; + color: #ffffff +} +.img { + width:100px; +} +td { + border: #999999 3px; + border-style: solid; +} +.description { + width: 100% +} \ No newline at end of file