Skip to content

Commit

Permalink
2
Browse files Browse the repository at this point in the history
  • Loading branch information
MarbleTurtle committed Mar 1, 2020
1 parent 8512f3e commit 5e72484
Show file tree
Hide file tree
Showing 4 changed files with 151 additions and 46 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Expand Up @@ -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
Expand All @@ -26,7 +26,7 @@ dependencies {
}

group = 'com.highlight'
version = '0.4'
version = '0.5'
sourceCompatibility = '1.8'

tasks.withType(JavaCompile) {
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/highlight/HighlightConfig.java
Expand Up @@ -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;
}

}
136 changes: 107 additions & 29 deletions src/main/java/com/highlight/HighlightOverlay.java
Expand Up @@ -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;
}
}
}
}
Expand Down
47 changes: 32 additions & 15 deletions src/main/java/com/highlight/HighlightPlugin.java
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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, "");
}
}

Expand All @@ -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;
Expand Down

0 comments on commit 5e72484

Please sign in to comment.