timers: consolidate teleblock timers
This commit is contained in:
@@ -30,12 +30,10 @@ import com.google.inject.testing.fieldbinder.Bind;
|
||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.EnumSet;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.InventoryID;
|
||||
import net.runelite.api.ItemContainer;
|
||||
import net.runelite.api.WorldType;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.ItemContainerChanged;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
@@ -65,11 +63,6 @@ import org.mockito.stubbing.Answer;
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class TimersPluginTest
|
||||
{
|
||||
private static final String DMM_HALF_TELEBLOCK_MESSAGE = "<col=4f006f>A Tele Block spell has been cast on you by Runelite. It will expire in 1 minute, 15 seconds.</col>";
|
||||
private static final String FULL_TELEBLOCK_MESSAGE = "<col=4f006f>A Tele Block spell has been cast on you by Runelite. It will expire in 5 minutes.</col>";
|
||||
private static final String HALF_TELEBLOCK_MESSAGE = "<col=4f006f>A Tele Block spell has been cast on you by Runelite. It will expire in 2 minutes, 30 seconds.</col>";
|
||||
private static final String TRANSPARENT_CHATBOX_FULL_TELEBLOCK_MESSAGE = "<col=c356ef>A Tele Block spell has been cast on you by Alexsuperfly. It will expire in 5 minutes.</col>";
|
||||
private static final String TRANSPARENT_CHATBOX_TELEBLOCK_REMOVED_MESSAGE = "<col=c356ef>Your Tele Block has been removed because you killed Alexsuperfly.</col>";
|
||||
private static final int FIGHT_CAVES_REGION_ID = 9551;
|
||||
|
||||
@Inject
|
||||
@@ -105,54 +98,56 @@ public class TimersPluginTest
|
||||
public void testHalfTeleblock()
|
||||
{
|
||||
when(timersConfig.showTeleblock()).thenReturn(true);
|
||||
when(client.getWorldType()).thenReturn(EnumSet.of(WorldType.MEMBERS));
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", HALF_TELEBLOCK_MESSAGE, "", 0);
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", "<col=4f006f>A Tele Block spell has been cast on you by Runelite. It will expire in 2 minutes, 30 seconds.</col>", "", 0);
|
||||
timersPlugin.onChatMessage(chatMessage);
|
||||
|
||||
ArgumentCaptor<InfoBox> captor = ArgumentCaptor.forClass(InfoBox.class);
|
||||
verify(infoBoxManager).addInfoBox(captor.capture());
|
||||
TimerTimer infoBox = (TimerTimer) captor.getValue();
|
||||
assertEquals(GameTimer.HALFTB, infoBox.getTimer());
|
||||
assertEquals(GameTimer.TELEBLOCK, infoBox.getTimer());
|
||||
assertEquals(Duration.ofSeconds(2 * 60 + 30), infoBox.getDuration());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFullTeleblock()
|
||||
{
|
||||
when(timersConfig.showTeleblock()).thenReturn(true);
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", FULL_TELEBLOCK_MESSAGE, "", 0);
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", "<col=4f006f>A Tele Block spell has been cast on you by Runelite. It will expire in 5 minutes.</col>", "", 0);
|
||||
timersPlugin.onChatMessage(chatMessage);
|
||||
|
||||
ArgumentCaptor<InfoBox> captor = ArgumentCaptor.forClass(InfoBox.class);
|
||||
verify(infoBoxManager).addInfoBox(captor.capture());
|
||||
TimerTimer infoBox = (TimerTimer) captor.getValue();
|
||||
assertEquals(GameTimer.FULLTB, infoBox.getTimer());
|
||||
assertEquals(GameTimer.TELEBLOCK, infoBox.getTimer());
|
||||
assertEquals(Duration.ofMinutes(5), infoBox.getDuration());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDmmHalfTb()
|
||||
{
|
||||
when(timersConfig.showTeleblock()).thenReturn(true);
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", DMM_HALF_TELEBLOCK_MESSAGE, "", 0);
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", "<col=4f006f>A Tele Block spell has been cast on you by Runelite. It will expire in 1 minute, 15 seconds.</col>", "", 0);
|
||||
timersPlugin.onChatMessage(chatMessage);
|
||||
|
||||
ArgumentCaptor<InfoBox> captor = ArgumentCaptor.forClass(InfoBox.class);
|
||||
verify(infoBoxManager).addInfoBox(captor.capture());
|
||||
TimerTimer infoBox = (TimerTimer) captor.getValue();
|
||||
assertEquals(GameTimer.DMM_HALFTB, infoBox.getTimer());
|
||||
assertEquals(GameTimer.TELEBLOCK, infoBox.getTimer());
|
||||
assertEquals(Duration.ofSeconds(60 + 15), infoBox.getDuration());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDmmFullTb()
|
||||
{
|
||||
when(timersConfig.showTeleblock()).thenReturn(true);
|
||||
when(client.getWorldType()).thenReturn(EnumSet.of(WorldType.DEADMAN));
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", HALF_TELEBLOCK_MESSAGE, "", 0);
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", "<col=4f006f>A Tele Block spell has been cast on you by Runelite. It will expire in 2 minutes, 30 seconds.</col>", "", 0);
|
||||
timersPlugin.onChatMessage(chatMessage);
|
||||
|
||||
ArgumentCaptor<InfoBox> captor = ArgumentCaptor.forClass(InfoBox.class);
|
||||
verify(infoBoxManager).addInfoBox(captor.capture());
|
||||
TimerTimer infoBox = (TimerTimer) captor.getValue();
|
||||
assertEquals(GameTimer.DMM_FULLTB, infoBox.getTimer());
|
||||
assertEquals(GameTimer.TELEBLOCK, infoBox.getTimer());
|
||||
assertEquals(Duration.ofSeconds(60 * 2 + 30), infoBox.getDuration());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -185,25 +180,54 @@ public class TimersPluginTest
|
||||
public void testTransparentChatboxTb()
|
||||
{
|
||||
when(timersConfig.showTeleblock()).thenReturn(true);
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", TRANSPARENT_CHATBOX_FULL_TELEBLOCK_MESSAGE, "", 0);
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", "<col=c356ef>A Tele Block spell has been cast on you by Alexsuperfly. It will expire in 5 minutes.</col>", "", 0);
|
||||
timersPlugin.onChatMessage(chatMessage);
|
||||
|
||||
ArgumentCaptor<InfoBox> captor = ArgumentCaptor.forClass(InfoBox.class);
|
||||
verify(infoBoxManager).addInfoBox(captor.capture());
|
||||
TimerTimer infoBox = (TimerTimer) captor.getValue();
|
||||
assertEquals(GameTimer.FULLTB, infoBox.getTimer());
|
||||
assertEquals(GameTimer.TELEBLOCK, infoBox.getTimer());
|
||||
assertEquals(Duration.ofMinutes(5), infoBox.getDuration());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransparentChatboxTbRemoved()
|
||||
{
|
||||
when(timersConfig.showTeleblock()).thenReturn(true);
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", TRANSPARENT_CHATBOX_TELEBLOCK_REMOVED_MESSAGE, "", 0);
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", "<col=c356ef>Your Tele Block has been removed because you killed Alexsuperfly.</col>", "", 0);
|
||||
timersPlugin.onChatMessage(chatMessage);
|
||||
|
||||
verify(infoBoxManager, atLeastOnce()).removeIf(any());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMageArena2TbFull()
|
||||
{
|
||||
when(timersConfig.showTeleblock()).thenReturn(true);
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", "<col=c356ef>A Tele Block spell has been cast on you. It will expire in 2 minutes.</col>", "", 0);
|
||||
timersPlugin.onChatMessage(chatMessage);
|
||||
|
||||
ArgumentCaptor<InfoBox> captor = ArgumentCaptor.forClass(InfoBox.class);
|
||||
verify(infoBoxManager).addInfoBox(captor.capture());
|
||||
TimerTimer infoBox = (TimerTimer) captor.getValue();
|
||||
assertEquals(GameTimer.TELEBLOCK, infoBox.getTimer());
|
||||
assertEquals(Duration.ofMinutes(2), infoBox.getDuration());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMageArena2TbHalf()
|
||||
{
|
||||
when(timersConfig.showTeleblock()).thenReturn(true);
|
||||
ChatMessage chatMessage = new ChatMessage(null, ChatMessageType.SPAM, "", "<col=c356ef>A Tele Block spell has been cast on you. It will expire in 1 minute.</col>", "", 0);
|
||||
timersPlugin.onChatMessage(chatMessage);
|
||||
|
||||
ArgumentCaptor<InfoBox> captor = ArgumentCaptor.forClass(InfoBox.class);
|
||||
verify(infoBoxManager).addInfoBox(captor.capture());
|
||||
TimerTimer infoBox = (TimerTimer) captor.getValue();
|
||||
assertEquals(GameTimer.TELEBLOCK, infoBox.getTimer());
|
||||
assertEquals(Duration.ofMinutes(1), infoBox.getDuration());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStamina()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user