Merge pull request #1 from runelite-extended/master

Merge
This commit is contained in:
Ganom
2019-06-01 21:30:33 -04:00
committed by GitHub
14 changed files with 145 additions and 183 deletions

View File

@@ -25,7 +25,6 @@
package net.runelite.client.game.chatbox;
import com.google.common.base.Strings;
import com.google.common.primitives.Ints;
import com.google.inject.Inject;
import java.awt.Point;
import java.awt.Rectangle;
@@ -58,6 +57,7 @@ import net.runelite.api.widgets.WidgetType;
import net.runelite.client.callback.ClientThread;
import net.runelite.client.input.KeyListener;
import net.runelite.client.input.MouseListener;
import net.runelite.client.util.MiscUtils;
import net.runelite.client.util.Text;
@Slf4j
@@ -349,8 +349,8 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
if (isStartLine || isEndLine || (cursorEnd > line.end && cursorStart < line.start))
{
final int cIdx = Ints.constrainToRange(cursorStart - line.start, 0, len);
final int ceIdx = Ints.constrainToRange(cursorEnd - line.start, 0, len);
final int cIdx = MiscUtils.clamp(cursorStart - line.start, 0, len);
final int ceIdx = MiscUtils.clamp(cursorEnd - line.start, 0, len);
lt = Text.escapeJagex(text.substring(0, cIdx));
mt = Text.escapeJagex(text.substring(cIdx, ceIdx));
@@ -452,7 +452,7 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
int cx = p.x - ccl.getX() - ox;
int cy = p.y - ccl.getY() - oy;
int currentLine = Ints.constrainToRange(cy / oh, 0, editLines.size() - 1);
int currentLine = MiscUtils.clamp(cy / oh, 0, editLines.size() - 1);
final Line line = editLines.get(currentLine);
final String tsValue = line.text;
@@ -489,7 +489,7 @@ public class ChatboxTextInput extends ChatboxInput implements KeyListener, Mouse
break;
}
charIndex = Ints.constrainToRange(charIndex, 0, tsValue.length());
charIndex = MiscUtils.clamp(charIndex, 0, tsValue.length());
return line.start + charIndex;
};

View File

