Initial commit
This commit is contained in:
19
src/main/java/com/example/ExampleConfig.java
Normal file
19
src/main/java/com/example/ExampleConfig.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package com.example;
|
||||
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("example")
|
||||
public interface ExampleConfig extends Config
|
||||
{
|
||||
@ConfigItem(
|
||||
keyName = "greeting",
|
||||
name = "Welcome Greeting",
|
||||
description = "The message to show to the user when they login"
|
||||
)
|
||||
default String greeting()
|
||||
{
|
||||
return "Hello";
|
||||
}
|
||||
}
|
||||
53
src/main/java/com/example/ExamplePlugin.java
Normal file
53
src/main/java/com/example/ExamplePlugin.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package com.example;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import javax.inject.Inject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
|
||||
@Slf4j
|
||||
@PluginDescriptor(
|
||||
name = "Example"
|
||||
)
|
||||
public class ExamplePlugin extends Plugin
|
||||
{
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private ExampleConfig config;
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
log.info("Example started!");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
log.info("Example stopped!");
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onGameStateChanged(GameStateChanged gameStateChanged)
|
||||
{
|
||||
if (gameStateChanged.getGameState() == GameState.LOGGED_IN)
|
||||
{
|
||||
client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "Example says " + config.greeting(), null);
|
||||
}
|
||||
}
|
||||
|
||||
@Provides
|
||||
ExampleConfig provideConfig(ConfigManager configManager)
|
||||
{
|
||||
return configManager.getConfig(ExampleConfig.class);
|
||||
}
|
||||
}
|
||||
13
src/test/java/com/example/ExamplePluginTest.java
Normal file
13
src/test/java/com/example/ExamplePluginTest.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package com.example;
|
||||
|
||||
import net.runelite.client.RuneLite;
|
||||
import net.runelite.client.externalplugins.ExternalPluginManager;
|
||||
|
||||
public class ExamplePluginTest
|
||||
{
|
||||
public static void main(String[] args) throws Exception
|
||||
{
|
||||
ExternalPluginManager.loadBuiltin(ExamplePlugin.class);
|
||||
RuneLite.main(args);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user