@@ -29,6 +29,7 @@ import java.awt.event.KeyEvent;
|
|||||||
import java.awt.event.MouseEvent;
|
import java.awt.event.MouseEvent;
|
||||||
import java.awt.event.MouseWheelEvent;
|
import java.awt.event.MouseWheelEvent;
|
||||||
import net.runelite.api.MainBufferProvider;
|
import net.runelite.api.MainBufferProvider;
|
||||||
|
import net.runelite.api.widgets.WidgetItem;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface of callbacks the injected client uses to send events
|
* Interface of callbacks the injected client uses to send events
|
||||||
@@ -79,6 +80,11 @@ public interface Callbacks
|
|||||||
*/
|
*/
|
||||||
void draw(MainBufferProvider mainBufferProvider, Graphics graphics, int x, int y);
|
void draw(MainBufferProvider mainBufferProvider, Graphics graphics, int x, int y);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called before the client will render an item widget.
|
||||||
|
*/
|
||||||
|
void drawItem(int itemId, WidgetItem widgetItem);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mouse pressed event. If this event will be consumed it will not be propagated further to client.
|
* Mouse pressed event. If this event will be consumed it will not be propagated further to client.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,78 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
|
|
||||||
* 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.api.queries;
|
|
||||||
|
|
||||||
import net.runelite.api.Client;
|
|
||||||
import net.runelite.api.widgets.Widget;
|
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
|
||||||
import net.runelite.api.widgets.WidgetItem;
|
|
||||||
|
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class BankItemQuery extends WidgetItemQuery
|
|
||||||
{
|
|
||||||
private static final int ITEM_EMPTY = 6512;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WidgetItem[] result(Client client)
|
|
||||||
{
|
|
||||||
Collection<WidgetItem> widgetItems = getBankItems(client);
|
|
||||||
if (widgetItems != null)
|
|
||||||
{
|
|
||||||
return widgetItems.stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.filter(predicate)
|
|
||||||
.toArray(WidgetItem[]::new);
|
|
||||||
}
|
|
||||||
return new WidgetItem[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
private Collection<WidgetItem> getBankItems(Client client)
|
|
||||||
{
|
|
||||||
Collection<WidgetItem> widgetItems = new ArrayList<>();
|
|
||||||
Widget bank = client.getWidget(WidgetInfo.BANK_ITEM_CONTAINER);
|
|
||||||
if (bank != null && !bank.isHidden())
|
|
||||||
{
|
|
||||||
Widget[] children = bank.getDynamicChildren();
|
|
||||||
for (int i = 0; i < children.length; i++)
|
|
||||||
{
|
|
||||||
Widget child = children[i];
|
|
||||||
if (child.getItemId() == ITEM_EMPTY || child.isSelfHidden())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// set bounds to same size as default inventory
|
|
||||||
Rectangle bounds = child.getBounds();
|
|
||||||
bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32);
|
|
||||||
// Index is set to 0 because the widget's index does not correlate to the order in the bank
|
|
||||||
widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), 0, bounds));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return widgetItems;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
|
|
||||||
* 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.api.queries;
|
|
||||||
|
|
||||||
import net.runelite.api.Client;
|
|
||||||
import net.runelite.api.widgets.Widget;
|
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
|
||||||
import net.runelite.api.widgets.WidgetItem;
|
|
||||||
|
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class EquipmentItemQuery extends WidgetItemQuery
|
|
||||||
{
|
|
||||||
private static final WidgetInfo[] ALL_EQUIPMENT_WIDGET_INFOS =
|
|
||||||
{
|
|
||||||
WidgetInfo.EQUIPMENT_HELMET,
|
|
||||||
WidgetInfo.EQUIPMENT_CAPE,
|
|
||||||
WidgetInfo.EQUIPMENT_AMULET,
|
|
||||||
WidgetInfo.EQUIPMENT_WEAPON,
|
|
||||||
WidgetInfo.EQUIPMENT_BODY,
|
|
||||||
WidgetInfo.EQUIPMENT_SHIELD,
|
|
||||||
WidgetInfo.EQUIPMENT_LEGS,
|
|
||||||
WidgetInfo.EQUIPMENT_GLOVES,
|
|
||||||
WidgetInfo.EQUIPMENT_BOOTS,
|
|
||||||
WidgetInfo.EQUIPMENT_RING,
|
|
||||||
WidgetInfo.EQUIPMENT_AMMO,
|
|
||||||
};
|
|
||||||
|
|
||||||
private final Collection<WidgetInfo> slots = new ArrayList<>();
|
|
||||||
|
|
||||||
public EquipmentItemQuery slotEquals(WidgetInfo... slotWidgetInfo)
|
|
||||||
{
|
|
||||||
slots.addAll(Arrays.asList(slotWidgetInfo));
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WidgetItem[] result(Client client)
|
|
||||||
{
|
|
||||||
Collection<WidgetItem> widgetItems = getEquippedItems(client);
|
|
||||||
if (widgetItems != null)
|
|
||||||
{
|
|
||||||
return widgetItems.stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.filter(predicate)
|
|
||||||
.toArray(WidgetItem[]::new);
|
|
||||||
}
|
|
||||||
return new WidgetItem[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
private Collection<WidgetItem> getEquippedItems(Client client)
|
|
||||||
{
|
|
||||||
Collection<WidgetItem> widgetItems = new ArrayList<>();
|
|
||||||
Widget equipment = client.getWidget(WidgetInfo.EQUIPMENT);
|
|
||||||
if (equipment != null && !equipment.isHidden())
|
|
||||||
{
|
|
||||||
if (slots.isEmpty())
|
|
||||||
{
|
|
||||||
slots.addAll(Arrays.asList(ALL_EQUIPMENT_WIDGET_INFOS));
|
|
||||||
}
|
|
||||||
for (WidgetInfo slot : slots)
|
|
||||||
{
|
|
||||||
Widget parentWidget = client.getWidget(slot);
|
|
||||||
Widget itemWidget = parentWidget.getChild(1);
|
|
||||||
// Check if background icon is hidden. if hidden, item is equipped.
|
|
||||||
boolean equipped = parentWidget.getChild(2).isSelfHidden();
|
|
||||||
// set bounds to same size as default inventory
|
|
||||||
Rectangle bounds = itemWidget.getBounds();
|
|
||||||
bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32);
|
|
||||||
// Index is set to 0 because there is no set in stone order of equipment slots
|
|
||||||
widgetItems.add(new WidgetItem(equipped ? itemWidget.getItemId() : -1, itemWidget.getItemQuantity(), 0, bounds));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return widgetItems;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
|
|
||||||
* 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.api.queries;
|
|
||||||
|
|
||||||
import net.runelite.api.Client;
|
|
||||||
import net.runelite.api.widgets.Widget;
|
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
|
||||||
import net.runelite.api.widgets.WidgetItem;
|
|
||||||
|
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class InventoryWidgetItemQuery extends WidgetItemQuery
|
|
||||||
{
|
|
||||||
private static final WidgetInfo[] INVENTORY_WIDGET_INFOS =
|
|
||||||
{
|
|
||||||
WidgetInfo.DEPOSIT_BOX_INVENTORY_ITEMS_CONTAINER,
|
|
||||||
WidgetInfo.BANK_INVENTORY_ITEMS_CONTAINER,
|
|
||||||
WidgetInfo.SHOP_INVENTORY_ITEMS_CONTAINER,
|
|
||||||
WidgetInfo.GRAND_EXCHANGE_INVENTORY_ITEMS_CONTAINER,
|
|
||||||
WidgetInfo.GUIDE_PRICES_INVENTORY_ITEMS_CONTAINER,
|
|
||||||
WidgetInfo.EQUIPMENT_INVENTORY_ITEMS_CONTAINER,
|
|
||||||
WidgetInfo.INVENTORY
|
|
||||||
};
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WidgetItem[] result(Client client)
|
|
||||||
{
|
|
||||||
Collection<WidgetItem> widgetItems = getInventoryItems(client);
|
|
||||||
if (widgetItems != null)
|
|
||||||
{
|
|
||||||
return widgetItems.stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.filter(predicate)
|
|
||||||
.toArray(WidgetItem[]::new);
|
|
||||||
}
|
|
||||||
return new WidgetItem[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
private Collection<WidgetItem> getInventoryItems(Client client)
|
|
||||||
{
|
|
||||||
Collection<WidgetItem> widgetItems = new ArrayList<>();
|
|
||||||
for (WidgetInfo widgetInfo : INVENTORY_WIDGET_INFOS)
|
|
||||||
{
|
|
||||||
Widget inventory = client.getWidget(widgetInfo);
|
|
||||||
if (inventory == null || inventory.isHidden())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (widgetInfo == WidgetInfo.INVENTORY)
|
|
||||||
{
|
|
||||||
widgetItems.addAll(inventory.getWidgetItems());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Widget[] children = inventory.getDynamicChildren();
|
|
||||||
for (int i = 0; i < children.length; i++)
|
|
||||||
{
|
|
||||||
Widget child = children[i];
|
|
||||||
// set bounds to same size as default inventory
|
|
||||||
Rectangle bounds = child.getBounds();
|
|
||||||
bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32);
|
|
||||||
widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), i, bounds));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return widgetItems;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
|
|
||||||
* 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.api.queries;
|
|
||||||
|
|
||||||
import net.runelite.api.Client;
|
|
||||||
import net.runelite.api.widgets.Widget;
|
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
|
||||||
import net.runelite.api.widgets.WidgetItem;
|
|
||||||
|
|
||||||
import java.awt.Rectangle;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class ShopItemQuery extends WidgetItemQuery
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public WidgetItem[] result(Client client)
|
|
||||||
{
|
|
||||||
Collection<WidgetItem> widgetItems = getShopItems(client);
|
|
||||||
if (widgetItems != null)
|
|
||||||
{
|
|
||||||
return widgetItems.stream()
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.filter(predicate)
|
|
||||||
.toArray(WidgetItem[]::new);
|
|
||||||
}
|
|
||||||
return new WidgetItem[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
private Collection<WidgetItem> getShopItems(Client client)
|
|
||||||
{
|
|
||||||
Collection<WidgetItem> widgetItems = new ArrayList<>();
|
|
||||||
Widget shop = client.getWidget(WidgetInfo.SHOP_ITEMS_CONTAINER);
|
|
||||||
if (shop != null && !shop.isHidden())
|
|
||||||
{
|
|
||||||
Widget[] children = shop.getDynamicChildren();
|
|
||||||
for (int i = 1; i < children.length; i++)
|
|
||||||
{
|
|
||||||
Widget child = children[i];
|
|
||||||
// set bounds to same size as default inventory
|
|
||||||
Rectangle bounds = child.getBounds();
|
|
||||||
bounds.setBounds(bounds.x - 1, bounds.y - 1, 32, 32);
|
|
||||||
widgetItems.add(new WidgetItem(child.getItemId(), child.getItemQuantity(), i - 1, bounds));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return widgetItems;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -129,6 +129,7 @@ public class WidgetID
|
|||||||
public static final int SKILLS_GROUP_ID = 320;
|
public static final int SKILLS_GROUP_ID = 320;
|
||||||
public static final int QUESTTAB_GROUP_ID = 629;
|
public static final int QUESTTAB_GROUP_ID = 629;
|
||||||
public static final int MUSIC_GROUP_ID = 239;
|
public static final int MUSIC_GROUP_ID = 239;
|
||||||
|
public static final int BARROWS_PUZZLE_GROUP_ID = 25;
|
||||||
|
|
||||||
static class WorldMap
|
static class WorldMap
|
||||||
{
|
{
|
||||||
@@ -577,7 +578,7 @@ public class WidgetID
|
|||||||
{
|
{
|
||||||
static final int POINTS_INFOBOX = 6;
|
static final int POINTS_INFOBOX = 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class ExperienceDrop
|
static class ExperienceDrop
|
||||||
{
|
{
|
||||||
static final int DROP_1 = 15;
|
static final int DROP_1 = 15;
|
||||||
@@ -771,4 +772,26 @@ public class WidgetID
|
|||||||
static final int CONTAINER = 0;
|
static final int CONTAINER = 0;
|
||||||
static final int LIST = 3;
|
static final int LIST = 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class Barrows_Puzzle
|
||||||
|
{
|
||||||
|
static final int PARENT = 0;
|
||||||
|
static final int CONTAINER = 1;
|
||||||
|
static final int TOP_ROW_PUZZLE = 2;
|
||||||
|
static final int SEQUENCE_1 = 3;
|
||||||
|
static final int SEQUENCE_1_TEXT = 4;
|
||||||
|
static final int SEQUENCE_2 = 5;
|
||||||
|
static final int SEQUENCE_2_TEXT = 6;
|
||||||
|
static final int SEQUENCE_3 = 7;
|
||||||
|
static final int SEQUENCE_3_TEXT = 8;
|
||||||
|
static final int SEQUENCE_4 = 9;
|
||||||
|
static final int SEQUENCE_4_TEXT = 10;
|
||||||
|
static final int NEXT_SHAPE_TEXT = 11;
|
||||||
|
static final int ANSWER1_CONTAINER = 12;
|
||||||
|
static final int ANSWER1 = 13;
|
||||||
|
static final int ANSWER2_CONTAINER = 14;
|
||||||
|
static final int ANSWER2 = 15;
|
||||||
|
static final int ANSWER3_CONTAINER = 16;
|
||||||
|
static final int ANSWER3 = 17;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -410,6 +410,14 @@ public enum WidgetInfo
|
|||||||
BARROWS_BROTHERS(WidgetID.BARROWS_GROUP_ID, WidgetID.Barrows.BARROWS_BROTHERS),
|
BARROWS_BROTHERS(WidgetID.BARROWS_GROUP_ID, WidgetID.Barrows.BARROWS_BROTHERS),
|
||||||
BARROWS_POTENTIAL(WidgetID.BARROWS_GROUP_ID, WidgetID.Barrows.BARROWS_POTENTIAL),
|
BARROWS_POTENTIAL(WidgetID.BARROWS_GROUP_ID, WidgetID.Barrows.BARROWS_POTENTIAL),
|
||||||
BARROWS_REWARD_INVENTORY(WidgetID.BARROWS_REWARD_GROUP_ID, WidgetID.Barrows.BARROWS_REWARD_INVENTORY),
|
BARROWS_REWARD_INVENTORY(WidgetID.BARROWS_REWARD_GROUP_ID, WidgetID.Barrows.BARROWS_REWARD_INVENTORY),
|
||||||
|
BARROWS_PUZZLE_PARENT(WidgetID.BARROWS_PUZZLE_GROUP_ID, WidgetID.Barrows_Puzzle.PARENT),
|
||||||
|
BARROWS_PUZZLE_ANSWER1(WidgetID.BARROWS_PUZZLE_GROUP_ID, WidgetID.Barrows_Puzzle.ANSWER1),
|
||||||
|
BARROWS_PUZZLE_ANSWER1_CONTAINER(WidgetID.BARROWS_PUZZLE_GROUP_ID, WidgetID.Barrows_Puzzle.ANSWER1_CONTAINER),
|
||||||
|
BARROWS_PUZZLE_ANSWER2(WidgetID.BARROWS_PUZZLE_GROUP_ID, WidgetID.Barrows_Puzzle.ANSWER2),
|
||||||
|
BARROWS_PUZZLE_ANSWER2_CONTAINER(WidgetID.BARROWS_PUZZLE_GROUP_ID, WidgetID.Barrows_Puzzle.ANSWER2_CONTAINER),
|
||||||
|
BARROWS_PUZZLE_ANSWER3(WidgetID.BARROWS_PUZZLE_GROUP_ID, WidgetID.Barrows_Puzzle.ANSWER3),
|
||||||
|
BARROWS_PUZZLE_ANSWER3_CONTAINER(WidgetID.BARROWS_PUZZLE_GROUP_ID, WidgetID.Barrows_Puzzle.ANSWER3_CONTAINER),
|
||||||
|
BARROWS_FIRST_PUZZLE(WidgetID.BARROWS_PUZZLE_GROUP_ID, WidgetID.Barrows_Puzzle.SEQUENCE_1),
|
||||||
|
|
||||||
BLAST_MINE(WidgetID.BLAST_MINE_GROUP_ID, 2),
|
BLAST_MINE(WidgetID.BLAST_MINE_GROUP_ID, 2),
|
||||||
|
|
||||||
|
|||||||
@@ -25,11 +25,15 @@
|
|||||||
package net.runelite.api.widgets;
|
package net.runelite.api.widgets;
|
||||||
|
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.ToString;
|
||||||
import net.runelite.api.Point;
|
import net.runelite.api.Point;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An item that is being represented in a {@link Widget}.
|
* An item that is being represented in a {@link Widget}.
|
||||||
*/
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ToString
|
||||||
public class WidgetItem
|
public class WidgetItem
|
||||||
{
|
{
|
||||||
private final int id;
|
private final int id;
|
||||||
@@ -37,20 +41,6 @@ public class WidgetItem
|
|||||||
private final int index;
|
private final int index;
|
||||||
private final Rectangle canvasBounds;
|
private final Rectangle canvasBounds;
|
||||||
|
|
||||||
public WidgetItem(int id, int quantity, int index, Rectangle canvasBounds)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
this.quantity = quantity;
|
|
||||||
this.index = index;
|
|
||||||
this.canvasBounds = canvasBounds;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "WidgetItem{" + "id=" + id + ", quantity=" + quantity + ", index=" + index + ", canvasBounds=" + canvasBounds + '}';
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the ID of the item represented.
|
* Gets the ID of the item represented.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ import net.runelite.client.rs.ClientUpdateCheckMode;
|
|||||||
import net.runelite.client.task.Scheduler;
|
import net.runelite.client.task.Scheduler;
|
||||||
import net.runelite.client.util.DeferredEventBus;
|
import net.runelite.client.util.DeferredEventBus;
|
||||||
import net.runelite.client.util.ExecutorServiceExceptionLogger;
|
import net.runelite.client.util.ExecutorServiceExceptionLogger;
|
||||||
import net.runelite.client.util.QueryRunner;
|
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -75,7 +74,6 @@ public class RuneLiteModule extends AbstractModule
|
|||||||
bindConstant().annotatedWith(Names.named("developerMode")).to(developerMode);
|
bindConstant().annotatedWith(Names.named("developerMode")).to(developerMode);
|
||||||
bind(ScheduledExecutorService.class).toInstance(new ExecutorServiceExceptionLogger(Executors.newSingleThreadScheduledExecutor()));
|
bind(ScheduledExecutorService.class).toInstance(new ExecutorServiceExceptionLogger(Executors.newSingleThreadScheduledExecutor()));
|
||||||
bind(OkHttpClient.class).toInstance(RuneLiteAPI.CLIENT);
|
bind(OkHttpClient.class).toInstance(RuneLiteAPI.CLIENT);
|
||||||
bind(QueryRunner.class);
|
|
||||||
bind(MenuManager.class);
|
bind(MenuManager.class);
|
||||||
bind(ChatMessageManager.class);
|
bind(ChatMessageManager.class);
|
||||||
bind(ItemManager.class);
|
bind(ItemManager.class);
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import net.runelite.api.BufferProvider;
|
import net.runelite.api.BufferProvider;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.MainBufferProvider;
|
import net.runelite.api.MainBufferProvider;
|
||||||
|
import net.runelite.api.NullItemID;
|
||||||
import net.runelite.api.RenderOverview;
|
import net.runelite.api.RenderOverview;
|
||||||
import net.runelite.api.Renderable;
|
import net.runelite.api.Renderable;
|
||||||
import net.runelite.api.WorldMapManager;
|
import net.runelite.api.WorldMapManager;
|
||||||
@@ -52,6 +53,7 @@ import net.runelite.api.hooks.Callbacks;
|
|||||||
import net.runelite.api.hooks.DrawCallbacks;
|
import net.runelite.api.hooks.DrawCallbacks;
|
||||||
import net.runelite.api.widgets.Widget;
|
import net.runelite.api.widgets.Widget;
|
||||||
import static net.runelite.api.widgets.WidgetInfo.WORLD_MAP_VIEW;
|
import static net.runelite.api.widgets.WidgetInfo.WORLD_MAP_VIEW;
|
||||||
|
import net.runelite.api.widgets.WidgetItem;
|
||||||
import net.runelite.client.Notifier;
|
import net.runelite.client.Notifier;
|
||||||
import net.runelite.client.RuneLite;
|
import net.runelite.client.RuneLite;
|
||||||
import net.runelite.client.chat.ChatMessageManager;
|
import net.runelite.client.chat.ChatMessageManager;
|
||||||
@@ -62,6 +64,7 @@ import net.runelite.client.task.Scheduler;
|
|||||||
import net.runelite.client.ui.ClientUI;
|
import net.runelite.client.ui.ClientUI;
|
||||||
import net.runelite.client.ui.DrawManager;
|
import net.runelite.client.ui.DrawManager;
|
||||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||||
|
import net.runelite.client.ui.overlay.OverlayManager;
|
||||||
import net.runelite.client.ui.overlay.OverlayRenderer;
|
import net.runelite.client.ui.overlay.OverlayRenderer;
|
||||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||||
import net.runelite.client.util.DeferredEventBus;
|
import net.runelite.client.util.DeferredEventBus;
|
||||||
@@ -80,6 +83,7 @@ public class Hooks implements Callbacks
|
|||||||
private static final Injector injector = RuneLite.getInjector();
|
private static final Injector injector = RuneLite.getInjector();
|
||||||
private static final Client client = injector.getInstance(Client.class);
|
private static final Client client = injector.getInstance(Client.class);
|
||||||
private static final OverlayRenderer renderer = injector.getInstance(OverlayRenderer.class);
|
private static final OverlayRenderer renderer = injector.getInstance(OverlayRenderer.class);
|
||||||
|
private static final OverlayManager overlayManager = injector.getInstance(OverlayManager.class);
|
||||||
|
|
||||||
private static final GameTick GAME_TICK = new GameTick();
|
private static final GameTick GAME_TICK = new GameTick();
|
||||||
private static final BeforeRender BEFORE_RENDER = new BeforeRender();
|
private static final BeforeRender BEFORE_RENDER = new BeforeRender();
|
||||||
@@ -443,6 +447,10 @@ public class Hooks implements Callbacks
|
|||||||
{
|
{
|
||||||
graphics2d.dispose();
|
graphics2d.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WidgetItemOverlays render at ABOVE_WIDGETS, reset widget item
|
||||||
|
// list for next frame.
|
||||||
|
overlayManager.getItemWidgets().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -490,4 +498,14 @@ public class Hooks implements Callbacks
|
|||||||
pixelPos += pixelJump;
|
pixelPos += pixelJump;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void drawItem(int itemId, WidgetItem widgetItem)
|
||||||
|
{
|
||||||
|
// Empty bank item
|
||||||
|
if (widgetItem.getId() != NullItemID.NULL_6512)
|
||||||
|
{
|
||||||
|
overlayManager.getItemWidgets().add(widgetItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ public enum AgilityShortcut
|
|||||||
CORSAIR_COVE_DUNGEON_PILLAR(15, "Pillar Jump", new WorldPoint(1980, 8996, 0), PILLAR_31809),
|
CORSAIR_COVE_DUNGEON_PILLAR(15, "Pillar Jump", new WorldPoint(1980, 8996, 0), PILLAR_31809),
|
||||||
EDGEVILLE_DUNGEON_MONKEYBARS(15, "Monkey Bars", null, MONKEYBARS_23566),
|
EDGEVILLE_DUNGEON_MONKEYBARS(15, "Monkey Bars", null, MONKEYBARS_23566),
|
||||||
TROLLHEIM_ROCKS(15, "Rocks", null, new WorldPoint(2838, 3614, 0), ROCKS_3748), // No fixed world map location, but rocks near death plateau have a requirement of 15
|
TROLLHEIM_ROCKS(15, "Rocks", null, new WorldPoint(2838, 3614, 0), ROCKS_3748), // No fixed world map location, but rocks near death plateau have a requirement of 15
|
||||||
YANILLE_UNDERWALL_TUNNEL(16, "Underwall Tunnel", new WorldPoint(2574, 3109, 0), HOLE_16520, WALL_17047),
|
YANILLE_UNDERWALL_TUNNEL(16, "Underwall Tunnel", new WorldPoint(2574, 3109, 0), HOLE_16520, CASTLE_WALL),
|
||||||
YANILLE_WATCHTOWER_TRELLIS(18, "Trellis", null, TRELLIS_20056),
|
YANILLE_WATCHTOWER_TRELLIS(18, "Trellis", null, TRELLIS_20056),
|
||||||
COAL_TRUCKS_LOG_BALANCE(20, "Log Balance", new WorldPoint(2598, 3475, 0), LOG_BALANCE_23274),
|
COAL_TRUCKS_LOG_BALANCE(20, "Log Balance", new WorldPoint(2598, 3475, 0), LOG_BALANCE_23274),
|
||||||
GRAND_EXCHANGE_UNDERWALL_TUNNEL(21, "Underwall Tunnel", new WorldPoint(3139, 3515, 0), UNDERWALL_TUNNEL_16529, UNDERWALL_TUNNEL_16530),
|
GRAND_EXCHANGE_UNDERWALL_TUNNEL(21, "Underwall Tunnel", new WorldPoint(3139, 3515, 0), UNDERWALL_TUNNEL_16529, UNDERWALL_TUNNEL_16530),
|
||||||
@@ -106,7 +106,7 @@ public enum AgilityShortcut
|
|||||||
CATHERBY_OBELISK_GRAPPLE(36, "Grapple Rock", new WorldPoint(2841, 3434, 0), CROSSBOW_TREE_17062),
|
CATHERBY_OBELISK_GRAPPLE(36, "Grapple Rock", new WorldPoint(2841, 3434, 0), CROSSBOW_TREE_17062),
|
||||||
GNOME_STRONGHOLD_ROCKS(37, "Rocks", new WorldPoint(2485, 3515, 0), ROCKS_16534, ROCKS_16535),
|
GNOME_STRONGHOLD_ROCKS(37, "Rocks", new WorldPoint(2485, 3515, 0), ROCKS_16534, ROCKS_16535),
|
||||||
AL_KHARID_MINING_PITCLIFF_SCRAMBLE(38, "Rocks", new WorldPoint(3305, 3315, 0), ROCKS_16549, ROCKS_16550),
|
AL_KHARID_MINING_PITCLIFF_SCRAMBLE(38, "Rocks", new WorldPoint(3305, 3315, 0), ROCKS_16549, ROCKS_16550),
|
||||||
YANILLE_WALL_GRAPPLE(39, "Grapple Wall", new WorldPoint(2552, 3072, 0), CASTLE_WALL),
|
YANILLE_WALL_GRAPPLE(39, "Grapple Wall", new WorldPoint(2552, 3072, 0), WALL_17047),
|
||||||
NEITIZNOT_BRIDGE_REPAIR(40, "Bridge Repair - Quest", new WorldPoint(2315, 3828, 0), ROPE_BRIDGE_21306, ROPE_BRIDGE_21307),
|
NEITIZNOT_BRIDGE_REPAIR(40, "Bridge Repair - Quest", new WorldPoint(2315, 3828, 0), ROPE_BRIDGE_21306, ROPE_BRIDGE_21307),
|
||||||
KOUREND_LAKE_JUMP_EAST(40, "Stepping Stones", new WorldPoint(1612, 3570, 0), STEPPING_STONE_29729, STEPPING_STONE_29730),
|
KOUREND_LAKE_JUMP_EAST(40, "Stepping Stones", new WorldPoint(1612, 3570, 0), STEPPING_STONE_29729, STEPPING_STONE_29730),
|
||||||
KOUREND_LAKE_JUMP_WEST(40, "Stepping Stones", new WorldPoint(1604, 3572, 0), STEPPING_STONE_29729, STEPPING_STONE_29730),
|
KOUREND_LAKE_JUMP_WEST(40, "Stepping Stones", new WorldPoint(1604, 3572, 0), STEPPING_STONE_29729, STEPPING_STONE_29730),
|
||||||
|
|||||||
@@ -86,4 +86,15 @@ public interface BarrowsConfig extends Config
|
|||||||
{
|
{
|
||||||
return Color.RED;
|
return Color.RED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "showPuzzleAnswer",
|
||||||
|
name = "Show Puzzle Answer",
|
||||||
|
description = "Configures if the puzzle answer should be shown.",
|
||||||
|
position = 5
|
||||||
|
)
|
||||||
|
default boolean showPuzzleAnswer()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ package net.runelite.client.plugins.barrows;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Rectangle;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
@@ -38,6 +39,7 @@ import net.runelite.api.Perspective;
|
|||||||
import net.runelite.api.Player;
|
import net.runelite.api.Player;
|
||||||
import net.runelite.api.WallObject;
|
import net.runelite.api.WallObject;
|
||||||
import net.runelite.api.coords.LocalPoint;
|
import net.runelite.api.coords.LocalPoint;
|
||||||
|
import net.runelite.api.widgets.Widget;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
@@ -66,6 +68,7 @@ class BarrowsOverlay extends Overlay
|
|||||||
Player local = client.getLocalPlayer();
|
Player local = client.getLocalPlayer();
|
||||||
final Color npcColor = getMinimapDotColor(1);
|
final Color npcColor = getMinimapDotColor(1);
|
||||||
final Color playerColor = getMinimapDotColor(2);
|
final Color playerColor = getMinimapDotColor(2);
|
||||||
|
Widget puzzleAnswer = plugin.getPuzzleAnswer();
|
||||||
|
|
||||||
// tunnels are only on z=0
|
// tunnels are only on z=0
|
||||||
if (!plugin.getWalls().isEmpty() && client.getPlane() == 0 && config.showMinimap())
|
if (!plugin.getWalls().isEmpty() && client.getPlane() == 0 && config.showMinimap())
|
||||||
@@ -119,6 +122,13 @@ class BarrowsOverlay extends Overlay
|
|||||||
renderBarrowsBrothers(graphics);
|
renderBarrowsBrothers(graphics);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (puzzleAnswer != null && config.showPuzzleAnswer() && !puzzleAnswer.isHidden())
|
||||||
|
{
|
||||||
|
Rectangle answerRect = puzzleAnswer.getBounds();
|
||||||
|
graphics.setColor(Color.GREEN);
|
||||||
|
graphics.draw(answerRect);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.barrows;
|
package net.runelite.client.plugins.barrows;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@@ -82,6 +83,11 @@ public class BarrowsPlugin extends Plugin
|
|||||||
);
|
);
|
||||||
|
|
||||||
private static final Set<Integer> BARROWS_LADDERS = Sets.newHashSet(NullObjectID.NULL_20675, NullObjectID.NULL_20676, NullObjectID.NULL_20677);
|
private static final Set<Integer> BARROWS_LADDERS = Sets.newHashSet(NullObjectID.NULL_20675, NullObjectID.NULL_20676, NullObjectID.NULL_20677);
|
||||||
|
private static final ImmutableList<WidgetInfo> POSSIBLE_SOLUTIONS = ImmutableList.of(
|
||||||
|
WidgetInfo.BARROWS_PUZZLE_ANSWER1,
|
||||||
|
WidgetInfo.BARROWS_PUZZLE_ANSWER2,
|
||||||
|
WidgetInfo.BARROWS_PUZZLE_ANSWER3
|
||||||
|
);
|
||||||
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private final Set<WallObject> walls = new HashSet<>();
|
private final Set<WallObject> walls = new HashSet<>();
|
||||||
@@ -89,6 +95,9 @@ public class BarrowsPlugin extends Plugin
|
|||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private final Set<GameObject> ladders = new HashSet<>();
|
private final Set<GameObject> ladders = new HashSet<>();
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private Widget puzzleAnswer;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private OverlayManager overlayManager;
|
private OverlayManager overlayManager;
|
||||||
|
|
||||||
@@ -130,6 +139,7 @@ public class BarrowsPlugin extends Plugin
|
|||||||
overlayManager.remove(brotherOverlay);
|
overlayManager.remove(brotherOverlay);
|
||||||
walls.clear();
|
walls.clear();
|
||||||
ladders.clear();
|
ladders.clear();
|
||||||
|
puzzleAnswer = null;
|
||||||
|
|
||||||
// Restore widgets
|
// Restore widgets
|
||||||
final Widget potential = client.getWidget(WidgetInfo.BARROWS_POTENTIAL);
|
final Widget potential = client.getWidget(WidgetInfo.BARROWS_POTENTIAL);
|
||||||
@@ -213,6 +223,7 @@ public class BarrowsPlugin extends Plugin
|
|||||||
// on region changes the tiles get set to null
|
// on region changes the tiles get set to null
|
||||||
walls.clear();
|
walls.clear();
|
||||||
ladders.clear();
|
ladders.clear();
|
||||||
|
puzzleAnswer = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -243,5 +254,21 @@ public class BarrowsPlugin extends Plugin
|
|||||||
.runeLiteFormattedMessage(message.build())
|
.runeLiteFormattedMessage(message.build())
|
||||||
.build());
|
.build());
|
||||||
}
|
}
|
||||||
|
else if (event.getGroupId() == WidgetID.BARROWS_PUZZLE_GROUP_ID)
|
||||||
|
{
|
||||||
|
final int answer = client.getWidget(WidgetInfo.BARROWS_FIRST_PUZZLE).getModelId() - 3;
|
||||||
|
puzzleAnswer = null;
|
||||||
|
|
||||||
|
for (WidgetInfo puzzleNode : POSSIBLE_SOLUTIONS)
|
||||||
|
{
|
||||||
|
final Widget widgetToCheck = client.getWidget(puzzleNode);
|
||||||
|
|
||||||
|
if (widgetToCheck != null && widgetToCheck.getModelId() == answer)
|
||||||
|
{
|
||||||
|
puzzleAnswer = client.getWidget(puzzleNode);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,65 +25,39 @@
|
|||||||
package net.runelite.client.plugins.inventorytags;
|
package net.runelite.client.plugins.inventorytags;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.Rectangle;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.Query;
|
|
||||||
import net.runelite.api.queries.InventoryWidgetItemQuery;
|
|
||||||
import net.runelite.api.widgets.WidgetItem;
|
import net.runelite.api.widgets.WidgetItem;
|
||||||
import net.runelite.client.game.ItemManager;
|
import net.runelite.client.game.ItemManager;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.WidgetItemOverlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
|
||||||
import net.runelite.client.ui.overlay.OverlayPriority;
|
|
||||||
import net.runelite.client.util.QueryRunner;
|
|
||||||
|
|
||||||
public class InventoryTagsOverlay extends Overlay
|
public class InventoryTagsOverlay extends WidgetItemOverlay
|
||||||
{
|
{
|
||||||
private final QueryRunner queryRunner;
|
|
||||||
private final ItemManager itemManager;
|
private final ItemManager itemManager;
|
||||||
private final InventoryTagsPlugin plugin;
|
private final InventoryTagsPlugin plugin;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private InventoryTagsOverlay(QueryRunner queryRunner, ItemManager itemManager, InventoryTagsPlugin plugin)
|
private InventoryTagsOverlay(ItemManager itemManager, InventoryTagsPlugin plugin)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
|
||||||
setPriority(OverlayPriority.LOW);
|
|
||||||
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
|
||||||
this.queryRunner = queryRunner;
|
|
||||||
this.itemManager = itemManager;
|
this.itemManager = itemManager;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension render(Graphics2D graphics)
|
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
|
||||||
{
|
{
|
||||||
if (!plugin.isHasTaggedItems())
|
final String group = plugin.getTag(itemId);
|
||||||
|
if (group != null)
|
||||||
{
|
{
|
||||||
return null;
|
final Color color = plugin.getGroupNameColor(group);
|
||||||
}
|
if (color != null)
|
||||||
|
|
||||||
// Now query the inventory for the tagged item ids
|
|
||||||
final Query query = new InventoryWidgetItemQuery();
|
|
||||||
final WidgetItem[] widgetItems = queryRunner.runQuery(query);
|
|
||||||
|
|
||||||
// Iterate through all found items and draw the outlines
|
|
||||||
for (final WidgetItem item : widgetItems)
|
|
||||||
{
|
|
||||||
final String group = plugin.getTag(item.getId());
|
|
||||||
|
|
||||||
if (group != null)
|
|
||||||
{
|
{
|
||||||
final Color color = plugin.getGroupNameColor(group);
|
Rectangle bounds = itemWidget.getCanvasBounds();
|
||||||
if (color != null)
|
final BufferedImage outline = itemManager.getItemOutline(itemId, itemWidget.getQuantity(), color);
|
||||||
{
|
graphics.drawImage(outline, (int) bounds.getX() + 1, (int) bounds.getY() + 1, null);
|
||||||
final BufferedImage outline = itemManager.getItemOutline(item.getId(), item.getQuantity(), color);
|
|
||||||
graphics.drawImage(outline, item.getCanvasLocation().getX() + 1, item.getCanvasLocation().getY() + 1, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,15 +30,9 @@ import com.google.inject.Provides;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.AccessLevel;
|
|
||||||
import lombok.Getter;
|
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.InventoryID;
|
|
||||||
import net.runelite.api.Item;
|
|
||||||
import net.runelite.api.ItemContainer;
|
|
||||||
import net.runelite.api.MenuAction;
|
import net.runelite.api.MenuAction;
|
||||||
import net.runelite.api.MenuEntry;
|
import net.runelite.api.MenuEntry;
|
||||||
import net.runelite.api.events.ItemContainerChanged;
|
|
||||||
import net.runelite.api.events.MenuOpened;
|
import net.runelite.api.events.MenuOpened;
|
||||||
import net.runelite.api.events.MenuOptionClicked;
|
import net.runelite.api.events.MenuOptionClicked;
|
||||||
import net.runelite.api.events.WidgetMenuOptionClicked;
|
import net.runelite.api.events.WidgetMenuOptionClicked;
|
||||||
@@ -107,9 +101,6 @@ public class InventoryTagsPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private OverlayManager overlayManager;
|
private OverlayManager overlayManager;
|
||||||
|
|
||||||
@Getter(AccessLevel.PACKAGE)
|
|
||||||
private boolean hasTaggedItems;
|
|
||||||
|
|
||||||
private boolean editorMode;
|
private boolean editorMode;
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@@ -151,7 +142,7 @@ public class InventoryTagsPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
removeInventoryMenuOptions();
|
removeInventoryMenuOptions();
|
||||||
overlayManager.remove(overlay);
|
overlayManager.remove(overlay);
|
||||||
hasTaggedItems = editorMode = false;
|
editorMode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -179,14 +170,10 @@ public class InventoryTagsPlugin extends Plugin
|
|||||||
if (event.getMenuOption().equals(MENU_SET))
|
if (event.getMenuOption().equals(MENU_SET))
|
||||||
{
|
{
|
||||||
setTag(event.getId(), selectedMenu);
|
setTag(event.getId(), selectedMenu);
|
||||||
|
|
||||||
hasTaggedItems = true;
|
|
||||||
}
|
}
|
||||||
else if (event.getMenuOption().equals(MENU_REMOVE))
|
else if (event.getMenuOption().equals(MENU_REMOVE))
|
||||||
{
|
{
|
||||||
unsetTag(event.getId());
|
unsetTag(event.getId());
|
||||||
|
|
||||||
checkForTags(client.getItemContainer(InventoryID.INVENTORY));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,47 +222,6 @@ public class InventoryTagsPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onItemContainerChanged(ItemContainerChanged itemContainerChanged)
|
|
||||||
{
|
|
||||||
ItemContainer itemContainer = itemContainerChanged.getItemContainer();
|
|
||||||
if (itemContainer == client.getItemContainer(InventoryID.INVENTORY))
|
|
||||||
{
|
|
||||||
checkForTags(itemContainer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void checkForTags(ItemContainer itemContainer)
|
|
||||||
{
|
|
||||||
hasTaggedItems = false;
|
|
||||||
|
|
||||||
if (itemContainer == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Item[] items = itemContainer.getItems();
|
|
||||||
if (items != null)
|
|
||||||
{
|
|
||||||
for (Item item : items)
|
|
||||||
{
|
|
||||||
if (item == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String tag = getTag(item.getId());
|
|
||||||
if (tag == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
hasTaggedItems = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Color getGroupNameColor(final String name)
|
Color getGroupNameColor(final String name)
|
||||||
{
|
{
|
||||||
switch (name)
|
switch (name)
|
||||||
|
|||||||
@@ -24,125 +24,93 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.itemcharges;
|
package net.runelite.client.plugins.itemcharges;
|
||||||
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import net.runelite.api.ItemID;
|
import net.runelite.api.ItemID;
|
||||||
import net.runelite.api.Query;
|
|
||||||
import net.runelite.api.queries.EquipmentItemQuery;
|
|
||||||
import net.runelite.api.queries.InventoryWidgetItemQuery;
|
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
|
||||||
import net.runelite.api.widgets.WidgetItem;
|
import net.runelite.api.widgets.WidgetItem;
|
||||||
import static net.runelite.client.plugins.itemcharges.ItemChargeType.*;
|
import static net.runelite.client.plugins.itemcharges.ItemChargeType.ABYSSAL_BRACELET;
|
||||||
|
import static net.runelite.client.plugins.itemcharges.ItemChargeType.BELLOWS;
|
||||||
|
import static net.runelite.client.plugins.itemcharges.ItemChargeType.FUNGICIDE_SPRAY;
|
||||||
|
import static net.runelite.client.plugins.itemcharges.ItemChargeType.IMPBOX;
|
||||||
|
import static net.runelite.client.plugins.itemcharges.ItemChargeType.TELEPORT;
|
||||||
|
import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERCAN;
|
||||||
|
import static net.runelite.client.plugins.itemcharges.ItemChargeType.WATERSKIN;
|
||||||
import net.runelite.client.ui.FontManager;
|
import net.runelite.client.ui.FontManager;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.WidgetItemOverlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
|
||||||
import net.runelite.client.ui.overlay.components.TextComponent;
|
import net.runelite.client.ui.overlay.components.TextComponent;
|
||||||
import net.runelite.client.util.QueryRunner;
|
|
||||||
|
|
||||||
class ItemChargeOverlay extends Overlay
|
class ItemChargeOverlay extends WidgetItemOverlay
|
||||||
{
|
{
|
||||||
private final QueryRunner queryRunner;
|
|
||||||
private final ItemChargePlugin itemChargePlugin;
|
private final ItemChargePlugin itemChargePlugin;
|
||||||
private final ItemChargeConfig config;
|
private final ItemChargeConfig config;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ItemChargeOverlay(QueryRunner queryRunner, ItemChargePlugin itemChargePlugin, ItemChargeConfig config)
|
ItemChargeOverlay(ItemChargePlugin itemChargePlugin, ItemChargeConfig config)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
|
||||||
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
|
||||||
this.queryRunner = queryRunner;
|
|
||||||
this.itemChargePlugin = itemChargePlugin;
|
this.itemChargePlugin = itemChargePlugin;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension render(Graphics2D graphics)
|
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
|
||||||
{
|
{
|
||||||
if (!displayOverlay())
|
if (!displayOverlay())
|
||||||
{
|
{
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
graphics.setFont(FontManager.getRunescapeSmallFont());
|
graphics.setFont(FontManager.getRunescapeSmallFont());
|
||||||
|
|
||||||
for (WidgetItem item : getChargeWidgetItems())
|
int charges;
|
||||||
|
if (itemId == ItemID.DODGY_NECKLACE)
|
||||||
{
|
{
|
||||||
int charges;
|
if (!config.showDodgyCount())
|
||||||
if (item.getId() == ItemID.DODGY_NECKLACE)
|
|
||||||
{
|
{
|
||||||
if (!config.showDodgyCount())
|
return;
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
charges = config.dodgyNecklace();
|
|
||||||
}
|
|
||||||
else if (item.getId() == ItemID.BINDING_NECKLACE)
|
|
||||||
{
|
|
||||||
if (!config.showBindingNecklaceCharges())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
charges = config.bindingNecklace();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ItemWithCharge chargeItem = ItemWithCharge.findItem(item.getId());
|
|
||||||
if (chargeItem == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ItemChargeType type = chargeItem.getType();
|
|
||||||
if ((type == TELEPORT && !config.showTeleportCharges())
|
|
||||||
|| (type == FUNGICIDE_SPRAY && !config.showFungicideCharges())
|
|
||||||
|| (type == IMPBOX && !config.showImpCharges())
|
|
||||||
|| (type == WATERCAN && !config.showWateringCanCharges())
|
|
||||||
|| (type == WATERSKIN && !config.showWaterskinCharges())
|
|
||||||
|| (type == BELLOWS && !config.showBellowCharges())
|
|
||||||
|| (type == ABYSSAL_BRACELET && !config.showAbyssalBraceletCharges()))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
charges = chargeItem.getCharges();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final Rectangle bounds = item.getCanvasBounds();
|
charges = config.dodgyNecklace();
|
||||||
final TextComponent textComponent = new TextComponent();
|
|
||||||
textComponent.setPosition(new Point(bounds.x, bounds.y + 16));
|
|
||||||
textComponent.setText(charges < 0 ? "?" : String.valueOf(charges));
|
|
||||||
textComponent.setColor(itemChargePlugin.getColor(charges));
|
|
||||||
textComponent.render(graphics);
|
|
||||||
}
|
}
|
||||||
return null;
|
else if (itemId == ItemID.BINDING_NECKLACE)
|
||||||
}
|
{
|
||||||
|
if (!config.showBindingNecklaceCharges())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
private Collection<WidgetItem> getChargeWidgetItems()
|
charges = config.bindingNecklace();
|
||||||
{
|
}
|
||||||
Query inventoryQuery = new InventoryWidgetItemQuery();
|
else
|
||||||
WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
|
{
|
||||||
|
ItemWithCharge chargeItem = ItemWithCharge.findItem(itemId);
|
||||||
|
if (chargeItem == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Query equipmentQuery = new EquipmentItemQuery().slotEquals(
|
ItemChargeType type = chargeItem.getType();
|
||||||
WidgetInfo.EQUIPMENT_AMULET,
|
if ((type == TELEPORT && !config.showTeleportCharges())
|
||||||
WidgetInfo.EQUIPMENT_RING,
|
|| (type == FUNGICIDE_SPRAY && !config.showFungicideCharges())
|
||||||
WidgetInfo.EQUIPMENT_GLOVES,
|
|| (type == IMPBOX && !config.showImpCharges())
|
||||||
WidgetInfo.EQUIPMENT_WEAPON
|
|| (type == WATERCAN && !config.showWateringCanCharges())
|
||||||
);
|
|| (type == WATERSKIN && !config.showWaterskinCharges())
|
||||||
WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
|
|| (type == BELLOWS && !config.showBellowCharges())
|
||||||
|
|| (type == ABYSSAL_BRACELET && !config.showAbyssalBraceletCharges()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Collection<WidgetItem> jewellery = new ArrayList<>();
|
charges = chargeItem.getCharges();
|
||||||
jewellery.addAll(Arrays.asList(inventoryWidgetItems));
|
}
|
||||||
jewellery.addAll(Arrays.asList(equipmentWidgetItems));
|
|
||||||
return jewellery;
|
final Rectangle bounds = itemWidget.getCanvasBounds();
|
||||||
|
final TextComponent textComponent = new TextComponent();
|
||||||
|
textComponent.setPosition(new Point(bounds.x, bounds.y + 16));
|
||||||
|
textComponent.setText(charges < 0 ? "?" : String.valueOf(charges));
|
||||||
|
textComponent.setColor(itemChargePlugin.getColor(charges));
|
||||||
|
textComponent.render(graphics);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean displayOverlay()
|
private boolean displayOverlay()
|
||||||
|
|||||||
@@ -32,24 +32,19 @@ import javax.inject.Inject;
|
|||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.ItemID;
|
import net.runelite.api.ItemID;
|
||||||
import net.runelite.api.Point;
|
import net.runelite.api.Point;
|
||||||
import net.runelite.api.Query;
|
|
||||||
import net.runelite.api.Varbits;
|
import net.runelite.api.Varbits;
|
||||||
import net.runelite.api.queries.InventoryWidgetItemQuery;
|
|
||||||
import net.runelite.api.widgets.WidgetItem;
|
import net.runelite.api.widgets.WidgetItem;
|
||||||
import net.runelite.client.game.ItemManager;
|
import net.runelite.client.game.ItemManager;
|
||||||
import static net.runelite.client.plugins.runepouch.config.RunePouchOverlayMode.BOTH;
|
import static net.runelite.client.plugins.runepouch.config.RunePouchOverlayMode.BOTH;
|
||||||
import static net.runelite.client.plugins.runepouch.config.RunePouchOverlayMode.MOUSE_HOVER;
|
import static net.runelite.client.plugins.runepouch.config.RunePouchOverlayMode.MOUSE_HOVER;
|
||||||
import net.runelite.client.ui.FontManager;
|
import net.runelite.client.ui.FontManager;
|
||||||
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 net.runelite.client.ui.overlay.OverlayUtil;
|
||||||
|
import net.runelite.client.ui.overlay.WidgetItemOverlay;
|
||||||
import net.runelite.client.ui.overlay.tooltip.Tooltip;
|
import net.runelite.client.ui.overlay.tooltip.Tooltip;
|
||||||
import net.runelite.client.ui.overlay.tooltip.TooltipManager;
|
import net.runelite.client.ui.overlay.tooltip.TooltipManager;
|
||||||
import net.runelite.client.util.ColorUtil;
|
import net.runelite.client.util.ColorUtil;
|
||||||
import net.runelite.client.util.QueryRunner;
|
|
||||||
|
|
||||||
public class RunepouchOverlay extends Overlay
|
public class RunepouchOverlay extends WidgetItemOverlay
|
||||||
{
|
{
|
||||||
private static final Varbits[] AMOUNT_VARBITS =
|
private static final Varbits[] AMOUNT_VARBITS =
|
||||||
{
|
{
|
||||||
@@ -61,8 +56,6 @@ public class RunepouchOverlay extends Overlay
|
|||||||
};
|
};
|
||||||
private static final Dimension IMAGE_SIZE = new Dimension(11, 11);
|
private static final Dimension IMAGE_SIZE = new Dimension(11, 11);
|
||||||
|
|
||||||
|
|
||||||
private final QueryRunner queryRunner;
|
|
||||||
private final Client client;
|
private final Client client;
|
||||||
private final RunepouchConfig config;
|
private final RunepouchConfig config;
|
||||||
private final TooltipManager tooltipManager;
|
private final TooltipManager tooltipManager;
|
||||||
@@ -71,37 +64,26 @@ public class RunepouchOverlay extends Overlay
|
|||||||
private ItemManager itemManager;
|
private ItemManager itemManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
RunepouchOverlay(QueryRunner queryRunner, Client client, RunepouchConfig config, TooltipManager tooltipManager)
|
RunepouchOverlay(Client client, RunepouchConfig config, TooltipManager tooltipManager)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
|
||||||
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
|
||||||
this.tooltipManager = tooltipManager;
|
this.tooltipManager = tooltipManager;
|
||||||
this.queryRunner = queryRunner;
|
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension render(Graphics2D graphics)
|
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
|
||||||
{
|
{
|
||||||
Query query = new InventoryWidgetItemQuery().idEquals(ItemID.RUNE_POUCH);
|
if (itemId != ItemID.RUNE_POUCH)
|
||||||
WidgetItem[] items = queryRunner.runQuery(query);
|
|
||||||
if (items.length == 0)
|
|
||||||
{
|
{
|
||||||
return null;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
WidgetItem runePouch = items[0];
|
|
||||||
Point location = runePouch.getCanvasLocation();
|
|
||||||
if (location == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
assert AMOUNT_VARBITS.length == RUNE_VARBITS.length;
|
assert AMOUNT_VARBITS.length == RUNE_VARBITS.length;
|
||||||
|
|
||||||
graphics.setFont(FontManager.getRunescapeSmallFont());
|
graphics.setFont(FontManager.getRunescapeSmallFont());
|
||||||
|
|
||||||
|
Point location = itemWidget.getCanvasLocation();
|
||||||
StringBuilder tooltipBuilder = new StringBuilder();
|
StringBuilder tooltipBuilder = new StringBuilder();
|
||||||
|
|
||||||
for (int i = 0; i < AMOUNT_VARBITS.length; i++)
|
for (int i = 0; i < AMOUNT_VARBITS.length; i++)
|
||||||
@@ -158,12 +140,11 @@ public class RunepouchOverlay extends Overlay
|
|||||||
String tooltip = tooltipBuilder.toString();
|
String tooltip = tooltipBuilder.toString();
|
||||||
|
|
||||||
if (!tooltip.isEmpty()
|
if (!tooltip.isEmpty()
|
||||||
&& runePouch.getCanvasBounds().contains(client.getMouseCanvasPosition().getX(), client.getMouseCanvasPosition().getY())
|
&& itemWidget.getCanvasBounds().contains(client.getMouseCanvasPosition().getX(), client.getMouseCanvasPosition().getY())
|
||||||
&& (config.runePouchOverlayMode() == MOUSE_HOVER || config.runePouchOverlayMode() == BOTH))
|
&& (config.runePouchOverlayMode() == MOUSE_HOVER || config.runePouchOverlayMode() == BOTH))
|
||||||
{
|
{
|
||||||
tooltipManager.add(new Tooltip(tooltip));
|
tooltipManager.add(new Tooltip(tooltip));
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private BufferedImage getRuneImage(Runes rune)
|
private BufferedImage getRuneImage(Runes rune)
|
||||||
|
|||||||
@@ -24,111 +24,88 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.slayer;
|
package net.runelite.client.plugins.slayer;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import static com.google.common.collect.ObjectArrays.concat;
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.awt.Rectangle;
|
import java.awt.Rectangle;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import com.google.common.primitives.ImmutableIntArray;
|
|
||||||
import net.runelite.api.ItemID;
|
import net.runelite.api.ItemID;
|
||||||
import net.runelite.api.Query;
|
|
||||||
import net.runelite.api.queries.EquipmentItemQuery;
|
|
||||||
import net.runelite.api.queries.InventoryWidgetItemQuery;
|
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
|
||||||
import net.runelite.api.widgets.WidgetItem;
|
import net.runelite.api.widgets.WidgetItem;
|
||||||
import net.runelite.client.ui.FontManager;
|
import net.runelite.client.ui.FontManager;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.WidgetItemOverlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
|
||||||
import net.runelite.client.ui.overlay.components.TextComponent;
|
import net.runelite.client.ui.overlay.components.TextComponent;
|
||||||
import net.runelite.client.util.QueryRunner;
|
|
||||||
|
|
||||||
class SlayerOverlay extends Overlay
|
class SlayerOverlay extends WidgetItemOverlay
|
||||||
{
|
{
|
||||||
private final static Set<Integer> SLAYER_JEWELRY = ImmutableSet.of(
|
private final static Set<Integer> SLAYER_JEWELRY = ImmutableSet.of(
|
||||||
ItemID.SLAYER_RING_1,
|
ItemID.SLAYER_RING_1,
|
||||||
ItemID.SLAYER_RING_2,
|
ItemID.SLAYER_RING_2,
|
||||||
ItemID.SLAYER_RING_3,
|
ItemID.SLAYER_RING_3,
|
||||||
ItemID.SLAYER_RING_4,
|
ItemID.SLAYER_RING_4,
|
||||||
ItemID.SLAYER_RING_5,
|
ItemID.SLAYER_RING_5,
|
||||||
ItemID.SLAYER_RING_6,
|
ItemID.SLAYER_RING_6,
|
||||||
ItemID.SLAYER_RING_7,
|
ItemID.SLAYER_RING_7,
|
||||||
ItemID.SLAYER_RING_8
|
ItemID.SLAYER_RING_8
|
||||||
);
|
);
|
||||||
|
|
||||||
private final static ImmutableIntArray ALL_SLAYER_ITEMS = ImmutableIntArray.of(
|
private final static Set<Integer> ALL_SLAYER_ITEMS = ImmutableSet.of(
|
||||||
ItemID.SLAYER_HELMET,
|
ItemID.SLAYER_HELMET,
|
||||||
ItemID.SLAYER_HELMET_I,
|
ItemID.SLAYER_HELMET_I,
|
||||||
ItemID.BLACK_SLAYER_HELMET,
|
ItemID.BLACK_SLAYER_HELMET,
|
||||||
ItemID.BLACK_SLAYER_HELMET_I,
|
ItemID.BLACK_SLAYER_HELMET_I,
|
||||||
ItemID.GREEN_SLAYER_HELMET,
|
ItemID.GREEN_SLAYER_HELMET,
|
||||||
ItemID.GREEN_SLAYER_HELMET_I,
|
ItemID.GREEN_SLAYER_HELMET_I,
|
||||||
ItemID.PURPLE_SLAYER_HELMET,
|
ItemID.PURPLE_SLAYER_HELMET,
|
||||||
ItemID.PURPLE_SLAYER_HELMET_I,
|
ItemID.PURPLE_SLAYER_HELMET_I,
|
||||||
ItemID.RED_SLAYER_HELMET,
|
ItemID.RED_SLAYER_HELMET,
|
||||||
ItemID.RED_SLAYER_HELMET_I,
|
ItemID.RED_SLAYER_HELMET_I,
|
||||||
ItemID.TURQUOISE_SLAYER_HELMET,
|
ItemID.TURQUOISE_SLAYER_HELMET,
|
||||||
ItemID.TURQUOISE_SLAYER_HELMET_I,
|
ItemID.TURQUOISE_SLAYER_HELMET_I,
|
||||||
ItemID.HYDRA_SLAYER_HELMET,
|
ItemID.HYDRA_SLAYER_HELMET,
|
||||||
ItemID.HYDRA_SLAYER_HELMET_I,
|
ItemID.HYDRA_SLAYER_HELMET_I,
|
||||||
ItemID.SLAYER_RING_ETERNAL,
|
ItemID.SLAYER_RING_ETERNAL,
|
||||||
ItemID.ENCHANTED_GEM,
|
ItemID.ENCHANTED_GEM,
|
||||||
ItemID.ETERNAL_GEM,
|
ItemID.ETERNAL_GEM,
|
||||||
ItemID.BRACELET_OF_SLAUGHTER,
|
ItemID.BRACELET_OF_SLAUGHTER,
|
||||||
ItemID.EXPEDITIOUS_BRACELET,
|
ItemID.EXPEDITIOUS_BRACELET,
|
||||||
ItemID.SLAYER_RING_1,
|
ItemID.SLAYER_RING_1,
|
||||||
ItemID.SLAYER_RING_2,
|
ItemID.SLAYER_RING_2,
|
||||||
ItemID.SLAYER_RING_3,
|
ItemID.SLAYER_RING_3,
|
||||||
ItemID.SLAYER_RING_4,
|
ItemID.SLAYER_RING_4,
|
||||||
ItemID.SLAYER_RING_5,
|
ItemID.SLAYER_RING_5,
|
||||||
ItemID.SLAYER_RING_6,
|
ItemID.SLAYER_RING_6,
|
||||||
ItemID.SLAYER_RING_7,
|
ItemID.SLAYER_RING_7,
|
||||||
ItemID.SLAYER_RING_8
|
ItemID.SLAYER_RING_8
|
||||||
);
|
);
|
||||||
|
|
||||||
private final SlayerConfig config;
|
private final SlayerConfig config;
|
||||||
private final SlayerPlugin plugin;
|
private final SlayerPlugin plugin;
|
||||||
private final QueryRunner queryRunner;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private SlayerOverlay(SlayerPlugin plugin, SlayerConfig config, QueryRunner queryRunner)
|
private SlayerOverlay(SlayerPlugin plugin, SlayerConfig config)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.DYNAMIC);
|
|
||||||
setLayer(OverlayLayer.ABOVE_WIDGETS);
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.queryRunner = queryRunner;
|
|
||||||
}
|
|
||||||
|
|
||||||
private ImmutableList<WidgetItem> getSlayerItems()
|
|
||||||
{
|
|
||||||
int[] slayerItems = ALL_SLAYER_ITEMS.toArray();
|
|
||||||
Query inventoryQuery = new InventoryWidgetItemQuery().idEquals(slayerItems);
|
|
||||||
WidgetItem[] inventoryWidgetItems = queryRunner.runQuery(inventoryQuery);
|
|
||||||
|
|
||||||
Query equipmentQuery = new EquipmentItemQuery().slotEquals(WidgetInfo.EQUIPMENT_HELMET, WidgetInfo.EQUIPMENT_RING, WidgetInfo.EQUIPMENT_GLOVES).idEquals(slayerItems);
|
|
||||||
WidgetItem[] equipmentWidgetItems = queryRunner.runQuery(equipmentQuery);
|
|
||||||
|
|
||||||
WidgetItem[] items = concat(inventoryWidgetItems, equipmentWidgetItems, WidgetItem.class);
|
|
||||||
return ImmutableList.copyOf(items);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension render(Graphics2D graphics)
|
public void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget)
|
||||||
{
|
{
|
||||||
|
if (!ALL_SLAYER_ITEMS.contains(itemId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!config.showItemOverlay())
|
if (!config.showItemOverlay())
|
||||||
{
|
{
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int amount = plugin.getAmount();
|
int amount = plugin.getAmount();
|
||||||
if (amount <= 0)
|
if (amount <= 0)
|
||||||
{
|
{
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int slaughterCount = plugin.getSlaughterChargeCount();
|
int slaughterCount = plugin.getSlaughterChargeCount();
|
||||||
@@ -136,33 +113,26 @@ class SlayerOverlay extends Overlay
|
|||||||
|
|
||||||
graphics.setFont(FontManager.getRunescapeSmallFont());
|
graphics.setFont(FontManager.getRunescapeSmallFont());
|
||||||
|
|
||||||
for (WidgetItem item : getSlayerItems())
|
final Rectangle bounds = itemWidget.getCanvasBounds();
|
||||||
|
final TextComponent textComponent = new TextComponent();
|
||||||
|
|
||||||
|
switch (itemId)
|
||||||
{
|
{
|
||||||
int itemId = item.getId();
|
case ItemID.EXPEDITIOUS_BRACELET:
|
||||||
|
textComponent.setText(String.valueOf(expeditiousCount));
|
||||||
final Rectangle bounds = item.getCanvasBounds();
|
break;
|
||||||
final TextComponent textComponent = new TextComponent();
|
case ItemID.BRACELET_OF_SLAUGHTER:
|
||||||
|
textComponent.setText(String.valueOf(slaughterCount));
|
||||||
switch (item.getId())
|
break;
|
||||||
{
|
default:
|
||||||
case ItemID.EXPEDITIOUS_BRACELET:
|
textComponent.setText(String.valueOf(amount));
|
||||||
textComponent.setText(String.valueOf(expeditiousCount));
|
break;
|
||||||
break;
|
|
||||||
case ItemID.BRACELET_OF_SLAUGHTER:
|
|
||||||
textComponent.setText(String.valueOf(slaughterCount));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
textComponent.setText(String.valueOf(amount));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw the counter in the bottom left for equipment, and top left for jewelry
|
|
||||||
textComponent.setPosition(new Point(bounds.x, bounds.y + (SLAYER_JEWELRY.contains(itemId)
|
|
||||||
? bounds.height
|
|
||||||
: graphics.getFontMetrics().getHeight())));
|
|
||||||
textComponent.render(graphics);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
// Draw the counter in the bottom left for equipment, and top left for jewelry
|
||||||
|
textComponent.setPosition(new Point(bounds.x, bounds.y + (SLAYER_JEWELRY.contains(itemId)
|
||||||
|
? bounds.height
|
||||||
|
: graphics.getFontMetrics().getHeight())));
|
||||||
|
textComponent.render(graphics);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ enum Task
|
|||||||
ABERRANT_SPECTRES("Aberrant spectres", ItemID.ABERRANT_SPECTRE, "Spectre"),
|
ABERRANT_SPECTRES("Aberrant spectres", ItemID.ABERRANT_SPECTRE, "Spectre"),
|
||||||
ABYSSAL_DEMONS("Abyssal demons", ItemID.ABYSSAL_DEMON),
|
ABYSSAL_DEMONS("Abyssal demons", ItemID.ABYSSAL_DEMON),
|
||||||
ABYSSAL_SIRE("Abyssal Sire", ItemID.ABYSSAL_ORPHAN),
|
ABYSSAL_SIRE("Abyssal Sire", ItemID.ABYSSAL_ORPHAN),
|
||||||
ADAMANT_DRAGONS("Adamant dragons", ItemID.ADAMANTITE_BAR),
|
ADAMANT_DRAGONS("Adamant dragons", ItemID.ADAMANT_DRAGON_MASK),
|
||||||
ALCHEMICAL_HYDRA("Alchemical Hydra", ItemID.IKKLE_HYDRA),
|
ALCHEMICAL_HYDRA("Alchemical Hydra", ItemID.IKKLE_HYDRA),
|
||||||
ANKOU("Ankou", ItemID.ANKOU_MASK),
|
ANKOU("Ankou", ItemID.ANKOU_MASK),
|
||||||
AVIANSIES("Aviansies", ItemID.ENSOULED_AVIANSIE_HEAD),
|
AVIANSIES("Aviansies", ItemID.ENSOULED_AVIANSIE_HEAD),
|
||||||
@@ -137,7 +137,7 @@ enum Task
|
|||||||
RATS("Rats", ItemID.RATS_TAIL),
|
RATS("Rats", ItemID.RATS_TAIL),
|
||||||
RED_DRAGONS("Red dragons", ItemID.BABY_RED_DRAGON),
|
RED_DRAGONS("Red dragons", ItemID.BABY_RED_DRAGON),
|
||||||
ROCKSLUGS("Rockslugs", ItemID.ROCKSLUG, 4, ItemID.BAG_OF_SALT),
|
ROCKSLUGS("Rockslugs", ItemID.ROCKSLUG, 4, ItemID.BAG_OF_SALT),
|
||||||
RUNE_DRAGONS("Rune dragons", ItemID.RUNITE_BAR),
|
RUNE_DRAGONS("Rune dragons", ItemID.RUNE_DRAGON_MASK),
|
||||||
SCORPIA("Scorpia", ItemID.SCORPIAS_OFFSPRING),
|
SCORPIA("Scorpia", ItemID.SCORPIAS_OFFSPRING),
|
||||||
CHAOS_DRUIDS("Chaos druids", ItemID.ELDER_CHAOS_HOOD, "Elder Chaos druid", "Chaos druid"),
|
CHAOS_DRUIDS("Chaos druids", ItemID.ELDER_CHAOS_HOOD, "Elder Chaos druid", "Chaos druid"),
|
||||||
BANDITS("Bandits", ItemID.BANDIT, "Bandit"),
|
BANDITS("Bandits", ItemID.BANDIT, "Bandit"),
|
||||||
|
|||||||
@@ -26,15 +26,14 @@
|
|||||||
package net.runelite.client.rs;
|
package net.runelite.client.rs;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import okhttp3.Request;
|
|
||||||
import okhttp3.Response;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
import okhttp3.OkHttpClient;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class ClientConfigLoader
|
class ClientConfigLoader
|
||||||
@@ -52,13 +51,13 @@ class ClientConfigLoader
|
|||||||
RSConfig fetch() throws IOException
|
RSConfig fetch() throws IOException
|
||||||
{
|
{
|
||||||
final Request request = new Request.Builder()
|
final Request request = new Request.Builder()
|
||||||
.url(CONFIG_URL)
|
.url(CONFIG_URL)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
final RSConfig config = new RSConfig();
|
final RSConfig config = new RSConfig();
|
||||||
|
|
||||||
try (final Response response = httpClient.newCall(request).execute(); final BufferedReader in = new BufferedReader(
|
try (final Response response = httpClient.newCall(request).execute(); final BufferedReader in = new BufferedReader(
|
||||||
new InputStreamReader(response.body().byteStream())))
|
new InputStreamReader(response.body().byteStream())))
|
||||||
{
|
{
|
||||||
String str;
|
String str;
|
||||||
|
|
||||||
|
|||||||
@@ -32,12 +32,47 @@ import com.google.common.reflect.TypeToken;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import io.sigpipe.jbsdiff.InvalidHeaderException;
|
import io.sigpipe.jbsdiff.InvalidHeaderException;
|
||||||
import io.sigpipe.jbsdiff.Patch;
|
import io.sigpipe.jbsdiff.Patch;
|
||||||
|
import java.applet.Applet;
|
||||||
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.FileReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
import java.security.cert.Certificate;
|
||||||
|
import java.security.cert.CertificateException;
|
||||||
|
import java.security.cert.CertificateFactory;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.jar.Attributes;
|
||||||
|
import java.util.jar.JarEntry;
|
||||||
|
import java.util.jar.JarInputStream;
|
||||||
|
import java.util.jar.JarOutputStream;
|
||||||
|
import java.util.jar.Manifest;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import javassist.ClassPool;
|
import javassist.ClassPool;
|
||||||
import javassist.NotFoundException;
|
import javassist.NotFoundException;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import static net.runelite.client.rs.ClientUpdateCheckMode.AUTO;
|
||||||
|
import static net.runelite.client.rs.ClientUpdateCheckMode.NONE;
|
||||||
|
import static net.runelite.client.rs.ClientUpdateCheckMode.VANILLA;
|
||||||
|
|
||||||
import net.runelite.client.RuneLite;
|
import net.runelite.client.RuneLite;
|
||||||
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
|
||||||
import net.runelite.client.rs.bytecode.ByteCodeUtils;
|
import net.runelite.client.rs.bytecode.ByteCodeUtils;
|
||||||
|
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
||||||
import net.runelite.client.rs.bytecode.Hooks;
|
import net.runelite.client.rs.bytecode.Hooks;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import okhttp3.Request;
|
import okhttp3.Request;
|
||||||
@@ -45,28 +80,6 @@ import okhttp3.Response;
|
|||||||
import org.apache.commons.compress.compressors.CompressorException;
|
import org.apache.commons.compress.compressors.CompressorException;
|
||||||
import org.xeustechnologies.jcl.JarClassLoader;
|
import org.xeustechnologies.jcl.JarClassLoader;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Named;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
import java.applet.Applet;
|
|
||||||
import java.io.*;
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLClassLoader;
|
|
||||||
import java.security.cert.Certificate;
|
|
||||||
import java.security.cert.CertificateException;
|
|
||||||
import java.security.cert.CertificateFactory;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.jar.*;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
import static net.runelite.client.rs.ClientUpdateCheckMode.*;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ClientLoader
|
public class ClientLoader
|
||||||
@@ -75,7 +88,6 @@ public class ClientLoader
|
|||||||
private final ClientConfigLoader clientConfigLoader;
|
private final ClientConfigLoader clientConfigLoader;
|
||||||
private ClientUpdateCheckMode updateCheckMode;
|
private ClientUpdateCheckMode updateCheckMode;
|
||||||
private JarOutputStream target;
|
private JarOutputStream target;
|
||||||
private boolean scrapedHooks = false;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private ClientLoader(
|
private ClientLoader(
|
||||||
@@ -86,20 +98,248 @@ public class ClientLoader
|
|||||||
this.clientConfigLoader = clientConfigLoader;
|
this.clientConfigLoader = clientConfigLoader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Applet load()
|
||||||
|
{
|
||||||
|
if (updateCheckMode == NONE)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File injectedClientFile = ByteCodeUtils.injectedClientFile;
|
||||||
|
File hijackedClientFile = ByteCodeUtils.hijackedClientFile;
|
||||||
|
Manifest manifest = new Manifest();
|
||||||
|
manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
|
||||||
|
target = new JarOutputStream(new FileOutputStream(injectedClientFile), manifest);
|
||||||
|
RSConfig config = clientConfigLoader.fetch();
|
||||||
|
|
||||||
|
Map<String, byte[]> zipFile = new HashMap<>();
|
||||||
|
{
|
||||||
|
Certificate[] jagexCertificateChain = getJagexCertificateChain();
|
||||||
|
String codebase = config.getCodeBase();
|
||||||
|
String initialJar = config.getInitialJar();
|
||||||
|
URL url = new URL(codebase + initialJar);
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
|
||||||
|
{
|
||||||
|
JarInputStream jis;
|
||||||
|
|
||||||
|
jis = new JarInputStream(response.body().byteStream());
|
||||||
|
|
||||||
|
byte[] tmp = new byte[4096];
|
||||||
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream(756 * 1024);
|
||||||
|
for (; ; )
|
||||||
|
{
|
||||||
|
JarEntry metadata = jis.getNextJarEntry();
|
||||||
|
if (metadata == null)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer.reset();
|
||||||
|
for (; ; )
|
||||||
|
{
|
||||||
|
int n = jis.read(tmp);
|
||||||
|
if (n <= -1)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
buffer.write(tmp, 0, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
zipFile.put(metadata.getName(), buffer.toByteArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updateCheckMode == AUTO)
|
||||||
|
{
|
||||||
|
Map<String, String> hashes;
|
||||||
|
try (InputStream is = ClientLoader.class.getResourceAsStream("/patch/hashes.json"))
|
||||||
|
{
|
||||||
|
hashes = new Gson().fromJson(new InputStreamReader(is), new TypeToken<HashMap<String, String>>()
|
||||||
|
{
|
||||||
|
}.getType());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Map.Entry<String, String> file : hashes.entrySet())
|
||||||
|
{
|
||||||
|
byte[] bytes = zipFile.get(file.getKey());
|
||||||
|
|
||||||
|
String ourHash = null;
|
||||||
|
if (bytes != null)
|
||||||
|
{
|
||||||
|
ourHash = Hashing.sha512().hashBytes(bytes).toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!file.getValue().equals(ourHash))
|
||||||
|
{
|
||||||
|
if (hijackedClientFile.exists()) {
|
||||||
|
Logger.getAnonymousLogger().warning("[RuneLit] Hash checking / Client patching skipped due to hijacked client.");
|
||||||
|
updateCheckMode = VANILLA;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
log.info("{} had a hash mismatch; falling back to vanilla. {} != {}", file.getKey(), file.getValue(), ourHash);
|
||||||
|
log.info("Client is outdated!");
|
||||||
|
updateCheckMode = VANILLA;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (updateCheckMode == AUTO)
|
||||||
|
{
|
||||||
|
ByteArrayOutputStream patchOs = new ByteArrayOutputStream(756 * 1024);
|
||||||
|
int patchCount = 0;
|
||||||
|
|
||||||
|
for (Map.Entry<String, byte[]> file : zipFile.entrySet())
|
||||||
|
{
|
||||||
|
byte[] bytes;
|
||||||
|
try (InputStream is = ClientLoader.class.getResourceAsStream("/patch/" + file.getKey() + ".bs"))
|
||||||
|
{
|
||||||
|
if (is == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bytes = ByteStreams.toByteArray(is);
|
||||||
|
}
|
||||||
|
|
||||||
|
patchOs.reset();
|
||||||
|
Patch.patch(file.getValue(), bytes, patchOs);
|
||||||
|
file.setValue(patchOs.toByteArray());
|
||||||
|
|
||||||
|
++patchCount;
|
||||||
|
|
||||||
|
if (!file.getKey().startsWith("META")) {
|
||||||
|
add(file.getValue(), file.getKey(), target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target!=null)
|
||||||
|
target.close();
|
||||||
|
|
||||||
|
log.info("Patched {} classes", patchCount);
|
||||||
|
}
|
||||||
|
if (hooksFile.exists()) {
|
||||||
|
ByteCodePatcher.classPool = new ClassPool(true);
|
||||||
|
ByteCodePatcher.classPool.appendClassPath(RuneLite.RUNELITE_DIR+"/injectedClient-"+ RuneLiteAPI.getVersion() +"-.jar");
|
||||||
|
Gson gson = new Gson();
|
||||||
|
Hooks hooks = gson.fromJson(new BufferedReader(new FileReader(hooksFile)), Hooks.class);
|
||||||
|
|
||||||
|
if (hooks.clientInstance.equals("")||
|
||||||
|
hooks.projectileClass.equals("") ||
|
||||||
|
hooks.actorClass.equals("") ||
|
||||||
|
hooks.playerClass.equals("")) {
|
||||||
|
System.out.println("[RuneLit] Bad hooks, re-scraping.");
|
||||||
|
ByteCodePatcher.clientInstance = getClientInstance(ByteCodeUtils.injectedClientFile.getPath());
|
||||||
|
ByteCodePatcher.findHooks(injectedClientFile.getPath());
|
||||||
|
} else {
|
||||||
|
ByteCodePatcher.clientInstance = hooks.clientInstance;
|
||||||
|
ByteCodePatcher.applyHooks(ByteCodeUtils.injectedClientFile, hooks);
|
||||||
|
System.out.println("[RuneLit] Loaded hooks");
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
System.out.println("[RuneLit] Hooks file not found, scraping hooks.");
|
||||||
|
ByteCodePatcher.clientInstance = getClientInstance(ByteCodeUtils.injectedClientFile.getPath());
|
||||||
|
ByteCodePatcher.findHooks(injectedClientFile.getPath());
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, byte[]> zipFile2 = new HashMap<>();
|
||||||
|
JarInputStream jis = new JarInputStream(new FileInputStream(hijackedClientFile));
|
||||||
|
|
||||||
|
byte[] tmp = new byte[4096];
|
||||||
|
ByteArrayOutputStream buffer = new ByteArrayOutputStream(756 * 1024);
|
||||||
|
for (; ; ) {
|
||||||
|
JarEntry metadata = jis.getNextJarEntry();
|
||||||
|
if (metadata == null) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer.reset();
|
||||||
|
for (; ; ) {
|
||||||
|
int n = jis.read(tmp);
|
||||||
|
if (n <= -1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
buffer.write(tmp, 0, n);
|
||||||
|
}
|
||||||
|
|
||||||
|
zipFile2.put(metadata.getName(), buffer.toByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
String initialClass = config.getInitialClass();
|
||||||
|
|
||||||
|
ClassLoader rsClassLoader = new ClassLoader(ClientLoader.class.getClassLoader())
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected Class<?> findClass(String name) throws ClassNotFoundException
|
||||||
|
{
|
||||||
|
String path = name.replace('.', '/').concat(".class");
|
||||||
|
byte[] data = zipFile2.get(path);
|
||||||
|
if (data == null)
|
||||||
|
{
|
||||||
|
throw new ClassNotFoundException(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return defineClass(name, data, 0, data.length);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Class<?> clientClass = rsClassLoader.loadClass(initialClass);
|
||||||
|
|
||||||
|
Applet rs = (Applet) clientClass.newInstance();
|
||||||
|
rs.setStub(new RSAppletStub(config));
|
||||||
|
return rs;
|
||||||
|
}
|
||||||
|
catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException
|
||||||
|
| CompressorException | InvalidHeaderException | CertificateException | SecurityException e)
|
||||||
|
{
|
||||||
|
if (e instanceof ClassNotFoundException)
|
||||||
|
{
|
||||||
|
log.error("Unable to load client - class not found. This means you"
|
||||||
|
+ " are not running RuneLite with Maven as the client patch"
|
||||||
|
+ " is not in your classpath.");
|
||||||
|
}
|
||||||
|
|
||||||
|
log.error("Error loading RS!", e);
|
||||||
|
return null;
|
||||||
|
} catch (NotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void add(byte[] bytes, String entryName ,JarOutputStream target) throws IOException {
|
||||||
|
BufferedInputStream in = null;
|
||||||
|
try {
|
||||||
|
JarEntry entry = new JarEntry(entryName);
|
||||||
|
target.putNextEntry(entry);
|
||||||
|
target.write(bytes);
|
||||||
|
target.closeEntry();
|
||||||
|
} finally {
|
||||||
|
if (in != null)
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Certificate[] getJagexCertificateChain() throws CertificateException
|
private static Certificate[] getJagexCertificateChain() throws CertificateException
|
||||||
{
|
{
|
||||||
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
|
CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
|
||||||
Collection<? extends Certificate> certificates = certificateFactory.generateCertificates(ClientLoader.class.getResourceAsStream("jagex.crt"));
|
Collection<? extends Certificate> certificates = certificateFactory.generateCertificates(ClientLoader.class.getResourceAsStream("jagex.crt"));
|
||||||
return certificates.toArray(new Certificate[certificates.size()]);
|
return certificates.toArray(new Certificate[certificates.size()]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String initVanillaInjected(String jarFile) {
|
public static String getClientInstance(String jarFile) {
|
||||||
List<String> protectedMethods = new ArrayList<>();
|
|
||||||
String clientInstance = "";
|
|
||||||
JarClassLoader jcl = new JarClassLoader();
|
JarClassLoader jcl = new JarClassLoader();
|
||||||
try {
|
try {
|
||||||
ClassPool classPool = new ClassPool(true);
|
ClassPool classPool = new ClassPool(true);
|
||||||
classPool.appendClassPath(RuneLite.RUNELITE_DIR + "/injectedClient-" + RuneLiteAPI.getVersion() + "-.jar");
|
classPool.appendClassPath(RuneLite.RUNELITE_DIR+"/injectedClient-"+ RuneLiteAPI.getVersion() +"-.jar");
|
||||||
} catch (NotFoundException e) {
|
} catch (NotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -114,7 +354,7 @@ public class ClientLoader
|
|||||||
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
ClassLoader cl = ClassLoader.getSystemClassLoader();
|
||||||
try {
|
try {
|
||||||
URLClassLoader child = new URLClassLoader(
|
URLClassLoader child = new URLClassLoader(
|
||||||
new URL[]{temp.toURI().toURL()},
|
new URL[] {temp.toURI().toURL()},
|
||||||
cl
|
cl
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
@@ -123,24 +363,17 @@ public class ClientLoader
|
|||||||
try {
|
try {
|
||||||
jcl2.add(new FileInputStream(ByteCodeUtils.injectedClientFile));
|
jcl2.add(new FileInputStream(ByteCodeUtils.injectedClientFile));
|
||||||
Field[] fields = classToLoad.getDeclaredFields();
|
Field[] fields = classToLoad.getDeclaredFields();
|
||||||
Method[] methods = classToLoad.getMethods();
|
|
||||||
for (Field f : fields) {
|
for (Field f : fields) {
|
||||||
try {
|
try {
|
||||||
|
if (f.getType().getName()=="client") {
|
||||||
if (f.getType().getName() == "client") {
|
ByteCodePatcher.hooks.clientInstance = classToLoad.getName()+"."+f.getName();
|
||||||
ByteCodePatcher.hooks.clientInstance = classToLoad.getName() + "." + f.getName();
|
System.out.println("[RuneLit] Found client instance at "+classToLoad.getName()+"."+f.getName());
|
||||||
System.out.println("[RuneLit] Found client instance at " + classToLoad.getName() + "." + f.getName());
|
return classToLoad.getName()+"."+f.getName();
|
||||||
return classToLoad.getName() + "." + f.getName();
|
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Method m : methods) {
|
|
||||||
if (m.getName().contains("protect")) {
|
|
||||||
protectedMethods.add(classToLoad.getName()+":"+m.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -150,7 +383,7 @@ public class ClientLoader
|
|||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.out.println("Class not found: " + entry.getName());
|
System.out.println("Class not found: "+entry.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -158,219 +391,6 @@ public class ClientLoader
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
String[] hooksProtectedMethods = new String[protectedMethods.size()];
|
return "";
|
||||||
int i = 0;
|
|
||||||
for (String s : protectedMethods) {
|
|
||||||
hooksProtectedMethods[i] = s;
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
ByteCodePatcher.hooks.protectedMethods = hooksProtectedMethods;
|
|
||||||
return clientInstance;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Applet load() {
|
|
||||||
if (updateCheckMode == NONE) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
File injectedClientFile = ByteCodeUtils.injectedClientFile;
|
|
||||||
File hijackedClientFile = ByteCodeUtils.hijackedClientFile;
|
|
||||||
Manifest manifest = new Manifest();
|
|
||||||
manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
|
|
||||||
target = new JarOutputStream(new FileOutputStream(injectedClientFile), manifest);
|
|
||||||
RSConfig config = clientConfigLoader.fetch();
|
|
||||||
|
|
||||||
Map<String, byte[]> zipFile = new HashMap<>();
|
|
||||||
{
|
|
||||||
Certificate[] jagexCertificateChain = getJagexCertificateChain();
|
|
||||||
String codebase = config.getCodeBase();
|
|
||||||
String initialJar = config.getInitialJar();
|
|
||||||
URL url = new URL(codebase + initialJar);
|
|
||||||
Request request = new Request.Builder()
|
|
||||||
.url(url)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute()) {
|
|
||||||
JarInputStream jis;
|
|
||||||
|
|
||||||
jis = new JarInputStream(response.body().byteStream());
|
|
||||||
|
|
||||||
byte[] tmp = new byte[4096];
|
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream(756 * 1024);
|
|
||||||
for (; ; ) {
|
|
||||||
JarEntry metadata = jis.getNextJarEntry();
|
|
||||||
if (metadata == null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer.reset();
|
|
||||||
for (; ; ) {
|
|
||||||
int n = jis.read(tmp);
|
|
||||||
if (n <= -1) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
buffer.write(tmp, 0, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
zipFile.put(metadata.getName(), buffer.toByteArray());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updateCheckMode == AUTO) {
|
|
||||||
Map<String, String> hashes;
|
|
||||||
try (InputStream is = ClientLoader.class.getResourceAsStream("/patch/hashes.json")) {
|
|
||||||
hashes = new Gson().fromJson(new InputStreamReader(is), new TypeToken<HashMap<String, String>>() {
|
|
||||||
}.getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Map.Entry<String, String> file : hashes.entrySet()) {
|
|
||||||
byte[] bytes = zipFile.get(file.getKey());
|
|
||||||
|
|
||||||
String ourHash = null;
|
|
||||||
if (bytes != null) {
|
|
||||||
ourHash = Hashing.sha512().hashBytes(bytes).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!file.getValue().equals(ourHash)) {
|
|
||||||
if (hijackedClientFile.exists()) {
|
|
||||||
Logger.getAnonymousLogger().warning("[RuneLit] Hash checking / Client patching skipped due to hijacked client.");
|
|
||||||
updateCheckMode = VANILLA;
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
log.info("{} had a hash mismatch; falling back to vanilla. {} != {}", file.getKey(), file.getValue(), ourHash);
|
|
||||||
log.info("Client is outdated!");
|
|
||||||
updateCheckMode = VANILLA;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (updateCheckMode == AUTO) {
|
|
||||||
ByteArrayOutputStream patchOs = new ByteArrayOutputStream(756 * 1024);
|
|
||||||
int patchCount = 0;
|
|
||||||
|
|
||||||
for (Map.Entry<String, byte[]> file : zipFile.entrySet()) {
|
|
||||||
byte[] bytes;
|
|
||||||
try (InputStream is = ClientLoader.class.getResourceAsStream("/patch/" + file.getKey() + ".bs")) {
|
|
||||||
if (is == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
bytes = ByteStreams.toByteArray(is);
|
|
||||||
}
|
|
||||||
|
|
||||||
patchOs.reset();
|
|
||||||
Patch.patch(file.getValue(), bytes, patchOs);
|
|
||||||
file.setValue(patchOs.toByteArray());
|
|
||||||
|
|
||||||
++patchCount;
|
|
||||||
|
|
||||||
if (!file.getKey().startsWith("META")) {
|
|
||||||
add(file.getValue(), file.getKey(), target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (target != null)
|
|
||||||
target.close();
|
|
||||||
|
|
||||||
log.info("Patched {} classes", patchCount);
|
|
||||||
}
|
|
||||||
if (hooksFile.exists()) {
|
|
||||||
ByteCodePatcher.classPool = new ClassPool(true);
|
|
||||||
ByteCodePatcher.classPool.appendClassPath(RuneLite.RUNELITE_DIR + "/injectedClient-" + RuneLiteAPI.getVersion() + "-.jar");
|
|
||||||
Gson gson = new Gson();
|
|
||||||
Hooks hooks = gson.fromJson(new BufferedReader(new FileReader(hooksFile)), Hooks.class);
|
|
||||||
if (hooks.clientInstance.equals("") ||
|
|
||||||
hooks.projectileClass.equals("") ||
|
|
||||||
hooks.actorClass.equals("") ||
|
|
||||||
hooks.clientInstance.equals("") ||
|
|
||||||
hooks.playerClass.equals("")) {
|
|
||||||
System.out.println("[RuneLit] Bad hooks, re-scraping.");
|
|
||||||
ByteCodePatcher.clientInstance = ByteCodeUtils.injectedClientFile.getPath();
|
|
||||||
ByteCodePatcher.findHooks(injectedClientFile.getPath());
|
|
||||||
} else {
|
|
||||||
ByteCodePatcher.clientInstance = hooks.clientInstance;
|
|
||||||
ByteCodePatcher.applyHooks(ByteCodeUtils.injectedClientFile, hooks);
|
|
||||||
System.out.println("[RuneLit] Loaded hooks");
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
System.out.println("[RuneLit] Hooks file not found, scraping hooks.");
|
|
||||||
ByteCodePatcher.clientInstance = initVanillaInjected(ByteCodeUtils.injectedClientFile.getPath());
|
|
||||||
ByteCodePatcher.findHooks(injectedClientFile.getPath());
|
|
||||||
}
|
|
||||||
|
|
||||||
Map<String, byte[]> zipFile2 = new HashMap<>();
|
|
||||||
JarInputStream jis = new JarInputStream(new FileInputStream(hijackedClientFile));
|
|
||||||
|
|
||||||
byte[] tmp = new byte[4096];
|
|
||||||
ByteArrayOutputStream buffer = new ByteArrayOutputStream(756 * 1024);
|
|
||||||
for (; ; ) {
|
|
||||||
JarEntry metadata = jis.getNextJarEntry();
|
|
||||||
if (metadata == null) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer.reset();
|
|
||||||
for (; ; ) {
|
|
||||||
int n = jis.read(tmp);
|
|
||||||
if (n <= -1) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
buffer.write(tmp, 0, n);
|
|
||||||
}
|
|
||||||
|
|
||||||
zipFile2.put(metadata.getName(), buffer.toByteArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
String initialClass = config.getInitialClass();
|
|
||||||
|
|
||||||
ClassLoader rsClassLoader = new ClassLoader(ClientLoader.class.getClassLoader()) {
|
|
||||||
@Override
|
|
||||||
protected Class<?> findClass(String name) throws ClassNotFoundException {
|
|
||||||
String path = name.replace('.', '/').concat(".class");
|
|
||||||
byte[] data = zipFile2.get(path);
|
|
||||||
if (data == null) {
|
|
||||||
throw new ClassNotFoundException(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return defineClass(name, data, 0, data.length);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
Class<?> clientClass = rsClassLoader.loadClass(initialClass);
|
|
||||||
|
|
||||||
Applet rs = (Applet) clientClass.newInstance();
|
|
||||||
rs.setStub(new RSAppletStub(config));
|
|
||||||
return rs;
|
|
||||||
} catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException
|
|
||||||
| CompressorException | InvalidHeaderException | CertificateException | SecurityException e) {
|
|
||||||
if (e instanceof ClassNotFoundException) {
|
|
||||||
log.error("Unable to load client - class not found. This means you"
|
|
||||||
+ " are not running RuneLite with Maven as the client patch"
|
|
||||||
+ " is not in your classpath.");
|
|
||||||
}
|
|
||||||
|
|
||||||
log.error("Error loading RS!", e);
|
|
||||||
return null;
|
|
||||||
} catch (NotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void add(byte[] bytes, String entryName, JarOutputStream target) throws IOException {
|
|
||||||
BufferedInputStream in = null;
|
|
||||||
try {
|
|
||||||
JarEntry entry = new JarEntry(entryName);
|
|
||||||
target.putNextEntry(entry);
|
|
||||||
target.write(bytes);
|
|
||||||
target.closeEntry();
|
|
||||||
} finally {
|
|
||||||
if (in != null)
|
|
||||||
in.close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,12 +25,11 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.rs;
|
package net.runelite.client.rs;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
|
|
||||||
import java.applet.AppletContext;
|
import java.applet.AppletContext;
|
||||||
import java.applet.AppletStub;
|
import java.applet.AppletStub;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
class RSAppletStub implements AppletStub
|
class RSAppletStub implements AppletStub
|
||||||
|
|||||||
@@ -25,10 +25,9 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.rs;
|
package net.runelite.client.rs;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
class RSConfig
|
class RSConfig
|
||||||
|
|||||||
@@ -7,12 +7,23 @@ import javassist.CtClass;
|
|||||||
import javassist.NotFoundException;
|
import javassist.NotFoundException;
|
||||||
import net.runelite.client.RuneLite;
|
import net.runelite.client.RuneLite;
|
||||||
import net.runelite.client.rs.ClientLoader;
|
import net.runelite.client.rs.ClientLoader;
|
||||||
import net.runelite.client.rs.bytecode.transformers.*;
|
import net.runelite.client.rs.bytecode.transformers.ActorTransform;
|
||||||
|
import net.runelite.client.rs.bytecode.transformers.PlayerTransform;
|
||||||
|
import net.runelite.client.rs.bytecode.transformers.ProjectileTransform;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import org.xeustechnologies.jcl.JarClassLoader;
|
import org.xeustechnologies.jcl.JarClassLoader;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.BufferedInputStream;
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.FileWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.Writer;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -32,7 +43,7 @@ public class ByteCodePatcher {
|
|||||||
public static void applyHooks(File jf, Hooks hooks) {
|
public static void applyHooks(File jf, Hooks hooks) {
|
||||||
try {
|
try {
|
||||||
URLClassLoader child = new URLClassLoader(
|
URLClassLoader child = new URLClassLoader(
|
||||||
new URL[]{jf.toURI().toURL()},
|
new URL[] {jf.toURI().toURL()},
|
||||||
cl
|
cl
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
@@ -42,8 +53,6 @@ public class ByteCodePatcher {
|
|||||||
transformProjectile(projectileClass);
|
transformProjectile(projectileClass);
|
||||||
Class playerClass = Class.forName(hooks.playerClass, false, child);
|
Class playerClass = Class.forName(hooks.playerClass, false, child);
|
||||||
transformPlayer(playerClass);
|
transformPlayer(playerClass);
|
||||||
Class clientClass = Class.forName(hooks.clientClass, false, child);
|
|
||||||
transformClient(clientClass);
|
|
||||||
ByteCodeUtils.updateHijackedJar();
|
ByteCodeUtils.updateHijackedJar();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -57,7 +66,7 @@ public class ByteCodePatcher {
|
|||||||
public static void findHooks(String jf) {
|
public static void findHooks(String jf) {
|
||||||
try {
|
try {
|
||||||
classPool = new ClassPool(true);
|
classPool = new ClassPool(true);
|
||||||
classPool.appendClassPath(RuneLite.RUNELITE_DIR + "/injectedClient-" + RuneLiteAPI.getVersion() + "-.jar");
|
classPool.appendClassPath(RuneLite.RUNELITE_DIR+"/injectedClient-"+ RuneLiteAPI.getVersion() +"-.jar");
|
||||||
} catch (NotFoundException e) {
|
} catch (NotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -90,7 +99,7 @@ public class ByteCodePatcher {
|
|||||||
public static void checkClasses(File jf, JarEntry entry) {
|
public static void checkClasses(File jf, JarEntry entry) {
|
||||||
try {
|
try {
|
||||||
URLClassLoader child = new URLClassLoader(
|
URLClassLoader child = new URLClassLoader(
|
||||||
new URL[]{jf.toURI().toURL()},
|
new URL[] {jf.toURI().toURL()},
|
||||||
cl
|
cl
|
||||||
);
|
);
|
||||||
try {
|
try {
|
||||||
@@ -98,23 +107,22 @@ public class ByteCodePatcher {
|
|||||||
checkActor(classToLoad);
|
checkActor(classToLoad);
|
||||||
checkProjectile(classToLoad);
|
checkProjectile(classToLoad);
|
||||||
checkPlayer(classToLoad);
|
checkPlayer(classToLoad);
|
||||||
checkClient(classToLoad);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.out.println("Class not found: " + entry.getName());
|
System.out.println("Class not found: "+entry.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkActor(Class current) {
|
public static void checkActor(Class current) {
|
||||||
try {
|
try {
|
||||||
Method method = current.getDeclaredMethod("setCombatInfo", int.class, int.class, int.class, int.class, int.class, int.class);
|
Method method = current.getDeclaredMethod("setCombatInfo", new Class[] { int.class, int.class, int.class, int.class, int.class, int.class });
|
||||||
if (method != null) {
|
if (method!=null) {
|
||||||
hooks.actorClass = current.getName();
|
hooks.actorClass = current.getName();
|
||||||
System.out.println("[Z-lyte] Transforming Actor at class: " + current.getName());
|
System.out.println("[RuneLit] Transforming Actor at class: "+current.getName());
|
||||||
ActorTransform at = new ActorTransform();
|
ActorTransform at = new ActorTransform();
|
||||||
at.modify(current);
|
at.modify(current);
|
||||||
}
|
}
|
||||||
@@ -126,17 +134,17 @@ public class ByteCodePatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void transformActor(Class actor) {
|
public static void transformActor(Class actor) {
|
||||||
System.out.println("[RuneLit] Transforming Actor at class: " + actor.getName());
|
System.out.println("[RuneLit] Transforming Actor at class: "+actor.getName());
|
||||||
ActorTransform at = new ActorTransform();
|
ActorTransform at = new ActorTransform();
|
||||||
at.modify(actor);
|
at.modify(actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void checkProjectile(Class current) {
|
public static void checkProjectile(Class current) {
|
||||||
try {
|
try {
|
||||||
Method method = current.getDeclaredMethod("projectileMoved", int.class, int.class, int.class, int.class);
|
Method method = current.getDeclaredMethod("projectileMoved", new Class[] { int.class, int.class, int.class, int.class});
|
||||||
if (method != null) {
|
if (method!=null) {
|
||||||
hooks.projectileClass = current.getName();
|
hooks.projectileClass = current.getName();
|
||||||
System.out.println("[RuneLit] Transforming Projectile at class: " + current.getName());
|
System.out.println("[RuneLit] Transforming Projectile at class: "+current.getName());
|
||||||
ProjectileTransform pt = new ProjectileTransform();
|
ProjectileTransform pt = new ProjectileTransform();
|
||||||
pt.modify(current);
|
pt.modify(current);
|
||||||
}
|
}
|
||||||
@@ -148,7 +156,7 @@ public class ByteCodePatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void transformProjectile(Class projectile) {
|
public static void transformProjectile(Class projectile) {
|
||||||
System.out.println("[RuneLit] Transforming Projectile at class: " + projectile.getName());
|
System.out.println("[RuneLit] Transforming Projectile at class: "+projectile.getName());
|
||||||
ProjectileTransform pt = new ProjectileTransform();
|
ProjectileTransform pt = new ProjectileTransform();
|
||||||
pt.modify(projectile);
|
pt.modify(projectile);
|
||||||
}
|
}
|
||||||
@@ -156,26 +164,12 @@ public class ByteCodePatcher {
|
|||||||
public static void checkPlayer(Class current) {
|
public static void checkPlayer(Class current) {
|
||||||
try {
|
try {
|
||||||
Method method = current.getDeclaredMethod("getSkullIcon");
|
Method method = current.getDeclaredMethod("getSkullIcon");
|
||||||
if (method != null) {
|
if (method!=null) {
|
||||||
hooks.playerClass = current.getName();
|
hooks.playerClass = current.getName();
|
||||||
System.out.println("[RuneLit] Transforming Player at class: " + current.getName());
|
System.out.println("[RuneLit] Transforming Player at class: "+current.getName());
|
||||||
PlayerTransform pt = new PlayerTransform();
|
PlayerTransform pt = new PlayerTransform();
|
||||||
pt.modify(current);
|
pt.modify(current);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void checkClient(Class current) {
|
|
||||||
try {
|
|
||||||
Method method = current.getDeclaredMethod("getProjectiles");
|
|
||||||
if (method != null) {
|
|
||||||
hooks.clientInstance = current.getName();
|
|
||||||
System.out.println("[RuneLit] Transforming Projectile at class: " + current.getName());
|
|
||||||
ClientTransform ct = new ClientTransform();
|
|
||||||
ct.modify(current);
|
|
||||||
}
|
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
//e.printStackTrace();
|
//e.printStackTrace();
|
||||||
} catch (NoClassDefFoundError e) {
|
} catch (NoClassDefFoundError e) {
|
||||||
@@ -183,16 +177,10 @@ public class ByteCodePatcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void transformClient(Class client) {
|
|
||||||
System.out.println("[RuneLit] Transforming Client at class: " + client.getName());
|
|
||||||
ClientTransform ct = new ClientTransform();
|
|
||||||
ct.modify(client);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void transformPlayer(Class player) {
|
public static void transformPlayer(Class player) {
|
||||||
System.out.println("[RuneLit] Transforming Player at class: " + player.getName());
|
System.out.println("[RuneLit] Transforming Player at class: "+player.getName());
|
||||||
PlayerTransform pt = new PlayerTransform();
|
PlayerTransform pt = new PlayerTransform();
|
||||||
pt.modify(player);
|
pt.modify(player);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,18 +4,26 @@ import javassist.CtClass;
|
|||||||
import net.runelite.client.RuneLite;
|
import net.runelite.client.RuneLite;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.jar.*;
|
import java.util.jar.Attributes;
|
||||||
|
import java.util.jar.JarEntry;
|
||||||
|
import java.util.jar.JarFile;
|
||||||
|
import java.util.jar.JarOutputStream;
|
||||||
|
import java.util.jar.Manifest;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
public class ByteCodeUtils {
|
public class ByteCodeUtils {
|
||||||
//TODO: Write method to delete old revision injected clients.
|
//TODO: Write method to delete old revision injected clients.
|
||||||
public static File injectedClientFile = new File(RuneLite.RUNELITE_DIR + "/injectedClient-" + RuneLiteAPI.getVersion() + "-.jar");
|
public static File injectedClientFile = new File(RuneLite.RUNELITE_DIR+"/injectedClient-"+ RuneLiteAPI.getVersion() +"-.jar");
|
||||||
public static File hijackedClientFile = new File(RuneLite.RUNELITE_DIR + "/hijackedClient-" + RuneLiteAPI.getVersion() + "-.jar");
|
public static File hijackedClientFile = new File(RuneLite.RUNELITE_DIR+"/hijackedClient-"+ RuneLiteAPI.getVersion() +"-.jar");
|
||||||
|
|
||||||
public static JarOutputStream target;
|
public static JarOutputStream target;
|
||||||
|
|
||||||
@@ -39,12 +47,12 @@ public class ByteCodeUtils {
|
|||||||
JarEntry entry = entries.nextElement();
|
JarEntry entry = entries.nextElement();
|
||||||
boolean skip = false;
|
boolean skip = false;
|
||||||
for (CtClass ct : ByteCodePatcher.modifiedClasses) {
|
for (CtClass ct : ByteCodePatcher.modifiedClasses) {
|
||||||
if ((ct.getName() + ".class").equals(entry.getName())) {
|
if ((ct.getName()+".class").equals(entry.getName())) {
|
||||||
skip = true;
|
skip = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!skip)
|
if (!skip)
|
||||||
add(entry);
|
add(entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CtClass ct : ByteCodePatcher.modifiedClasses) {
|
for (CtClass ct : ByteCodePatcher.modifiedClasses) {
|
||||||
@@ -59,10 +67,10 @@ public class ByteCodeUtils {
|
|||||||
|
|
||||||
private static void add(CtClass ct) {
|
private static void add(CtClass ct) {
|
||||||
try {
|
try {
|
||||||
JarEntry newEntry = new JarEntry(ct.getName() + ".class");
|
JarEntry newEntry = new JarEntry(ct.getName()+".class");
|
||||||
target.putNextEntry(newEntry);
|
target.putNextEntry(newEntry);
|
||||||
target.write(ct.toBytecode());
|
target.write(ct.toBytecode());
|
||||||
target.closeEntry();
|
target.closeEntry();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -70,7 +78,7 @@ public class ByteCodeUtils {
|
|||||||
|
|
||||||
private static void add(JarEntry entry) throws IOException {
|
private static void add(JarEntry entry) throws IOException {
|
||||||
try {
|
try {
|
||||||
if (!entry.getName().startsWith("META") && !entry.getName().equals("")) {
|
if (!entry.getName().startsWith("META")&&!entry.getName().equals("")) {
|
||||||
target.putNextEntry(entry);
|
target.putNextEntry(entry);
|
||||||
target.write(getBytesFromZipFile(entry.getName()));
|
target.write(getBytesFromZipFile(entry.getName()));
|
||||||
target.closeEntry();
|
target.closeEntry();
|
||||||
@@ -86,7 +94,7 @@ public class ByteCodeUtils {
|
|||||||
zipFile = new ZipFile(injectedClientFile);
|
zipFile = new ZipFile(injectedClientFile);
|
||||||
Enumeration<? extends ZipEntry> entries = zipFile.entries();
|
Enumeration<? extends ZipEntry> entries = zipFile.entries();
|
||||||
|
|
||||||
while (entries.hasMoreElements()) {
|
while(entries.hasMoreElements()){
|
||||||
ZipEntry entry = entries.nextElement();
|
ZipEntry entry = entries.nextElement();
|
||||||
if (entry.getName().equals(entryName)) {
|
if (entry.getName().equals(entryName)) {
|
||||||
InputStream stream = zipFile.getInputStream(entry);
|
InputStream stream = zipFile.getInputStream(entry);
|
||||||
@@ -104,6 +112,6 @@ public class ByteCodeUtils {
|
|||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,11 @@
|
|||||||
package net.runelite.client.rs.bytecode;
|
package net.runelite.client.rs.bytecode;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class Hooks {
|
public class Hooks {
|
||||||
|
|
||||||
public String clientInstance = "";
|
public String clientInstance = "";
|
||||||
public String actorClass = "";
|
public String actorClass = "";
|
||||||
public String projectileClass = "";
|
public String projectileClass = "";
|
||||||
public String playerClass = "";
|
public String playerClass = "";
|
||||||
public String clientClass = "client"; //Always named client
|
|
||||||
public String[] protectedMethods;
|
|
||||||
|
|
||||||
public Hooks() {
|
public Hooks() {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,17 @@
|
|||||||
package net.runelite.client.rs.bytecode.transformers;
|
package net.runelite.client.rs.bytecode.transformers;
|
||||||
|
|
||||||
|
import javassist.CannotCompileException;
|
||||||
import javassist.CtClass;
|
import javassist.CtClass;
|
||||||
import javassist.CtMethod;
|
import javassist.CtMethod;
|
||||||
import javassist.CtNewMethod;
|
import javassist.CtNewMethod;
|
||||||
import javassist.NotFoundException;
|
import javassist.NotFoundException;
|
||||||
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
||||||
|
import net.runelite.client.rs.bytecode.ByteCodeUtils;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLClassLoader;
|
||||||
|
|
||||||
public class ActorTransform {
|
public class ActorTransform {
|
||||||
public CtClass ct = null;
|
public CtClass ct = null;
|
||||||
@@ -29,7 +36,7 @@ public class ActorTransform {
|
|||||||
ct.addMethod(protectedAnimation);
|
ct.addMethod(protectedAnimation);
|
||||||
CtMethod getAnimation = ct.getDeclaredMethod("getAnimation");
|
CtMethod getAnimation = ct.getDeclaredMethod("getAnimation");
|
||||||
ct.removeMethod(getAnimation);
|
ct.removeMethod(getAnimation);
|
||||||
getAnimation = CtNewMethod.make("public int getAnimation() { return this.getRsAnimation(); }", ct);
|
getAnimation = CtNewMethod.make("public int getAnimation() { return this.getRsAnimation(); }",ct);
|
||||||
ct.addMethod(getAnimation);
|
ct.addMethod(getAnimation);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -44,7 +51,7 @@ public class ActorTransform {
|
|||||||
getAnimationChanged = CtNewMethod.make("public void animationChanged(int n) { " +
|
getAnimationChanged = CtNewMethod.make("public void animationChanged(int n) { " +
|
||||||
" net.runelite.api.events.AnimationChanged animationChanged = new net.runelite.api.events.AnimationChanged();" +
|
" net.runelite.api.events.AnimationChanged animationChanged = new net.runelite.api.events.AnimationChanged();" +
|
||||||
" animationChanged.setActor((net.runelite.api.Actor)this);" +
|
" animationChanged.setActor((net.runelite.api.Actor)this);" +
|
||||||
" " + ByteCodePatcher.clientInstance + ".getCallbacks().post((java.lang.Object)animationChanged); }", ct);
|
" "+ByteCodePatcher.clientInstance+".getCallbacks().post((java.lang.Object)animationChanged); }",ct);
|
||||||
ct.addMethod(getAnimationChanged);
|
ct.addMethod(getAnimationChanged);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|||||||
@@ -1,56 +0,0 @@
|
|||||||
package net.runelite.client.rs.bytecode.transformers;
|
|
||||||
|
|
||||||
import javassist.CtClass;
|
|
||||||
import javassist.CtMethod;
|
|
||||||
import javassist.CtNewMethod;
|
|
||||||
import javassist.NotFoundException;
|
|
||||||
import javassist.bytecode.AnnotationsAttribute;
|
|
||||||
import javassist.bytecode.ClassFile;
|
|
||||||
import javassist.bytecode.ConstPool;
|
|
||||||
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
|
||||||
|
|
||||||
public class ClientTransform {
|
|
||||||
public CtClass ct = null;
|
|
||||||
|
|
||||||
public void modify(Class client) {
|
|
||||||
try {
|
|
||||||
ct = ByteCodePatcher.classPool.get(client.getName());
|
|
||||||
transformGetProjectiles();
|
|
||||||
ByteCodePatcher.modifiedClasses.add(ct);
|
|
||||||
} catch (NotFoundException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void transformGetProjectiles() {
|
|
||||||
|
|
||||||
CtMethod getProjectiles;
|
|
||||||
try {
|
|
||||||
CtMethod protectedAnimation = ct.getDeclaredMethod("1protect$getProjectilesDeque");
|
|
||||||
ct.removeMethod(protectedAnimation);
|
|
||||||
protectedAnimation.setName("getProjectilesDeque");
|
|
||||||
ct.addMethod(protectedAnimation);
|
|
||||||
getProjectiles = ct.getDeclaredMethod("getProjectiles");
|
|
||||||
ct.removeMethod(getProjectiles);
|
|
||||||
getProjectiles = CtNewMethod.make("public java.util.List getProjectiles() { " +
|
|
||||||
" java.util.ArrayList localArrayList = new java.util.ArrayList();" +
|
|
||||||
" net.runelite.rs.api.RSDeque localRSDeque = getProjectilesDeque();" +
|
|
||||||
" net.runelite.rs.api.RSNode localRSNode = localRSDeque.getHead();" +
|
|
||||||
" for (net.runelite.api.Node localNode = localRSNode.getNext(); localNode != localRSNode; localNode = localNode.getNext()) {" +
|
|
||||||
" net.runelite.api.Projectile localProjectile = (net.runelite.api.Projectile)localNode;" +
|
|
||||||
" localArrayList.add(localProjectile); }" +
|
|
||||||
" return localArrayList; }", ct);
|
|
||||||
|
|
||||||
ct.addMethod(getProjectiles);
|
|
||||||
ClassFile classFile = ct.getClassFile();
|
|
||||||
ConstPool constPool = classFile.getConstPool();
|
|
||||||
AnnotationsAttribute attr = new AnnotationsAttribute(constPool, AnnotationsAttribute.visibleTag);
|
|
||||||
javassist.bytecode.annotation.Annotation annotation = new javassist.bytecode.annotation.Annotation("Override", constPool);
|
|
||||||
attr.setAnnotation(annotation);
|
|
||||||
getProjectiles.getMethodInfo().addAttribute(attr);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -38,27 +38,26 @@ public class PlayerTransform {
|
|||||||
String SkullIcon = "net.runelite.api.SkullIcon";
|
String SkullIcon = "net.runelite.api.SkullIcon";
|
||||||
getSkullIcon = ct.getDeclaredMethod("getSkullIcon");
|
getSkullIcon = ct.getDeclaredMethod("getSkullIcon");
|
||||||
ct.removeMethod(getSkullIcon);
|
ct.removeMethod(getSkullIcon);
|
||||||
getSkullIcon = CtNewMethod.make("public " + SkullIcon + " getSkullIcon() {" +
|
getSkullIcon = CtNewMethod.make("public "+SkullIcon+" getSkullIcon() {" +
|
||||||
" switch (this.getRsSkullIcon()) {" +
|
" switch (this.getRsSkullIcon()) {" +
|
||||||
" case 0: {" +
|
" case 0: {" +
|
||||||
" return " + SkullIcon + ".SKULL; }" +
|
" return "+SkullIcon+".SKULL; }" +
|
||||||
" case 1: {" +
|
" case 1: {" +
|
||||||
" return " + SkullIcon + ".SKULL_FIGHT_PIT; }" +
|
" return "+SkullIcon+".SKULL_FIGHT_PIT; }" +
|
||||||
" case 8: {" +
|
" case 8: {" +
|
||||||
" return " + SkullIcon + ".DEAD_MAN_FIVE; }" +
|
" return "+SkullIcon+".DEAD_MAN_FIVE; }" +
|
||||||
" case 9: {" +
|
" case 9: {" +
|
||||||
" return " + SkullIcon + ".DEAD_MAN_FOUR; }" +
|
" return "+SkullIcon+".DEAD_MAN_FOUR; }" +
|
||||||
" case 10: {" +
|
" case 10: {" +
|
||||||
" return " + SkullIcon + ".DEAD_MAN_THREE; }" +
|
" return "+SkullIcon+".DEAD_MAN_THREE; }" +
|
||||||
" case 11: {" +
|
" case 11: {" +
|
||||||
" return " + SkullIcon + ".DEAD_MAN_TWO; }" +
|
" return "+SkullIcon+".DEAD_MAN_TWO; }" +
|
||||||
" case 12: {" +
|
" case 12: {" +
|
||||||
" return " + SkullIcon + ".DEAD_MAN_ONE; } }" +
|
" return "+SkullIcon+".DEAD_MAN_ONE; } }" +
|
||||||
" return null; }", ct);
|
" return null; }",ct);
|
||||||
ct.addMethod(getSkullIcon);
|
ct.addMethod(getSkullIcon);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import javassist.CtClass;
|
|||||||
import javassist.CtMethod;
|
import javassist.CtMethod;
|
||||||
import javassist.CtNewMethod;
|
import javassist.CtNewMethod;
|
||||||
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
import net.runelite.client.rs.bytecode.ByteCodePatcher;
|
||||||
|
import net.runelite.client.rs.bytecode.ByteCodeUtils;
|
||||||
|
|
||||||
public class ProjectileTransform {
|
public class ProjectileTransform {
|
||||||
public CtClass ct = null;
|
public CtClass ct = null;
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import lombok.AccessLevel;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.runelite.api.MenuAction;
|
import net.runelite.api.MenuAction;
|
||||||
import net.runelite.api.events.MenuOptionClicked;
|
import net.runelite.api.events.MenuOptionClicked;
|
||||||
|
import net.runelite.api.widgets.WidgetItem;
|
||||||
import net.runelite.client.config.ConfigGroup;
|
import net.runelite.client.config.ConfigGroup;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.config.RuneLiteConfig;
|
import net.runelite.client.config.RuneLiteConfig;
|
||||||
@@ -96,6 +97,8 @@ public class OverlayManager
|
|||||||
*/
|
*/
|
||||||
@Getter(AccessLevel.PACKAGE)
|
@Getter(AccessLevel.PACKAGE)
|
||||||
private final List<Overlay> overlays = new ArrayList<>();
|
private final List<Overlay> overlays = new ArrayList<>();
|
||||||
|
@Getter
|
||||||
|
private final List<WidgetItem> itemWidgets = new ArrayList<>();
|
||||||
|
|
||||||
private final Map<OverlayLayer, List<Overlay>> overlayLayers = new EnumMap<>(OverlayLayer.class);
|
private final Map<OverlayLayer, List<Overlay>> overlayLayers = new EnumMap<>(OverlayLayer.class);
|
||||||
|
|
||||||
@@ -168,6 +171,12 @@ public class OverlayManager
|
|||||||
// Add is always true
|
// Add is always true
|
||||||
overlays.add(overlay);
|
overlays.add(overlay);
|
||||||
loadOverlay(overlay);
|
loadOverlay(overlay);
|
||||||
|
// WidgetItemOverlays have a reference to the overlay manager in order to get the WidgetItems
|
||||||
|
// for each frame.
|
||||||
|
if (overlay instanceof WidgetItemOverlay)
|
||||||
|
{
|
||||||
|
((WidgetItemOverlay) overlay).setOverlayManager(this);
|
||||||
|
}
|
||||||
rebuildOverlayLayers();
|
rebuildOverlayLayers();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2017, Devin French <https://github.com/devinfrench>
|
* Copyright (c) 2019, Adam <Adam@sigterm.info>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -22,53 +22,57 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.api.queries;
|
package net.runelite.client.ui.overlay;
|
||||||
|
|
||||||
import net.runelite.api.Client;
|
import java.awt.Dimension;
|
||||||
import net.runelite.api.Query;
|
import java.awt.Graphics2D;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.AccessLevel;
|
||||||
|
import lombok.Setter;
|
||||||
import net.runelite.api.widgets.WidgetItem;
|
import net.runelite.api.widgets.WidgetItem;
|
||||||
|
|
||||||
public abstract class WidgetItemQuery extends Query<WidgetItem, WidgetItemQuery>
|
public abstract class WidgetItemOverlay extends Overlay
|
||||||
{
|
{
|
||||||
|
@Setter(AccessLevel.PACKAGE)
|
||||||
|
private OverlayManager overlayManager;
|
||||||
|
|
||||||
public WidgetItemQuery idEquals(int... ids)
|
protected WidgetItemOverlay()
|
||||||
{
|
{
|
||||||
predicate = and(item ->
|
super.setPosition(OverlayPosition.DYNAMIC);
|
||||||
{
|
super.setPriority(OverlayPriority.LOW);
|
||||||
for (int id : ids)
|
super.setLayer(OverlayLayer.ABOVE_WIDGETS);
|
||||||
{
|
|
||||||
if (item.getId() == id)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public WidgetItemQuery indexEquals(int... indexes)
|
public abstract void renderItemOverlay(Graphics2D graphics, int itemId, WidgetItem itemWidget);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Dimension render(Graphics2D graphics)
|
||||||
{
|
{
|
||||||
predicate = and(item ->
|
final List<WidgetItem> itemWidgets = overlayManager.getItemWidgets();
|
||||||
|
for (WidgetItem widget : itemWidgets)
|
||||||
{
|
{
|
||||||
for (int index : indexes)
|
renderItemOverlay(graphics, widget.getId(), widget);
|
||||||
{
|
}
|
||||||
if (item.getIndex() == index)
|
return null;
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public WidgetItemQuery quantityEquals(int quantity)
|
// Don't allow setting position, priority, or layer
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setPosition(OverlayPosition position)
|
||||||
{
|
{
|
||||||
predicate = and(item -> item.getQuantity() == quantity);
|
throw new IllegalStateException();
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract WidgetItem[] result(Client client);
|
public void setPriority(OverlayPriority priority)
|
||||||
|
{
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setLayer(OverlayLayer layer)
|
||||||
|
{
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Tomas Slusny <slusnucky@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.util;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
import net.runelite.api.Client;
|
|
||||||
import net.runelite.api.Query;
|
|
||||||
|
|
||||||
@Singleton
|
|
||||||
public class QueryRunner
|
|
||||||
{
|
|
||||||
@Inject
|
|
||||||
private Client client;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public <T> T[] runQuery(Query query)
|
|
||||||
{
|
|
||||||
return (T[]) query.result(client);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -28,6 +28,7 @@ import com.google.common.cache.Cache;
|
|||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -108,6 +109,8 @@ import net.runelite.api.mixins.Shadow;
|
|||||||
import net.runelite.api.vars.AccountType;
|
import net.runelite.api.vars.AccountType;
|
||||||
import net.runelite.api.widgets.Widget;
|
import net.runelite.api.widgets.Widget;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
|
import net.runelite.api.widgets.WidgetItem;
|
||||||
|
import net.runelite.api.widgets.WidgetType;
|
||||||
import net.runelite.rs.api.RSChatLineBuffer;
|
import net.runelite.rs.api.RSChatLineBuffer;
|
||||||
import net.runelite.rs.api.RSClanMemberManager;
|
import net.runelite.rs.api.RSClanMemberManager;
|
||||||
import net.runelite.rs.api.RSClient;
|
import net.runelite.rs.api.RSClient;
|
||||||
@@ -1324,8 +1327,11 @@ public abstract class RSClientMixin implements RSClient
|
|||||||
|
|
||||||
@MethodHook("renderWidgetLayer")
|
@MethodHook("renderWidgetLayer")
|
||||||
@Inject
|
@Inject
|
||||||
public static void renderWidgetLayer(Widget[] widgets, int parentId, int var2, int var3, int var4, int var5, int x, int y, int var8)
|
public static void renderWidgetLayer(Widget[] widgets, int parentId, int minX, int minY, int maxX, int maxY, int x, int y, int var8)
|
||||||
{
|
{
|
||||||
|
Callbacks callbacks = client.getCallbacks();
|
||||||
|
HashTable<WidgetNode> componentTable = client.getComponentTable();
|
||||||
|
|
||||||
for (Widget rlWidget : widgets)
|
for (Widget rlWidget : widgets)
|
||||||
{
|
{
|
||||||
RSWidget widget = (RSWidget) rlWidget;
|
RSWidget widget = (RSWidget) rlWidget;
|
||||||
@@ -1338,10 +1344,30 @@ public abstract class RSClientMixin implements RSClient
|
|||||||
{
|
{
|
||||||
widget.setRenderParentId(parentId);
|
widget.setRenderParentId(parentId);
|
||||||
}
|
}
|
||||||
widget.setRenderX(x + widget.getRelativeX());
|
|
||||||
widget.setRenderY(y + widget.getRelativeY());
|
|
||||||
|
|
||||||
HashTable<WidgetNode> componentTable = client.getComponentTable();
|
final int renderX = x + widget.getRelativeX();
|
||||||
|
final int renderY = y + widget.getRelativeY();
|
||||||
|
widget.setRenderX(renderX);
|
||||||
|
widget.setRenderY(renderY);
|
||||||
|
|
||||||
|
final int widgetType = widget.getType();
|
||||||
|
if (widgetType == WidgetType.GRAPHIC && widget.getItemId() != -1)
|
||||||
|
{
|
||||||
|
if (renderX >= minX && renderX <= maxX && renderY >= minY && renderY <= maxY)
|
||||||
|
{
|
||||||
|
WidgetItem widgetItem = new WidgetItem(widget.getItemId(), widget.getItemQuantity(), -1, widget.getBounds());
|
||||||
|
callbacks.drawItem(widget.getItemId(), widgetItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (widgetType == WidgetType.INVENTORY)
|
||||||
|
{
|
||||||
|
Collection<WidgetItem> widgetItems = widget.getWidgetItems();
|
||||||
|
for (WidgetItem widgetItem : widgetItems)
|
||||||
|
{
|
||||||
|
callbacks.drawItem(widgetItem.getId(), widgetItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WidgetNode childNode = componentTable.get(widget.getId());
|
WidgetNode childNode = componentTable.get(widget.getId());
|
||||||
if (childNode != null)
|
if (childNode != null)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user