From 13c7fef7742036392d5ce8477b78b572a22b0050 Mon Sep 17 00:00:00 2001 From: Max Weber Date: Mon, 18 May 2020 15:35:15 -0600 Subject: [PATCH 1/4] npcunaggroarea: split color config depending on timer status --- .../npcunaggroarea/NpcAggroAreaConfig.java | 24 +++++++++++++++---- .../npcunaggroarea/NpcAggroAreaOverlay.java | 10 +++----- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaConfig.java index 8f101f90c2..223695fa64 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaConfig.java @@ -25,6 +25,7 @@ package net.runelite.client.plugins.npcunaggroarea; import java.awt.Color; +import net.runelite.client.config.Alpha; import net.runelite.client.config.Config; import net.runelite.client.config.ConfigGroup; import net.runelite.client.config.ConfigItem; @@ -83,21 +84,34 @@ public interface NpcAggroAreaConfig extends Config } @ConfigItem( - keyName = "npcUnaggroAreaColor", - name = "Area lines colour", - description = "Choose colour to use for marking NPC unaggressive area", + keyName = "npcAggroAreaColor", + name = "Aggressive colour", + description = "Choose colour to use for marking NPC unaggressive area when NPCs are aggressive", position = 5 ) + @Alpha default Color aggroAreaColor() { - return Color.YELLOW; + return new Color(0x64FFFF00, true); + } + + @ConfigItem( + keyName = "npcUnaggroAreaColor", + name = "Unaggressive colour", + description = "Choose colour to use for marking NPC unaggressive area after NPCs have lost aggression", + position = 6 + ) + @Alpha + default Color unaggroAreaColor() + { + return new Color(0xFFFF00); } @ConfigItem( keyName = "notifyExpire", name = "Notify Expiration", description = "Send a notifcation when the unaggressive timer expires", - position = 6 + position = 7 ) default boolean notifyExpire() { diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaOverlay.java index 811952de57..2e77daa25e 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/npcunaggroarea/NpcAggroAreaOverlay.java @@ -76,15 +76,11 @@ class NpcAggroAreaOverlay extends Overlay return null; } - Color outlineColor = config.aggroAreaColor(); + Color outlineColor = config.unaggroAreaColor(); AggressionTimer timer = plugin.getCurrentTimer(); - if (timer == null || Instant.now().compareTo(timer.getEndTime()) < 0) + if (outlineColor == null || timer == null || Instant.now().compareTo(timer.getEndTime()) < 0) { - outlineColor = new Color( - outlineColor.getRed(), - outlineColor.getGreen(), - outlineColor.getBlue(), - 100); + outlineColor = config.aggroAreaColor(); } renderPath(graphics, lines, outlineColor); From 33feac8e3b13cc539c7661d89c8258023d839f00 Mon Sep 17 00:00:00 2001 From: Malfuryent Date: Sun, 11 Nov 2018 19:04:25 +0100 Subject: [PATCH 2/4] report button: add ability to switch between 24h and 12h clock Co-authored-by: melkypie <5113962+melkypie@users.noreply.github.com> --- .../reportbutton/ReportButtonConfig.java | 10 +++++ .../reportbutton/ReportButtonPlugin.java | 38 ++++++++++++---- .../plugins/reportbutton/TimeFormat.java | 43 +++++++++++++++++++ 3 files changed, 83 insertions(+), 8 deletions(-) create mode 100644 runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/TimeFormat.java diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/ReportButtonConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/ReportButtonConfig.java index 7848b20a7d..e8d90f2abd 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/ReportButtonConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/ReportButtonConfig.java @@ -40,4 +40,14 @@ public interface ReportButtonConfig extends Config { return TimeStyle.LOGIN_TIME; } + + @ConfigItem( + keyName = "switchTimeFormat", + name = "Time Format", + description = "Configures time between 12 or 24 hour time format" + ) + default TimeFormat switchTimeFormat() + { + return TimeFormat.TIME_12H; + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/ReportButtonPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/ReportButtonPlugin.java index d1ec6d6828..4859c877cc 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/ReportButtonPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/ReportButtonPlugin.java @@ -45,6 +45,7 @@ import net.runelite.api.widgets.WidgetInfo; import net.runelite.client.callback.ClientThread; import net.runelite.client.config.ConfigManager; import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.events.ConfigChanged; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.task.Schedule; @@ -58,10 +59,9 @@ public class ReportButtonPlugin extends Plugin { private static final ZoneId UTC = ZoneId.of("UTC"); private static final ZoneId JAGEX = ZoneId.of("Europe/London"); - - private static final DateTimeFormatter DATE_TIME_FORMAT = DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM); private static final DateFormat DATE_FORMAT = new SimpleDateFormat("MMM. dd, yyyy"); + private DateTimeFormatter timeFormat; private Instant loginTime; private int ticksSinceLogin; private boolean ready; @@ -85,6 +85,7 @@ public class ReportButtonPlugin extends Plugin public void startUp() { clientThread.invoke(this::updateReportButtonTime); + updateTimeFormat(); } @Override @@ -134,6 +135,15 @@ public class ReportButtonPlugin extends Plugin } } + @Subscribe + public void onConfigChanged(ConfigChanged event) + { + if (event.getGroup().equals("reportButton") && event.getKey().equals("switchTimeFormat")) + { + updateTimeFormat(); + } + } + @Schedule( period = 500, unit = ChronoUnit.MILLIS @@ -199,25 +209,37 @@ public class ReportButtonPlugin extends Plugin return Integer.toString(ticksSinceLogin); } - private static String getLocalTime() + private String getLocalTime() { - return LocalTime.now().format(DATE_TIME_FORMAT); + return LocalTime.now().format(timeFormat); } - private static String getUTCTime() + private String getUTCTime() { LocalTime time = LocalTime.now(UTC); - return time.format(DATE_TIME_FORMAT); + return time.format(timeFormat); } - private static String getJagexTime() + private String getJagexTime() { LocalTime time = LocalTime.now(JAGEX); - return time.format(DATE_TIME_FORMAT); + return time.format(timeFormat); } private static String getDate() { return DATE_FORMAT.format(new Date()); } + + private void updateTimeFormat() + { + if (config.switchTimeFormat() == TimeFormat.TIME_24H) + { + timeFormat = DateTimeFormatter.ofPattern("HH:mm:ss"); + } + else + { + timeFormat = DateTimeFormatter.ofLocalizedTime(FormatStyle.MEDIUM); + } + } } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/TimeFormat.java b/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/TimeFormat.java new file mode 100644 index 0000000000..ac7ccaad91 --- /dev/null +++ b/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/TimeFormat.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2020, melky + * 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.reportbutton; + +import lombok.RequiredArgsConstructor; + +@RequiredArgsConstructor +public enum TimeFormat +{ + TIME_12H("12-hour"), + TIME_24H("24-hour"); + + private final String name; + + @Override + public String toString() + { + return this.name; + } +} + From 582798148aa6864c9230ce5d19e90f343c9933b5 Mon Sep 17 00:00:00 2001 From: melkypie <5113962+melkypie@users.noreply.github.com> Date: Sat, 9 May 2020 14:00:23 +0300 Subject: [PATCH 3/4] report button: add clock tag Co-authored-by: Malfuryent --- .../client/plugins/reportbutton/ReportButtonPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/ReportButtonPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/ReportButtonPlugin.java index 4859c877cc..8ad7c9d8ec 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/ReportButtonPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/reportbutton/ReportButtonPlugin.java @@ -53,7 +53,7 @@ import net.runelite.client.task.Schedule; @PluginDescriptor( name = "Report Button", description = "Replace the text on the Report button with the current time", - tags = {"time", "utc"} + tags = {"time", "utc", "clock"} ) public class ReportButtonPlugin extends Plugin { From 98395b94b18b16b91a8abcd16d74f8832fb3c0d3 Mon Sep 17 00:00:00 2001 From: Max Weber Date: Sun, 24 May 2020 08:57:03 -0600 Subject: [PATCH 4/4] ItemManager: only canonicalize notes f9d3647db1a6c8b715d50d39a5141b006f5f3840 made ItemManager return a price for placeholders, which is wrong. --- .../net/runelite/client/game/ItemManager.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/game/ItemManager.java b/runelite-client/src/main/java/net/runelite/client/game/ItemManager.java index cb9cf32afd..6233265e73 100644 --- a/runelite-client/src/main/java/net/runelite/client/game/ItemManager.java +++ b/runelite-client/src/main/java/net/runelite/client/game/ItemManager.java @@ -290,20 +290,25 @@ public class ItemManager */ public int getItemPrice(int itemID, boolean ignoreUntradeableMap) { - final int realId = canonicalize(itemID); - - if (realId == ItemID.COINS_995) + if (itemID == ItemID.COINS_995) { return 1; } - if (realId == ItemID.PLATINUM_TOKEN) + if (itemID == ItemID.PLATINUM_TOKEN) { return 1000; } + ItemComposition itemComposition = getItemComposition(itemID); + if (itemComposition.getNote() != -1) + { + itemID = itemComposition.getLinkedNoteId(); + } + itemID = WORN_ITEMS.getOrDefault(itemID, itemID); + if (!ignoreUntradeableMap) { - UntradeableItemMapping p = UntradeableItemMapping.map(ItemVariationMapping.map(realId)); + UntradeableItemMapping p = UntradeableItemMapping.map(ItemVariationMapping.map(itemID)); if (p != null) { return getItemPrice(p.getPriceID()) * p.getQuantity(); @@ -311,7 +316,7 @@ public class ItemManager } int price = 0; - for (int mappedID : ItemMapping.map(realId)) + for (int mappedID : ItemMapping.map(itemID)) { ItemPrice ip = itemPrices.get(mappedID); if (ip != null)