mirror of
https://github.com/runelite/example-plugin.git
synced 2026-08-02 02:06:23 -04:00
54 lines
1.2 KiB
Java
54 lines
1.2 KiB
Java
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.debug("Example started!");
|
|
}
|
|
|
|
@Override
|
|
protected void shutDown() throws Exception
|
|
{
|
|
log.debug("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);
|
|
}
|
|
}
|