Merge pull request #1267 from Infinitay/update-kingdom-plugin
Kingdom of Misc - Only show when on Miscellania and check if quest completed
This commit is contained in:
@@ -295,6 +295,7 @@ public enum Varbits
|
||||
*/
|
||||
KINGDOM_FAVOR(72),
|
||||
KINGDOM_COFFER(74),
|
||||
THRONE_OF_MISCELLANIA_QUEST(359),
|
||||
|
||||
/**
|
||||
* Daily Tasks (Collection availability)
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Infinitay <https://github.com/Infinitay>
|
||||
* 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.kingdomofmiscellania;
|
||||
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup(
|
||||
keyName = "kingdom",
|
||||
name = "Kingdom of Miscellania",
|
||||
description = "Configuration for Kingdom of Miscellania plugin"
|
||||
)
|
||||
public interface KingdomConfig extends Config
|
||||
{
|
||||
@ConfigItem(
|
||||
keyName = "showOnlyInKingdom",
|
||||
name = "Show Only in Kingdom",
|
||||
description = "Configures whether or not to display kingdom information only when in kingdom",
|
||||
position = 1
|
||||
)
|
||||
default boolean showOnlyInKingdom()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "showWhenLow",
|
||||
name = "Show When Low Favor or Coffer",
|
||||
description = "Configures whether or not to display kingdom information when favor or coffer is low",
|
||||
position = 2
|
||||
)
|
||||
default boolean showWhenLow()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "favorLessThanValue",
|
||||
name = "Alert if favor % below",
|
||||
description = "Configures display kingdom information when favor less than value",
|
||||
position = 3
|
||||
)
|
||||
default int favorLessThanValue()
|
||||
{
|
||||
return 95;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "cofferLessThanValue",
|
||||
name = "Alert if coffer below",
|
||||
description = "Configures display kingdom information when coffer less than value",
|
||||
position = 4
|
||||
)
|
||||
default int cofferLessThanValue()
|
||||
{
|
||||
return 1000000;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,6 @@ package net.runelite.client.plugins.kingdomofmiscellania;
|
||||
|
||||
import com.google.common.eventbus.Subscribe;
|
||||
import com.google.common.primitives.Ints;
|
||||
import com.google.inject.Provides;
|
||||
import java.awt.image.BufferedImage;
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.inject.Inject;
|
||||
@@ -35,10 +34,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
import net.runelite.api.events.MapRegionChanged;
|
||||
import net.runelite.api.events.VarbitChanged;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
@@ -55,33 +52,15 @@ public class KingdomPlugin extends Plugin
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private KingdomConfig config;
|
||||
|
||||
@Inject
|
||||
private InfoBoxManager infoBoxManager;
|
||||
|
||||
@Getter
|
||||
private int favor = -1, coffer = -1;
|
||||
private int favor = 0, coffer = 0;
|
||||
|
||||
private KingdomCounter counter;
|
||||
private BufferedImage counterImage;
|
||||
|
||||
@Provides
|
||||
KingdomConfig provideConfig(ConfigManager configManager)
|
||||
{
|
||||
return configManager.getConfig(KingdomConfig.class);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onConfigChanged(ConfigChanged event)
|
||||
{
|
||||
if (event.getGroup().equals("kingdom") && client.getGameState() == GameState.LOGGED_IN)
|
||||
{
|
||||
processInfobox();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void startUp() throws Exception
|
||||
{
|
||||
@@ -113,23 +92,16 @@ public class KingdomPlugin extends Plugin
|
||||
|
||||
private void processInfobox()
|
||||
{
|
||||
if (client.getGameState() == GameState.LOGGED_IN)
|
||||
if (client.getGameState() == GameState.LOGGED_IN && hasCompletedQuest() && isInKingdom())
|
||||
{
|
||||
if (!config.showOnlyInKingdom() || isInKingdom())
|
||||
{
|
||||
addKingdomInfobox();
|
||||
}
|
||||
else if (config.showWhenLow() && (isFavorLow(config.favorLessThanValue()) || isCofferLow(config.cofferLessThanValue())))
|
||||
{
|
||||
addKingdomInfobox();
|
||||
}
|
||||
else
|
||||
{
|
||||
removeKingdomInfobox();
|
||||
}
|
||||
addKingdomInfobox();
|
||||
}
|
||||
else
|
||||
{
|
||||
removeKingdomInfobox();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addKingdomInfobox()
|
||||
{
|
||||
@@ -156,15 +128,9 @@ public class KingdomPlugin extends Plugin
|
||||
return Ints.indexOf(client.getMapRegions(), KINGDOM_REGION) >= 0;
|
||||
}
|
||||
|
||||
private boolean isFavorLow(int lessThanValue)
|
||||
private boolean hasCompletedQuest()
|
||||
{
|
||||
int i = getFavorPercent(favor);
|
||||
return i < lessThanValue;
|
||||
}
|
||||
|
||||
private boolean isCofferLow(int lessThanValue)
|
||||
{
|
||||
return coffer < lessThanValue;
|
||||
return client.getSetting(Varbits.THRONE_OF_MISCELLANIA_QUEST) == 1;
|
||||
}
|
||||
|
||||
static int getFavorPercent(int favor)
|
||||
|
||||
Reference in New Issue
Block a user