Merge remote-tracking branch 'runelite/master'

This commit is contained in:
ThatGamerBlue
2020-09-08 18:36:30 +01:00
38 changed files with 525 additions and 930 deletions

View File

@@ -27,6 +27,9 @@ package net.runelite.client;
import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.core.Observable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
import lombok.AllArgsConstructor;
import net.runelite.http.api.RuneLiteAPI;
@@ -34,6 +37,7 @@ import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import okhttp3.ResponseBody;
@AllArgsConstructor
class SessionClient
@@ -54,7 +58,10 @@ class SessionClient
try (Response response = okHttpClient.newCall(request).execute())
{
return RuneLiteAPI.GSON.fromJson(response.body().string(), UUID.class);
ResponseBody body = response.body();
InputStream in = body.byteStream();
return RuneLiteAPI.GSON.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), UUID.class);
}
});
}

View File

@@ -28,9 +28,11 @@ import com.google.gson.Gson;
import io.reactivex.rxjava3.schedulers.Schedulers;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets;
import java.time.Instant;
import java.util.UUID;
@@ -87,7 +89,7 @@ public class SessionManager
try (FileInputStream in = new FileInputStream(SESSION_FILE))
{
session = new Gson().fromJson(new InputStreamReader(in), AccountSession.class);
session = new Gson().fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), AccountSession.class);
log.debug("Loaded session for {}", session.getUsername());
}
@@ -128,7 +130,7 @@ public class SessionManager
return;
}
try (FileWriter fw = new FileWriter(SESSION_FILE, StandardCharsets.UTF_8))
try (Writer fw = new OutputStreamWriter(new FileOutputStream(SESSION_FILE), StandardCharsets.UTF_8))
{
new Gson().toJson(accountSession, fw);

View File

@@ -28,7 +28,6 @@ import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.ImmutableMap;
import io.reactivex.rxjava3.core.Completable;
import io.reactivex.rxjava3.schedulers.Schedulers;
import java.awt.Color;
import java.awt.image.BufferedImage;
@@ -216,13 +215,6 @@ public class ItemManager
eventbus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
eventbus.subscribe(PostItemDefinition.class, this, this::onPostItemDefinition);
Completable.fromAction(ItemVariationMapping::load)
.subscribeOn(Schedulers.computation())
.subscribe(
() -> log.debug("Loaded {} item variations", ItemVariationMapping.getSize()),
ex -> log.warn("Error loading item variations", ex)
);
}
private void loadPrices()

View File

@@ -192,7 +192,7 @@ public enum ItemMapping
ITEM_RING_OF_ENDURANCE(RING_OF_ENDURANCE_UNCHARGED_24844, RING_OF_ENDURANCE),
// Infinity colour kits
ITEM_INFINITY_TOP(INFINITY_TOP, INFINITY_TOP_10605, INFINITY_TOP_20574, DARK_INFINITY_TOP, LIGHT_INFINITY_TOP),
ITEM_INFINITY_TOP(INFINITY_TOP, INFINITY_TOP_20574, DARK_INFINITY_TOP, LIGHT_INFINITY_TOP),
ITEM_INFINITY_TOP_LIGHT_COLOUR_KIT(LIGHT_INFINITY_COLOUR_KIT, LIGHT_INFINITY_TOP),
ITEM_INFINITY_TOP_DARK_COLOUR_KIT(DARK_INFINITY_COLOUR_KIT, DARK_INFINITY_TOP),
ITEM_INFINITY_BOTTOMS(INFINITY_BOTTOMS, INFINITY_BOTTOMS_20575, DARK_INFINITY_BOTTOMS, LIGHT_INFINITY_BOTTOMS),

View File

