Fixes protect item overlay in pvp worlds (#758)
* Updates whalewatchers to work with new worldtypes, fixes bug where the protect item overlay was not being enabled on PvP worlds Signed-off-by: PKLite <stonewall@pklite.xyz> * Make sure plugin stops displaying overlays for disabled config items Signed-off-by: PKLite <stonewall@pklite.xyz>
This commit is contained in:
@@ -1,16 +1,20 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2019. PKLite
|
||||
* Redistributions and modifications of this software are permitted as long as this notice remains in its original unmodified state at the top of this file.
|
||||
* If there are any questions comments, or feedback about this software, please direct all inquiries directly to the following authors:
|
||||
*
|
||||
* PKLite discord: https://discord.gg/Dp3HuFM
|
||||
* Written by PKLite(ST0NEWALL, others) <stonewall@stonewall@pklite.xyz>, 2019
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* * Copyright (c) 2019 RuneLitePlus
|
||||
* * Redistributions and modifications of this software are permitted as long as this notice remains in its original unmodified state at the top of this file.
|
||||
* * If there are any questions comments, or feedback about this software, please direct all inquiries directly to the file authors:
|
||||
* * ST0NEWALL#9112
|
||||
* * RuneLitePlus Discord: https://discord.gg/Q7wFtCe
|
||||
* * RuneLitePlus website: https://runelitepl.us
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.whalewatchers;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Objects;
|
||||
import javax.inject.Inject;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.Client;
|
||||
@@ -21,9 +25,9 @@ import net.runelite.api.Skill;
|
||||
import net.runelite.api.SkullIcon;
|
||||
import net.runelite.api.VarPlayer;
|
||||
import net.runelite.api.Varbits;
|
||||
import static net.runelite.api.WorldType.HIGH_RISK;
|
||||
import static net.runelite.api.WorldType.PVP;
|
||||
import net.runelite.api.WorldType;
|
||||
import static net.runelite.api.WorldType.isPvpWorld;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.HitsplatApplied;
|
||||
import net.runelite.api.events.ItemContainerChanged;
|
||||
@@ -50,7 +54,9 @@ import org.apache.commons.lang3.ObjectUtils;
|
||||
public class WhaleWatchersPlugin extends Plugin
|
||||
{
|
||||
|
||||
public boolean enableOverlay = false;
|
||||
private static final String CONFIG_GROUP_NAME = "WhaleWatchers";
|
||||
|
||||
public boolean protectItemOverlay = false;
|
||||
public int damageDone = 0;
|
||||
public int damageTaken = 0;
|
||||
public boolean inCombat = false;
|
||||
@@ -83,11 +89,7 @@ public class WhaleWatchersPlugin extends Plugin
|
||||
@Subscribe
|
||||
public void onOverlayMenuClicked(OverlayMenuClicked event)
|
||||
{
|
||||
if (!event.getOverlay().equals(overlay))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
if (event.getOverlay().equals(overlay))
|
||||
{
|
||||
if (event.getEntry().getOption().equals("Reset"))
|
||||
{
|
||||
@@ -116,6 +118,28 @@ public class WhaleWatchersPlugin extends Plugin
|
||||
resetDamageCounter();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onConfigChanged(ConfigChanged event)
|
||||
{
|
||||
if (!event.getGroup().equals(CONFIG_GROUP_NAME))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!config.protectItemWarning())
|
||||
{
|
||||
protectItemOverlay = false;
|
||||
}
|
||||
if (!config.gloryWarning())
|
||||
{
|
||||
displayGloryOverlay = false;
|
||||
}
|
||||
if (!config.smiteableWarning())
|
||||
{
|
||||
displaySmiteOverlay = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Subscribe
|
||||
public void onHitsplatApplied(HitsplatApplied event)
|
||||
@@ -186,28 +210,32 @@ public class WhaleWatchersPlugin extends Plugin
|
||||
{
|
||||
try
|
||||
{
|
||||
if (client.getLocalPlayer().getSkullIcon() == (SkullIcon.SKULL))
|
||||
final SkullIcon skullIcon = Objects.requireNonNull(client.getLocalPlayer().getSkullIcon());
|
||||
final EnumSet worldTypes = client.getWorldType();
|
||||
if (WorldType.isHighRiskWorld(worldTypes))
|
||||
{
|
||||
if (client.getVar(Varbits.PRAYER_PROTECT_ITEM) == 0 && client.getVar(Varbits.IN_WILDERNESS) == 1 ||
|
||||
client.getWorldType().contains(PVP))
|
||||
{
|
||||
enableOverlay = true;
|
||||
}
|
||||
if (client.getVar(Varbits.PRAYER_PROTECT_ITEM) == 1 || client.getVar(Varbits.IN_WILDERNESS) == 0 ||
|
||||
client.getWorldType().contains(HIGH_RISK) || client.getWorld() == 365)
|
||||
{
|
||||
enableOverlay = false;
|
||||
}
|
||||
protectItemOverlay = false;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if (skullIcon.equals(SkullIcon.SKULL))
|
||||
{
|
||||
enableOverlay = false;
|
||||
if (WorldType.isPvpWorld(worldTypes) || WorldType.isDeadmanWorld(worldTypes) ||
|
||||
client.getVar(Varbits.IN_WILDERNESS) == 1)
|
||||
{
|
||||
protectItemOverlay = client.getRealSkillLevel(Skill.PRAYER) > 25 &&
|
||||
client.getVar(Varbits.PRAYER_PROTECT_ITEM) == 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
protectItemOverlay = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NullPointerException e)
|
||||
{
|
||||
|
||||
// local player isn't skulled
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
/*******************************************************************************
|
||||
* Copyright (c) 2019. PKLite
|
||||
* Redistributions and modifications of this software are permitted as long as this notice remains in its original unmodified state at the top of this file.
|
||||
* If there are any questions comments, or feedback about this software, please direct all inquiries directly to the following authors:
|
||||
*
|
||||
* PKLite discord: https://discord.gg/Dp3HuFM
|
||||
* Written by PKLite(ST0NEWALL, others) <stonewall@stonewall@pklite.xyz>, 2019
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/*
|
||||
* ******************************************************************************
|
||||
* * Copyright (c) 2019 RuneLitePlus
|
||||
* * Redistributions and modifications of this software are permitted as long as this notice remains in its original unmodified state at the top of this file.
|
||||
* * If there are any questions comments, or feedback about this software, please direct all inquiries directly to the file authors:
|
||||
* * ST0NEWALL#9112
|
||||
* * RuneLitePlus Discord: https://discord.gg/Q7wFtCe
|
||||
* * RuneLitePlus website: https://runelitepl.us
|
||||
* *****************************************************************************
|
||||
*/
|
||||
|
||||
package net.runelite.client.plugins.whalewatchers;
|
||||
|
||||
@@ -49,7 +51,7 @@ public class WhaleWatchersProtOverlay extends Overlay
|
||||
@Override
|
||||
public Dimension render(Graphics2D graphics)
|
||||
{
|
||||
if (plugin.enableOverlay && config.protectItemWarning())
|
||||
if (plugin.protectItemOverlay && config.protectItemWarning())
|
||||
{
|
||||
Rectangle rectangle = new Rectangle();
|
||||
rectangle.setBounds(client.getCanvas().getBounds());
|
||||
|
||||
Reference in New Issue
Block a user