Fix style errors
This commit is contained in:
@@ -33,7 +33,9 @@ import javax.inject.Inject;
|
||||
import net.runelite.api.*;
|
||||
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
|
||||
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
|
||||
|
||||
import net.runelite.client.ui.overlay.OverlayMenuEntry;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||
@@ -42,133 +44,155 @@ import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||
|
||||
public class RaidsPartyOverlay extends Overlay
|
||||
{
|
||||
public static final String PARTY_OVERLAY_RESET = "Reset missing";
|
||||
public static final String PARTY_OVERLAY_REFRESH = "Refresh party";
|
||||
public static final String PARTY_OVERLAY_RESET = "Reset missing";
|
||||
public static final String PARTY_OVERLAY_REFRESH = "Refresh party";
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private RaidsPlugin plugin;
|
||||
@Inject
|
||||
private RaidsPlugin plugin;
|
||||
|
||||
private final PanelComponent panel = new PanelComponent();
|
||||
private final PanelComponent panel = new PanelComponent();
|
||||
|
||||
@Inject
|
||||
private RaidsPartyOverlay(RaidsPlugin plugin)
|
||||
{
|
||||
super(plugin);
|
||||
setPosition(OverlayPosition.TOP_RIGHT);
|
||||
setPriority(OverlayPriority.HIGH);
|
||||
getMenuEntries().add(new OverlayMenuEntry(MenuAction.RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Raids party overlay"));
|
||||
getMenuEntries().add(new OverlayMenuEntry(MenuAction.RUNELITE_OVERLAY, PARTY_OVERLAY_RESET, "Raids party overlay"));
|
||||
getMenuEntries().add(new OverlayMenuEntry(MenuAction.RUNELITE_OVERLAY, PARTY_OVERLAY_REFRESH, "Raids party overlay"));
|
||||
}
|
||||
@Inject
|
||||
private RaidsPartyOverlay(RaidsPlugin plugin)
|
||||
{
|
||||
super(plugin);
|
||||
setPosition(OverlayPosition.TOP_RIGHT);
|
||||
setPriority(OverlayPriority.HIGH);
|
||||
getMenuEntries().add(new OverlayMenuEntry(MenuAction.RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Raids party overlay"));
|
||||
getMenuEntries().add(new OverlayMenuEntry(MenuAction.RUNELITE_OVERLAY, PARTY_OVERLAY_RESET, "Raids party overlay"));
|
||||
getMenuEntries().add(new OverlayMenuEntry(MenuAction.RUNELITE_OVERLAY, PARTY_OVERLAY_REFRESH, "Raids party overlay"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (!plugin.isInRaidChambers())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (!plugin.isInRaidChambers())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (client.getClanChatCount() == 0) {
|
||||
// Player left clan chat
|
||||
return null;
|
||||
}
|
||||
if (client.getClanChatCount() == 0)
|
||||
{
|
||||
// Player left clan chat
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean inLobby = client.getVar(VarPlayer.IN_RAID_PARTY) != -1; // -1 if raid started
|
||||
boolean inLobby = client.getVar(VarPlayer.IN_RAID_PARTY) != -1; // -1 if raid started
|
||||
|
||||
int partySize = client.getVar(Varbits.RAID_PARTY_SIZE);
|
||||
int partySize = client.getVar(Varbits.RAID_PARTY_SIZE);
|
||||
|
||||
int playerCount = client.getPlayers().size();
|
||||
int playerCount = client.getPlayers().size();
|
||||
|
||||
String partyCountString;
|
||||
String partyCountString;
|
||||
|
||||
Color countColor = Color.WHITE;
|
||||
if (inLobby) {
|
||||
partyCountString = String.format("%d/%d", playerCount, partySize);
|
||||
// While we are in the lobby compare to players visible on the screen
|
||||
if (partySize <= playerCount) {
|
||||
countColor = Color.GREEN;
|
||||
} else {
|
||||
countColor = Color.RED;
|
||||
}
|
||||
} else {
|
||||
// If raid has started then we compare the current party size to what it was when we started
|
||||
partyCountString = String.format("%d/%d", partySize, plugin.getStartPlayerCount());
|
||||
if (plugin.getMissingPartyMembers().size() > 0) {
|
||||
countColor = Color.RED; // Somebody is missing
|
||||
}
|
||||
}
|
||||
Color countColor = Color.WHITE;
|
||||
if (inLobby)
|
||||
{
|
||||
partyCountString = String.format("%d/%d", playerCount, partySize);
|
||||
// While we are in the lobby compare to players visible on the screen
|
||||
if (partySize <= playerCount)
|
||||
{
|
||||
countColor = Color.GREEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
countColor = Color.RED;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If raid has started then we compare the current party size to what it was when we started
|
||||
partyCountString = String.format("%d/%d", partySize, plugin.getStartPlayerCount());
|
||||
if (plugin.getMissingPartyMembers().size() > 0)
|
||||
{
|
||||
countColor = Color.RED; // Somebody is missing
|
||||
}
|
||||
}
|
||||
|
||||
panel.getChildren().clear();
|
||||
panel.getChildren().clear();
|
||||
|
||||
// Show amount of people currently in raid vs total in the party
|
||||
panel.getChildren().add(LineComponent.builder()
|
||||
.left("Party size:")
|
||||
.right(partyCountString)
|
||||
.rightColor(countColor)
|
||||
.build());
|
||||
// Show amount of people currently in raid vs total in the party
|
||||
panel.getChildren().add(LineComponent.builder()
|
||||
.left("Party size:")
|
||||
.right(partyCountString)
|
||||
.rightColor(countColor)
|
||||
.build());
|
||||
|
||||
if (inLobby) {
|
||||
int world = client.getWorld();
|
||||
int wrongWorldClanMembers = 0;
|
||||
int clanMemberCount = 0;
|
||||
for (ClanMember clanMember : client.getClanMembers()) {
|
||||
if (clanMember != null) {
|
||||
if (clanMember.getWorld() != world) {
|
||||
wrongWorldClanMembers++;
|
||||
} else {
|
||||
clanMemberCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (inLobby)
|
||||
{
|
||||
int world = client.getWorld();
|
||||
int wrongWorldClanMembers = 0;
|
||||
int clanMemberCount = 0;
|
||||
for (ClanMember clanMember : client.getClanMembers())
|
||||
{
|
||||
if (clanMember != null)
|
||||
{
|
||||
if (clanMember.getWorld() != world)
|
||||
{
|
||||
wrongWorldClanMembers++;
|
||||
}
|
||||
else
|
||||
{
|
||||
clanMemberCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Show amount of people on the right world but not at the raids area
|
||||
Color notInPartyColor = Color.GREEN;
|
||||
int notInParty = clanMemberCount - partySize;
|
||||
// Show amount of people on the right world but not at the raids area
|
||||
Color notInPartyColor = Color.GREEN;
|
||||
int notInParty = clanMemberCount - partySize;
|
||||
|
||||
if (notInParty > 0) {
|
||||
notInPartyColor = Color.WHITE;
|
||||
}
|
||||
if (notInParty > 0)
|
||||
{
|
||||
notInPartyColor = Color.WHITE;
|
||||
}
|
||||
|
||||
panel.getChildren().add(LineComponent.builder()
|
||||
.left("Not at raids:")
|
||||
.right(String.valueOf(notInParty))
|
||||
.rightColor(notInPartyColor)
|
||||
.build());
|
||||
panel.getChildren().add(LineComponent.builder()
|
||||
.left("Not at raids:")
|
||||
.right(String.valueOf(notInParty))
|
||||
.rightColor(notInPartyColor)
|
||||
.build());
|
||||
|
||||
// Show amount of clan members that are not in the right world.
|
||||
Color wrongWorldColor;
|
||||
if (wrongWorldClanMembers == 0) {
|
||||
wrongWorldColor = Color.GREEN;
|
||||
} else {
|
||||
wrongWorldColor = Color.WHITE;
|
||||
}
|
||||
// Show amount of clan members that are not in the right world.
|
||||
Color wrongWorldColor;
|
||||
if (wrongWorldClanMembers == 0)
|
||||
{
|
||||
wrongWorldColor = Color.GREEN;
|
||||
}
|
||||
else
|
||||
{
|
||||
wrongWorldColor = Color.WHITE;
|
||||
}
|
||||
|
||||
panel.getChildren().add(LineComponent.builder()
|
||||
.left("Wrong world:")
|
||||
.right(String.valueOf(wrongWorldClanMembers))
|
||||
.rightColor(wrongWorldColor)
|
||||
.build());
|
||||
panel.getChildren().add(LineComponent.builder()
|
||||
.left("Wrong world:")
|
||||
.right(String.valueOf(wrongWorldClanMembers))
|
||||
.rightColor(wrongWorldColor)
|
||||
.build());
|
||||
|
||||
} else {
|
||||
Set<String> missingPartyMembers = plugin.getMissingPartyMembers();
|
||||
if (missingPartyMembers.size() > 0) {
|
||||
panel.getChildren().add(LineComponent.builder()
|
||||
.left("Missing players:")
|
||||
.build());
|
||||
}
|
||||
else
|
||||
{
|
||||
Set<String> missingPartyMembers = plugin.getMissingPartyMembers();
|
||||
if (missingPartyMembers.size() > 0)
|
||||
{
|
||||
panel.getChildren().add(LineComponent.builder()
|
||||
.left("Missing players:")
|
||||
.build());
|
||||
|
||||
for (String member : missingPartyMembers) {
|
||||
panel.getChildren().add(LineComponent.builder()
|
||||
.left(member)
|
||||
.leftColor(Color.RED)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (String member : missingPartyMembers)
|
||||
{
|
||||
panel.getChildren().add(LineComponent.builder()
|
||||
.left(member)
|
||||
.leftColor(Color.RED)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return panel.render(graphics);
|
||||
}
|
||||
return panel.render(graphics);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,12 +27,14 @@ package net.runelite.client.plugins.raids;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.inject.Binder;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.*;
|
||||
@@ -63,9 +65,9 @@ import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
import net.runelite.client.util.Text;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Chambers Of Xeric",
|
||||
description = "Show helpful information for the Chambers of Xeric raid",
|
||||
tags = {"combat", "raid", "overlay", "pve", "pvm", "bosses"}
|
||||
name = "Chambers Of Xeric",
|
||||
description = "Show helpful information for the Chambers of Xeric raid",
|
||||
tags = {"combat", "raid", "overlay", "pve", "pvm", "bosses"}
|
||||
)
|
||||
@Slf4j
|
||||
public class RaidsPlugin extends Plugin
|
||||
@@ -157,7 +159,8 @@ public class RaidsPlugin extends Plugin
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
overlayManager.add(overlay);
|
||||
if (config.partyDisplay()) {
|
||||
if (config.partyDisplay())
|
||||
{
|
||||
overlayManager.add(partyOverlay);
|
||||
}
|
||||
updateLists();
|
||||
@@ -168,7 +171,8 @@ public class RaidsPlugin extends Plugin
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
overlayManager.remove(overlay);
|
||||
if (config.partyDisplay()) {
|
||||
if (config.partyDisplay())
|
||||
{
|
||||
overlayManager.remove(partyOverlay);
|
||||
}
|
||||
infoBoxManager.removeInfoBox(timer);
|
||||
@@ -191,10 +195,14 @@ public class RaidsPlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getKey().equals("partyDisplay")) {
|
||||
if (config.partyDisplay()) {
|
||||
if (event.getKey().equals("partyDisplay"))
|
||||
{
|
||||
if (config.partyDisplay())
|
||||
{
|
||||
overlayManager.add(partyOverlay);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
overlayManager.remove(partyOverlay);
|
||||
}
|
||||
}
|
||||
@@ -207,7 +215,8 @@ public class RaidsPlugin extends Plugin
|
||||
public void onVarbitChanged(VarbitChanged event)
|
||||
{
|
||||
checkRaidPresence(false);
|
||||
if (config.partyDisplay()) {
|
||||
if (config.partyDisplay())
|
||||
{
|
||||
updatePartyMembers(false);
|
||||
}
|
||||
}
|
||||
@@ -221,22 +230,24 @@ public class RaidsPlugin extends Plugin
|
||||
|
||||
if (message.startsWith(RAID_START_MESSAGE))
|
||||
{
|
||||
if (config.raidsTimer()) {
|
||||
if (config.raidsTimer())
|
||||
{
|
||||
timer = new RaidsTimer(spriteManager.getSprite(TAB_QUESTS_BROWN_RAIDING_PARTY, 0), this, Instant.now());
|
||||
infoBoxManager.addInfoBox(timer);
|
||||
}
|
||||
if (config.partyDisplay()) {
|
||||
// Base this on visible players since party size shows people outside the lobby
|
||||
// and they did not get to come on the raid
|
||||
List<Player> players = client.getPlayers();
|
||||
startPlayerCount = players.size();
|
||||
if (config.partyDisplay())
|
||||
{
|
||||
// Base this on visible players since party size shows people outside the lobby
|
||||
// and they did not get to come on the raid
|
||||
List<Player> players = client.getPlayers();
|
||||
startPlayerCount = players.size();
|
||||
|
||||
partyMembers.clear();
|
||||
startingPartyMembers.clear();
|
||||
missingPartyMembers.clear();
|
||||
partyMembers.clear();
|
||||
startingPartyMembers.clear();
|
||||
missingPartyMembers.clear();
|
||||
|
||||
startingPartyMembers.addAll(Lists.transform(players, Player::getName));
|
||||
partyMembers.addAll(startingPartyMembers);
|
||||
startingPartyMembers.addAll(Lists.transform(players, Player::getName));
|
||||
partyMembers.addAll(startingPartyMembers);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,26 +272,26 @@ public class RaidsPlugin extends Plugin
|
||||
double percentage = personalPoints / (totalPoints / 100.0);
|
||||
|
||||
String chatMessage = new ChatMessageBuilder()
|
||||
.append(ChatColorType.NORMAL)
|
||||
.append("Total points: ")
|
||||
.append(ChatColorType.HIGHLIGHT)
|
||||
.append(POINTS_FORMAT.format(totalPoints))
|
||||
.append(ChatColorType.NORMAL)
|
||||
.append(", Personal points: ")
|
||||
.append(ChatColorType.HIGHLIGHT)
|
||||
.append(POINTS_FORMAT.format(personalPoints))
|
||||
.append(ChatColorType.NORMAL)
|
||||
.append(" (")
|
||||
.append(ChatColorType.HIGHLIGHT)
|
||||
.append(DECIMAL_FORMAT.format(percentage))
|
||||
.append(ChatColorType.NORMAL)
|
||||
.append("%)")
|
||||
.build();
|
||||
.append(ChatColorType.NORMAL)
|
||||
.append("Total points: ")
|
||||
.append(ChatColorType.HIGHLIGHT)
|
||||
.append(POINTS_FORMAT.format(totalPoints))
|
||||
.append(ChatColorType.NORMAL)
|
||||
.append(", Personal points: ")
|
||||
.append(ChatColorType.HIGHLIGHT)
|
||||
.append(POINTS_FORMAT.format(personalPoints))
|
||||
.append(ChatColorType.NORMAL)
|
||||
.append(" (")
|
||||
.append(ChatColorType.HIGHLIGHT)
|
||||
.append(DECIMAL_FORMAT.format(percentage))
|
||||
.append(ChatColorType.NORMAL)
|
||||
.append("%)")
|
||||
.build();
|
||||
|
||||
chatMessageManager.queue(QueuedMessage.builder()
|
||||
.type(ChatMessageType.CLANCHAT_INFO)
|
||||
.runeLiteFormattedMessage(chatMessage)
|
||||
.build());
|
||||
.type(ChatMessageType.CLANCHAT_INFO)
|
||||
.runeLiteFormattedMessage(chatMessage)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -293,48 +304,59 @@ public class RaidsPlugin extends Plugin
|
||||
if (entry.getMenuAction() == MenuAction.RUNELITE_OVERLAY &&
|
||||
entry.getTarget().equals("Raids party overlay"))
|
||||
{
|
||||
switch (entry.getOption()) {
|
||||
switch (entry.getOption())
|
||||
{
|
||||
case RaidsPartyOverlay.PARTY_OVERLAY_RESET:
|
||||
startingPartyMembers.clear();
|
||||
startingPartyMembers.clear();
|
||||
updatePartyMembers(true);
|
||||
missingPartyMembers.clear();
|
||||
break;
|
||||
case RaidsPartyOverlay.PARTY_OVERLAY_REFRESH:
|
||||
updatePartyMembers(true);
|
||||
missingPartyMembers.clear();
|
||||
break;
|
||||
case RaidsPartyOverlay.PARTY_OVERLAY_REFRESH:
|
||||
updatePartyMembers(true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updatePartyMembers(boolean force) {
|
||||
private void updatePartyMembers(boolean force)
|
||||
{
|
||||
int partySize = client.getVar(Varbits.RAID_PARTY_SIZE);
|
||||
if (partySize <= 0) {
|
||||
if (partySize <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (startingPartyMembers.size() == partySize && !force) {
|
||||
if (startingPartyMembers.size() == partySize && !force)
|
||||
{
|
||||
// Skip update if the part is as big as when we started
|
||||
missingPartyMembers.clear(); // Clear missing members in case someone came back
|
||||
missingPartyMembers.clear(); // Clear missing members in case someone came back
|
||||
return;
|
||||
}
|
||||
|
||||
// Only update while in raid
|
||||
if (client.getVar(VarPlayer.IN_RAID_PARTY) == -1 || force) {
|
||||
if (client.getVar(VarPlayer.IN_RAID_PARTY) == -1 || force)
|
||||
{
|
||||
Widget[] widgets;
|
||||
try {
|
||||
try
|
||||
{
|
||||
widgets = client.getWidget(WidgetInfo.RAIDING_PARTY).getStaticChildren()[2].getStaticChildren()[3].getDynamicChildren();
|
||||
} catch (NullPointerException e) {
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
return; // Raid widget not loaded
|
||||
}
|
||||
|
||||
partyMembers.clear();
|
||||
for (int i = 0; i < widgets.length; i++) {
|
||||
if (widgets[i] != null) {
|
||||
for (int i = 0; i < widgets.length; i++)
|
||||
{
|
||||
if (widgets[i] != null)
|
||||
{
|
||||
// Party members names can be found as a color tagged string in every fourth(ish) of these children
|
||||
String name = widgets[i].getName();
|
||||
if (name.length() > 1) {
|
||||
if (name.length() > 1)
|
||||
{
|
||||
// Clean away tag
|
||||
partyMembers.add(name.substring(name.indexOf('>') + 1, name.indexOf('<', 1)));
|
||||
}
|
||||
@@ -342,14 +364,18 @@ public class RaidsPlugin extends Plugin
|
||||
}
|
||||
|
||||
// If we don't have any starting members, update starting members
|
||||
if (startingPartyMembers.size() == 0 || force) {
|
||||
if (startingPartyMembers.size() == 0 || force)
|
||||
{
|
||||
missingPartyMembers.clear();
|
||||
startingPartyMembers.clear();
|
||||
startingPartyMembers.addAll(partyMembers);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Check if anyone left
|
||||
if (startingPartyMembers.size() > partyMembers.size()) {
|
||||
if (startingPartyMembers.size() > partyMembers.size())
|
||||
{
|
||||
missingPartyMembers.clear();
|
||||
missingPartyMembers.addAll(startingPartyMembers);
|
||||
missingPartyMembers.removeAll(partyMembers);
|
||||
@@ -420,14 +446,14 @@ public class RaidsPlugin extends Plugin
|
||||
final String raidData = "[" + layout + "]: " + rooms;
|
||||
|
||||
chatMessageManager.queue(QueuedMessage.builder()
|
||||
.type(ChatMessageType.CLANCHAT_INFO)
|
||||
.runeLiteFormattedMessage(new ChatMessageBuilder()
|
||||
.append(ChatColorType.HIGHLIGHT)
|
||||
.append("Layout: ")
|
||||
.append(ChatColorType.NORMAL)
|
||||
.append(raidData)
|
||||
.build())
|
||||
.build());
|
||||
.type(ChatMessageType.CLANCHAT_INFO)
|
||||
.runeLiteFormattedMessage(new ChatMessageBuilder()
|
||||
.append(ChatColorType.HIGHLIGHT)
|
||||
.append("Layout: ")
|
||||
.append(ChatColorType.NORMAL)
|
||||
.append(raidData)
|
||||
.build())
|
||||
.build());
|
||||
}
|
||||
|
||||
private void updateInfoBoxState()
|
||||
|
||||
Reference in New Issue
Block a user