Skip to content

Support for Lightbearer and reorder preaches when new preaches happen#2

Open
levex wants to merge 1 commit into
InfernoStats:masterfrom
levex:lightbearer-support
Open

Support for Lightbearer and reorder preaches when new preaches happen#2
levex wants to merge 1 commit into
InfernoStats:masterfrom
levex:lightbearer-support

Conversation

@levex

@levex levex commented Apr 30, 2025

Copy link
Copy Markdown
  • Display the tick a player in the party has equipped their lightbearer.
  • Displays players preaching with a ring with a yellow hue.
  • Reorder preaches when new preaches happen so that the lowest preach is always at the bottom.

fix typo

remove unneeded changes

fix bugs

import net.runelite.client.party.messages.PartyMessage;

public class RingChangeMessage extends PartyMessage {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use Lombok's @AllArgsConstructor to remove your own and give these fields descriptive names. Then, annotate them with @SerializedName to shrink the serialized size of the party message.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file should not be modified.

position = 4,
hidden = true,
keyName = "hornAnimId",
name = "[WIP] Extra Animation Id",

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't PR things that are still a work in progress

HashMap<String, Preach> players = plugin.getPlayers();

panelComponent.getChildren().clear();

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not something you changed, but since we're going to update this: panelComponent.setPreferredSize(new Dimension(getMaxWidth(graphics, players, title) + 10, 0)); should probably be like +12 or +14. It's at the point where it's close enough that the font size will occasionally mess up the formatting of the name.

Comment on lines +112 to +117
Item item;
try {
item = client.getItemContainer(InventoryID.EQUIPMENT).getItem(EquipmentInventorySlot.RING.getSlotIdx());
} catch (NullPointerException _e) {
item = null;
}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make a function for this, it's done more than once

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would also prefer checking for nulls instead of try-catching NPEs

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

InventoryID is also deprecated, use the GameVal form of it

}

private int startTick() {
return config.backwardsCount() ? 150 : 0;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

150 should not be hardcoded here, it should be a config option

@@ -0,0 +1,25 @@
package com.infernostats;

public class Preach implements Comparable<Preach> {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs @AllArgsDataConstructor, set all properties to private, and add @Getter as well


// Check if the localPlayer equipped a Lightbearer
if (config.lightbearerSupport() && players.containsKey(client.getLocalPlayer().getName())) {
Preach localPreach = players.get(client.getLocalPlayer().getName());

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

client.getLocalPlayer().getName() can throw an error, do appropriate handling above this branch

panelComponent.getChildren().add(LineComponent.builder()
.leftColor(preach.preachedWithRing ? Color.YELLOW : Color.WHITE)
.left(playerName)
.right(Integer.toString(preach.tick) + (!preach.preachedWithRing && preach.ringTick != 0 ? " (" + Integer.toString(preach.ringTick) + ")" : ""))

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract the logic in the right hand side of this out of the builder

{
String longestKey = Collections.max(players.keySet(), Comparator.comparingInt(String::length));
return graphics.getFontMetrics().stringWidth(longestKey) + graphics.getFontMetrics().stringWidth(title);
return graphics.getFontMetrics().stringWidth(longestKey) + graphics.getFontMetrics().stringWidth(title) + graphics.getFontMetrics().stringWidth("(157)");

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Format this line so it's not as long

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants