Merge remote-tracking branch 'runelite/master' into 2310-merge

This commit is contained in:
Owain van Brakel
2019-10-30 20:28:52 +01:00
16 changed files with 211 additions and 62 deletions

View File

@@ -1,6 +1,6 @@
name: OpenOSRS - CI
name: OpenOSRS - CI (PR)
on: [pull_request, push]
on: pull_request
jobs:
pr-lint:
@@ -76,3 +76,15 @@ jobs:
uses: hmarr/auto-approve-action@v2.0.0
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
automerge:
name: Automerge
needs: approve
runs-on: ubuntu-latest
steps:
- name: automerge
uses: pascalgn/automerge-action@f84dd310ea4a19890c70a4ff11ab282a872fb94b
env:
AUTOMERGE: "automated pull request"
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

58
.github/workflows/pr.yml vendored Normal file
View File

@@ -0,0 +1,58 @@
name: OpenOSRS - CI (push)
on:
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
name: Build
steps:
- uses: actions/checkout@v1
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Assembling
run: ./gradlew assemble --console=plain
- name: Building
run: ./gradlew build --stacktrace -x test -x checkstyleMain --console=plain
test:
runs-on: ubuntu-latest
name: Test
steps:
- uses: actions/checkout@v1
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Assembling
run: ./gradlew assemble --console=plain
- name: Testing
run: ./gradlew test --stacktrace --console=plain
checkstyle:
name: Checkstyle
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Make gradlew executable
run: chmod +x ./gradlew
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Assembling
run: ./gradlew assemble --console=plain
- name: Checking code conventions
run: ./gradlew checkstyleMain --console=plain

View File

@@ -27,7 +27,7 @@ const val kotlinVersion = "1.3.50"
object ProjectVersions {
const val launcherVersion = "2.0.3"
const val rlVersion = "1.5.37-SNAPSHOT"
const val rlVersion = "1.5.38-SNAPSHOT"
const val openosrsVersion = "2.1.8.0"

View File

@@ -24,15 +24,11 @@
*/
package net.runelite.api.events;
import javax.annotation.Nullable;
import lombok.Data;
import net.runelite.api.Actor;
@Data
public class AreaSoundEffectPlayed implements Event
{
@Nullable
private final Actor source;
private int soundId;
private int sceneX;
private int sceneY;

View File

@@ -24,15 +24,11 @@
*/
package net.runelite.api.events;
import javax.annotation.Nullable;
import lombok.Data;
import net.runelite.api.Actor;
@Data
public class SoundEffectPlayed implements Event
{
@Nullable
private final Actor source;
private int soundId;
private int delay;

View File

@@ -110,7 +110,6 @@ class SoundEffectOverlay extends Overlay
String text =
"Id: " + event.getSoundId() +
" - S: " + (event.getSource() != null ? event.getSource().getName() : "<none>") +
" - L: " + event.getSceneX() + "," + event.getSceneY() +
" - R: " + event.getRange() +
" - D: " + event.getDelay();

View File

@@ -30,17 +30,40 @@ public enum LootRecordSortType implements Comparator<LootTrackerRecord>
if (o1.getSubTitle().equals(LootRecordType.DEATH.name()))
{
return Arrays.stream(o1.getItems()).flatMapToInt(lootTrackerItem ->
IntStream.of((int) lootTrackerItem.getPrice() * lootTrackerItem.getQuantity())).sum();
IntStream.of((int) lootTrackerItem.getGePrice() * lootTrackerItem.getQuantity())).sum();
}
if (o2.getSubTitle().equals(LootRecordType.DEATH.name()))
{
return Arrays.stream(o1.getItems()).flatMapToInt(lootTrackerItem ->
IntStream.of((int) lootTrackerItem.getPrice() * lootTrackerItem.getQuantity())).sum();
IntStream.of((int) lootTrackerItem.getGePrice() * lootTrackerItem.getQuantity())).sum();
}
int sum = Arrays.stream(o1.getItems()).flatMapToInt(lootTrackerItem ->
IntStream.of((int) lootTrackerItem.getPrice() * lootTrackerItem.getQuantity())).sum();
IntStream.of((int) lootTrackerItem.getGePrice() * lootTrackerItem.getQuantity())).sum();
return sum + Arrays.stream(o2.getItems()).flatMapToInt(lootTrackerItem ->
IntStream.of((int) lootTrackerItem.getPrice() * lootTrackerItem.getQuantity())).sum();
IntStream.of((int) lootTrackerItem.getGePrice() * lootTrackerItem.getQuantity())).sum();
}
},
TOTAL_HA_VALUE
{
@Override
public int compare(LootTrackerRecord o1, LootTrackerRecord o2)
{
// We want deaths at the bottom of the list
if (o1.getSubTitle().equals(LootRecordType.DEATH.name()))
{
return Arrays.stream(o1.getItems()).flatMapToInt(lootTrackerItem ->
IntStream.of((int) lootTrackerItem.getHaPrice() * lootTrackerItem.getQuantity())).sum();
}
if (o2.getSubTitle().equals(LootRecordType.DEATH.name()))
{
return Arrays.stream(o1.getItems()).flatMapToInt(lootTrackerItem ->
IntStream.of((int) lootTrackerItem.getHaPrice() * lootTrackerItem.getQuantity())).sum();
}
int sum = Arrays.stream(o1.getItems()).flatMapToInt(lootTrackerItem ->
IntStream.of((int) lootTrackerItem.getHaPrice() * lootTrackerItem.getQuantity())).sum();
return sum + Arrays.stream(o2.getItems()).flatMapToInt(lootTrackerItem ->
IntStream.of((int) lootTrackerItem.getHaPrice() * lootTrackerItem.getQuantity())).sum();
}
},
ITEM_COUNT

View File

@@ -72,6 +72,8 @@ class LootTrackerBox extends JPanel
private final ItemManager itemManager;
@Getter(AccessLevel.PACKAGE)
private final String id;
private final LootTrackerPriceType priceType;
private final boolean showPriceType;
@Getter(AccessLevel.PACKAGE)
private final List<LootTrackerRecord> records = new ArrayList<>();
@@ -87,6 +89,8 @@ class LootTrackerBox extends JPanel
final String id,
@Nullable final String subtitle,
final boolean hideIgnoredItems,
final LootTrackerPriceType priceType,
final boolean showPriceType,
@Nullable final Boolean showDate,
final BiConsumer<String, Boolean> onItemToggle)
{
@@ -95,6 +99,8 @@ class LootTrackerBox extends JPanel
this.itemManager = itemManager;
this.onItemToggle = onItemToggle;
this.hideIgnoredItems = hideIgnoredItems;
this.priceType = priceType;
this.showPriceType = showPriceType;
setLayout(new BorderLayout(0, 1));
setBorder(new EmptyBorder(5, 0, 0, 0));
@@ -200,7 +206,13 @@ class LootTrackerBox extends JPanel
{
buildItems();
priceLabel.setText(QuantityFormatter.quantityToStackSize(totalPrice) + " gp");
String priceTypeString = " ";
if (showPriceType)
{
priceTypeString = priceType == LootTrackerPriceType.HIGH_ALCHEMY ? "HA: " : "GE: ";
}
priceLabel.setText(priceTypeString + QuantityFormatter.quantityToStackSize(totalPrice) + " gp");
priceLabel.setToolTipText(QuantityFormatter.formatNumber(totalPrice) + " gp");
final long kills = getTotalKills();
@@ -280,7 +292,7 @@ class LootTrackerBox extends JPanel
continue;
}
totalPrice += entry.getPrice();
totalPrice += priceType == LootTrackerPriceType.HIGH_ALCHEMY ? entry.getHaPrice() : entry.getGePrice();
int quantity = 0;
for (final LootTrackerItem i : items)
@@ -296,9 +308,10 @@ class LootTrackerBox extends JPanel
if (quantity != 0)
{
int newQuantity = entry.getQuantity() + quantity;
long pricePerItem = entry.getPrice() == 0 ? 0 : (entry.getPrice() / entry.getQuantity());
long gePricePerItem = entry.getGePrice() == 0 ? 0 : (entry.getGePrice() / entry.getQuantity());
long haPricePerItem = entry.getHaPrice() == 0 ? 0 : (entry.getHaPrice() / entry.getQuantity());
items.add(new LootTrackerItem(entry.getId(), entry.getName(), newQuantity, pricePerItem * newQuantity, entry.isIgnored()));
items.add(new LootTrackerItem(entry.getId(), entry.getName(), newQuantity, gePricePerItem * newQuantity, haPricePerItem * newQuantity, entry.isIgnored()));
}
else
{
@@ -306,7 +319,14 @@ class LootTrackerBox extends JPanel
}
}
items.sort((i1, i2) -> Long.compare(i2.getPrice(), i1.getPrice()));
if (priceType == LootTrackerPriceType.HIGH_ALCHEMY)
{
items.sort((i1, i2) -> Long.compare(i2.getHaPrice(), i1.getHaPrice()));
}
else
{
items.sort((i1, i2) -> Long.compare(i2.getGePrice(), i1.getGePrice()));
}
// Calculates how many rows need to be display to fit all items
final int rowSize = ((items.size() % ITEMS_PER_ROW == 0) ? 0 : 1) + items.size() / ITEMS_PER_ROW;
@@ -371,8 +391,11 @@ class LootTrackerBox extends JPanel
{
final String name = item.getName();
final int quantity = item.getQuantity();
final long price = item.getPrice();
final long gePrice = item.getGePrice();
final long haPrice = item.getHaPrice();
final String ignoredLabel = item.isIgnored() ? " - Ignored" : "";
return name + " x " + quantity + " (" + QuantityFormatter.quantityToStackSize(price) + ") " + ignoredLabel;
return "<html>" + name + " x " + quantity + ignoredLabel
+ "<br>GE: " + QuantityFormatter.quantityToStackSize(gePrice)
+ "<br>HA: " + QuantityFormatter.quantityToStackSize(haPrice) + "</html>";
}
}

