diff --git a/pom.xml b/pom.xml index a0cb4b9ffd..75299b58a8 100644 --- a/pom.xml +++ b/pom.xml @@ -112,6 +112,7 @@ runescape-client runescape-client-injector runescape-client-injector-plugin + runelite-plugin-archetype http-api http-service runelite-proxy diff --git a/runelite-plugin-archetype/pom.xml b/runelite-plugin-archetype/pom.xml new file mode 100644 index 0000000000..50c097f5d9 --- /dev/null +++ b/runelite-plugin-archetype/pom.xml @@ -0,0 +1,86 @@ + + + + 4.0.0 + + + net.runelite + runelite-parent + 1.2.8-SNAPSHOT + + + runelite-plugin-archetype + maven-archetype + Runelite Plugin Archetype + + + + + + src/main/resources + true + + archetype-resources/pom.xml + + + + src/main/resources + false + + archetype-resources/pom.xml + + + + + + + org.apache.maven.archetype + archetype-packaging + 3.0.1 + + + + + + + maven-archetype-plugin + 3.0.1 + + + org.apache.maven.plugins + maven-resources-plugin + 3.0.2 + + + \ + + + + + + diff --git a/runelite-plugin-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml b/runelite-plugin-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml new file mode 100644 index 0000000000..b67d8cde67 --- /dev/null +++ b/runelite-plugin-archetype/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -0,0 +1,13 @@ + + + + + src/main/java + + **/*.java + + + + diff --git a/runelite-plugin-archetype/src/main/resources/archetype-resources/pom.xml b/runelite-plugin-archetype/src/main/resources/archetype-resources/pom.xml new file mode 100644 index 0000000000..7b5a41a31e --- /dev/null +++ b/runelite-plugin-archetype/src/main/resources/archetype-resources/pom.xml @@ -0,0 +1,54 @@ + + + 4.0.0 + \${groupId} + \${artifactId} + \${version} + jar + + + UTF-8 + 1.8 + 1.8 + + + + + runelite + Runelite + http://repo.runelite.net + + + + + + net.runelite + client + ${project.version} + provided + + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.8 + + + install + + + + + + + run + + + + + + + diff --git a/runelite-plugin-archetype/src/main/resources/archetype-resources/src/main/java/ExampleOverlay.java b/runelite-plugin-archetype/src/main/resources/archetype-resources/src/main/java/ExampleOverlay.java new file mode 100644 index 0000000000..0675bccdfc --- /dev/null +++ b/runelite-plugin-archetype/src/main/resources/archetype-resources/src/main/java/ExampleOverlay.java @@ -0,0 +1,47 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}; + +import java.awt.Dimension; +import java.awt.Graphics2D; +import javax.annotation.Nullable; +import javax.inject.Inject; +import net.runelite.api.Client; +import net.runelite.api.GameState; +import net.runelite.api.Player; +import net.runelite.api.Point; +import net.runelite.client.ui.overlay.Overlay; +import net.runelite.client.ui.overlay.OverlayPosition; + +public class ExampleOverlay extends Overlay +{ + private final Client client; + private final ExamplePluginConfiguration config; + + @Inject + public ExampleOverlay(@Nullable Client client, ExamplePluginConfiguration config) + { + super(OverlayPosition.DYNAMIC); + this.client = client; + this.config = config; + } + + @Override + public Dimension render(Graphics2D graphics) + { + if (client.getGameState() != GameState.LOGGED_IN || !config.enabled()) + { + return null; + } + + Player player = client.getLocalPlayer(); + String text = player.getName() + " (Level: " + player.getCombatLevel() + ")"; + + Point textLocation = player.getCanvasTextLocation(graphics, text, player.getModelHeight()); + graphics.drawString(text, textLocation.getX(), textLocation.getY()); + + return null; + } + +} diff --git a/runelite-plugin-archetype/src/main/resources/archetype-resources/src/main/java/ExamplePlugin.java b/runelite-plugin-archetype/src/main/resources/archetype-resources/src/main/java/ExamplePlugin.java new file mode 100644 index 0000000000..1c38a3712c --- /dev/null +++ b/runelite-plugin-archetype/src/main/resources/archetype-resources/src/main/java/ExamplePlugin.java @@ -0,0 +1,74 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}; + +import com.google.common.eventbus.Subscribe; +import com.google.inject.Binder; +import com.google.inject.Provides; +import javax.annotation.Nullable; +import javax.inject.Inject; +import net.runelite.api.Client; +import net.runelite.api.GameState; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.events.GameStateChanged; +import net.runelite.client.plugins.Plugin; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.ui.overlay.Overlay; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@PluginDescriptor( + name = "Example plugin" +) +public class ExamplePlugin extends Plugin +{ + private static final Logger logger = LoggerFactory.getLogger(ExamplePlugin.class); + + @Inject + @Nullable + Client client; + + @Inject + ExampleOverlay overlay; + + @Override + protected void startUp() throws Exception + { + logger.info("Example plugin started!"); + } + + @Override + protected void shutDown() throws Exception + { + logger.info("Example plugin stopped!"); + } + + @Subscribe + public void onGameStateChanged(GameStateChanged gameStateChanged) + { + if (gameStateChanged.getGameState() == GameState.LOGGED_IN) + { + client.sendGameMessage("Example plugin is running!"); + } + } + + @Override + public void configure(Binder binder) + { + binder.bind(ExampleOverlay.class); + } + + @Override + public Overlay getOverlay() + { + return overlay; + } + + @Provides + ExamplePluginConfiguration provideConfig(ConfigManager configManager) + { + return configManager.getConfig(ExamplePluginConfiguration.class); + } + +} \ No newline at end of file diff --git a/runelite-plugin-archetype/src/main/resources/archetype-resources/src/main/java/ExamplePluginConfiguration.java b/runelite-plugin-archetype/src/main/resources/archetype-resources/src/main/java/ExamplePluginConfiguration.java new file mode 100644 index 0000000000..4017349734 --- /dev/null +++ b/runelite-plugin-archetype/src/main/resources/archetype-resources/src/main/java/ExamplePluginConfiguration.java @@ -0,0 +1,26 @@ +#set( $symbol_pound = '#' ) +#set( $symbol_dollar = '$' ) +#set( $symbol_escape = '\' ) +package ${package}; + +import net.runelite.client.config.Config; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup( + keyName = "exampleplugin", + name = "Example plugin", + description = "Configuration for example plugin" +) +public interface ExamplePluginConfiguration extends Config +{ + @ConfigItem( + keyName = "enabled", + name = "Enable overlay", + description = "Configures whether the overlay is enabled" + ) + default boolean enabled() + { + return true; + } +}