From 5e724840edebf05a6a51c62d0efe9d93dbf665d7 Mon Sep 17 00:00:00 2001 From: MarbleTurtle <60723971+MarbleTurtle@users.noreply.github.com> Date: Sun, 1 Mar 2020 15:03:10 -0800 Subject: [PATCH] 2 --- build.gradle | 4 +- .../java/com/highlight/HighlightConfig.java | 10 ++ .../java/com/highlight/HighlightOverlay.java | 136 ++++++++++++++---- .../java/com/highlight/HighlightPlugin.java | 47 ++++-- 4 files changed, 151 insertions(+), 46 deletions(-) diff --git a/build.gradle b/build.gradle index e495d8c..a68f3c1 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ repositories { mavenCentral() } -def runeLiteVersion = '1.6.5' +def runeLiteVersion = '1.6.7' dependencies { compileOnly group: 'net.runelite', name:'client', version: runeLiteVersion @@ -26,7 +26,7 @@ dependencies { } group = 'com.highlight' -version = '0.4' +version = '0.5' sourceCompatibility = '1.8' tasks.withType(JavaCompile) { diff --git a/src/main/java/com/highlight/HighlightConfig.java b/src/main/java/com/highlight/HighlightConfig.java index 52d6d89..ec31d34 100644 --- a/src/main/java/com/highlight/HighlightConfig.java +++ b/src/main/java/com/highlight/HighlightConfig.java @@ -16,4 +16,14 @@ default boolean message() { return true; } + @ConfigItem( + keyName = "highlightClan", + name = "Highlight clan member", + description = "Attempts to highlight the clan member instead of the world, if it fails will default to world." + ) + default boolean clanFirst() + { + return true; + } + } diff --git a/src/main/java/com/highlight/HighlightOverlay.java b/src/main/java/com/highlight/HighlightOverlay.java index 145667b..5e398c7 100644 --- a/src/main/java/com/highlight/HighlightOverlay.java +++ b/src/main/java/com/highlight/HighlightOverlay.java @@ -21,54 +21,132 @@ class HighlightOverlay extends Overlay { private final HighlightPlugin plugin; private final Client client; private int hasScrolled; - + @Inject + private HighlightConfig config; @Inject private HighlightOverlay(HighlightPlugin plugin, Client client) { this.setPosition(OverlayPosition.DYNAMIC); this.setLayer(OverlayLayer.ABOVE_WIDGETS); this.plugin = plugin; this.client = client; + } public Dimension render(Graphics2D graphics) { - int world = this.plugin.getWorld(); - if (world==0) { - this.hasScrolled = 0; - return null; - } else { - Widget musicContainer = this.client.getWidget(WidgetInfo.WORLD_SWITCHER_LIST); - if (musicContainer != null && !musicContainer.isHidden()) { - Widget worldList = this.client.getWidget(WidgetInfo.WORLD_SWITCHER_LIST); - Widget found = null; - if (worldList == null) { + if(config.clanFirst()){ + if(this.plugin.getClan()){ + String player = this.plugin.getPlayer(); + if(player==""){ + this.hasScrolled=0; return null; } else { - Widget[] var8 = worldList.getDynamicChildren(); - int var9 = var8.length; - for(int var10 = 0; var10 < var9; ++var10) { - Widget track = var8[var10]; - if (track.getName().contains(""+world)) { - found = track; - break; + Widget clanContainer = this.client.getWidget(WidgetInfo.CLAN_CHAT_LIST); + if(clanContainer!=null&&!clanContainer.isHidden()){ + Widget found = null; + Widget[] var8 = clanContainer.getDynamicChildren(); + int var9 = var8.length; + for (int var10 = 0; var10 < var9; ++var10) { + Widget clany = var8[var10]; + if (clany.getText().contains(player)) { + found = clany; + break; + } } - } - - if (found == null) { + if(found==null){ + return null; + }else{ + if (this.hasScrolled != found.getRelativeY()) { + this.hasScrolled = found.getRelativeY(); + this.plugin.scrollToWidget(this.client.getWidget(WidgetInfo.CLAN_CHAT_LIST), this.client.getWidget(7, 17), new Widget[]{found}); + } + this.plugin.highlightWidget(graphics, found, this.client.getWidget(WidgetInfo.CLAN_CHAT_LIST), PADDING, (String) null); + return null; + } + }else if (hasScrolled != 0) { + hasScrolled = 0; + this.plugin.resetPlayer(); return null; } else { - if (this.hasScrolled!=world) { - this.hasScrolled = world; - this.plugin.scrollToWidget(this.client.getWidget(69,15), this.client.getWidget(69,18), new Widget[]{found}); + return null; + } + } + }else{ + int world = this.plugin.getWorld(); + if (world == 0) { + this.hasScrolled = 0; + return null; + } else { + Widget worldContainer = this.client.getWidget(WidgetInfo.WORLD_SWITCHER_LIST); + if (worldContainer != null && !worldContainer.isHidden()) { + Widget found = null; + Widget[] var8 = worldContainer.getDynamicChildren(); + int var9 = var8.length; + for (int var10 = 0; var10 < var9; ++var10) { + Widget track = var8[var10]; + if (track.getName().contains("" + world)) { + found = track; + break; + } + } + if (found == null) { + return null; + } else { + if (this.hasScrolled != world) { + this.hasScrolled = world; + this.plugin.scrollToWidget(this.client.getWidget(69, 15), this.client.getWidget(69, 18), new Widget[]{found}); + } + this.plugin.highlightWidget(graphics, found, this.client.getWidget(69, 15), PADDING, (String) null); + return null; } - this.plugin.highlightWidget(graphics, found, this.client.getWidget(69,15), PADDING, (String)null); + } else if (hasScrolled != 0) { + hasScrolled = 0; + this.plugin.resetWorld(); + return null; + } else { return null; } } - } else if(hasScrolled!=0){ - hasScrolled=0; - this.plugin.resetWorld(); + } + } else { + int world = this.plugin.getWorld(); + if (world == 0) { + this.hasScrolled = 0; return null; } else { - return null; + Widget worldContainer = this.client.getWidget(WidgetInfo.WORLD_SWITCHER_LIST); + if (worldContainer != null && !worldContainer.isHidden()) { + Widget worldList = this.client.getWidget(WidgetInfo.WORLD_SWITCHER_LIST); + Widget found = null; + if (worldList == null) { + return null; + } else { + Widget[] var8 = worldList.getDynamicChildren(); + int var9 = var8.length; + for (int var10 = 0; var10 < var9; ++var10) { + Widget track = var8[var10]; + if (track.getName().contains("" + world)) { + found = track; + break; + } + } + + if (found == null) { + return null; + } else { + if (this.hasScrolled != world) { + this.hasScrolled = world; + this.plugin.scrollToWidget(this.client.getWidget(69, 15), this.client.getWidget(69, 18), new Widget[]{found}); + } + this.plugin.highlightWidget(graphics, found, this.client.getWidget(69, 15), PADDING, (String) null); + return null; + } + } + } else if (hasScrolled != 0) { + hasScrolled = 0; + this.plugin.resetWorld(); + return null; + } else { + return null; + } } } } diff --git a/src/main/java/com/highlight/HighlightPlugin.java b/src/main/java/com/highlight/HighlightPlugin.java index b4e5201..fec9be0 100644 --- a/src/main/java/com/highlight/HighlightPlugin.java +++ b/src/main/java/com/highlight/HighlightPlugin.java @@ -37,7 +37,8 @@ public class HighlightPlugin extends Plugin private static final Color HIGHLIGHT_HOVER_BORDER_COLOR; private static final Color HIGHLIGHT_FILL_COLOR; private int world; - private boolean open; + private String player; + private boolean clan; @Inject private Client client; @Inject @@ -91,30 +92,38 @@ private void insertMenuEntry(MenuEntry newEntry, MenuEntry[] entries) { } private void highlight(String playerName) { - boolean clan = false; + clan = false; if(this.client.getClanMemberManager()!=null) { - for (int c = 0; c != this.client.getClanMemberManager().getMembers().length; c++) { - if (this.client.getClanMemberManager().getMembers()[c].getName().equals(playerName)) { - clan = true; - world = this.client.getClanMemberManager().getMembers()[c].getWorld(); - break; + for (int c = 0; c != this.client.getClanMemberManager().getMembers().length; c++) { + if (this.client.getClanMemberManager().getMembers()[c].getName().equals(playerName)) { + clan = true; + player = Text.toJagexName(this.client.getClanMemberManager().getMembers()[c].getName()); + world = this.client.getClanMemberManager().getMembers()[c].getWorld(); + if(world==this.client.getWorld()){ + sendNotification(2); + this.resetWorld(); + }else { + sendNotification(4); + } + break; + } } } - } if(!clan){ for(int f=0; f!=this.client.getFriendContainer().getCount();f++){ if(this.client.getFriendContainer().getMembers()[f].getName().equals(playerName)){ world=this.client.getFriendContainer().getMembers()[f].getWorld(); + if(world==this.client.getWorld()){ + sendNotification(2); + this.resetWorld(); + }else{ + sendNotification(1); + } } } } - if(world==this.client.getWorld()){ - sendNotification(2); - this.resetWorld(); - }else if(world==0){ + if(world==0){ sendNotification(3); - }else{ - sendNotification(1); } } @@ -175,10 +184,14 @@ private void sendNotification(int type) { stringBuilder.append("Player is on your world."); String notification = stringBuilder.toString(); this.client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", notification, ""); - }else{ + }else if(type==3){ stringBuilder.append("Unable to find world, player is neither in clan chat nor on friends list."); String notification = stringBuilder.toString(); this.client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", notification, ""); + }else{ + stringBuilder.append("Highlighting "+player+" in clan chat."); + String notification = stringBuilder.toString(); + this.client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", notification, ""); } } @@ -190,6 +203,10 @@ HighlightConfig provideConfig(ConfigManager configManager) public int getWorld() {return this.world;} public void resetWorld() {this.world=0;} + public String getPlayer() {return this.player;} + public void resetPlayer() {this.player="";} + public boolean getClan() {return this.clan;} + public void resetClan() {this.clan=false;} static { HIGHLIGHT_BORDER_COLOR = Color.ORANGE;