View File

@@ -220,4 +220,23 @@ public interface LootTrackerConfig extends Config
return true;
}
@ConfigItem(
keyName = "priceType",
name = "Price Type",
description = "What type of price to use for calculating value."
)
default LootTrackerPriceType priceType()
{
return LootTrackerPriceType.GRAND_EXCHANGE;
}
@ConfigItem(
keyName = "showPriceType",
name = "Show Price Type",
description = "Whether to show a GE: or HA: next to the total values in the tracker"
)
default boolean showPriceType()
{
return false;
}
}

View File

@@ -39,7 +39,9 @@ class LootTrackerItem
@Getter(AccessLevel.PACKAGE)
private final int quantity;
@Getter(AccessLevel.PACKAGE)
private final long price;
private final long gePrice;
@Getter
private final long haPrice;
@Getter(AccessLevel.PACKAGE)
@Setter(AccessLevel.PACKAGE)
private boolean ignored;

View File

@@ -684,7 +684,7 @@ class LootTrackerPanel extends PluginPanel
// Create box
final LootTrackerBox box = new LootTrackerBox(record.getTimestamp().toEpochMilli(), itemManager, record.getTitle(), record.getSubTitle(),
hideIgnoredItems, config.displayDate(), plugin::toggleItem);
hideIgnoredItems, config.priceType(), config.showPriceType(), config.displayDate(), plugin::toggleItem);
box.combine(record);
// Create popup menu
@@ -780,7 +780,8 @@ class LootTrackerPanel extends PluginPanel
private void updateOverall()
{
long overallKills = 0;
long overallGp = 0;
long overallGe = 0;
long overallHa = 0;
for (LootTrackerRecord record : records)
{
@@ -824,7 +825,8 @@ class LootTrackerPanel extends PluginPanel
continue;
}
overallGp += item.getPrice();
overallGe += item.getGePrice();
overallHa += item.getHaPrice();
}
if (present > 0)
@@ -833,8 +835,16 @@ class LootTrackerPanel extends PluginPanel
}
}
String priceType = "";
if (config.showPriceType())
{
priceType = config.priceType() == LootTrackerPriceType.HIGH_ALCHEMY ? "HA " : "GE ";
}
overallKillsLabel.setText(htmlLabel("Total count: ", overallKills));
overallGpLabel.setText(htmlLabel("Total value: ", overallGp));
overallGpLabel.setText(htmlLabel("Total " + priceType + "value: ", config.priceType() == LootTrackerPriceType.HIGH_ALCHEMY ? overallHa : overallGe));
overallGpLabel.setToolTipText("<html>Total GE price: " + QuantityFormatter.formatNumber(overallGe)
+ "<br>Total HA price: " + QuantityFormatter.formatNumber(overallHa) + "</html>");
updateCollapseText();
}

View File

@@ -66,6 +66,7 @@ import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.Constants;
import net.runelite.api.GameState;
import net.runelite.api.InventoryID;
import net.runelite.api.Item;
@@ -1213,15 +1214,18 @@ public class LootTrackerPlugin extends Plugin
{
final ItemDefinition itemDefinition = itemManager.getItemDefinition(itemId);
final int realItemId = itemDefinition.getNote() != -1 ? itemDefinition.getLinkedNoteId() : itemId;
final long price;
final long gePrice ;
final long haPrice ;
// If it's a death we want to get a coin value for untradeables lost
if (!itemDefinition.isTradeable() && quantity < 0)
{
price = (long) itemDefinition.getPrice() * (long) quantity;
gePrice = (long) itemDefinition.getPrice() * (long) quantity;
haPrice = (long) Math.round(itemDefinition.getPrice() * Constants.HIGH_ALCHEMY_MULTIPLIER) * (long) quantity;
}
else
{
price = (long) itemManager.getItemPrice(realItemId) * (long) quantity;
gePrice = (long) itemManager.getItemPrice(realItemId) * (long) quantity;
haPrice = (long) Math.round(itemManager.getItemPrice(realItemId) * Constants.HIGH_ALCHEMY_MULTIPLIER) * (long) quantity;
}
final boolean ignored = ignoredItems.contains(itemDefinition.getName());
@@ -1229,7 +1233,8 @@ public class LootTrackerPlugin extends Plugin
itemId,
itemDefinition.getName(),
quantity,
price,
gePrice,
haPrice,
ignored);
}

