Updating raids plugin with lyzrds dc scouter, and adding pts/hr.

This commit is contained in:
Ganom
2019-04-26 23:01:31 -04:00
parent 7dd4662977
commit 15ac022e59
5 changed files with 207 additions and 5 deletions

View File

@@ -178,6 +178,16 @@ public interface RaidsConfig extends Config
return false;
}
@ConfigItem(
position = 1,
keyName = "ptsHr",
name = "Enable points per hour message",
description = "Enable the message"
)
default boolean ptsHr()
{
return true;
}
@ConfigItem(
position = 16,
keyName = "showRecommendedItems",

View File

@@ -0,0 +1,124 @@
/*
* Copyright (c) 2018, Lyzrds
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.raids;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.lang.reflect.Method;
import javax.inject.Inject;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.ui.ColorScheme;
import net.runelite.client.ui.PluginPanel;
public class RaidsPanel extends PluginPanel
{
@Inject
private Client client;
@Inject
private RaidsPlugin raidsPlugin;
@Inject
private ClientThread clientThread;
private JButton reloadButton = new JButton("Reload Instance");
private JButton reloadScouter = new JButton("Reload Raid Overlay");
private JLabel reloadMessage = new JLabel("<html><center><h3>Instance Reload Helper </h3>Reloading an instance will cause your client to disconnect temporarily.<br></center></html>");
void init(RaidsConfig config)
{
// this may or may not qualify as a hack
// but this lets the editor pane expand to fill the whole parent panel
getParent().setLayout(new FlowLayout());
getParent().add(this, BorderLayout.CENTER);
setLayout(new BorderLayout());
setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
setBackground(ColorScheme.DARK_GRAY_COLOR);
JPanel reloadContainer = new JPanel();
JPanel scouterContainer = new JPanel();
JPanel buttons = new JPanel();
reloadContainer.setLayout(new BorderLayout());
buttons.setLayout(new BorderLayout());
buttons.setBackground(ColorScheme.DARKER_GRAY_COLOR);
reloadContainer.setBackground(ColorScheme.DARKER_GRAY_COLOR);
scouterContainer.setLayout(new BorderLayout());
scouterContainer.setBackground(ColorScheme.DARKER_GRAY_COLOR);
JPanel reloadFrame = new JPanel();
JPanel scoutFrame = new JPanel();
reloadButton.addActionListener((ActionEvent e) ->
{
if ((client.getGameState() == GameState.LOGGED_IN))
{
try
{
//look for client.gameStateChanged(-1); in src files to find
Method m = client.getClass().getClassLoader().loadClass("jr").getDeclaredMethod("fn", int.class, int.class);
m.setAccessible(true);
m.invoke(null, 40, -1893789506);
//Method m = client.getClass().getClassLoader().loadClass("jr").getDeclaredMethod("fn", int.class, int.class);
//m.setAccessible(true);
//m.invoke(null, 40, -1893789506);
//TODO: Since this is mainly for raids i'd like to reload the raids scouting plugin after the dc is finished
}
catch (ReflectiveOperationException f)
{
throw new RuntimeException(f);
}
}
else
{
//TODO: User is still in a dc, or not logged in. Possibly provide a meaningful message somewhere.
}
});
reloadScouter.addActionListener((ActionEvent e) ->
{
if ((client.getGameState() == GameState.LOGGED_IN))
{
raidsPlugin.checkRaidPresence(true);
}
});
reloadFrame.add(reloadButton);
scoutFrame.add(reloadScouter);
reloadContainer.add(reloadFrame, BorderLayout.NORTH);
reloadContainer.add(scoutFrame, BorderLayout.SOUTH);
add(reloadMessage, BorderLayout.PAGE_START);
add(reloadContainer, BorderLayout.CENTER);
}
}

View File

@@ -79,13 +79,16 @@ import net.runelite.client.plugins.PluginType;
import net.runelite.client.plugins.raids.solver.Layout;
import net.runelite.client.plugins.raids.solver.LayoutSolver;
import net.runelite.client.plugins.raids.solver.RotationSolver;
import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.DrawManager;
import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.ui.overlay.WidgetOverlay;
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
import net.runelite.client.ui.overlay.tooltip.Tooltip;
import net.runelite.client.ui.overlay.tooltip.TooltipManager;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.Text;
import net.runelite.client.util.HotkeyListener;
import org.apache.commons.lang3.StringUtils;
@@ -174,12 +177,17 @@ public class RaidsPlugin extends Plugin
@Getter
private boolean inRaidChambers;
@Inject
private ClientToolbar clientToolbar;
private RaidsPanel panel;
private int upperTime = -1;
private int middleTime = -1;
private int lowerTime = -1;
private int raidTime = -1;
private WidgetOverlay widgetOverlay;
private String tooltip;
public boolean canShow;
private NavigationButton navButton;
@Provides
RaidsConfig provideConfig(ConfigManager configManager)
@@ -201,6 +209,16 @@ public class RaidsPlugin extends Plugin
updateLists();
clientThread.invokeLater(() -> checkRaidPresence(true));
widgetOverlay = overlayManager.getWidgetOverlay(WidgetInfo.RAIDS_POINTS_INFOBOX);
panel = injector.getInstance(RaidsPanel.class);
panel.init(config);
final BufferedImage icon = ImageUtil.getResourceStreamFromClass(this.getClass(), "instancereloadhelper.png");
navButton = NavigationButton.builder()
.tooltip("Raids Reload")
.icon(icon)
.priority(8)
.panel(panel)
.build();
clientToolbar.addNavigation(navButton);
}
@Override
@@ -208,6 +226,7 @@ public class RaidsPlugin extends Plugin
{
overlayManager.remove(overlay);
overlayManager.remove(pointsOverlay);
clientToolbar.removeNavigation(navButton);
inRaidChambers = false;
widgetOverlay = null;
raid = null;
@@ -286,12 +305,14 @@ public class RaidsPlugin extends Plugin
if (matcher.find())
{
raidTime = timeToSeconds(matcher.group(1));
int timesec = timeToSeconds(matcher.group(1));
updateTooltip();
if (config.pointsMessage())
{
int totalPoints = client.getVar(Varbits.TOTAL_POINTS);
int personalPoints = client.getVar(Varbits.PERSONAL_POINTS);
int partySize = client.getVar(Varbits.RAID_PARTY_SIZE);
double percentage = personalPoints / (totalPoints / 100.0);
@@ -316,6 +337,52 @@ public class RaidsPlugin extends Plugin
.type(ChatMessageType.FRIENDSCHATNOTIFICATION)
.runeLiteFormattedMessage(chatMessage)
.build());
if (config.ptsHr())
{
String ptssolo;
{
ptssolo = POINTS_FORMAT.format(((float) personalPoints / (float) timesec) * 3600);
}
String ptsteam;
{
ptsteam = POINTS_FORMAT.format(((float) totalPoints / (float) timesec) * 3600);
}
String ptssplit;
{
ptssplit = POINTS_FORMAT.format(((float) (totalPoints / (float) timesec) * 3600) / (partySize));
}
String chatMessage2 = new ChatMessageBuilder()
.append(ChatColorType.NORMAL)
.append("Solo Pts/Hr: ")
.append(ChatColorType.HIGHLIGHT)
.append(ptssolo)
.append(ChatColorType.NORMAL)
.append("Team Pts/Hr: ")
.append(ChatColorType.HIGHLIGHT)
.append(ptsteam)
.build();
chatMessageManager.queue(QueuedMessage.builder()
.type(ChatMessageType.FRIENDSCHATNOTIFICATION)
.runeLiteFormattedMessage(chatMessage2)
.build());
String chatMessage3 = new ChatMessageBuilder()
.append(ChatColorType.NORMAL)
.append("Split Pts/Hr: ")
.append(ChatColorType.HIGHLIGHT)
.append(ptssplit)
.build();
chatMessageManager.queue(QueuedMessage.builder()
.type(ChatMessageType.FRIENDSCHATNOTIFICATION)
.runeLiteFormattedMessage(chatMessage3)
.build());
}
}
}
}
@@ -338,7 +405,7 @@ public class RaidsPlugin extends Plugin
}
}
private void checkRaidPresence(boolean force)
public void checkRaidPresence(boolean force)
{
if (client.getGameState() != GameState.LOGGED_IN)
{

View File

@@ -104,16 +104,17 @@ public class RaidsPointsOverlay extends Overlay
.left("Unique:")
.right(UNIQUE_FORMAT.format(uniqueChance))
.build());
//TODO this is annoyingly bugged, personalpoints returns null for some reason
/*
if (partySize > 1)
{
double personalChance = uniqueChance * (personalPoints / totalPoints);
double personalChance = uniqueChance * (double)(personalPoints / totalPoints);
panel.getChildren().add(LineComponent.builder()
panel.getChildren().add(LineComponent.builder()
.left("Personal:")
.right(UNIQUE_FORMAT.format(personalChance))
.build());
}
}*/
return panel.render(graphics);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB