Merge pull request #7383 from SirGirion/feature/motherlode-ore-tracker
Add ore tracker to MLM plugin
This commit is contained in:
@@ -111,4 +111,14 @@ public interface MotherlodeConfig extends Config
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "showOresFound",
|
||||
name = "Show ores found",
|
||||
description = "Shows the ores found during current mining session"
|
||||
)
|
||||
default boolean showOresFound()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2019, Sir Girion <https://github.com/sirgirion>
|
||||
* 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.awt.Dimension;
|
||||
import java.awt.Graphics2D;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.client.ui.overlay.Overlay;
|
||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||
import net.runelite.client.ui.overlay.components.LineComponent;
|
||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||
import net.runelite.client.ui.overlay.components.TitleComponent;
|
||||
|
||||
public class MotherlodeOreOverlay extends Overlay
|
||||
{
|
||||
private final MotherlodePlugin plugin;
|
||||
private final MotherlodeConfig config;
|
||||
private final PanelComponent panelComponent = new PanelComponent();
|
||||
|
||||
@Inject
|
||||
MotherlodeOreOverlay(MotherlodePlugin plugin, MotherlodeConfig config)
|
||||
{
|
||||
setPosition(OverlayPosition.TOP_LEFT);
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (!plugin.isInMlm() || !config.showOresFound())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
MotherlodeSession session = plugin.getSession();
|
||||
|
||||
int nuggetsFound = session.getNuggetsFound();
|
||||
int coalFound = session.getCoalFound();
|
||||
int goldFound = session.getGoldFound();
|
||||
int mithrilFound = session.getMithrilFound();
|
||||
int adamantiteFound = session.getAdamantiteFound();
|
||||
int runiteFound = session.getRuniteFound();
|
||||
|
||||
// If no ores have even been collected, don't bother showing anything
|
||||
if (nuggetsFound == 0 && coalFound == 0 && goldFound == 0 && mithrilFound == 0
|
||||
&& adamantiteFound == 0 && runiteFound == 0)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
panelComponent.getChildren().clear();
|
||||
panelComponent.getChildren().add(TitleComponent.builder().text("Ores found").build());
|
||||
|
||||
if (nuggetsFound > 0)
|
||||
{
|
||||
panelComponent.getChildren().add(LineComponent.builder()
|
||||
.left("Nuggets:")
|
||||
.right(Integer.toString(nuggetsFound))
|
||||
.build());
|
||||
}
|
||||
|
||||
if (coalFound > 0)
|
||||
{
|
||||
panelComponent.getChildren().add(LineComponent.builder()
|
||||
.left("Coal:")
|
||||
.right(Integer.toString(coalFound))
|
||||
.build());
|
||||
}
|
||||
|
||||
if (goldFound > 0)
|
||||
{
|
||||
panelComponent.getChildren().add(LineComponent.builder()
|
||||
.left("Gold:")
|
||||
.right(Integer.toString(goldFound))
|
||||
.build());
|
||||
}
|
||||
|
||||
if (mithrilFound > 0)
|
||||
{
|
||||
panelComponent.getChildren().add(LineComponent.builder()
|
||||
.left("Mithril:")
|
||||
.right(Integer.toString(mithrilFound))
|
||||
.build());
|
||||
}
|
||||
|
||||
if (adamantiteFound > 0)
|
||||
{
|
||||
panelComponent.getChildren().add(LineComponent.builder()
|
||||
.left("Adamantite:")
|
||||
.right(Integer.toString(adamantiteFound))
|
||||
.build());
|
||||
}
|
||||
|
||||
if (runiteFound > 0)
|
||||
{
|
||||
panelComponent.getChildren().add(LineComponent.builder()
|
||||
.left("Runite:")
|
||||
.right(Integer.toString(runiteFound))
|
||||
.build());
|
||||
}
|
||||
|
||||
return panelComponent.render(graphics);
|
||||
}
|
||||
}
|
||||
@@ -59,6 +59,7 @@ import net.runelite.api.events.GameObjectChanged;
|
||||
import net.runelite.api.events.GameObjectDespawned;
|
||||
import net.runelite.api.events.GameObjectSpawned;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.ItemContainerChanged;
|
||||
import net.runelite.api.events.VarbitChanged;
|
||||
import net.runelite.api.events.WallObjectChanged;
|
||||
import net.runelite.api.events.WallObjectDespawned;
|
||||
@@ -84,7 +85,7 @@ public class MotherlodePlugin extends Plugin
|
||||
private static final Set<Integer> MOTHERLODE_MAP_REGIONS = ImmutableSet.of(14679, 14680, 14681, 14935, 14936, 14937, 15191, 15192, 15193);
|
||||
private static final Set<Integer> MINE_SPOTS = ImmutableSet.of(ORE_VEIN_26661, ORE_VEIN_26662, ORE_VEIN_26663, ORE_VEIN_26664);
|
||||
private static final Set<Integer> MLM_ORE_TYPES = ImmutableSet.of(ItemID.RUNITE_ORE, ItemID.ADAMANTITE_ORE,
|
||||
ItemID.MITHRIL_ORE, ItemID.GOLD_ORE, ItemID.COAL, ItemID.GOLDEN_NUGGET);
|
||||
ItemID.MITHRIL_ORE, ItemID.GOLD_ORE, ItemID.COAL, ItemID.GOLDEN_NUGGET);
|
||||
private static final Set<Integer> ROCK_OBSTACLES = ImmutableSet.of(ROCKFALL, ROCKFALL_26680);
|
||||
|
||||
private static final int MAX_INVENTORY_SIZE = 28;
|
||||
@@ -109,6 +110,9 @@ public class MotherlodePlugin extends Plugin
|
||||
@Inject
|
||||
private MotherlodeGemOverlay motherlodeGemOverlay;
|
||||
|
||||
@Inject
|
||||
private MotherlodeOreOverlay motherlodeOreOverlay;
|
||||
|
||||
@Inject
|
||||
private MotherlodeConfig config;
|
||||
|
||||
@@ -129,6 +133,7 @@ public class MotherlodePlugin extends Plugin
|
||||
private Integer depositsLeft;
|
||||
|
||||
private MotherlodeSession session;
|
||||
private boolean shouldUpdateOres;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private final Set<WallObject> veins = new HashSet<>();
|
||||
@@ -147,6 +152,7 @@ public class MotherlodePlugin extends Plugin
|
||||
overlayManager.add(overlay);
|
||||
overlayManager.add(rocksOverlay);
|
||||
overlayManager.add(motherlodeGemOverlay);
|
||||
overlayManager.add(motherlodeOreOverlay);
|
||||
overlayManager.add(motherlodeSackOverlay);
|
||||
|
||||
session = new MotherlodeSession();
|
||||
@@ -164,6 +170,7 @@ public class MotherlodePlugin extends Plugin
|
||||
overlayManager.remove(overlay);
|
||||
overlayManager.remove(rocksOverlay);
|
||||
overlayManager.remove(motherlodeGemOverlay);
|
||||
overlayManager.remove(motherlodeOreOverlay);
|
||||
overlayManager.remove(motherlodeSackOverlay);
|
||||
session = null;
|
||||
veins.clear();
|
||||
@@ -190,7 +197,9 @@ public class MotherlodePlugin extends Plugin
|
||||
{
|
||||
if (inMlm)
|
||||
{
|
||||
int lastSackValue = curSackSize;
|
||||
refreshSackValues();
|
||||
shouldUpdateOres = curSackSize != lastSackValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -368,6 +377,29 @@ public class MotherlodePlugin extends Plugin
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onItemContainerChanged(ItemContainerChanged event)
|
||||
{
|
||||
final ItemContainer container = event.getItemContainer();
|
||||
|
||||
if (!inMlm || container != client.getItemContainer(InventoryID.INVENTORY) || !shouldUpdateOres)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Item[] inv = container.getItems();
|
||||
|
||||
for (Item item : inv)
|
||||
{
|
||||
if (MLM_ORE_TYPES.contains(item.getId()))
|
||||
{
|
||||
session.updateOreFound(item);
|
||||
}
|
||||
}
|
||||
|
||||
shouldUpdateOres = false;
|
||||
}
|
||||
|
||||
private Integer calculateDepositsLeft()
|
||||
{
|
||||
if (maxSackSize == 0) // check if maxSackSize has been initialized
|
||||
@@ -445,6 +477,7 @@ public class MotherlodePlugin extends Plugin
|
||||
/**
|
||||
* Checks if the given point is "upstairs" in the mlm.
|
||||
* The upper floor is actually on z=0.
|
||||
*
|
||||
* @param localPoint
|
||||
* @return
|
||||
*/
|
||||
@@ -452,4 +485,4 @@ public class MotherlodePlugin extends Plugin
|
||||
{
|
||||
return Perspective.getTileHeight(client, localPoint, 0) < UPPER_FLOOR_HEIGHT;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,12 +24,13 @@
|
||||
*/
|
||||
package net.runelite.client.plugins.motherlode;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Item;
|
||||
import net.runelite.api.ItemID;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
|
||||
@Slf4j
|
||||
public class MotherlodeSession
|
||||
@@ -59,7 +60,25 @@ public class MotherlodeSession
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private int sapphiresFound;
|
||||
|
||||
public void incrementGemFound(int gemID)
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private int nuggetsFound;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private int coalFound;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private int goldFound;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private int mithrilFound;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private int adamantiteFound;
|
||||
|
||||
@Getter(AccessLevel.PACKAGE)
|
||||
private int runiteFound;
|
||||
|
||||
void incrementGemFound(int gemID)
|
||||
{
|
||||
lastGemFound = Instant.now();
|
||||
|
||||
@@ -82,7 +101,34 @@ public class MotherlodeSession
|
||||
break;
|
||||
|
||||
default:
|
||||
log.error("Invalid gem type specified. The gem count will not be incremented.");
|
||||
log.debug("Invalid gem type specified. The gem count will not be incremented.");
|
||||
}
|
||||
}
|
||||
|
||||
void updateOreFound(Item ore)
|
||||
{
|
||||
switch (ore.getId())
|
||||
{
|
||||
case ItemID.GOLDEN_NUGGET:
|
||||
nuggetsFound += ore.getQuantity();
|
||||
break;
|
||||
case ItemID.COAL:
|
||||
coalFound++;
|
||||
break;
|
||||
case ItemID.GOLD_ORE:
|
||||
goldFound++;
|
||||
break;
|
||||
case ItemID.MITHRIL_ORE:
|
||||
mithrilFound++;
|
||||
break;
|
||||
case ItemID.ADAMANTITE_ORE:
|
||||
adamantiteFound++;
|
||||
break;
|
||||
case ItemID.RUNITE_ORE:
|
||||
runiteFound++;
|
||||
break;
|
||||
default:
|
||||
log.debug("Invalid ore specified. The ore count will not be updated.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user