View File

@@ -0,0 +1,31 @@
/*
* Copyright (c) 2019 Hydrox6 <ikada@protonmail.ch>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.client.plugins.loottracker;
public enum LootTrackerPriceType
{
GRAND_EXCHANGE,
HIGH_ALCHEMY
}

View File

@@ -31,16 +31,6 @@ import net.runelite.client.config.ConfigItem;
@ConfigGroup("music")
public interface MusicConfig extends Config
{
@ConfigItem(
keyName = "muteOtherAreaSounds",
name = "Mute others' area sounds",
description = "Mute area sounds caused from other players"
)
default boolean muteOtherAreaSounds()
{
return false;
}
@ConfigItem(
keyName = "musicVolume",
name = "",

View File

@@ -37,16 +37,13 @@ import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import net.runelite.api.Actor;
import net.runelite.api.Client;
import net.runelite.api.GameState;
import net.runelite.api.Player;
import net.runelite.api.ScriptID;
import net.runelite.api.SoundEffectID;
import net.runelite.api.SpriteID;
import net.runelite.api.VarClientInt;
import net.runelite.api.VarPlayer;
import net.runelite.api.events.AreaSoundEffectPlayed;
import net.runelite.api.events.ConfigChanged;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.ScriptCallbackEvent;
@@ -139,7 +136,6 @@ public class MusicPlugin extends Plugin
eventBus.subscribe(VarClientIntChanged.class, this, this::onVarClientIntChanged);
eventBus.subscribe(VolumeChanged.class, this, this::onVolumeChanged);
eventBus.subscribe(ScriptCallbackEvent.class, this, this::onScriptCallbackEvent);
eventBus.subscribe(AreaSoundEffectPlayed.class, this, this::onAreaSoundEffectPlayed);
}
private void onGameStateChanged(GameStateChanged gameStateChanged)
@@ -562,15 +558,4 @@ public class MusicPlugin extends Plugin
client.getIntStack()[client.getIntStackSize() - 1] = -1;
}
}
private void onAreaSoundEffectPlayed(AreaSoundEffectPlayed areaSoundEffectPlayed)
{
Actor source = areaSoundEffectPlayed.getSource();
if (source != client.getLocalPlayer()
&& source instanceof Player
&& musicConfig.muteOtherAreaSounds())
{
areaSoundEffectPlayed.consume();
}
}
}

View File

@@ -31,11 +31,11 @@ import net.runelite.api.mixins.FieldHook;
import net.runelite.api.mixins.Inject;
import net.runelite.api.mixins.Mixin;
import net.runelite.api.mixins.Shadow;
import net.runelite.rs.api.RSRawPcmStream;
import net.runelite.rs.api.RSClient;
import net.runelite.rs.api.RSPcmStream;
import net.runelite.rs.api.RSRawPcmStream;
import net.runelite.rs.api.RSRawSound;
import net.runelite.rs.api.RSSoundEffect;
import net.runelite.rs.api.RSPcmStream;
@Mixin(RSClient.class)
public abstract class SoundEffectMixin implements RSClient
@@ -120,7 +120,7 @@ public abstract class SoundEffectMixin implements RSClient
{
// Regular sound effect
SoundEffectPlayed event = new SoundEffectPlayed(null);
SoundEffectPlayed event = new SoundEffectPlayed();
event.setSoundId(client.getQueuedSoundEffectIDs()[soundIndex]);
event.setDelay(client.getQueuedSoundEffectDelays()[soundIndex]);
client.getCallbacks().post(SoundEffectPlayed.class, event);
@@ -133,7 +133,7 @@ public abstract class SoundEffectMixin implements RSClient
int y = (packedLocation >> 8) & 0xFF;
int range = (packedLocation) & 0xFF;
AreaSoundEffectPlayed event = new AreaSoundEffectPlayed(null);
AreaSoundEffectPlayed event = new AreaSoundEffectPlayed();
event.setSoundId(client.getQueuedSoundEffectIDs()[soundIndex]);
event.setSceneX(x);
event.setSceneY(y);