diff --git a/README.md b/README.md index fa597f4..f76209d 100644 --- a/README.md +++ b/README.md @@ -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`. diff --git a/src/main/java/com/pettheanimals/PetTheAnimalsConfig.java b/src/main/java/com/pettheanimals/PetTheAnimalsConfig.java index 791814a..55ffedf 100644 --- a/src/main/java/com/pettheanimals/PetTheAnimalsConfig.java +++ b/src/main/java/com/pettheanimals/PetTheAnimalsConfig.java @@ -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 ""; + } } diff --git a/src/main/java/com/pettheanimals/PetTheAnimalsPlugin.java b/src/main/java/com/pettheanimals/PetTheAnimalsPlugin.java index 149a95c..55d5436 100644 --- a/src/main/java/com/pettheanimals/PetTheAnimalsPlugin.java +++ b/src/main/java/com/pettheanimals/PetTheAnimalsPlugin.java @@ -53,6 +53,7 @@ public class PetTheAnimalsPlugin extends Plugin @Override protected void startUp() throws Exception { + registerPetMenu(); log.info("Pet the Animals started"); } @@ -63,6 +64,7 @@ protected void shutDown() throws Exception clearOverheadTask.cancel(true); } scheduler.shutdownNow(); + unregisterPetMenu(); log.info("Pet the Animals stopped"); } @@ -221,7 +223,7 @@ 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)) @@ -229,6 +231,21 @@ private boolean isWhitelisted(String npcName) 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; } @@ -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();