@@ -37,10 +37,7 @@ import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import net.runelite.api.EquipmentInventorySlot;
import net.runelite.api.GameState;
import net.runelite.api.InventoryID;
import net.runelite.api.Item;
import net.runelite.api.ItemID;
import net.runelite.api.MenuEntry;
import net.runelite.api.MessageNode;
@@ -50,7 +47,6 @@ import net.runelite.api.Varbits;
import net.runelite.api.coords.WorldPoint;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameStateChanged;
import net.runelite.api.events.ItemContainerChanged;
import net.runelite.api.events.ItemDespawned;
import net.runelite.api.events.ItemSpawned;
import net.runelite.api.events.MenuEntryAdded;
@@ -185,29 +181,54 @@ public class BarbarianAssaultPlugin extends Plugin
@Subscribe
public void onWidgetLoaded(WidgetLoaded event)
{
if (event.getGroupId() == WidgetID.BA_REWARD_GROUP_ID)
switch (event.getGroupId())
{
Wave wave = new Wave(client);
Widget rewardWidget = client.getWidget(WidgetInfo.BA_REWARD_TEXT);
if (rewardWidget != null && rewardWidget.getText().contains(ENDGAME_REWARD_NEEDLE_TEXT) && gameTime != null)
case WidgetID.BA_REWARD_GROUP_ID:
{
if (config.waveTimes())
Wave wave = new Wave(client);
Widget rewardWidget = client.getWidget(WidgetInfo.BA_REWARD_TEXT);
if (rewardWidget != null && rewardWidget.getText().contains(ENDGAME_REWARD_NEEDLE_TEXT) && gameTime != null)
{
announceTime("Game finished, duration: ", gameTime.getTime(false));
if (config.waveTimes())
{
announceTime("Game finished, duration: ", gameTime.getTime(false));
}
if (config.showTotalRewards())
{
announceSomething(game.getGameSummary());
}
}
if (config.showTotalRewards())
Widget pointsWidget = client.getWidget(WidgetInfo.BA_RUNNERS_PASSED);
if (rewardWidget != null && !rewardWidget.getText().contains(ENDGAME_REWARD_NEEDLE_TEXT) && pointsWidget != null
&& config.showSummaryOfPoints() && !hasAnnounced && client.getVar(Varbits.IN_GAME_BA) == 0)
{
announceSomething(game.getGameSummary());
wave.setWaveAmounts();
wave.setWavePoints();
game.getWaves().add(wave);
announceSomething(wave.getWaveSummary());
}
break;
}
Widget pointsWidget = client.getWidget(WidgetInfo.BA_RUNNERS_PASSED);
if (!rewardWidget.getText().contains(ENDGAME_REWARD_NEEDLE_TEXT) && pointsWidget != null
&& config.showSummaryOfPoints() && !hasAnnounced && client.getVar(Varbits.IN_GAME_BA) == 0)
case WidgetID.BA_ATTACKER_GROUP_ID:
{
wave.setWaveAmounts();
wave.setWavePoints();
game.getWaves().add(wave);
announceSomething(wave.getWaveSummary());
setOverlayRound(Role.ATTACKER);
break;
}
case WidgetID.BA_DEFENDER_GROUP_ID:
{
setOverlayRound(Role.DEFENDER);
break;
}
case WidgetID.BA_HEALER_GROUP_ID:
{
setOverlayRound(Role.HEALER);
break;
}
case WidgetID.BA_COLLECTOR_GROUP_ID:
{
setOverlayRound(Role.COLLECTOR);
break;
}
}
}
@@ -295,44 +316,6 @@ public class BarbarianAssaultPlugin extends Plugin
}
}
@Subscribe
public void onItemContainerChanged(final ItemContainerChanged event)
{
if (event.getItemContainer() != client.getItemContainer(InventoryID.EQUIPMENT))
{
return;
}
if (overlay.getCurrentRound() != null)
{
return;
}
final Item[] items = event.getItemContainer().getItems();
// Check that the local player is wearing enough items to be wearing a cape.
if (items == null || items.length <= EquipmentInventorySlot.CAPE.getSlotIdx())
{
return;
}
switch (items[EquipmentInventorySlot.CAPE.getSlotIdx()].getId())
{
case ItemID.ATTACKER_ICON:
overlay.setCurrentRound(new Round(Role.ATTACKER));
break;
case ItemID.COLLECTOR_ICON:
overlay.setCurrentRound(new Round(Role.COLLECTOR));
break;
case ItemID.DEFENDER_ICON:
overlay.setCurrentRound(new Round(Role.DEFENDER));
break;
case ItemID.HEALER_ICON:
overlay.setCurrentRound(new Round(Role.HEALER));
break;
}
}
@Subscribe
public void onVarbitChanged(VarbitChanged event)
{
@@ -457,6 +440,16 @@ public class BarbarianAssaultPlugin extends Plugin
}
}
private void setOverlayRound(Role role)
{
if (overlay.getCurrentRound() != null)
{
return;
}
overlay.setCurrentRound(new Round(role));
}
private void announceSomething(final ChatMessageBuilder chatMessage)
{
chatMessageManager.queue(QueuedMessage.builder()

View File

@@ -24,30 +24,30 @@
*/
package net.runelite.client.plugins.blackjack;
import com.google.inject.Binder;
import javax.inject.Inject;
import javax.inject.Singleton;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.ChatMessageType;
import net.runelite.api.Client;
import static net.runelite.api.Varbits.QUEST_THE_FEUD;
import net.runelite.api.GameState;
import net.runelite.api.Varbits;
import net.runelite.api.events.ChatMessage;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.MenuEntryAdded;
import net.runelite.api.events.VarbitChanged;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.menus.MenuManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.PluginType;
import static net.runelite.client.util.MenuUtil.swap;
import net.runelite.client.util.MenuUtil;
import net.runelite.client.util.Text;
import org.apache.commons.lang3.RandomUtils;
/**
* Authors gazivodag longstreet
*/
@PluginDescriptor(
name = "Blackjack",
description = "Uses chat messages and tick timers instead of animations to read",
description = "Allows for one-click blackjacking, both knocking out and pickpocketing",
tags = {"blackjack", "thieving"},
type = PluginType.SKILLING
)
@@ -55,111 +55,51 @@ import static net.runelite.client.util.MenuUtil.swap;
@Slf4j
public class BlackjackPlugin extends Plugin
{
private static final String PICKPOCKET = "Pickpocket";
private static final String KNOCK_OUT = "Knock-out";
private static final String LURE = "Lure";
private static final String BANDIT = "Bandit";
private static final String MENAPHITE = "Menaphite Thug";
private static int POLLNIVNEACH_REGION = 13358;
@Inject
private Client client;
@Inject
private MenuManager menuManager;
private boolean isKnockedOut = false;
private boolean ableToBlackJack = false;
private int lastKnockout;
private boolean pickpocketing;
private boolean ableToBlackJack;
@Override
public void configure(Binder binder)
{
}
@Override
protected void startUp() throws Exception
{
menuManager.addPriorityEntry(LURE, BANDIT);
menuManager.addPriorityEntry(LURE, MENAPHITE);
menuManager.addPriorityEntry(KNOCK_OUT, BANDIT);
menuManager.addPriorityEntry(KNOCK_OUT, MENAPHITE);
}
@Override
protected void shutDown() throws Exception
{
menuManager.removePriorityEntry(LURE, BANDIT);
menuManager.removePriorityEntry(LURE, MENAPHITE);
menuManager.removePriorityEntry(PICKPOCKET, BANDIT);
menuManager.removePriorityEntry(PICKPOCKET, MENAPHITE);
menuManager.removePriorityEntry(KNOCK_OUT, BANDIT);
menuManager.removePriorityEntry(KNOCK_OUT, MENAPHITE);
}
@Subscribe
public void onGameTick(GameTick gameTick)
{
if (ableToBlackJack && pickpocketing && client.getTickCount() >= lastKnockout + 4)
{
pickpocketing = false;
menuManager.removePriorityEntry(PICKPOCKET, BANDIT);
menuManager.removePriorityEntry(PICKPOCKET, MENAPHITE);
menuManager.addPriorityEntry(KNOCK_OUT, BANDIT);
menuManager.addPriorityEntry(KNOCK_OUT, MENAPHITE);
}
}
private long nextKnockOutTick = 0;
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded event)
{
// Lure has higher priority than knock-out
if (event.getTarget().contains(MENAPHITE) || event.getTarget().contains(BANDIT)
&& event.getOption().equals(LURE))
if (client.getGameState() != GameState.LOGGED_IN
|| (client.getLocalPlayer().getWorldLocation().getRegionID() != POLLNIVNEACH_REGION || !ableToBlackJack))
{
swap(client, KNOCK_OUT, LURE, event.getTarget(), false);
return;
}
String option = Text.removeTags(event.getOption().toLowerCase());
String target = Text.removeTags(event.getTarget().toLowerCase());
if (isKnockedOut && nextKnockOutTick >= client.getTickCount())
{
MenuUtil.swap(client, "pickpocket", option, target);
}
else
{
MenuUtil.swap(client, "knock-out", option, target);
}
}
@Subscribe
public void onChatMessage(ChatMessage chatMessage)
public void onChatMessage(ChatMessage event)
{
if (chatMessage.getType() == ChatMessageType.SPAM)
if (event.getType() == ChatMessageType.SPAM
&& event.getMessage().equals("You smack the bandit over the head and render them unconscious."))
{
if (chatMessage.getMessage().equals("You smack the bandit over the head and render them unconscious.")
|| chatMessage.getMessage().equals("Your blow only glances off the bandit's head."))
{
menuManager.removePriorityEntry(KNOCK_OUT, BANDIT);
menuManager.removePriorityEntry(KNOCK_OUT, MENAPHITE);
menuManager.addPriorityEntry(PICKPOCKET, BANDIT);
menuManager.addPriorityEntry(PICKPOCKET, MENAPHITE);
lastKnockout = client.getTickCount();
pickpocketing = true;
}
isKnockedOut = true;
nextKnockOutTick = client.getTickCount() + RandomUtils.nextInt(3, 4);
}
}
@Subscribe
public void onVarbitChanged(VarbitChanged event)
{
ableToBlackJack = client.getVar(QUEST_THE_FEUD) >= 13;
if (!ableToBlackJack)
{
menuManager.removePriorityEntry(LURE, BANDIT);
menuManager.removePriorityEntry(LURE, MENAPHITE);
menuManager.removePriorityEntry(KNOCK_OUT, BANDIT);
menuManager.removePriorityEntry(KNOCK_OUT, MENAPHITE);
menuManager.removePriorityEntry(PICKPOCKET, BANDIT);
menuManager.removePriorityEntry(PICKPOCKET, MENAPHITE);
}
ableToBlackJack = client.getVar(Varbits.QUEST_THE_FEUD) >= 13;
}
}
}

