mining plugin: add session stats

Co-authored-by: jzomerlei <jzomerlei@gmail.com>
This commit is contained in:
Adam
2020-08-14 15:14:03 -04:00
committed by Adam
parent 10773f6a5e
commit 276746eea6
6 changed files with 575 additions and 2 deletions

View File

@@ -0,0 +1,56 @@
/*
* Copyright (c) 2020, Jordan Zomerlei <https://github.com/JZomerlei>
* 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.mining;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
import net.runelite.client.config.Units;
@ConfigGroup("mining")
public interface MiningConfig extends Config
{
@ConfigItem(
keyName = "statTimeout",
name = "Reset stats",
description = "Duration the mining indicator and session stats are displayed before being reset"
)
@Units(Units.MINUTES)
default int statTimeout()
{
return 5;
}
@ConfigItem(
keyName = "showMiningStats",
name = "Show session stats",
description = "Configures whether to display mining session stats"
)
default boolean showMiningStats()
{
return true;
}
}

View File

@@ -0,0 +1,108 @@
/*
* Copyright (c) 2020, Jordan Zomerlei <https://github.com/JZomerlei>
* 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.mining;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.MenuAction;
import net.runelite.api.Skill;
import net.runelite.client.plugins.xptracker.XpTrackerService;
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
import net.runelite.client.ui.overlay.OverlayMenuEntry;
import net.runelite.client.ui.overlay.OverlayPanel;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.LineComponent;
import net.runelite.client.ui.overlay.components.TitleComponent;
class MiningOverlay extends OverlayPanel
{
static final String MINING_RESET = "Reset";
private final Client client;
private final MiningPlugin plugin;
private final MiningConfig config;
private final XpTrackerService xpTrackerService;
@Inject
private MiningOverlay(final Client client, final MiningPlugin plugin, final MiningConfig config, XpTrackerService xpTrackerService)
{
super(plugin);
setPosition(OverlayPosition.TOP_LEFT);
this.client = client;
this.plugin = plugin;
this.config = config;
this.xpTrackerService = xpTrackerService;
getMenuEntries().add(new OverlayMenuEntry(MenuAction.RUNELITE_OVERLAY_CONFIG, OPTION_CONFIGURE, "Mining overlay"));
getMenuEntries().add(new OverlayMenuEntry(MenuAction.RUNELITE_OVERLAY, MINING_RESET, "Mining overlay"));
}
@Override
public Dimension render(Graphics2D graphics)
{
MiningSession session = plugin.getSession();
if (session == null || session.getLastMined() == null || !config.showMiningStats())
{
return null;
}
Pickaxe pickaxe = plugin.getPickaxe();
if (pickaxe != null && pickaxe.matchesMiningAnimation(client.getLocalPlayer()))
{
panelComponent.getChildren().add(TitleComponent.builder()
.text("Mining")
.color(Color.GREEN)
.build());
}
else
{
panelComponent.getChildren().add(TitleComponent.builder()
.text("NOT mining")
.color(Color.RED)
.build());
}
int actions = xpTrackerService.getActions(Skill.MINING);
if (actions > 0)
{
panelComponent.getChildren().add(LineComponent.builder()
.left("Total mined:")
.right(Integer.toString(actions))
.build());
if (actions > 2)
{
panelComponent.getChildren().add(LineComponent.builder()
.left("Mined/hr:")
.right(Integer.toString(xpTrackerService.getActionsHr(Skill.MINING)))
.build());
}
}
return super.render(graphics);
}
}

View File

@@ -24,15 +24,21 @@
*/
package net.runelite.client.plugins.mining;
import com.google.inject.Provides;
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import javax.annotation.Nullable;
import javax.inject.Inject;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.GameObject;
import net.runelite.api.GameState;
import net.runelite.api.MenuAction;
import static net.runelite.api.ObjectID.DEPLETED_VEIN_26665;
import static net.runelite.api.ObjectID.DEPLETED_VEIN_26666;
import static net.runelite.api.ObjectID.DEPLETED_VEIN_26667;
@@ -42,27 +48,43 @@ import static net.runelite.api.ObjectID.ORE_VEIN_26661;
import static net.runelite.api.ObjectID.ORE_VEIN_26662;
import static net.runelite.api.ObjectID.ORE_VEIN_26663;
import static net.runelite.api.ObjectID.ORE_VEIN_26664;
import net.runelite.api.Player;
import net.runelite.api.WallObject;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.AnimationChanged;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameObjectDespawned;
import net.runelite.api.events.GameObjectSpawned;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.WallObjectSpawned;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.events.OverlayMenuClicked;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDependency;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.xptracker.XpTrackerPlugin;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.ui.overlay.OverlayMenuEntry;
@PluginDescriptor(
name = "Mining",
description = "Show ore respawn timers",
description = "Show mining statistics and ore respawn timers",
tags = {"overlay", "skilling", "timers"},
enabledByDefault = false
)
@PluginDependency(XpTrackerPlugin.class)
public class MiningPlugin extends Plugin
{
private static final int ROCK_DISTANCE = 14;
private static final Pattern MINING_PATERN = Pattern.compile(
"You " +
"(?:manage to|just)" +
" (?:mined?|quarry) " +
"(?:some|an?) " +
"(?:copper|tin|clay|iron|silver|coal|gold|mithril|adamantite|runeite|amethyst|sandstone|granite|Opal|piece of Jade|Red Topaz|Emerald|Sapphire|Ruby|Diamond)" +
"(?:\\.|!)");
@Inject
private Client client;
@@ -70,26 +92,62 @@ public class MiningPlugin extends Plugin
@Inject
private OverlayManager overlayManager;
@Inject
private MiningOverlay overlay;
@Inject
private MiningRocksOverlay rocksOverlay;
@Inject
private MiningConfig config;
@Getter
@Nullable
private MiningSession session;
@Getter(AccessLevel.PACKAGE)
private final List<RockRespawn> respawns = new ArrayList<>();
private boolean recentlyLoggedIn;
@Getter
@Nullable
private Pickaxe pickaxe;
@Provides
MiningConfig getConfig(ConfigManager configManager)
{
return configManager.getConfig(MiningConfig.class);
}
@Override
protected void startUp()
{
overlayManager.add(overlay);
overlayManager.add(rocksOverlay);
}
@Override
protected void shutDown() throws Exception
{
session = null;
pickaxe = null;
overlayManager.remove(overlay);
overlayManager.remove(rocksOverlay);
respawns.clear();
}
@Subscribe
public void onOverlayMenuClicked(OverlayMenuClicked overlayMenuClicked)
{
OverlayMenuEntry overlayMenuEntry = overlayMenuClicked.getEntry();
if (overlayMenuEntry.getMenuAction() == MenuAction.RUNELITE_OVERLAY
&& overlayMenuClicked.getEntry().getOption().equals(MiningOverlay.MINING_RESET)
&& overlayMenuClicked.getOverlay() == overlay)
{
session = null;
}
}
@Subscribe
public void onGameStateChanged(GameStateChanged event)
{
@@ -107,11 +165,54 @@ public class MiningPlugin extends Plugin
}
}
@Subscribe
public void onAnimationChanged(final AnimationChanged event)
{
Player local = client.getLocalPlayer();
if (event.getActor() != local)
{
return;
}
int animId = local.getAnimation();
Pickaxe pickaxe = Pickaxe.fromAnimation(animId);
if (pickaxe != null)
{
this.pickaxe = pickaxe;
}
}
@Subscribe
public void onGameTick(GameTick gameTick)
{
respawns.removeIf(RockRespawn::isExpired);
recentlyLoggedIn = false;
if (session == null || session.getLastMined() == null)
{
return;
}
if (pickaxe != null && pickaxe.matchesMiningAnimation(client.getLocalPlayer()))
{
session.setLastMined();
return;
}
Duration statTimeout = Duration.ofMinutes(config.statTimeout());
Duration sinceMined = Duration.between(session.getLastMined(), Instant.now());
if (sinceMined.compareTo(statTimeout) >= 0)
{
resetSession();
}
}
public void resetSession()
{
session = null;
pickaxe = null;
}
@Subscribe
@@ -209,4 +310,21 @@ public class MiningPlugin extends Plugin
}
}
}
}
@Subscribe
public void onChatMessage(ChatMessage event)
{
if (event.getType() == ChatMessageType.SPAM || event.getType() == ChatMessageType.GAMEMESSAGE)
{
if (MINING_PATERN.matcher(event.getMessage()).matches())
{
if (session == null)
{
session = new MiningSession();
}
session.setLastMined();
}
}
}
}

