diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryOverlay.java index b317d5d89c..31d304e782 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryOverlay.java @@ -210,12 +210,12 @@ class KourendLibraryOverlay extends Overlay } // Render the customer's wanted book on their head and a poly under their feet - LibraryCustomer customer = library.getCustomer(); - if (customer != null) + int customerId = library.getCustomerId(); + if (customerId != -1) { for (NPC n : plugin.getNpcsToMark()) { - if (n.getId() != customer.getId()) + if (n.getId() != customerId) { continue; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryPlugin.java index cf2d5bca44..c9770baab7 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/KourendLibraryPlugin.java @@ -44,6 +44,7 @@ import net.runelite.api.Item; import net.runelite.api.ItemContainer; import net.runelite.api.MenuAction; import net.runelite.api.NPC; +import net.runelite.api.NpcID; import net.runelite.api.Player; import net.runelite.api.coords.WorldPoint; import net.runelite.api.events.AnimationChanged; @@ -270,8 +271,7 @@ public class KourendLibraryPlugin extends Plugin Widget npcHead = client.getWidget(WidgetInfo.DIALOG_NPC_HEAD_MODEL); if (npcHead != null) { - LibraryCustomer cust = LibraryCustomer.getById(npcHead.getModelId()); - if (cust != null) + if (isLibraryCustomer(npcHead.getModelId())) { Widget textw = client.getWidget(WidgetInfo.DIALOG_NPC_TEXT); String text = textw.getText(); @@ -286,12 +286,12 @@ public class KourendLibraryPlugin extends Plugin return; } - library.setCustomer(cust, book); + library.setCustomer(npcHead.getModelId(), book); panel.update(); } else if (text.contains("You can have this other book") || text.contains("please accept a token of my thanks.") || text.contains("Thanks, I'll get on with reading it.")) { - library.setCustomer(null, null); + library.setCustomer(-1, null); panel.update(); } } @@ -307,7 +307,7 @@ public class KourendLibraryPlugin extends Plugin @Subscribe public void onNpcSpawned(NpcSpawned event) { - if (LibraryCustomer.getById(event.getNpc().getId()) != null) + if (isLibraryCustomer(event.getNpc().getId())) { npcsToMark.add(event.getNpc()); } @@ -345,4 +345,9 @@ public class KourendLibraryPlugin extends Plugin playerBooks = books; } } + + static boolean isLibraryCustomer(int npcId) + { + return npcId == NpcID.VILLIA || npcId == NpcID.PROFESSOR_GRACKLEBONE || npcId == NpcID.SAM_7049; + } } \ No newline at end of file diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/Library.java b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/Library.java index 5af160da87..ea74a84b39 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/Library.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/Library.java @@ -74,7 +74,7 @@ class Library private Book customerBook; @Getter - private LibraryCustomer customer; + private int customerId; Library() { @@ -93,9 +93,9 @@ class Library return Collections.unmodifiableList(byIndex); } - void setCustomer(LibraryCustomer customer, Book book) + void setCustomer(int customerId, Book book) { - this.customer = customer; + this.customerId = customerId; this.customerBook = book; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/LibraryCustomer.java b/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/LibraryCustomer.java deleted file mode 100644 index 229ed37efe..0000000000 --- a/runelite-client/src/main/java/net/runelite/client/plugins/kourendlibrary/LibraryCustomer.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2018 Abex - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * 1. Redistributions of source code must retain the above copyright notice, this - * list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.runelite.client.plugins.kourendlibrary; - -import java.util.HashMap; -import java.util.Map; -import lombok.Getter; - -import net.runelite.api.NpcID; - -enum LibraryCustomer -{ - VILLIA(NpcID.VILLIA, "Villia"), - PROFESSOR_GRACKLEBONE(NpcID.PROFESSOR_GRACKLEBONE, "Prof. Gracklebone"), - SAM(NpcID.SAM_7049, "Sam"); - - @Getter - private final int id; - - @Getter - private final String name; - - private static final Map byId = buildIdMap(); - - LibraryCustomer(int id, String name) - { - this.id = id; - this.name = name; - } - - static LibraryCustomer getById(int id) - { - return byId.get(id); - } - - private static Map buildIdMap() - { - Map byId = new HashMap<>(); - for (LibraryCustomer c : values()) - { - byId.put(c.id, c); - } - return byId; - } -}