xp tracker: expose xp stats
This commit is contained in:
@@ -49,7 +49,7 @@ class XpPanel extends PluginPanel
|
||||
private final JLabel totalXpGained = new JLabel();
|
||||
private final JLabel totalXpHr = new JLabel();
|
||||
|
||||
XpPanel(Client client, SkillIconManager iconManager)
|
||||
XpPanel(XpTrackerPlugin xpTrackerPlugin, Client client, SkillIconManager iconManager)
|
||||
{
|
||||
super();
|
||||
|
||||
@@ -90,7 +90,7 @@ class XpPanel extends PluginPanel
|
||||
break;
|
||||
}
|
||||
|
||||
infoBoxes.put(skill, new XpInfoBox(client, infoBoxPanel, new SkillXPInfo(skill), iconManager));
|
||||
infoBoxes.put(skill, new XpInfoBox(client, infoBoxPanel, xpTrackerPlugin.getSkillXpInfo(skill), iconManager));
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
|
||||
@@ -24,10 +24,12 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.xptracker;
|
||||
|
||||
import static net.runelite.client.plugins.xptracker.XpWorldType.NORMAL;
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.google.inject.Binder;
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import javax.imageio.ImageIO;
|
||||
@@ -36,12 +38,14 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.Player;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.api.events.ExperienceChanged;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.client.game.SkillIconManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import static net.runelite.client.plugins.xptracker.XpWorldType.NORMAL;
|
||||
import net.runelite.client.ui.ClientUI;
|
||||
import net.runelite.client.ui.NavigationButton;
|
||||
import net.runelite.http.api.worlds.World;
|
||||
@@ -70,12 +74,21 @@ public class XpTrackerPlugin extends Plugin
|
||||
|
||||
private NavigationButton navButton;
|
||||
private XpPanel xpPanel;
|
||||
|
||||
private final Map<Skill, SkillXPInfo> xpInfos = new HashMap<>();
|
||||
|
||||
private WorldResult worlds;
|
||||
private XpWorldType lastWorldType;
|
||||
private String lastUsername;
|
||||
|
||||
private final XpClient xpClient = new XpClient();
|
||||
|
||||
@Override
|
||||
public void configure(Binder binder)
|
||||
{
|
||||
binder.bind(XpTrackerService.class).to(XpTrackerServiceImpl.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
@@ -90,7 +103,7 @@ public class XpTrackerPlugin extends Plugin
|
||||
log.warn("Error looking up worlds list", e);
|
||||
}
|
||||
|
||||
xpPanel = new XpPanel(client, skillIconManager);
|
||||
xpPanel = new XpPanel(this, client, skillIconManager);
|
||||
navButton = new NavigationButton(
|
||||
"XP Tracker",
|
||||
ImageIO.read(getClass().getResourceAsStream("xp.png")),
|
||||
@@ -170,6 +183,11 @@ public class XpTrackerPlugin extends Plugin
|
||||
return xpType;
|
||||
}
|
||||
|
||||
public SkillXPInfo getSkillXpInfo(Skill skill)
|
||||
{
|
||||
return xpInfos.computeIfAbsent(skill, s -> new SkillXPInfo(s));
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onXpChanged(ExperienceChanged event)
|
||||
{
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* 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.xptracker;
|
||||
|
||||
import net.runelite.api.Skill;
|
||||
|
||||
public interface XpTrackerService
|
||||
{
|
||||
/**
|
||||
* Get the number of actions done
|
||||
* @param skill
|
||||
* @return
|
||||
*/
|
||||
int getActions(Skill skill);
|
||||
|
||||
/**
|
||||
* Get the number of actions per hour
|
||||
* @param skill
|
||||
* @return
|
||||
*/
|
||||
int getActionsHr(Skill skill);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
||||
* 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.xptracker;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import net.runelite.api.Skill;
|
||||
|
||||
@Singleton
|
||||
class XpTrackerServiceImpl implements XpTrackerService
|
||||
{
|
||||
private final XpTrackerPlugin plugin;
|
||||
|
||||
@Inject
|
||||
XpTrackerServiceImpl(XpTrackerPlugin plugin)
|
||||
{
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActions(Skill skill)
|
||||
{
|
||||
SkillXPInfo xpInfo = plugin.getSkillXpInfo(skill);
|
||||
return xpInfo.getActions();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActionsHr(Skill skill)
|
||||
{
|
||||
SkillXPInfo xpInfo = plugin.getSkillXpInfo(skill);
|
||||
return xpInfo.getActionsHr();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user