Merge pull request #941 from sdburns1998/code-cleanup
api: client: code clean up
This commit is contained in:
@@ -36,7 +36,7 @@ import net.runelite.api.Client;
|
||||
@Slf4j
|
||||
public class ClientThread
|
||||
{
|
||||
private ConcurrentLinkedQueue<BooleanSupplier> invokes = new ConcurrentLinkedQueue<>();
|
||||
private final ConcurrentLinkedQueue<BooleanSupplier> invokes = new ConcurrentLinkedQueue<>();
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@@ -115,7 +115,7 @@ public class ChatMessageManager
|
||||
|
||||
boolean isChatboxTransparent = client.isResized() && client.getVar(Varbits.TRANSPARENT_CHATBOX) == 1;
|
||||
Color usernameColor = null;
|
||||
Color senderColor = null;
|
||||
Color senderColor;
|
||||
|
||||
switch (chatMessageType)
|
||||
{
|
||||
|
||||
@@ -49,7 +49,7 @@ import net.runelite.discord.DiscordUser;
|
||||
public class DiscordService implements AutoCloseable
|
||||
{
|
||||
private final EventBus eventBus;
|
||||
public final RuneLiteProperties runeLiteProperties;
|
||||
private final RuneLiteProperties runeLiteProperties;
|
||||
private final ScheduledExecutorService executorService;
|
||||
private final DiscordRPC discordRPC;
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import static net.runelite.client.game.HiscoreManager.NONE;
|
||||
import net.runelite.http.api.hiscore.HiscoreClient;
|
||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Slf4j
|
||||
class HiscoreLoader extends CacheLoader<HiscoreManager.HiscoreKey, HiscoreResult>
|
||||
@@ -50,7 +51,7 @@ class HiscoreLoader extends CacheLoader<HiscoreManager.HiscoreKey, HiscoreResult
|
||||
}
|
||||
|
||||
@Override
|
||||
public HiscoreResult load(HiscoreManager.HiscoreKey hiscoreKey) throws Exception
|
||||
public HiscoreResult load(@NotNull HiscoreManager.HiscoreKey hiscoreKey) throws Exception
|
||||
{
|
||||
return EMPTY;
|
||||
}
|
||||
|
||||
@@ -168,6 +168,7 @@ import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.http.api.item.ItemClient;
|
||||
import net.runelite.http.api.item.ItemPrice;
|
||||
import net.runelite.http.api.item.ItemStats;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Singleton
|
||||
@Slf4j
|
||||
@@ -279,7 +280,7 @@ public class ItemManager
|
||||
.build(new CacheLoader<ImageKey, AsyncBufferedImage>()
|
||||
{
|
||||
@Override
|
||||
public AsyncBufferedImage load(ImageKey key) throws Exception
|
||||
public AsyncBufferedImage load(@NotNull ImageKey key) throws Exception
|
||||
{
|
||||
return loadImage(key.itemId, key.itemQuantity, key.stackable);
|
||||
}
|
||||
@@ -291,7 +292,7 @@ public class ItemManager
|
||||
.build(new CacheLoader<Integer, ItemDefinition>()
|
||||
{
|
||||
@Override
|
||||
public ItemDefinition load(Integer key) throws Exception
|
||||
public ItemDefinition load(@NotNull Integer key) throws Exception
|
||||
{
|
||||
return client.getItemDefinition(key);
|
||||
}
|
||||
@@ -303,7 +304,7 @@ public class ItemManager
|
||||
.build(new CacheLoader<OutlineKey, BufferedImage>()
|
||||
{
|
||||
@Override
|
||||
public BufferedImage load(OutlineKey key) throws Exception
|
||||
public BufferedImage load(@NotNull OutlineKey key) throws Exception
|
||||
{
|
||||
return loadItemOutline(key.itemId, key.itemQuantity, key.outlineColor);
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ public class SkillIconManager
|
||||
public BufferedImage getSkillImage(Skill skill, boolean small)
|
||||
{
|
||||
int skillIdx = skill.ordinal() + (small ? Skill.values().length : 0);
|
||||
BufferedImage skillImage = null;
|
||||
BufferedImage skillImage;
|
||||
|
||||
if (imgCache[skillIdx] != null)
|
||||
{
|
||||
|
||||
@@ -20,10 +20,10 @@ public enum Sound
|
||||
RESTORED_SPECIAL_ATTACK(16, "net/runelite/client/game/sounds/restorespec.wav"),
|
||||
IDLE(17, "net/runelite/client/game/sounds/idle.wav");
|
||||
|
||||
private String filePath;
|
||||
private int id;
|
||||
private final String filePath;
|
||||
private final int id;
|
||||
|
||||
private Sound(int id, String filePath)
|
||||
Sound(int id, String filePath)
|
||||
{
|
||||
this.id = id;
|
||||
this.filePath = filePath;
|
||||
|
||||
@@ -54,7 +54,7 @@ public class SpriteManager
|
||||
@Inject
|
||||
private ClientThread clientThread;
|
||||
|
||||
public Cache<Long, BufferedImage> cache = CacheBuilder.newBuilder()
|
||||
private final Cache<Long, BufferedImage> cache = CacheBuilder.newBuilder()
|
||||
.maximumSize(128L)
|
||||
.expireAfterAccess(1, TimeUnit.HOURS)
|
||||
.build();
|
||||
@@ -110,12 +110,8 @@ public class SpriteManager
|
||||
public void addSpriteTo(JButton c, int archive, int file)
|
||||
{
|
||||
getSpriteAsync(archive, file, img ->
|
||||
{
|
||||
SwingUtilities.invokeLater(() ->
|
||||
{
|
||||
c.setIcon(new ImageIcon(img));
|
||||
});
|
||||
});
|
||||
c.setIcon(new ImageIcon(img))));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -124,12 +120,8 @@ public class SpriteManager
|
||||
public void addSpriteTo(JLabel c, int archive, int file)
|
||||
{
|
||||
getSpriteAsync(archive, file, img ->
|
||||
{
|
||||
SwingUtilities.invokeLater(() ->
|
||||
{
|
||||
c.setIcon(new ImageIcon(img));
|
||||
});
|
||||
});
|
||||
c.setIcon(new ImageIcon(img))));
|
||||
}
|
||||
|
||||
public void addSpriteOverrides(SpriteOverride[] add)
|
||||
|
||||
@@ -27,13 +27,13 @@ package net.runelite.client.game.chatbox;
|
||||
/**
|
||||
* A modal input that lives in the chatbox panel.
|
||||
*/
|
||||
public abstract class ChatboxInput
|
||||
abstract class ChatboxInput
|
||||
{
|
||||
protected void open()
|
||||
void open()
|
||||
{
|
||||
}
|
||||
|
||||
protected void close()
|
||||
void close()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,12 +156,12 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
|
||||
return this;
|
||||
}
|
||||
|
||||
public ChatboxTextInput cursorAt(int index)
|
||||
private ChatboxTextInput cursorAt(int index)
|
||||
{
|
||||
return cursorAt(index, index);
|
||||
}
|
||||
|
||||
public ChatboxTextInput cursorAt(int indexA, int indexB)
|
||||
private ChatboxTextInput cursorAt(int indexA, int indexB)
|
||||
{
|
||||
if (indexA < 0)
|
||||
{
|
||||
@@ -722,9 +722,6 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
|
||||
newPos++;
|
||||
break;
|
||||
case KeyEvent.VK_UP:
|
||||
ev.consume();
|
||||
newPos = getLineOffset.applyAsInt(code);
|
||||
break;
|
||||
case KeyEvent.VK_DOWN:
|
||||
ev.consume();
|
||||
newPos = getLineOffset.applyAsInt(code);
|
||||
|
||||
@@ -40,7 +40,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
public class ClientLoader
|
||||
{
|
||||
private final ClientConfigLoader clientConfigLoader;
|
||||
private ClientUpdateCheckMode updateCheckMode;
|
||||
private final ClientUpdateCheckMode updateCheckMode;
|
||||
public static boolean useLocalInjected = false;
|
||||
|
||||
@Inject
|
||||
@@ -69,14 +69,16 @@ public class ClientLoader
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (IOException | ClassNotFoundException | InstantiationException | IllegalAccessException e)
|
||||
catch (IOException | InstantiationException | IllegalAccessException 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 injected client"
|
||||
+ " is not in your classpath.");
|
||||
}
|
||||
log.error("Error loading RS!", e);
|
||||
return null;
|
||||
}
|
||||
catch (ClassNotFoundException e)
|
||||
{
|
||||
log.error("Unable to load client - class not found. This means you"
|
||||
+ " are not running RuneLite with Maven as the injected client"
|
||||
+ " is not in your classpath.");
|
||||
|
||||
log.error("Error loading RS!", e);
|
||||
return null;
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import net.runelite.client.eventbus.EventBus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@Singleton
|
||||
public class DeferredEventBus extends EventBus
|
||||
@@ -43,19 +44,19 @@ public class DeferredEventBus extends EventBus
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(Object object)
|
||||
public void register(@NotNull Object object)
|
||||
{
|
||||
eventBus.register(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister(Object object)
|
||||
public void unregister(@NotNull Object object)
|
||||
{
|
||||
eventBus.unregister(object);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void post(Object object)
|
||||
public void post(@NotNull Object object)
|
||||
{
|
||||
pendingEvents.add(object);
|
||||
}
|
||||
@@ -66,7 +67,10 @@ public class DeferredEventBus extends EventBus
|
||||
while (size-- > 0)
|
||||
{
|
||||
Object object = pendingEvents.poll();
|
||||
eventBus.post(object);
|
||||
if (object != null)
|
||||
{
|
||||
eventBus.post(object);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,13 +8,13 @@ import net.runelite.api.coords.WorldPoint;
|
||||
|
||||
public class MiscUtils
|
||||
{
|
||||
private static int[] abovePointsX = {2944, 3392, 3392, 2944};
|
||||
private static int[] abovePointsY = {3523, 3523, 3971, 3971};
|
||||
private static int[] belowPointsX = {2944, 2944, 3264, 3264};
|
||||
private static int[] belowPointsY = {9918, 10360, 10360, 9918};
|
||||
private static final int[] abovePointsX = {2944, 3392, 3392, 2944};
|
||||
private static final int[] abovePointsY = {3523, 3523, 3971, 3971};
|
||||
private static final int[] belowPointsX = {2944, 2944, 3264, 3264};
|
||||
private static final int[] belowPointsY = {9918, 10360, 10360, 9918};
|
||||
|
||||
private static Polygon abovePoly = new Polygon(abovePointsX, abovePointsY, abovePointsX.length);
|
||||
private static Polygon belowPoly = new Polygon(belowPointsX, belowPointsY, belowPointsX.length);
|
||||
private static final Polygon abovePoly = new Polygon(abovePointsX, abovePointsY, abovePointsX.length);
|
||||
private static final Polygon belowPoly = new Polygon(belowPointsX, belowPointsY, belowPointsX.length);
|
||||
|
||||
//test replacement so private for now
|
||||
private static boolean inWildy(WorldPoint point)
|
||||
@@ -50,12 +50,9 @@ public class MiscUtils
|
||||
//v underground //v above ground
|
||||
int wildernessLevel = clamp(y > 6400 ? ((y - 9920) / 8) + 1 : ((y - 3520) / 8) + 1, 0, 56);
|
||||
|
||||
if (point.getPlane() > 0)
|
||||
if (point.getPlane() > 0 && y < 9920)
|
||||
{
|
||||
if (y < 9920)
|
||||
{
|
||||
wildernessLevel = 0;
|
||||
}
|
||||
wildernessLevel = 0;
|
||||
}
|
||||
|
||||
if (client.getWorldType().stream().anyMatch(worldType -> worldType == WorldType.PVP || worldType == WorldType.HIGH_RISK))
|
||||
|
||||
@@ -36,7 +36,7 @@ public class PvPUtil
|
||||
* @param point the point in the world to get the wilderness level for
|
||||
* @return the int representing the wilderness level
|
||||
*/
|
||||
public static int getWildernessLevelFrom(WorldPoint point)
|
||||
private static int getWildernessLevelFrom(WorldPoint point)
|
||||
{
|
||||
int y = point.getY();
|
||||
|
||||
|
||||
@@ -30,12 +30,12 @@ import org.objectweb.asm.tree.AnnotationNode;
|
||||
import org.objectweb.asm.tree.FieldNode;
|
||||
import org.objectweb.asm.tree.MethodNode;
|
||||
|
||||
public class RefUtils implements Opcodes
|
||||
class RefUtils implements Opcodes
|
||||
{
|
||||
|
||||
private static final String TYPE_PREFIX = "us/runelitepl/mixinprocessor/annotations/";
|
||||
|
||||
public static boolean isReturn(int opcode, boolean checkType)
|
||||
private static boolean isReturn(int opcode, boolean checkType)
|
||||
{
|
||||
return (opcode == RETURN && !checkType) || opcode == IRETURN || opcode == LRETURN || opcode == DRETURN ||
|
||||
opcode == ARETURN || opcode == FRETURN;
|
||||
@@ -76,7 +76,7 @@ public class RefUtils implements Opcodes
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String makeAnnotationDesc(String annot)
|
||||
private static String makeAnnotationDesc(String annot)
|
||||
{
|
||||
return "L" + TYPE_PREFIX + annot + ";";
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class SwingUtil
|
||||
* Sets some sensible defaults for swing.
|
||||
* IMPORTANT! Needs to be called before main frame creation
|
||||
*/
|
||||
public static void setupDefaults()
|
||||
private static void setupDefaults()
|
||||
{
|
||||
// Force heavy-weight popups/tooltips.
|
||||
// Prevents them from being obscured by the game applet.
|
||||
@@ -117,7 +117,7 @@ public class SwingUtil
|
||||
*
|
||||
* @param laf the swing look and feel
|
||||
*/
|
||||
public static void setTheme(@Nonnull final LookAndFeel laf)
|
||||
private static void setTheme(@Nonnull final LookAndFeel laf)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -135,7 +135,7 @@ public class SwingUtil
|
||||
*
|
||||
* @param font the new font to use
|
||||
*/
|
||||
public static void setFont(@Nonnull final Font font)
|
||||
private static void setFont(@Nonnull final Font font)
|
||||
{
|
||||
final FontUIResource f = new FontUIResource(font);
|
||||
final Enumeration keys = UIManager.getDefaults().keys();
|
||||
|
||||
@@ -77,12 +77,12 @@ public enum WildernessLocation
|
||||
this.worldArea = new WorldArea(location.x, location.y, location.width, location.height, plane);
|
||||
}
|
||||
|
||||
public static class Location
|
||||
static class Location
|
||||
{
|
||||
public int x;
|
||||
public int y;
|
||||
public int width;
|
||||
public int height;
|
||||
final int x;
|
||||
final int y;
|
||||
final int width;
|
||||
final int height;
|
||||
|
||||
Location(int x, int y, int x1, int y1)
|
||||
{
|
||||
|
||||
@@ -30,7 +30,7 @@ import com.sun.jna.platform.win32.WinDef;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class IcmpEchoReply extends Structure
|
||||
class IcmpEchoReply extends Structure
|
||||
{
|
||||
private static final int IP_OPTION_INFO_SIZE = 1 + 1 + 1 + 1 + (Pointer.SIZE == 8 ? 12 : 4); // on 64bit vms add 4 byte padding
|
||||
public static final int SIZE = 4 + 4 + 4 + 2 + 2 + Pointer.SIZE + IP_OPTION_INFO_SIZE;
|
||||
|
||||
Reference in New Issue
Block a user