View File

@@ -0,0 +1,39 @@
/*
* Copyright (c) 2020, Jordan Zomerlei <https://github.com/JZomerlei>
* 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.mining;
import java.time.Instant;
import lombok.Getter;
class MiningSession
{
@Getter
private Instant lastMined;
void setLastMined()
{
lastMined = Instant.now();
}
}

View File

@@ -0,0 +1,106 @@
/*
* Copyright (c) 2020, Jordan Zomerlei <https://github.com/JZomerlei>
* 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.mining;
import com.google.common.collect.ImmutableMap;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Getter;
import static net.runelite.api.AnimationID.MINING_3A_PICKAXE;
import static net.runelite.api.AnimationID.MINING_ADAMANT_PICKAXE;
import static net.runelite.api.AnimationID.MINING_BLACK_PICKAXE;
import static net.runelite.api.AnimationID.MINING_BRONZE_PICKAXE;
import static net.runelite.api.AnimationID.MINING_CRYSTAL_PICKAXE;
import static net.runelite.api.AnimationID.MINING_DRAGON_PICKAXE;
import static net.runelite.api.AnimationID.MINING_DRAGON_PICKAXE_OR;
import static net.runelite.api.AnimationID.MINING_DRAGON_PICKAXE_UPGRADED;
import static net.runelite.api.AnimationID.MINING_GILDED_PICKAXE;
import static net.runelite.api.AnimationID.MINING_INFERNAL_PICKAXE;
import static net.runelite.api.AnimationID.MINING_IRON_PICKAXE;
import static net.runelite.api.AnimationID.MINING_MITHRIL_PICKAXE;
import static net.runelite.api.AnimationID.MINING_RUNE_PICKAXE;
import static net.runelite.api.AnimationID.MINING_STEEL_PICKAXE;
import static net.runelite.api.ItemID.ADAMANT_PICKAXE;
import static net.runelite.api.ItemID.BLACK_PICKAXE;
import static net.runelite.api.ItemID.BRONZE_PICKAXE;
import static net.runelite.api.ItemID.CRYSTAL_PICKAXE;
import static net.runelite.api.ItemID.DRAGON_PICKAXE;
import static net.runelite.api.ItemID.DRAGON_PICKAXEOR;
import static net.runelite.api.ItemID.DRAGON_PICKAXE_12797;
import static net.runelite.api.ItemID.GILDED_PICKAXE;
import static net.runelite.api.ItemID.INFERNAL_PICKAXE;
import static net.runelite.api.ItemID.IRON_PICKAXE;
import static net.runelite.api.ItemID.MITHRIL_PICKAXE;
import static net.runelite.api.ItemID.RUNE_PICKAXE;
import static net.runelite.api.ItemID.STEEL_PICKAXE;
import static net.runelite.api.ItemID._3RD_AGE_PICKAXE;
import net.runelite.api.Player;
@AllArgsConstructor
@Getter
enum Pickaxe
{
BRONZE(MINING_BRONZE_PICKAXE, BRONZE_PICKAXE),
IRON(MINING_IRON_PICKAXE, IRON_PICKAXE),
STEEL(MINING_STEEL_PICKAXE, STEEL_PICKAXE),
BLACK(MINING_BLACK_PICKAXE, BLACK_PICKAXE),
MITHRIL(MINING_MITHRIL_PICKAXE, MITHRIL_PICKAXE),
ADAMANT(MINING_ADAMANT_PICKAXE, ADAMANT_PICKAXE),
RUNE(MINING_RUNE_PICKAXE, RUNE_PICKAXE),
GILDED(MINING_GILDED_PICKAXE, GILDED_PICKAXE),
DRAGON(MINING_DRAGON_PICKAXE, DRAGON_PICKAXE),
DRAGON_OR(MINING_DRAGON_PICKAXE_OR, DRAGON_PICKAXEOR),
DRAGON_UPGRADED(MINING_DRAGON_PICKAXE_UPGRADED, DRAGON_PICKAXE_12797),
INFERNAL(MINING_INFERNAL_PICKAXE, INFERNAL_PICKAXE),
THIRDAGE(MINING_3A_PICKAXE, _3RD_AGE_PICKAXE),
CRYSTAL(MINING_CRYSTAL_PICKAXE, CRYSTAL_PICKAXE);
private final int animId;
private final int itemId;
private static final Map<Integer, Pickaxe> PICKAXE_ANIM_IDS;
static
{
ImmutableMap.Builder<Integer, Pickaxe> builder = new ImmutableMap.Builder<>();
for (Pickaxe pickaxe : values())
{
builder.put(pickaxe.animId, pickaxe);
}
PICKAXE_ANIM_IDS = builder.build();
}
boolean matchesMiningAnimation(final Player player)
{
return player != null && animId == player.getAnimation();
}
static Pickaxe fromAnimation(int animId)
{
return PICKAXE_ANIM_IDS.get(animId);
}
}

View File

@@ -0,0 +1,146 @@
/*
* Copyright (c) 2020, Jordan Zomerlei <https://github.com/JZomerlei>
* 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.mining;
import com.google.inject.Guice;
import com.google.inject.testing.fieldbinder.Bind;
import com.google.inject.testing.fieldbinder.BoundFieldModule;
import javax.inject.Inject;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.events.ChatMessage;
import net.runelite.client.ui.overlay.OverlayManager;
import static org.junit.Assert.assertNotNull;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class MiningPluginTest
{
@Inject
MiningPlugin miningPlugin;
@Mock
@Bind
MiningConfig miningConfig;
@Mock
@Bind
Client client;
@Mock
@Bind
MiningOverlay miningOverlay;
@Mock
@Bind
MiningRocksOverlay miningRocksOverlay;
@Mock
@Bind
OverlayManager overlayManager;
@Before
public void before()
{
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
}
@Test
public void testClay()
{
testMessage("You manage to mine some clay.");
}
@Test
public void testIron()
{
testMessage("You manage to mine some iron.");
}
@Test
public void testSandstone()
{
testMessage("You manage to quarry some sandstone.");
}
@Test
public void testGranite()
{
testMessage("You manage to quarry some granite.");
}
@Test
public void testOpal()
{
testMessage("You just mined an Opal!");
}
@Test
public void testJade()
{
testMessage("You just mined a piece of Jade!");
}
@Test
public void testRedTopaz()
{
testMessage("You just mined a Red Topaz!");
}
@Test
public void testSapphire()
{
testMessage("You just mined a Sapphire!");
}
@Test
public void testEmerald()
{
testMessage("You just mined an Emerald!");
}
@Test
public void testRuby()
{
testMessage("You just mined a Ruby!");
}
@Test
public void testDiamond()
{
testMessage("You just mined a Diamond!");
}
private void testMessage(String gameMessage)
{
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", gameMessage, "", 0);
miningPlugin.onChatMessage(chatMessage);
assertNotNull(miningPlugin.getSession());
}
}