* xp tracker: display >1m exp with thousandths precision

* fishing plugin: fix trawler timer with one tick left

* Remove gray pixel from Dragon Scimitar cursor (#8725)

* ui: add SplitComponent

SplitComponent is a component containing two other components, with the area split between the two, either horizontally or vertically.


Co-authored-by: Jasper Ketelaar <Jasperketelaar@kpnmail.nl>

* client: add smelting plugin

Co-authored-by: Adam <Adam@sigterm.info>

* constants: add GAME_TICK_LENGTH and use where needed

Also update many usages of 20ms to CLIENT_TICK_LENGTH

* regenmeter: add option to notify before next hp regen

* barrows plugin: add prayer drain timer

* chat: ensure queued messages are always cleared after adding

Mark queued message type as non null because addChatMessage will throw
if it is. This was causing the client to get stuck trying to add the
same broken message each loop.

* xp tracker: show on canvas

Co-authored-by: Jasper Ketelaar <Jasperketelaar@kpnmail.nl>

* party plugin: add partyinfo debug command

* xp tracker: add start and goal levels to on-canvas tracker

* xp tracker (onscreen): add toggle between displaying XP Left/XP Gained

* xp tracker: add right-click configure on on-screen trackers

* party service: check joins are for the current party

The server can resume party membership on handshake to parties other
than the current client party (eg. if the client is restarted or for any
other reason the current party changes). This desyncs otherwise if the
joins aren't checked to be in the current party.

* Add options for actions left and done for on screen XP

Add configurable option for on screen XP display mode, what now
includes:
- Actions done
- Actions left
- Xp gained
- Xp left

Signed-off-by: Tomas Slusny <slusnucky@gmail.com>

* Update Merge branch

# Conflicts:
#	README.md
#	runelite-api/src/main/java/net/runelite/api/widgets/WidgetID.java
#	runelite-client/src/main/java/net/runelite/client/plugins/antidrag/AntiDragConfig.java
#	runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultOverlay.java
#	runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/BarbarianAssaultPlugin.java
#	runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/Calls.java
#	runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/Game.java
#	runelite-client/src/main/java/net/runelite/client/plugins/barbarianassault/Wave.java
#	runelite-client/src/main/java/net/runelite/client/plugins/blastmine/BlastMineOreCountOverlay.java
#	runelite-client/src/main/java/net/runelite/client/plugins/inventoryviewer/InventoryViewerOverlay.java
#	runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingConfig.java
#	runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingOverlay.java
#	runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingPlugin.java
#	runelite-client/src/main/java/net/runelite/client/plugins/smelting/SmeltingSession.java
#	runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpInfoBoxOverlay.java
#	runelite-client/src/main/java/net/runelite/client/plugins/xptracker/XpTrackerPlugin.java
#	runelite-client/src/main/java/net/runelite/client/ui/overlay/components/ComponentOrientation.java
#	runelite-client/src/main/java/net/runelite/client/ui/overlay/components/SplitComponent.java

* client: use immutablemap for maps built in class initializers

* Merge branch 'master' of https://github.com/runelite/runelite into updateee

* Fix
This commit is contained in:
James
2019-05-12 17:32:18 -07:00
committed by supermxn
parent 8fd1560ab3
commit b69578d93d
58 changed files with 767 additions and 348 deletions

View File

@@ -216,4 +216,46 @@ public class ChatClient
return Integer.parseInt(response.body().string());
}
}
public boolean submitGc(String username, int gc) throws IOException
{
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
.addPathSegment("chat")
.addPathSegment("gc")
.addQueryParameter("name", username)
.addQueryParameter("gc", Integer.toString(gc))
.build();
Request request = new Request.Builder()
.post(RequestBody.create(null, new byte[0]))
.url(url)
.build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
{
return response.isSuccessful();
}
}
public int getGc(String username) throws IOException
{
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
.addPathSegment("chat")
.addPathSegment("gc")
.addQueryParameter("name", username)
.build();
Request request = new Request.Builder()
.url(url)
.build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
{
if (!response.isSuccessful())
{
throw new IOException("Unable to look up gamble count!");
}
return Integer.parseInt(response.body().string());
}
}
}

View File

@@ -107,6 +107,28 @@ public class ChatController
return kc;
}
@PostMapping("/gc")
public void submitGc(@RequestParam String name, @RequestParam int gc)
{
if (gc < 0)
{
return;
}
chatService.setGc(name, gc);
}
@GetMapping("/gc")
public int getKc(@RequestParam String name)
{
Integer kc = chatService.getGc(name);
if (kc == null)
{
throw new NotFoundException();
}
return kc;
}
@PostMapping("/task")
public void submitTask(@RequestParam String name, @RequestParam("task") String taskName, @RequestParam int amount,
@RequestParam int initialAmount, @RequestParam String location)

View File

@@ -82,6 +82,24 @@ public class ChatService
}
}
public Integer getGc(String name)
{
String value;
try (Jedis jedis = jedisPool.getResource())
{
value = jedis.get("gc." + name);
}
return value == null ? null : Integer.parseInt(value);
}
public void setGc(String name, int gc)
{
try (Jedis jedis = jedisPool.getResource())
{
jedis.setex("gc." + name, (int) EXPIRE.getSeconds(), Integer.toString(gc));
}
}
public Task getTask(String name)
{
Map<String, String> map;

View File

@@ -135,6 +135,24 @@ public final class ScriptID
*/
public static final int DIARY_QUEST_UPDATE_LINECOUNT = 2523;
/**
* Initializes the chatbox input to use RuneLite callbacks
* <ul>
* <li> String Prompt text </li>
* <li> String Default value </li>
* </ul>
*/
public static final int RUNELITE_CHATBOX_INPUT_INIT = 10001;
/**
* Handles zoom input
* <ul>
* <li> int zoom value </li>
* <li> int zoom value </li>
* </ul>
*/
public static final int CAMERA_DO_ZOOM = 42;
/**
* Does nothing
*
@@ -157,4 +175,4 @@ public final class ScriptID
* </ul>
*/
public static final int XPDROP_DISABLED = 2091;
}
}

View File

@@ -25,12 +25,12 @@
package net.runelite.client.game;
import com.google.common.collect.ImmutableMap;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -39,7 +39,7 @@ import java.util.Map;
*/
public class ItemVariationMapping
{
private static final Map<Integer, Integer> MAPPINGS = new HashMap<>();
private static final Map<Integer, Integer> MAPPINGS;
static
{
@@ -51,6 +51,7 @@ public class ItemVariationMapping
final InputStream geLimitData = ItemVariationMapping.class.getResourceAsStream("/item_variations.json");
final Map<String, Collection<Integer>> itemVariations = gson.fromJson(new InputStreamReader(geLimitData), typeToken.getType());
ImmutableMap.Builder<Integer, Integer> builder = new ImmutableMap.Builder<>();
for (Collection<Integer> value : itemVariations.values())
{
final Iterator<Integer> iterator = value.iterator();
@@ -58,9 +59,10 @@ public class ItemVariationMapping
while (iterator.hasNext())
{
MAPPINGS.put(iterator.next(), base);
builder.put(iterator.next(), base);
}
}
MAPPINGS = builder.build();
}
/**

View File

@@ -24,7 +24,7 @@
*/
package net.runelite.client.plugins.agility;
import java.util.HashMap;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import lombok.Getter;
import net.runelite.api.coords.WorldPoint;
@@ -48,7 +48,7 @@ enum Courses
RELLEKA(780.0, 475, 10553),
ARDOUGNE(793.0, 529, 10547);
private final static Map<Integer, Courses> coursesByRegion = new HashMap<>();
private final static Map<Integer, Courses> coursesByRegion;
@Getter
private final double totalXp;
@@ -64,10 +64,14 @@ enum Courses
static
{
ImmutableMap.Builder<Integer, Courses> builder = new ImmutableMap.Builder<>();
for (Courses course : values())
{
coursesByRegion.put(course.regionId, course);
builder.put(course.regionId, course);
}
coursesByRegion = builder.build();
}
Courses(double totalXp, int lastObstacleXp, int regionId, WorldPoint... courseEndWorldPoints)

View File

@@ -39,6 +39,7 @@ import net.runelite.api.SpriteID;
import net.runelite.client.game.SpriteManager;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.ComponentOrientation;
import net.runelite.client.ui.overlay.components.InfoBoxComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
@@ -60,7 +61,7 @@ class HydraOverlay extends Overlay
this.client = client;
this.spriteManager = spriteManager;
setPosition(OverlayPosition.BOTTOM_RIGHT);
panelComponent.setOrientation(PanelComponent.Orientation.VERTICAL);
panelComponent.setOrientation(ComponentOrientation.VERTICAL);
}
@Override

View File

