Merge pull request #288 from runelite-extended/raids
Update to Raids, fixes timer issue aswell.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Kamiel
|
||||
* Copyright (c) 2019, ganom <https://github.com/Ganom>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -35,8 +36,8 @@ public interface RaidsConfig extends Config
|
||||
@ConfigItem(
|
||||
position = 0,
|
||||
keyName = "raidsTimer",
|
||||
name = "Level time tooltip",
|
||||
description = "Displays your level times as a tooltip on the points overlay"
|
||||
name = "Display elapsed raid time",
|
||||
description = "Display elapsed raid time"
|
||||
)
|
||||
default boolean raidsTimer()
|
||||
{
|
||||
@@ -168,8 +169,7 @@ public interface RaidsConfig extends Config
|
||||
position = 12,
|
||||
keyName = "enhanceScouterTitle",
|
||||
name = "Enhance scouter title",
|
||||
description = "Adds #combat and good puzzles to scouter title",
|
||||
hidden = true
|
||||
description = "Adds #combat and good puzzles to scouter title"
|
||||
)
|
||||
default boolean enhanceScouterTitle()
|
||||
{
|
||||
@@ -288,6 +288,28 @@ public interface RaidsConfig extends Config
|
||||
|
||||
@ConfigItem(
|
||||
position = 25,
|
||||
keyName = "hideVanguards",
|
||||
name = "Hide Vanguard raids",
|
||||
description = "Completely hides raids with Vanguards"
|
||||
)
|
||||
default boolean hideVanguards()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 26,
|
||||
keyName = "hideUnknownCombat",
|
||||
name = "Hide Unknown combat raids",
|
||||
description = "Completely hides raids with Unknown combat"
|
||||
)
|
||||
default boolean hideUnknownCombat()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 27,
|
||||
keyName = "layoutMessage",
|
||||
name = "Send raid layout message when entering raid",
|
||||
description = "Sends game message with raid layout on entering new raid"
|
||||
@@ -298,7 +320,7 @@ public interface RaidsConfig extends Config
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
position = 26,
|
||||
position = 28,
|
||||
keyName = "displayFloorBreak",
|
||||
name = "Layout floor break",
|
||||
description = "Displays floor break in layout"
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Kamiel
|
||||
* Copyright (c) 2019, ganom <https://github.com/Ganom>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -151,7 +152,10 @@ public class RaidsOverlay extends Overlay
|
||||
boolean iceDemon = false;
|
||||
boolean tightrope = false;
|
||||
boolean thieving = false;
|
||||
boolean vanguards = false;
|
||||
boolean unknownCombat = false;
|
||||
String puzzles = "";
|
||||
String roomName = "";
|
||||
if (config.enhanceScouterTitle() || config.scavsBeforeIce() || sharable)
|
||||
{
|
||||
for (Room layoutRoom : plugin.getRaid().getLayout().getRooms())
|
||||
@@ -168,9 +172,19 @@ public class RaidsOverlay extends Overlay
|
||||
{
|
||||
case COMBAT:
|
||||
combatCount++;
|
||||
roomName = room.getBoss().getName();
|
||||
switch (RaidRoom.Boss.fromString(roomName))
|
||||
{
|
||||
case VANGUARDS:
|
||||
vanguards = true;
|
||||
break;
|
||||
case UNKNOWN:
|
||||
unknownCombat = true;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case PUZZLE:
|
||||
String roomName = room.getPuzzle().getName();
|
||||
roomName = room.getPuzzle().getName();
|
||||
switch (RaidRoom.Puzzle.fromString(roomName))
|
||||
{
|
||||
case CRABS:
|
||||
@@ -198,10 +212,11 @@ public class RaidsOverlay extends Overlay
|
||||
{
|
||||
puzzles = crabs ? "cr" : iceDemon ? "ri" : thieving ? "tr" : "?r";
|
||||
}
|
||||
else if (config.hideRopeless())
|
||||
|
||||
if ((config.hideVanguards() && vanguards) || (config.hideRopeless() && !tightrope) || (config.hideUnknownCombat() && unknownCombat))
|
||||
{
|
||||
panelComponent.getChildren().add(TitleComponent.builder()
|
||||
.text("No Tightrope!")
|
||||
.text("Bad Raid!")
|
||||
.color(Color.RED)
|
||||
.build());
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Kamiel
|
||||
* Copyright (c) 2019, ganom <https://github.com/Ganom>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -28,6 +29,7 @@ import com.google.inject.Binder;
|
||||
import com.google.inject.Provides;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@@ -48,6 +50,7 @@ import net.runelite.api.NullObjectID;
|
||||
import static net.runelite.api.Perspective.SCENE_SIZE;
|
||||
import net.runelite.api.Point;
|
||||
import net.runelite.api.SpriteID;
|
||||
import static net.runelite.api.SpriteID.TAB_QUESTS_BROWN_RAIDING_PARTY;
|
||||
import net.runelite.api.Tile;
|
||||
import net.runelite.api.VarPlayer;
|
||||
import net.runelite.api.Varbits;
|
||||
@@ -96,6 +99,9 @@ import org.apache.commons.lang3.StringUtils;
|
||||
public class RaidsPlugin extends Plugin
|
||||
{
|
||||
private static final int LOBBY_PLANE = 3;
|
||||
private static final String RAID_START_MESSAGE = "The raid has begun!";
|
||||
private static final String LEVEL_COMPLETE_MESSAGE = "level complete!";
|
||||
private static final String RAID_COMPLETE_MESSAGE = "Congratulations - your raid is complete!";
|
||||
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("###.##");
|
||||
static final DecimalFormat POINTS_FORMAT = new DecimalFormat("#,###");
|
||||
private static final String SPLIT_REGEX = "\\s*,\\s*";
|
||||
@@ -181,6 +187,7 @@ public class RaidsPlugin extends Plugin
|
||||
private String tooltip;
|
||||
public boolean canShow;
|
||||
private NavigationButton navButton;
|
||||
private RaidsTimer timer;
|
||||
|
||||
@Provides
|
||||
RaidsConfig provideConfig(ConfigManager configManager)
|
||||
@@ -220,9 +227,11 @@ public class RaidsPlugin extends Plugin
|
||||
overlayManager.remove(overlay);
|
||||
overlayManager.remove(pointsOverlay);
|
||||
clientToolbar.removeNavigation(navButton);
|
||||
infoBoxManager.removeInfoBox(timer);
|
||||
inRaidChambers = false;
|
||||
widgetOverlay = null;
|
||||
raid = null;
|
||||
timer = null;
|
||||
|
||||
final Widget widget = client.getWidget(WidgetInfo.RAIDS_POINTS_INFOBOX);
|
||||
if (widget != null)
|
||||
@@ -240,6 +249,12 @@ public class RaidsPlugin extends Plugin
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.getKey().equals("raidsTimer"))
|
||||
{
|
||||
updateInfoBoxState();
|
||||
return;
|
||||
}
|
||||
|
||||
updateLists();
|
||||
clientThread.invokeLater(() -> checkRaidPresence(true));
|
||||
}
|
||||
@@ -274,26 +289,26 @@ public class RaidsPlugin extends Plugin
|
||||
String message = Text.removeTags(event.getMessage());
|
||||
Matcher matcher;
|
||||
|
||||
matcher = LEVEL_COMPLETE_REGEX.matcher(message);
|
||||
if (matcher.find())
|
||||
if (config.raidsTimer() && message.startsWith(RAID_START_MESSAGE))
|
||||
{
|
||||
String floor = matcher.group(1);
|
||||
int time = timeToSeconds(matcher.group(2));
|
||||
if (floor.equals("Upper"))
|
||||
timer = new RaidsTimer(spriteManager.getSprite(TAB_QUESTS_BROWN_RAIDING_PARTY, 0), this, Instant.now());
|
||||
infoBoxManager.addInfoBox(timer);
|
||||
}
|
||||
|
||||
if (timer != null && message.contains(LEVEL_COMPLETE_MESSAGE))
|
||||
{
|
||||
timer.timeFloor();
|
||||
}
|
||||
|
||||
if (message.startsWith(RAID_COMPLETE_MESSAGE))
|
||||
{
|
||||
if (timer != null)
|
||||
{
|
||||
upperTime = time;
|
||||
}
|
||||
else if (floor.equals("Middle"))
|
||||
{
|
||||
middleTime = time;
|
||||
}
|
||||
else if (floor.equals("Lower"))
|
||||
{
|
||||
lowerTime = time;
|
||||
timer.timeOlm();
|
||||
timer.setStopped(true);
|
||||
}
|
||||
updateTooltip();
|
||||
}
|
||||
|
||||
matcher = RAID_COMPLETE_REGEX.matcher(message);
|
||||
if (matcher.find())
|
||||
{
|
||||
@@ -410,6 +425,7 @@ public class RaidsPlugin extends Plugin
|
||||
if (force || inRaidChambers != setting)
|
||||
{
|
||||
inRaidChambers = setting;
|
||||
updateInfoBoxState();
|
||||
|
||||
if (inRaidChambers)
|
||||
{
|
||||
@@ -434,14 +450,9 @@ public class RaidsPlugin extends Plugin
|
||||
overlay.setScoutOverlayShown(true);
|
||||
sendRaidLayoutMessage();
|
||||
}
|
||||
else
|
||||
else if (!config.scoutOverlayAtBank())
|
||||
{
|
||||
if (!config.scoutOverlayAtBank())
|
||||
{
|
||||
overlay.setScoutOverlayShown(false);
|
||||
}
|
||||
|
||||
reset();
|
||||
overlay.setScoutOverlayShown(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -474,6 +485,30 @@ public class RaidsPlugin extends Plugin
|
||||
.build());
|
||||
}
|
||||
|
||||
private void updateInfoBoxState()
|
||||
{
|
||||
if (timer == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (inRaidChambers && config.raidsTimer())
|
||||
{
|
||||
if (!infoBoxManager.getInfoBoxes().contains(timer))
|
||||
{
|
||||
infoBoxManager.addInfoBox(timer);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
infoBoxManager.removeInfoBox(timer);
|
||||
}
|
||||
|
||||
if (!inRaidChambers)
|
||||
{
|
||||
timer = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateLists()
|
||||
{
|
||||
@@ -817,7 +852,7 @@ public class RaidsPlugin extends Plugin
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if (seconds >= 3600)
|
||||
{
|
||||
builder.append((int) Math.floor(seconds / 3600)).append(";");
|
||||
builder.append((int) Math.floor(seconds / 3600) + ";");
|
||||
}
|
||||
seconds %= 3600;
|
||||
if (builder.toString().equals(""))
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Kamiel
|
||||
* 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.raids;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import lombok.Setter;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.ui.overlay.infobox.InfoBox;
|
||||
|
||||
public class RaidsTimer extends InfoBox
|
||||
{
|
||||
private final Instant startTime;
|
||||
private Instant floorTime;
|
||||
private LocalTime time;
|
||||
private LocalTime firstFloorTime;
|
||||
private LocalTime secondFloorTime;
|
||||
private LocalTime thirdFloorTime;
|
||||
private LocalTime olmTime;
|
||||
|
||||
@Setter
|
||||
private boolean stopped;
|
||||
|
||||
public RaidsTimer(BufferedImage image, Plugin plugin, Instant startTime)
|
||||
{
|
||||
super(image, plugin);
|
||||
this.startTime = startTime;
|
||||
floorTime = startTime;
|
||||
stopped = false;
|
||||
}
|
||||
|
||||
public void timeFloor()
|
||||
{
|
||||
Duration elapsed = Duration.between(floorTime, Instant.now());
|
||||
|
||||
if (firstFloorTime == null)
|
||||
{
|
||||
firstFloorTime = LocalTime.ofSecondOfDay(elapsed.getSeconds());
|
||||
}
|
||||
else if (secondFloorTime == null)
|
||||
{
|
||||
secondFloorTime = LocalTime.ofSecondOfDay(elapsed.getSeconds());
|
||||
}
|
||||
else if (thirdFloorTime == null)
|
||||
{
|
||||
thirdFloorTime = LocalTime.ofSecondOfDay(elapsed.getSeconds());
|
||||
}
|
||||
|
||||
floorTime = Instant.now();
|
||||
}
|
||||
|
||||
public void timeOlm()
|
||||
{
|
||||
Duration elapsed = Duration.between(floorTime, Instant.now());
|
||||
olmTime = LocalTime.ofSecondOfDay(elapsed.getSeconds());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getText()
|
||||
{
|
||||
if (startTime == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
if (!stopped)
|
||||
{
|
||||
Duration elapsed = Duration.between(startTime, Instant.now());
|
||||
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()
|
||||
{
|
||||
if (stopped)
|
||||
{
|
||||
return Color.GREEN;
|
||||
}
|
||||
|
||||
return Color.WHITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip()
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("Elapsed raid time: ");
|
||||
builder.append(time.format(DateTimeFormatter.ofPattern("HH:mm:ss")));
|
||||
|
||||
if (firstFloorTime != null)
|
||||
{
|
||||
builder.append("</br>First floor: ");
|
||||
builder.append(firstFloorTime.format(DateTimeFormatter.ofPattern("mm:ss")));
|
||||
}
|
||||
|
||||
if (secondFloorTime != null)
|
||||
{
|
||||
builder.append("</br>Second floor: ");
|
||||
builder.append(secondFloorTime.format(DateTimeFormatter.ofPattern("mm:ss")));
|
||||
}
|
||||
|
||||
if (thirdFloorTime != null)
|
||||
{
|
||||
builder.append("</br>Third floor: ");
|
||||
builder.append(thirdFloorTime.format(DateTimeFormatter.ofPattern("mm:ss")));
|
||||
}
|
||||
|
||||
if (olmTime != null)
|
||||
{
|
||||
builder.append("</br>Olm: ");
|
||||
builder.append(olmTime.format(DateTimeFormatter.ofPattern("mm:ss")));
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user