Merge remote-tracking branch 'upstream/master'
This commit is contained in:
@@ -38,7 +38,7 @@ object ProjectVersions {
|
||||
object Plugins {
|
||||
val grgitPlugin = "org.ajoberstar:grgit:2.3.0"
|
||||
val versionsPlugin = "com.github.ben-manes:gradle-versions-plugin:0.27.0"
|
||||
val injectorPlugin = "com.openosrs:injector-plugin:1.0.0"
|
||||
val injectorPlugin = "com.openosrs:injector-plugin:1.0.2"
|
||||
val testLogger = Pair("com.adarshr.test-logger", "2.0.0")
|
||||
val versions = Pair("com.github.ben-manes.versions", "0.27.0")
|
||||
val buildScan = Pair("com.gradle.build-scan", "3.0")
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
|
||||
* 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.mapping;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(
|
||||
{
|
||||
ElementType.FIELD, ElementType.METHOD, ElementType.TYPE
|
||||
})
|
||||
public @interface ObfuscatedName
|
||||
{
|
||||
String value();
|
||||
}
|
||||
@@ -3,7 +3,6 @@ package net.runelite.client.plugins.deathindicator;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -22,7 +21,6 @@ public class Bones
|
||||
private static final String BONES_PREFIX = "bones_";
|
||||
|
||||
private ImmutableMap<Integer, Map<WorldPoint, List<Bone>>> map;
|
||||
private boolean changed = false;
|
||||
|
||||
void init(Client client, ConfigManager configManager)
|
||||
{
|
||||
@@ -31,14 +29,14 @@ public class Bones
|
||||
Bone[][] bones = getBones(configManager, regions);
|
||||
if (log.isDebugEnabled())
|
||||
{
|
||||
log.debug("Regions are now {}", Arrays.toString(regions));
|
||||
log.trace("Regions are now {}", Arrays.toString(regions));
|
||||
|
||||
int n = 0;
|
||||
for (Bone[] ar : bones)
|
||||
{
|
||||
n += ar.length;
|
||||
}
|
||||
log.debug("Loaded {} Bones", n);
|
||||
log.debug("Loaded {} Bones", n);
|
||||
}
|
||||
|
||||
initMap(regions, bones);
|
||||
@@ -81,7 +79,7 @@ public class Bones
|
||||
Bone[] boneA = bones[i];
|
||||
if (boneA.length == 0)
|
||||
{
|
||||
builder.put(region, Collections.EMPTY_MAP);
|
||||
builder.put(region, new HashMap<>());
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -103,35 +101,29 @@ public class Bones
|
||||
this.forEach(bone -> bone.addToScene(scene));
|
||||
}
|
||||
|
||||
void save(ConfigManager configManager)
|
||||
void save(ConfigManager configManager, int region)
|
||||
{
|
||||
if (this.map == null || !changed)
|
||||
final Map<WorldPoint, List<Bone>> regionBones = this.map.get(region);
|
||||
if (regionBones == null)
|
||||
{
|
||||
this.changed = false;
|
||||
return;
|
||||
}
|
||||
|
||||
for (Map.Entry<Integer, Map<WorldPoint, List<Bone>>> entry : this.map.entrySet())
|
||||
final String key = BONES_PREFIX + region;
|
||||
|
||||
if (regionBones.size() == 0)
|
||||
{
|
||||
final String key = BONES_PREFIX + entry.getKey();
|
||||
final Map<WorldPoint, List<Bone>> map = entry.getValue();
|
||||
if (map.size() == 0)
|
||||
{
|
||||
configManager.unsetConfiguration(CONFIG_GROUP, key);
|
||||
continue;
|
||||
}
|
||||
|
||||
List<Bone> list = new ArrayList<>(map.values().size());
|
||||
for (List<Bone> lb : map.values())
|
||||
{
|
||||
list.addAll(lb);
|
||||
}
|
||||
|
||||
String val = GSON.toJson(list.toArray(new Bone[0]));
|
||||
configManager.setConfiguration(CONFIG_GROUP, key, val);
|
||||
configManager.unsetConfiguration(CONFIG_GROUP, key);
|
||||
}
|
||||
|
||||
this.changed = false;
|
||||
List<Bone> list = new ArrayList<>(regionBones.values().size());
|
||||
for (List<Bone> lb : regionBones.values())
|
||||
{
|
||||
list.addAll(lb);
|
||||
}
|
||||
|
||||
String val = GSON.toJson(list.toArray(new Bone[0]));
|
||||
configManager.setConfiguration(CONFIG_GROUP, key, val);
|
||||
}
|
||||
|
||||
public boolean add(Bone bone)
|
||||
@@ -141,7 +133,6 @@ public class Bones
|
||||
return false;
|
||||
}
|
||||
|
||||
this.changed = true;
|
||||
final int region = bone.getLoc().getRegionID();
|
||||
final Map<WorldPoint, List<Bone>> map = this.map.get(region);
|
||||
final List<Bone> list = map.computeIfAbsent(bone.getLoc(), wp -> new ArrayList<>());
|
||||
@@ -151,7 +142,6 @@ public class Bones
|
||||
|
||||
public void remove(Bone bone)
|
||||
{
|
||||
this.changed = true;
|
||||
final int region = bone.getLoc().getRegionID();
|
||||
final Map<WorldPoint, List<Bone>> map = this.map.get(region);
|
||||
final List<Bone> list = map.get(bone.getLoc());
|
||||
|
||||
@@ -182,7 +182,6 @@ public class DeathIndicatorPlugin extends Plugin
|
||||
worldMapPointManager.removeIf(DeathWorldMapPoint.class::isInstance);
|
||||
|
||||
clientThread.invokeLater(this::clearBones);
|
||||
saveBones();
|
||||
}
|
||||
|
||||
private void initBones()
|
||||
@@ -190,11 +189,6 @@ public class DeathIndicatorPlugin extends Plugin
|
||||
bones.init(client, configManager);
|
||||
}
|
||||
|
||||
private void saveBones()
|
||||
{
|
||||
bones.save(configManager);
|
||||
}
|
||||
|
||||
private void clearBones()
|
||||
{
|
||||
bones.clear(client.getScene());
|
||||
@@ -236,12 +230,16 @@ public class DeathIndicatorPlugin extends Plugin
|
||||
|
||||
private void onPlayerDeath(PlayerDeath death)
|
||||
{
|
||||
Player p = death.getPlayer();
|
||||
newBoneFor(death.getPlayer());
|
||||
}
|
||||
|
||||
private void newBoneFor(Player player)
|
||||
{
|
||||
Bone b = new Bone();
|
||||
|
||||
b.setName(Text.sanitize(p.getName()));
|
||||
b.setName(Text.sanitize(player.getName()));
|
||||
b.setTime(Instant.now());
|
||||
b.setLoc(p.getWorldLocation());
|
||||
b.setLoc(player.getWorldLocation());
|
||||
|
||||
while (!bones.add(b))
|
||||
{
|
||||
@@ -249,6 +247,7 @@ public class DeathIndicatorPlugin extends Plugin
|
||||
}
|
||||
|
||||
b.addToScene(client.getScene());
|
||||
bones.save(configManager, b.getLoc().getRegionID());
|
||||
}
|
||||
|
||||
private void onMenuEntryAdded(MenuEntryAdded event)
|
||||
@@ -309,7 +308,13 @@ public class DeathIndicatorPlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
lastDeath = client.getLocalPlayer().getWorldLocation();
|
||||
Player lp = client.getLocalPlayer();
|
||||
if (config.permaBones())
|
||||
{
|
||||
newBoneFor(lp);
|
||||
}
|
||||
|
||||
lastDeath = lp.getWorldLocation();
|
||||
lastDeathWorld = client.getWorld();
|
||||
lastDeathTime = Instant.now();
|
||||
}
|
||||
@@ -400,7 +405,6 @@ public class DeathIndicatorPlugin extends Plugin
|
||||
if (client.getGameState() == GameState.LOGGED_IN)
|
||||
{
|
||||
clientThread.invokeLater(this::clearBones);
|
||||
saveBones();
|
||||
}
|
||||
}
|
||||
return;
|
||||
@@ -438,7 +442,6 @@ public class DeathIndicatorPlugin extends Plugin
|
||||
{
|
||||
case LOADING:
|
||||
clearBones();
|
||||
saveBones();
|
||||
break;
|
||||
case LOGGED_IN:
|
||||
if (config.permaBones())
|
||||
|
||||
@@ -180,14 +180,14 @@ public class PlayerIndicatorsOverlay extends Overlay
|
||||
textLocation.getY() - height),
|
||||
ImageUtil.resizeImage(agilityIcon, height, height));
|
||||
}
|
||||
else if (level >= plugin.getAgilitySecondThreshold())
|
||||
if (level >= plugin.getAgilitySecondThreshold())
|
||||
{
|
||||
OverlayUtil.renderImageLocation(graphics,
|
||||
new Point(textLocation.getX() + agilityIcon.getWidth() + width,
|
||||
textLocation.getY() - height),
|
||||
ImageUtil.resizeImage(agilityIcon, height, height));
|
||||
}
|
||||
else if (level < plugin.getAgilityFirstThreshold())
|
||||
if (level < plugin.getAgilityFirstThreshold())
|
||||
{
|
||||
OverlayUtil.renderImageLocation(graphics,
|
||||
new Point(textLocation.getX() + 5 + width,
|
||||
|
||||
@@ -513,6 +513,25 @@ public class SuppliesTrackerPlugin extends Plugin
|
||||
|
||||
private void onMenuOptionClicked(final MenuOptionClicked event)
|
||||
{
|
||||
// Fix for house pool
|
||||
switch (event.getMenuOpcode())
|
||||
{
|
||||
case ITEM_FIRST_OPTION:
|
||||
case ITEM_SECOND_OPTION:
|
||||
case ITEM_THIRD_OPTION:
|
||||
case ITEM_FOURTH_OPTION:
|
||||
case ITEM_FIFTH_OPTION:
|
||||
case EXAMINE_ITEM_BANK_EQ:
|
||||
case WIDGET_FIRST_OPTION:
|
||||
case WIDGET_SECOND_OPTION:
|
||||
case WIDGET_THIRD_OPTION:
|
||||
case WIDGET_FOURTH_OPTION:
|
||||
case WIDGET_FIFTH_OPTION:
|
||||
case WIDGET_DEFAULT:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
// Uses stacks to push/pop for tick eating
|
||||
// Create pattern to find eat/drink at beginning
|
||||
Pattern eatPattern = Pattern.compile(EAT_PATTERN);
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Copyright (c) 2019, winterdaze
|
||||
* 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.bosstimetracker;
|
||||
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBox;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.Color;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
public class BossTimeTracker extends InfoBox
|
||||
{
|
||||
private final Instant startTime;
|
||||
private LocalTime time;
|
||||
private Instant lastTime;
|
||||
|
||||
public BossTimeTracker(BufferedImage image, BossTimeTrackerPlugin plugin, Instant startTime, Instant lastTime)
|
||||
{
|
||||
super(image, plugin);
|
||||
this.startTime = startTime;
|
||||
this.lastTime = lastTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText()
|
||||
{
|
||||
if (startTime == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
if (lastTime == null)
|
||||
{
|
||||
Duration elapsed = Duration.between(startTime, Instant.now());
|
||||
time = LocalTime.ofSecondOfDay(elapsed.getSeconds());
|
||||
}
|
||||
else
|
||||
{
|
||||
Duration elapsed = Duration.between(startTime, lastTime);
|
||||
time = LocalTime.ofSecondOfDay(elapsed.getSeconds());
|
||||
}
|
||||
|
||||
if (time.getHour() > 0)
|
||||
{
|
||||
return time.format(DateTimeFormatter.ofPattern("HH:mm"));
|
||||
}
|
||||
return time.format(DateTimeFormatter.ofPattern("mm:ss"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Color getTextColor()
|
||||
{
|
||||
return Color.WHITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Elapsed time: ");
|
||||
builder.append(time.format(DateTimeFormatter.ofPattern("HH:mm:ss")));
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
* Copyright (c) 2019, winterdaze
|
||||
* 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.bosstimetracker;
|
||||
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.util.Text;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.PluginType;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBoxManager;
|
||||
import net.runelite.client.eventbus.EventBus;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Arrays;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static net.runelite.api.ItemID.FIRE_CAPE;
|
||||
import static net.runelite.api.ItemID.INFERNAL_CAPE;
|
||||
|
||||
@PluginDescriptor(
|
||||
name = "Boss Time Tracker",
|
||||
description = "Display elapsed time in the Fight Caves and Inferno",
|
||||
tags = {"inferno", "fight", "caves", "cape", "timer", "tzhaar", "pvm"},
|
||||
type = PluginType.PVM,
|
||||
enabledByDefault = false
|
||||
)
|
||||
public class BossTimeTrackerPlugin extends Plugin
|
||||
{
|
||||
private static final Pattern WAVE_MESSAGE = Pattern.compile("Wave: (\\d+)");
|
||||
private static final String DEFEATED_MESSAGE = "You have been defeated!";
|
||||
private static final Pattern COMPLETE_MESSAGE = Pattern.compile("Your (TzTok-Jad|TzKal-Zuk) kill count is:");
|
||||
private static final Pattern PAUSED_MESSAGE = Pattern.compile("The (Inferno|Fight Cave) has been paused. You may now log out.");
|
||||
private static final String CONFIG_GROUP = "Boss Time Tracker";
|
||||
private static final String CONFIG_TIME = "time";
|
||||
private static final String CONFIG_STARTED = "started";
|
||||
private static final String CONFIG_LASTTIME = "lasttime";
|
||||
|
||||
@Inject
|
||||
private InfoBoxManager infoBoxManager;
|
||||
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
@Inject
|
||||
private ItemManager itemManager;
|
||||
|
||||
@Inject
|
||||
private ConfigManager configManager;
|
||||
|
||||
@Inject
|
||||
private EventBus eventBus;
|
||||
|
||||
@Getter
|
||||
private BossTimeTracker timer;
|
||||
|
||||
private Instant startTime;
|
||||
private Instant lastTime;
|
||||
private Boolean started = false;
|
||||
private boolean loggingIn;
|
||||
|
||||
@Override
|
||||
public void startUp()
|
||||
{
|
||||
addSubscriptions();
|
||||
}
|
||||
|
||||
public void onGameStateChanged(GameStateChanged event)
|
||||
{
|
||||
switch (event.getGameState())
|
||||
{
|
||||
case LOGGED_IN:
|
||||
if (loggingIn)
|
||||
{
|
||||
loggingIn = false;
|
||||
loadConfig();
|
||||
resetConfig();
|
||||
}
|
||||
break;
|
||||
case LOGGING_IN:
|
||||
loggingIn = true;
|
||||
break;
|
||||
case LOADING:
|
||||
if (!loggingIn)
|
||||
{
|
||||
updateInfoBoxState();
|
||||
}
|
||||
break;
|
||||
case HOPPING:
|
||||
loggingIn = true;
|
||||
case LOGIN_SCREEN:
|
||||
removeTimer();
|
||||
saveConfig();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void onChatMessage(ChatMessage event)
|
||||
{
|
||||
if (event.getType() != ChatMessageType.GAMEMESSAGE && event.getType() != ChatMessageType.SPAM)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String message = Text.removeTags(event.getMessage());
|
||||
Matcher matcher = COMPLETE_MESSAGE.matcher(message);
|
||||
|
||||
if (message.contains(DEFEATED_MESSAGE) || matcher.matches())
|
||||
{
|
||||
removeTimer();
|
||||
resetConfig();
|
||||
resetVars();
|
||||
return;
|
||||
}
|
||||
|
||||
Instant now = Instant.now();
|
||||
matcher = PAUSED_MESSAGE.matcher(message);
|
||||
if (matcher.matches())
|
||||
{
|
||||
lastTime = now;
|
||||
createTimer(startTime, now);
|
||||
return;
|
||||
}
|
||||
|
||||
matcher = WAVE_MESSAGE.matcher(message);
|
||||
if (!matcher.matches())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!started)
|
||||
{
|
||||
int wave = Integer.parseInt(matcher.group(1));
|
||||
if (wave != 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
started = true;
|
||||
startTime = now;
|
||||
}
|
||||
else if (lastTime != null)
|
||||
{
|
||||
startTime = startTime.plus(Duration.between(startTime, now)).minus(Duration.between(startTime, lastTime));
|
||||
lastTime = null;
|
||||
}
|
||||
|
||||
createTimer(startTime, lastTime);
|
||||
}
|
||||
|
||||
private void updateInfoBoxState()
|
||||
{
|
||||
if (timer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!checkInFightCaves() && !checkInInferno())
|
||||
{
|
||||
removeTimer();
|
||||
resetConfig();
|
||||
resetVars();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkInFightCaves()
|
||||
{
|
||||
return client.getMapRegions() != null && Arrays.stream(client.getMapRegions())
|
||||
.filter(x -> x == 9551)
|
||||
.toArray().length > 0;
|
||||
}
|
||||
|
||||
private boolean checkInInferno()
|
||||
{
|
||||
return client.getMapRegions() != null && Arrays.stream(client.getMapRegions())
|
||||
.filter(x -> x == 9043)
|
||||
.toArray().length > 0;
|
||||
}
|
||||
|
||||
private void resetVars()
|
||||
{
|
||||
startTime = null;
|
||||
lastTime = null;
|
||||
started = false;
|
||||
}
|
||||
|
||||
private void removeTimer()
|
||||
{
|
||||
infoBoxManager.removeInfoBox(timer);
|
||||
timer = null;
|
||||
}
|
||||
|
||||
private void createTimer(Instant startTime, Instant lastTime)
|
||||
{
|
||||
if (timer != null)
|
||||
{
|
||||
infoBoxManager.removeInfoBox(timer);
|
||||
}
|
||||
|
||||
if (checkInFightCaves())
|
||||
{
|
||||
timer = new BossTimeTracker(itemManager.getImage(FIRE_CAPE), this, startTime, lastTime);
|
||||
infoBoxManager.addInfoBox(timer);
|
||||
}
|
||||
else if (checkInInferno())
|
||||
{
|
||||
timer = new BossTimeTracker(itemManager.getImage(INFERNAL_CAPE), this, startTime, lastTime);
|
||||
infoBoxManager.addInfoBox(timer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() throws Exception
|
||||
{
|
||||
eventBus.unregister(this);
|
||||
removeTimer();
|
||||
resetConfig();
|
||||
resetVars();
|
||||
}
|
||||
|
||||
private void addSubscriptions()
|
||||
{
|
||||
eventBus.subscribe(GameStateChanged.class, this, this::onGameStateChanged);
|
||||
eventBus.subscribe(ChatMessage.class, this, this::onChatMessage);
|
||||
}
|
||||
|
||||
private void loadConfig()
|
||||
{
|
||||
startTime = configManager.getConfiguration(CONFIG_GROUP, CONFIG_TIME, Instant.class);
|
||||
started = configManager.getConfiguration(CONFIG_GROUP, CONFIG_STARTED, Boolean.class);
|
||||
lastTime = configManager.getConfiguration(CONFIG_GROUP, CONFIG_LASTTIME, Instant.class);
|
||||
if (started == null)
|
||||
{
|
||||
started = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void resetConfig()
|
||||
{
|
||||
configManager.unsetConfiguration(CONFIG_GROUP, CONFIG_TIME);
|
||||
configManager.unsetConfiguration(CONFIG_GROUP, CONFIG_STARTED);
|
||||
configManager.unsetConfiguration(CONFIG_GROUP, CONFIG_LASTTIME);
|
||||
}
|
||||
|
||||
private void saveConfig()
|
||||
{
|
||||
if (startTime == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (lastTime == null)
|
||||
{
|
||||
lastTime = Instant.now();
|
||||
}
|
||||
|
||||
configManager.setConfiguration(CONFIG_GROUP, CONFIG_TIME, startTime);
|
||||
configManager.setConfiguration(CONFIG_GROUP, CONFIG_STARTED, started);
|
||||
configManager.setConfiguration(CONFIG_GROUP, CONFIG_LASTTIME, lastTime);
|
||||
resetVars();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user