From 637ffe93613f15d46c9f62e6aa3183c96b617998 Mon Sep 17 00:00:00 2001 From: Tyler Bochard Date: Fri, 29 Dec 2023 12:05:13 -0500 Subject: [PATCH] support kotlin 1.9.22 This makes some changes to the client pom to support compiling kotlin Adds "hotlite.plugins" package to the plugin scanner Adds K-Example kotlin plugin example. This is all very basic at the moment but kotlin plugin functionality will eventually be as good as it was on Meteor. This depends on the recent launcher commit that updates the kotlin std lib for runtime --- .mvn/jvm.config | 2 + runelite-client/pom.xml | 32 +++ .../hotlite/plugins/example/ExampleConfig.kt | 259 ++++++++++++++++++ .../hotlite/plugins/example/ExamplePlugin.kt | 27 ++ .../client/plugins/PluginManager.java | 3 + 5 files changed, 323 insertions(+) create mode 100644 runelite-client/src/main/java/hotlite/plugins/example/ExampleConfig.kt create mode 100644 runelite-client/src/main/java/hotlite/plugins/example/ExamplePlugin.kt diff --git a/.mvn/jvm.config b/.mvn/jvm.config index 67bd169f31..01ea565cbe 100644 --- a/.mvn/jvm.config +++ b/.mvn/jvm.config @@ -1 +1,3 @@ -Xmx512m +--add-opens=java.base/java.lang=ALL-UNNAMED +--add-opens=java.base/java.io=ALL-UNNAMED diff --git a/runelite-client/pom.xml b/runelite-client/pom.xml index 82adc6766c..7b65e232cc 100644 --- a/runelite-client/pom.xml +++ b/runelite-client/pom.xml @@ -41,6 +41,7 @@ nogit false false + 1.9.22 @@ -322,6 +323,13 @@ cfr 0.152 + + + + org.jetbrains.kotlin + kotlin-stdlib + ${kotlin.version} + @@ -490,6 +498,30 @@ + + org.jetbrains.kotlin + kotlin-maven-plugin + ${kotlin.version} + + + compile + + compile + + + + test-compile + + test-compile + + + + + + ${project.basedir}/src/main/kotlin + + + diff --git a/runelite-client/src/main/java/hotlite/plugins/example/ExampleConfig.kt b/runelite-client/src/main/java/hotlite/plugins/example/ExampleConfig.kt new file mode 100644 index 0000000000..a7371f2734 --- /dev/null +++ b/runelite-client/src/main/java/hotlite/plugins/example/ExampleConfig.kt @@ -0,0 +1,259 @@ +/* + * Copyright (c) 2018, Cas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package hotlite.plugins.example + +import net.runelite.client.config.* +import java.awt.Color + +@ConfigGroup("agility") +interface ExampleConfig : Config { + @ConfigItem( + keyName = "showClickboxes", + name = "Show Clickboxes", + description = "Show agility course and other obstacle clickboxes", + position = 0 + ) + fun showClickboxes(): Boolean { + return true + } + + @ConfigItem( + keyName = "showLapCount", + name = "Show Lap Count", + description = "Enable/disable the lap counter", + position = 1 + ) + fun showLapCount(): Boolean { + return true + } + + @ConfigItem( + keyName = "lapTimeout", + name = "Hide Lap Count", + description = "Time until the lap counter hides/resets", + position = 2 + ) + @Units( + Units.MINUTES + ) + fun lapTimeout(): Int { + return 5 + } + + @ConfigItem( + keyName = "lapsToLevel", + name = "Show Laps Until Goal", + description = "Show number of laps remaining until next goal is reached.", + position = 3 + ) + fun lapsToLevel(): Boolean { + return true + } + + @ConfigItem( + keyName = "lapsPerHour", + name = "Show Laps Per Hour", + description = "Shows how many laps you can expect to complete per hour.", + position = 4 + ) + fun lapsPerHour(): Boolean { + return true + } + + @get:ConfigItem( + keyName = "overlayColor", + name = "Overlay Color", + description = "Color of Agility overlay", + position = 5 + ) + @get:Alpha + val overlayColor: Color? + get() = Color.GREEN + + @ConfigItem( + keyName = "highlightMarks", + name = "Highlight Marks of Grace", + description = "Enable/disable the highlighting of retrievable Marks of Grace", + position = 6 + ) + fun highlightMarks(): Boolean { + return true + } + + @get:ConfigItem( + keyName = "markHighlight", + name = "Mark Highlight Color", + description = "Color of highlighted Marks of Grace", + position = 7 + ) + @get:Alpha + val markColor: Color? + get() = Color.RED + + @ConfigItem( + keyName = "highlightPortals", + name = "Highlight Portals", + description = "Enable/disable the highlighting of Prifddinas portals", + position = 8 + ) + fun highlightPortals(): Boolean { + return true + } + + @get:ConfigItem( + keyName = "portalsHighlight", + name = "Portals Color", + description = "Color of highlighted Prifddinas portals", + position = 9 + ) + @get:Alpha + val portalsColor: Color? + get() = Color.MAGENTA + + @ConfigItem( + keyName = "highlightShortcuts", + name = "Highlight Agility Shortcuts", + description = "Enable/disable the highlighting of Agility shortcuts", + position = 10 + ) + fun highlightShortcuts(): Boolean { + return true + } + + @ConfigItem( + keyName = "trapOverlay", + name = "Show Trap Overlay", + description = "Enable/disable the highlighting of traps on Agility courses", + position = 11 + ) + fun showTrapOverlay(): Boolean { + return true + } + + @get:ConfigItem( + keyName = "trapHighlight", + name = "Trap Overlay Color", + description = "Color of Agility trap overlay", + position = 12 + ) + @get:Alpha + val trapColor: Color? + get() = Color.RED + + @ConfigItem( + keyName = "agilityArenaNotifier", + name = "Agility Arena notifier", + description = "Notify on ticket location change in Agility Arena", + position = 13 + ) + fun notifyAgilityArena(): Boolean { + return true + } + + @ConfigItem( + keyName = "agilityArenaTimer", + name = "Agility Arena timer", + description = "Configures whether Agility Arena timer is displayed", + position = 14 + ) + fun showAgilityArenaTimer(): Boolean { + return true + } + + @ConfigItem( + keyName = "highlightStick", + name = "Highlight Stick", + description = "Highlight the retrievable stick in the Werewolf Agility Course", + position = 15 + ) + fun highlightStick(): Boolean { + return true + } + + @Alpha + @ConfigItem( + keyName = "stickHighlightColor", + name = "Stick Highlight Color", + description = "Color of highlighted stick", + position = 16 + ) + fun stickHighlightColor(): Color? { + return Color.RED + } + + @ConfigItem( + keyName = "highlightSepulchreNpcs", + name = "Highlight Projectiles", + description = "Highlights arrows and swords in the Sepulchre", + position = 17, + section = sepulchreSection + ) + fun highlightSepulchreNpcs(): Boolean { + return true + } + + @Alpha + @ConfigItem( + keyName = "sepulchreHighlightColor", + name = "Projectile Color", + description = "Overlay color for arrows and swords", + position = 18, + section = sepulchreSection + ) + fun sepulchreHighlightColor(): Color? { + return Color.GREEN + } + + @ConfigItem( + keyName = "highlightSepulchreObstacles", + name = "Highlight Obstacles", + description = "Highlights pillars and stairs in the Sepulchre", + position = 19, + section = sepulchreSection + ) + fun highlightSepulchreObstacles(): Boolean { + return true + } + + @ConfigItem( + keyName = "highlightSepulchreSkilling", + name = "Highlight Skill Challenges", + description = "Highlights skilling challenges in the Sepulchre", + position = 20, + section = sepulchreSection + ) + fun highlightSepulchreSkilling(): Boolean { + return true + } + + companion object { + @ConfigSection( + name = "Hallowed Sepulchre", + description = "Settings for Hallowed Sepulchre highlights", + position = 17 + ) + const val sepulchreSection = "Hallowed Sepulchre" + } +} diff --git a/runelite-client/src/main/java/hotlite/plugins/example/ExamplePlugin.kt b/runelite-client/src/main/java/hotlite/plugins/example/ExamplePlugin.kt new file mode 100644 index 0000000000..2f760b3d72 --- /dev/null +++ b/runelite-client/src/main/java/hotlite/plugins/example/ExamplePlugin.kt @@ -0,0 +1,27 @@ +package hotlite.plugins.example + +import com.google.inject.Inject +import com.google.inject.Provides +import net.runelite.api.events.GameTick +import net.runelite.client.config.ConfigManager +import net.runelite.client.eventbus.Subscribe +import net.runelite.client.plugins.Plugin +import net.runelite.client.plugins.PluginDescriptor + +@PluginDescriptor( + name = "K-Example", + description = "Kotlin Example", + tags = ["kotlin"] +) +class ExamplePlugin : Plugin() { + + @Subscribe + fun onGameTick(event: GameTick) { + println("Game Tick") + } + + @Provides + fun getConfig(configManager: ConfigManager): ExampleConfig { + return configManager.getConfig(ExampleConfig::class.java) + } +} \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java index 077f2cbd57..25978f59e4 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/PluginManager.java @@ -270,6 +270,9 @@ public void loadCorePlugins() throws IOException, PluginInstantiationException List> plugins = classPath.getTopLevelClassesRecursive(PLUGIN_PACKAGE).stream() .map(ClassInfo::load) .collect(Collectors.toList()); + plugins.addAll(classPath.getTopLevelClassesRecursive("hotlite.plugins").stream() + .map(ClassInfo::load) + .collect(Collectors.toList())); plugins.addAll(classPath.getTopLevelClassesRecursive("com.example").stream() .map(ClassInfo::load) .collect(Collectors.toList()));