Skip to content

Commit

Permalink
Added basic Quest Helper layout
Browse files Browse the repository at this point in the history
This has been shifted from working in the Runelite repo to being a plugin in the Hub.
  • Loading branch information
Zoinkwiz committed Jun 25, 2020
1 parent 07f0c93 commit 987493d
Show file tree
Hide file tree
Showing 69 changed files with 8,386 additions and 68 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repositories {
mavenCentral()
}

def runeLiteVersion = '1.6.6.1'
def runeLiteVersion = '1.6.21'

dependencies {
compileOnly group: 'net.runelite', name:'client', version: runeLiteVersion
Expand All @@ -26,7 +26,7 @@ dependencies {
}

group = 'com.example'
version = '1.0-SNAPSHOT'
version = '1.6.21'
sourceCompatibility = '1.8'

tasks.withType(JavaCompile) {
Expand Down
5 changes: 3 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#Thu Jun 25 09:45:02 BST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
12 changes: 6 additions & 6 deletions runelite-plugin.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
displayName=Example
author=Nobody
support=
description=An example greeter plugin
tags=
plugins=com.example.ExamplePlugin
displayName=Quest Helper
author=Zoinkwiz
support=https://github.com/Zoinkwiz/quest-helper
description=A helper for questing
tags=quest,helper
plugins=com.example.QuestHelperPlugin
53 changes: 0 additions & 53 deletions src/main/java/com/example/ExamplePlugin.java

This file was deleted.

66 changes: 66 additions & 0 deletions src/main/java/com/questhelper/ItemCollections.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2020, Zoinkwiz
* 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 com.questhelper;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import lombok.Getter;
import net.runelite.api.ItemID;

public class ItemCollections
{
@Getter
private static List<Integer> axes = new ArrayList<>(Arrays.asList(
ItemID.BRONZE_AXE,
ItemID.IRON_AXE,
ItemID.STEEL_AXE,
ItemID.BLACK_AXE,
ItemID.MITHRIL_AXE,
ItemID.ADAMANT_AXE,
ItemID.GILDED_AXE,
ItemID.RUNE_AXE,
ItemID.DRAGON_AXE,
ItemID.INFERNAL_AXE,
ItemID._3RD_AGE_AXE,
ItemID.CRYSTAL_AXE)
);

@Getter
private static List<Integer> pickaxes = new ArrayList<>(Arrays.asList(
ItemID.BRONZE_PICKAXE,
ItemID.IRON_PICKAXE,
ItemID.STEEL_PICKAXE,
ItemID.BLACK_PICKAXE,
ItemID.MITHRIL_PICKAXE,
ItemID.ADAMANT_PICKAXE,
ItemID.GILDED_PICKAXE,
ItemID.RUNE_PICKAXE,
ItemID.DRAGON_PICKAXE,
ItemID.INFERNAL_PICKAXE,
ItemID._3RD_AGE_PICKAXE,
ItemID.CRYSTAL_PICKAXE)
);
}
162 changes: 162 additions & 0 deletions src/main/java/com/questhelper/ItemRequirement.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/*
* Copyright (c) 2019, Trevor <https://github.com/Trevor159>
* 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 com.questhelper;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.inject.Inject;
import lombok.Getter;
import lombok.Setter;
import net.runelite.api.Client;
import net.runelite.api.InventoryID;
import net.runelite.api.Item;
import net.runelite.api.ItemContainer;
import net.runelite.client.game.ItemManager;

public class ItemRequirement
{
@Getter
private final int id;

private String name;

@Getter
private final int quantity;

@Getter
private boolean equip;

@Setter
@Getter
private String tip;

private final List<Integer> alternates = new ArrayList<>();

public ItemRequirement(String name, int id)
{
this(name, id, 1);
}

public ItemRequirement(String name, int id, int quantity)
{
this.id = id;
this.quantity = quantity;
this.name = name;
equip = false;
}

public ItemRequirement(String name, int id, int quantity, boolean equip)
{
this(name, id, quantity);
this.equip = equip;
}

public void addAlternates(List<Integer> alternates) {
this.alternates.addAll(alternates);
}

public void addAlternates(Integer... alternates) {
Collections.addAll(this.alternates, alternates);
}

public void addName(String name)
{
this.name = name;
}

public boolean showQuantity() {
return quantity != -1;
}

public boolean isActualItem() {
return id != -1;
}

public String getName()
{
return name;
}

public ArrayList<Integer> getAllIds() {
ArrayList<Integer> ids = new ArrayList<>(alternates);
ids.add(id);
return ids;
}

public boolean check(Client client, boolean checkEquippedOnly)
{
ItemContainer equipped = client.getItemContainer(InventoryID.EQUIPMENT);
int tempQuantity = quantity;

if(equipped != null)
{
Item[] equippedItems = equipped.getItems();

for (Item item : equippedItems)
{
if (item.getId() == id || alternates.contains(item.getId()))
{
if (item.getQuantity() >= tempQuantity)
{
return true;
}
else
{
tempQuantity -= item.getQuantity();
}
}
}
}

if(!checkEquippedOnly) {
ItemContainer inventory = client.getItemContainer(InventoryID.INVENTORY);
if(inventory != null)
{
Item[] inventoryItems = inventory.getItems();
for (Item item : inventoryItems)
{
if (item.getId() == id || alternates.contains(item.getId()))
{
if (item.getQuantity() >= tempQuantity)
{
return true;
}
else
{
tempQuantity -= item.getQuantity();
}
}
}
}
}
return false;
}

public boolean check(Client client) {
return check(client, false);
}
}
Loading

0 comments on commit 987493d

Please sign in to comment.