@@ -28,23 +28,54 @@ package net.runelite.client.game;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;
import com.google.common.collect.Multimap;
import com.google.gson.stream.JsonReader;
import java.io.IOException;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
/**
* Converts variation items to it's base item counterparts
*/
@Slf4j
public class ItemVariationMapping
{
private static Map<Integer, Integer> MAPPINGS;
private static Multimap<Integer, Integer> INVERTED_MAPPINGS;
private static final Map<Integer, Integer> MAPPINGS;
private static final Multimap<Integer, Integer> INVERTED_MAPPINGS;
static
{
final Gson gson = new Gson();
final TypeToken<Map<String, Collection<Integer>>> typeToken = new TypeToken<Map<String, Collection<Integer>>>()
{
};
final InputStream geLimitData = ItemVariationMapping.class.getResourceAsStream("/item_variations.json");
final Map<String, Collection<Integer>> itemVariations = gson.fromJson(new InputStreamReader(geLimitData, StandardCharsets.UTF_8), typeToken.getType());
ImmutableMap.Builder<Integer, Integer> builder = new ImmutableMap.Builder<>();
ImmutableMultimap.Builder<Integer, Integer> invertedBuilder = new ImmutableMultimap.Builder<>();
for (Collection<Integer> value : itemVariations.values())
{
final Iterator<Integer> iterator = value.iterator();
final int base = iterator.next();
while (iterator.hasNext())
{
final int id = iterator.next();
builder.put(id, base);
invertedBuilder.put(base, id);
}
invertedBuilder.put(base, base);
}
INVERTED_MAPPINGS = invertedBuilder.build();
MAPPINGS = builder.build();
}
/**
* Get base item id for provided variation item id.
@@ -68,41 +99,6 @@ public class ItemVariationMapping
return INVERTED_MAPPINGS.asMap().getOrDefault(itemId, Collections.singletonList(itemId));
}
public static void load() throws IOException
{
try (JsonReader reader = new JsonReader(new InputStreamReader(ItemVariationMapping.class.getResourceAsStream("/item_variations.min.json"), StandardCharsets.UTF_8)))
{
ImmutableMap.Builder<Integer, Integer> builder = ImmutableMap.builderWithExpectedSize(5039);
ImmutableMultimap.Builder<Integer, Integer> invertedBuilder = new ImmutableMultimap.Builder<>();
reader.beginObject();
while (reader.hasNext())
{
// Names are useless
reader.skipValue();
reader.beginArray();
int base = reader.nextInt();
while (reader.hasNext())
{
final int id = reader.nextInt();
builder.put(id, base);
invertedBuilder.put(base, id);
}
invertedBuilder.put(base, base);
reader.endArray();
}
reader.endObject();
INVERTED_MAPPINGS = invertedBuilder.build();
MAPPINGS = builder.build();
}
}
static int getSize()
{
return MAPPINGS.size();

View File

@@ -40,9 +40,14 @@ public class MouseManager
private final List<MouseListener> mouseListeners = new CopyOnWriteArrayList<>();
private final List<MouseWheelListener> mouseWheelListeners = new CopyOnWriteArrayList<>();
private final RuneLiteConfig runeLiteConfig;
@Inject
private RuneLiteConfig runeLiteConfig;
private MouseManager(RuneLiteConfig runeLiteConfig)
{
this.runeLiteConfig = runeLiteConfig;
}
public void registerMouseListener(MouseListener mouseListener)
{
@@ -136,7 +141,7 @@ public class MouseManager
}
return mouseEvent;
}
private void checkExtraMouseButtons(MouseEvent mouseEvent)
{
// Prevent extra mouse buttons from being passed into the client,

View File

@@ -0,0 +1,43 @@
/*
* Copyright (c) 2020, 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.timetracking;
import lombok.AllArgsConstructor;
@AllArgsConstructor
public enum TimeFormatMode
{
RELATIVE("Relative"),
ABSOLUTE_12H("12 Hour"),
ABSOLUTE_24H("24 Hour");
private final String name;
@Override
public String toString()
{
return name;
}
}

View File

@@ -28,6 +28,7 @@ package net.runelite.client.rs;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import lombok.AllArgsConstructor;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
@@ -55,7 +56,7 @@ class ClientConfigLoader
}
String str;
final BufferedReader in = new BufferedReader(new InputStreamReader(response.body().byteStream()));
final BufferedReader in = new BufferedReader(new InputStreamReader(response.body().byteStream(), StandardCharsets.UTF_8));
while ((str = in.readLine()) != null)
{
int idx = str.indexOf('=');

View File

@@ -98,7 +98,7 @@ public class ColorValueSlider extends JPanel
super.paint(g);
g.setColor(TRACK_COLOR);
g.fillRect(0, this.getHeight() / 2 - 2, this.getWidth() - KNOB_WIDTH, 5);
g.fillRect(0, this.getHeight() / 2 - 2, ColorUtil.MAX_RGB_VALUE + KNOB_WIDTH * 2, 5);
g.setColor(KNOB_COLOR);
g.fillRect(value - KNOB_WIDTH / 2, this.getHeight() / 2 - KNOB_HEIGHT / 2, KNOB_WIDTH, KNOB_HEIGHT);

View File

@@ -65,7 +65,7 @@ public class RuneliteColorPicker extends JDialog
{
static final String CONFIG_GROUP = "colorpicker";
private final static int FRAME_WIDTH = 400;
private final static int FRAME_WIDTH = 410;
private final static int FRAME_HEIGHT = 380;
private final static int TONE_PANEL_SIZE = 160;

View File

@@ -35,6 +35,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@@ -219,7 +220,7 @@ public class ImageCapture
try (InputStream in = response.body().byteStream())
{
ImageUploadResponse imageUploadResponse = RuneLiteAPI.GSON
.fromJson(new InputStreamReader(in), ImageUploadResponse.class);
.fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), ImageUploadResponse.class);
if (imageUploadResponse.isSuccess())
{

View File

@@ -339,7 +339,6 @@ public class WeaponMap
StyleMap.put(ItemID.ROCK_HAMMER, WeaponStyle.MELEE);
StyleMap.put(ItemID.ROYAL_SCEPTRE, WeaponStyle.MELEE);
StyleMap.put(ItemID.RUBBER_CHICKEN, WeaponStyle.MELEE);
StyleMap.put(ItemID.RUBBER_CHICKEN_10732, WeaponStyle.MELEE);
StyleMap.put(ItemID.RUBBER_CHICKEN_22666, WeaponStyle.MELEE);
StyleMap.put(ItemID.RUNE_2H_SWORD, WeaponStyle.MELEE);
StyleMap.put(ItemID.RUNE_AXE, WeaponStyle.MELEE);
@@ -370,7 +369,6 @@ public class WeaponMap
StyleMap.put(ItemID.SARADOMIN_SWORD, WeaponStyle.MELEE);
StyleMap.put(ItemID.SARAS_BLESSED_SWORD_FULL, WeaponStyle.MELEE);
StyleMap.put(ItemID.SCYTHE, WeaponStyle.MELEE);
StyleMap.put(ItemID.SCYTHE_10735, WeaponStyle.MELEE);
StyleMap.put(ItemID.SCYTHE_OF_VITUR, WeaponStyle.MELEE);
StyleMap.put(ItemID.SCYTHE_OF_VITUR_22664, WeaponStyle.MELEE);
StyleMap.put(ItemID.SCYTHE_OF_VITUR_UNCHARGED, WeaponStyle.MELEE);