diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsConfig.java index 539c810de2..16922d9874 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsConfig.java @@ -68,15 +68,4 @@ public interface FpsConfig extends Config { return true; } - - @ConfigItem( - keyName = "drawPing", - name = "Draw ping indicator", - description = "Show a number in the corner for the current ping", - position = 3 - ) - default boolean drawPing() - { - return false; - } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java index 17afae61b6..0103337792 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java @@ -26,14 +26,14 @@ package net.runelite.client.plugins.fps; import java.awt.Color; import java.awt.Dimension; -import java.awt.FontMetrics; import java.awt.Graphics2D; import javax.inject.Inject; import javax.inject.Singleton; import net.runelite.api.Client; import net.runelite.api.Point; -import net.runelite.api.Varbits; import net.runelite.api.events.FocusChanged; +import net.runelite.api.widgets.Widget; +import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.ui.overlay.Overlay; import net.runelite.client.ui.overlay.OverlayLayer; import net.runelite.client.ui.overlay.OverlayPosition; @@ -51,6 +51,10 @@ import net.runelite.client.ui.overlay.OverlayUtil; @Singleton public class FpsOverlay extends Overlay { + private static final int Y_OFFSET = 1; + private static final int X_OFFSET = 1; + private static final String FPS_STRING = " FPS"; + // Local dependencies private final Client client; private final FpsPlugin plugin; @@ -84,62 +88,30 @@ public class FpsOverlay extends Overlay return isEnforced() ? Color.red : Color.yellow; } - private static Color getPingColor(int ping) - { - if (ping >= 100 || ping < 0) - { - return Color.red; - } - else if (ping >= 50) - { - return Color.yellow; - } - return Color.green; - } - - private int calculateOffset() - { - if ((client.getVar(Varbits.SIDE_PANELS) == 1) && client.isResized()) - { - return 27; - } - - return 2; - } - @Override public Dimension render(Graphics2D graphics) { - if (!plugin.isDrawFps() && !plugin.isDrawPing()) + if (!plugin.isDrawFps()) { return null; } - final int offset = calculateOffset(); + // On resizable bottom line mode the logout button is at the top right, so offset the overlay + // to account for it + Widget logoutButton = client.getWidget(WidgetInfo.RESIZABLE_MINIMAP_LOGOUT_BUTTON); + int xOffset = X_OFFSET; + if (logoutButton != null && !logoutButton.isHidden()) + { + xOffset += logoutButton.getWidth(); + } + + final String text = client.getFPS() + FPS_STRING; + final int textWidth = graphics.getFontMetrics().stringWidth(text); + final int textHeight = graphics.getFontMetrics().getAscent() - graphics.getFontMetrics().getDescent(); + final int width = (int) client.getRealDimensions().getWidth(); - final FontMetrics fontMetrics = graphics.getFontMetrics(); - - int baseYOffset = (fontMetrics.getAscent() - fontMetrics.getDescent()) + 1; - - if (plugin.isDrawFps()) - { - final String fpsText = String.format("%d FPS", client.getFPS()); - final int textWidth = fontMetrics.stringWidth(fpsText); - - final Point point = new Point(width - textWidth - offset, baseYOffset); - OverlayUtil.renderTextLocation(graphics, point, fpsText, getFpsValueColor()); - - baseYOffset += 11; - } - - if (plugin.isDrawPing()) - { - final String pingText = String.format("%dms", plugin.getPing()); - final int textWidth = fontMetrics.stringWidth(pingText); - - final Point point = new Point(width - textWidth - offset, baseYOffset); - OverlayUtil.renderTextLocation(graphics, point, pingText, getPingColor(plugin.getPing())); - } + final Point point = new Point(width - textWidth - xOffset, textHeight + Y_OFFSET); + OverlayUtil.renderTextLocation(graphics, point, text, getFpsValueColor()); return null; } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsPlugin.java index b33699436a..4af5c588a8 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsPlugin.java @@ -27,27 +27,19 @@ package net.runelite.client.plugins.fps; import com.google.inject.Inject; import com.google.inject.Provides; import com.google.inject.Singleton; -import java.util.concurrent.Executors; -import java.util.concurrent.ScheduledExecutorService; -import java.util.concurrent.TimeUnit; import lombok.AccessLevel; import lombok.Getter; -import net.runelite.api.Client; -import net.runelite.api.GameState; import net.runelite.api.events.ConfigChanged; import net.runelite.api.events.FocusChanged; -import net.runelite.api.events.GameStateChanged; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.EventBus; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.ui.DrawManager; import net.runelite.client.ui.overlay.OverlayManager; -import net.runelite.client.util.ExecutorServiceExceptionLogger; -import net.runelite.client.util.ping.Ping; /** - * Performance has two primary areas, this plugin class just keeps those areas up to date and handles setup / teardown. + * FPS Control has two primary areas, this plugin class just keeps those areas up to date and handles setup / teardown. * *
Overlay paints the current FPS, the color depends on whether or not FPS is being enforced. * The overlay is lightweight and is merely and indicator. @@ -55,15 +47,11 @@ import net.runelite.client.util.ping.Ping; *
Draw Listener, sleeps a calculated amount after each canvas paint operation. * This is the heart of the plugin, the amount of sleep taken is regularly adjusted to account varying * game and system load, it usually finds the sweet spot in about two seconds. - * - *
Pinging the world, when logged in and ping display is enabled, every 5 seconds the remote server
- * for the current world is pinged. A scheduled method in this class is responsible for that. When ping fails
- * or those conditions are not met, ping will have the value of -1.
*/
@PluginDescriptor(
name = "Performance",
- description = "Show current Ping and FPS or set an FPS limit",
- tags = {"frames", "framerate", "limit", "overlay", "ping"},
+ description = "Show current FPS or set an FPS limit",
+ tags = {"frames", "framerate", "limit", "overlay"},
enabledByDefault = false
)
@Singleton
@@ -71,9 +59,6 @@ public class FpsPlugin extends Plugin
{
static final String CONFIG_GROUP_KEY = "fpscontrol";
- @Getter
- private int ping;
-
@Inject
private OverlayManager overlayManager;
@@ -86,30 +71,18 @@ public class FpsPlugin extends Plugin
@Inject
private DrawManager drawManager;
- @Inject
- private Client client;
-
@Inject
private FpsConfig fpsConfig;
@Inject
private EventBus eventBus;
- private final ScheduledExecutorService pingExecutorService = new ExecutorServiceExceptionLogger(Executors.newSingleThreadScheduledExecutor());
-
- private boolean loaded = false;
-
- private boolean shutdown;
-
@Getter(AccessLevel.PACKAGE)
private FpsLimitMode limitMode;
@Getter(AccessLevel.PACKAGE)
private boolean drawFps;
- @Getter(AccessLevel.PACKAGE)
- private boolean drawPing;
-
@Provides
FpsConfig provideConfig(ConfigManager configManager)
{
@@ -124,7 +97,6 @@ public class FpsPlugin extends Plugin
limitMode = fpsConfig.limitMode();
drawFps = fpsConfig.drawFps();
- drawPing = fpsConfig.drawPing();
}
}
@@ -134,11 +106,6 @@ public class FpsPlugin extends Plugin
overlay.onFocusChanged(event);
}
- private void onGameStateChanged(GameStateChanged event)
- {
- shutdown = event.getGameState() != GameState.LOGGED_IN;
- }
-
@Override
protected void startUp() throws Exception
{
@@ -146,17 +113,9 @@ public class FpsPlugin extends Plugin
limitMode = fpsConfig.limitMode();
drawFps = fpsConfig.drawFps();
- drawPing = fpsConfig.drawPing();
overlayManager.add(overlay);
drawManager.registerEveryFrameListener(drawListener);
drawListener.reloadConfig();
- shutdown = client.getGameState() != GameState.LOGGED_IN;
-
- if (!loaded)
- {
- pingExecutorService.scheduleAtFixedRate(this::getPingToCurrentWorld, 5, 5, TimeUnit.SECONDS);
- loaded = true;
- }
}
@Override
@@ -166,25 +125,11 @@ public class FpsPlugin extends Plugin
overlayManager.remove(overlay);
drawManager.unregisterEveryFrameListener(drawListener);
- shutdown = true;
}
private void addSubscriptions()
{
eventBus.subscribe(ConfigChanged.class, this, this::onConfigChanged);
eventBus.subscribe(FocusChanged.class, this, this::onFocusChanged);
- eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
- }
-
- private void getPingToCurrentWorld()
- {
- if (!shutdown && drawPing)
- {
- ping = Ping.ping(String.format("oldschool%d.runescape.com", client.getWorld() - 300));
- }
- else
- {
- ping = -1;
- }
}
}
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentification.java b/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentification.java
index d71bcc0074..8d411a4aaa 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentification.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/itemidentification/ItemIdentification.java
@@ -72,6 +72,7 @@ enum ItemIdentification
MAGIC_SAPLING(Type.SAPLING, "Magic", "MAG", ItemID.MAGIC_SAPLING, ItemID.MAGIC_SEEDLING, ItemID.MAGIC_SEEDLING_W),
REDWOOD_SAPLING(Type.SAPLING, "Red", "RED", ItemID.REDWOOD_SAPLING, ItemID.REDWOOD_SEEDLING, ItemID.REDWOOD_SEEDLING_W),
SPIRIT_SAPLING(Type.SAPLING, "Spirit", "SPI", ItemID.SPIRIT_SAPLING, ItemID.SPIRIT_SEEDLING, ItemID.SPIRIT_SEEDLING_W),
+ CRYSTAL_SAPLING(Type.SAPLING, "Crystal", "CRY", ItemID.CRYSTAL_SAPLING, ItemID.CRYSTAL_SEEDLING, ItemID.CRYSTAL_SEEDLING_W),
APPLE_SAPLING(Type.SAPLING, "Apple", "APP", ItemID.APPLE_SAPLING, ItemID.APPLE_SEEDLING, ItemID.APPLE_SEEDLING_W),
BANANA_SAPLING(Type.SAPLING, "Banana", "BAN", ItemID.BANANA_SAPLING, ItemID.BANANA_SEEDLING, ItemID.BANANA_SEEDLING_W),
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZoneOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZoneOverlay.java
index 247b2f97ab..c13389485d 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZoneOverlay.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZoneOverlay.java
@@ -102,14 +102,19 @@ class NightmareZoneOverlay extends Overlay
renderAbsorptionCounter();
+ final int currentPoints = client.getVar(Varbits.NMZ_POINTS);
+ final int totalPoints = currentPoints + client.getVar(VarPlayer.NMZ_REWARD_POINTS);
+
panelComponent.getChildren().clear();
+
TableComponent tableComponent = new TableComponent();
tableComponent.setColumnAlignments(TableAlignment.LEFT, TableAlignment.RIGHT);
- tableComponent.addRow("Points:", StackFormatter.formatNumber(client.getVar(Varbits.NMZ_POINTS)));
+ tableComponent.addRow("Points:", StackFormatter.formatNumber(currentPoints));
+ tableComponent.addRow("Points/Hour:", StackFormatter.formatNumber(plugin.getPointsPerHour()));
if (plugin.isShowtotalpoints())
{
- tableComponent.addRow("Total:", StackFormatter.formatNumber(client.getVar(VarPlayer.NMZ_REWARD_POINTS) + client.getVar(Varbits.NMZ_POINTS)));
+ tableComponent.addRow("Total:", StackFormatter.formatNumber(totalPoints));
}
panelComponent.getChildren().add(tableComponent);
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZonePlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZonePlugin.java
index 9c32dabc51..7993ae37ca 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZonePlugin.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/nightmarezone/NightmareZonePlugin.java
@@ -25,11 +25,14 @@
package net.runelite.client.plugins.nightmarezone;
import com.google.inject.Provides;
+
import java.awt.Color;
import java.util.Arrays;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.AccessLevel;
+import java.time.Duration;
+import java.time.Instant;
import lombok.Getter;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
@@ -56,6 +59,7 @@ import net.runelite.client.util.Text;
public class NightmareZonePlugin extends Plugin
{
private static final int[] NMZ_MAP_REGION = {9033};
+ private static final Duration HOUR = Duration.ofHours(1);
@Inject
private Notifier notifier;
@@ -75,6 +79,11 @@ public class NightmareZonePlugin extends Plugin
@Inject
private EventBus eventBus;
+ @Getter
+ private int pointsPerHour;
+
+ private Instant nmzSessionStartTime;
+
// This starts as true since you need to get
// above the threshold before sending notifications
private boolean absorptionNotificationSend = true;
@@ -120,6 +129,8 @@ public class NightmareZonePlugin extends Plugin
{
nmzWidget.setHidden(false);
}
+
+ resetPointsPerHour();
}
private void addSubscriptions()
@@ -155,6 +166,11 @@ public class NightmareZonePlugin extends Plugin
absorptionNotificationSend = true;
}
+ if (nmzSessionStartTime != null)
+ {
+ resetPointsPerHour();
+ }
+
return;
}
@@ -162,6 +178,11 @@ public class NightmareZonePlugin extends Plugin
{
checkAbsorption();
}
+
+ if (config.moveOverlay())
+ {
+ pointsPerHour = calculatePointsPerHour();
+ }
}
private void onChatMessage(ChatMessage event)
@@ -239,6 +260,32 @@ public class NightmareZonePlugin extends Plugin
return !Arrays.equals(client.getMapRegions(), NMZ_MAP_REGION);
}
+ private int calculatePointsPerHour()
+ {
+ Instant now = Instant.now();
+ final int currentPoints = client.getVar(Varbits.NMZ_POINTS);
+
+ if (nmzSessionStartTime == null)
+ {
+ nmzSessionStartTime = now;
+ }
+
+ Duration timeSinceStart = Duration.between(nmzSessionStartTime, now);
+
+ if (!timeSinceStart.isZero())
+ {
+ return (int) ((double) currentPoints * (double) HOUR.toMillis() / (double) timeSinceStart.toMillis());
+ }
+
+ return 0;
+ }
+
+ private void resetPointsPerHour()
+ {
+ nmzSessionStartTime = null;
+ pointsPerHour = 0;
+ }
+
private void updateConfig()
{
this.moveOverlay = config.moveOverlay();
diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperConfig.java
index 8035af73fb..d21ed61e80 100644
--- a/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperConfig.java
+++ b/runelite-client/src/main/java/net/runelite/client/plugins/worldhopper/WorldHopperConfig.java
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2018, Lotto