Merge pull request #693 from runelite-extended/inferno-and-fightcaves-fix
Inferno and fightcaves fix
This commit is contained in:
@@ -38,6 +38,7 @@ import net.runelite.client.ui.overlay.OverlayPosition;
|
|||||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||||
import net.runelite.client.ui.overlay.components.TitleComponent;
|
import net.runelite.client.ui.overlay.components.TitleComponent;
|
||||||
import net.runelite.client.ui.overlay.components.table.TableComponent;
|
import net.runelite.client.ui.overlay.components.table.TableComponent;
|
||||||
|
import net.runelite.client.ui.overlay.components.table.TableAlignment;
|
||||||
|
|
||||||
class WaveOverlay extends Overlay
|
class WaveOverlay extends Overlay
|
||||||
{
|
{
|
||||||
@@ -97,15 +98,20 @@ class WaveOverlay extends Overlay
|
|||||||
.color(HEADER_COLOR)
|
.color(HEADER_COLOR)
|
||||||
.build());
|
.build());
|
||||||
|
|
||||||
|
|
||||||
TableComponent tableComponent = new TableComponent();
|
TableComponent tableComponent = new TableComponent();
|
||||||
|
tableComponent.setColumnAlignments(TableAlignment.CENTER);
|
||||||
|
|
||||||
for (String line : buildWaveLines(waveContents))
|
for (String line : buildWaveLines(waveContents))
|
||||||
{
|
{
|
||||||
tableComponent.addRow(line);
|
tableComponent.addRow(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!tableComponent.isEmpty())
|
||||||
|
{
|
||||||
panelComponent.getChildren().add(tableComponent);
|
panelComponent.getChildren().add(tableComponent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private static Collection<String> buildWaveLines(final Map<WaveMonster, Integer> wave)
|
private static Collection<String> buildWaveLines(final Map<WaveMonster, Integer> wave)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ package net.runelite.client.plugins.inferno;
|
|||||||
import net.runelite.client.config.Config;
|
import net.runelite.client.config.Config;
|
||||||
import net.runelite.client.config.ConfigGroup;
|
import net.runelite.client.config.ConfigGroup;
|
||||||
import net.runelite.client.config.ConfigItem;
|
import net.runelite.client.config.ConfigItem;
|
||||||
|
import java.awt.Color;
|
||||||
|
|
||||||
@ConfigGroup("inferno")
|
@ConfigGroup("inferno")
|
||||||
public interface InfernoConfig extends Config
|
public interface InfernoConfig extends Config
|
||||||
@@ -63,4 +64,26 @@ public interface InfernoConfig extends Config
|
|||||||
{
|
{
|
||||||
return InfernoWaveDisplayMode.BOTH;
|
return InfernoWaveDisplayMode.BOTH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
position = 3,
|
||||||
|
keyName = "getWaveOverlayHeaderColor",
|
||||||
|
name = "Wave Header",
|
||||||
|
description = "Color for Wave Header"
|
||||||
|
)
|
||||||
|
default Color getWaveOverlayHeaderColor()
|
||||||
|
{
|
||||||
|
return Color.ORANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
position = 4,
|
||||||
|
keyName = "getWaveTextColor",
|
||||||
|
name = "Wave Text Color",
|
||||||
|
description = "Color for Wave Texts"
|
||||||
|
)
|
||||||
|
default Color getWaveTextColor()
|
||||||
|
{
|
||||||
|
return Color.WHITE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -25,17 +25,16 @@
|
|||||||
package net.runelite.client.plugins.inferno;
|
package net.runelite.client.plugins.inferno;
|
||||||
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EnumMap;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import net.runelite.api.Actor;
|
||||||
import net.runelite.api.ChatMessageType;
|
import net.runelite.api.ChatMessageType;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
@@ -65,11 +64,6 @@ import org.apache.commons.lang3.ArrayUtils;
|
|||||||
public class InfernoPlugin extends Plugin
|
public class InfernoPlugin extends Plugin
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final Pattern WAVE_PATTERN = Pattern.compile(".*Wave: (\\d+).*");
|
|
||||||
private static final int MAX_MONSTERS_OF_TYPE_PER_WAVE = 6;
|
|
||||||
private static final int INFERNO_REGION = 9043;
|
|
||||||
static final int MAX_WAVE = 69;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
@@ -94,9 +88,6 @@ public class InfernoPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private InfernoConfig config;
|
private InfernoConfig config;
|
||||||
|
|
||||||
@Getter
|
|
||||||
static final List<EnumMap<InfernoWaveMonster, Integer>> WAVES = new ArrayList<>();
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private int currentWave = -1;
|
private int currentWave = -1;
|
||||||
|
|
||||||
@@ -118,46 +109,16 @@ public class InfernoPlugin extends Plugin
|
|||||||
private InfernoJadAttack attack;
|
private InfernoJadAttack attack;
|
||||||
|
|
||||||
private NPC jad;
|
private NPC jad;
|
||||||
|
private static final int INFERNO_REGION = 9043;
|
||||||
|
private int currentWaveNumber;
|
||||||
|
private int nextWaveNumber;
|
||||||
|
private Map<Integer, String> monster;
|
||||||
|
private Map<Integer, int[]> waves;
|
||||||
|
private List<Actor> waveMonsters;
|
||||||
|
|
||||||
|
public InfernoPlugin()
|
||||||
static
|
|
||||||
{
|
{
|
||||||
final InfernoWaveMonster[] waveMonsters = InfernoWaveMonster.values();
|
waveMonsters = new ArrayList<Actor>();
|
||||||
|
|
||||||
// Add wave 1, future waves are derived from its contents
|
|
||||||
final EnumMap<InfernoWaveMonster, Integer> waveOne = new EnumMap<>(InfernoWaveMonster.class);
|
|
||||||
waveOne.put(waveMonsters[0], 1);
|
|
||||||
WAVES.add(waveOne);
|
|
||||||
|
|
||||||
for (int wave = 1; wave < MAX_WAVE; wave++)
|
|
||||||
{
|
|
||||||
final EnumMap<InfernoWaveMonster, Integer> prevWave = WAVES.get(wave - 1).clone();
|
|
||||||
int maxMonsterOrdinal = -1;
|
|
||||||
|
|
||||||
for (int i = 0; i < waveMonsters.length; i++)
|
|
||||||
{
|
|
||||||
final int ordinalMonsterQuantity = prevWave.getOrDefault(waveMonsters[i], 0);
|
|
||||||
|
|
||||||
if (ordinalMonsterQuantity == MAX_MONSTERS_OF_TYPE_PER_WAVE)
|
|
||||||
{
|
|
||||||
maxMonsterOrdinal = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (maxMonsterOrdinal >= 0)
|
|
||||||
{
|
|
||||||
prevWave.remove(waveMonsters[maxMonsterOrdinal]);
|
|
||||||
}
|
|
||||||
|
|
||||||
final int addedMonsterOrdinal = maxMonsterOrdinal >= 0 ? maxMonsterOrdinal + 1 : 0;
|
|
||||||
final InfernoWaveMonster addedMonster = waveMonsters[addedMonsterOrdinal];
|
|
||||||
final int addedMonsterQuantity = prevWave.getOrDefault(addedMonster, 0);
|
|
||||||
|
|
||||||
prevWave.put(addedMonster, addedMonsterQuantity + 1);
|
|
||||||
|
|
||||||
WAVES.add(prevWave);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@@ -174,6 +135,8 @@ public class InfernoPlugin extends Plugin
|
|||||||
overlayManager.add(nibblerOverlay);
|
overlayManager.add(nibblerOverlay);
|
||||||
overlayManager.add(waveOverlay);
|
overlayManager.add(waveOverlay);
|
||||||
overlayManager.add(jadOverlay);
|
overlayManager.add(jadOverlay);
|
||||||
|
monster = InfernoWaveMappings.npcNameMapping();
|
||||||
|
waves = InfernoWaveMappings.waveMapping();
|
||||||
monsters = new HashMap<>();
|
monsters = new HashMap<>();
|
||||||
monsterCurrentAttackMap = new HashMap<>(6);
|
monsterCurrentAttackMap = new HashMap<>(6);
|
||||||
for (int i = 1; i <= 6; i++)
|
for (int i = 1; i <= 6; i++)
|
||||||
@@ -194,6 +157,11 @@ public class InfernoPlugin extends Plugin
|
|||||||
overlayManager.remove(jadOverlay);
|
overlayManager.remove(jadOverlay);
|
||||||
jad = null;
|
jad = null;
|
||||||
attack = null;
|
attack = null;
|
||||||
|
monster = null;
|
||||||
|
monsters = null;
|
||||||
|
waves = null;
|
||||||
|
currentWaveNumber = -1;
|
||||||
|
nextWaveNumber = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -218,6 +186,11 @@ public class InfernoPlugin extends Plugin
|
|||||||
{
|
{
|
||||||
jad = event.getNpc();
|
jad = event.getNpc();
|
||||||
}
|
}
|
||||||
|
final Actor actor = event.getActor();
|
||||||
|
if (actor != null)
|
||||||
|
{
|
||||||
|
waveMonsters.add(actor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -242,6 +215,11 @@ public class InfernoPlugin extends Plugin
|
|||||||
jad = null;
|
jad = null;
|
||||||
attack = null;
|
attack = null;
|
||||||
}
|
}
|
||||||
|
final Actor actor = event.getActor();
|
||||||
|
if (actor != null)
|
||||||
|
{
|
||||||
|
waveMonsters.remove(actor);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -261,16 +239,19 @@ public class InfernoPlugin extends Plugin
|
|||||||
@Subscribe
|
@Subscribe
|
||||||
public void onChatMessage(ChatMessage event)
|
public void onChatMessage(ChatMessage event)
|
||||||
{
|
{
|
||||||
final Matcher waveMatcher = WAVE_PATTERN.matcher(event.getMessage());
|
|
||||||
|
|
||||||
if (event.getType() != ChatMessageType.GAMEMESSAGE
|
if (event.getType() != ChatMessageType.GAMEMESSAGE || !inInferno())
|
||||||
|| !inInferno()
|
|
||||||
|| !waveMatcher.matches())
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
String message = event.getMessage();
|
||||||
|
if (event.getMessage().contains("Wave:"))
|
||||||
|
{
|
||||||
|
message = message.substring(message.indexOf(": ") + 2);
|
||||||
|
currentWaveNumber = Integer.parseInt(message.substring(0, message.indexOf("<")));
|
||||||
|
nextWaveNumber = ((currentWaveNumber < 63) ? (currentWaveNumber + 1) : -1);
|
||||||
|
}
|
||||||
|
|
||||||
currentWave = Integer.parseInt(waveMatcher.group(1));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -419,9 +400,40 @@ public class InfernoPlugin extends Plugin
|
|||||||
return ArrayUtils.contains(client.getMapRegions(), INFERNO_REGION);
|
return ArrayUtils.contains(client.getMapRegions(), INFERNO_REGION);
|
||||||
}
|
}
|
||||||
|
|
||||||
static String formatMonsterQuantity(final InfernoWaveMonster monster, final int quantity)
|
public boolean isNotFinalWave()
|
||||||
{
|
{
|
||||||
return String.format("%dx %s", quantity, monster);
|
return currentWaveNumber <= 68;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
InfernoJadAttack getAttack()
|
||||||
|
{
|
||||||
|
return attack;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getCurrentWaveNumber()
|
||||||
|
{
|
||||||
|
return currentWaveNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getNextWaveNumber()
|
||||||
|
{
|
||||||
|
return nextWaveNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Integer, String> getMonster()
|
||||||
|
{
|
||||||
|
return monster;
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Integer, int[]> getWaves()
|
||||||
|
{
|
||||||
|
return waves;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Actor> getWaveMonsters()
|
||||||
|
{
|
||||||
|
return waveMonsters;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,146 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, Kyleeld <https://github.com/kyleeld>
|
||||||
|
* Copyright (c) 2019, RuneLitePlus <https://runelitepl.us>
|
||||||
|
*
|
||||||
|
* 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.inferno;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class InfernoWaveMappings
|
||||||
|
{
|
||||||
|
static Map<Integer, int[]> waveMapping()
|
||||||
|
{
|
||||||
|
return new HashMap<Integer, int[]>()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
put(1, new int[]{32, 32, 32, 85});
|
||||||
|
put(2, new int[]{32, 32, 32, 85, 85});
|
||||||
|
put(3, new int[]{32, 32, 32, 32, 32, 32});
|
||||||
|
put(4, new int[]{32, 32, 32, 165});
|
||||||
|
put(5, new int[]{32, 32, 32, 85, 165});
|
||||||
|
put(6, new int[]{32, 32, 32, 85, 85, 165});
|
||||||
|
put(7, new int[]{32, 32, 32, 165, 165});
|
||||||
|
put(8, new int[]{32, 32, 32, 32, 32, 32});
|
||||||
|
put(9, new int[]{32, 32, 32, 240});
|
||||||
|
put(10, new int[]{32, 32, 32, 85, 240});
|
||||||
|
put(11, new int[]{32, 32, 32, 85, 85, 240});
|
||||||
|
put(12, new int[]{32, 32, 32, 165, 240});
|
||||||
|
put(13, new int[]{32, 32, 32, 85, 165, 240});
|
||||||
|
put(14, new int[]{32, 32, 32, 85, 85, 165, 240});
|
||||||
|
put(15, new int[]{32, 32, 32, 165, 165, 240});
|
||||||
|
put(16, new int[]{32, 32, 32, 240, 240});
|
||||||
|
put(17, new int[]{32, 32, 32, 32, 32, 32});
|
||||||
|
put(18, new int[]{32, 32, 32, 370});
|
||||||
|
put(19, new int[]{32, 32, 32, 85, 370});
|
||||||
|
put(20, new int[]{32, 32, 32, 85, 85, 370});
|
||||||
|
put(21, new int[]{32, 32, 32, 165, 370});
|
||||||
|
put(22, new int[]{32, 32, 32, 85, 165, 370});
|
||||||
|
put(23, new int[]{32, 32, 32, 85, 85, 165, 370});
|
||||||
|
put(24, new int[]{32, 32, 32, 165, 165, 370});
|
||||||
|
put(25, new int[]{32, 32, 32, 240, 370});
|
||||||
|
put(26, new int[]{32, 32, 32, 85, 240, 370});
|
||||||
|
put(27, new int[]{32, 32, 32, 85, 85, 240, 370});
|
||||||
|
put(28, new int[]{32, 32, 32, 165, 240, 370});
|
||||||
|
put(29, new int[]{32, 32, 32, 85, 165, 240, 370});
|
||||||
|
put(30, new int[]{32, 32, 32, 85, 85, 165, 240, 370});
|
||||||
|
put(31, new int[]{32, 32, 32, 165, 165, 240, 370});
|
||||||
|
put(32, new int[]{32, 32, 32, 240, 240, 370});
|
||||||
|
put(33, new int[]{32, 32, 32, 370, 370});
|
||||||
|
put(34, new int[]{32, 32, 32, 32, 32, 32});
|
||||||
|
put(35, new int[]{32, 32, 32, 490});
|
||||||
|
put(36, new int[]{32, 32, 32, 85, 490});
|
||||||
|
put(37, new int[]{32, 32, 32, 85, 85, 490});
|
||||||
|
put(38, new int[]{32, 32, 32, 165, 490});
|
||||||
|
put(39, new int[]{32, 32, 32, 85, 165, 490});
|
||||||
|
put(40, new int[]{32, 32, 32, 85, 85, 165, 490});
|
||||||
|
put(41, new int[]{32, 32, 32, 165, 165, 490});
|
||||||
|
put(42, new int[]{32, 32, 32, 240, 490});
|
||||||
|
put(43, new int[]{32, 32, 32, 85, 240, 490});
|
||||||
|
put(44, new int[]{32, 32, 32, 85, 85, 240, 490});
|
||||||
|
put(45, new int[]{32, 32, 32, 165, 240, 490 });
|
||||||
|
put(46, new int[]{32, 32, 32, 85, 165, 240, 490});
|
||||||
|
put(47, new int[]{32, 32, 32, 85, 85, 165, 240, 490});
|
||||||
|
put(48, new int[]{32, 32, 32, 165, 165, 240, 490});
|
||||||
|
put(49, new int[]{32, 32, 32, 240, 240, 490});
|
||||||
|
put(50, new int[]{32, 32, 32, 370, 490});
|
||||||
|
put(51, new int[]{32, 32, 32, 85, 370, 490});
|
||||||
|
put(52, new int[]{32, 32, 32, 85, 85, 370, 490});
|
||||||
|
put(53, new int[]{32, 32, 32, 165, 370, 490});
|
||||||
|
put(54, new int[]{32, 32, 32, 85, 165, 370, 490});
|
||||||
|
put(55, new int[]{32, 32, 32, 85, 85, 165, 370, 490});
|
||||||
|
put(56, new int[]{32, 32, 32, 165, 165, 370, 490});
|
||||||
|
put(57, new int[]{32, 32, 32, 240, 370, 490});
|
||||||
|
put(58, new int[]{32, 32, 32, 85, 240, 370, 490});
|
||||||
|
put(59, new int[]{32, 32, 32, 85, 85, 240, 370, 490});
|
||||||
|
put(60, new int[]{32, 32, 32, 165, 240, 370, 490});
|
||||||
|
put(61, new int[]{32, 32, 32, 85, 165, 240, 370, 490});
|
||||||
|
put(62, new int[]{32, 32, 32, 85, 85, 165, 240, 370, 490});
|
||||||
|
put(63, new int[]{32, 32, 32, 165, 165, 240, 370, 490});
|
||||||
|
put(64, new int[]{32, 32, 32, 85, 240, 240, 370, 490});
|
||||||
|
put(65, new int[]{32, 32, 32, 85, 370, 370, 490});
|
||||||
|
put(66, new int[]{32, 32, 32, 85, 490, 490});
|
||||||
|
put(67, new int[]{900});
|
||||||
|
put(68, new int[]{900, 900, 900});
|
||||||
|
put(69, new int[]{1400});
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static Map<Integer, String> npcNameMapping()
|
||||||
|
{
|
||||||
|
return new HashMap<Integer, String>()
|
||||||
|
{
|
||||||
|
{
|
||||||
|
put(32, "Jal-Nib - Level 32");
|
||||||
|
put(85, " Jal-MejRah - Level 85");
|
||||||
|
put(165, "Jal-Ak - Level 165");
|
||||||
|
put(240, "Jal-ImKot - Level 240");
|
||||||
|
put(370, "Jal-Xil - Level 370");
|
||||||
|
put(490, "Jal-Zek - Level 490");
|
||||||
|
put(900, "JalTok-Jad - Level 900");
|
||||||
|
put(1400, "TzKal-Zuk - Level 1400");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static HashMap intArrayToHashmap(int inputArray[])
|
||||||
|
{
|
||||||
|
HashMap<Integer, Integer> elementCountMap = new HashMap<Integer, Integer>();
|
||||||
|
for (int i : inputArray)
|
||||||
|
{
|
||||||
|
if (elementCountMap.containsKey(i))
|
||||||
|
{
|
||||||
|
elementCountMap.put(i, elementCountMap.get(i) + 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
elementCountMap.put(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return elementCountMap;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2018, Jordan Atwood <jordan.atwood423@gmail.com>
|
|
||||||
* 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.inferno;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
enum InfernoWaveMonster
|
|
||||||
{
|
|
||||||
|
|
||||||
JAL_NIB("Jal-Nib", 32),
|
|
||||||
JAL_MEJRAH("Jal-MejRah", 85),
|
|
||||||
JAL_AK("Jal-Ak", 165),
|
|
||||||
JAL_IMKOT("Jal-ImKot", 240),
|
|
||||||
JAL_XIL("Jal-XIL", 370),
|
|
||||||
JAL_ZEK("Jal-Zek", 490),
|
|
||||||
JALTOK_JAD("JalTok-Jad", 900),
|
|
||||||
TZKAL_ZUK("TzKal-Zuk", 1400);
|
|
||||||
|
|
||||||
private final String name;
|
|
||||||
private final int level;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return String.format("%s - Level %s", name, level);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,127 +1,69 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2018, Jordan Atwood <jordan.atwood423@gmail.com>
|
|
||||||
* 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.inferno;
|
package net.runelite.client.plugins.inferno;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.util.HashMap;
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import javax.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import net.runelite.client.ui.ColorScheme;
|
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
|
||||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
|
||||||
import net.runelite.client.ui.overlay.components.TitleComponent;
|
import net.runelite.client.ui.overlay.components.TitleComponent;
|
||||||
import net.runelite.client.ui.overlay.components.table.TableComponent;
|
import java.awt.Graphics2D;
|
||||||
|
import net.runelite.client.ui.overlay.OverlayPriority;
|
||||||
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
|
import java.awt.Dimension;
|
||||||
|
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||||
|
import net.runelite.api.Client;
|
||||||
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
|
|
||||||
class InfernoWaveOverlay extends Overlay
|
public class InfernoWaveOverlay extends Overlay
|
||||||
{
|
{
|
||||||
private static final Color HEADER_COLOR = ColorScheme.BRAND_ORANGE;
|
private final Client client;
|
||||||
|
|
||||||
private final InfernoConfig config;
|
|
||||||
private final InfernoPlugin plugin;
|
private final InfernoPlugin plugin;
|
||||||
|
private final InfernoConfig config;
|
||||||
private final PanelComponent panelComponent = new PanelComponent();
|
private PanelComponent panelComponent;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private InfernoWaveOverlay(InfernoConfig config, InfernoPlugin plugin)
|
InfernoWaveOverlay(final Client client, final InfernoPlugin plugin, final InfernoConfig config)
|
||||||
{
|
{
|
||||||
setPosition(OverlayPosition.TOP_RIGHT);
|
(this.panelComponent = new PanelComponent()).setPreferredSize(new Dimension(150, 0));
|
||||||
this.config = config;
|
this.setPosition(OverlayPosition.TOP_RIGHT);
|
||||||
|
this.setPriority(OverlayPriority.HIGH);
|
||||||
|
this.client = client;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public Dimension render(final Graphics2D graphics)
|
||||||
public Dimension render(Graphics2D graphics)
|
|
||||||
{
|
{
|
||||||
if (!plugin.inInferno()
|
if (!plugin.inInferno() || plugin.getCurrentWaveNumber() == 0)
|
||||||
|| plugin.getCurrentWave() < 0)
|
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
panelComponent.getChildren().clear();
|
panelComponent.getChildren().clear();
|
||||||
|
|
||||||
final int currentWave = plugin.getCurrentWave();
|
|
||||||
final int waveIndex = currentWave - 1;
|
|
||||||
|
|
||||||
if (config.waveDisplay() == InfernoWaveDisplayMode.CURRENT
|
if (config.waveDisplay() == InfernoWaveDisplayMode.CURRENT
|
||||||
|| config.waveDisplay() == InfernoWaveDisplayMode.BOTH)
|
|| config.waveDisplay() == InfernoWaveDisplayMode.BOTH)
|
||||||
{
|
{
|
||||||
final Map<InfernoWaveMonster, Integer> waveContents = InfernoPlugin.getWAVES().get(waveIndex);
|
renderWave("Current Wave (Wave " + plugin.getCurrentWaveNumber() + ")", plugin.getCurrentWaveNumber());
|
||||||
|
|
||||||
addWaveInfo("Wave " + plugin.getCurrentWave(), waveContents);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((config.waveDisplay() == InfernoWaveDisplayMode.NEXT
|
if ((config.waveDisplay() == InfernoWaveDisplayMode.NEXT
|
||||||
|| config.waveDisplay() == InfernoWaveDisplayMode.BOTH)
|
|| config.waveDisplay() == InfernoWaveDisplayMode.BOTH)
|
||||||
&& currentWave != InfernoPlugin.MAX_WAVE)
|
&& plugin.isNotFinalWave())
|
||||||
{
|
{
|
||||||
final Map<InfernoWaveMonster, Integer> waveContents = InfernoPlugin.getWAVES().get(waveIndex + 1);
|
renderWave("Next Wave (Wave " + plugin.getNextWaveNumber() + ")", plugin.getCurrentWaveNumber());
|
||||||
|
|
||||||
addWaveInfo("Next wave", waveContents);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return panelComponent.render(graphics);
|
return panelComponent.render(graphics);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addWaveInfo(final String headerText, final Map<InfernoWaveMonster, Integer> waveContents)
|
private void renderWave(final String header, final int waveNumber)
|
||||||
{
|
{
|
||||||
panelComponent.getChildren().add(TitleComponent.builder()
|
panelComponent.getChildren().add(TitleComponent.builder().text(header).color(config.getWaveOverlayHeaderColor()).build());
|
||||||
.text(headerText)
|
final HashMap<Integer, Integer> waveMap = (HashMap<Integer, Integer>) InfernoWaveMappings.intArrayToHashmap(plugin.getWaves().get(waveNumber));
|
||||||
.color(HEADER_COLOR)
|
for (final Map.Entry<Integer, Integer> entry : waveMap.entrySet())
|
||||||
.build());
|
|
||||||
|
|
||||||
TableComponent tableComponent = new TableComponent();
|
|
||||||
|
|
||||||
for (String line : buildWaveLines(waveContents))
|
|
||||||
{
|
{
|
||||||
tableComponent.addRow(line);
|
final int monsterID = entry.getKey();
|
||||||
}
|
final int quantity = entry.getValue();
|
||||||
|
if (quantity <= 0)
|
||||||
panelComponent.getChildren().add(tableComponent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Collection<String> buildWaveLines(final Map<InfernoWaveMonster, Integer> wave)
|
|
||||||
{
|
{
|
||||||
final List<Map.Entry<InfernoWaveMonster, Integer>> monsters = new ArrayList<>(wave.entrySet());
|
continue;
|
||||||
monsters.sort(Map.Entry.comparingByKey());
|
}
|
||||||
final List<String> outputLines = new ArrayList<>();
|
panelComponent.getChildren().add(TitleComponent.builder().text(quantity + "x " + plugin.getMonster().get(monsterID)).color(config.getWaveTextColor()).build());
|
||||||
|
|
||||||
for (Map.Entry<InfernoWaveMonster, Integer> monsterEntry : monsters)
|
|
||||||
{
|
|
||||||
final InfernoWaveMonster monster = monsterEntry.getKey();
|
|
||||||
final int quantity = monsterEntry.getValue();
|
|
||||||
final String line = InfernoPlugin.formatMonsterQuantity(monster, quantity);
|
|
||||||
|
|
||||||
outputLines.add(line);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return outputLines;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user