Merge remote-tracking branch 'upstream/master' into master
This commit is contained in:
@@ -124,6 +124,11 @@ public class SkillChallengeClue extends ClueScroll implements NpcClueScroll, Nam
|
||||
item(ItemID.CRYSTAL_HARPOON_INACTIVE)
|
||||
);
|
||||
|
||||
private static final AnyRequirementCollection ANY_HAMMER = any("Hammer",
|
||||
item(ItemID.HAMMER),
|
||||
item(ItemID.IMCANDO_HAMMER)
|
||||
);
|
||||
|
||||
private static final Set<SkillChallengeClue> CLUES = ImmutableSet.of(
|
||||
// Charlie Tasks
|
||||
new SkillChallengeClue("Cook a Pike", "i need to cook charlie a pike.", "i need to take the cooked pike to charlie.", item(ItemID.PIKE), item(ItemID.RAW_PIKE)),
|
||||
@@ -133,7 +138,7 @@ public class SkillChallengeClue extends ClueScroll implements NpcClueScroll, Nam
|
||||
new SkillChallengeClue("Fish a Herring", "i need to fish charlie a herring.", "i need to take a raw herring to charlie.", item(ItemID.RAW_HERRING), any("Fishing rod", item(ItemID.FISHING_ROD), item(ItemID.PEARL_FISHING_ROD)), item(ItemID.FISHING_BAIT)),
|
||||
new SkillChallengeClue("Fish a Trout", "i need to fish charlie a trout.", "i need to take a raw trout to charlie.", item(ItemID.RAW_TROUT), any("Fly fishing rod", item(ItemID.FLY_FISHING_ROD), item(ItemID.PEARL_FLY_FISHING_ROD)), item(ItemID.FEATHER)),
|
||||
new SkillChallengeClue("Mine a piece of Iron Ore", "i need to mine charlie a piece of iron ore from an iron vein.", "i need to take the iron ore to charlie.", item(ItemID.IRON_ORE), ANY_PICKAXE),
|
||||
new SkillChallengeClue("Smith an Iron Dagger", "i need to smith charlie one iron dagger.", "i need to take the iron dagger i smithed to charlie.", item(ItemID.IRON_DAGGER), item(ItemID.IRON_BAR), item(ItemID.HAMMER)),
|
||||
new SkillChallengeClue("Smith an Iron Dagger", "i need to smith charlie one iron dagger.", "i need to take the iron dagger i smithed to charlie.", item(ItemID.IRON_DAGGER), item(ItemID.IRON_BAR), ANY_HAMMER),
|
||||
// Elite Sherlock Tasks
|
||||
new SkillChallengeClue("Equip a Dragon Scimitar.", true, any("Any Dragon Scimitar", item(ItemID.DRAGON_SCIMITAR), item(ItemID.DRAGON_SCIMITAR_OR))),
|
||||
new SkillChallengeClue("Enchant some Dragonstone Jewellery.", "enchant a piece of dragonstone jewellery.",
|
||||
@@ -153,7 +158,7 @@ public class SkillChallengeClue extends ClueScroll implements NpcClueScroll, Nam
|
||||
new SkillChallengeClue("Catch a black warlock.", item(ItemID.BUTTERFLY_JAR), any("Butterfly Net", item(ItemID.BUTTERFLY_NET), item(ItemID.MAGIC_BUTTERFLY_NET))),
|
||||
new SkillChallengeClue("Catch a red chinchompa.", item(ItemID.BOX_TRAP)),
|
||||
new SkillChallengeClue("Mine a mithril ore.", ANY_PICKAXE),
|
||||
new SkillChallengeClue("Smith a mithril 2h sword.", item(ItemID.HAMMER), xOfItem(ItemID.MITHRIL_BAR, 3)),
|
||||
new SkillChallengeClue("Smith a mithril 2h sword.", ANY_HAMMER, xOfItem(ItemID.MITHRIL_BAR, 3)),
|
||||
new SkillChallengeClue("Catch a raw shark.", ANY_HARPOON),
|
||||
new SkillChallengeClue("Cut a yew log.", ANY_AXE),
|
||||
new SkillChallengeClue("Fix a magical lamp in Dorgesh-Kaan.", new String[] { "Broken lamp" }, new int[] { 10834, 10835 }, item(ItemID.LIGHT_ORB)),
|
||||
@@ -165,7 +170,7 @@ public class SkillChallengeClue extends ClueScroll implements NpcClueScroll, Nam
|
||||
new SkillChallengeClue("Hand in a Tier 2 or higher set of Shayzien supply armour. (Requires 11 lovakite bars)", "take the lovakengj armourers a boxed set of shayzien supply armour at tier 2 or above.", any("Shayzien Supply Set (Tier 2 or higher)", item(ItemID.SHAYZIEN_SUPPLY_SET_2), item(ItemID.SHAYZIEN_SUPPLY_SET_3), item(ItemID.SHAYZIEN_SUPPLY_SET_4), item(ItemID.SHAYZIEN_SUPPLY_SET_5))),
|
||||
// Master Sherlock Tasks
|
||||
new SkillChallengeClue("Equip an abyssal whip in front of the abyssal demons of the Slayer Tower.", true, any("Abyssal Whip", item(ItemID.ABYSSAL_WHIP), item(ItemID.FROZEN_ABYSSAL_WHIP), item(ItemID.VOLCANIC_ABYSSAL_WHIP))),
|
||||
new SkillChallengeClue("Smith a runite med helm.", item(ItemID.HAMMER), item(ItemID.RUNITE_BAR)),
|
||||
new SkillChallengeClue("Smith a runite med helm.", ANY_HAMMER, item(ItemID.RUNITE_BAR)),
|
||||
new SkillChallengeClue("Teleport to a spirit tree you planted yourself."),
|
||||
new SkillChallengeClue("Create a Barrows teleport tablet.", item(ItemID.DARK_ESSENCE_BLOCK), xOfItem(ItemID.BLOOD_RUNE, 1), xOfItem(ItemID.LAW_RUNE, 2), xOfItem(ItemID.SOUL_RUNE, 2)),
|
||||
new SkillChallengeClue("Kill a Nechryael in the Slayer Tower.", "slay a nechryael in the slayer tower."),
|
||||
|
||||
@@ -139,17 +139,6 @@ public interface FriendsChatConfig extends Config
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "clanTabChat",
|
||||
name = "Tab Chat",
|
||||
description = "Message friends chat without appending '/' when the friends chat tab is selected.",
|
||||
position = 9
|
||||
)
|
||||
default boolean friendsChatTabChat()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "confirmKicks",
|
||||
name = "Confirm Kicks",
|
||||
|
||||
@@ -96,8 +96,6 @@ import net.runelite.client.util.Text;
|
||||
public class FriendsChatPlugin extends Plugin
|
||||
{
|
||||
private static final int MAX_CHATS = 10;
|
||||
private static final String TITLE = "FC";
|
||||
private static final String RECENT_TITLE = "Recent FCs";
|
||||
private static final int MESSAGE_DELAY = 10;
|
||||
|
||||
@Inject
|
||||
@@ -284,27 +282,16 @@ public class FriendsChatPlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
Widget chatTitleWidget = client.getWidget(WidgetInfo.FRIENDS_CHAT_TITLE);
|
||||
if (chatTitleWidget != null)
|
||||
Widget chatList = client.getWidget(WidgetInfo.FRIENDS_CHAT_LIST);
|
||||
if (chatList != null)
|
||||
{
|
||||
Widget chatList = client.getWidget(WidgetInfo.FRIENDS_CHAT_LIST);
|
||||
Widget owner = client.getWidget(WidgetInfo.FRIENDS_CHAT_OWNER);
|
||||
FriendsChatManager friendsChatManager = client.getFriendsChatManager();
|
||||
if (friendsChatManager != null && friendsChatManager.getCount() > 0)
|
||||
if ((friendsChatManager == null || friendsChatManager.getCount() <= 0)
|
||||
&& chatList.getChildren() == null && !Strings.isNullOrEmpty(owner.getText())
|
||||
&& config.recentChats())
|
||||
{
|
||||
chatTitleWidget.setText(TITLE + " (" + friendsChatManager.getCount() + "/100)");
|
||||
}
|
||||
else if (chatList.getChildren() == null && !Strings.isNullOrEmpty(owner.getText()))
|
||||
{
|
||||
if (config.recentChats())
|
||||
{
|
||||
chatTitleWidget.setText(RECENT_TITLE);
|
||||
loadFriendsChats();
|
||||
}
|
||||
else
|
||||
{
|
||||
chatTitleWidget.setText(TITLE);
|
||||
}
|
||||
loadFriendsChats();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -542,15 +529,6 @@ public class FriendsChatPlugin extends Plugin
|
||||
{
|
||||
switch (scriptCallbackEvent.getEventName())
|
||||
{
|
||||
case "friendsChatInput":
|
||||
{
|
||||
final int[] intStack = client.getIntStack();
|
||||
final int size = client.getIntStackSize();
|
||||
// If the user accidentally adds a / when the config and the friends chat chat tab is active, handle it like a normal message
|
||||
boolean alterDispatch = config.friendsChatTabChat() && !client.getVar(VarClientStr.CHATBOX_TYPED_TEXT).startsWith("/");
|
||||
intStack[size - 1] = alterDispatch ? 1 : 0;
|
||||
break;
|
||||
}
|
||||
case "confirmFriendsChatKick":
|
||||
{
|
||||
if (!config.confirmKicks() || kickConfirmed)
|
||||
@@ -614,7 +592,6 @@ public class FriendsChatPlugin extends Plugin
|
||||
private void resetChats()
|
||||
{
|
||||
Widget chatList = client.getWidget(WidgetInfo.FRIENDS_CHAT_LIST);
|
||||
Widget chatTitleWidget = client.getWidget(WidgetInfo.FRIENDS_CHAT_TITLE);
|
||||
|
||||
if (chatList == null)
|
||||
{
|
||||
@@ -626,8 +603,6 @@ public class FriendsChatPlugin extends Plugin
|
||||
{
|
||||
chatList.setChildren(null);
|
||||
}
|
||||
|
||||
chatTitleWidget.setText(TITLE);
|
||||
}
|
||||
|
||||
private void loadFriendsChats()
|
||||
|
||||
@@ -218,7 +218,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
|
||||
private int textureArrayId;
|
||||
|
||||
private final GLBuffer uniformBuffer = new GLBuffer();
|
||||
private final float[] textureOffsets = new float[128];
|
||||
private final float[] textureOffsets = new float[256];
|
||||
|
||||
private GpuIntBuffer vertexBuffer;
|
||||
private GpuFloatBuffer uvBuffer;
|
||||
@@ -1198,7 +1198,7 @@ public class GpuPlugin extends Plugin implements DrawCallbacks
|
||||
// Bind uniforms
|
||||
gl.glUniformBlockBinding(glProgram, uniBlockMain, 0);
|
||||
gl.glUniform1i(uniTextures, 1); // texture sampler array is bound to texture1
|
||||
gl.glUniform2fv(uniTextureOffsets, 128, textureOffsets, 0);
|
||||
gl.glUniform2fv(uniTextureOffsets, textureOffsets.length, textureOffsets, 0);
|
||||
|
||||
// We just allow the GL to do face culling. Note this requires the priority renderer
|
||||
// to have logic to disregard culled faces in the priority depth testing.
|
||||
|
||||
@@ -30,6 +30,7 @@ import lombok.Data;
|
||||
class XpAction
|
||||
{
|
||||
private int actions = 0;
|
||||
private int actionsSinceReset = 0;
|
||||
private boolean actionsHistoryInitialized = false;
|
||||
private int[] actionExps = new int[10];
|
||||
private int actionExpIndex = 0;
|
||||
|
||||
@@ -135,6 +135,10 @@ class XpInfoBox extends JPanel
|
||||
final JMenuItem resetOthers = new JMenuItem("Reset others");
|
||||
resetOthers.addActionListener(e -> xpTrackerPlugin.resetOtherSkillState(skill));
|
||||
|
||||
// Create reset per hour menu
|
||||
final JMenuItem resetPerHour = new JMenuItem("Reset/hr");
|
||||
resetPerHour.addActionListener(e -> xpTrackerPlugin.resetSkillPerHourState(skill));
|
||||
|
||||
// Create reset others menu
|
||||
pauseSkill.addActionListener(e -> xpTrackerPlugin.pauseSkill(skill, !paused));
|
||||
|
||||
@@ -144,6 +148,7 @@ class XpInfoBox extends JPanel
|
||||
popupMenu.add(openXpTracker);
|
||||
popupMenu.add(reset);
|
||||
popupMenu.add(resetOthers);
|
||||
popupMenu.add(resetPerHour);
|
||||
popupMenu.add(pauseSkill);
|
||||
popupMenu.add(canvasItem);
|
||||
popupMenu.addPopupMenuListener(new PopupMenuListener()
|
||||
|
||||
@@ -90,6 +90,10 @@ class XpPanel extends PluginPanel
|
||||
final JMenuItem reset = new JMenuItem("Reset All");
|
||||
reset.addActionListener(e -> xpTrackerPlugin.resetAndInitState());
|
||||
|
||||
// Create reset all per hour menu
|
||||
final JMenuItem resetPerHour = new JMenuItem("Reset All/hr");
|
||||
resetPerHour.addActionListener(e -> xpTrackerPlugin.resetAllSkillsPerHourState());
|
||||
|
||||
// Create pause all menu
|
||||
final JMenuItem pauseAll = new JMenuItem("Pause All");
|
||||
pauseAll.addActionListener(e -> xpTrackerPlugin.pauseAllSkills(true));
|
||||
@@ -104,6 +108,7 @@ class XpPanel extends PluginPanel
|
||||
popupMenu.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
popupMenu.add(openXpTracker);
|
||||
popupMenu.add(reset);
|
||||
popupMenu.add(resetPerHour);
|
||||
popupMenu.add(pauseAll);
|
||||
popupMenu.add(unpauseAll);
|
||||
overallPanel.setComponentPopupMenu(popupMenu);
|
||||
|
||||
@@ -24,15 +24,17 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.xptracker;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
import lombok.NonNull;
|
||||
import net.runelite.api.NPC;
|
||||
import net.runelite.api.Skill;
|
||||
|
||||
/**
|
||||
* Internal state for the XpTrackerPlugin
|
||||
*
|
||||
* <p>
|
||||
* Note: This class's operations are not currently synchronized.
|
||||
* It is intended to be called by the XpTrackerPlugin on the client thread.
|
||||
*/
|
||||
@@ -43,6 +45,9 @@ class XpState
|
||||
private final Map<Skill, XpStateSingle> xpSkills = new EnumMap<>(Skill.class);
|
||||
private NPC interactedNPC;
|
||||
|
||||
@Inject
|
||||
private XpTrackerConfig xpTrackerConfig;
|
||||
|
||||
/**
|
||||
* Destroys all internal state, however any XpSnapshotSingle or XpSnapshotTotal remain unaffected.
|
||||
*/
|
||||
@@ -53,7 +58,8 @@ class XpState
|
||||
|
||||
/**
|
||||
* Resets a single skill
|
||||
* @param skill Skill to reset
|
||||
*
|
||||
* @param skill Skill to reset
|
||||
* @param currentXp Current XP to set to, if unknown set to -1
|
||||
*/
|
||||
void resetSkill(Skill skill, long currentXp)
|
||||
@@ -62,15 +68,26 @@ class XpState
|
||||
xpSkills.put(skill, new XpStateSingle(skill, currentXp));
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the per hour rates of a single skill
|
||||
*
|
||||
* @param skill Skill to reset per hour rates
|
||||
*/
|
||||
void resetSkillPerHour(Skill skill)
|
||||
{
|
||||
xpSkills.get(skill).resetPerHour();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a skill with the current known XP.
|
||||
* When the result of this operation is XpUpdateResult.UPDATED, the UI should be updated accordingly.
|
||||
* This is to distinguish events that reload all the skill's current values (such as world hopping)
|
||||
* and also first-login when the skills are not initialized (the start XP will be -1 in this case).
|
||||
* @param skill Skill to update
|
||||
* @param currentXp Current known XP for this skill
|
||||
*
|
||||
* @param skill Skill to update
|
||||
* @param currentXp Current known XP for this skill
|
||||
* @param goalStartXp Possible XP start goal
|
||||
* @param goalEndXp Possible XP end goal
|
||||
* @param goalEndXp Possible XP end goal
|
||||
* @return Whether or not the skill has been initialized, there was no change, or it has been updated
|
||||
*/
|
||||
XpUpdateResult updateSkill(Skill skill, long currentXp, int goalStartXp, int goalEndXp)
|
||||
@@ -92,7 +109,7 @@ class XpState
|
||||
else
|
||||
{
|
||||
long startXp = state.getStartXp();
|
||||
int gainedXp = state.getXpGained();
|
||||
int gainedXp = state.getTotalXpGained();
|
||||
|
||||
if (startXp + gainedXp > currentXp)
|
||||
{
|
||||
@@ -119,8 +136,9 @@ class XpState
|
||||
|
||||
/**
|
||||
* Updates skill with average actions based on currently interacted NPC.
|
||||
* @param skill experience gained skill
|
||||
* @param npc currently interacted NPC
|
||||
*
|
||||
* @param skill experience gained skill
|
||||
* @param npc currently interacted NPC
|
||||
* @param npcHealth health of currently interacted NPC
|
||||
*/
|
||||
void updateNpcExperience(Skill skill, NPC npc, Integer npcHealth, int xpModifier)
|
||||
@@ -146,10 +164,7 @@ class XpState
|
||||
else
|
||||
{
|
||||
// So we have a decent average off the bat, lets populate all values with what we see.
|
||||
for (int i = 0; i < action.getActionExps().length; i++)
|
||||
{
|
||||
action.getActionExps()[i] = actionExp;
|
||||
}
|
||||
Arrays.fill(action.getActionExps(), actionExp);
|
||||
|
||||
action.setActionsHistoryInitialized(true);
|
||||
}
|
||||
@@ -161,8 +176,9 @@ class XpState
|
||||
/**
|
||||
* Update number of actions performed for skill if last interacted NPC died.
|
||||
* (eg. amount of kills in this case)
|
||||
* @param skill skill to update actions for
|
||||
* @param npc npc that just died
|
||||
*
|
||||
* @param skill skill to update actions for
|
||||
* @param npc npc that just died
|
||||
* @param npcHealth max health of npc that just died
|
||||
* @return UPDATED in case new kill was successfully added
|
||||
*/
|
||||
@@ -170,25 +186,41 @@ class XpState
|
||||
{
|
||||
XpStateSingle state = getSkill(skill);
|
||||
|
||||
if (state.getXpGained() <= 0 || npcHealth == null || npc != interactedNPC)
|
||||
if (state.getXpGainedSinceReset() <= 0 || npcHealth == null || npc != interactedNPC)
|
||||
{
|
||||
return XpUpdateResult.NO_CHANGE;
|
||||
}
|
||||
|
||||
final XpAction xpAction = state.getXpAction(XpActionType.ACTOR_HEALTH);
|
||||
xpAction.setActions(xpAction.getActions() + 1);
|
||||
xpAction.setActionsSinceReset(xpAction.getActionsSinceReset() + 1);
|
||||
return xpAction.isActionsHistoryInitialized() ? XpUpdateResult.UPDATED : XpUpdateResult.NO_CHANGE;
|
||||
}
|
||||
|
||||
void tick(Skill skill, long delta)
|
||||
{
|
||||
getSkill(skill).tick(delta);
|
||||
final XpStateSingle state = getSkill(skill);
|
||||
|
||||
state.tick(delta);
|
||||
|
||||
int resetAfterMinutes = xpTrackerConfig.resetSkillRateAfter();
|
||||
if (resetAfterMinutes > 0)
|
||||
{
|
||||
final long now = System.currentTimeMillis();
|
||||
final int resetAfterMillis = resetAfterMinutes * 60 * 1000;
|
||||
final long lastChangeMillis = state.getLastChangeMillis();
|
||||
// When pauseSkillAfter is 0, it is effectively disabled
|
||||
if (lastChangeMillis != 0 && (now - lastChangeMillis) >= resetAfterMillis)
|
||||
{
|
||||
state.resetPerHour();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Forcefully initialize a skill with a known start XP from the current XP.
|
||||
* This is used in resetAndInitState by the plugin. It should not result in showing the XP in the UI.
|
||||
* @param skill Skill to initialize
|
||||
*
|
||||
* @param skill Skill to initialize
|
||||
* @param currentXp Current known XP for the skill
|
||||
*/
|
||||
void initializeSkill(Skill skill, long currentXp)
|
||||
@@ -211,6 +243,7 @@ class XpState
|
||||
/**
|
||||
* Obtain an immutable snapshot of the provided skill
|
||||
* intended for use with the UI which operates on another thread
|
||||
*
|
||||
* @param skill Skill to obtain the snapshot for
|
||||
* @return An immutable snapshot of the specified skill for this session since first login or last reset
|
||||
*/
|
||||
@@ -223,6 +256,7 @@ class XpState
|
||||
/**
|
||||
* Obtain an immutable snapshot of the provided skill
|
||||
* intended for use with the UI which operates on another thread
|
||||
*
|
||||
* @return An immutable snapshot of total information for this session since first login or last reset
|
||||
*/
|
||||
@NonNull
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.xptracker;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -38,19 +39,25 @@ import net.runelite.api.Skill;
|
||||
class XpStateSingle
|
||||
{
|
||||
private final Skill skill;
|
||||
private final Map<XpActionType, XpAction> actions = new HashMap<>();
|
||||
private final Map<XpActionType, XpAction> actions = new EnumMap<>(XpActionType.class);
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private long startXp;
|
||||
|
||||
@Getter
|
||||
private int xpGained = 0;
|
||||
private int xpGainedSinceReset = 0;
|
||||
|
||||
private int xpGainedBeforeReset = 0;
|
||||
|
||||
@Setter
|
||||
private XpActionType actionType = XpActionType.EXPERIENCE;
|
||||
|
||||
@Setter
|
||||
private long skillTime = 0;
|
||||
@Getter
|
||||
private long lastChangeMillis;
|
||||
|
||||
private int startLevelExp = 0;
|
||||
private int endLevelExp = 0;
|
||||
|
||||
@@ -62,18 +69,28 @@ class XpStateSingle
|
||||
|
||||
XpAction getXpAction(final XpActionType type)
|
||||
{
|
||||
actions.putIfAbsent(type, new XpAction());
|
||||
return actions.get(type);
|
||||
return actions.computeIfAbsent(type, k -> new XpAction());
|
||||
}
|
||||
|
||||
long getCurrentXp()
|
||||
{
|
||||
return startXp + xpGained;
|
||||
return startXp + getTotalXpGained();
|
||||
}
|
||||
|
||||
void setXpGainedSinceReset(int xpGainedSinceReset)
|
||||
{
|
||||
this.xpGainedSinceReset = xpGainedSinceReset;
|
||||
lastChangeMillis = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
int getTotalXpGained()
|
||||
{
|
||||
return xpGainedBeforeReset + xpGainedSinceReset;
|
||||
}
|
||||
|
||||
private int getActionsHr()
|
||||
{
|
||||
return toHourly(getXpAction(actionType).getActions());
|
||||
return toHourly(getXpAction(actionType).getActionsSinceReset());
|
||||
}
|
||||
|
||||
private int toHourly(int value)
|
||||
@@ -131,12 +148,9 @@ class XpStateSingle
|
||||
|
||||
private long getSecondsTillLevel()
|
||||
{
|
||||
// Java 8 doesn't have good duration / period objects to represent spans of time that can be formatted
|
||||
// Rather than importing another dependency like joda time (which is practically built into java 10)
|
||||
// below will be a custom formatter that handles spans larger than 1 day
|
||||
long seconds = getTimeElapsedInSeconds();
|
||||
|
||||
if (seconds <= 0 || xpGained <= 0)
|
||||
if (seconds <= 0 || xpGainedSinceReset <= 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
@@ -144,7 +158,7 @@ class XpStateSingle
|
||||
// formula is xpRemaining / xpPerSecond
|
||||
// xpPerSecond being xpGained / seconds
|
||||
// This can be simplified so division is only done once and we can work in whole numbers!
|
||||
return (getXpRemaining() * seconds) / xpGained;
|
||||
return (getXpRemaining() * seconds) / xpGainedSinceReset;
|
||||
}
|
||||
|
||||
private String getTimeTillLevel(XpGoalTimeType goalTimeType)
|
||||
@@ -155,6 +169,9 @@ class XpStateSingle
|
||||
return "\u221e";
|
||||
}
|
||||
|
||||
// Java 8 doesn't have good duration / period objects to represent spans of time that can be formatted
|
||||
// Rather than importing another dependency like joda time (which is practically built into java 10)
|
||||
// below will be a custom formatter that handles spans larger than 1 day
|
||||
long durationDays = remainingSeconds / (24 * 60 * 60);
|
||||
long durationHours = (remainingSeconds % (24 * 60 * 60)) / (60 * 60);
|
||||
long durationHoursTotal = remainingSeconds / (60 * 60);
|
||||
@@ -197,18 +214,33 @@ class XpStateSingle
|
||||
|
||||
int getXpHr()
|
||||
{
|
||||
return toHourly(xpGained);
|
||||
return toHourly(xpGainedSinceReset);
|
||||
}
|
||||
|
||||
void resetPerHour()
|
||||
{
|
||||
//reset actions per hour
|
||||
for (XpAction action : actions.values())
|
||||
{
|
||||
action.setActions(action.getActions() + action.getActionsSinceReset());
|
||||
action.setActionsSinceReset(0);
|
||||
}
|
||||
|
||||
//reset xp per hour
|
||||
xpGainedBeforeReset += xpGainedSinceReset;
|
||||
setXpGainedSinceReset(0);
|
||||
setSkillTime(0);
|
||||
}
|
||||
|
||||
boolean update(long currentXp, int goalStartXp, int goalEndXp)
|
||||
{
|
||||
if (startXp == -1)
|
||||
{
|
||||
log.warn("Attempted to update skill state " + skill + " but was not initialized with current xp");
|
||||
log.warn("Attempted to update skill state {} but was not initialized with current xp", skill);
|
||||
return false;
|
||||
}
|
||||
|
||||
long originalXp = xpGained + startXp;
|
||||
long originalXp = getTotalXpGained() + startXp;
|
||||
int actionExp = (int) (currentXp - originalXp);
|
||||
|
||||
// No experience gained
|
||||
@@ -228,19 +260,16 @@ class XpStateSingle
|
||||
{
|
||||
// populate all values in our action history array with this first value that we see
|
||||
// so the average value of our action history starts out as this first value we see
|
||||
for (int i = 0; i < action.getActionExps().length; i++)
|
||||
{
|
||||
action.getActionExps()[i] = actionExp;
|
||||
}
|
||||
Arrays.fill(action.getActionExps(), actionExp);
|
||||
|
||||
action.setActionsHistoryInitialized(true);
|
||||
}
|
||||
|
||||
action.setActionExpIndex((action.getActionExpIndex() + 1) % action.getActionExps().length);
|
||||
action.setActions(action.getActions() + 1);
|
||||
action.setActionsSinceReset(action.getActionsSinceReset() + 1);
|
||||
|
||||
// Calculate experience gained
|
||||
xpGained = (int) (currentXp - startXp);
|
||||
setXpGainedSinceReset((int) (currentXp - (startXp + xpGainedBeforeReset)));
|
||||
|
||||
// Determine XP goals, overall has no goals
|
||||
if (skill != Skill.OVERALL)
|
||||
@@ -273,7 +302,7 @@ class XpStateSingle
|
||||
public void tick(long delta)
|
||||
{
|
||||
// Don't tick skills that have not gained XP or have been reset.
|
||||
if (xpGained <= 0)
|
||||
if (xpGainedSinceReset <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -285,12 +314,12 @@ class XpStateSingle
|
||||
return XpSnapshotSingle.builder()
|
||||
.startLevel(Experience.getLevelForXp(startLevelExp))
|
||||
.endLevel(Experience.getLevelForXp(endLevelExp))
|
||||
.xpGainedInSession(xpGained)
|
||||
.xpGainedInSession(getTotalXpGained())
|
||||
.xpRemainingToGoal(getXpRemaining())
|
||||
.xpPerHour(getXpHr())
|
||||
.skillProgressToGoal(getSkillProgress())
|
||||
.actionType(actionType)
|
||||
.actionsInSession(getXpAction(actionType).getActions())
|
||||
.actionsInSession(getXpAction(actionType).getActions() + getXpAction(actionType).getActionsSinceReset())
|
||||
.actionsRemainingToGoal(getActionsRemaining())
|
||||
.actionsPerHour(getActionsHr())
|
||||
.timeTillGoal(getTimeTillLevel(XpGoalTimeType.DAYS))
|
||||
|
||||
@@ -88,6 +88,18 @@ public interface XpTrackerConfig extends Config
|
||||
|
||||
@ConfigItem(
|
||||
position = 4,
|
||||
keyName = "resetSkillRateAfter",
|
||||
name = "Auto reset after",
|
||||
description = "Configures how many minutes passes before resetting a skill's per hour rates while in game and there's no XP, 0 means disabled"
|
||||
)
|
||||
@Units(Units.MINUTES)
|
||||
default int resetSkillRateAfter()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 5,
|
||||
keyName = "skillTabOverlayMenuOptions",
|
||||
name = "Add skill tab canvas menu option",
|
||||
description = "Configures whether a menu option to show/hide canvas XP trackers will be added to skills on the skill tab",
|
||||
@@ -99,7 +111,7 @@ public interface XpTrackerConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 5,
|
||||
position = 6,
|
||||
keyName = "onScreenDisplayMode",
|
||||
name = "On-screen tracker display mode (top)",
|
||||
description = "Configures the information displayed in the first line of on-screen XP overlays",
|
||||
@@ -111,7 +123,7 @@ public interface XpTrackerConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 6,
|
||||
position = 7,
|
||||
keyName = "onScreenDisplayModeBottom",
|
||||
name = "On-screen tracker display mode (bottom)",
|
||||
description = "Configures the information displayed in the second line of on-screen XP overlays",
|
||||
@@ -123,7 +135,7 @@ public interface XpTrackerConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 7,
|
||||
position = 8,
|
||||
keyName = "xpPanelLabel1",
|
||||
name = "Top-left XP info label",
|
||||
description = "Configures the information displayed in the top-left of XP info box"
|
||||
@@ -134,7 +146,7 @@ public interface XpTrackerConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 8,
|
||||
position = 9,
|
||||
keyName = "xpPanelLabel2",
|
||||
name = "Top-right XP info label",
|
||||
description = "Configures the information displayed in the top-right of XP info box"
|
||||
@@ -146,7 +158,7 @@ public interface XpTrackerConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 9,
|
||||
position = 10,
|
||||
keyName = "xpPanelLabel3",
|
||||
name = "Bottom-left XP info label",
|
||||
description = "Configures the information displayed in the bottom-left of XP info box"
|
||||
@@ -157,7 +169,7 @@ public interface XpTrackerConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 10,
|
||||
position = 11,
|
||||
keyName = "xpPanelLabel4",
|
||||
name = "Bottom-right XP info label",
|
||||
description = "Configures the information displayed in the bottom-right of XP info box"
|
||||
@@ -168,7 +180,7 @@ public interface XpTrackerConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 11,
|
||||
position = 12,
|
||||
keyName = "progressBarLabel",
|
||||
name = "Progress bar label",
|
||||
description = "Configures the info box progress bar to show Time to goal or percentage complete"
|
||||
@@ -179,7 +191,7 @@ public interface XpTrackerConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 12,
|
||||
position = 13,
|
||||
keyName = "progressBarTooltipLabel",
|
||||
name = "Tooltip label",
|
||||
description = "Configures the info box progress bar tooltip to show Time to goal or percentage complete"
|
||||
@@ -190,7 +202,7 @@ public interface XpTrackerConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 13,
|
||||
position = 14,
|
||||
keyName = "prioritizeRecentXpSkills",
|
||||
name = "Move recently trained skills to top",
|
||||
description = "Configures whether skills should be organized by most recently gained xp"
|
||||
|
||||
@@ -120,6 +120,9 @@ public class XpTrackerPlugin extends Plugin
|
||||
@Inject
|
||||
private XpClient xpClient;
|
||||
|
||||
@Inject
|
||||
private XpState xpState;
|
||||
|
||||
private NavigationButton navButton;
|
||||
@Setter(AccessLevel.PACKAGE)
|
||||
@VisibleForTesting
|
||||
@@ -131,7 +134,6 @@ public class XpTrackerPlugin extends Plugin
|
||||
private long lastXp = 0;
|
||||
private boolean initializeTracker;
|
||||
|
||||
private final XpState xpState = new XpState();
|
||||
private final XpPauseState xpPauseState = new XpPauseState();
|
||||
|
||||
@Provides
|
||||
@@ -323,6 +325,7 @@ public class XpTrackerPlugin extends Plugin
|
||||
/**
|
||||
* Reset an individual skill with the client's current known state of the skill
|
||||
* Will also clear the skill from the UI.
|
||||
*
|
||||
* @param skill Skill to reset
|
||||
*/
|
||||
void resetSkillState(Skill skill)
|
||||
@@ -335,6 +338,7 @@ public class XpTrackerPlugin extends Plugin
|
||||
|
||||
/**
|
||||
* Reset all skills except for the one provided
|
||||
*
|
||||
* @param skill Skill to ignore during reset
|
||||
*/
|
||||
void resetOtherSkillState(Skill skill)
|
||||
@@ -349,6 +353,29 @@ public class XpTrackerPlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the xp gained since last reset of the skill
|
||||
* Does not clear the skill from the UI.
|
||||
*
|
||||
* @param skill Skill to reset per hour rate
|
||||
*/
|
||||
void resetSkillPerHourState(Skill skill)
|
||||
{
|
||||
xpState.resetSkillPerHour(skill);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the xp gained since last reset of all skills including OVERALL
|
||||
* Does not clear the UI.
|
||||
*/
|
||||
void resetAllSkillsPerHourState()
|
||||
{
|
||||
for (Skill skill : Skill.values())
|
||||
{
|
||||
resetSkillPerHourState(skill);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onStatChanged(StatChanged statChanged)
|
||||
{
|
||||
@@ -377,7 +404,7 @@ public class XpTrackerPlugin extends Plugin
|
||||
final Actor interacting = client.getLocalPlayer().getInteracting();
|
||||
if (interacting instanceof NPC && COMBAT.contains(skill))
|
||||
{
|
||||
final int xpModifier = worldSetToType(client.getWorldType()).modifier(client);;
|
||||
final int xpModifier = worldSetToType(client.getWorldType()).modifier(client);
|
||||
final NPC npc = (NPC) interacting;
|
||||
xpState.updateNpcExperience(skill, npc, npcManager.getHealth(npc.getId()), xpModifier);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user