Add Blast furnace plugin

This commit is contained in:
Seth
2018-02-14 08:32:33 -06:00
committed by Adam
parent fd81d32909
commit 9845e48875
9 changed files with 521 additions and 2 deletions

View File

@@ -198,7 +198,31 @@ public enum Varbits
* Nightmare Zone
*/
NMZ_ABSORPTION(3956, 1067, 5, 14),
NMZ_POINTS(3949, 1059, 0, 19);
NMZ_POINTS(3949, 1059, 0, 19),
/**
* Blast Furnace
*/
BLAST_FURNACE_COPPER_ORE(959, 549, 16, 23),
BLAST_FURNACE_TIN_ORE(950, 547, 8, 15),
BLAST_FURNACE_IRON_ORE(951, 547, 16, 23),
BLAST_FURNACE_COAL(949, 547, 0, 7),
BLAST_FURNACE_MITHRIL_ORE(952, 547, 24, 31),
BLAST_FURNACE_ADAMANTITE_ORE(953, 548, 0, 7),
BLAST_FURNACE_RUNITE_ORE(954, 548, 8, 15),
BLAST_FURNACE_SILVER_ORE(955, 548, 24, 31),
BLAST_FURNACE_GOLD_ORE(955, 548, 16, 23),
BLAST_FURNACE_BRONZE_BAR(941, 545, 0, 7),
BLAST_FURNACE_IRON_BAR(942, 545, 8, 15),
BLAST_FURNACE_STEEL_BAR(943, 545, 16, 23),
BLAST_FURNACE_MITHRIL_BAR(944, 545, 24, 31),
BLAST_FURNACE_ADAMANTITE_BAR(945, 546, 0, 7),
BLAST_FURNACE_RUNITE_BAR(946, 546, 8, 15),
BLAST_FURNACE_SILVER_BAR(948, 546, 24, 31),
BLAST_FURNACE_GOLD_BAR(947, 546, 16, 23),
BLAST_FURNACE_COFFER(5357, 795, 1, 31);
/**
* varbit id

View File

@@ -64,6 +64,7 @@ public class WidgetID
public static final int EXPERIENCE_DROP_GROUP_ID = 122;
public static final int PUZZLE_BOX_GROUP_ID = 306;
public static final int NIGHTMARE_ZONE_GROUP_ID = 202;
public static final int BLAST_FURNACE_GROUP_ID = 474;
static class WorldMap
{

View File

@@ -169,7 +169,9 @@ public enum WidgetInfo
PUZZLE_BOX(WidgetID.PUZZLE_BOX_GROUP_ID, WidgetID.PuzzleBox.VISIBLE_BOX),
NIGHTMARE_ZONE(WidgetID.NIGHTMARE_ZONE_GROUP_ID, 1);
NIGHTMARE_ZONE(WidgetID.NIGHTMARE_ZONE_GROUP_ID, 1),
BLAST_FURNACE_COFFER(WidgetID.BLAST_FURNACE_GROUP_ID, 0);
private final int groupId;
private final int childId;

View File

@@ -0,0 +1,78 @@
/*
* Copyright (c) 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.blastfurnace;
import java.util.HashMap;
import java.util.Map;
import lombok.Getter;
import net.runelite.api.ItemID;
import net.runelite.api.Varbits;
public enum BarsOres
{
COPPER_ORE(Varbits.BLAST_FURNACE_COPPER_ORE, ItemID.COPPER_ORE),
TIN_ORE(Varbits.BLAST_FURNACE_TIN_ORE, ItemID.TIN_ORE),
IRON_ORE(Varbits.BLAST_FURNACE_IRON_ORE, ItemID.IRON_ORE),
COAL(Varbits.BLAST_FURNACE_COAL, ItemID.COAL),
MITHRIL_ORE(Varbits.BLAST_FURNACE_MITHRIL_ORE, ItemID.MITHRIL_ORE),
ADAMANTITE_ORE(Varbits.BLAST_FURNACE_ADAMANTITE_ORE, ItemID.ADAMANTITE_ORE),
RUNITE_ORE(Varbits.BLAST_FURNACE_RUNITE_ORE, ItemID.RUNITE_ORE),
SILVER_ORE(Varbits.BLAST_FURNACE_SILVER_ORE, ItemID.SILVER_ORE),
GOLD_ORE(Varbits.BLAST_FURNACE_GOLD_ORE, ItemID.GOLD_ORE),
BRONZE_BAR(Varbits.BLAST_FURNACE_BRONZE_BAR, ItemID.BRONZE_BAR),
IRON_BAR(Varbits.BLAST_FURNACE_IRON_BAR, ItemID.IRON_BAR),
STEEL_BAR(Varbits.BLAST_FURNACE_STEEL_BAR, ItemID.STEEL_BAR),
MITHRIL_BAR(Varbits.BLAST_FURNACE_MITHRIL_BAR, ItemID.MITHRIL_BAR),
ADAMANTITE_BAR(Varbits.BLAST_FURNACE_ADAMANTITE_BAR, ItemID.ADAMANTITE_BAR),
RUNITE_BAR(Varbits.BLAST_FURNACE_RUNITE_BAR, ItemID.RUNITE_BAR),
SILVER_BAR(Varbits.BLAST_FURNACE_SILVER_BAR, ItemID.SILVER_BAR),
GOLD_BAR(Varbits.BLAST_FURNACE_GOLD_BAR, ItemID.GOLD_BAR);
private static final Map<Varbits, BarsOres> VARBIT = new HashMap<>();
static
{
for (BarsOres s : values())
{
VARBIT.put(s.getVarbit(), s);
}
}
@Getter
private final Varbits varbit;
@Getter
private final int itemID;
BarsOres(Varbits varbit, int itemID)
{
this.varbit = varbit;
this.itemID = itemID;
}
public static BarsOres getVarbit(Varbits varbit)
{
return VARBIT.get(varbit);
}
}

View File

@@ -0,0 +1,79 @@
/*
* Copyright (c) 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.blastfurnace;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import java.text.NumberFormat;
import javax.inject.Inject;
import net.runelite.api.Client;
import static net.runelite.api.Varbits.BLAST_FURNACE_COFFER;
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;
class BlastFurnaceCofferOverlay extends Overlay
{
private final Client client;
private final BlastFurnacePlugin plugin;
private final BlastFurnaceConfig config;
private final PanelComponent panelComponent = new PanelComponent();
@Inject
BlastFurnaceCofferOverlay(Client client, BlastFurnacePlugin plugin, BlastFurnaceConfig config)
{
setPosition(OverlayPosition.TOP_LEFT);
this.client = client;
this.plugin = plugin;
this.config = config;
}
@Override
public Dimension render(Graphics2D graphics, Point parent)
{
if (plugin.getConveyorBelt() == null)
{
return null;
}
Widget sack = client.getWidget(WidgetInfo.BLAST_FURNACE_COFFER);
panelComponent.getLines().clear();
if (sack != null)
{
sack.setHidden(true);
panelComponent.getLines().add(new PanelComponent.Line(
"Coffer:",
NumberFormat.getInstance().format(client.getSetting(BLAST_FURNACE_COFFER)) + " gp"
));
}
return panelComponent.render(graphics, parent);
}
}

View File

@@ -0,0 +1,57 @@
/*
* Copyright (c) 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.blastfurnace;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@ConfigGroup(
keyName = "blastfurnace",
name = "Blast Furnace",
description = "Configuration for the Blast furnace plugin"
)
public interface BlastFurnaceConfig extends Config
{
@ConfigItem(
keyName = "enabled",
name = "Enable",
description = "Configures whether to enable the blast furnace plugin"
)
default boolean enabled()
{
return true;
}
@ConfigItem(
keyName = "showConveyorBelt",
name = "Show Conveyor belt clickbox",
description = "Configures whether or not the clickbox for the conveyor belt is displayed"
)
default boolean showConveyorBelt()
{
return true;
}
}

View File

@@ -0,0 +1,87 @@
/*
* Copyright (c) 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.blastfurnace;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.image.BufferedImage;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.client.game.ItemManager;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
import net.runelite.client.ui.overlay.components.ImagePanelComponent;
class BlastFurnaceOverlay extends Overlay
{
private final Client client;
private final BlastFurnacePlugin plugin;
private final BlastFurnaceConfig config;
private final ImagePanelComponent imagePanelComponent = new ImagePanelComponent();
@Inject
private ItemManager itemManager;
@Inject
BlastFurnaceOverlay(Client client, BlastFurnacePlugin plugin, BlastFurnaceConfig config)
{
setPosition(OverlayPosition.TOP_LEFT);
this.plugin = plugin;
this.client = client;
this.config = config;
}
@Override
public Dimension render(Graphics2D graphics, Point parent)
{
if (!config.enabled() || plugin.getConveyorBelt() == null)
{
return null;
}
imagePanelComponent.getImages().clear();
for (BarsOres varbit : BarsOres.values())
{
int amount = client.getSetting(varbit.getVarbit());
if (amount == 0)
{
continue;
}
imagePanelComponent.getImages().add(getImage(varbit.getItemID(), amount));
}
return imagePanelComponent.render(graphics, parent);
}
private BufferedImage getImage(int itemID, int amount)
{
BufferedImage image = itemManager.getImage(itemID, amount, true);
return image;
}
}

View File

@@ -0,0 +1,102 @@
/*
* Copyright (c) 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.blastfurnace;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Provides;
import java.util.Arrays;
import java.util.Collection;
import javax.inject.Inject;
import lombok.AccessLevel;
import lombok.Getter;
import net.runelite.api.GameObject;
import net.runelite.api.GameState;
import static net.runelite.api.ObjectID.CONVEYOR_BELT;
import net.runelite.api.events.GameObjectDespawned;
import net.runelite.api.events.GameObjectSpawned;
import net.runelite.api.events.GameStateChanged;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.ui.overlay.Overlay;
@PluginDescriptor(
name = "Blast Furnace"
)
public class BlastFurnacePlugin extends Plugin
{
@Getter(AccessLevel.PACKAGE)
private GameObject conveyorBelt;
@Inject
private BlastFurnaceOverlay overlay;
@Inject
private BlastFurnaceCofferOverlay cofferOverlay;
@Inject
private ConveyorBeltOverlay conveyorBeltOverlay;
@Provides
BlastFurnaceConfig provideConfig(ConfigManager configManager)
{
return configManager.getConfig(BlastFurnaceConfig.class);
}
@Override
public Collection<Overlay> getOverlays()
{
return Arrays.asList(overlay, cofferOverlay, conveyorBeltOverlay);
}
@Subscribe
public void onGameObjectSpawn(GameObjectSpawned event)
{
GameObject gameObject = event.getGameObject();
if (gameObject.getId() == CONVEYOR_BELT)
{
conveyorBelt = gameObject;
}
}
@Subscribe
public void onGameObjectDespawn(GameObjectDespawned event)
{
GameObject gameObject = event.getGameObject();
if (gameObject.getId() == CONVEYOR_BELT)
{
conveyorBelt = null;
}
}
@Subscribe
public void onGameStateChanged(GameStateChanged event)
{
if (event.getGameState() == GameState.LOADING)
{
conveyorBelt = null;
}
}
}

View File

@@ -0,0 +1,89 @@
/*
* Copyright (c) 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.blastfurnace;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
import java.awt.geom.Area;
import javax.inject.Inject;
import net.runelite.api.Client;
import net.runelite.api.GameObject;
import net.runelite.api.Point;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
class ConveyorBeltOverlay extends Overlay
{
private static final int MAX_DISTANCE = 2350;
private final Client client;
private final BlastFurnacePlugin plugin;
private final BlastFurnaceConfig config;
@Inject
ConveyorBeltOverlay(Client client, BlastFurnacePlugin plugin, BlastFurnaceConfig config)
{
setPosition(OverlayPosition.DYNAMIC);
this.client = client;
this.plugin = plugin;
this.config = config;
}
@Override
public Dimension render(Graphics2D graphics, java.awt.Point parent)
{
if (!config.enabled() || !config.showConveyorBelt() || plugin.getConveyorBelt() == null)
{
return null;
}
Point localLocation = client.getLocalPlayer().getLocalLocation();
Point mousePosition = client.getMouseCanvasPosition();
GameObject object = plugin.getConveyorBelt();
Point location = object.getLocalLocation();
if (localLocation.distanceTo(location) <= MAX_DISTANCE)
{
Area objectClickbox = object.getClickbox();
if (objectClickbox != null)
{
if (objectClickbox.contains(mousePosition.getX(), mousePosition.getY()))
{
graphics.setColor(Color.RED.darker());
}
else
{
graphics.setColor(Color.RED);
}
graphics.draw(objectClickbox);
graphics.setColor(new Color(0xFF, 0, 0, 20));
graphics.fill(objectClickbox);
}
}
return null;
}
}