Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,24 @@
*🚧 This plugin is a **Work in Progress** 🚧
# ✨🐾 Pet The Animals 🐾✨

Pet friendly NPCs around Gielinor directly from RuneLite.
This plugin adds a custom **Pet** option to a variety of animals and displays a fun
response from your character.

## Features
- Right–click **Pet** option for whitelisted NPCs.
- Overhead text and/or chat messages with randomized flavour text.
- Configurable maximum distance to interact.
- Add your own comma‑separated list of additional NPC names to pet.

## Configuration
The plugin exposes several options in the RuneLite configuration panel:

| Option | Description |
| --- | --- |
| Enable Chat Message | Send pet message to chatbox. |
| Enable Overhead Text | Show message over your player. |
| Max Distance | Maximum number of tiles you can be from the NPC (default 2). |
| Additional NPCs | Extra comma-separated NPC names that are allowed to be petted. |

## Building
This is a standard RuneLite plugin and can be built with `./gradlew build`.
28 changes: 24 additions & 4 deletions src/main/java/com/pettheanimals/PetTheAnimalsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,28 @@ default boolean enableChatMessage()
name = "Enable Overhead Text",
description = "Show the pet message above your player."
)
default boolean enableOverheadText()
{
return true;
}
default boolean enableOverheadText()
{
return true;
}

@ConfigItem(
keyName = "petDistance",
name = "Max Distance",
description = "Maximum tiles away you can be to pet an NPC."
)
default int petDistance()
{
return 2;
}

@ConfigItem(
keyName = "additionalNpcNames",
name = "Additional NPCs",
description = "Comma-separated list of extra NPC names that can be petted."
)
default String additionalNpcNames()
{
return "";
}
}
21 changes: 19 additions & 2 deletions src/main/java/com/pettheanimals/PetTheAnimalsPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class PetTheAnimalsPlugin extends Plugin
@Override
protected void startUp() throws Exception
{
registerPetMenu();
log.info("Pet the Animals started");
}

Expand All @@ -63,6 +64,7 @@ protected void shutDown() throws Exception
clearOverheadTask.cancel(true);
}
scheduler.shutdownNow();
unregisterPetMenu();
log.info("Pet the Animals stopped");
}

Expand Down Expand Up @@ -221,14 +223,29 @@ private boolean isWhitelisted(String npcName)
}
// Remove level suffixes and trim
String name = npcName.replaceAll("\\s*\\(level-?\\d+\\)\\s*", "").trim();
// Case-insensitive exact match against our whitelist
// Case-insensitive exact match against our built-in whitelist
for (String allowed : PetResponses.WHITELISTED_NPCS)
{
if (allowed.equalsIgnoreCase(name))
{
return true;
}
}

// Allow user-defined additional names from configuration
String extra = config.additionalNpcNames();
if (extra != null && !extra.trim().isEmpty())
{
String[] split = extra.split(",");
for (String s : split)
{
if (name.equalsIgnoreCase(s.trim()))
{
return true;
}
}
}

return false;
}

Expand Down Expand Up @@ -426,7 +443,7 @@ public void onMenuOptionClicked(MenuOptionClicked event)
{
WorldPoint me = client.getLocalPlayer().getWorldLocation();
WorldPoint them = npc.getWorldLocation();
if (!withinTiles(me, them, 2))
if (!withinTiles(me, them, config.petDistance()))
{
client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "You need to be closer to do that.", null);
event.consume();
Expand Down