Merge pull request #3961 from NathenSample/3911-KourendLibrary
Update kourend library plugin encapsulation
This commit is contained in:
@@ -32,7 +32,7 @@ import net.runelite.api.ItemID;
|
|||||||
import net.runelite.client.game.AsyncBufferedImage;
|
import net.runelite.client.game.AsyncBufferedImage;
|
||||||
import net.runelite.client.game.ItemManager;
|
import net.runelite.client.game.ItemManager;
|
||||||
|
|
||||||
public enum Book
|
enum Book
|
||||||
{
|
{
|
||||||
DARK_MANUSCRIPT_13514(ItemID.DARK_MANUSCRIPT),
|
DARK_MANUSCRIPT_13514(ItemID.DARK_MANUSCRIPT),
|
||||||
DARK_MANUSCRIPT_13515(ItemID.DARK_MANUSCRIPT_13515),
|
DARK_MANUSCRIPT_13515(ItemID.DARK_MANUSCRIPT_13515),
|
||||||
@@ -89,12 +89,12 @@ public enum Book
|
|||||||
return Collections.unmodifiableMap(byName);
|
return Collections.unmodifiableMap(byName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Book byId(int id)
|
static Book byId(int id)
|
||||||
{
|
{
|
||||||
return BY_ID.get(id);
|
return BY_ID.get(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Book byName(String name)
|
static Book byName(String name)
|
||||||
{
|
{
|
||||||
return BY_NAME.get(name);
|
return BY_NAME.get(name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,12 +70,12 @@ class BookPanel extends JPanel
|
|||||||
setComponentZOrder(image, getComponentCount() - 1);
|
setComponentZOrder(image, getComponentCount() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLocation(String location)
|
void setLocation(String location)
|
||||||
{
|
{
|
||||||
this.location.setText(location);
|
this.location.setText(location);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsTarget(boolean target)
|
void setIsTarget(boolean target)
|
||||||
{
|
{
|
||||||
location.setForeground(target ? Color.GREEN : Color.WHITE);
|
location.setForeground(target ? Color.GREEN : Color.WHITE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import net.runelite.api.coords.WorldPoint;
|
|||||||
|
|
||||||
class Bookcase
|
class Bookcase
|
||||||
{
|
{
|
||||||
public Bookcase(WorldPoint location)
|
Bookcase(WorldPoint location)
|
||||||
{
|
{
|
||||||
this.location = location;
|
this.location = location;
|
||||||
this.index = new ArrayList<>();
|
this.index = new ArrayList<>();
|
||||||
@@ -62,19 +62,19 @@ class Bookcase
|
|||||||
@Getter
|
@Getter
|
||||||
private Set<Book> possibleBooks = new HashSet<>();
|
private Set<Book> possibleBooks = new HashSet<>();
|
||||||
|
|
||||||
public void clearBook()
|
void clearBook()
|
||||||
{
|
{
|
||||||
book = null;
|
book = null;
|
||||||
isBookSet = false;
|
isBookSet = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBook(Book book)
|
void setBook(Book book)
|
||||||
{
|
{
|
||||||
this.book = book;
|
this.book = book;
|
||||||
this.isBookSet = true;
|
this.isBookSet = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLocationString()
|
String getLocationString()
|
||||||
{
|
{
|
||||||
StringBuilder b = new StringBuilder();
|
StringBuilder b = new StringBuilder();
|
||||||
|
|
||||||
|
|||||||
@@ -49,9 +49,8 @@ import net.runelite.client.ui.overlay.OverlayUtil;
|
|||||||
|
|
||||||
import static net.runelite.api.Perspective.getCanvasTilePoly;
|
import static net.runelite.api.Perspective.getCanvasTilePoly;
|
||||||
|
|
||||||
public class KourendLibraryOverlay extends Overlay
|
class KourendLibraryOverlay extends Overlay
|
||||||
{
|
{
|
||||||
private final static WorldPoint LIBRARY_CENTER = new WorldPoint(1632, 3807, 1);
|
|
||||||
private final static int MAXIMUM_DISTANCE = 24;
|
private final static int MAXIMUM_DISTANCE = 24;
|
||||||
|
|
||||||
private final Library library;
|
private final Library library;
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ import net.runelite.client.ui.PluginPanel;
|
|||||||
import net.runelite.client.util.SwingUtil;
|
import net.runelite.client.util.SwingUtil;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class KourendLibraryPanel extends PluginPanel
|
class KourendLibraryPanel extends PluginPanel
|
||||||
{
|
{
|
||||||
private static final ImageIcon RESET_ICON;
|
private static final ImageIcon RESET_ICON;
|
||||||
private static final ImageIcon RESET_CLICK_ICON;
|
private static final ImageIcon RESET_CLICK_ICON;
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ import static net.runelite.client.plugins.kourendlibrary.Book.*;
|
|||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class Library
|
class Library
|
||||||
{
|
{
|
||||||
private final Map<WorldPoint, Bookcase> byPoint = new HashMap<>();
|
private final Map<WorldPoint, Bookcase> byPoint = new HashMap<>();
|
||||||
private final Map<Integer, ArrayList<Bookcase>> byLevel = new HashMap<>();
|
private final Map<Integer, ArrayList<Bookcase>> byLevel = new HashMap<>();
|
||||||
@@ -83,23 +83,23 @@ public class Library
|
|||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized List<Bookcase> getBookcasesOnLevel(int z)
|
synchronized List<Bookcase> getBookcasesOnLevel(int z)
|
||||||
{
|
{
|
||||||
return Collections.unmodifiableList(byLevel.get(z));
|
return Collections.unmodifiableList(byLevel.get(z));
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized List<Bookcase> getBookcases()
|
synchronized List<Bookcase> getBookcases()
|
||||||
{
|
{
|
||||||
return Collections.unmodifiableList(byIndex);
|
return Collections.unmodifiableList(byIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCustomer(LibraryCustomer customer, Book book)
|
void setCustomer(LibraryCustomer customer, Book book)
|
||||||
{
|
{
|
||||||
this.customer = customer;
|
this.customer = customer;
|
||||||
this.customerBook = book;
|
this.customerBook = book;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void reset()
|
synchronized void reset()
|
||||||
{
|
{
|
||||||
state = SolvedState.NO_DATA;
|
state = SolvedState.NO_DATA;
|
||||||
for (Bookcase b : byIndex)
|
for (Bookcase b : byIndex)
|
||||||
@@ -110,7 +110,7 @@ public class Library
|
|||||||
log.info("Library is now reset");
|
log.info("Library is now reset");
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void mark(WorldPoint loc, Book book)
|
synchronized void mark(WorldPoint loc, Book book)
|
||||||
{
|
{
|
||||||
Bookcase bookcase = byPoint.get(loc);
|
Bookcase bookcase = byPoint.get(loc);
|
||||||
if (bookcase == null)
|
if (bookcase == null)
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import lombok.Getter;
|
|||||||
|
|
||||||
import net.runelite.api.NpcID;
|
import net.runelite.api.NpcID;
|
||||||
|
|
||||||
public enum LibraryCustomer
|
enum LibraryCustomer
|
||||||
{
|
{
|
||||||
VILLIA(NpcID.VILLIA, "Villia"),
|
VILLIA(NpcID.VILLIA, "Villia"),
|
||||||
PROFESSOR_GRACKLEBONE(NpcID.PROFESSOR_GRACKLEBONE, "Prof. Gracklebone"),
|
PROFESSOR_GRACKLEBONE(NpcID.PROFESSOR_GRACKLEBONE, "Prof. Gracklebone"),
|
||||||
@@ -50,7 +50,7 @@ public enum LibraryCustomer
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static LibraryCustomer getById(int id)
|
static LibraryCustomer getById(int id)
|
||||||
{
|
{
|
||||||
return byId.get(id);
|
return byId.get(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.kourendlibrary;
|
package net.runelite.client.plugins.kourendlibrary;
|
||||||
|
|
||||||
public enum SolvedState
|
enum SolvedState
|
||||||
{
|
{
|
||||||
NO_DATA,
|
NO_DATA,
|
||||||
INCOMPLETE,
|
INCOMPLETE,
|
||||||
|
|||||||
Reference in New Issue
Block a user