client: remove Cerberus plugin
Removed at Jagex's request
This commit is contained in:
@@ -1,70 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2018, Tomas Slusny <slusnucky@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.cerberus;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import net.runelite.api.NPC;
|
|
||||||
import net.runelite.api.NpcID;
|
|
||||||
import net.runelite.api.Skill;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public enum CerberusGhost
|
|
||||||
{
|
|
||||||
RANGE(NpcID.SUMMONED_SOUL, Skill.RANGED),
|
|
||||||
MAGE(NpcID.SUMMONED_SOUL_5868, Skill.MAGIC),
|
|
||||||
MELEE(NpcID.SUMMONED_SOUL_5869, Skill.ATTACK);
|
|
||||||
|
|
||||||
private final int npcId;
|
|
||||||
private final Skill type;
|
|
||||||
|
|
||||||
private static final Map<Integer, CerberusGhost> MAP;
|
|
||||||
|
|
||||||
static
|
|
||||||
{
|
|
||||||
ImmutableMap.Builder<Integer, CerberusGhost> builder = new ImmutableMap.Builder<>();
|
|
||||||
|
|
||||||
for (final CerberusGhost ghost : values())
|
|
||||||
{
|
|
||||||
builder.put(ghost.getNpcId(), ghost);
|
|
||||||
}
|
|
||||||
|
|
||||||
MAP = builder.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Try to identify if NPC is ghost
|
|
||||||
* @param npc npc
|
|
||||||
* @return optional ghost
|
|
||||||
*/
|
|
||||||
public static Optional<CerberusGhost> fromNPC(final NPC npc)
|
|
||||||
{
|
|
||||||
return npc == null ? Optional.empty() : Optional.ofNullable(MAP.get(npc.getId()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2018, Tomas Slusny <slusnucky@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.cerberus;
|
|
||||||
|
|
||||||
import java.awt.Dimension;
|
|
||||||
import java.awt.Graphics2D;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
import net.runelite.client.game.SkillIconManager;
|
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
|
||||||
import net.runelite.client.ui.overlay.components.ComponentOrientation;
|
|
||||||
import net.runelite.client.ui.overlay.components.ImageComponent;
|
|
||||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
|
||||||
|
|
||||||
@Singleton
|
|
||||||
public class CerberusOverlay extends Overlay
|
|
||||||
{
|
|
||||||
private final CerberusPlugin plugin;
|
|
||||||
private final SkillIconManager iconManager;
|
|
||||||
private final PanelComponent panelComponent = new PanelComponent();
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
CerberusOverlay(final CerberusPlugin plugin, final SkillIconManager iconManager)
|
|
||||||
{
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.iconManager = iconManager;
|
|
||||||
setPosition(OverlayPosition.BOTTOM_RIGHT);
|
|
||||||
panelComponent.setOrientation(ComponentOrientation.HORIZONTAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Dimension render(Graphics2D graphics)
|
|
||||||
{
|
|
||||||
if (plugin.getGhosts().isEmpty())
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
panelComponent.getChildren().clear();
|
|
||||||
|
|
||||||
// Ghosts are already sorted
|
|
||||||
plugin.getGhosts().stream()
|
|
||||||
// Iterate only through the correct amount of ghosts
|
|
||||||
.limit(CerberusGhost.values().length)
|
|
||||||
.forEach(npc -> CerberusGhost
|
|
||||||
.fromNPC(npc)
|
|
||||||
.ifPresent(ghost -> panelComponent
|
|
||||||
.getChildren()
|
|
||||||
.add(new ImageComponent(iconManager.getSkillImage(ghost.getType())))));
|
|
||||||
|
|
||||||
|
|
||||||
return panelComponent.render(graphics);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,115 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2018, Tomas Slusny <slusnucky@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.cerberus;
|
|
||||||
|
|
||||||
import com.google.common.collect.ComparisonChain;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import javax.inject.Singleton;
|
|
||||||
import lombok.Getter;
|
|
||||||
import net.runelite.api.GameState;
|
|
||||||
import net.runelite.api.NPC;
|
|
||||||
import net.runelite.api.events.GameStateChanged;
|
|
||||||
import net.runelite.api.events.GameTick;
|
|
||||||
import net.runelite.api.events.NpcDespawned;
|
|
||||||
import net.runelite.api.events.NpcSpawned;
|
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
|
||||||
import net.runelite.client.plugins.Plugin;
|
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
|
||||||
|
|
||||||
@PluginDescriptor(
|
|
||||||
name = "Cerberus",
|
|
||||||
description = "Show what to pray against the summoned souls",
|
|
||||||
tags = {"bosses", "combat", "ghosts", "prayer", "pve", "overlay", "souls"}
|
|
||||||
)
|
|
||||||
@Singleton
|
|
||||||
public class CerberusPlugin extends Plugin
|
|
||||||
{
|
|
||||||
@Getter
|
|
||||||
private final List<NPC> ghosts = new ArrayList<>();
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private OverlayManager overlayManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private CerberusOverlay overlay;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void startUp() throws Exception
|
|
||||||
{
|
|
||||||
overlayManager.add(overlay);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void shutDown() throws Exception
|
|
||||||
{
|
|
||||||
overlayManager.remove(overlay);
|
|
||||||
ghosts.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onGameStateChanged(GameStateChanged event)
|
|
||||||
{
|
|
||||||
GameState gameState = event.getGameState();
|
|
||||||
if (gameState == GameState.LOGIN_SCREEN || gameState == GameState.HOPPING || gameState == GameState.CONNECTION_LOST)
|
|
||||||
{
|
|
||||||
ghosts.clear();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onNpcSpawned(final NpcSpawned event)
|
|
||||||
{
|
|
||||||
final NPC npc = event.getNpc();
|
|
||||||
CerberusGhost.fromNPC(npc).ifPresent(ghost -> ghosts.add(npc));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onNpcDespawned(final NpcDespawned event)
|
|
||||||
{
|
|
||||||
ghosts.remove(event.getNpc());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onGameTick(GameTick gameTick)
|
|
||||||
{
|
|
||||||
if (ghosts.isEmpty())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ghosts.sort((a, b) -> ComparisonChain.start()
|
|
||||||
// First, sort by the southernmost ghost (e.g with lowest y)
|
|
||||||
.compare(a.getLocalLocation().getY(), b.getLocalLocation().getY())
|
|
||||||
// Then, sort by the westernmost ghost (e.g with lowest x)
|
|
||||||
.compare(a.getLocalLocation().getX(), b.getLocalLocation().getX())
|
|
||||||
// This will give use the current wave and order of the ghosts based on
|
|
||||||
// what ghost will attack first
|
|
||||||
.result());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2018, 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.client.plugins.cerberus;
|
|
||||||
|
|
||||||
import com.google.inject.Guice;
|
|
||||||
import com.google.inject.testing.fieldbinder.Bind;
|
|
||||||
import com.google.inject.testing.fieldbinder.BoundFieldModule;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import net.runelite.api.NPC;
|
|
||||||
import net.runelite.api.coords.LocalPoint;
|
|
||||||
import net.runelite.api.events.GameTick;
|
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.mockito.Mock;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
import static org.mockito.Mockito.when;
|
|
||||||
import org.mockito.junit.MockitoJUnitRunner;
|
|
||||||
|
|
||||||
@RunWith(MockitoJUnitRunner.class)
|
|
||||||
public class CerberusPluginTest
|
|
||||||
{
|
|
||||||
@Mock
|
|
||||||
@Bind
|
|
||||||
OverlayManager overlayManager;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
CerberusPlugin cerberusPlugin;
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void before()
|
|
||||||
{
|
|
||||||
Guice.createInjector(BoundFieldModule.of(this)).injectMembers(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testOnGameTick()
|
|
||||||
{
|
|
||||||
List<NPC> ghosts = cerberusPlugin.getGhosts();
|
|
||||||
ghosts.addAll(Arrays.asList(
|
|
||||||
mockNpc(new LocalPoint(0, 0)),
|
|
||||||
mockNpc(new LocalPoint(1, 0)),
|
|
||||||
mockNpc(new LocalPoint(0, 5)),
|
|
||||||
mockNpc(new LocalPoint(2, 0)),
|
|
||||||
mockNpc(new LocalPoint(2, 5)),
|
|
||||||
mockNpc(new LocalPoint(1, 5))
|
|
||||||
));
|
|
||||||
cerberusPlugin.onGameTick(new GameTick());
|
|
||||||
|
|
||||||
// Expected sort is by lowest y first, then by lowest x
|
|
||||||
assertEquals(ghosts.get(0).getLocalLocation(), new LocalPoint(0, 0));
|
|
||||||
assertEquals(ghosts.get(1).getLocalLocation(), new LocalPoint(1, 0));
|
|
||||||
assertEquals(ghosts.get(2).getLocalLocation(), new LocalPoint(2, 0));
|
|
||||||
|
|
||||||
assertEquals(ghosts.get(3).getLocalLocation(), new LocalPoint(0, 5));
|
|
||||||
assertEquals(ghosts.get(4).getLocalLocation(), new LocalPoint(1, 5));
|
|
||||||
assertEquals(ghosts.get(5).getLocalLocation(), new LocalPoint(2, 5));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static NPC mockNpc(LocalPoint localPoint)
|
|
||||||
{
|
|
||||||
NPC npc = mock(NPC.class);
|
|
||||||
when(npc.getLocalLocation()).thenReturn(localPoint);
|
|
||||||
return npc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user