Support for Lightbearer and reorder preaches when new preaches happen#2
Support for Lightbearer and reorder preaches when new preaches happen#2levex wants to merge 1 commit into
Conversation
levex
commented
Apr 30, 2025
- 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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
This file should not be modified.
| position = 4, | ||
| hidden = true, | ||
| keyName = "hornAnimId", | ||
| name = "[WIP] Extra Animation Id", |
There was a problem hiding this comment.
Don't PR things that are still a work in progress
| HashMap<String, Preach> players = plugin.getPlayers(); | ||
|
|
||
| panelComponent.getChildren().clear(); | ||
|
|
There was a problem hiding this comment.
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.
| Item item; | ||
| try { | ||
| item = client.getItemContainer(InventoryID.EQUIPMENT).getItem(EquipmentInventorySlot.RING.getSlotIdx()); | ||
| } catch (NullPointerException _e) { | ||
| item = null; | ||
| } |
There was a problem hiding this comment.
Make a function for this, it's done more than once
There was a problem hiding this comment.
I would also prefer checking for nulls instead of try-catching NPEs
There was a problem hiding this comment.
InventoryID is also deprecated, use the GameVal form of it
| } | ||
|
|
||
| private int startTick() { | ||
| return config.backwardsCount() ? 150 : 0; |
There was a problem hiding this comment.
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> { | |||
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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) + ")" : "")) |
There was a problem hiding this comment.
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)"); |
There was a problem hiding this comment.
Format this line so it's not as long