Add Motherlode plugin

This commit is contained in:
Seth
2018-01-24 19:29:29 -06:00
parent fdbd4237b9
commit 353b837206
9 changed files with 662 additions and 2 deletions

View File

@@ -175,7 +175,12 @@ public enum Varbits
/**
* Barbarian Assault
*/
IN_GAME_BA(3923, 638, 12, 12);
IN_GAME_BA(3923, 638, 12, 12),
/**
* Motherlode mine sack
*/
SACK_NUMBER(5558, 375, 8, 15);
/**
* varbit id

View File

@@ -59,6 +59,7 @@ public class WidgetID
public static final int QUEST_COMPLETED_GROUP_ID = 277;
public static final int CLUE_SCROLL_REWARD_GROUP_ID = 73;
public static final int BARROWS_REWARD_GROUP_ID = 155;
public static final int MOTHERLODE_MINE_GROUP_ID = 382;
static class WorldMap
{

View File

@@ -161,7 +161,9 @@ public enum WidgetInfo
LEVEL_UP_LEVEL(WidgetID.LEVEL_UP_GROUP_ID, WidgetID.LevelUp.LEVEL),
QUEST_COMPLETED(WidgetID.QUEST_COMPLETED_GROUP_ID, 0),
QUEST_COMPLETED_NAME_TEXT(WidgetID.QUEST_COMPLETED_GROUP_ID, WidgetID.QuestCompleted.NAME_TEXT);
QUEST_COMPLETED_NAME_TEXT(WidgetID.QUEST_COMPLETED_GROUP_ID, WidgetID.QuestCompleted.NAME_TEXT),
MOTHERLODE_MINE(WidgetID.MOTHERLODE_MINE_GROUP_ID, 0);
private final int groupId;
private final int childId;

View File

@@ -0,0 +1,77 @@
/*
* Copyright (c) 2016-2018, Seth <Sethtroll3@gmail.com>
* 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.motherlode;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@ConfigGroup(
keyName = "motherlode",
name = "Motherlode",
description = "Configuration for the motherlode plugin"
)
public interface MotherlodeConfig extends Config
{
@ConfigItem(
keyName = "enabled",
name = "Enable",
description = "Configures whether or not the motherlode plugin is displayed"
)
default boolean enabled()
{
return true;
}
@ConfigItem(
keyName = "showRocks",
name = "Show Pay-dirt mining spots",
description = "Configures whether or not the pay-dirt minings spots is displayed"
)
default boolean showRocks()
{
return true;
}
@ConfigItem(
keyName = "statTimeout",
name = "Reset stats (minutes)",
description = "Configures the time until statistic is reset"
)
default int statTimeout()
{
return 5;
}
@ConfigItem(
keyName = "showSack",
name = "Show Pay-dirt Sack",
description = "Configures whether to Pay-dirt sack is displayed"
)
default boolean showSack()
{
return true;
}
}

View File

@@ -0,0 +1,128 @@
/*
* Copyright (c) 2016-2018, Seth <Sethtroll3@gmail.com>
* 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.motherlode;
import net.runelite.api.Client;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.PanelComponent;
import javax.inject.Inject;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import java.time.Duration;
import java.time.Instant;
import java.util.Arrays;
import java.util.List;
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_ADAMANT;
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_BLACK;
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_BRONZE;
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_DRAGON;
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_DRAGON_ORN;
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_INFERNAL;
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_IRON;
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_MITHRIL;
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_RUNE;
import static net.runelite.api.AnimationID.MINING_MOTHERLODE_STEEL;
class MotherlodeOverlay extends Overlay
{
private static final List<Integer> MINING_ANIMATION_IDS = Arrays.asList
(
MINING_MOTHERLODE_BRONZE, MINING_MOTHERLODE_IRON, MINING_MOTHERLODE_STEEL,
MINING_MOTHERLODE_BLACK, MINING_MOTHERLODE_MITHRIL, MINING_MOTHERLODE_ADAMANT,
MINING_MOTHERLODE_RUNE, MINING_MOTHERLODE_DRAGON, MINING_MOTHERLODE_DRAGON_ORN,
MINING_MOTHERLODE_INFERNAL
);
private final Client client;
private final MotherlodePlugin plugin;
private final MotherlodeConfig config;
private final PanelComponent panelComponent = new PanelComponent();
@Inject
MotherlodeOverlay(Client client, MotherlodePlugin plugin, MotherlodeConfig config)
{
setPosition(OverlayPosition.TOP_LEFT);
this.client = client;
this.plugin = plugin;
this.config = config;
}
@Override
public Dimension render(Graphics2D graphics, Point parent)
{
if (!config.enabled())
{
return null;
}
MotherlodeSession session = plugin.getSession();
if (session.getLastPayDirtMined() == null)
{
return null;
}
Duration statTimeout = Duration.ofMinutes(config.statTimeout());
Duration sinceCut = Duration.between(session.getLastPayDirtMined(), Instant.now());
if (sinceCut.compareTo(statTimeout) >= 0)
{
return null;
}
panelComponent.getLines().clear();
if (MINING_ANIMATION_IDS.contains(client.getLocalPlayer().getAnimation()))
{
panelComponent.setTitle("You are mining");
panelComponent.setTitleColor(Color.GREEN);
}
else
{
panelComponent.setTitle("You are NOT mining");
panelComponent.setTitleColor(Color.RED);
}
panelComponent.getLines().add(new PanelComponent.Line(
"Pay-dirt mined:",
Integer.toString(session.getTotalMined())
));
panelComponent.getLines().add(new PanelComponent.Line(
"Pay-dirt/hr:",
session.getRecentMined() > 2
? Integer.toString(session.getPerHour())
: ""
));
return panelComponent.render(graphics, parent);
}
}

View File

@@ -0,0 +1,132 @@
/*
* Copyright (c) 2016-2018, Seth <Sethtroll3@gmail.com>
* 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.motherlode;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Binder;
import com.google.inject.Provides;
import lombok.Getter;
import net.runelite.api.ChatMessageType;
import net.runelite.api.events.ChatMessage;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.task.Schedule;
import net.runelite.client.ui.overlay.Overlay;
import javax.imageio.ImageIO;
import javax.inject.Inject;
import java.awt.image.BufferedImage;
import java.time.Duration;
import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.Collection;
@PluginDescriptor(
name = "Motherlode plugin"
)
public class MotherlodePlugin extends Plugin
{
@Getter
private BufferedImage mineIcon;
@Inject
MotherlodeOverlay overlay;
@Inject
MotherlodeRocksOverlay rocksOverlay;
@Inject
MotherlodeSackOverlay motherlodeSackOverlay;
@Inject
MotherlodeConfig config;
private final MotherlodeSession session = new MotherlodeSession();
@Override
public void configure(Binder binder)
{
binder.bind(MotherlodeOverlay.class);
}
@Provides
MotherlodeConfig getConfig(ConfigManager configManager)
{
return configManager.getConfig(MotherlodeConfig.class);
}
@Override
public Collection<Overlay> getOverlays()
{
return Arrays.asList(overlay, rocksOverlay, motherlodeSackOverlay);
}
@Override
protected void startUp() throws Exception
{
mineIcon = ImageIO.read(MotherlodePlugin.class.getResourceAsStream("/skill_icons/mining.png"));
}
public MotherlodeSession getSession()
{
return session;
}
@Subscribe
public void onChatMessage(ChatMessage event)
{
if (event.getType() == ChatMessageType.FILTERED)
{
if (event.getMessage().equals("You manage to mine some pay-dirt."))
{
session.incrementPayDirtMined();
}
}
}
@Schedule(
period = 1,
unit = ChronoUnit.SECONDS
)
public void checkMining()
{
Instant lastPayDirtMined = session.getLastPayDirtMined();
if (lastPayDirtMined == null)
{
return;
}
// reset recentPayDirtMined if you haven't mined anything recently
Duration statTimeout = Duration.ofMinutes(config.statTimeout());
Duration sinceMined = Duration.between(lastPayDirtMined, Instant.now());
if (sinceMined.compareTo(statTimeout) >= 0)
{
session.resetRecent();
}
}
}

View File

@@ -0,0 +1,142 @@
/*
* Copyright (c) 2016-2018, Seth <Sethtroll3@gmail.com>
* 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.motherlode;
import net.runelite.api.Client;
import net.runelite.api.GameObject;
import net.runelite.api.Perspective;
import net.runelite.api.Player;
import net.runelite.api.Region;
import net.runelite.api.Tile;
import net.runelite.api.WallObject;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayLayer;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.OverlayUtil;
import javax.inject.Inject;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Polygon;
import java.util.Arrays;
import java.util.List;
class MotherlodeRocksOverlay extends Overlay
{
private static final int REGION_SIZE = 104;
private static final int MAX_DISTANCE = 2350;
private static final List<Integer> MINE_SPOTS = Arrays.asList(26661, 26662, 26663, 26664);
private static final List<Integer> ROCK_OBSTACLES = Arrays.asList(26680, 26679);
private final Client client;
private final MotherlodePlugin plugin;
private final MotherlodeConfig config;
@Inject
MotherlodeRocksOverlay(Client client, MotherlodePlugin plugin, MotherlodeConfig config)
{
setPosition(OverlayPosition.DYNAMIC);
setLayer(OverlayLayer.UNDER_WIDGETS);
this.client = client;
this.plugin = plugin;
this.config = config;
}
@Override
public Dimension render(Graphics2D graphics, Point parent)
{
if (!config.enabled() || !config.showRocks())
{
return null;
}
Player local = client.getLocalPlayer();
//Render mining spot
renderTiles(graphics, local);
return null;
}
private void renderTiles(Graphics2D graphics, Player local)
{
Region region = client.getRegion();
Tile[][][] tiles = region.getTiles();
int z = client.getPlane();
for (int x = 0; x < REGION_SIZE; ++x)
{
for (int y = 0; y < REGION_SIZE; ++y)
{
Tile tile = tiles[z][x][y];
if (tile == null)
{
continue;
}
if (local.getLocalLocation().distanceTo(tile.getLocalLocation()) <= MAX_DISTANCE)
{
renderMine(graphics, tile);
}
}
}
}
private void renderMine(Graphics2D graphics, Tile tile)
{
//Draw the Pay-dirt spots
WallObject wallObject = tile.getWallObject();
if (wallObject != null && MINE_SPOTS.contains(wallObject.getId()))
{
net.runelite.api.Point canvasLoc = Perspective.getCanvasImageLocation(client, graphics, wallObject.getLocalLocation(), plugin.getMineIcon(), 150);
if (canvasLoc != null)
{
graphics.drawImage(plugin.getMineIcon(), canvasLoc.getX(), canvasLoc.getY(), null);
return;
}
}
//Draw the rock obstacles
GameObject[] gameObjects = tile.getGameObjects();
for (GameObject gameObject : gameObjects)
{
if (gameObject != null && ROCK_OBSTACLES.contains(gameObject.getId()))
{
Polygon poly = Perspective.getCanvasTilePoly(client, gameObject.getLocalLocation());
if (poly != null)
{
OverlayUtil.renderPolygon(graphics, poly, Color.red);
}
}
}
}
}

View File

@@ -0,0 +1,81 @@
/*
* Copyright (c) 2016-2018, Seth <Sethtroll3@gmail.com>
* 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.motherlode;
import net.runelite.api.Client;
import net.runelite.api.Varbits;
import net.runelite.api.widgets.Widget;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.PanelComponent;
import javax.inject.Inject;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
class MotherlodeSackOverlay extends Overlay
{
private final Client client;
private final MotherlodeConfig config;
private final PanelComponent panelComponent = new PanelComponent();
@Inject
MotherlodeSackOverlay(Client client, MotherlodeConfig config)
{
setPosition(OverlayPosition.TOP_LEFT);
this.client = client;
this.config = config;
}
@Override
public Dimension render(Graphics2D graphics, Point parent)
{
if (!config.enabled())
{
return null;
}
Widget sack = client.getWidget(WidgetInfo.MOTHERLODE_MINE);
panelComponent.getLines().clear();
if (sack != null)
{
sack.setHidden(true);
if (config.showSack())
{
panelComponent.getLines().add(new PanelComponent.Line(
"Pay-dirt in sack:",
String.valueOf(client.getSetting(Varbits.SACK_NUMBER))
));
}
}
return panelComponent.render(graphics, parent);
}
}

View File

@@ -0,0 +1,92 @@
/*
* Copyright (c) 2016-2018, Seth <Sethtroll3@gmail.com>
* 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.motherlode;
import java.time.Duration;
import java.time.Instant;
public class MotherlodeSession
{
private static final Duration HOUR = Duration.ofHours(1);
private int perHour;
private Instant lastPayDirtMined;
private int totalMined;
private Instant recentPayDirtMined;
private int recentMined;
public void incrementPayDirtMined()
{
Instant now = Instant.now();
lastPayDirtMined = now;
++totalMined;
if (recentMined == 0)
{
recentPayDirtMined = now;
}
++recentMined;
Duration timeSinceStart = Duration.between(recentPayDirtMined, now);
if (!timeSinceStart.isZero())
{
perHour = (int) ((double) recentMined * (double) HOUR.toMillis() / (double) timeSinceStart.toMillis());
}
}
public void resetRecent()
{
recentPayDirtMined = null;
recentMined = 0;
}
public int getPerHour()
{
return perHour;
}
public Instant getLastPayDirtMined()
{
return lastPayDirtMined;
}
public int getTotalMined()
{
return totalMined;
}
public Instant getRecentPayDirtMined()
{
return recentPayDirtMined;
}
public int getRecentMined()
{
return recentMined;
}
}