@@ -24,9 +24,17 @@
*/
package net.runelite.client.plugins.attackstyles;
import java.util.HashMap;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import static net.runelite.client.plugins.attackstyles.AttackStyle.*;
import static net.runelite.client.plugins.attackstyles.AttackStyle.ACCURATE;
import static net.runelite.client.plugins.attackstyles.AttackStyle.AGGRESSIVE;
import static net.runelite.client.plugins.attackstyles.AttackStyle.CASTING;
import static net.runelite.client.plugins.attackstyles.AttackStyle.CONTROLLED;
import static net.runelite.client.plugins.attackstyles.AttackStyle.DEFENSIVE;
import static net.runelite.client.plugins.attackstyles.AttackStyle.DEFENSIVE_CASTING;
import static net.runelite.client.plugins.attackstyles.AttackStyle.LONGRANGE;
import static net.runelite.client.plugins.attackstyles.AttackStyle.OTHER;
import static net.runelite.client.plugins.attackstyles.AttackStyle.RANGING;
public enum WeaponType
{
@@ -59,16 +67,20 @@ public enum WeaponType
TYPE_26(AGGRESSIVE, AGGRESSIVE, null, AGGRESSIVE),
TYPE_27(ACCURATE, null, null, OTHER);
private static final Map<Integer, WeaponType> weaponTypes = new HashMap<>();
private final AttackStyle[] attackStyles;
private static final Map<Integer, WeaponType> weaponTypes;
static
{
ImmutableMap.Builder<Integer, WeaponType> builder = new ImmutableMap.Builder<>();
for (WeaponType weaponType : values())
{
weaponTypes.put(weaponType.ordinal(), weaponType);
builder.put(weaponType.ordinal(), weaponType);
}
weaponTypes = builder.build();
}
WeaponType(AttackStyle... attackStyles)

View File

@@ -31,16 +31,14 @@ import net.runelite.client.chat.ChatColorType;
import net.runelite.client.chat.ChatMessageBuilder;
import net.runelite.client.eventbus.Subscribe;
import java.awt.*;
import java.util.ArrayList;
@Getter
public class Game
{
@Getter
private Client client;
@Getter
private String currentWave;
@Getter
private ArrayList<Wave> waves = new ArrayList<>();
private String[] totalDescriptions = {
"A: ",
@@ -120,9 +118,11 @@ public class Game
message.append("(");
if (totalPoints[i] < 0)
{
message.append(ChatColorType.HIGHLIGHT);
message.append(String.valueOf(totalPoints[i]));
message.append(ChatColorType.NORMAL);
message.append(Color.RED, String.valueOf(totalPoints[i]));
}
else if (totalPoints[i] > 0)
{
message.append(Color.BLUE, String.valueOf(totalPoints[i]));
}
else
{

View File

@@ -35,10 +35,9 @@ import net.runelite.client.chat.ChatMessageManager;
import javax.inject.Inject;
import java.awt.*;
@Getter
class Wave
{
@Getter
private Client client;
private final ImmutableList<WidgetInfo> WIDGETS = ImmutableList.of(
WidgetInfo.BA_FAILED_ATTACKER_ATTACKS,
@@ -65,17 +64,17 @@ class Wave
WidgetInfo.BA_HITPOINTS_REPLENISHED_POINTS,
WidgetInfo.BA_WRONG_POISON_PACKS_POINTS
);
private int[] amountsList = new int[6];
private int[] waveAmounts = new int[6];
private int[] allPointsList = new int[10];
private int[] importantPointsList = new int[6];
private int[] wavePoints = new int[6];
private int[] otherRolesPointsList = new int[4];
private String[] descriptions = {
" A: ",
" D: ",
" C: ",
" Vial: ",
" H packs: ",
" Total: "};
"; D: ",
"; C: ",
"; Vial: ",
"; H packs: ",
"; Total: "};
private String[] otherPointsDescriptions = {
" A: ",
@@ -87,23 +86,11 @@ class Wave
{
this.client = client;
}
int[] getOtherRolesPointsList()
{
return otherRolesPointsList;
}
int[] getWaveAmounts()
{
return amountsList;
}
int[] getWavePoints()
{
return importantPointsList;
}
void setWaveAmounts(int[] amounts)
{
for (int i = 0; i < amounts.length; i++)
{
amountsList[i] = amounts[i];
waveAmounts[i] = amounts[i];
}
}
@@ -111,7 +98,7 @@ class Wave
{
for (int i = 0; i < points.length; i++)
{
importantPointsList[i] = points[i];
wavePoints[i] = points[i];
}
for (int i = 0; i < otherRolesPoints.length; i++)
{
@@ -125,7 +112,7 @@ class Wave
Widget w = client.getWidget(WIDGETS.get(i));
if (w != null)
{
amountsList[i] = Integer.parseInt(w.getText());
waveAmounts[i] = Integer.parseInt(w.getText());
}
}
}
@@ -138,26 +125,26 @@ class Wave
switch (i)
{
case 1:
importantPointsList[0] += allPointsList[i];
wavePoints[0] += allPointsList[i];
break;
case 4:
importantPointsList[1] += allPointsList[i];
wavePoints[1] += allPointsList[i];
break;
case 6:
importantPointsList[2] += allPointsList[i];
wavePoints[2] += allPointsList[i];
break;
case 8:
case 9:
importantPointsList[3] += allPointsList[i];
wavePoints[3] += allPointsList[i];
break;
default:
break;
}
}
importantPointsList[5] = 0;
for (int i = 0; i < importantPointsList.length-1; i++)
wavePoints[5] = 0;
for (int i = 0; i < wavePoints.length-1; i++)
{
importantPointsList[5] += importantPointsList[i];
wavePoints[5] += wavePoints[i];
}
for (int i = 0; i < POINTSWIDGETS.size(); i++)
{
@@ -201,15 +188,19 @@ class Wave
if (i != 4)
{
message.append(descriptions[i]);
message.append(String.valueOf(amountsList[i]));
message.append(String.valueOf(waveAmounts[i]));
message.append("(");
if (importantPointsList[i] < 0)
if (wavePoints[i] < 0)
{
message.append(Color.RED, String.valueOf(importantPointsList[i]));
message.append(Color.RED, String.valueOf(wavePoints[i]));
}
else if (wavePoints[i] > 0)
{
message.append(Color.BLUE, String.valueOf(wavePoints[i]));
}
else
{
message.append(String.valueOf(importantPointsList[i]));
message.append(String.valueOf(wavePoints[i]));
}
message.append(")");
}

View File

@@ -24,7 +24,7 @@
*/
package net.runelite.client.plugins.blastfurnace;
import java.util.HashMap;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import lombok.Getter;
import net.runelite.api.ItemID;
@@ -50,14 +50,18 @@ public enum BarsOres
SILVER_BAR(Varbits.BLAST_FURNACE_SILVER_BAR, ItemID.SILVER_BAR),
GOLD_BAR(Varbits.BLAST_FURNACE_GOLD_BAR, ItemID.GOLD_BAR);
private static final Map<Varbits, BarsOres> VARBIT = new HashMap<>();
private static final Map<Varbits, BarsOres> VARBIT;
static
{
ImmutableMap.Builder<Varbits, BarsOres> builder = new ImmutableMap.Builder<>();
for (BarsOres s : values())
{
VARBIT.put(s.getVarbit(), s);
builder.put(s.getVarbit(), s);
}
VARBIT = builder.build();
}
@Getter

View File

@@ -35,6 +35,7 @@ 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.components.ComponentOrientation;
import net.runelite.client.ui.overlay.components.ImageComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
@@ -54,7 +55,7 @@ class BlastFurnaceOverlay extends Overlay
this.plugin = plugin;
this.client = client;
setPosition(OverlayPosition.TOP_LEFT);
imagePanelComponent.setOrientation(PanelComponent.Orientation.HORIZONTAL);
imagePanelComponent.setOrientation(ComponentOrientation.HORIZONTAL);
getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Blast furnace overlay"));
}

View File

@@ -39,6 +39,8 @@ import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
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.components.ComponentOrientation;
import net.runelite.client.ui.overlay.components.ImageComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
@@ -57,7 +59,7 @@ class BlastMineOreCountOverlay extends Overlay
this.client = client;
this.config = config;
this.itemManager = itemManager;
panelComponent.setOrientation(PanelComponent.Orientation.HORIZONTAL);
panelComponent.setOrientation(ComponentOrientation.HORIZONTAL);
getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Blast mine overlay"));
}

View File

@@ -24,7 +24,7 @@
*/
package net.runelite.client.plugins.blastmine;
import java.util.HashMap;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import lombok.Getter;
import net.runelite.api.ObjectID;
@@ -37,17 +37,21 @@ public enum BlastMineRockType
LIT(ObjectID.POT_OF_DYNAMITE_28585, ObjectID.POT_OF_DYNAMITE_28586),
EXPLODED(ObjectID.SHATTERED_ROCKFACE, ObjectID.SHATTERED_ROCKFACE_28588);
private static final Map<Integer, BlastMineRockType> rockTypes = new HashMap<>();
private static final Map<Integer, BlastMineRockType> rockTypes;
static
{
ImmutableMap.Builder<Integer, BlastMineRockType> builder = new ImmutableMap.Builder<>();
for (BlastMineRockType type : values())
{
for (int spotId : type.getObjectIds())
{
rockTypes.put(spotId, type);
builder.put(spotId, type);
}
}
rockTypes = builder.build();
}
@Getter

View File

@@ -25,9 +25,9 @@
*/
package net.runelite.client.plugins.bosstimer;
import com.google.common.collect.ImmutableMap;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.HashMap;
import java.util.Map;
import net.runelite.api.ItemID;
import net.runelite.api.NpcID;
@@ -59,7 +59,7 @@ enum Boss
DUSK(NpcID.DUSK_7889, 2, ChronoUnit.MINUTES, ItemID.NOON),
ALCHEMICAL_HYDRA(NpcID.ALCHEMICAL_HYDRA_8622, 25200, ChronoUnit.MILLIS, ItemID.IKKLE_HYDRA);
private static final Map<Integer, Boss> bosses = new HashMap<>();
private static final Map<Integer, Boss> bosses;
private final int id;
private final Duration spawnTime;
@@ -67,10 +67,14 @@ enum Boss
static
{
ImmutableMap.Builder<Integer, Boss> builder = new ImmutableMap.Builder<>();
for (Boss boss : values())
{
bosses.put(boss.getId(), boss);
builder.put(boss.getId(), boss);
}
bosses = builder.build();
}
private Boss(int id, long period, ChronoUnit unit, int itemSpriteId)

View File

@@ -24,7 +24,7 @@
*/
package net.runelite.client.plugins.cerberus;
import java.util.HashMap;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import java.util.Optional;
import lombok.Getter;
@@ -41,18 +41,21 @@ public enum CerberusGhost
MAGE(NpcID.SUMMONED_SOUL_5868, Skill.MAGIC),
MELEE(NpcID.SUMMONED_SOUL_5869, Skill.ATTACK);
private static final Map<Integer, CerberusGhost> MAP = new HashMap<>();
private final int npcId;
private final Skill type;
private static final Map<Integer, CerberusGhost> MAP;
static
{
final CerberusGhost[] values = CerberusGhost.values();
ImmutableMap.Builder<Integer, CerberusGhost> builder = new ImmutableMap.Builder<>();
for (final CerberusGhost ghost : values)
for (final CerberusGhost ghost : values())
{
MAP.put(ghost.getNpcId(), ghost);
builder.put(ghost.getNpcId(), ghost);
}
MAP = builder.build();
}
/**

View File

@@ -31,6 +31,7 @@ import javax.inject.Singleton;
import net.runelite.client.game.SkillIconManager;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.ComponentOrientation;
import net.runelite.client.ui.overlay.components.ImageComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
@@ -47,7 +48,7 @@ public class CerberusOverlay extends Overlay
this.plugin = plugin;
this.iconManager = iconManager;
setPosition(OverlayPosition.BOTTOM_RIGHT);
panelComponent.setOrientation(PanelComponent.Orientation.HORIZONTAL);
panelComponent.setOrientation(ComponentOrientation.HORIZONTAL);
}
@Override

View File

@@ -99,6 +99,17 @@ public interface ChatCommandsConfig extends Config
@ConfigItem(
position = 6,
keyName = "gc",
name = "GC Command",
description = "Configures whether the Barbarian Assault High gamble count command is enabled<br> !gc"
)
default boolean gc()
{
return true;
}
@ConfigItem(
position = 7,
keyName = "clearShortcuts",
name = "Clear shortcuts",
description = "Enable shortcuts (ctrl+w and backspace) for clearing the chatbox"

View File

@@ -41,6 +41,7 @@ import net.runelite.api.IconID;
import net.runelite.api.ItemComposition;
import net.runelite.api.MessageNode;
import net.runelite.api.VarPlayer;
import net.runelite.api.Varbits;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.VarbitChanged;
@@ -96,6 +97,7 @@ public class ChatCommandsPlugin extends Plugin
private static final String KILLCOUNT_COMMAND_STRING = "!kc";
private static final String CMB_COMMAND_STRING = "!cmb";
private static final String QP_COMMAND_STRING = "!qp";
private static final String GC_COMMAND_STRING = "!gc";
private static final String PB_COMMAND = "!pb";
private final HiscoreClient hiscoreClient = new HiscoreClient();
@@ -145,6 +147,7 @@ public class ChatCommandsPlugin extends Plugin
chatCommandManager.registerCommandAsync(CLUES_COMMAND_STRING, this::clueLookup);
chatCommandManager.registerCommandAsync(KILLCOUNT_COMMAND_STRING, this::killCountLookup, this::killCountSubmit);
chatCommandManager.registerCommandAsync(QP_COMMAND_STRING, this::questPointsLookup, this::questPointsSubmit);
chatCommandManager.registerCommandAsync(GC_COMMAND_STRING, this::gambleCountLookup, this::gambleCountSubmit);
chatCommandManager.registerCommandAsync(PB_COMMAND, this::personalBestLookup, this::personalBestSubmit);
}
@@ -163,6 +166,7 @@ public class ChatCommandsPlugin extends Plugin
chatCommandManager.unregisterCommand(KILLCOUNT_COMMAND_STRING);
chatCommandManager.unregisterCommand(QP_COMMAND_STRING);
chatCommandManager.unregisterCommand(PB_COMMAND);
chatCommandManager.unregisterCommand(GC_COMMAND_STRING);
}
@Provides
@@ -484,6 +488,77 @@ public class ChatCommandsPlugin extends Plugin
return true;
}
private void gambleCountLookup(ChatMessage chatMessage, String message)
{
if (!config.gc())
{
return;
}
ChatMessageType type = chatMessage.getType();
final String player;
if (type.equals(ChatMessageType.PRIVATECHAT))
{
player = client.getLocalPlayer().getName();
}
else
{
player = sanitize(chatMessage.getName());
}
int gc;
try
{
gc = chatClient.getGc(player);
log.info("gc lookup");
}
catch (IOException ex)
{
log.debug("unable to lookup gamble count", ex);
log.info("gc lookup error");
return;
}
String response = new ChatMessageBuilder()
.append(ChatColorType.NORMAL)
.append("Barbarian Assault High-level gambles: ")
.append(ChatColorType.HIGHLIGHT)
.append(Integer.toString(gc))
.build();
log.debug("Setting response {}", response);
final MessageNode messageNode = chatMessage.getMessageNode();
messageNode.setRuneLiteFormatMessage(response);
chatMessageManager.update(messageNode);
client.refreshChat();
}
private boolean gambleCountSubmit(ChatInput chatInput, String value)
{
final int gc = client.getVar(Varbits.BA_GC);
final String playerName = client.getLocalPlayer().getName();
executor.execute(() ->
{
try
{
chatClient.submitGc(playerName, gc);
}
catch (Exception ex)
{
log.warn("unable to submit gamble count", ex);
}
finally
{
chatInput.resume();
}
});
return true;
}
private void personalBestLookup(ChatMessage chatMessage, String message)
{
if (!config.pb())

View File

@@ -24,56 +24,58 @@
*/
package net.runelite.client.plugins.chatcommands;
import java.util.HashMap;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import net.runelite.api.Skill;
class SkillAbbreviations
{
private static final Map<String, String> MAP = new HashMap<>();
private static final Map<String, String> MAP;
static
{
MAP.put("ATK", Skill.ATTACK.getName());
MAP.put("ATT", Skill.ATTACK.getName());
MAP.put("DEF", Skill.DEFENCE.getName());
MAP.put("STR", Skill.STRENGTH.getName());
MAP.put("HEALTH", Skill.HITPOINTS.getName());
MAP.put("HIT", Skill.HITPOINTS.getName());
MAP.put("HITPOINT", Skill.HITPOINTS.getName());
MAP.put("HP", Skill.HITPOINTS.getName());
MAP.put("RANGE", Skill.RANGED.getName());
MAP.put("RANGING", Skill.RANGED.getName());
MAP.put("RNG", Skill.RANGED.getName());
MAP.put("PRAY", Skill.PRAYER.getName());
MAP.put("MAG", Skill.MAGIC.getName());
MAP.put("MAGE", Skill.MAGIC.getName());
MAP.put("COOK", Skill.COOKING.getName());
MAP.put("WC", Skill.WOODCUTTING.getName());
MAP.put("WOOD", Skill.WOODCUTTING.getName());
MAP.put("WOODCUT", Skill.WOODCUTTING.getName());
MAP.put("FLETCH", Skill.FLETCHING.getName());
MAP.put("FISH", Skill.FISHING.getName());
MAP.put("FM", Skill.FIREMAKING.getName());
MAP.put("FIRE", Skill.FIREMAKING.getName());
MAP.put("CRAFT", Skill.CRAFTING.getName());
MAP.put("SMITH", Skill.SMITHING.getName());
MAP.put("MINE", Skill.MINING.getName());
MAP.put("HL", Skill.HERBLORE.getName());
MAP.put("HERB", Skill.HERBLORE.getName());
MAP.put("AGI", Skill.AGILITY.getName());
MAP.put("AGIL", Skill.AGILITY.getName());
MAP.put("THIEF", Skill.THIEVING.getName());
MAP.put("SLAY", Skill.SLAYER.getName());
MAP.put("FARM", Skill.FARMING.getName());
MAP.put("RC", Skill.RUNECRAFT.getName());
MAP.put("RUNE", Skill.RUNECRAFT.getName());
MAP.put("RUNECRAFTING", Skill.RUNECRAFT.getName());
MAP.put("HUNT", Skill.HUNTER.getName());
MAP.put("CON", Skill.CONSTRUCTION.getName());
MAP.put("CONSTRUCT", Skill.CONSTRUCTION.getName());
MAP.put("ALL", Skill.OVERALL.getName());
MAP.put("TOTAL", Skill.OVERALL.getName());
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<>();
builder.put("ATK", Skill.ATTACK.getName());
builder.put("ATT", Skill.ATTACK.getName());
builder.put("DEF", Skill.DEFENCE.getName());
builder.put("STR", Skill.STRENGTH.getName());
builder.put("HEALTH", Skill.HITPOINTS.getName());
builder.put("HIT", Skill.HITPOINTS.getName());
builder.put("HITPOINT", Skill.HITPOINTS.getName());
builder.put("HP", Skill.HITPOINTS.getName());
builder.put("RANGE", Skill.RANGED.getName());
builder.put("RANGING", Skill.RANGED.getName());
builder.put("RNG", Skill.RANGED.getName());
builder.put("PRAY", Skill.PRAYER.getName());
builder.put("MAG", Skill.MAGIC.getName());
builder.put("MAGE", Skill.MAGIC.getName());
builder.put("COOK", Skill.COOKING.getName());
builder.put("WC", Skill.WOODCUTTING.getName());
builder.put("WOOD", Skill.WOODCUTTING.getName());
builder.put("WOODCUT", Skill.WOODCUTTING.getName());
builder.put("FLETCH", Skill.FLETCHING.getName());
builder.put("FISH", Skill.FISHING.getName());
builder.put("FM", Skill.FIREMAKING.getName());
builder.put("FIRE", Skill.FIREMAKING.getName());
builder.put("CRAFT", Skill.CRAFTING.getName());
builder.put("SMITH", Skill.SMITHING.getName());
builder.put("MINE", Skill.MINING.getName());
builder.put("HL", Skill.HERBLORE.getName());
builder.put("HERB", Skill.HERBLORE.getName());
builder.put("AGI", Skill.AGILITY.getName());
builder.put("AGIL", Skill.AGILITY.getName());
builder.put("THIEF", Skill.THIEVING.getName());
builder.put("SLAY", Skill.SLAYER.getName());
builder.put("FARM", Skill.FARMING.getName());
builder.put("RC", Skill.RUNECRAFT.getName());
builder.put("RUNE", Skill.RUNECRAFT.getName());
builder.put("RUNECRAFTING", Skill.RUNECRAFT.getName());
builder.put("HUNT", Skill.HUNTER.getName());
builder.put("CON", Skill.CONSTRUCTION.getName());
builder.put("CONSTRUCT", Skill.CONSTRUCTION.getName());
builder.put("ALL", Skill.OVERALL.getName());
builder.put("TOTAL", Skill.OVERALL.getName());
MAP = builder.build();
}
/**

View File

@@ -25,8 +25,8 @@
*/
package net.runelite.client.plugins.discord;
import java.util.ArrayList;
import java.util.HashMap;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import java.util.List;
import java.util.Map;
import lombok.AllArgsConstructor;
@@ -250,16 +250,18 @@ enum DiscordGameEventType
RAIDS_CHAMBERS_OF_XERIC("Chambers of Xeric", DiscordAreaType.RAIDS, Varbits.IN_RAID),
RAIDS_THEATRE_OF_BLOOD("Theatre of Blood", DiscordAreaType.RAIDS, Varbits.THEATRE_OF_BLOOD);
private static final Map<Integer, DiscordGameEventType> FROM_REGION = new HashMap<>();
private static final List<DiscordGameEventType> FROM_VARBITS = new ArrayList<>();
private static final Map<Integer, DiscordGameEventType> FROM_REGION;
private static final List<DiscordGameEventType> FROM_VARBITS;
static
{
ImmutableMap.Builder<Integer, DiscordGameEventType> regionMapBuilder = new ImmutableMap.Builder<>();
ImmutableList.Builder<DiscordGameEventType> fromVarbitsBuilder = ImmutableList.builder();
for (DiscordGameEventType discordGameEventType : DiscordGameEventType.values())
{
if (discordGameEventType.getVarbits() != null)
{
FROM_VARBITS.add(discordGameEventType);
fromVarbitsBuilder.add(discordGameEventType);
continue;
}
@@ -270,10 +272,11 @@ enum DiscordGameEventType
for (int region : discordGameEventType.getRegionIds())
{
assert !FROM_REGION.containsKey(region);
FROM_REGION.put(region, discordGameEventType);
regionMapBuilder.put(region, discordGameEventType);
}
}
FROM_REGION = regionMapBuilder.build();
FROM_VARBITS = fromVarbitsBuilder.build();
}
private String imageKey;

View File

@@ -24,7 +24,7 @@
*/
package net.runelite.client.plugins.fishing;
import java.util.HashMap;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import lombok.Getter;
import net.runelite.api.ItemID;
@@ -160,7 +160,7 @@ enum FishingSpot
FISHING_SPOT_8523);
@Getter
private static final Map<Integer, FishingSpot> SPOTS = new HashMap<>();
private static final Map<Integer, FishingSpot> SPOTS;
private final String name;
private final int fishSpriteId;
@@ -168,15 +168,17 @@ enum FishingSpot
static
{
FishingSpot[] spots = values();
ImmutableMap.Builder<Integer, FishingSpot> builder = new ImmutableMap.Builder<>();
for (FishingSpot spot : spots)
for (FishingSpot spot : values())
{
for (int spotId : spot.getIds())
{
SPOTS.put(spotId, spot);
builder.put(spotId, spot);
}
}
SPOTS = builder.build();
}
FishingSpot(String spot, int fishSpriteId, int... ids)

View File

@@ -24,7 +24,7 @@
*/
package net.runelite.client.plugins.implings;
import java.util.HashMap;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -70,14 +70,18 @@ enum Impling
private ImplingType implingType;
private final int npcId;
private static final Map<Integer, Impling> IMPLINGS = new HashMap<>();
private static final Map<Integer, Impling> IMPLINGS;
static
{
ImmutableMap.Builder<Integer, Impling> builder = new ImmutableMap.Builder<>();
for (Impling impling : values())
{
IMPLINGS.put(impling.npcId, impling);
builder.put(impling.npcId, impling);
}
IMPLINGS = builder.build();
}
static Impling findImpling(int npcId)

View File

@@ -43,6 +43,7 @@ import net.runelite.client.game.ItemManager;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.ComponentConstants;
import net.runelite.client.ui.overlay.components.ComponentOrientation;
import net.runelite.client.ui.overlay.components.ImageComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
import net.runelite.client.ui.overlay.components.TitleComponent;
@@ -69,7 +70,7 @@ class InventoryViewerOverlay extends Overlay
inventoryComponent.setWrapping(4);
inventoryComponent.setGap(new Point(6, 4));
inventoryComponent.setOrientation(PanelComponent.Orientation.HORIZONTAL);
inventoryComponent.setOrientation(ComponentOrientation.HORIZONTAL);
inventoryComponent.setBackgroundColor(null);
inventoryComponent.setBorder(new Rectangle(
0,
@@ -77,7 +78,7 @@ class InventoryViewerOverlay extends Overlay
0,
ComponentConstants.STANDARD_BORDER));
wrapperComponent.setOrientation(PanelComponent.Orientation.VERTICAL);
wrapperComponent.setOrientation(ComponentOrientation.HORIZONTAL);
wrapperComponent.setWrapping(2);
wrapperComponent.setBorder(new Rectangle(
ComponentConstants.STANDARD_BORDER * 2,

View File

@@ -24,7 +24,7 @@
*/
package net.runelite.client.plugins.itemcharges;
import java.util.HashMap;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import javax.annotation.Nullable;
import lombok.AllArgsConstructor;
@@ -174,14 +174,18 @@ enum ItemWithCharge
private final int id;
private final int charges;
private static final Map<Integer, ItemWithCharge> ID_MAP = new HashMap<>();
private static final Map<Integer, ItemWithCharge> ID_MAP;
static
{
ImmutableMap.Builder<Integer, ItemWithCharge> builder = new ImmutableMap.Builder<>();
for (ItemWithCharge itemCharge : values())
{
ID_MAP.put(itemCharge.getId(), itemCharge);
builder.put(itemCharge.getId(), itemCharge);
}
ID_MAP = builder.build();
}
@Nullable

View File

@@ -24,7 +24,7 @@
*/
package net.runelite.client.plugins.itemidentification;
import java.util.HashMap;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import net.runelite.api.ItemID;
@@ -100,17 +100,21 @@ enum ItemIdentification
this.itemIDs = ids;
}
private static final Map<Integer, ItemIdentification> itemIdentifications = new HashMap<>();
private static final Map<Integer, ItemIdentification> itemIdentifications;
static
{
ImmutableMap.Builder<Integer, ItemIdentification> builder = new ImmutableMap.Builder<>();
for (ItemIdentification i : values())
{
for (int id : i.itemIDs)
{
itemIdentifications.put(id, i);
builder.put(id, i);
}
}
itemIdentifications = builder.build();
}
static ItemIdentification get(int id)

View File

@@ -32,6 +32,7 @@ import net.runelite.api.ItemContainer;
import net.runelite.client.game.ItemManager;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.ComponentOrientation;
import net.runelite.client.ui.overlay.components.ImageComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
@@ -60,7 +61,7 @@ class LootingBagViewerOverlay extends Overlay
setPosition(OverlayPosition.BOTTOM_RIGHT);
panelComponent.setWrapping(4);
panelComponent.setGap(new Point(6, 4));
panelComponent.setOrientation(PanelComponent.Orientation.HORIZONTAL);
panelComponent.setOrientation(ComponentOrientation.HORIZONTAL);
this.itemManager = itemManager;
this.client = client;

View File

@@ -24,12 +24,22 @@
*/
package net.runelite.client.plugins.poh;
import com.google.common.collect.ImmutableMap;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map;
import lombok.Getter;
import static net.runelite.api.NullObjectID.NULL_13615;
import static net.runelite.api.NullObjectID.NULL_13618;
import static net.runelite.api.NullObjectID.NULL_13620;
import static net.runelite.api.NullObjectID.NULL_13622;
import static net.runelite.api.NullObjectID.NULL_13625;
import static net.runelite.api.NullObjectID.NULL_13627;
import static net.runelite.api.NullObjectID.NULL_13629;
import static net.runelite.api.NullObjectID.NULL_13632;
import static net.runelite.api.NullObjectID.NULL_13634;
import static net.runelite.api.NullObjectID.NULL_29228;
import static net.runelite.api.NullObjectID.NULL_29229;
import static net.runelite.api.ObjectID.*;
import static net.runelite.api.NullObjectID.*;
import net.runelite.client.util.ImageUtil;
public enum PohIcons
@@ -56,7 +66,7 @@ public enum PohIcons
ALTAR("altar",
ALTAR_13179, ALTAR_13180, ALTAR_13181, ALTAR_13182, ALTAR_13183, ALTAR_13184, ALTAR_13185, ALTAR_13186,
ALTAR_13187, ALTAR_13188, ALTAR_13189, ALTAR_13190, ALTAR_13191, ALTAR_13192, ALTAR_13193, ALTAR_13194,
ALTAR_13194, ALTAR_13196, ALTAR_13197, ALTAR_13198, ALTAR_13199
ALTAR_13196, ALTAR_13197, ALTAR_13198, ALTAR_13199
),
POOLS("pool", POOL_OF_RESTORATION, POOL_OF_REVITALISATION, POOL_OF_REJUVENATION, FANCY_REJUVENATION_POOL, ORNATE_REJUVENATION_POOL),
GLORY("glory", AMULET_OF_GLORY),
@@ -83,7 +93,7 @@ public enum PohIcons
DIGSITE_PENDANT, DIGSITE_PENDANT_33417, DIGSITE_PENDANT_33418, DIGSITE_PENDANT_33420
);
private static final Map<Integer, PohIcons> minimapIcons = new HashMap<>();
private static final Map<Integer, PohIcons> minimapIcons;
@Getter
private final String imageResource;
@@ -94,15 +104,17 @@ public enum PohIcons
static
{
PohIcons[] icons = values();
ImmutableMap.Builder<Integer, PohIcons> builder = new ImmutableMap.Builder<>();
for (PohIcons icon : icons)
for (PohIcons icon : values())
{
for (Integer spotId : icon.getIds())
{
minimapIcons.put(spotId, icon);
builder.put(spotId, icon);
}
}
minimapIcons = builder.build();
}
PohIcons(String imageResource, int... ids)

View File

@@ -24,7 +24,7 @@
*/
package net.runelite.client.plugins.prayer;
import java.util.HashMap;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -453,17 +453,19 @@ enum PrayerItems
DAMAGED_BOOK_3841(ItemID.DAMAGED_BOOK_3841, 5),
FALADOR_SHIELD_4(ItemID.FALADOR_SHIELD_4, 5);
private static final Map<Integer, Integer> prayerBonuses = new HashMap<>();
private static final Map<Integer, Integer> prayerBonuses;
private final int itemId;
private final int prayerBonus;
static
{
ImmutableMap.Builder<Integer, Integer> builder = new ImmutableMap.Builder<>();
for (PrayerItems item : values())
{
prayerBonuses.put(item.getItemId(), item.getPrayerBonus());
builder.put(item.getItemId(), item.getPrayerBonus());
}
prayerBonuses = builder.build();
}
static int getItemPrayerBonus(int itemId)

View File

@@ -24,7 +24,7 @@
*/
package net.runelite.client.plugins.prayer;
import java.util.HashMap;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import net.runelite.api.ItemID;
@@ -36,7 +36,7 @@ enum PrayerRestoreType
HOLYWRENCH(ItemID.PRAYER_CAPE, ItemID.PRAYER_CAPET, ItemID.PRAYER_CAPE_10643, ItemID.MAX_CAPE, ItemID.MAX_CAPE_13282,
ItemID.MAX_CAPE_13342, ItemID.HOLY_WRENCH, ItemID.RING_OF_THE_GODS_I);
private static final Map<Integer, PrayerRestoreType> prayerRestores = new HashMap<>();
private static final Map<Integer, PrayerRestoreType> prayerRestores;
private final int[] items;
@@ -47,13 +47,15 @@ enum PrayerRestoreType
static
{
ImmutableMap.Builder<Integer, PrayerRestoreType> builder = new ImmutableMap.Builder<>();
for (PrayerRestoreType prayerRestoreType : values())
{
for (int itemId : prayerRestoreType.items)
{
prayerRestores.put(itemId, prayerRestoreType);
builder.put(itemId, prayerRestoreType);
}
}
prayerRestores = builder.build();
}
static PrayerRestoreType getType(final int itemId)

View File

@@ -25,7 +25,7 @@
*/
package net.runelite.client.plugins.puzzlesolver;
import java.util.HashMap;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
@@ -135,14 +135,18 @@ enum VarrockMuseumAnswer
LEECH_5("What is special about Morytanian leeches?", "They attack by jumping."),
LEECH_6("How does a leech change when it feeds?", "It doubles in size.");
private static final Map<String, String> MATCHES = new HashMap<>();
private static final Map<String, String> MATCHES;
static
{
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<>();
for (VarrockMuseumAnswer varrockMuseumAnswer : VarrockMuseumAnswer.values())
{
MATCHES.put(varrockMuseumAnswer.question, varrockMuseumAnswer.answer);
builder.put(varrockMuseumAnswer.question, varrockMuseumAnswer.answer);
}
MATCHES = builder.build();
}
private final String question;

View File

@@ -48,10 +48,7 @@ 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;
import net.runelite.client.ui.overlay.components.ImageComponent;
import net.runelite.client.ui.overlay.components.LineComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
import net.runelite.client.ui.overlay.components.TitleComponent;
import net.runelite.client.ui.overlay.components.*;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.Text;
@@ -383,7 +380,7 @@ public class RaidsOverlay extends Overlay
smallImages = true;
}
panelImages.setOrientation(PanelComponent.Orientation.HORIZONTAL);
panelImages.setOrientation(ComponentOrientation.HORIZONTAL);
for (Integer e : idArray)
{
final BufferedImage image = getImage(e, smallImages);

View File

@@ -24,7 +24,7 @@
*/
package net.runelite.client.plugins.runecraft;
import java.util.HashMap;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import lombok.Getter;
import static net.runelite.api.ItemID.AIR_RUNE;
@@ -64,14 +64,18 @@ public enum AbyssRifts
@Getter
private final int itemId;
private static final Map<Integer, AbyssRifts> rifts = new HashMap<>();
private static final Map<Integer, AbyssRifts> rifts;
static
{
ImmutableMap.Builder<Integer, AbyssRifts> builder = new ImmutableMap.Builder<>();
for (AbyssRifts s : values())
{
rifts.put(s.getObjectId(), s);
builder.put(s.getObjectId(), s);
}
rifts = builder.build();
}
AbyssRifts(int objectId, int itemId)

View File

@@ -25,8 +25,8 @@
package net.runelite.client.plugins.runepouch;
import com.google.common.collect.ImmutableMap;
import java.awt.image.BufferedImage;
import java.util.HashMap;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
@@ -85,14 +85,16 @@ public enum Runes
@Setter
private BufferedImage image;
private static final Map<Integer, Runes> runes = new HashMap<>();
private static final Map<Integer, Runes> runes;
static
{
ImmutableMap.Builder<Integer, Runes> builder = new ImmutableMap.Builder<>();
for (Runes rune : values())
{
runes.put(rune.getId(), rune);
builder.put(rune.getId(), rune);
}
runes = builder.build();
}
Runes(int id, int itemId)

View File

@@ -29,8 +29,8 @@ import com.google.common.base.Preconditions;
import java.util.ArrayList;
import static java.util.Arrays.asList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import lombok.Getter;
import net.runelite.api.ItemID;
@@ -239,7 +239,7 @@ enum Task
ZUK("TzKal-Zuk", ItemID.TZREKZUK);
//</editor-fold>
private static final Map<String, Task> tasks = new HashMap<>();
private static final Map<String, Task> tasks;
private final String name;
private final int itemSpriteId;
@@ -252,10 +252,14 @@ enum Task
static
{
ImmutableMap.Builder<String, Task> builder = new ImmutableMap.Builder<>();
for (Task task : values())
{
tasks.put(task.getName().toLowerCase(), task);
builder.put(task.getName().toLowerCase(), task);
}
tasks = builder.build();
}
Task(String name, int itemSpriteId)

View File

@@ -32,14 +32,13 @@ import net.runelite.client.config.ConfigItem;
public interface SmeltingConfig extends Config
{
@ConfigItem(
position = 1,
keyName = "statTimeout",
name = "Reset stats (minutes)",
description = "The time it takes for the current smelting session to be reset"
position = 1,
keyName = "statTimeout",
name = "Reset stats (minutes)",
description = "The time it takes for the current smelting session to be reset"
)
default int statTimeout()
{
return 5;
}
}

View File

@@ -27,11 +27,11 @@ package net.runelite.client.plugins.smelting;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.time.Instant;
import java.time.Duration;
import java.time.Instant;
import javax.inject.Inject;
import static net.runelite.api.AnimationID.SMITHING_SMELTING;
import static net.runelite.api.AnimationID.SMITHING_CANNONBALL;
import static net.runelite.api.AnimationID.SMITHING_SMELTING;
import net.runelite.api.Client;
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
import net.runelite.api.Skill;
@@ -50,20 +50,18 @@ class SmeltingOverlay extends Overlay
private final Client client;
private final SmeltingPlugin plugin;
private final SmeltingConfig config;
private final XpTrackerService xpTrackerService;
private final PanelComponent panelComponent = new PanelComponent();
@Inject
public SmeltingOverlay(Client client, SmeltingPlugin plugin, SmeltingConfig config, XpTrackerService xpTrackerService)
SmeltingOverlay(Client client, SmeltingPlugin plugin, XpTrackerService xpTrackerService)
{
super(plugin);
setPosition(OverlayPosition.TOP_LEFT);
this.client = client;
this.plugin = plugin;
this.config = config;
this.xpTrackerService = xpTrackerService;
setPosition(OverlayPosition.TOP_LEFT);
getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Smelting overlay"));
}
@@ -71,16 +69,13 @@ class SmeltingOverlay extends Overlay
public Dimension render(Graphics2D graphics)
{
SmeltingSession session = plugin.getSession();
if (session!=null)
if (session.getLastItemSmelted() == null)
if (session == null)
{
return null;
}
panelComponent.getChildren().clear();
if (session!=null)
if (isSmelting() || Duration.between(session.getLastItemSmelted(), Instant.now()).getSeconds() < SMELT_TIMEOUT)
{
panelComponent.getChildren().add(TitleComponent.builder()
@@ -125,6 +120,7 @@ class SmeltingOverlay extends Overlay
return panelComponent.render(graphics);
}
private boolean isSmelting()
{
switch (client.getLocalPlayer().getAnimation())

View File

@@ -38,20 +38,17 @@ import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDependency;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType;
import net.runelite.client.plugins.xptracker.XpTrackerPlugin;
import net.runelite.client.ui.overlay.OverlayManager;
@PluginDescriptor(
name = "Smelting",
description = "Show Smelting stats",
tags = {"overlay", "skilling"},
type = PluginType.UTILITY
name = "Smelting",
description = "Show Smelting stats",
tags = {"overlay", "skilling"}
)
@PluginDependency(XpTrackerPlugin.class)
public class SmeltingPlugin extends Plugin
{
@Inject
private SmeltingConfig config;
@@ -71,14 +68,14 @@ public class SmeltingPlugin extends Plugin
}
@Override
protected void startUp() throws Exception
protected void startUp()
{
session = null;
overlayManager.add(overlay);
}
@Override
protected void shutDown() throws Exception
protected void shutDown()
{
overlayManager.remove(overlay);
session = null;
@@ -92,40 +89,37 @@ public class SmeltingPlugin extends Plugin
return;
}
if (event.getMessage().contains("You retrieve a bar of"))
if (event.getMessage().startsWith("You retrieve a bar of"))
{
if (session == null)
{
session = new SmeltingSession();
}
session.setLastItemSmelted(Instant.now());
session.increaseBarsSmelted();
}
else if (event.getMessage().contains("You remove the cannonballs from the mould"))
else if (event.getMessage().startsWith("You remove the cannonballs from the mould"))
{
if (session == null)
{
session = new SmeltingSession();
}
session.setLastItemSmelted(Instant.now());
session.increaseCannonBallsSmelted();
}
}
@Subscribe
public void onGameTick(GameTick event)
{
if (session!=null)
if (session.getLastItemSmelted() != null)
if (session != null)
{
final Duration statTimeout = Duration.ofMinutes(config.statTimeout());
final Duration sinceCaught = Duration.between(session.getLastItemSmelted(), Instant.now());
if (sinceCaught.compareTo(statTimeout) >= 0)
{
session.setLastItemSmelted(null);
session = null;
}
}
}
}

View File

@@ -25,30 +25,29 @@
package net.runelite.client.plugins.smelting;
import java.time.Instant;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
class SmeltingSession
{
@Getter(AccessLevel.PACKAGE)
@Setter
private Instant lastItemSmelted;
@Getter(AccessLevel.PACKAGE)
private int barsSmelted;
@Getter(AccessLevel.PACKAGE)
private int cannonBallsSmelted;
@Getter(AccessLevel.PACKAGE)
private Instant lastItemSmelted;
void increaseBarsSmelted()
{
barsSmelted++;
lastItemSmelted = Instant.now();
}
void increaseCannonBallsSmelted()
{
cannonBallsSmelted += 4;
lastItemSmelted = Instant.now();
}
}

View File

@@ -36,6 +36,7 @@ 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;
import net.runelite.client.ui.overlay.components.ComponentOrientation;
import net.runelite.client.ui.overlay.components.ImageComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
@@ -55,7 +56,7 @@ public class TeamCapesOverlay extends Overlay
this.plugin = plugin;
this.config = config;
this.manager = manager;
panelComponent.setOrientation(PanelComponent.Orientation.HORIZONTAL);
panelComponent.setOrientation(ComponentOrientation.HORIZONTAL);
panelComponent.setWrapping(4);
getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Teamcapes overlay"));
}

View File

@@ -24,7 +24,7 @@
*/
package net.runelite.client.plugins.tithefarm;
import java.util.HashMap;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import lombok.Getter;
import net.runelite.api.ObjectID;
@@ -60,19 +60,21 @@ public enum TitheFarmPlantType
@Getter
private final int[] objectIds;
private static final Map<Integer, TitheFarmPlantType> plantTypes = new HashMap<>();
private static final Map<Integer, TitheFarmPlantType> plantTypes;
static
{
TitheFarmPlantType[] types = values();
ImmutableMap.Builder<Integer, TitheFarmPlantType> builder = new ImmutableMap.Builder<>();
for (TitheFarmPlantType type : types)
for (TitheFarmPlantType type : values())
{
for (int spotId : type.getObjectIds())
{
plantTypes.put(spotId, type);
builder.put(spotId, type);
}
}
plantTypes = builder.build();
}
TitheFarmPlantType(String name, int baseId, int... objectIds)

View File

@@ -19,6 +19,7 @@ import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayMenuEntry;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayPriority;
import net.runelite.client.ui.overlay.components.ComponentOrientation;
import net.runelite.client.ui.overlay.components.PanelComponent;
import net.runelite.client.ui.overlay.components.TitleComponent;
@@ -58,7 +59,7 @@ public class WhaleWatchersOverlay extends Overlay
if (plugin.inCombat && config.showDamageCounter())
{
panelComponent.setOrientation(PanelComponent.Orientation.HORIZONTAL);
panelComponent.setOrientation(ComponentOrientation.HORIZONTAL);
panelComponent.setWrapping(5);
String opp = client.getLocalPlayer().getInteracting() != null ?
client.getLocalPlayer().getInteracting().getName() : lastOpponent;

View File

@@ -24,7 +24,7 @@
*/
package net.runelite.client.plugins.woodcutting;
import java.util.HashMap;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -67,14 +67,18 @@ enum Axe
private final Integer animId;
private final Integer itemId;
private static final Map<Integer, Axe> AXE_ANIM_IDS = new HashMap<>();
private static final Map<Integer, Axe> AXE_ANIM_IDS;
static
{
ImmutableMap.Builder<Integer, Axe> builder = new ImmutableMap.Builder<>();
for (Axe axe : values())
{
AXE_ANIM_IDS.put(axe.animId, axe);
builder.put(axe.animId, axe);
}
AXE_ANIM_IDS = builder.build();
}
static Axe findAxeByAnimId(int animId)

View File

@@ -24,7 +24,7 @@
*/
package net.runelite.client.plugins.woodcutting;
import java.util.HashMap;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import lombok.Getter;
import static net.runelite.api.ObjectID.REDWOOD;
@@ -42,17 +42,21 @@ enum Tree
this.treeIds = treeIds;
}
private static final Map<Integer, Tree> TREES = new HashMap<>();
private static final Map<Integer, Tree> TREES;
static
{
ImmutableMap.Builder<Integer, Tree> builder = new ImmutableMap.Builder<>();
for (Tree tree : values())
{
for (int treeId : tree.treeIds)
{
TREES.put(treeId, tree);
builder.put(treeId, tree);
}
}
TREES = builder.build();
}
static Tree findTree(int objectId)

View File

@@ -57,8 +57,6 @@ import net.runelite.client.util.StackFormatter;
class XpInfoBox extends JPanel
{
private static final String REMOVE_STATE = "Remove from canvas";
private static final String ADD_STATE = "Add to canvas";
private static final DecimalFormat TWO_DECIMAL_FORMAT = new DecimalFormat("0.00");
// Templates
@@ -69,6 +67,9 @@ class XpInfoBox extends JPanel
private static final String HTML_LABEL_TEMPLATE =
"<html><body style='color:%s'>%s<span style='color:white'>%s</span></body></html>";
private static final String REMOVE_STATE = "Remove from canvas";
private static final String ADD_STATE = "Add to canvas";
// Instance members
private final JPanel panel;
@@ -91,9 +92,9 @@ class XpInfoBox extends JPanel
private final JLabel expLeft = new JLabel();
private final JLabel actionsLeft = new JLabel();
private final JMenuItem pauseSkill = new JMenuItem("Pause");
private final JMenuItem canvasItem = new JMenuItem(ADD_STATE);
private final XpTrackerConfig xpTrackerConfig;
private final JMenuItem canvasItem = new JMenuItem(ADD_STATE);
private boolean paused = false;
@@ -244,7 +245,6 @@ class XpInfoBox extends JPanel
}
progressBar.setPositions(positions);
progressBar.setPositionWidth(xpTrackerConfig.levelMarkerWidth());
}
else
{

View File

@@ -24,6 +24,7 @@
*/
package net.runelite.client.plugins.xptracker;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
@@ -31,9 +32,12 @@ import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.Experience;
import net.runelite.api.Skill;
import net.runelite.client.ui.FontManager;
import net.runelite.client.ui.SkillColor;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayMenuEntry;
import net.runelite.client.ui.overlay.components.ComponentOrientation;
import net.runelite.client.ui.overlay.components.ImageComponent;
import net.runelite.client.ui.overlay.components.LineComponent;
@@ -41,69 +45,128 @@ import net.runelite.client.ui.overlay.components.PanelComponent;
import net.runelite.client.ui.overlay.components.ProgressBarComponent;
import net.runelite.client.ui.overlay.components.SplitComponent;
import net.runelite.client.util.StackFormatter;
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
class XpInfoBoxOverlay extends Overlay
{
private static final int PANEL_PREFERRED_WIDTH = 155;
private static final int BORDER_SIZE = 7;
private static final int GAP_SIZE = 5;
private static final int PANEL_PREFERRED_WIDTH = 150;
private static final int BORDER_SIZE = 2;
private static final int XP_AND_PROGRESS_BAR_GAP = 2;
private static final int XP_AND_ICON_GAP = 4;
private static final Rectangle XP_AND_ICON_COMPONENT_BORDER = new Rectangle(2, 1, 4, 0);
private final PanelComponent panel = new PanelComponent();
private final PanelComponent iconXpSplitPanel = new PanelComponent();
private final XpTrackerPlugin plugin;
private final XpTrackerConfig config;
@Getter(AccessLevel.PACKAGE)
private final Skill skill;
private final BufferedImage icon;
XpInfoBoxOverlay(XpTrackerPlugin plugin, Skill skill, BufferedImage icon)
XpInfoBoxOverlay(
XpTrackerPlugin plugin,
XpTrackerConfig config,
Skill skill,
BufferedImage icon)
{
super(plugin);
this.plugin = plugin;
this.config = config;
this.skill = skill;
this.icon = icon;
panel.setBorder(new Rectangle(BORDER_SIZE, BORDER_SIZE, BORDER_SIZE, BORDER_SIZE));
panel.setGap(new Point(0, GAP_SIZE));
panel.setGap(new Point(0, XP_AND_PROGRESS_BAR_GAP));
panel.setPreferredSize(new Dimension(PANEL_PREFERRED_WIDTH, 0));
iconXpSplitPanel.setBorder(XP_AND_ICON_COMPONENT_BORDER);
iconXpSplitPanel.setBackgroundColor(null);
iconXpSplitPanel.setPreferredSize(new Dimension(PANEL_PREFERRED_WIDTH, 0));
getMenuEntries().add(new OverlayMenuEntry(RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "XP Tracker overlay"));
}
@Override
public Dimension render(Graphics2D graphics)
{
panel.getChildren().clear();
iconXpSplitPanel.getChildren().clear();
//Setting the font to rs small font so that the overlay isn't huge
graphics.setFont(FontManager.getRunescapeSmallFont());
final XpSnapshotSingle snapshot = plugin.getSkillSnapshot(skill);
panel.getChildren().clear();
final LineComponent xpLeft = LineComponent.builder()
.left("Xp Gained:")
.right(StackFormatter.quantityToRSDecimalStack(snapshot.getXpGainedInSession()))
final String leftStr;
final int rightNum;
switch (config.onScreenDisplayMode())
{
case ACTIONS_DONE:
leftStr = snapshot.getActionType().getLabel() + " Done";
rightNum = snapshot.getActionsInSession();
break;
case ACTIONS_LEFT:
leftStr = snapshot.getActionType().getLabel() + " Left";
rightNum = snapshot.getActionsRemainingToGoal();
break;
case XP_LEFT:
leftStr = config.onScreenDisplayMode().toString();
rightNum = snapshot.getXpRemainingToGoal();
break;
case XP_GAINED:
default:
leftStr = config.onScreenDisplayMode().toString();
rightNum = snapshot.getXpGainedInSession();
break;
}
final LineComponent xpLine = LineComponent.builder()
.left(leftStr + ":")
.right(StackFormatter.quantityToRSDecimalStack(rightNum, true))
.build();
final LineComponent xpHour = LineComponent.builder()
.left("Xp/Hour:")
.right(StackFormatter.quantityToRSDecimalStack(snapshot.getXpPerHour()))
.build();
.left("XP/Hour:")
.right(StackFormatter.quantityToRSDecimalStack(snapshot.getXpPerHour(), true))
.build();
final SplitComponent xpSplit = SplitComponent.builder()
.first(xpLeft)
.second(xpHour)
.orientation(ComponentOrientation.VERTICAL)
.build();
.first(xpLine)
.second(xpHour)
.orientation(ComponentOrientation.VERTICAL)
.build();
final ImageComponent imageComponent = new ImageComponent(icon);
final SplitComponent iconSplit = SplitComponent.builder()
.first(imageComponent)
.second(xpSplit)
.orientation(ComponentOrientation.HORIZONTAL)
.gap(new Point(GAP_SIZE, 0))
.build();
final SplitComponent iconXpSplit = SplitComponent.builder()
.first(imageComponent)
.second(xpSplit)
.orientation(ComponentOrientation.HORIZONTAL)
.gap(new Point(XP_AND_ICON_GAP, 0))
.build();
iconXpSplitPanel.getChildren().add(iconXpSplit);
final ProgressBarComponent progressBarComponent = new ProgressBarComponent();
progressBarComponent.setBackgroundColor(new Color(61, 56, 49));
progressBarComponent.setForegroundColor(SkillColor.find(skill).getColor());
progressBarComponent.setLeftLabel(String.valueOf(snapshot.getStartLevel()));
progressBarComponent.setRightLabel(snapshot.getEndGoalXp() == Experience.MAX_SKILL_XP
? "200M"
: String.valueOf(snapshot.getEndLevel()));
progressBarComponent.setValue(snapshot.getSkillProgressToGoal());
panel.getChildren().add(iconSplit);
panel.getChildren().add(iconXpSplitPanel);
panel.getChildren().add(progressBarComponent);
return panel.render(graphics);
}
@Override
public String getName()
{
return super.getName() + skill.getName();
}
}

View File

@@ -24,14 +24,31 @@
*/
package net.runelite.client.plugins.xptracker;
import lombok.AllArgsConstructor;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Range;
@ConfigGroup("xpTracker")
public interface XpTrackerConfig extends Config
{
@AllArgsConstructor
enum OnScreenDisplayMode
{
XP_GAINED("XP Gained"),
XP_LEFT("XP Left"),
ACTIONS_DONE("Actions Done"),
ACTIONS_LEFT("Actions Left");
private final String name;
@Override
public String toString()
{
return name;
}
}
@ConfigItem(
position = 0,
keyName = "hideMaxed",
@@ -65,23 +82,8 @@ public interface XpTrackerConfig extends Config
return false;
}
@Range(
min = 1,
max = 5
)
@ConfigItem(
position = 3,
keyName = "levelMarkerWidth",
name = "Level marker width",
description = "Alters the width of the intermediate level markers"
)
default int levelMarkerWidth()
{
return 1;
}
@ConfigItem(
position = 4,
keyName = "pauseSkillAfter",
name = "Auto pause after",
description = "Configures how many minutes passes before pausing a skill while in game and there's no XP, 0 means disabled"
@@ -90,4 +92,15 @@ public interface XpTrackerConfig extends Config
{
return 0;
}
@ConfigItem(
position = 4,
keyName = "onScreenDisplayMode",
name = "On-screen tracker display mode",
description = "Configures the information displayed in the first line of on-screen XP overlays"
)
default OnScreenDisplayMode onScreenDisplayMode()
{
return OnScreenDisplayMode.XP_GAINED;
}
}

View File

@@ -59,11 +59,8 @@ import static net.runelite.client.plugins.xptracker.XpWorldType.NORMAL;
import net.runelite.client.task.Schedule;
import net.runelite.client.ui.ClientToolbar;
import net.runelite.client.ui.NavigationButton;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.http.api.worlds.World;
import net.runelite.http.api.worlds.WorldClient;
import net.runelite.http.api.worlds.WorldResult;
import net.runelite.client.util.ImageUtil;
import net.runelite.http.api.xp.XpClient;
@PluginDescriptor(
@@ -87,9 +84,6 @@ public class XpTrackerPlugin extends Plugin
Skill.HITPOINTS,
Skill.MAGIC);
private final XpState xpState = new XpState();
private final XpClient xpClient = new XpClient();
@Inject
private ClientToolbar clientToolbar;
@@ -110,13 +104,14 @@ public class XpTrackerPlugin extends Plugin
private NavigationButton navButton;
private XpPanel xpPanel;
private WorldResult worlds;
private XpWorldType lastWorldType;
private String lastUsername;
private long lastTickMillis = 0;
private boolean fetchXp;
private long lastXp = 0;
private final XpClient xpClient = new XpClient();
private final XpState xpState = new XpState();
private final XpPauseState xpPauseState = new XpPauseState();
@Provides
@@ -151,6 +146,7 @@ public class XpTrackerPlugin extends Plugin
@Override
protected void shutDown() throws Exception
{
overlayManager.removeIf(e -> e instanceof XpInfoBoxOverlay);
xpState.reset();
clientToolbar.removeNavigation(navButton);
}
@@ -225,7 +221,7 @@ public class XpTrackerPlugin extends Plugin
void addOverlay(Skill skill)
{
removeOverlay(skill);
overlayManager.add(new XpInfoBoxOverlay(this, skill, skillIconManager.getSkillImage(skill)));
overlayManager.add(new XpInfoBoxOverlay(this, xpTrackerConfig, skill, skillIconManager.getSkillImage(skill)));
}
/**
@@ -286,7 +282,6 @@ public class XpTrackerPlugin extends Plugin
int currentXp = client.getSkillExperience(skill);
xpState.resetSkill(skill, currentXp);
xpPanel.resetSkill(skill);
xpPanel.updateTotal(xpState.getTotalSnapshot());
removeOverlay(skill);
}
@@ -302,12 +297,10 @@ public class XpTrackerPlugin extends Plugin
if (skill != s && s != Skill.OVERALL)
{
resetSkillState(s);
removeOverlay(s);
}
}
}
@Subscribe
public void onExperienceChanged(ExperienceChanged event)
{

View File

@@ -37,6 +37,7 @@ import net.runelite.api.SpriteID;
import net.runelite.client.game.SpriteManager;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.ComponentOrientation;
import net.runelite.client.ui.overlay.components.InfoBoxComponent;
import net.runelite.client.ui.overlay.components.PanelComponent;
@@ -55,7 +56,7 @@ class OlmPrayAgainstOverlay extends Overlay
this.client = client;
this.spriteManager = spriteManager;
setPosition(OverlayPosition.BOTTOM_RIGHT);
panelComponent.setOrientation(PanelComponent.Orientation.VERTICAL);
panelComponent.setOrientation(ComponentOrientation.VERTICAL);
}
public Dimension render(Graphics2D graphics2D)

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 2018, Jacob M <https://github.com/jacoblairm>
* 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 HOLDER 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.zoom;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum ControlFunction
{
NONE("None"),
CONTROL_TO_ZOOM("Hold to zoom"),
CONTROL_TO_RESET("Reset zoom");
private String name;
@Override
public String toString()
{
return getName();
}
}

View File

@@ -1,27 +1,3 @@
/*
* Copyright (c) 2018 Abex
* 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.zoom;
import net.runelite.client.config.Config;
@@ -72,14 +48,38 @@ public interface ZoomConfig extends Config
return false;
}
@ConfigItem(
keyName = "requireControlDown",
name = "Require control down",
description = "Configures if holding control is required for zooming",
position = 4
keyName = "controlFunction",
name = "Control Function",
description = "Configures the zoom function when control is pressed",
position = 5
)
default boolean requireControlDown()
default ControlFunction controlFunction()
{
return false;
return ControlFunction.NONE;
}
}
@ConfigItem(
keyName = "ctrlZoomValue",
name = "Reset zoom position",
description = "Position of zoom when it is reset",
position = 6
)
default int ctrlZoomValue()
{
return 600;
}
@ConfigItem(
keyName = "zoomIncrement",
name = "Zoom Speed",
description = "Speed of zoom",
position = 7
)
default int zoomIncrement()
{
return 25;
}
}

View File

@@ -30,9 +30,11 @@ import com.google.inject.Inject;
import com.google.inject.Provides;
import java.awt.event.KeyEvent;
import net.runelite.api.Client;
import net.runelite.api.ScriptID;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.FocusChanged;
import net.runelite.api.events.ScriptCallbackEvent;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.input.KeyListener;
@@ -56,10 +58,13 @@ public class ZoomPlugin extends Plugin implements KeyListener
private static final int INNER_ZOOM_LIMIT = 1004;
private boolean controlDown;
@Inject
private Client client;
@Inject
private ClientThread clientThread;
@Inject
private ZoomConfig zoomConfig;
@@ -85,7 +90,7 @@ public class ZoomPlugin extends Plugin implements KeyListener
int[] intStack = client.getIntStack();
int intStackSize = client.getIntStackSize();
if ("scrollWheelZoom".equals(event.getEventName()) && zoomConfig.requireControlDown() && !controlDown)
if ("scrollWheelZoom".equals(event.getEventName()) && zoomConfig.controlFunction() == ControlFunction.CONTROL_TO_ZOOM && !controlDown)
{
intStack[intStackSize - 1] = 1;
}
@@ -104,6 +109,11 @@ public class ZoomPlugin extends Plugin implements KeyListener
return;
}
if ("scrollWheelZoomIncrement".equals(event.getEventName()) && zoomConfig.zoomIncrement() != 25)
{
intStack[intStackSize - 1] = zoomConfig.zoomIncrement();
}
if (zoomConfig.innerLimit())
{
// This lets the options panel's slider have an exponential rate
@@ -138,7 +148,7 @@ public class ZoomPlugin extends Plugin implements KeyListener
controlDown = false;
}
}
@Override
protected void startUp()
{
@@ -180,6 +190,11 @@ public class ZoomPlugin extends Plugin implements KeyListener
if (e.getKeyCode() == KeyEvent.VK_CONTROL)
{
controlDown = false;
if (zoomConfig.controlFunction() == ControlFunction.CONTROL_TO_RESET)
{
final int zoomValue = Ints.constrainToRange(zoomConfig.ctrlZoomValue(), zoomConfig.OUTER_LIMIT_MIN, INNER_ZOOM_LIMIT);
clientThread.invokeLater(() -> client.runScript(ScriptID.CAMERA_DO_ZOOM, zoomValue, zoomValue));
}
}
}
}
}

View File

@@ -28,4 +28,4 @@ public enum ComponentOrientation
{
HORIZONTAL,
VERTICAL
}
}

View File

@@ -37,12 +37,6 @@ import lombok.Setter;
public class PanelComponent implements LayoutableRenderableEntity
{
public enum Orientation
{
HORIZONTAL,
VERTICAL;
}
@Getter
private final Rectangle bounds = new Rectangle();
@@ -60,7 +54,7 @@ public class PanelComponent implements LayoutableRenderableEntity
private final List<LayoutableRenderableEntity> children = new ArrayList<>();
@Setter
private Orientation orientation = Orientation.VERTICAL;
private ComponentOrientation orientation = ComponentOrientation.VERTICAL;
@Setter
private int wrapping = -1;

View File

@@ -47,10 +47,14 @@ public class ProgressBarComponent implements LayoutableRenderableEntity
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("0.0");
private static final DecimalFormat DECIMAL_FORMAT_ABS = new DecimalFormat("#0");
private static final int SIDE_LABEL_OFFSET = 4;
private long minimum;
private long maximum = 100;
private double value;
private LabelDisplayMode labelDisplayMode = LabelDisplayMode.PERCENTAGE;
private String leftLabel;
private String rightLabel;
private Color foregroundColor = new Color(82, 161, 82);
private Color backgroundColor = new Color(255, 255, 255, 127);
private Color fontColor = Color.WHITE;
@@ -104,6 +108,24 @@ public class ProgressBarComponent implements LayoutableRenderableEntity
textComponent.setText(textToWrite);
textComponent.render(graphics);
if (leftLabel != null)
{
final TextComponent leftTextComponent = new TextComponent();
leftTextComponent.setPosition(new Point(barX + SIDE_LABEL_OFFSET, progressTextY));
leftTextComponent.setColor(fontColor);
leftTextComponent.setText(leftLabel);
leftTextComponent.render(graphics);
}
if (rightLabel != null)
{
final TextComponent leftTextComponent = new TextComponent();
leftTextComponent.setPosition(new Point(barX + width - metrics.stringWidth(rightLabel) - SIDE_LABEL_OFFSET, progressTextY));
leftTextComponent.setColor(fontColor);
leftTextComponent.setText(rightLabel);
leftTextComponent.render(graphics);
}
final Dimension dimension = new Dimension(width, height);
bounds.setLocation(preferredLocation);
bounds.setSize(dimension);

View File

@@ -24,47 +24,56 @@
*/
package net.runelite.client.ui.overlay.components;
import java.awt.*;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import lombok.Builder;
import lombok.Getter;
import lombok.Setter;
@Builder
@Setter
@Builder
public class SplitComponent implements LayoutableRenderableEntity
{
private LayoutableRenderableEntity first;
private LayoutableRenderableEntity second;
@Builder.Default
private Point preferredLocation = new Point();
@Builder.Default
private Dimension preferredSize = new Dimension(ComponentConstants.STANDARD_WIDTH, 0);
@Builder.Default
private ComponentOrientation orientation = ComponentOrientation.VERTICAL;
@Builder.Default
private Point gap = new Point(0, 0);
private LayoutableRenderableEntity first;
private LayoutableRenderableEntity second;
@Builder.Default
@Getter
private final Rectangle bounds = new Rectangle();
@Override
public Dimension render(Graphics2D graphics)
{
graphics.translate(preferredLocation.x, preferredLocation.y);
first.setPreferredLocation(preferredLocation);
first.setPreferredSize(preferredSize);
first.setPreferredLocation(new Point(0, 0));
final Dimension firstDimenson = first.render(graphics);
final Dimension firstDimension = first.render(graphics);
int x = 0, y = 0;
if (orientation == ComponentOrientation.VERTICAL)
{
y = firstDimenson.height + gap.y;
y = firstDimension.height + gap.y;
}
else
{
x = firstDimenson.width + gap.x;
x = firstDimension.width + gap.x;
}
second.setPreferredLocation(new Point(x, y));
second.setPreferredLocation(new Point(x + preferredLocation.x, y + preferredLocation.y));
// Make the second component fit to whatever size is left after the first component is rendered
second.setPreferredSize(new Dimension(preferredSize.width - x, preferredSize.height - y));
@@ -76,21 +85,18 @@ public class SplitComponent implements LayoutableRenderableEntity
if (orientation == ComponentOrientation.VERTICAL)
{
totalWidth = Math.max(firstDimenson.width, secondDimension.width);
totalWidth = Math.max(firstDimension.width, secondDimension.width);
totalHeight = y + secondDimension.height;
}
else
{
totalHeight = Math.max(firstDimenson.height, secondDimension.height);
totalHeight = Math.max(firstDimension.height, secondDimension.height);
totalWidth = x + secondDimension.width;
}
graphics.translate(-preferredLocation.x, -preferredLocation.y);
return new Dimension(totalWidth, totalHeight);
final Dimension dimension = new Dimension(totalWidth, totalHeight);
bounds.setLocation(preferredLocation);
bounds.setSize(dimension);
return dimension;
}
@Override
public Rectangle getBounds() {
return null;
}
}
}

View File

@@ -38,6 +38,7 @@ import net.runelite.api.Client;
import net.runelite.client.config.RuneLiteConfig;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.ComponentOrientation;
import net.runelite.client.ui.overlay.components.InfoBoxComponent;
import net.runelite.client.ui.overlay.components.LayoutableRenderableEntity;
import net.runelite.client.ui.overlay.components.PanelComponent;
@@ -84,8 +85,8 @@ public class InfoBoxOverlay extends Overlay
panelComponent.getChildren().clear();
panelComponent.setWrapping(config.infoBoxWrap());
panelComponent.setOrientation(config.infoBoxVertical()
? PanelComponent.Orientation.VERTICAL
: PanelComponent.Orientation.HORIZONTAL);
? ComponentOrientation.VERTICAL
: ComponentOrientation.HORIZONTAL);
panelComponent.setPreferredSize(new Dimension(config.infoBoxSize(), config.infoBoxSize()));
for (InfoBox box : infoBoxes)

View File

@@ -6,13 +6,15 @@
iconst 1
iconst 0
sconst "scrollWheelZoom"
runelite_callback
runelite_callback
if_icmpeq LABEL18
iconst 0
iload 0
iconst 25
multiply
sub
sconst "scrollWheelZoomIncrement"
runelite_callback
multiply
sub
istore 1
iconst 512
istore 2
@@ -28,21 +30,21 @@ LABEL14:
if_icmpne LABEL18
jump LABEL19
LABEL18:
return
return
LABEL19:
viewport_getfov
viewport_getfov
istore 2
istore 3
iload 3
iload 1
add
add
istore 3
iload 2
iload 1
add
add
istore 2
iload 3
iload 2
invoke 42
LABEL33:
return
return