View File

@@ -26,7 +26,6 @@ package net.runelite.client.plugins.config;
import com.google.common.base.Splitter;
import com.google.common.base.Strings;
import com.google.common.primitives.Ints;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
@@ -108,6 +107,7 @@ import net.runelite.client.ui.components.IconTextField;
import net.runelite.client.ui.components.colorpicker.RuneliteColorPicker;
import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.MiscUtils;
import net.runelite.client.util.Text;
import org.apache.commons.lang3.StringUtils;
@@ -701,7 +701,7 @@ public class ConfigPanel extends PluginPanel
}
// Config may previously have been out of range
value = Ints.constrainToRange(value, min, max);
value = MiscUtils.clamp(value, min, max);
if (max < Integer.MAX_VALUE)
{

View File

@@ -577,6 +577,7 @@ public class CoxPlugin extends Plugin
if (runTekton)
{
runVanguards = false;
if (Tekton_NPC.getId() == NpcID.TEKTON_ENRAGED || Tekton_NPC.getId() == NpcID.TEKTON_ENRAGED_7544)
{
enrageStage = true;
@@ -593,6 +594,7 @@ public class CoxPlugin extends Plugin
if (runGuard)
{
runVanguards = false;
if (guardTick == -1)
{
if (Guard1_NPC != null)
@@ -644,17 +646,19 @@ public class CoxPlugin extends Plugin
case NpcID.VANGUARD_7526:
break;
}
if (meleeVangHP <= 0 && mageVangHP <= 0 && rangeVangHP <= 0)
{
runVanguards = false;
}
}
if (mageVangHP == 0 && meleeVangHP == 0 && rangeVangHP == 0)
{
runVanguards = false;
}
}
if (runOlm)
{
runVanguards = false;
Olm_Crystals.clear();
Olm_Heal.clear();
Olm_TP.clear();
client.clearHintArrow();
sleepcount--;

View File

@@ -27,7 +27,6 @@ package net.runelite.client.plugins.devtools;
import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import com.google.common.collect.ImmutableList;
import com.google.common.primitives.Ints;
import com.google.inject.Provides;
import java.awt.image.BufferedImage;
import static java.lang.Math.min;
@@ -60,6 +59,7 @@ import net.runelite.client.ui.NavigationButton;
import net.runelite.client.ui.overlay.OverlayManager;
import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.ImageUtil;
import net.runelite.client.util.MiscUtils;
import org.slf4j.LoggerFactory;
@PluginDescriptor(
@@ -288,7 +288,7 @@ public class DevToolsPlugin extends Plugin
Skill skill = Skill.valueOf(args[0].toUpperCase());
int level = Integer.parseInt(args[1]);
level = Ints.constrainToRange(level, 1, Experience.MAX_REAL_LEVEL);
level = MiscUtils.clamp(level, 1, Experience.MAX_REAL_LEVEL);
int xp = Experience.getXpForLevel(level);
client.getBoostedSkillLevels()[skill.ordinal()] = level;

View File

@@ -33,6 +33,17 @@ public interface MouseHighlightConfig extends Config
{
@ConfigItem(
position = 0,
keyName = "mainTooltip",
name = "Main Tooltips",
description = "Whether or not tooltips are shown on things other than interfaces or the chatbox"
)
default boolean mainTooltip()
{
return true;
}
@ConfigItem(
position = 1,
keyName = "uiTooltip",
name = "Interface Tooltips",
description = "Whether or not tooltips are shown on interfaces"
@@ -43,7 +54,7 @@ public interface MouseHighlightConfig extends Config
}
@ConfigItem(
position = 1,
position = 2,
keyName = "chatboxTooltip",
name = "Chatbox Tooltips",
description = "Whether or not tooltips are shown over the chatbox"
@@ -53,13 +64,23 @@ public interface MouseHighlightConfig extends Config
return true;
}
@ConfigItem(position = 2, keyName = "hideSpells", name = "Spellbook", description = "Hides vanilla client tooltips in the spellbook")
@ConfigItem(
position = 3,
keyName = "hideSpells",
name = "Spellbook",
description = "Hides vanilla client tooltips in the spellbook"
)
default boolean shouldHideSpells()
{
return false;
}
@ConfigItem(position = 3, keyName = "hideCombat", name = "Combat", description = "Hides vanilla client tooltips in the combat menu")
@ConfigItem(
position = 4,
keyName = "hideCombat",
name = "Combat",
description = "Hides vanilla client tooltips in the combat menu"
)
default boolean shouldHideCombat()
{
return false;

View File

@@ -126,6 +126,11 @@ class MouseHighlightOverlay extends Overlay
}
}
if (widget == null && !config.mainTooltip())
{
return null;
}
// If this varc is set, a tooltip is already being displayed
int tooltipDisplayed = client.getVar(VarClientInt.TOOLTIP_VISIBLE);
if (tooltipDisplayed == 1)

View File

@@ -25,7 +25,6 @@
*/
package net.runelite.client.plugins.zoom;
import com.google.common.primitives.Ints;
import com.google.inject.Inject;
import com.google.inject.Provides;
import java.awt.event.KeyEvent;
@@ -41,6 +40,7 @@ import net.runelite.client.input.KeyListener;
import net.runelite.client.input.KeyManager;
import net.runelite.client.plugins.Plugin;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.util.MiscUtils;
@PluginDescriptor(
name = "Camera Zoom",
@@ -103,7 +103,7 @@ public class ZoomPlugin extends Plugin implements KeyListener
if ("outerZoomLimit".equals(event.getEventName()))
{
int outerLimit = Ints.constrainToRange(zoomConfig.outerLimit(), ZoomConfig.OUTER_LIMIT_MIN, ZoomConfig.OUTER_LIMIT_MAX);
int outerLimit = MiscUtils.clamp(zoomConfig.outerLimit(), ZoomConfig.OUTER_LIMIT_MIN, ZoomConfig.OUTER_LIMIT_MAX);
int outerZoomLimit = 128 - outerLimit;
intStack[intStackSize - 1] = outerZoomLimit;
return;
@@ -192,7 +192,7 @@ public class ZoomPlugin extends Plugin implements KeyListener
controlDown = false;
if (zoomConfig.controlFunction() == ControlFunction.CONTROL_TO_RESET)
{
final int zoomValue = Ints.constrainToRange(zoomConfig.ctrlZoomValue(), zoomConfig.OUTER_LIMIT_MIN, INNER_ZOOM_LIMIT);
final int zoomValue = MiscUtils.clamp(zoomConfig.ctrlZoomValue(), zoomConfig.OUTER_LIMIT_MIN, INNER_ZOOM_LIMIT);
clientThread.invokeLater(() -> client.runScript(ScriptID.CAMERA_DO_ZOOM, zoomValue, zoomValue));
}
}

View File

@@ -25,7 +25,6 @@
*/
package net.runelite.client.ui.components.colorpicker;
import com.google.common.primitives.Ints;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
@@ -39,6 +38,7 @@ import java.awt.image.BufferedImage;
import java.util.function.Consumer;
import javax.swing.JPanel;
import lombok.Setter;
import net.runelite.client.util.MiscUtils;
public class ColorPanel extends JPanel
{
@@ -144,8 +144,8 @@ public class ColorPanel extends JPanel
return;
}
x = Ints.constrainToRange(x, 0, size - 1);
y = Ints.constrainToRange(y, 0, size - 1);
x = MiscUtils.clamp(x, 0, size - 1);
y = MiscUtils.clamp(y, 0, size - 1);
targetPosition = new Point(x, y);
paintImmediately(0, 0, size, size);
@@ -200,8 +200,8 @@ public class ColorPanel extends JPanel
*/
private Color colorAt(int x, int y)
{
x = Ints.constrainToRange(x, 0, size - 1);
y = Ints.constrainToRange(y, 0, size - 1);
x = MiscUtils.clamp(x, 0, size - 1);
y = MiscUtils.clamp(y, 0, size - 1);
return new Color(image.getRGB(x, y));
}
}

View File

@@ -25,7 +25,6 @@
*/
package net.runelite.client.ui.components.colorpicker;
import com.google.common.primitives.Ints;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
@@ -35,6 +34,7 @@ import java.util.function.Consumer;
import javax.swing.JPanel;
import lombok.Setter;
import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.MiscUtils;
public class ColorValueSlider extends JPanel
{
@@ -83,7 +83,7 @@ public class ColorValueSlider extends JPanel
private void moveTarget(int x, boolean shouldUpdate)
{
value = Ints.constrainToRange(x, ColorUtil.MIN_RGB_VALUE + KNOB_WIDTH, ColorUtil.MAX_RGB_VALUE + KNOB_WIDTH);
value = MiscUtils.clamp(x, ColorUtil.MIN_RGB_VALUE + KNOB_WIDTH, ColorUtil.MAX_RGB_VALUE + KNOB_WIDTH);
paintImmediately(0, 0, this.getWidth(), this.getHeight());
if (shouldUpdate && onValueChanged != null)

View File

@@ -25,7 +25,6 @@
*/
package net.runelite.client.ui.components.colorpicker;
import com.google.common.primitives.Ints;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
@@ -36,6 +35,7 @@ import java.util.function.Consumer;
import javax.swing.JPanel;
import lombok.Getter;
import lombok.Setter;
import net.runelite.client.util.MiscUtils;
public class HuePanel extends JPanel
{
@@ -94,7 +94,7 @@ public class HuePanel extends JPanel
*/
private void moveSelector(int y)
{
y = Ints.constrainToRange(y, 0, height - 1);
y = MiscUtils.clamp(y, 0, height - 1);
if (y == this.selectedY)
{
return;

View File

@@ -25,7 +25,6 @@
package net.runelite.client.ui.overlay;
import com.google.common.base.MoreObjects;
import com.google.common.primitives.Ints;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics2D;
@@ -54,6 +53,7 @@ import net.runelite.client.input.MouseAdapter;
import net.runelite.client.input.MouseManager;
import net.runelite.client.ui.JagexColors;
import net.runelite.client.util.ColorUtil;
import net.runelite.client.util.MiscUtils;
@Singleton
public class OverlayRenderer extends MouseAdapter implements KeyListener
@@ -250,8 +250,8 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
}
final Dimension realDimensions = client.getRealDimensions();
location.x = Ints.constrainToRange(location.x, 0, Math.max(0, realDimensions.width - dimension.width));
location.y = Ints.constrainToRange(location.y, 0, Math.max(0, realDimensions.height - dimension.height));
location.x = MiscUtils.clamp(location.x, 0, Math.max(0, realDimensions.width - dimension.width));
location.y = MiscUtils.clamp(location.y, 0, Math.max(0, realDimensions.height - dimension.height));
}
if (overlay.getPreferredSize() != null)
@@ -347,8 +347,8 @@ public class OverlayRenderer extends MouseAdapter implements KeyListener
{
final Dimension realDimension = client.getRealDimensions();
mousePoint.translate(-overlayOffset.x, -overlayOffset.y);
mousePoint.x = Ints.constrainToRange(mousePoint.x, 0, Math.max(0, realDimension.width - movedOverlay.getBounds().width));
mousePoint.y = Ints.constrainToRange(mousePoint.y, 0, Math.max(0, realDimension.height - movedOverlay.getBounds().height));
mousePoint.x = MiscUtils.clamp(mousePoint.x, 0, Math.max(0, realDimension.width - movedOverlay.getBounds().width));
mousePoint.y = MiscUtils.clamp(mousePoint.y, 0, Math.max(0, realDimension.height - movedOverlay.getBounds().height));
movedOverlay.setPreferredPosition(null);
movedOverlay.setPreferredLocation(mousePoint);
mouseEvent.consume();

View File

@@ -24,7 +24,6 @@
*/
package net.runelite.client.util;
import com.google.common.primitives.Ints;
import java.awt.Color;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
@@ -171,7 +170,7 @@ public class ColorUtil
*/
public static int constrainValue(int value)
{
return Ints.constrainToRange(value, MIN_RGB_VALUE, MAX_RGB_VALUE);
return MiscUtils.clamp(value, MIN_RGB_VALUE, MAX_RGB_VALUE);
}
/**