Here are the examples of the java api @org.pf4j.Extension taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
119 Examples
19
Source : VetionPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Vetion Helper", enabledByDefault = false, description = "Tracks Vet'ion's special attacks", tags = { "bosses", "combat", "pve", "overlay" })
public clreplaced VetionPlugin extends Plugin {
@Inject
private OverlayManager overlayManager;
@Inject
private VetionOverlay overlay;
@Getter(AccessLevel.PACKAGE)
private Map<Actor, Instant> vetions;
public static final int VETION_EARTHQUAKE = 5507;
@Override
protected void startUp() {
vetions = new HashMap<>();
overlayManager.add(overlay);
}
@Override
protected void shutDown() {
overlayManager.remove(overlay);
vetions = null;
}
@Subscribe
private void onAnimationChanged(AnimationChanged event) {
if (event.getActor().getAnimation() == VETION_EARTHQUAKE) {
Actor vet = event.getActor();
vetions.remove(vet, Instant.now());
vetions.put(vet, Instant.now());
}
}
}
19
Source : StrongholdPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Stronghold", enabledByDefault = false, description = "Highlights the correct answer to Stronghold of Security questions", tags = { "stronghold", "security", "overlay", "answer", "highlight" })
public clreplaced StrongholdPlugin extends Plugin {
@Inject
private Client client;
@Inject
private StrongholdConfig config;
private boolean queueNPCDialogue;
private boolean queueNPCOption;
private String questionCache;
@Provides
StrongholdConfig getConfig(ConfigManager configManager) {
return configManager.getConfig(StrongholdConfig.clreplaced);
}
@Subscribe
public void onWidgetLoaded(WidgetLoaded widgetLoaded) {
switch(widgetLoaded.getGroupId()) {
case WidgetID.DIALOG_NPC_GROUP_ID:
queueNPCDialogue = true;
break;
case WidgetID.DIALOG_OPTION_GROUP_ID:
queueNPCOption = true;
break;
}
}
@Subscribe
public void onClientTick(ClientTick t) {
if (queueNPCDialogue) {
queueNPCDialogue = false;
onNPCDialogue();
}
if (queueNPCOption) {
queueNPCOption = false;
onNPCOption();
}
}
private void onNPCDialogue() {
final Widget debugWidget = client.getWidget(WidgetInfo.DIALOG_NPC_TEXT);
if (debugWidget == null) {
return;
}
final String npcText = debugWidget.getText();
if (StrongholdAnswer.MATCHES.containsKey(npcText)) {
questionCache = npcText;
}
}
private void onNPCOption() {
if (questionCache == null) {
return;
}
final Widget optionsWidget = client.getWidget(WidgetInfo.DIALOG_OPTION);
if (optionsWidget == null) {
return;
}
final Widget[] widgets = optionsWidget.getParent().getChildren();
final Widget answerWidget = StrongholdAnswer.findCorrect(questionCache, widgets);
questionCache = null;
if (answerWidget == null) {
return;
}
final String answerText = answerWidget.getText();
answerWidget.setText(ColorUtil.wrapWithColorTag(answerText, config.highlightedAnswer()));
}
}
19
Source : SpecOrbPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Spec Orb", enabledByDefault = false, description = "Make the special attack orb work everywhere with all weapons")
public clreplaced SpecOrbPlugin extends Plugin {
@Inject
private Client client;
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded event) {
if (event.getMenuAction() == MenuAction.CC_OP && event.getParam1() == WidgetInfo.MINIMAP_SPEC_CLICKBOX.getGroupId()) {
client.setMenuOptionCount(client.getMenuOptionCount() - 1);
}
}
@Subscribe
private void onClientTick(ClientTick event) {
Rectangle specClickBox = client.getWidget(WidgetInfo.MINIMAP_SPEC_CLICKBOX).getBounds();
if (specClickBox == null) {
return;
}
if (specClickBox.contains(client.getMouseCanvasPosition().getX(), client.getMouseCanvasPosition().getY())) {
client.insertMenuItem("Use <col=00ff00>Special Attack</col>", "", MenuAction.CC_OP.getId(), 1, -1, WidgetInfo.COMBAT_SPECIAL_ATTACK_CLICKBOX.getId(), false);
}
}
}
19
Source : SorceressGardenPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Sorceress Garden", enabledByDefault = false, description = "Provides various utilities for the Sorceress's Garden minigame", tags = { "sorceress", "garden", "sqirk", "sq'irk", "thieving", "farming" })
@PluginDependency(XpTrackerPlugin.clreplaced)
public clreplaced SorceressGardenPlugin extends Plugin {
private static final int GARDEN_REGION = 11605;
@Inject
private SorceressGardenConfig config;
@Inject
private OverlayManager overlayManager;
@Inject
private SorceressGardenOverlay sorceressGardenOverlay;
@Inject
private SorceressSqirkOverlay sorceressSqirkOverlay;
@Inject
private SorceressSession sorceressSession;
@Inject
private Client client;
@Provides
SorceressGardenConfig provideConfig(ConfigManager configManager) {
return configManager.getConfig(SorceressGardenConfig.clreplaced);
}
@Override
protected void startUp() {
// runs on plugin startup
overlayManager.add(sorceressGardenOverlay);
overlayManager.add(sorceressSqirkOverlay);
}
@Override
protected void shutDown() {
// runs on plugin shutdown
overlayManager.remove(sorceressGardenOverlay);
overlayManager.remove(sorceressSqirkOverlay);
}
@Subscribe
private void onXpDropEvent(XpDropEvent event) {
if (!config.showSqirksStats()) {
return;
}
// Switch based off of XP gained, this is how we determine which Sqi'rk was picked
if (event.getSkill() == Skill.FARMING && isInGarden()) {
switch(event.getExp()) {
case 30:
sorceressSession.incrementSqirks(ItemID.WINTER_SQIRK);
break;
case 40:
sorceressSession.incrementSqirks(ItemID.SPRING_SQIRK);
break;
case 50:
sorceressSession.incrementSqirks(ItemID.AUTUMN_SQIRK);
break;
case 60:
sorceressSession.incrementSqirks(ItemID.SUMMER_SQIRK);
break;
}
}
}
boolean isInGarden() {
return client.getMapRegions() != null && ArrayUtils.contains(client.getMapRegions(), GARDEN_REGION);
}
}
19
Source : RunedokuPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Runedoku Solver", enabledByDefault = false, description = "Show solutions for current Runedoku puzzle.", tags = { "overlay", "runedoku", "sudoku", "puzzle", "solving" })
public clreplaced RunedokuPlugin extends Plugin {
@Inject
private OverlayManager overlayManager;
@Inject
private RunedokuOverlay runedokuOverlay;
@Provides
RunedokuConfig provideConfig(ConfigManager configManager) {
return configManager.getConfig(RunedokuConfig.clreplaced);
}
@Override
protected void startUp() {
overlayManager.add(runedokuOverlay);
}
@Override
protected void shutDown() {
overlayManager.remove(runedokuOverlay);
}
}
19
Source : PlayerAttackTimerPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Singleton
@Extension
@PluginDescriptor(name = "Player Attack Timer", enabledByDefault = false, description = "Display the tick delay for your current weapon.<br>Helps with lazy prayer flicking and flinching.", tags = { "player", "attack", "tick", "timer", "delay" })
public clreplaced PlayerAttackTimerPlugin extends Plugin {
private final Map<Integer, Integer> customAnimationTickMap = new HashMap<>();
private static final Splitter NEWLINE_SPLITTER = Splitter.on("\n").omitEmptyStrings().trimResults();
@Inject
private Client client;
@Inject
PlayerAttackTimerConfig config;
@Inject
private OverlayManager overlayManager;
@Inject
private PlayerOverlay playerOverlay;
@Getter(AccessLevel.PACKAGE)
private int ticksUntilNextAnimation;
@Provides
PlayerAttackTimerConfig getConfig(final ConfigManager configManager) {
return configManager.getConfig(PlayerAttackTimerConfig.clreplaced);
}
@Override
protected void startUp() {
overlayManager.add(playerOverlay);
parseCustomAnimationConfig(config.customAnimations());
}
@Override
protected void shutDown() {
overlayManager.remove(playerOverlay);
customAnimationTickMap.clear();
}
@Subscribe
private void onConfigChanged(final ConfigChanged event) {
if (!event.getGroup().equals("playerattacktimer")) {
return;
}
switch(event.getKey()) {
case "customAnimations":
parseCustomAnimationConfig(config.customAnimations());
break;
default:
break;
}
}
@Subscribe
private void onGameTick(final GameTick event) {
if (ticksUntilNextAnimation > 0) {
--ticksUntilNextAnimation;
}
final Player player = client.getLocalPlayer();
if (ticksUntilNextAnimation > 0 || player == null) {
return;
}
final int animationId = player.getAnimation();
final Integer delay = customAnimationTickMap.getOrDefault(animationId, ATTACK_TIMER_MAP.get(animationId));
if (delay != null) {
ticksUntilNextAnimation = delay;
}
}
private void parseCustomAnimationConfig(final String config) {
if (!ConfigParser.parse(config)) {
return;
}
customAnimationTickMap.clear();
final Map<String, String> split = NEWLINE_SPLITTER.withKeyValueSeparator(':').split(config);
if (split.isEmpty()) {
return;
}
for (final Map.Entry<String, String> entry : split.entrySet()) {
customAnimationTickMap.put(Integer.valueOf(entry.getKey()), Integer.valueOf(entry.getValue()));
}
}
}
19
Source : PileIndicatorsPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Pile Indicators", enabledByDefault = false, description = "Highlight and count how many npcs/players are stacked on each other.", tags = { "overlay", "pile", "stack", "pvp", "pvm", "pve" })
@Slf4j
public clreplaced PileIndicatorsPlugin extends Plugin {
@Inject
private Client client;
@Inject
private PileIndicatorsConfig config;
@Inject
private OverlayManager overlayManager;
@Inject
private PileIndicatorsOverlay overlay;
@Provides
PileIndicatorsConfig provideConfig(ConfigManager configManager) {
return configManager.getConfig(PileIndicatorsConfig.clreplaced);
}
@Override
protected void startUp() {
overlayManager.add(overlay);
}
@Override
protected void shutDown() {
overlayManager.remove(overlay);
}
List<List<Actor>> getStacks() {
List<List<Actor>> outerArrayList = new ArrayList<>();
List<Actor> pileList = new ArrayList<>();
if (config.enableNPCS()) {
for (NPC npc : client.getNpcs()) {
if (npc != null) {
pileList.add(npc);
}
}
}
if (config.enablePlayers() && (client.getVar(Varbits.IN_WILDERNESS) > 0 && config.wildyOnlyPlayer()) ^ (!config.wildyOnlyPlayer())) {
for (Player player : client.getPlayers()) {
if (player != null) {
pileList.add(player);
}
}
}
if (pileList.size() == 0) {
return null;
}
for (Actor actor : pileList) {
ArrayList<Actor> potentialStackArrayList = new ArrayList<>();
for (Actor actorToCompareTo : pileList) {
if (!potentialStackArrayList.contains(actorToCompareTo) && actor.getWorldLocation().distanceTo(actorToCompareTo.getWorldLocation()) == 0) {
potentialStackArrayList.add(actorToCompareTo);
}
}
if (potentialStackArrayList.size() >= config.minimumPileSize()) {
outerArrayList.add(potentialStackArrayList);
}
}
return outerArrayList.size() != 0 ? outerArrayList : null;
}
Color getColorByPileType(PileType pileType) {
switch(pileType) {
case PLAYER_PILE:
return config.playerPileColor();
case NPC_PILE:
return config.npcPileColor();
case MIXED_PILE:
return config.mixedPileColor();
}
return null;
}
PileType getPileType(List<Actor> pile) {
PileType pileType = null;
for (Actor actor : pile) {
if (actor instanceof NPC && pileType == null) {
pileType = PileType.NPC_PILE;
}
if (actor instanceof Player && pileType == null) {
pileType = PileType.PLAYER_PILE;
}
if (actor instanceof Player && pileType == PileType.NPC_PILE) {
pileType = PileType.MIXED_PILE;
}
if (actor instanceof NPC && pileType == PileType.PLAYER_PILE) {
pileType = PileType.MIXED_PILE;
}
}
return pileType;
}
}
19
Source : NightmarePlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Nightmare of Ashihama", enabledByDefault = false, description = "Show what prayer to use and which tiles to avoid", tags = { "bosses", "combat", "nm", "overlay", "nightmare", "pve", "pvm", "ashihama" })
@Slf4j
@Singleton
public clreplaced NightmarePlugin extends Plugin {
// Nightmare's attack animations
private static final int NIGHTMARE_HUSK_SPAWN = 8565;
private static final int NIGHTMARE_CHARGE_1 = 8597;
private static final int NIGHTMARE_CURSE = 8599;
private static final int NIGHTMARE_PARASITE_TOSS2 = 8606;
private static final int NIGHTMARE_CHARGE_2 = 8609;
private static final int NIGHTMARE_MELEE_ATTACK = 8594;
private static final int NIGHTMARE_RANGE_ATTACK = 8596;
private static final int NIGHTMARE_MAGIC_ATTACK = 8595;
private static final int NIGHTMARE_PRE_MUSHROOM = 37738;
private static final int NIGHTMARE_MUSHROOM = 37739;
// graphics object
private static final int NIGHTMARE_SHADOW = 1767;
private static final List<Integer> INACTIVE_TOTEMS = Arrays.asList(9434, 9437, 9440, 9443);
@Getter(AccessLevel.PACKAGE)
private final Map<Integer, MemorizedTotem> totems = new HashMap<>();
@Getter(AccessLevel.PACKAGE)
private final Map<LocalPoint, GameObject> spores = new HashMap<>();
@Getter(AccessLevel.PACKAGE)
private final Map<Polygon, Player> huskTarget = new HashMap<>();
@Getter(AccessLevel.PACKAGE)
private final Map<Integer, Player> parasiteTargets = new HashMap<>();
@Inject
private Client client;
@Inject
private NightmareConfig config;
@Inject
private OverlayManager overlayManager;
@Inject
private NightmarePrayerInfoBox prayerInfoBox;
@Nullable
@Getter(AccessLevel.PACKAGE)
private NightmareAttack pendingNightmareAttack;
@Nullable
@Getter(AccessLevel.PACKAGE)
private NPC nm;
@Getter(AccessLevel.PACKAGE)
private boolean inFight;
private boolean cursed;
private int attacksSinceCurse;
@Getter(AccessLevel.PACKAGE)
private int ticksUntilNextAttack = 0;
@Getter(AccessLevel.PACKAGE)
private int ticksUntilParasite = 0;
@Getter(AccessLevel.PACKAGE)
private boolean nightmareCharging = false;
@Getter(AccessLevel.PACKAGE)
private boolean shadowsSpawning = false;
@Getter(AccessLevel.PACKAGE)
@Setter
private boolean flash = false;
@Inject
private NightmareOverlay overlay;
@Inject
private NightmarePrayerOverlay prayerOverlay;
public NightmarePlugin() {
inFight = false;
}
@Provides
NightmareConfig provideConfig(ConfigManager configManager) {
return configManager.getConfig(NightmareConfig.clreplaced);
}
@Override
protected void startUp() {
overlayManager.add(overlay);
overlayManager.add(prayerOverlay);
overlayManager.add(prayerInfoBox);
reset();
}
@Override
protected void shutDown() {
overlayManager.remove(overlay);
overlayManager.remove(prayerOverlay);
overlayManager.remove(prayerInfoBox);
reset();
}
private void reset() {
inFight = false;
nm = null;
pendingNightmareAttack = null;
nightmareCharging = false;
shadowsSpawning = false;
cursed = false;
flash = false;
attacksSinceCurse = 0;
ticksUntilNextAttack = 0;
ticksUntilParasite = 0;
totems.clear();
spores.clear();
huskTarget.clear();
parasiteTargets.clear();
}
@Subscribe
private void onGameObjectSpawned(GameObjectSpawned event) {
if (!inFight) {
return;
}
GameObject gameObj = event.getGameObject();
int id = gameObj.getId();
if (id == NIGHTMARE_MUSHROOM || id == NIGHTMARE_PRE_MUSHROOM) {
spores.put(gameObj.getLocalLocation(), gameObj);
}
}
@Subscribe
private void onGameObjectDespawned(GameObjectDespawned event) {
if (!inFight) {
return;
}
GameObject gameObj = event.getGameObject();
int id = gameObj.getId();
if (id == NIGHTMARE_MUSHROOM || id == NIGHTMARE_PRE_MUSHROOM) {
spores.remove(gameObj.getLocalLocation());
}
}
@Subscribe
private void onProjectileSpawned(ProjectileSpawned event) {
if (!inFight) {
return;
}
var projectile = event.getProjectile();
Player targetPlayer;
switch(projectile.getId()) {
case 1770:
targetPlayer = (Player) projectile.getInteracting();
parasiteTargets.putIfAbsent(targetPlayer.getPlayerId(), targetPlayer);
break;
case 1781:
targetPlayer = (Player) projectile.getInteracting();
huskTarget.putIfAbsent(targetPlayer.getCanvasTilePoly(), targetPlayer);
break;
}
}
@Subscribe
public void onAnimationChanged(AnimationChanged event) {
Actor actor = event.getActor();
if (!(actor instanceof NPC)) {
return;
}
NPC npc = (NPC) actor;
int id = npc.getId();
// this will trigger once when the fight begins
if (id == 9432) {
// reset everything
reset();
nm = npc;
inFight = true;
}
if (!inFight || nm == null) {
return;
}
int animationId = npc.getAnimation();
if (animationId == NIGHTMARE_MAGIC_ATTACK) {
ticksUntilNextAttack = 7;
attacksSinceCurse++;
pendingNightmareAttack = cursed ? NightmareAttack.CURSE_MAGIC : NightmareAttack.MAGIC;
} else if (animationId == NIGHTMARE_MELEE_ATTACK) {
ticksUntilNextAttack = 7;
attacksSinceCurse++;
pendingNightmareAttack = cursed ? NightmareAttack.CURSE_MELEE : NightmareAttack.MELEE;
} else if (animationId == NIGHTMARE_RANGE_ATTACK) {
ticksUntilNextAttack = 7;
attacksSinceCurse++;
pendingNightmareAttack = cursed ? NightmareAttack.CURSE_RANGE : NightmareAttack.RANGE;
} else if (animationId == NIGHTMARE_CURSE) {
cursed = true;
attacksSinceCurse = 0;
} else if ((id == 9427 || id == 9430) && animationId == NIGHTMARE_CHARGE_2) {
nightmareCharging = true;
} else if ((id == 9427 || id == 9430) && animationId == NIGHTMARE_CHARGE_1) {
nightmareCharging = false;
}
if (animationId != NIGHTMARE_HUSK_SPAWN && (id == 9425 || id == 9428) && !huskTarget.isEmpty()) {
huskTarget.clear();
}
if (cursed && attacksSinceCurse == 5) {
// curse is removed when she phases, or does 5 attacks
cursed = false;
attacksSinceCurse = -1;
}
if (animationId == NIGHTMARE_PARASITE_TOSS2) {
ticksUntilParasite = 27;
}
}
@Subscribe
public void onNpcChanged(NpcChanged event) {
final NPC npc = event.getNpc();
if (npc == null) {
return;
}
// if ID changes to 9431 (3rd phase) and is cursed, remove the curse
if (cursed && npc.getId() == 9431) {
cursed = false;
attacksSinceCurse = -1;
}
// if npc is in the totems map, update its phase
if (totems.containsKey(npc.getIndex())) {
totems.get(npc.getIndex()).updateCurrentPhase(npc.getId());
} else if (INACTIVE_TOTEMS.contains(npc.getId())) {
// else if the totem is not in the totem array and it is an inactive totem, add it to the totem map.
totems.putIfAbsent(npc.getIndex(), new MemorizedTotem(npc));
}
}
@Subscribe
private void onChatMessage(ChatMessage event) {
if (!inFight || nm == null || event.getType() != ChatMessageType.GAMEMESSAGE) {
return;
}
if (event.getMessage().contains("The Nightmare has impregnated you with a deadly parasite!")) {
flash = true;
}
}
@Subscribe
private void onGameStateChanged(GameStateChanged event) {
GameState gamestate = event.getGameState();
// if loading happens while inFight, the user has left the area (either via death or teleporting).
if (gamestate == GameState.LOADING && inFight) {
reset();
}
}
@Subscribe
private void onGameTick(final GameTick event) {
if (!inFight || nm == null) {
return;
}
// if nightmare's id is 9433, the fight has ended and everything should be reset
if (nm.getId() == 9433) {
reset();
}
ticksUntilNextAttack--;
if (ticksUntilParasite > 0) {
ticksUntilParasite--;
if (ticksUntilParasite == 0) {
parasiteTargets.clear();
}
}
if (pendingNightmareAttack != null && ticksUntilNextAttack <= 3) {
pendingNightmareAttack = null;
}
if (config.highlightShadows()) {
boolean doShadowsExist = false;
for (GraphicsObject graphicsObject : client.getGraphicsObjects()) {
if (graphicsObject.getId() == NIGHTMARE_SHADOW) {
shadowsSpawning = true;
doShadowsExist = true;
break;
}
}
if (!doShadowsExist) {
shadowsSpawning = false;
}
}
}
private boolean isNightmareNpc(int id) {
return id >= 9425 && id <= 9433;
}
}
19
Source : MultiIndicatorsPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Multi-Lines", enabledByDefault = false, description = "Show borders of multicombat and PvP safezones", tags = { "multicombat", "lines", "pvp", "deadman", "safezones" })
public clreplaced MultiIndicatorsPlugin extends Plugin {
@Inject
private Client client;
@Inject
private ClientThread clientThread;
@Inject
private MultiIndicatorsConfig config;
@Inject
private MultiIndicatorsOverlay overlay;
@Inject
private MultiIndicatorsMinimapOverlay minimapOverlay;
@Inject
private OverlayManager overlayManager;
@Getter(AccessLevel.PACKAGE)
private GeneralPath[] multicombatPathToDisplay;
@Getter(AccessLevel.PACKAGE)
private GeneralPath[] pvpPathToDisplay;
@Getter(AccessLevel.PACKAGE)
private GeneralPath[] wildernessLevelLinesPathToDisplay;
@Getter(AccessLevel.PACKAGE)
private GeneralPath[] wildernessTeleportLinesPathToDisplay;
@Getter(AccessLevel.PACKAGE)
private boolean inPvp;
@Getter(AccessLevel.PACKAGE)
private boolean inDeadman;
private int currentPlane;
@Provides
MultiIndicatorsConfig getConfig(ConfigManager configManager) {
return configManager.getConfig(MultiIndicatorsConfig.clreplaced);
}
@Override
protected void startUp() {
overlayManager.add(overlay);
overlayManager.add(minimapOverlay);
initializePaths();
clientThread.invokeLater(() -> {
if (client.getGameState() == GameState.LOGGED_IN) {
findLinesInScene();
}
});
}
@Override
protected void shutDown() {
overlayManager.remove(overlay);
overlayManager.remove(minimapOverlay);
uninitializePaths();
}
private void initializePaths() {
multicombatPathToDisplay = new GeneralPath[Constants.MAX_Z];
pvpPathToDisplay = new GeneralPath[Constants.MAX_Z];
wildernessLevelLinesPathToDisplay = new GeneralPath[Constants.MAX_Z];
wildernessTeleportLinesPathToDisplay = new GeneralPath[Constants.MAX_Z];
}
private void uninitializePaths() {
multicombatPathToDisplay = null;
pvpPathToDisplay = null;
wildernessLevelLinesPathToDisplay = null;
wildernessTeleportLinesPathToDisplay = null;
}
// sometimes the lines get offset (seems to happen when there is a delay
// due to map reloading when walking/running "Loading - please wait")
// resetting the lines generation logic fixes this
public void update() {
if (client.getGameState() == GameState.LOGGED_IN) {
clientThread.invokeLater(this::findLinesInScene);
}
}
private void transformWorldToLocal(float[] coords) {
LocalPoint lp = LocalPoint.fromWorld(client, (int) coords[0], (int) coords[1]);
if (lp != null) {
coords[0] = lp.getX() - Perspective.LOCAL_TILE_SIZE / 2;
coords[1] = lp.getY() - Perspective.LOCAL_TILE_SIZE / 2;
}
}
private boolean isOpenableAt(WorldPoint wp) {
int sceneX = wp.getX() - client.getBaseX();
int sceneY = wp.getY() - client.getBaseY();
Tile tile = client.getScene().getTiles()[wp.getPlane()][sceneX][sceneY];
if (tile == null) {
return false;
}
WallObject wallObject = tile.getWallObject();
if (wallObject == null) {
return false;
}
ObjectComposition objectComposition = client.getObjectDefinition(wallObject.getId());
if (objectComposition == null) {
return false;
}
String[] actions = objectComposition.getActions();
if (actions == null) {
return false;
}
return Arrays.stream(actions).anyMatch(x -> x != null && x.toLowerCase().equals("open"));
}
private boolean collisionFilter(float[] p1, float[] p2) {
int x1 = (int) p1[0];
int y1 = (int) p1[1];
int x2 = (int) p2[0];
int y2 = (int) p2[1];
if (x1 > x2) {
int temp = x1;
x1 = x2;
x2 = temp;
}
if (y1 > y2) {
int temp = y1;
y1 = y2;
y2 = temp;
}
int dx = x2 - x1;
int dy = y2 - y1;
WorldArea wa1 = new WorldArea(new WorldPoint(x1, y1, currentPlane), 1, 1);
WorldArea wa2 = new WorldArea(new WorldPoint(x1 - dy, y1 - dx, currentPlane), 1, 1);
if (isOpenableAt(wa1.toWorldPoint()) || isOpenableAt(wa2.toWorldPoint())) {
// When there's something with the open option (e.g. a door) on the tile,
// we replacedume it can be opened and walked through afterwards. Without this
// check, the line for that tile wouldn't render with collision detection
// because the collision check isn't done if collision data changes.
return true;
}
boolean b1 = wa1.canTravelInDirection(client, -dy, -dx);
boolean b2 = wa2.canTravelInDirection(client, dy, dx);
return b1 && b2;
}
private void findLinesInScene() {
inDeadman = client.getWorldType().stream().anyMatch(x -> x == WorldType.DEADMAN);
inPvp = client.getWorldType().stream().anyMatch(x -> x == WorldType.PVP);
Rectangle sceneRect = new Rectangle(client.getBaseX() + 1, client.getBaseY() + 1, Constants.SCENE_SIZE - 2, Constants.SCENE_SIZE - 2);
// Generate lines for multicombat zones
if (config.multicombatZoneVisibility() == ZoneVisibility.HIDE) {
Arrays.fill(multicombatPathToDisplay, null);
} else {
for (int i = 0; i < multicombatPathToDisplay.length; i++) {
currentPlane = i;
GeneralPath lines = new GeneralPath(MapLocations.getMulticombat(sceneRect, i));
lines = Geometry.clipPath(lines, sceneRect);
if (config.multicombatZoneVisibility() == ZoneVisibility.SHOW_IN_PVP && !isInDeadman() && !isInPvp()) {
lines = Geometry.clipPath(lines, MapLocations.getRoughWilderness(i));
}
lines = Geometry.splitIntoSegments(lines, 1);
if (useCollisionLogic()) {
lines = Geometry.filterPath(lines, this::collisionFilter);
}
lines = Geometry.transformPath(lines, this::transformWorldToLocal);
multicombatPathToDisplay[i] = lines;
}
}
// Generate safezone lines for deadman/pvp worlds
for (int i = 0; i < pvpPathToDisplay.length; i++) {
currentPlane = i;
GeneralPath safeZonePath = null;
if (config.showDeadmanSafeZones() && isInDeadman()) {
safeZonePath = new GeneralPath(MapLocations.getDeadmanSafeZones(sceneRect, i));
} else if (config.showPvpSafeZones() && isInPvp()) {
safeZonePath = new GeneralPath(MapLocations.getPvpSafeZones(sceneRect, i));
}
if (safeZonePath != null) {
safeZonePath = Geometry.clipPath(safeZonePath, sceneRect);
safeZonePath = Geometry.splitIntoSegments(safeZonePath, 1);
if (useCollisionLogic()) {
safeZonePath = Geometry.filterPath(safeZonePath, this::collisionFilter);
}
safeZonePath = Geometry.transformPath(safeZonePath, this::transformWorldToLocal);
}
pvpPathToDisplay[i] = safeZonePath;
}
// Generate wilderness Teleport lines
for (int i = 0; i < wildernessTeleportLinesPathToDisplay.length; i++) {
currentPlane = i;
GeneralPath wildernessTeleportLinesPath = null;
if (config.showWildernessTeleportLines()) {
wildernessTeleportLinesPath = new GeneralPath(MapLocations.getWildernessTeleportLines(sceneRect, i));
}
if (wildernessTeleportLinesPath != null) {
wildernessTeleportLinesPath = Geometry.clipPath(wildernessTeleportLinesPath, sceneRect);
wildernessTeleportLinesPath = Geometry.splitIntoSegments(wildernessTeleportLinesPath, 1);
if (useCollisionLogic()) {
wildernessTeleportLinesPath = Geometry.filterPath(wildernessTeleportLinesPath, this::collisionFilter);
}
wildernessTeleportLinesPath = Geometry.transformPath(wildernessTeleportLinesPath, this::transformWorldToLocal);
}
wildernessTeleportLinesPathToDisplay[i] = wildernessTeleportLinesPath;
}
// Generate wilderness level lines
for (int i = 0; i < wildernessLevelLinesPathToDisplay.length; i++) {
currentPlane = i;
GeneralPath wildernessLevelLinesPath = null;
if (config.showWildernessLevelLines()) {
wildernessLevelLinesPath = new GeneralPath(MapLocations.getWildernessLevelLines(sceneRect, i));
}
if (wildernessLevelLinesPath != null) {
wildernessLevelLinesPath = Geometry.clipPath(wildernessLevelLinesPath, sceneRect);
wildernessLevelLinesPath = Geometry.splitIntoSegments(wildernessLevelLinesPath, 1);
if (useCollisionLogic()) {
wildernessLevelLinesPath = Geometry.filterPath(wildernessLevelLinesPath, this::collisionFilter);
}
wildernessLevelLinesPath = Geometry.transformPath(wildernessLevelLinesPath, this::transformWorldToLocal);
}
wildernessLevelLinesPathToDisplay[i] = wildernessLevelLinesPath;
}
}
private boolean useCollisionLogic() {
// currently prevents overlay lines from showing up if this is ever enabled right now
return false;
}
@Subscribe
private void onConfigChanged(ConfigChanged event) {
if (!event.getGroup().equals("multiindicators")) {
return;
}
if (event.getKey().equals("collisionDetection") || event.getKey().equals("multicombatZoneVisibility") || event.getKey().equals("deadmanSafeZones") || event.getKey().equals("pvpSafeZones") || event.getKey().equals("wildernessLevelLines") || event.getKey().equals("wildernessTeleportLines")) {
findLinesInScene();
}
}
@Subscribe
private void onGameStateChanged(GameStateChanged event) {
if (event.getGameState() == GameState.LOGGED_IN) {
findLinesInScene();
}
}
}
19
Source : LizardmanShamanPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Lizardman Shamans", enabledByDefault = false, description = "Display an overlay for spawn explosion tiles", tags = { "lizardman", "shaman", "lizard" })
public clreplaced LizardmanShamanPlugin extends Plugin {
@Inject
private OverlayManager overlayManager;
@Inject
private LizardmanShamanOverlay overlay;
public static final int LIZARDMAN_SHAMAN_SPAWN_EXPLOSION = 7159;
@Provides
LizardmanShamanConfig getConfig(ConfigManager configManager) {
return configManager.getConfig(LizardmanShamanConfig.clreplaced);
}
@Override
protected void startUp() {
overlayManager.add(overlay);
}
@Override
protected void shutDown() {
overlayManager.remove(overlay);
}
}
19
Source : HallowedSepulchrePlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Hallowed Sepulchre", enabledByDefault = false, description = "A plugin for the Hallowed Sepulchre agility minigame.", tags = { "sepulchre", "hallowed", "darkmeyer", "agility", "course", "minigame" })
public clreplaced HallowedSepulchrePlugin extends Plugin {
private static final String GAME_MESSAGE_ENTER_LOBBY1 = "You make your way back to the lobby of the Hallowed Sepulchre.";
private static final String GAME_MESSAGE_ENTER_LOBBY2 = "The obelisk teleports you back to the lobby of the Hallowed Sepulchre.";
private static final String GAME_MESSAGE_ENTER_SEPULCHRE = "You venture further down into the Hallowed Sepulchre.";
private static final int ANIM_TICK_SPEED_2 = 2;
private static final int ANIM_TICK_SPEED_3 = 3;
private static final int WIZARD_STATUE_ANIM_FIRE = 8658;
private static final Set<Integer> ARROW_IDS = Set.of(NullNpcID.NULL_9672, NullNpcID.NULL_9673, NullNpcID.NULL_9674);
private static final Set<Integer> SWORD_IDS = Set.of(NullNpcID.NULL_9669, NullNpcID.NULL_9670, NullNpcID.NULL_9671);
private static final Set<Integer> CROSSBOWMAN_STATUE_IDS = Set.of(ObjectID.CROSSBOWMAN_STATUE, ObjectID.CROSSBOWMAN_STATUE_38445, ObjectID.CROSSBOWMAN_STATUE_38446);
private static final Set<Integer> WIZARD_STATUE_2TICK_IDS = Set.of(ObjectID.WIZARD_STATUE_38421, ObjectID.WIZARD_STATUE_38422, ObjectID.WIZARD_STATUE_38423, ObjectID.WIZARD_STATUE_38424, ObjectID.WIZARD_STATUE_38425);
private static final Set<Integer> WIZARD_STATUE_3TICK_IDS = Set.of(ObjectID.WIZARD_STATUE, ObjectID.WIZARD_STATUE_38410, ObjectID.WIZARD_STATUE_38411, ObjectID.WIZARD_STATUE_38412, ObjectID.WIZARD_STATUE_38416, ObjectID.WIZARD_STATUE_38417, ObjectID.WIZARD_STATUE_38418, ObjectID.WIZARD_STATUE_38419, ObjectID.WIZARD_STATUE_38420);
private static final Set<Integer> REGION_IDS = Set.of(8794, 8795, 8796, 8797, 8798, 9050, 9051, 9052, 9053, 9054, 9306, 9307, 9308, 9309, 9310, 9562, 9563, 9564, 9565, 9566, 9818, 9819, 9820, 9821, 9822, 10074, 10075, 10076, 10077, 10078, 10330, 10331, 10332, 10333, 10334);
@Inject
private Client client;
@Inject
private HallowedSepulchreConfig config;
@Inject
private OverlayManager overlayManager;
@Inject
private HallowedSepulchreOverlay hallowedSepulchreOverlay;
@Getter(AccessLevel.PACKAGE)
private final Set<GameObject> crossbowStatues = new HashSet<>();
@Getter(AccessLevel.PACKAGE)
private final Set<HallowedSepulchreWizardStatue> wizardStatues = new HashSet<>();
@Getter(AccessLevel.PACKAGE)
private final Set<NPC> arrows = new HashSet<>();
@Getter(AccessLevel.PACKAGE)
private final Set<NPC> swords = new HashSet<>();
@Getter(AccessLevel.PACKAGE)
private boolean playerInSepulchre = false;
@Provides
HallowedSepulchreConfig getConfig(final ConfigManager configManager) {
return configManager.getConfig(HallowedSepulchreConfig.clreplaced);
}
@Override
protected void startUp() {
if (client.getGameState() != GameState.LOGGED_IN || !isInSepulchreRegion()) {
return;
}
locateSepulchreGameObjects();
overlayManager.add(hallowedSepulchreOverlay);
playerInSepulchre = true;
}
@Override
protected void shutDown() {
playerInSepulchre = false;
overlayManager.remove(hallowedSepulchreOverlay);
clearSepulchreGameObjects();
}
@Subscribe
private void onGameTick(final GameTick event) {
if (!playerInSepulchre) {
return;
}
updateWizardStatues();
}
@Subscribe
private void onNpcSpawned(final NpcSpawned event) {
if (!playerInSepulchre) {
return;
}
addNpc(event.getNpc());
}
@Subscribe
private void onNpcDespawned(final NpcDespawned event) {
if (!playerInSepulchre) {
return;
}
removeNpc(event.getNpc());
}
@Subscribe
private void onGameObjectSpawned(final GameObjectSpawned event) {
if (!playerInSepulchre) {
return;
}
addGameObject(event.getGameObject());
}
@Subscribe
private void onGameStateChanged(final GameStateChanged event) {
final GameState gameState = event.getGameState();
switch(gameState) {
case LOGGED_IN:
if (isInSepulchreRegion()) {
playerInSepulchre = true;
} else if (playerInSepulchre) {
shutDown();
}
break;
case LOGIN_SCREEN:
if (playerInSepulchre) {
shutDown();
}
break;
default:
if (playerInSepulchre) {
clearSepulchreGameObjects();
}
break;
}
}
@Subscribe
private void onChatMessage(final ChatMessage message) {
if (!playerInSepulchre || message.getType() != ChatMessageType.GAMEMESSAGE) {
return;
}
switch(message.getMessage()) {
case GAME_MESSAGE_ENTER_LOBBY1:
case GAME_MESSAGE_ENTER_LOBBY2:
clearSepulchreGameObjects();
break;
case GAME_MESSAGE_ENTER_SEPULCHRE:
if (!overlayManager.anyMatch(o -> o instanceof HallowedSepulchreOverlay)) {
overlayManager.add(hallowedSepulchreOverlay);
}
break;
default:
break;
}
}
private void updateWizardStatues() {
if (!config.highlightWizardStatues() || wizardStatues.isEmpty()) {
return;
}
for (final HallowedSepulchreWizardStatue wizardStatue : wizardStatues) {
wizardStatue.updateTicksUntilNextAnimation();
}
}
private void addNpc(final NPC npc) {
final int id = npc.getId();
if (ARROW_IDS.contains(id)) {
arrows.add(npc);
} else if (SWORD_IDS.contains(id)) {
swords.add(npc);
}
}
private void removeNpc(final NPC npc) {
final int id = npc.getId();
if (ARROW_IDS.contains(id)) {
arrows.remove(npc);
} else if (SWORD_IDS.contains(id)) {
swords.remove(npc);
}
}
private void addGameObject(final GameObject gameObject) {
final int id = gameObject.getId();
if (CROSSBOWMAN_STATUE_IDS.contains(id)) {
crossbowStatues.add(gameObject);
} else if (WIZARD_STATUE_2TICK_IDS.contains(id)) {
wizardStatues.add(new HallowedSepulchreWizardStatue(gameObject, WIZARD_STATUE_ANIM_FIRE, ANIM_TICK_SPEED_2));
} else if (WIZARD_STATUE_3TICK_IDS.contains(id)) {
wizardStatues.add(new HallowedSepulchreWizardStatue(gameObject, WIZARD_STATUE_ANIM_FIRE, ANIM_TICK_SPEED_3));
}
}
private void clearSepulchreGameObjects() {
crossbowStatues.clear();
wizardStatues.clear();
arrows.clear();
swords.clear();
}
private boolean isInSepulchreRegion() {
return REGION_IDS.contains(client.getMapRegions()[0]);
}
private void locateSepulchreGameObjects() {
final LocatableQueryResults<GameObject> locatableQueryResults = new GameObjectQuery().result(client);
for (final GameObject gameObject : locatableQueryResults) {
addGameObject(gameObject);
}
for (final NPC npc : client.getNpcs()) {
addNpc(npc);
}
}
}
19
Source : EnvironmentAidPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Environment Aid", enabledByDefault = false, description = "Display or Remove Environment Aids.", tags = { "Barrows", "Area", "Effects", "environment", "aid" })
public clreplaced EnvironmentAidPlugin extends Plugin {
@Inject
private OverlayManager overlayManager;
@Inject
private Client client;
@Inject
private EnvironmentAidConfig config;
@Inject
private EnvironmentAidBarrowsOverlay environmentAidBarrowsOverlay;
@Getter(AccessLevel.PACKAGE)
public static final int MAX_DISTANCE = 2350;
@Getter(AccessLevel.PACKAGE)
private static final Set<Integer> BARROWS_WALLS = Sets.newHashSet(ObjectID.DOOR_20678, NullObjectID.NULL_20681, NullObjectID.NULL_20682, NullObjectID.NULL_20683, NullObjectID.NULL_20684, NullObjectID.NULL_20685, NullObjectID.NULL_20686, NullObjectID.NULL_20687, NullObjectID.NULL_20688, NullObjectID.NULL_20689, NullObjectID.NULL_20690, NullObjectID.NULL_20691, NullObjectID.NULL_20692, NullObjectID.NULL_20693, NullObjectID.NULL_20694, NullObjectID.NULL_20695, NullObjectID.NULL_20696, ObjectID.DOOR_20697, NullObjectID.NULL_20700, NullObjectID.NULL_20701, NullObjectID.NULL_20702, NullObjectID.NULL_20703, NullObjectID.NULL_20704, NullObjectID.NULL_20705, NullObjectID.NULL_20706, NullObjectID.NULL_20707, NullObjectID.NULL_20708, NullObjectID.NULL_20709, NullObjectID.NULL_20710, NullObjectID.NULL_20711, NullObjectID.NULL_20712, NullObjectID.NULL_20713, NullObjectID.NULL_20714, NullObjectID.NULL_20715, NullObjectID.NULL_20728, NullObjectID.NULL_20730);
private static final Set<Integer> BARROWS_LADDERS = Sets.newHashSet(NullObjectID.NULL_20675, NullObjectID.NULL_20676, NullObjectID.NULL_20677);
private static final int BARROWS_CRYPT_REGION_ID = 14231;
private static final int ZAMORAK_REGION = 11603;
private static final Set<Integer> SNOW_REGIONS = Set.of(// ICE PATH + GWD SURFACE(ENTRANCE)
11322, // ICE PATH + GWD SURFACE(ENTRANCE)
11323, // ICE PATH + GWD SURFACE(ENTRANCE)
11578, // ICE PATH + GWD SURFACE(ENTRANCE)
11579, // WATERBIRTH ISLAND
10042, // FAIRY RING DKS
10810);
private static final Set<Integer> UNDERWATER_REGION = Set.of(// FOSSIL ISLAND UNDERWATER
15008, // FOSSIL ISLAND UNDERWATER
15264, // MOGRE CAMP
11924);
private boolean wasInCrypt = false;
@Getter(AccessLevel.PACKAGE)
private final Set<WallObject> walls = new HashSet<>();
@Getter(AccessLevel.PACKAGE)
private final Set<GameObject> ladders = new HashSet<>();
@Provides
EnvironmentAidConfig getConfig(ConfigManager configManager) {
return configManager.getConfig(EnvironmentAidConfig.clreplaced);
}
@Override
protected void startUp() {
overlayManager.add(environmentAidBarrowsOverlay);
onStartUp();
}
@Override
protected void shutDown() {
overlayManager.remove(environmentAidBarrowsOverlay);
onShutDown();
}
private void onStartUp() {
if (client.getWidget(167, 0) != null) {
client.getWidget(167, 0).setHidden(config.snowEffect());
}
if (client.getWidget(406, 2) != null) {
client.getWidget(406, 2).setHidden(config.zamorakEffect());
}
if (client.getWidget(169, 0) != null) {
client.getWidget(169, 0).setHidden(config.waterEffect());
}
if (client.getWidget(170, 0) != null) {
client.getWidget(170, 0).setHidden(config.waterEffect());
}
}
private void onShutDown() {
wasInCrypt = false;
walls.clear();
ladders.clear();
if (client.getWidget(406, 2) != null) {
client.getWidget(406, 2).setHidden(false);
}
if (client.getWidget(167, 0) != null) {
client.getWidget(167, 0).setHidden(false);
}
if (client.getWidget(169, 0) != null) {
client.getWidget(169, 0).setHidden(false);
}
if (client.getWidget(170, 0) != null) {
client.getWidget(170, 0).setHidden(false);
}
}
@Subscribe
public void onGameTick(GameTick gameTick) {
if (isInZamorakRegion() && client.getWidget(406, 2) != null) {
client.getWidget(406, 2).setHidden(config.zamorakEffect());
}
if (isInSnowRegions() && client.getWidget(167, 0) != null) {
client.getWidget(167, 0).setHidden(config.snowEffect());
}
if (isInWaterRegion()) {
if (client.getWidget(169, 0) != null)
client.getWidget(169, 0).setHidden(config.waterEffect());
if (client.getWidget(170, 0) != null)
client.getWidget(170, 0).setHidden(config.waterEffect());
}
}
@Subscribe
public void widgetEvent(WidgetHiddenChanged widgetHiddenChanged) {
Widget event = widgetHiddenChanged.getWidget();
if (config.zamorakEffect() && isInZamorakRegion() && client.getWidget(406, 2) != null && event.getId() == client.getWidget(406, 2).getId()) {
hideWidget(event, true);
}
if (config.snowEffect() && isInSnowRegions() && client.getWidget(167, 0) != null && event.getId() == client.getWidget(167, 0).getId()) {
hideWidget(event, true);
}
if (config.waterEffect() && isInWaterRegion() && client.getWidget(169, 0) != null && event.getId() == client.getWidget(169, 0).getId()) {
hideWidget(event, true);
}
if (config.waterEffect() && isInWaterRegion() && client.getWidget(170, 0) != null && event.getId() == client.getWidget(170, 0).getId()) {
hideWidget(event, true);
}
}
private void hideWidget(Widget widget, boolean hidden) {
if (widget != null) {
widget.setHidden(true);
}
}
@Subscribe
private void onWallObjectSpawned(WallObjectSpawned event) {
WallObject wallObject = event.getWallObject();
if (BARROWS_WALLS.contains(wallObject.getId())) {
walls.add(wallObject);
}
}
@Subscribe
private void onWallObjectChanged(WallObjectChanged event) {
WallObject previous = event.getPrevious();
WallObject wallObject = event.getWallObject();
walls.remove(previous);
if (BARROWS_WALLS.contains(wallObject.getId())) {
walls.add(wallObject);
}
}
@Subscribe
private void onWallObjectDespawned(WallObjectDespawned event) {
WallObject wallObject = event.getWallObject();
walls.remove(wallObject);
}
@Subscribe
private void onGameObjectSpawned(GameObjectSpawned event) {
GameObject gameObject = event.getGameObject();
if (BARROWS_LADDERS.contains(gameObject.getId())) {
ladders.add(gameObject);
}
}
@Subscribe
private void onGameObjectChanged(GameObjectChanged event) {
GameObject previous = event.getPrevious();
GameObject gameObject = event.getGameObject();
ladders.remove(previous);
if (BARROWS_LADDERS.contains(gameObject.getId())) {
ladders.add(gameObject);
}
}
@Subscribe
private void onGameObjectDespawned(GameObjectDespawned event) {
GameObject gameObject = event.getGameObject();
ladders.remove(gameObject);
}
@Subscribe
private void onGameStateChanged(GameStateChanged event) {
if (event.getGameState() == GameState.LOADING) {
wasInCrypt = isInCrypt();
// on region changes the tiles get set to null
walls.clear();
ladders.clear();
}
}
private boolean isInCrypt() {
Player localPlayer = client.getLocalPlayer();
return localPlayer != null && localPlayer.getWorldLocation().getRegionID() == BARROWS_CRYPT_REGION_ID;
}
private boolean isInZamorakRegion() {
Player localPlayer = client.getLocalPlayer();
return localPlayer != null && localPlayer.getWorldLocation().getRegionID() == ZAMORAK_REGION;
}
private boolean isInWaterRegion() {
return UNDERWATER_REGION.contains(client.getMapRegions()[0]);
}
private boolean isInSnowRegions() {
return SNOW_REGIONS.contains(client.getMapRegions()[0]);
}
}
19
Source : EntityHiderExtendedPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Enreplacedy Hider Extended", enabledByDefault = false, description = "Hide ALL dead NPCs animations", tags = { "npcs" })
public clreplaced EnreplacedyHiderExtendedPlugin extends Plugin {
@Inject
private Client client;
@Override
protected void startUp() {
client.setIsHidingEnreplacedies(true);
client.setDeadNPCsHidden(true);
}
@Subscribe
public void onGameStateChanged(GameStateChanged event) {
if (event.getGameState() == GameState.LOGGED_IN) {
client.setIsHidingEnreplacedies(true);
}
}
@Override
protected void shutDown() {
client.setIsHidingEnreplacedies(false);
client.setDeadNPCsHidden(false);
}
}
19
Source : ClanManModePlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Clan Man Mode", enabledByDefault = false, description = "replacedists in clan PVP scenarios", tags = { "highlight", "minimap", "overlay", "players" })
public clreplaced ClanManModePlugin extends Plugin {
final Map<String, Integer> clan = new HashMap<>();
int wildernessLevel;
int clanmin;
int clanmax;
int inwildy;
int ticks;
@Inject
private OverlayManager overlayManager;
@Inject
private ClanManModeOverlay ClanManModeOverlay;
@Inject
private ClanManModeTileOverlay ClanManModeTileOverlay;
@Inject
private ClanManModeMinimapOverlay ClanManModeMinimapOverlay;
@Inject
private Client client;
@Provides
ClanManModeConfig provideConfig(ConfigManager configManager) {
return configManager.getConfig(ClanManModeConfig.clreplaced);
}
@Override
protected void startUp() {
overlayManager.add(ClanManModeOverlay);
overlayManager.add(ClanManModeTileOverlay);
overlayManager.add(ClanManModeMinimapOverlay);
}
@Override
protected void shutDown() {
overlayManager.remove(ClanManModeOverlay);
overlayManager.remove(ClanManModeTileOverlay);
overlayManager.remove(ClanManModeMinimapOverlay);
clan.clear();
ticks = 0;
wildernessLevel = 0;
clanmin = 0;
clanmax = 0;
inwildy = 0;
}
@Subscribe
private void onGameStateChanged(GameStateChanged gameStateChanged) {
if (gameStateChanged.getGameState() == GameState.LOGIN_SCREEN || gameStateChanged.getGameState() == GameState.HOPPING) {
ticks = 0;
}
}
@Subscribe
private void onGameTick(GameTick event) {
ticks++;
final Player localPlayer = client.getLocalPlayer();
if (!clan.containsKey(localPlayer.getName())) {
clan.put(localPlayer.getName(), localPlayer.getCombatLevel());
}
WorldPoint a = localPlayer.getWorldLocation();
int underLevel = ((a.getY() - 9920) / 8) + 1;
int upperLevel = ((a.getY() - 3520) / 8) + 1;
wildernessLevel = a.getY() > 6400 ? underLevel : upperLevel;
inwildy = client.getVar(Varbits.IN_WILDERNESS);
if (clan.size() > 0) {
clanmin = Collections.min(clan.values());
clanmax = Collections.max(clan.values());
}
}
}
19
Source : PdHandler.java
with Apache License 2.0
from XiaoMi
with Apache License 2.0
from XiaoMi
/**
* @author [email protected]
*/
@Slf4j
@Extension
public clreplaced PdHandler extends BaseHandler<Object> {
@Override
public Response<Object> execute(RequestContext context, Request request) {
return Response.success("plugin demo success:" + System.currentTimeMillis());
}
@Override
public String url() {
return "/mtop/test/pd";
}
}
19
Source : MaxHitPlugin.java
with GNU General Public License v3.0
from open-osrs
with GNU General Public License v3.0
from open-osrs
@Extension
@PluginDescriptor(name = "Max Hit", enabledByDefault = false, description = "Adds the max hit of the equipped weapon to the equipment and stats widget")
@Singleton
public clreplaced MaxHitPlugin extends Plugin {
@Inject
private Client client;
@Subscribe
private void onItemContainerChanged(final ItemContainerChanged event) {
this.updateMaxHitWidget();
}
@Subscribe
private void onVarreplacedanged(Varreplacedanged event) {
this.updateMaxHitWidget();
}
private void updateMaxHitWidget() {
Widget equipmentStats = client.getWidget(WidgetInfo.EQUIPMENT_INVENTORY_ITEMS_CONTAINER);
ItemContainer equipmentContainer = client.gereplacedemContainer(InventoryID.EQUIPMENT);
Item[] equipedItems = new Item[14];
if (equipmentStats != null && !equipmentStats.isHidden()) {
if (equipmentContainer != null) {
equipedItems = equipmentContainer.gereplacedems();
}
MeleeMaxHitCalculator meleeMaxHitCalculator = new MeleeMaxHitCalculator(this.client, equipedItems);
RangeMaxHitCalculator rangeMaxHitCalculator = new RangeMaxHitCalculator(this.client, equipedItems);
MagicMaxHitCalculator magicMaxHitCalculator = new MagicMaxHitCalculator(this.client, equipedItems);
MaxHit maxHit = new MaxHit(meleeMaxHitCalculator.getMaxHit(), rangeMaxHitCalculator.getMaxHit(), magicMaxHitCalculator.getMaxHit());
this.setWidgetMaxHit(maxHit);
}
}
private void setWidgetMaxHit(MaxHit maxhit) {
Widget equipmentPanel = client.getWidget(WidgetInfo.EQUIP_YOUR_CHARACTER);
if (equipmentPanel != null) {
Widget equipYourCharacter = equipmentPanel.getChildren()[1];
String maxHitText = "Max Hit: Melee: " + maxhit.getMaxMeleeHit();
maxHitText += " - Ranged: " + maxhit.getMaxRangeHit();
maxHitText += " - Magic: " + maxhit.getMaxMagicHit();
equipYourCharacter.setText(maxHitText);
}
}
private static clreplaced MaxHit {
private final double maxMeleeHit;
private final double maxRangeHit;
private final double maxMagicHit;
MaxHit(double maxMeleeHit, double maxRangeHit, double maxMagicHit) {
this.maxMeleeHit = maxMeleeHit;
this.maxRangeHit = maxRangeHit;
this.maxMagicHit = maxMagicHit;
}
double getMaxMeleeHit() {
return maxMeleeHit;
}
double getMaxRangeHit() {
return maxRangeHit;
}
double getMaxMagicHit() {
return maxMagicHit;
}
}
}
19
Source : ShelfRegister.java
with Apache License 2.0
from hank-cp
with Apache License 2.0
from hank-cp
/**
* @author <a href="https://github.com/hank-cp">Hank CP</a>
*/
@Extension
public clreplaced ShelfRegister implements PluginRegister {
@Override
public String name() {
return "shelf";
}
}
19
Source : LibraryRegister.java
with Apache License 2.0
from hank-cp
with Apache License 2.0
from hank-cp
/**
* @author <a href="https://github.com/hank-cp">Hank CP</a>
*/
@Extension
public clreplaced LibraryRegister implements PluginRegister {
@Override
public String name() {
return "library";
}
}
19
Source : AdminRegister.java
with Apache License 2.0
from hank-cp
with Apache License 2.0
from hank-cp
/**
* @author <a href="https://github.com/hank-cp">Hank CP</a>
*/
@Extension
public clreplaced AdminRegister implements PluginRegister {
@Override
public String name() {
return "admin";
}
}
19
Source : DummyExtension.java
with Apache License 2.0
from gentics
with Apache License 2.0
from gentics
@Extension
public clreplaced DummyExtension implements DummyExtensionPoint {
@Override
public String name() {
return "My dummy extension";
}
}
19
Source : LightThemeProvider.java
with GNU General Public License v3.0
from EXXETA
with GNU General Public License v3.0
from EXXETA
@Extension
public clreplaced LightThemeProvider extends BaseThemeProvider implements ThemeProvider, ThemeProviderHook {
@Override
public String getName() {
return "Light";
}
@Override
public String getCss() {
return getCssFromInputStream(LightThemeProvider.clreplaced.getResourcereplacedtream(getName() + ".css"));
}
@Override
public IconMode getIconMode() {
return IconMode.BLACK;
}
}
19
Source : DarkThemeProvider.java
with GNU General Public License v3.0
from EXXETA
with GNU General Public License v3.0
from EXXETA
@Extension
public clreplaced DarkThemeProvider extends BaseThemeProvider implements ThemeProvider, ThemeProviderHook {
@Override
public String getName() {
return "Dark";
}
@Override
public String getCss() {
return getCssFromInputStream(DarkThemeProvider.clreplaced.getResourcereplacedtream(getName() + ".css"));
}
@Override
public IconMode getIconMode() {
return IconMode.WHITE;
}
}
19
Source : ServiceModule.java
with Apache License 2.0
from exonum
with Apache License 2.0
from exonum
/**
* A service module defines bindings required to create an instance of {@link MyService}.
*/
@Extension
public final clreplaced ServiceModule extends AbstractServiceModule {
@Override
protected void configure() {
bind(Service.clreplaced).to(MyService.clreplaced).in(Singleton.clreplaced);
}
}
19
Source : QaServiceModule.java
with Apache License 2.0
from exonum
with Apache License 2.0
from exonum
/**
* A module of the QA service.
*/
@Extension
public final clreplaced QaServiceModule extends AbstractServiceModule {
@Override
protected void configure() {
bind(Service.clreplaced).to(QaServiceImpl.clreplaced);
bind(QaService.clreplaced).to(QaServiceImpl.clreplaced);
// Make sure QaService remains a singleton.
bind(QaServiceImpl.clreplaced).in(Singleton.clreplaced);
}
}
19
Source : FakeServiceModule.java
with Apache License 2.0
from exonum
with Apache License 2.0
from exonum
/**
* A module configuring {@link FakeService}.
*/
@Extension
public final clreplaced FakeServiceModule extends AbstractServiceModule {
@Override
protected void configure() {
bind(Service.clreplaced).to(FakeService.clreplaced).in(Singleton.clreplaced);
}
}
19
Source : CryptocurrencyServiceModule.java
with Apache License 2.0
from exonum
with Apache License 2.0
from exonum
@Extension
public final clreplaced CryptocurrencyServiceModule extends AbstractServiceModule {
@Override
protected void configure() {
bind(Service.clreplaced).to(CryptocurrencyServiceImpl.clreplaced);
bind(CryptocurrencyService.clreplaced).to(CryptocurrencyServiceImpl.clreplaced).in(Singleton.clreplaced);
}
}
19
Source : Hive3PluginCreator.java
with Apache License 2.0
from dremio
with Apache License 2.0
from dremio
/**
* PF4J extension for creating Hive3 StoragePlugin instances.
*/
@Extension
public clreplaced Hive3PluginCreator implements StoragePluginCreator {
public Hive3StoragePlugin createStoragePlugin(PluginManager pf4jManager, HiveStoragePluginConfig config, SabotContext context, String name, Provider<StoragePluginId> pluginIdProvider) {
final HiveConfFactory confFactory = new HiveConfFactory();
return new Hive3StoragePlugin(confFactory.createHiveConf(config), pf4jManager, context, name);
}
}
19
Source : HiveScanBatchCreator.java
with Apache License 2.0
from dremio
with Apache License 2.0
from dremio
@SuppressWarnings("unused")
@Extension
public clreplaced HiveScanBatchCreator implements HiveProxiedScanBatchCreator {
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(HiveScanBatchCreator.clreplaced);
private boolean isParquetSplit(final HiveTableXattr tableXattr, SplitAndParreplacedionInfo split, boolean isParreplacedioned) {
if (tableXattr.getReaderType() == NATIVE_PARQUET) {
return true;
}
Optional<String> tableInputFormat;
if (isParreplacedioned) {
final HiveReaderProto.ParreplacedionXattr parreplacedionXattr = HiveReaderProtoUtil.getParreplacedionXattr(split);
tableInputFormat = HiveReaderProtoUtil.getParreplacedionInputFormat(tableXattr, parreplacedionXattr);
} else {
tableInputFormat = HiveReaderProtoUtil.getTableInputFormat(tableXattr);
}
if (!tableInputFormat.isPresent()) {
return false;
}
try {
return MapredParquetInputFormat.clreplaced.isreplacedignableFrom((Clreplaced<? extends InputFormat>) Clreplaced.forName(tableInputFormat.get()));
} catch (ClreplacedNotFoundException e) {
return false;
}
}
private void clreplacedifySplitsAsParquetAndNonParquet(List<SplitAndParreplacedionInfo> allSplits, final HiveTableXattr tableXattr, boolean isParreplacedioned, List<SplitAndParreplacedionInfo> parquetSplits, List<SplitAndParreplacedionInfo> nonParquetSplits) {
// separate splits into parquet splits and non parquet splits
for (SplitAndParreplacedionInfo split : allSplits) {
if (isParquetSplit(tableXattr, split, isParreplacedioned)) {
parquetSplits.add(split);
} else {
nonParquetSplits.add(split);
}
}
}
@Override
public ProducerOperator create(FragmentExecutionContext fragmentExecContext, OperatorContext context, HiveProxyingSubScan config) throws ExecutionSetupException {
final Hive3StoragePlugin storagePlugin = fragmentExecContext.getStoragePlugin(config.getPluginId());
final HiveConf conf = storagePlugin.getHiveConf();
final HiveTableXattr tableXattr;
try {
tableXattr = HiveTableXattr.parseFrom(config.getExtendedProperty());
} catch (InvalidProtocolBufferException e) {
throw new ExecutionSetupException("Failure parsing table extended properties.", e);
}
// handle unexpected reader type
if (tableXattr.getReaderType() != HiveReaderProto.ReaderType.NATIVE_PARQUET && tableXattr.getReaderType() != HiveReaderProto.ReaderType.BASIC) {
throw new UnsupportedOperationException(tableXattr.getReaderType().name());
}
final UserGroupInformation proxyUgi = getUGI(storagePlugin, config);
final CompositeReaderConfig compositeConfig = CompositeReaderConfig.getCompound(context, config.getFullSchema(), config.getColumns(), config.getParreplacedionColumns());
final boolean isParreplacedioned = config.getParreplacedionColumns() != null && config.getParreplacedionColumns().size() > 0;
List<SplitAndParreplacedionInfo> parquetSplits = new ArrayList<>();
List<SplitAndParreplacedionInfo> nonParquetSplits = new ArrayList<>();
clreplacedifySplitsAsParquetAndNonParquet(config.getSplits(), tableXattr, isParreplacedioned, parquetSplits, nonParquetSplits);
RecordReaderIterator recordReaders = RecordReaderIterator.join(Objects.requireNonNull(ScanWithDremioReader.createReaders(conf, storagePlugin, fragmentExecContext, context, config, tableXattr, compositeConfig, proxyUgi, parquetSplits)), Objects.requireNonNull(ScanWithHiveReader.createReaders(conf, fragmentExecContext, context, config, tableXattr, compositeConfig, proxyUgi, nonParquetSplits)));
return new ScanOperator(config, context, recordReaders);
}
@VisibleForTesting
public UserGroupInformation getUGI(Hive3StoragePlugin storagePlugin, HiveProxyingSubScan config) {
final String userName = storagePlugin.getUsername(config.getProps().getUserName());
return HiveImpersonationUtil.createProxyUgi(userName);
}
}
19
Source : Hive2PluginCreator.java
with Apache License 2.0
from dremio
with Apache License 2.0
from dremio
/**
* PF4J extension for creating Hive2 StoragePlugin instances.
*/
@Extension
public clreplaced Hive2PluginCreator implements StoragePluginCreator {
public HiveStoragePlugin createStoragePlugin(PluginManager pf4jManager, HiveStoragePluginConfig config, SabotContext context, String name, Provider<StoragePluginId> pluginIdProvider) {
final HiveConfFactory confFactory = new HiveConfFactory();
return new HiveStoragePlugin(confFactory.createHiveConf(config), pf4jManager, context, name);
}
}
19
Source : HueUiSettingsExtension.java
with MIT License
from 89iuv
with MIT License
from 89iuv
@Extension
public clreplaced HueUiSettingsExtension implements UiSettingsExtensionPoint {
@Override
public String getPluginreplacedle() {
return "Hue integration";
}
@Override
public Parent getPluginParent() {
try {
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(getClreplaced().getResource("/ui/fxml/hue/hue_integration.fxml"));
// here something interesting happens
// the code gets initialized using the clreplacedpath of the parent
// but what we want is the clreplacedpath of the plugin
// in order to detect and initialize the plugin controller
fxmlLoader.setClreplacedLoader(getClreplaced().getClreplacedLoader());
Parent parent = null;
parent = fxmlLoader.load();
return parent;
} catch (IOException e) {
e.printStackTrace();
// fixme always return a pane with the encountered errors
throw new RuntimeException(e);
}
}
}
19
Source : HueFftExtension.java
with MIT License
from 89iuv
with MIT License
from 89iuv
@Extension
public clreplaced HueFftExtension implements SpectralExtensionPoint {
@Override
public void register(FrequencyBarsFFTService frequencyBarsFFTService) {
HueIntegration hueIntegration = new HueIntegration();
HueIntegrationManager hueIntegrationManager = new HueIntegrationManager(hueIntegration, frequencyBarsFFTService);
hueIntegrationManager.start();
}
}
19
Source : ArduinoUiSettingsExtension.java
with MIT License
from 89iuv
with MIT License
from 89iuv
@Extension
public clreplaced ArduinoUiSettingsExtension implements UiSettingsExtensionPoint {
@Override
public String getPluginreplacedle() {
return "Neopixel strip";
}
@Override
public Parent getPluginParent() {
try {
FXMLLoader fxmlLoader = new FXMLLoader();
fxmlLoader.setLocation(getClreplaced().getResource("/ui/fxml/arduino/neopixel_strip.fxml"));
// here something interesting happens
// the code gets initialized using the clreplacedpath of the parent
// but what we want is the clreplacedpath of the plugin
// in order to detect and initialize the plugin controller
fxmlLoader.setClreplacedLoader(getClreplaced().getClreplacedLoader());
return fxmlLoader.load();
} catch (IOException e) {
e.printStackTrace();
// fixme always return a pane with the encountered errors
throw new RuntimeException(e);
}
}
}
19
Source : ArduinoFftExtension.java
with MIT License
from 89iuv
with MIT License
from 89iuv
@Extension
public clreplaced ArduinoFftExtension implements SpectralExtensionPoint {
@Override
public void register(FrequencyBarsFFTService frequencyBarsFFTService) {
ArduinoManager arduinoManager = new ArduinoManager(frequencyBarsFFTService);
arduinoManager.play();
}
}
18
Source : ZulrahPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Zulrah Helper", enabledByDefault = false, description = "Shows tiles on where to stand during the phases and what prayer to use.", tags = { "zulrah", "boss", "helper" })
@Slf4j
public clreplaced ZulrahPlugin extends Plugin {
private static final ZulrahPattern[] patterns = new ZulrahPattern[] { new ZulrahPatternA(), new ZulrahPatternB(), new ZulrahPatternC(), new ZulrahPatternD() };
@Getter(AccessLevel.PACKAGE)
private NPC zulrah;
@Inject
private Client client;
@Inject
private OverlayManager overlayManager;
@Inject
private ZulrahCurrentPhaseOverlay currentPhaseOverlay;
@Inject
private ZulrahNextPhaseOverlay nextPhaseOverlay;
@Inject
private ZulrahPrayerOverlay zulrahPrayerOverlay;
@Inject
private ZulrahOverlay zulrahOverlay;
private ZulrahInstance instance;
@Override
protected void startUp() {
overlayManager.add(currentPhaseOverlay);
overlayManager.add(nextPhaseOverlay);
overlayManager.add(zulrahPrayerOverlay);
overlayManager.add(zulrahOverlay);
}
@Override
protected void shutDown() {
overlayManager.remove(currentPhaseOverlay);
overlayManager.remove(nextPhaseOverlay);
overlayManager.remove(zulrahPrayerOverlay);
overlayManager.remove(zulrahOverlay);
zulrah = null;
instance = null;
}
@Subscribe
private void onGameTick(GameTick event) {
if (client.getGameState() != GameState.LOGGED_IN) {
return;
}
if (zulrah == null) {
if (instance != null) {
log.debug("Zulrah encounter has ended.");
instance = null;
}
return;
}
if (instance == null) {
instance = new ZulrahInstance(zulrah);
log.debug("Zulrah encounter has started.");
}
ZulrahPhase currentPhase = ZulrahPhase.valueOf(zulrah, instance.getStartLocation());
if (instance.getPhase() == null) {
instance.setPhase(currentPhase);
} else if (!instance.getPhase().equals(currentPhase)) {
ZulrahPhase previousPhase = instance.getPhase();
instance.setPhase(currentPhase);
instance.nextStage();
log.debug("Zulrah phase has moved from {} -> {}, stage: {}", previousPhase, currentPhase, instance.getStage());
}
ZulrahPattern pattern = instance.getPattern();
if (pattern == null) {
int potential = 0;
ZulrahPattern potentialPattern = null;
for (ZulrahPattern p : patterns) {
if (p.stageMatches(instance.getStage(), instance.getPhase())) {
potential++;
potentialPattern = p;
}
}
if (potential == 1) {
log.debug("Zulrah pattern identified: {}", potentialPattern);
instance.setPattern(potentialPattern);
}
} else if (pattern.canReset(instance.getStage()) && (instance.getPhase() == null || instance.getPhase().equals(pattern.get(0)))) {
log.debug("Zulrah pattern has reset.");
instance.reset();
}
}
@Subscribe
private void onNpcSpawned(NpcSpawned event) {
NPC npc = event.getNpc();
if (npc != null && npc.getName() != null && npc.getName().toLowerCase().contains("zulrah")) {
zulrah = npc;
}
}
@Subscribe
private void onNpcDespawned(NpcDespawned event) {
NPC npc = event.getNpc();
if (npc != null && npc.getName() != null && npc.getName().toLowerCase().contains("zulrah")) {
zulrah = null;
}
}
public ZulrahInstance getInstance() {
return instance;
}
}
18
Source : TickTimersPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Boss Tick Timers", enabledByDefault = false, description = "Tick timers for bosses", tags = { "pvm", "bossing" })
public clreplaced TickTimersPlugin extends Plugin {
private static final int GENERAL_REGION = 11347;
private static final int ARMA_REGION = 11346;
private static final int SARA_REGION = 11602;
private static final int ZAMMY_REGION = 11603;
public static final int MINION_AUTO1 = 6154;
public static final int MINION_AUTO2 = 6156;
public static final int MINION_AUTO3 = 7071;
public static final int MINION_AUTO4 = 7073;
public static final int GENERAL_AUTO1 = 7018;
public static final int GENERAL_AUTO2 = 7020;
public static final int GENERAL_AUTO3 = 7021;
public static final int ZAMMY_GENERIC_AUTO = 64;
public static final int KRIL_AUTO = 6948;
public static final int KRIL_SPEC = 6950;
public static final int ZAKL_AUTO = 7077;
public static final int BALFRUG_AUTO = 4630;
public static final int ZILYANA_MELEE_AUTO = 6964;
public static final int ZILYANA_AUTO = 6967;
public static final int ZILYANA_SPEC = 6970;
public static final int STARLIGHT_AUTO = 6376;
public static final int BREE_AUTO = 7026;
public static final int GROWLER_AUTO = 7037;
public static final int KREE_RANGED = 6978;
public static final int SKREE_AUTO = 6955;
public static final int GEERIN_AUTO = 6956;
public static final int GEERIN_FLINCH = 6958;
public static final int KILISA_AUTO = 6957;
@Inject
private Client client;
@Inject
private OverlayManager overlayManager;
@Inject
private TimersOverlay timersOverlay;
@Inject
private TickTimersConfig config;
@Inject
private NPCManager npcManager;
@Getter(AccessLevel.PACKAGE)
private Set<NPCContainer> npcContainers = new HashSet<>();
private boolean validRegion;
@Getter(AccessLevel.PACKAGE)
private long lastTickTime;
@Provides
TickTimersConfig getConfig(ConfigManager configManager) {
return configManager.getConfig(TickTimersConfig.clreplaced);
}
@Override
public void startUp() {
if (client.getGameState() != GameState.LOGGED_IN) {
return;
}
if (regionCheck()) {
npcContainers.clear();
for (NPC npc : client.getNpcs()) {
addNpc(npc);
}
validRegion = true;
overlayManager.add(timersOverlay);
} else if (!regionCheck()) {
validRegion = false;
overlayManager.remove(timersOverlay);
npcContainers.clear();
}
}
@Override
public void shutDown() {
npcContainers.clear();
overlayManager.remove(timersOverlay);
validRegion = false;
}
@Subscribe
private void onGameStateChanged(GameStateChanged gameStateChanged) {
if (gameStateChanged.getGameState() != GameState.LOGGED_IN) {
return;
}
if (regionCheck()) {
npcContainers.clear();
for (NPC npc : client.getNpcs()) {
addNpc(npc);
}
validRegion = true;
overlayManager.add(timersOverlay);
} else if (!regionCheck()) {
validRegion = false;
overlayManager.remove(timersOverlay);
npcContainers.clear();
}
}
@Subscribe
private void onNpcSpawned(NpcSpawned event) {
if (!validRegion) {
return;
}
addNpc(event.getNpc());
}
@Subscribe
private void onNpcDespawned(NpcDespawned event) {
if (!validRegion) {
return;
}
removeNpc(event.getNpc());
}
@Subscribe
public void onGameTick(GameTick Event) {
lastTickTime = System.currentTimeMillis();
if (!validRegion) {
return;
}
handleBosses();
}
private void handleBosses() {
for (NPCContainer npc : getNpcContainers()) {
npc.setNpcInteracting(npc.getNpc().getInteracting());
if (npc.getTicksUntilAttack() >= 0) {
npc.setTicksUntilAttack(npc.getTicksUntilAttack() - 1);
}
for (int animation : npc.getAnimations()) {
if (animation == npc.getNpc().getAnimation() && npc.getTicksUntilAttack() < 1) {
npc.setTicksUntilAttack(npc.getAttackSpeed());
}
}
}
}
private boolean regionCheck() {
return Arrays.stream(client.getMapRegions()).anyMatch(x -> x == ARMA_REGION || x == GENERAL_REGION || x == ZAMMY_REGION || x == SARA_REGION);
}
private void addNpc(NPC npc) {
if (npc == null) {
return;
}
switch(npc.getId()) {
case NpcID.SERGEANT_STRONGSTACK:
case NpcID.SERGEANT_STEELWILL:
case NpcID.SERGEANT_GRIMSPIKE:
case NpcID.GENERAL_GRAARDOR:
case NpcID.TSTANON_KARLAK:
case NpcID.BALFRUG_KREEYATH:
case NpcID.ZAKLN_GRITCH:
case NpcID.KRIL_TSUTSAROTH:
case NpcID.STARLIGHT:
case NpcID.BREE:
case NpcID.GROWLER:
case NpcID.COMMANDER_ZILYANA:
case NpcID.FLIGHT_KILISA:
case NpcID.FLOCKLEADER_GEERIN:
case NpcID.WINGMAN_SKREE:
case NpcID.KREEARRA:
if (config.gwd()) {
npcContainers.add(new NPCContainer(npc, npcManager.getAttackSpeed(npc.getId())));
}
break;
}
}
private void removeNpc(NPC npc) {
if (npc == null) {
return;
}
switch(npc.getId()) {
case NpcID.SERGEANT_STRONGSTACK:
case NpcID.SERGEANT_STEELWILL:
case NpcID.SERGEANT_GRIMSPIKE:
case NpcID.GENERAL_GRAARDOR:
case NpcID.TSTANON_KARLAK:
case NpcID.BALFRUG_KREEYATH:
case NpcID.ZAKLN_GRITCH:
case NpcID.KRIL_TSUTSAROTH:
case NpcID.STARLIGHT:
case NpcID.BREE:
case NpcID.GROWLER:
case NpcID.COMMANDER_ZILYANA:
case NpcID.FLIGHT_KILISA:
case NpcID.FLOCKLEADER_GEERIN:
case NpcID.WINGMAN_SKREE:
case NpcID.KREEARRA:
npcContainers.removeIf(c -> c.getNpc() == npc);
break;
}
}
}
18
Source : TarnsLairPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Tarn's Lair", enabledByDefault = false, description = "Mark tiles and clickboxes to help traverse the maze", tags = { "agility", "maze", "minigame", "overlay" })
@Slf4j
public clreplaced TarnsLairPlugin extends Plugin {
private static final int TARNS_LAIR_NORTH_REGION = 12616;
private static final int TARNS_LAIR_SOUTH_REGION = 12615;
@Getter(AccessLevel.PACKAGE)
private final Map<TileObject, Tile> staircases = new HashMap<>();
@Getter(AccessLevel.PACKAGE)
private final Map<TileObject, Tile> wallTraps = new HashMap<>();
@Getter(AccessLevel.PACKAGE)
private final Map<TileObject, Tile> floorTraps = new HashMap<>();
@Getter(AccessLevel.PACKAGE)
private boolean inLair;
@Inject
private Client client;
@Inject
private OverlayManager overlayManager;
@Inject
private TarnsLairOverlay overlay;
@Override
protected void startUp() {
overlayManager.add(overlay);
}
@Override
protected void shutDown() {
overlayManager.remove(overlay);
staircases.clear();
wallTraps.clear();
floorTraps.clear();
inLair = false;
}
@Subscribe
private void onGameTick(GameTick event) {
int regionID = client.getLocalPlayer().getWorldLocation().getRegionID();
inLair = (regionID == TARNS_LAIR_NORTH_REGION || regionID == TARNS_LAIR_SOUTH_REGION);
}
@Subscribe
private void onGameObjectSpawned(GameObjectSpawned event) {
onTileObject(event.getTile(), null, event.getGameObject());
}
@Subscribe
private void onGameObjectChanged(GameObjectChanged event) {
onTileObject(event.getTile(), event.getPrevious(), event.getGameObject());
}
@Subscribe
private void onGameObjectDespawned(GameObjectDespawned event) {
onTileObject(event.getTile(), event.getGameObject(), null);
}
@Subscribe
private void onGroundObjectSpawned(GroundObjectSpawned event) {
onTileObject(event.getTile(), null, event.getGroundObject());
}
@Subscribe
private void onGroundObjectChanged(GroundObjectChanged event) {
onTileObject(event.getTile(), event.getPrevious(), event.getGroundObject());
}
@Subscribe
private void onGroundObjectDespawned(GroundObjectDespawned event) {
onTileObject(event.getTile(), event.getGroundObject(), null);
}
@Subscribe
private void onGameStateChanged(GameStateChanged event) {
if (event.getGameState() == GameState.LOADING) {
staircases.clear();
wallTraps.clear();
floorTraps.clear();
}
}
private void onTileObject(Tile tile, TileObject oldObject, TileObject newObject) {
staircases.remove(oldObject);
if (newObject != null && Obstacles.STAIRCASE_IDS.contains(newObject.getId())) {
staircases.put(newObject, tile);
}
wallTraps.remove(oldObject);
if (newObject != null && Obstacles.WALL_TRAP_IDS.contains(newObject.getId())) {
wallTraps.put(newObject, tile);
}
floorTraps.remove(oldObject);
if (newObject != null && Obstacles.FLOOR_TRAP_IDS.contains(newObject.getId())) {
floorTraps.put(newObject, tile);
}
}
}
18
Source : SpecBarPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Spec Bar", enabledByDefault = false, description = "Adds a spec bar to every weapon", tags = { "spec bar", "special attack", "spec", "bar", "pklite" })
public clreplaced SpecBarPlugin extends Plugin {
@Inject
private Client client;
@Subscribe
private void onScriptCallbackEvent(ScriptCallbackEvent event) {
if (!"drawSpecbarAnyway".equals(event.getEventName())) {
return;
}
int[] iStack = client.getIntStack();
int iStackSize = client.getIntStackSize();
iStack[iStackSize - 1] = 1;
}
}
18
Source : SpawnTimerPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Spawn Timer", enabledByDefault = false, description = "Shows NPC'S time since spawned", tags = { "highlight", "minimap", "npcs", "overlay", "spawn", "tags" })
public clreplaced SpawnTimerPlugin extends Plugin {
@Inject
private OverlayManager overlayManager;
@Getter(AccessLevel.PACKAGE)
private final Set<NPC> highlightedNpcs = new HashSet<>();
@Getter(AccessLevel.PACKAGE)
Set<SpawnTimer> ticks = new HashSet<>();
@Inject
private net.runelite.client.plugins.spawntimer.SpawnTimerOverlay SpawnTimerOverlay;
@Inject
private SpawnTimerConfig config;
@Provides
SpawnTimerConfig getConfig(ConfigManager configManager) {
return configManager.getConfig(SpawnTimerConfig.clreplaced);
}
@Getter(AccessLevel.PACKAGE)
public int currentTick;
@Override
protected void startUp() {
currentTick = 0;
overlayManager.add(SpawnTimerOverlay);
}
@Override
protected void shutDown() {
ticks.clear();
highlightedNpcs.clear();
overlayManager.remove(SpawnTimerOverlay);
}
@Subscribe
private void onGameTick(GameTick g) {
currentTick++;
}
@Subscribe
private void onGameStateChanged(GameStateChanged event) {
if (event.getGameState() == GameState.LOGIN_SCREEN || event.getGameState() == GameState.HOPPING) {
highlightedNpcs.clear();
ticks.clear();
}
}
@Subscribe
private void onNpcSpawned(NpcSpawned n) {
if (n.getNpc() != null) {
final NPC npc = n.getNpc();
highlightedNpcs.add(npc);
SpawnTimer temp = new SpawnTimer();
temp.setNpc(npc);
temp.setTick(currentTick);
ticks.add(temp);
}
}
@Subscribe
private void onNpcDespawned(NpcDespawned n) {
final NPC npc = n.getNpc();
if (highlightedNpcs.contains(npc)) {
highlightedNpcs.remove(npc);
// currentTick = 0;
ticks.removeIf(t -> t.getNpc() == npc);
}
}
@VisibleForTesting
public List<String> getHighlights() {
final String configNpcs = config.getNpcToHighlight().toLowerCase();
if (configNpcs.isEmpty()) {
return Collections.emptyList();
}
return Text.fromCSV(configNpcs);
}
}
18
Source : PlayerStatusPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Socket Player Status", description = "Socket extension for displaying player status to members in your party.", tags = { "socket", "server", "discord", "connection", "broadcast", "player", "status", "venge", "vengeance" }, enabledByDefault = false)
@Slf4j
@PluginDependency(SocketPlugin.clreplaced)
public clreplaced PlayerStatusPlugin extends Plugin {
@Inject
private Client client;
@Inject
private EventBus eventBus;
@Inject
private OverlayManager overlayManager;
@Inject
private ItemManager itemManager;
@Inject
private SpriteManager spriteManager;
@Inject
private PluginManager pluginManager;
@Inject
private SocketPlugin socketPlugin;
@Inject
private PlayerStatusOverlay overlay;
@Inject
private PlayerSidebarOverlay sidebar;
@Inject
private PlayerStatusConfig config;
@Provides
PlayerStatusConfig getConfig(ConfigManager configManager) {
return configManager.getConfig(PlayerStatusConfig.clreplaced);
}
@Getter(AccessLevel.PUBLIC)
private final Map<String, List<AbstractMarker>> statusEffects = new HashMap<String, List<AbstractMarker>>();
@Getter(AccessLevel.PUBLIC)
private Map<String, PlayerStatus> partyStatus = new TreeMap<String, PlayerStatus>();
private int lastRaidVarb;
private int lastVengCooldownVarb;
private int lastIsVengeancedVarb;
private int lastRefresh;
@Override
protected void startUp() {
lastRaidVarb = -1;
lastRefresh = 0;
synchronized (statusEffects) {
statusEffects.clear();
}
synchronized (partyStatus) {
partyStatus.clear();
}
overlayManager.add(overlay);
overlayManager.add(sidebar);
}
@Override
protected void shutDown() {
overlayManager.remove(overlay);
overlayManager.remove(sidebar);
}
@Subscribe
public void onVarreplacedanged(Varreplacedanged event) {
int raidVarb = client.getVar(Varbits.IN_RAID);
int vengCooldownVarb = client.getVar(Varbits.VENGEANCE_COOLDOWN);
int isVengeancedVarb = client.getVar(Varbits.VENGEANCE_ACTIVE);
if (lastRaidVarb != raidVarb) {
removeGameTimer(OVERLOAD_RAID);
removeGameTimer(PRAYER_ENHANCE);
lastRaidVarb = raidVarb;
}
if (lastVengCooldownVarb != vengCooldownVarb) {
if (vengCooldownVarb == 1) {
createGameTimer(VENGEANCE);
} else {
removeGameTimer(VENGEANCE);
}
lastVengCooldownVarb = vengCooldownVarb;
}
if (lastIsVengeancedVarb != isVengeancedVarb) {
if (isVengeancedVarb == 1) {
createGameIndicator(VENGEANCE_ACTIVE);
} else {
removeGameIndicator(VENGEANCE_ACTIVE);
}
lastIsVengeancedVarb = isVengeancedVarb;
}
}
@Subscribe
public void onMenuOptionClicked(MenuOptionClicked event) {
if (config.showStamina() && event.getMenuOption().contains("Drink") && (event.getId() == ItemID.STAMINA_MIX1 || event.getId() == ItemID.STAMINA_MIX2 || event.getId() == ItemID.EGNIOL_POTION_1 || event.getId() == ItemID.EGNIOL_POTION_2 || event.getId() == ItemID.EGNIOL_POTION_3 || event.getId() == ItemID.EGNIOL_POTION_4)) {
// Needs menu option hook because mixes use a common drink message, distinct from their standard potion messages
createGameTimer(STAMINA);
return;
}
}
@Subscribe
public void onChatMessage(ChatMessage event) {
if (event.getType() != ChatMessageType.SPAM && event.getType() != ChatMessageType.GAMEMESSAGE) {
return;
}
if (event.getMessage().equals(STAMINA_DRINK_MESSAGE) || event.getMessage().equals(STAMINA_SHARED_DRINK_MESSAGE)) {
createGameTimer(STAMINA);
}
if (event.getMessage().equals(STAMINA_EXPIRED_MESSAGE)) {
removeGameTimer(STAMINA);
}
if (event.getMessage().startsWith("You drink some of your") && event.getMessage().contains("overload")) {
if (client.getVar(Varbits.IN_RAID) == 1) {
createGameTimer(OVERLOAD_RAID);
} else {
createGameTimer(OVERLOAD);
}
}
if (event.getMessage().startsWith("You drink some of your") && event.getMessage().contains("prayer enhance")) {
createGameTimer(PRAYER_ENHANCE);
}
if (event.getMessage().equals(IMBUED_HEART_READY_MESSAGE)) {
removeGameTimer(IMBUED_HEART);
}
}
@Subscribe
private void onGraphicChanged(GraphicChanged event) {
Actor actor = event.getActor();
Player player = client.getLocalPlayer();
if (player == null || actor != client.getLocalPlayer()) {
return;
}
if (config.showImbuedHeart() && actor.getGraphic() == IMBUED_HEART.getGraphicId()) {
createGameTimer(IMBUED_HEART);
}
}
@Subscribe
public void onActorDeath(ActorDeath event) {
if (event.getActor() != client.getLocalPlayer()) {
return;
}
synchronized (statusEffects) {
List<AbstractMarker> activeEffects = statusEffects.get(null);
if (activeEffects == null) {
return;
}
for (AbstractMarker marker : new ArrayList<AbstractMarker>(activeEffects)) {
if (marker instanceof TimerMarker) {
TimerMarker timer = (TimerMarker) marker;
if (timer.getTimer().isRemovedOnDeath()) {
activeEffects.remove(marker);
}
}
}
if (activeEffects.isEmpty()) {
statusEffects.remove(null);
}
}
}
@Subscribe
public void onGameStateChanged(GameStateChanged event) {
switch(event.getGameState()) {
case HOPPING:
case LOGIN_SCREEN:
case LOGIN_SCREEN_AUTHENTICATOR:
{
synchronized (statusEffects) {
// Remove all party member trackers after you log out.
for (String s : new ArrayList<String>(statusEffects.keySet())) {
if (// s == null is local player, so we ignore
s != null) {
statusEffects.remove(s);
}
}
}
synchronized (partyStatus) {
partyStatus.clear();
}
break;
}
default:
break;
}
}
@Subscribe
public void onGameTick(GameTick event) {
if (client.getGameState() != GameState.LOGGED_IN) {
return;
}
int currentHealth = client.getBoostedSkillLevel(Skill.HITPOINTS);
int currentPrayer = client.getBoostedSkillLevel(Skill.PRAYER);
int maxHealth = client.getRealSkillLevel(Skill.HITPOINTS);
int maxPrayer = client.getRealSkillLevel(Skill.PRAYER);
int specialAttack = client.getVar(VarPlayer.SPECIAL_ATTACK_PERCENT) / // This variable is in [0, 1000]. So we divide by 10.
10;
int runEnergy = client.getEnergy();
String name = client.getLocalPlayer().getName();
PlayerStatus status;
synchronized (partyStatus) {
status = partyStatus.get(name);
if (status == null) {
status = new PlayerStatus(currentHealth, maxHealth, currentPrayer, maxPrayer, runEnergy, specialAttack);
partyStatus.put(name, status);
} else {
status.setHealth(currentHealth);
status.setMaxHealth(maxHealth);
status.setPrayer(currentPrayer);
status.setMaxPrayer(maxPrayer);
status.setRun(runEnergy);
status.setSpecial(specialAttack);
}
}
lastRefresh++;
if (lastRefresh >= Math.max(1, config.getStatsRefreshRate())) {
if (pluginManager.isPluginEnabled(socketPlugin)) {
JSONObject packet = new JSONObject();
packet.put("name", name);
packet.put("player-stats", status.toJSON());
eventBus.post(new SocketBroadcastPacket(packet));
}
lastRefresh = 0;
}
}
private void sortMarkers(List<AbstractMarker> markers) {
markers.sort(new Comparator<AbstractMarker>() {
@Override
public int compare(AbstractMarker o1, AbstractMarker o2) {
return Integer.compare(getMarkerOrdinal(o1), getMarkerOrdinal(o2));
}
private int getMarkerOrdinal(AbstractMarker marker) {
if (marker == null) {
return -1;
}
if (marker instanceof IndicatorMarker) {
return ((IndicatorMarker) marker).getIndicator().ordinal();
}
if (marker instanceof TimerMarker) {
return ((TimerMarker) marker).getTimer().ordinal();
}
return -1;
}
});
}
private void createGameTimer(GameTimer timer) {
createGameTimer(timer, null);
if (pluginManager.isPluginEnabled(socketPlugin)) {
JSONObject packet = new JSONObject();
packet.put("player-status-game-add", client.getLocalPlayer().getName());
packet.put("effect-name", timer.name());
eventBus.post(new SocketBroadcastPacket(packet));
}
}
private void createGameTimer(final GameTimer timer, String name) {
TimerMarker marker = new TimerMarker(timer, System.currentTimeMillis());
switch(timer.getImageType()) {
case SPRITE:
marker.setBaseImage(spriteManager.getSprite(timer.getImageId(), 0));
break;
case ITEM:
marker.setBaseImage(itemManager.getImage(timer.getImageId()));
break;
}
removeGameTimer(timer, name);
synchronized (statusEffects) {
List<AbstractMarker> activeEffects = statusEffects.get(name);
if (activeEffects == null) {
activeEffects = new ArrayList<AbstractMarker>();
statusEffects.put(name, activeEffects);
}
activeEffects.add(marker);
sortMarkers(activeEffects);
}
}
private void removeGameTimer(GameTimer timer) {
removeGameTimer(timer, null);
if (client.getLocalPlayer() == null) {
return;
}
if (pluginManager.isPluginEnabled(socketPlugin)) {
JSONObject packet = new JSONObject();
packet.put("player-status-game-remove", client.getLocalPlayer().getName());
packet.put("effect-name", timer.name());
eventBus.post(new SocketBroadcastPacket(packet));
}
}
private void removeGameTimer(GameTimer timer, String name) {
synchronized (statusEffects) {
List<AbstractMarker> activeEffects = statusEffects.get(name);
if (activeEffects == null) {
return;
}
for (AbstractMarker marker : new ArrayList<AbstractMarker>(activeEffects)) {
if (marker instanceof TimerMarker) {
TimerMarker instance = (TimerMarker) marker;
if (instance.getTimer() == timer) {
activeEffects.remove(marker);
}
}
}
if (activeEffects.isEmpty()) {
statusEffects.remove(name);
}
}
}
private void createGameIndicator(GameIndicator gameIndicator) {
createGameIndicator(gameIndicator, null);
if (client.getLocalPlayer() == null) {
return;
}
if (pluginManager.isPluginEnabled(socketPlugin)) {
JSONObject packet = new JSONObject();
packet.put("player-status-indicator-add", client.getLocalPlayer().getName());
packet.put("effect-name", gameIndicator.name());
eventBus.post(new SocketBroadcastPacket(packet));
}
}
private void createGameIndicator(GameIndicator gameIndicator, String name) {
IndicatorMarker marker = new IndicatorMarker(gameIndicator);
switch(gameIndicator.getImageType()) {
case SPRITE:
marker.setBaseImage(spriteManager.getSprite(gameIndicator.getImageId(), 0));
break;
case ITEM:
marker.setBaseImage(itemManager.getImage(gameIndicator.getImageId()));
break;
}
removeGameIndicator(gameIndicator, name);
synchronized (statusEffects) {
List<AbstractMarker> activeEffects = statusEffects.get(name);
if (activeEffects == null) {
activeEffects = new ArrayList<AbstractMarker>();
statusEffects.put(name, activeEffects);
}
activeEffects.add(marker);
sortMarkers(activeEffects);
}
}
private void removeGameIndicator(GameIndicator indicator) {
removeGameIndicator(indicator, null);
if (pluginManager.isPluginEnabled(socketPlugin)) {
JSONObject packet = new JSONObject();
packet.put("player-status-indicator-remove", client.getLocalPlayer().getName());
packet.put("effect-name", indicator.name());
eventBus.post(new SocketBroadcastPacket(packet));
}
}
private void removeGameIndicator(GameIndicator indicator, String name) {
synchronized (statusEffects) {
List<AbstractMarker> activeEffects = statusEffects.get(name);
if (activeEffects == null) {
return;
}
for (AbstractMarker marker : new ArrayList<AbstractMarker>(activeEffects)) {
if (marker instanceof IndicatorMarker) {
IndicatorMarker instance = (IndicatorMarker) marker;
if (instance.getIndicator() == indicator) {
activeEffects.remove(marker);
}
}
}
if (activeEffects.isEmpty()) {
statusEffects.remove(name);
}
}
}
@Subscribe
public void onSocketReceivePacket(SocketReceivePacket event) {
try {
JSONObject payload = event.getPayload();
String localName = client.getLocalPlayer().getName();
if (payload.has("player-stats")) {
String targetName = payload.getString("name");
if (targetName.equals(localName)) {
return;
}
JSONObject statusJson = payload.getJSONObject("player-stats");
PlayerStatus status;
synchronized (partyStatus) {
status = partyStatus.get(targetName);
if (status == null) {
status = PlayerStatus.fromJSON(statusJson);
partyStatus.put(targetName, status);
} else {
status.parseJSON(statusJson);
}
}
} else if (payload.has("player-status-game-add")) {
String targetName = payload.getString("player-status-game-add");
if (targetName.equals(localName)) {
return;
}
String effectName = payload.getString("effect-name");
GameTimer timer = GameTimer.valueOf(effectName);
createGameTimer(timer, targetName);
} else if (payload.has("player-status-game-remove")) {
String targetName = payload.getString("player-status-game-remove");
if (targetName.equals(localName)) {
return;
}
String effectName = payload.getString("effect-name");
GameTimer timer = GameTimer.valueOf(effectName);
removeGameTimer(timer, targetName);
} else if (payload.has("player-status-indicator-add")) {
String targetName = payload.getString("player-status-indicator-add");
if (targetName.equals(localName)) {
return;
}
String effectName = payload.getString("effect-name");
GameIndicator indicator = GameIndicator.valueOf(effectName);
createGameIndicator(indicator, targetName);
} else if (payload.has("player-status-indicator-remove")) {
String targetName = payload.getString("player-status-indicator-remove");
if (targetName.equals(localName)) {
return;
}
String effectName = payload.getString("effect-name");
GameIndicator indicator = GameIndicator.valueOf(effectName);
removeGameIndicator(indicator, targetName);
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Subscribe
public void onSocketPlayerLeave(SocketPlayerLeave event) {
String target = event.getPlayerName();
synchronized (statusEffects) {
if (statusEffects.containsKey(target)) {
statusEffects.remove(target);
}
}
synchronized (partyStatus) {
if (partyStatus.containsKey(target)) {
partyStatus.remove(target);
}
}
}
}
18
Source : SocketPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Slf4j
@Extension
@PluginDescriptor(name = "Socket", description = "Socket connection for broadcasting messages across clients.", tags = { "socket", "server", "discord", "connection", "broadcast" }, enabledByDefault = false)
public clreplaced SocketPlugin extends Plugin {
// To help users who decide to use weak preplacedwords.
public static final String PreplacedWORD_SALT = "$P@_/gKR`y:mv)6K";
@Inject
@Getter(AccessLevel.PUBLIC)
private Client client;
@Inject
@Getter(AccessLevel.PUBLIC)
private EventBus eventBus;
@Inject
@Getter(AccessLevel.PUBLIC)
private ClientThread clientThread;
@Inject
@Getter(AccessLevel.PUBLIC)
private SocketConfig config;
@Provides
SocketConfig getConfig(ConfigManager configManager) {
return configManager.getConfig(SocketConfig.clreplaced);
}
// This variables controls the next UNIX epoch time to establish the next connection.
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
private long nextConnection;
// This variables controls the current active connection.
private SocketConnection connection = null;
@Override
protected void startUp() {
nextConnection = 0L;
}
@Override
protected void shutDown() {
eventBus.unregister(SocketReceivePacket.clreplaced);
eventBus.unregister(SocketBroadcastPacket.clreplaced);
eventBus.unregister(SocketPlayerJoin.clreplaced);
eventBus.unregister(SocketPlayerLeave.clreplaced);
if (connection != null) {
connection.terminate(true);
}
}
@Subscribe
public void onGameTick(GameTick event) {
// Attempt connecting, or re-establishing connection to the socket server, only when the user is logged in.
if (client.getGameState() == GameState.LOGGED_IN) {
if (connection != null) {
// If an connection is already being established, ignore.
SocketState state = connection.getState();
if (state == SocketState.CONNECTING || state == SocketState.CONNECTED) {
return;
}
}
if (System.currentTimeMillis() >= nextConnection) {
// Create a new connection.
nextConnection = System.currentTimeMillis() + 30000L;
connection = new SocketConnection(this, client.getLocalPlayer().getName());
// Handler blocks, so run it on a separate thread.
new Thread(connection).start();
}
}
}
@Subscribe
public void onConfigChanged(ConfigChanged event) {
// Notify the user to restart the plugin when the config changes.
if (event.getGroup().equals("Socket")) {
clientThread.invoke(() -> client.addChatMessage(ChatMessageType.GAMEMESSAGE, "", "<col=b4281e>Configuration changed. Please restart the plugin to see updates.", null));
}
}
@Subscribe
public void onGameStateChanged(GameStateChanged event) {
// Terminate all connections to the socket server when the user logs out.
if (event.getGameState() == GameState.LOGIN_SCREEN) {
if (connection != null) {
connection.terminate(false);
}
}
}
@Subscribe
public void onSocketBroadcastPacket(SocketBroadcastPacket packet) {
try {
// Handles the packets that alternative plugins broadcasts.
if (connection == null || connection.getState() != SocketState.CONNECTED) {
return;
}
String data = packet.getPayload().toString();
log.debug("Deploying packet from client: {}", data);
String secret = config.getPreplacedword() + PreplacedWORD_SALT;
JSONObject payload = new JSONObject();
payload.put("header", SocketPacket.BROADCAST);
// Payload is now an encrypted string.
payload.put("payload", AES256.encrypt(secret, data));
PrintWriter outputStream = connection.getOutputStream();
synchronized (outputStream) {
outputStream.println(payload.toString());
}
} catch (Exception e) {
// Oh no, something went wrong!
e.printStackTrace();
log.error("An error has occurred while trying to broadcast a packet.", e);
}
}
}
18
Source : PlayerScouter.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Player Scouter", enabledByDefault = false, description = "Scout players and output them to your discord channel!")
@Slf4j
public clreplaced PlayerScouter extends Plugin {
private static final DiscordClient DISCORD_CLIENT = new DiscordClient();
private static final SimpleDateFormat SDF = new SimpleDateFormat("MMM dd h:mm a z");
// Add item id + ".png"
private static final String ICON_URL = "https://www.osrsbox.com/osrsbox-db/items-icons/";
@Inject
private Client client;
@Inject
private ItemManager itemManager;
@Inject
private PlayerScouterConfig config;
@Inject
private PlayerManager playerManager;
@Inject
private FriendChatManager friendChatManager;
private final Map<String, Integer> blacklist = new HashMap<>();
private HttpUrl webhook;
@Provides
PlayerScouterConfig provideConfig(ConfigManager configManager) {
return configManager.getConfig(PlayerScouterConfig.clreplaced);
}
@Override
protected void startUp() {
blacklist.clear();
this.webhook = HttpUrl.parse(config.webhook());
client.setComparingAppearance(true);
}
@Subscribe
private void onConfigChanged(ConfigChanged event) {
if (!event.getGroup().equals("playerscout")) {
return;
}
this.webhook = HttpUrl.parse(config.webhook());
}
@Override
protected void shutDown() {
blacklist.clear();
client.setComparingAppearance(false);
}
@Subscribe
private void onGameStateChanged(GameStateChanged event) {
if (event.getGameState() == GameState.LOGGED_IN) {
return;
}
blacklist.clear();
}
@Subscribe
private void onGameTick(GameTick event) {
resetBlacklist();
if (!checkWildy() || this.webhook == null) {
return;
}
final List<PlayerContainer> players = new ArrayList<>();
for (PlayerContainer player : playerManager.getPlayerContainers()) {
if (player.isScouted()) {
player.setScoutTimer(player.getScoutTimer() - 1);
if (player.getScoutTimer() <= 0) {
player.setScouted(false);
player.setScoutTimer(500);
}
continue;
}
if (player.getPlayer().getCombatLevel() < config.minimumCombat() || player.getPlayer().getCombatLevel() > config.maximumCombat()) {
continue;
}
if ((player.getPlayer().getCombatLevel() >= config.minimumCombat() && player.getPlayer().getCombatLevel() <= config.maximumCombat()) && player.getRisk() > config.minimumRisk()) {
if (player.getSkills() == null) {
if (player.isHttpRetry()) {
continue;
}
playerManager.updateStats(player.getPlayer());
continue;
}
if (config.mini()) {
players.add(player);
continue;
}
addPlayer(player);
}
}
if (config.mini()) {
players.sort(Comparator.comparingInt(PlayerContainer::getRisk).reversed());
scoutMini(players);
}
}
private void addPlayer(PlayerContainer player) {
if (player.getPlayer() == client.getLocalPlayer() || (!blacklist.isEmpty() && blacklist.containsKey(player.getName())) || (!config.scoutFriends() && client.isFriended(player.getName(), false) || (!config.scoutClan() && friendChatManager.isMember(player.getName())))) {
log.debug("Player Rejected: {}", player.getName());
return;
}
blacklist.put(player.getName(), client.getTickCount() + config.timeout());
scoutPlayer(player);
}
private void resetBlacklist() {
if (blacklist.isEmpty()) {
return;
}
Iterator<Map.Entry<String, Integer>> iter = blacklist.entrySet().iterator();
iter.forEachRemaining(entry -> {
if (entry.getValue() == client.getTickCount()) {
iter.remove();
}
});
}
private boolean checkWildy() {
if (!config.onlyWildy()) {
return true;
}
return client.getVar(Varbits.IN_WILDERNESS) == 1 || WorldType.isPvpWorld(client.getWorldType());
}
private void scoutMini(List<PlayerContainer> players) {
if (client.getLocalPlayer() == null) {
return;
}
final List<FieldEmbed> fieldList = new ArrayList<>();
final String location = WorldLocation.location(client.getLocalPlayer().getWorldLocation());
final int cap = Math.min(players.size(), 25);
int highestValue = 0;
int id = 0;
int risk = 0;
for (int i = 0; i < cap; i++) {
final PlayerContainer player = players.get(i);
final Map.Entry entry = getEntry(player.getGear());
risk += player.getRisk();
if (entry != null) {
final int mostValued = (int) entry.getValue();
final int mostValuedId = (int) entry.getKey();
if (mostValued > highestValue) {
highestValue = mostValued;
id = mostValuedId;
}
}
String name = "☠️ " + player.getName() + " ☠️";
if (player.getPlayer().getSkullIcon() == null) {
name = player.getName();
}
fieldList.add(FieldEmbed.builder().name(name).value(QuanreplacedyFormatter.quanreplacedyToRSDecimalStack(player.getRisk())).inline(true).build());
player.setScouted(true);
}
String iconId = String.valueOf(id);
String icon = ICON_URL + iconId + ".png";
ThumbnailEmbed image = ThumbnailEmbed.builder().url(ICON_URL + iconId + ".png").build();
String color = "8388352";
if (risk < 1000000 && risk > 150000) {
// blue
color = "32767";
} else if (risk > 1000000) {
// orange
color = "16744448";
}
message(location, icon, image, fieldList, color);
}
private void scoutPlayer(PlayerContainer player) {
if (player.isScouted()) {
return;
}
List<FieldEmbed> fieldList = new ArrayList<>();
// green
String color = "8388352";
if (player.getRisk() < 1000000 && player.getRisk() > 150000) {
// blue
color = "32767";
} else if (player.getRisk() > 1000000) {
// orange
color = "16744448";
}
ThumbnailEmbed image = ThumbnailEmbed.builder().url(ICON_URL + player.getWeapon() + ".png").build();
fieldList.add(FieldEmbed.builder().name("Risk").value(QuanreplacedyFormatter.quanreplacedyToRSDecimalStack(player.getRisk())).inline(true).build());
fieldList.add(FieldEmbed.builder().name("World").value(Integer.toString(client.getWorld())).inline(true).build());
fieldList.add(FieldEmbed.builder().name("Combat Level").value(Integer.toString(player.getPlayer().getCombatLevel())).inline(true).build());
if (client.getVar(Varbits.IN_WILDERNESS) == 1) {
fieldList.add(FieldEmbed.builder().name("Wildy Level").value(Integer.toString(player.getWildyLevel())).inline(true).build());
fieldList.add(FieldEmbed.builder().name("Location").value(player.getLocation()).inline(true).build());
}
fieldList.add(FieldEmbed.builder().name("Target").value(player.getTargetString()).inline(true).build());
if (config.outpureplacedems()) {
fieldList.add(FieldEmbed.builder().name("Risked Items Sorted by Value").value("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━").build());
int items = 0;
for (Map.Entry<Integer, Integer> entry : player.getRiskedGear().entrySet()) {
Integer gear = entry.getKey();
Integer value = entry.getValue();
if (value <= 0 || value <= config.minimumValue()) {
items++;
continue;
}
ItemStats item = itemManager.gereplacedemStats(gear, false);
String name = itemManager.gereplacedemComposition(gear).getName();
if (item == null) {
log.error("Item is Null: {}", gear);
continue;
}
fieldList.add(FieldEmbed.builder().name(name).value("Value: " + QuanreplacedyFormatter.quanreplacedyToRSDecimalStack(value)).inline(true).build());
}
if (items > 0) {
fieldList.add(FieldEmbed.builder().name("Items below value: " + config.minimumValue()).value(Integer.toString(items)).inline(true).build());
}
}
Map.Entry entry = getEntry(player.getGear());
String iconId = entry == null ? String.valueOf(1) : String.valueOf(entry.getKey());
String icon = ICON_URL + iconId + ".png";
String name = "☠️ " + player.getName() + " ☠️";
if (player.getPlayer().getSkullIcon() == null) {
name = player.getName();
}
message(name, icon, image, fieldList, color);
player.setScouted(true);
}
private void message(String name, String iconUrl, ThumbnailEmbed thumbnail, List<FieldEmbed> fields, String color) {
log.debug("Message Contents: {}, {}, {}, {}, {}", name, " ", thumbnail, Arrays.toString(fields.toArray()), config.webhook());
log.debug("Fields: {}", fields);
if (name.isEmpty() || fields.isEmpty()) {
log.debug("Discord message will fail with a missing name/description/field");
return;
}
final Date currentTime = new Date(System.currentTimeMillis());
DiscordEmbed discordEmbed = new DiscordEmbed(Autreplacedmbed.builder().icon_url(iconUrl).name(name).build(), thumbnail, " ", FooterEmbed.builder().icon_url("https://raw.githubusercontent.com/runelite/runelite/master/runelite-client/src/main/resources/net/runelite/client/plugins/hiscore/ultimate_ironman.png").text("Gabon Scouter | Time: " + SDF.format(currentTime)).build(), color, fields);
DiscordMessage discordMessage = discordEmbed.toDiscordMessage("Gabon Scouter", " ", "https://i.imgur.com/2A6dr7q.png");
DISCORD_CLIENT.message(this.webhook, discordMessage);
}
private static Map.Entry getEntry(LinkedHashMap<Integer, Integer> map) {
if (!map.isEmpty()) {
return map.entrySet().iterator().next();
}
return null;
}
}
18
Source : NeverLogoutPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Never Logout", enabledByDefault = false, description = "Overrides the 5 minute AFK logout timer.", tags = { "never log", "idle", "logout", "log", "never" })
public clreplaced NeverLogoutPlugin extends Plugin {
@Inject
private Client client;
@Subscribe
private void onGametick(GameTick gameTick) {
if (client.getKeyboardIdleTicks() > 14900) {
client.setKeyboardIdleTicks(0);
}
if (client.getMouseIdleTicks() > 14900) {
client.setMouseIdleTicks(0);
}
}
}
18
Source : LootAssistPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Loot replacedist Plugin", enabledByDefault = false, description = "Creates a tile overlay with a timer that counts down to when the loot will appear to you", tags = { "pklite", "loot", "looting", "loot replacedist", "replacedist", "loot replacedist" })
public clreplaced LootreplacedistPlugin extends Plugin {
@Inject
private OverlayManager overlayManager;
@Inject
private LootreplacedistOverlay lootreplacedistOverlay;
static final ConcurrentHashMap<WorldPoint, LootPile> lootPiles = new ConcurrentHashMap<>();
@Override
protected void startUp() {
overlayManager.add(lootreplacedistOverlay);
}
@Override
protected void shutDown() {
lootPiles.clear();
overlayManager.remove(lootreplacedistOverlay);
}
@Subscribe
private void onGameStateChanged(GameStateChanged event) {
lootPiles.clear();
}
@Subscribe
private void onAnimationChanged(AnimationChanged event) {
final Actor actor = event.getActor();
if (actor.getAnimation() == AnimationID.DEATH && actor instanceof Player) {
LootPile pile = new LootPile(actor.getWorldLocation(), actor.getName());
lootPiles.put(pile.getLocation(), pile);
}
}
}
18
Source : HydraPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Hydra Helper", enabledByDefault = false, description = "Overlays for normal Hydras.", tags = { "hydra", "helper", "baby", "small", "normal", "regular" })
public clreplaced HydraPlugin extends Plugin {
static final Set<HydraAnimation> VALID_HYDRA_ANIMATIONS = EnumSet.of(HydraAnimation.RANGE, HydraAnimation.MAGIC);
private static final String CONFIG_GROUP_NAME = "hydra";
private static final String CONFIG_ITEM_ATTACK_COUNTER = "attackCounterOverlay";
private static final String CONFIG_ITEM_PRAYER_OVERLAY = "prayerOverlay";
private static final String CONFIG_ITEM_POISON_PROJECTILE_OVERLAY = "poisonProjectileOverlay";
private static final String CONFIG_ITEM_BOLD_ATTACK_COUNTER_OVERLAY = "boldAttackCounterOverlay";
private static final String CONFIG_ITEM_MIRROR_MODE_COMPATABILITY = "mirrorMode";
private static final String NPC_NAME_HYDRA = "Hydra";
private static final int HYDRA_REGION_1 = 5279;
private static final int HYDRA_REGION_2 = 5280;
@Inject
private Client client;
@Inject
private HydraConfig hydraConfig;
@Inject
private OverlayManager overlayManager;
@Inject
private HydraAttackCounterOverlay hydraAttackCounterOverlay;
@Inject
private HydraPrayerOverlay hydraPrayerOverlay;
@Inject
private HydraPrayerAttackCounterOverlay hydraPrayerAttackCounterOverlay;
@Inject
private HydraPoisonOverlay hydraPoisonOverlay;
private final Map<Integer, Hydra> hydras = new HashMap<>();
private final Map<LocalPoint, Projectile> poisonProjectiles = new HashMap<>();
@Getter(AccessLevel.PACKAGE)
private NPC interactingNpc = null;
@Provides
HydraConfig provideConfig(final ConfigManager configManager) {
return configManager.getConfig(HydraConfig.clreplaced);
}
@Override
protected void startUp() {
if (hydraConfig.isAttackCounterOverlay()) {
overlayManager.add(hydraAttackCounterOverlay);
}
if (hydraConfig.isPrayerOverlay()) {
overlayManager.add(hydraPrayerOverlay);
overlayManager.add(hydraPrayerAttackCounterOverlay);
}
if (hydraConfig.isPoisonOverlay()) {
overlayManager.add(hydraPoisonOverlay);
}
hydraAttackCounterOverlay.setBoldAttackCounterOverlay(hydraConfig.isBoldAttackCounterOverlay());
hydraAttackCounterOverlay.setHydras(hydras);
hydraPrayerOverlay.setHydras(hydras);
hydraPrayerAttackCounterOverlay.setHydras(hydras);
hydraPoisonOverlay.setPoisonProjectiles(poisonProjectiles);
resetHydras();
poisonProjectiles.clear();
}
@Override
protected void shutDown() {
overlayManager.remove(hydraAttackCounterOverlay);
overlayManager.remove(hydraPrayerOverlay);
overlayManager.remove(hydraPrayerAttackCounterOverlay);
overlayManager.remove(hydraPoisonOverlay);
resetHydras();
poisonProjectiles.clear();
}
@Subscribe
private void onConfigChanged(final ConfigChanged event) {
if (!event.getGroup().equals(CONFIG_GROUP_NAME)) {
return;
}
final boolean newConfigValue = Boolean.parseBoolean(event.getNewValue());
switch(event.getKey()) {
case CONFIG_ITEM_ATTACK_COUNTER:
if (newConfigValue) {
overlayManager.add(hydraAttackCounterOverlay);
} else {
overlayManager.remove(hydraAttackCounterOverlay);
}
break;
case CONFIG_ITEM_PRAYER_OVERLAY:
if (newConfigValue) {
overlayManager.add(hydraPrayerOverlay);
overlayManager.add(hydraPrayerAttackCounterOverlay);
} else {
overlayManager.remove(hydraPrayerOverlay);
overlayManager.remove(hydraPrayerAttackCounterOverlay);
}
break;
case CONFIG_ITEM_POISON_PROJECTILE_OVERLAY:
if (newConfigValue) {
overlayManager.add(hydraPoisonOverlay);
} else {
overlayManager.remove(hydraPoisonOverlay);
}
break;
case CONFIG_ITEM_BOLD_ATTACK_COUNTER_OVERLAY:
hydraAttackCounterOverlay.setBoldAttackCounterOverlay(hydraConfig.isBoldAttackCounterOverlay());
break;
default:
break;
}
}
@Subscribe
private void onNpcSpawned(final NpcSpawned event) {
final NPC npc = event.getNpc();
if (isActorHydra(npc)) {
addHydra(npc);
}
}
@Subscribe
private void onNpcDespawned(final NpcDespawned event) {
final NPC npc = event.getNpc();
if (isActorHydra(npc)) {
removeHydra(npc);
poisonProjectiles.clear();
}
}
@Subscribe
private void onInteractingChanged(final InteractingChanged event) {
final Actor source = event.getSource();
if (!isActorHydra(source)) {
return;
}
final NPC npc = (NPC) source;
addHydra(npc);
updateInteractingNpc(npc);
}
@Subscribe
private void onAnimationChanged(final AnimationChanged event) {
final Actor actor = event.getActor();
if (!isActorHydra(actor)) {
return;
}
final NPC npc = (NPC) event.getActor();
addHydra(npc);
updateInteractingNpc(npc);
HydraAnimation hydraAnimation;
try {
hydraAnimation = HydraAnimation.fromId(npc.getAnimation());
} catch (final IllegalArgumentException e) {
hydraAnimation = null;
}
if (hydraAnimation == null || !VALID_HYDRA_ANIMATIONS.contains(hydraAnimation)) {
// If the animation is not range/magic then do nothing.
return;
}
final Hydra hydra = hydras.get(npc.getIndex());
if (hydra.getHydraAnimation() == null) {
// If this is the first observed animation then set it
hydra.setHydraAnimation(hydraAnimation);
} else {
if (!Objects.equals(hydra.getHydraAnimation(), hydraAnimation)) {
// If the animation switched from range/magic then set it and reset attack count
hydra.setHydraAnimation(hydraAnimation);
hydra.resetAttackCount();
}
}
hydra.updateAttackCount();
if (!poisonProjectiles.isEmpty()) {
updatePoisonProjectiles();
}
}
/**
* See net.runelite.client.plugins.alchemicalhydra.AlchemicalHydraPlugin
* Copyright (c) 2019, Lucas <https://github.com/lucwousin>
*
* @param event event object
*/
@Subscribe
private void onProjectileMoved(final ProjectileMoved event) {
if (interactingNpc == null || client.getGameCycle() >= event.getProjectile().getStartMovementCycle()) {
return;
}
final Projectile projectile = event.getProjectile();
final int projectileId = projectile.getId();
if (projectileId == ProjectileID.HYDRA_POISON) {
poisonProjectiles.put(event.getPosition(), projectile);
}
}
/**
* See net.runelite.client.plugins.alchemicalhydra.AlchemicalHydraPlugin
* Copyright (c) 2019, Lucas <https://github.com/lucwousin>
*/
private void updatePoisonProjectiles() {
final Set<LocalPoint> expiredPoisonProjectiles = new HashSet<>();
for (final Map.Entry<LocalPoint, Projectile> entry : poisonProjectiles.entrySet()) {
if (entry.getValue().getEndCycle() < client.getGameCycle()) {
expiredPoisonProjectiles.add(entry.getKey());
}
}
for (final LocalPoint projectileLocalPoint : expiredPoisonProjectiles) {
poisonProjectiles.remove(projectileLocalPoint);
}
}
boolean isPlayerAtHydraRegion() {
final Player player = client.getLocalPlayer();
if (player == null) {
return false;
}
final WorldPoint worldPoint = player.getWorldLocation();
if (worldPoint == null) {
return false;
}
final int regionId = worldPoint.getRegionID();
return regionId == HYDRA_REGION_1 || regionId == HYDRA_REGION_2;
}
private static boolean isActorHydra(final Actor actor) {
return Objects.equals(actor.getName(), NPC_NAME_HYDRA);
}
private void updateInteractingNpc(final NPC npc) {
if (!Objects.equals(interactingNpc, npc) && Objects.equals(npc.getInteracting(), client.getLocalPlayer())) {
interactingNpc = npc;
}
}
private void addHydra(final NPC npc) {
final int npcIndex = npc.getIndex();
if (!hydras.containsKey(npcIndex)) {
hydras.put(npcIndex, new Hydra(npc));
}
}
private void removeHydra(final NPC npc) {
final int npcIndex = npc.getIndex();
hydras.remove(npcIndex);
if (Objects.equals(interactingNpc, npc)) {
interactingNpc = null;
}
}
private void resetHydras() {
hydras.clear();
interactingNpc = null;
}
}
18
Source : HideUnderPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Hide Under", enabledByDefault = false, description = "Hide local player when under targeted players", tags = { "hide", "local", "player", "under" })
public clreplaced HideUnderPlugin extends Plugin {
@Inject
private Client client;
@Inject
HideUnderConfig config;
@Provides
HideUnderConfig provideConfig(ConfigManager configManager) {
return configManager.getConfig(HideUnderConfig.clreplaced);
}
@Override
protected void shutDown() {
client.setLocalPlayerHidden(false);
client.setRenderSelf(true);
}
@Subscribe
private void onGameStateChanged(GameStateChanged event) {
if (event.getGameState() == GameState.LOGGED_IN) {
client.setIsHidingEnreplacedies(true);
}
}
@Subscribe
private void onGameTick(GameTick event) {
if (client.getLocalPlayer() == null) {
return;
}
final WorldPoint localPlayerWp = WorldPoint.fromLocalInstance(client, client.getLocalPlayer().getLocalLocation());
final WorldPoint lp = client.getLocalPlayer().getWorldLocation();
boolean hide = false;
for (Player player : client.getPlayers()) {
if (player == client.getLocalPlayer()) {
continue;
}
if (client.getVarbitValue(5314) == 1) {
final WorldPoint playerWp = WorldPoint.fromLocalInstance(client, player.getLocalLocation());
if (localPlayerWp != null && localPlayerWp.distanceTo(playerWp) == 0) {
hide = true;
}
continue;
}
if (lp != null && player.getWorldLocation().distanceTo(lp) == 0) {
hide = true;
}
}
if (config.useRenderself()) {
client.setRenderSelf(!hide);
} else if (config.useEnreplacedyHider()) {
client.setLocalPlayerHidden(hide);
}
}
}
18
Source : GodbookPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Slf4j
@Extension
@PluginDescriptor(name = "Godbook", enabledByDefault = false, description = "Displays how long since someone preached.", tags = { "preach", "godbook" })
public clreplaced GodbookPlugin extends Plugin {
/* Thanks Caps lock 13 for his amazing work */
@Inject
private OverlayManager overlayManager;
@Inject
private GodbookOverlay overlay;
@Inject
private GodbookConfig config;
@Inject
private Client client;
@Getter
private ArrayList<String> names;
@Getter
private ArrayList<Integer> ticks;
@Getter
private boolean active;
private boolean isShowing;
private ArrayList<Integer> animationList;
@Provides
GodbookConfig provideConfig(ConfigManager configManager) {
return configManager.getConfig(GodbookConfig.clreplaced);
}
@Override
protected void startUp() {
active = false;
isShowing = false;
names = new ArrayList<>();
ticks = new ArrayList<>();
animationList = new ArrayList<>();
updateAnimationList();
}
@Override
protected void shutDown() {
overlayManager.remove(overlay);
isShowing = false;
}
@Subscribe
protected void onConfigChanged(ConfigChanged event) {
updateAnimationList();
}
private void updateAnimationList() {
String[] parsedAnimations = config.animations().split(",");
animationList.clear();
Arrays.stream(parsedAnimations).forEach(s -> {
try {
if (!Objects.equals(s, ""))
animationList.add(Integer.parseInt(s));
} catch (NumberFormatException e) {
log.warn("Failed to parse: " + s);
}
});
}
private void addPlayer(String name) {
active = true;
ticks.add(0);
names.add(name);
}
public void stop() {
active = false;
ticks.clear();
names.clear();
}
private boolean containsAnimation(int id) {
return animationList.contains(id);
}
public void increment() {
ArrayList<Integer> toRemove = IntStream.range(0, ticks.size()).filter(i -> ticks.get(i) > config.maxTicks() - 2).boxed().collect(Collectors.toCollection(ArrayList::new));
IntStream.range(0, ticks.size()).filter(toRemove::contains).forEach(i -> {
ticks.remove(i);
names.remove(i);
});
if (ticks.size() == 0) {
stop();
}
IntStream.range(0, ticks.size()).forEach(i -> {
int temp = ticks.get(i) + 1;
ticks.set(i, temp);
});
}
@Subscribe
public void onAnimationChanged(final AnimationChanged event) {
if ((config.verzikOnly() && inRegion(12611, 12612)) || !config.verzikOnly()) {
if (event.getActor().getAnimation() == 7155 || event.getActor().getAnimation() == 7154 || event.getActor().getAnimation() == 1336 || containsAnimation(event.getActor().getAnimation())) {
if (!active) {
overlayManager.add(overlay);
isShowing = true;
active = true;
}
addPlayer(event.getActor().getName());
}
}
}
@Subscribe
public void onGameTick(GameTick event) {
if (isShowing && ticks.size() == 0) {
overlayManager.remove(overlay);
isShowing = false;
}
if (active) {
increment();
}
}
public boolean inRegion(int... regions) {
if (client.getMapRegions() != null) {
return Arrays.stream(client.getMapRegions()).anyMatch(i -> Arrays.stream(regions).anyMatch(j -> i == j));
}
return false;
}
}
18
Source : EntityFocusPilePlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Enreplacedy FocusPile", enabledByDefault = false, description = "Bring player you are interacting with to the top of the pile.", tags = { "enreplacedy", "pile", "stack", "pvp", "focus", "dd" })
public clreplaced EnreplacedyFocusPilePlugin extends Plugin {
@Inject
private Client client;
@Subscribe
private void onGameTick(GameTick event) {
client.getPlayers().forEach((player) -> {
if (player.getAnimation() == -1 || player.getRSInteracting() != (client.getLocalPlayerIndex() + 32768)) {
return;
}
if (client.getVar(VarPlayer.ATTACKING_PLAYER) == -1) {
((RSClient) client).setLocalInteractingIndex(player.getPlayerId() & 2047);
}
});
}
}
18
Source : CastleWarsExtendedPlugin.java
with GNU General Public License v3.0
from xKylee
with GNU General Public License v3.0
from xKylee
@Extension
@PluginDescriptor(name = "Castle Wars Extended", description = "Overpowered Castle Wars Plugin", tags = { "castlewars", "minigame", "barricade", "npc" }, enabledByDefault = false)
@Slf4j
public clreplaced CastleWarsExtendedPlugin extends Plugin {
@Inject
private Client client;
@Inject
private CastleWarsExtendedConfig config;
@Inject
private OverlayManager overlayManager;
@Inject
private SceneOverlay SceneOverlay;
@Inject
private MinimapOverlay MinimapOverlay;
@Inject
private TindTimerOverlay TindTimerOverlay;
@Inject
private GameTimeOverlay GameTimeOverlay;
@Getter(AccessLevel.PACKAGE)
private GameObject saradominStandard;
@Getter(AccessLevel.PACKAGE)
private GameObject zamorakStandard;
@Getter(AccessLevel.PACKAGE)
private final List<WorldPoint> deSpawnedRocks = new ArrayList<>();
@Getter(AccessLevel.PACKAGE)
private final Set<GameObject> highlightRocks = new HashSet<>();
@Getter(AccessLevel.PACKAGE)
private final Map<WorldPoint, Barricade> litBarricades = new HashMap<>();
@Getter(AccessLevel.PACKAGE)
private Instant lastActionTime = Instant.ofEpochMilli(0);
@Getter(AccessLevel.PACKAGE)
private final Set<NPC> highlightBarricades = new HashSet<>();
public static int CASTLE_WARS = 9520;
public static int CASTLE_WARS_UNDERGROUND = 9620;
@Provides
CastleWarsExtendedConfig getConfig(ConfigManager configManager) {
return configManager.getConfig(CastleWarsExtendedConfig.clreplaced);
}
@Subscribe
public void onConfigChanged(ConfigChanged event) {
if (!event.getGroup().equals("castlewarsextended")) {
return;
}
if (!config.rocksHighlight()) {
highlightRocks.clear();
}
if (!config.useTindTimer()) {
litBarricades.clear();
}
rebuildAllHighlightBarricades();
TindTimerOverlay.updateConfig();
}
private void rebuildAllHighlightBarricades() {
highlightBarricades.clear();
if (client.getGameState() != GameState.LOGGED_IN && client.getGameState() != GameState.LOADING) {
return;
}
for (NPC npc : client.getNpcs()) {
switch(npc.getId()) {
case NpcID.BARRICADE:
case NpcID.BARRICADE_5724:
if (config.barricadeHighlight()) {
highlightBarricades.add(npc);
}
break;
}
}
}
@Override
protected void startUp() {
overlayManager.add(SceneOverlay);
overlayManager.add(MinimapOverlay);
overlayManager.add(TindTimerOverlay);
overlayManager.add(GameTimeOverlay);
TindTimerOverlay.updateConfig();
}
@Override
protected void shutDown() {
overlayManager.remove(SceneOverlay);
overlayManager.remove(MinimapOverlay);
overlayManager.remove(TindTimerOverlay);
overlayManager.remove(GameTimeOverlay);
lastActionTime = Instant.ofEpochMilli(0);
litBarricades.clear();
highlightBarricades.clear();
highlightRocks.clear();
deSpawnedRocks.clear();
}
@Subscribe
public void onGameStateChanged(final GameStateChanged event) {
if (event.getGameState() != GameState.LOGGED_IN) {
deSpawnedRocks.clear();
litBarricades.clear();
highlightBarricades.clear();
highlightRocks.clear();
saradominStandard = null;
zamorakStandard = null;
}
}
private boolean inCastleWars() {
Player localPlayer = client.getLocalPlayer();
return // 9520 = Castle Wars
localPlayer != null && localPlayer.getWorldLocation().getRegionID() >= CASTLE_WARS && // 9620 = Castle Wars underground
localPlayer.getWorldLocation().getRegionID() <= CASTLE_WARS_UNDERGROUND;
}
@Subscribe
public void onMenuEntryAdded(MenuEntryAdded menuEntryAdded) {
String option = Text.removeTags(menuEntryAdded.getOption()).toLowerCase();
String target = Text.standardize(menuEntryAdded.getTarget());
int identifier = menuEntryAdded.getIdentifier();
MenuEntry[] menuEntries = client.getMenuEntries();
if (config.hidePlayerOptions() && option.startsWith("use")) {
if (!inCastleWars() || target.contains("bandages")) {
return;
}
Player[] players = client.getCachedPlayers();
Player player = null;
if (identifier >= 0 && identifier < players.length) {
player = players[identifier];
}
if (player == null) {
return;
}
if (menuEntries.length > 0 && target.contains(player.getName().toLowerCase())) {
client.setMenuEntries(Arrays.copyOf(menuEntries, menuEntries.length - 1));
}
}
if (config.hideNpcOptions()) {
if (saradominStandard == null && zamorakStandard == null) {
return;
}
NPC[] npcs = client.getCachedNPCs();
NPC npc = null;
if (identifier >= 0 && identifier < npcs.length) {
npc = npcs[identifier];
}
if (npc == null) {
return;
}
if (saradominStandard.getLocalLocation().equals(npc.getLocalLocation()) || zamorakStandard.getLocalLocation().equals(npc.getLocalLocation())) {
if (menuEntries.length > 0) {
client.setMenuEntries(Arrays.copyOf(menuEntries, menuEntries.length - 1));
}
}
}
}
@Subscribe
public void onGameObjectSpawned(GameObjectSpawned event) {
final GameObject gameObject = event.getGameObject();
final Tile tile = event.getTile();
WorldPoint location = tile.getWorldLocation();
switch(gameObject.getId()) {
case ObjectID.SARADOMIN_STANDARD:
this.saradominStandard = gameObject;
log.debug("Saradomin flag spawn: {}", gameObject);
break;
case ObjectID.ZAMORAK_STANDARD:
this.zamorakStandard = gameObject;
log.debug("Zamorak flag spawn: {}", gameObject);
break;
// Underground rocks full
case ObjectID.ROCKS_4437:
case // Underground rocks half
ObjectID.ROCKS_4438:
if (config.rocksHighlight() && gameObject.getWorldLocation().getRegionID() == CASTLE_WARS_UNDERGROUND) {
highlightRocks.add(gameObject);
}
deSpawnedRocks.remove(location);
log.debug("Rock spawn: {}", gameObject);
break;
}
}
@Subscribe
public void onGameObjectChanged(GameObjectChanged event) {
final GameObject gameObject = event.getGameObject();
int id = gameObject.getId();
if (id == ObjectID.ROCKS_4437 || id == ObjectID.ROCKS_4438) {
highlightRocks.add(gameObject);
}
}
@Subscribe
public void onGameObjectDespawned(GameObjectDespawned event) {
final GameObject gameObject = event.getGameObject();
final Tile tile = event.getTile();
WorldPoint location = tile.getWorldLocation();
switch(gameObject.getId()) {
case ObjectID.SARADOMIN_STANDARD:
this.saradominStandard = null;
break;
case ObjectID.ZAMORAK_STANDARD:
this.zamorakStandard = null;
break;
case ObjectID.ROCKS_4438:
case ObjectID.ROCKS_4437:
deSpawnedRocks.add(location);
highlightRocks.remove(gameObject);
break;
}
}
@Subscribe
public void onGameTick(GameTick tick) {
if (client.getLocalPlayer() == null || client.getLocalPlayer().getWorldLocation().getRegionID() != CASTLE_WARS_UNDERGROUND && !highlightRocks.isEmpty()) {
highlightRocks.clear();
}
Iterator<Map.Entry<WorldPoint, Barricade>> it = litBarricades.entrySet().iterator();
Tile[][][] tiles = client.getScene().getTiles();
Instant expire = Instant.now().plusSeconds(7);
while (it.hasNext()) {
Map.Entry<WorldPoint, Barricade> entry = it.next();
Barricade cade = entry.getValue();
WorldPoint world = entry.getKey();
LocalPoint local = LocalPoint.fromWorld(client, world);
if (local == null) {
if (cade.getLitOn().isBefore(expire)) {
it.remove();
}
}
}
}
@Subscribe
public void onNpcSpawned(NpcSpawned npcSpawned) {
if (!config.barricadeHighlight()) {
return;
}
NPC npc = npcSpawned.getNpc();
switch(npc.getId()) {
case NpcID.BARRICADE:
case NpcID.BARRICADE_5723:
highlightBarricades.add(npc);
log.debug("Saradomin barricade spawn: {}", npc);
break;
case NpcID.BARRICADE_5724:
case NpcID.BARRICADE_5725:
highlightBarricades.add(npc);
log.debug("Zamorak barricade spawn: {}", npc);
break;
}
}
@Subscribe
public void onNpcChanged(NpcChanged npcChanged) {
NPC npc = npcChanged.getNpc();
final WorldPoint npcLocation = npc.getWorldLocation();
switch(npc.getId()) {
case NpcID.BARRICADE_5723:
case NpcID.BARRICADE_5725:
if (config.barricadeHighlight()) {
highlightBarricades.add(npc);
}
if (config.useTindTimer()) {
litBarricades.put(npcLocation, new Barricade(npc));
lastActionTime = Instant.now();
}
break;
case NpcID.BARRICADE:
case NpcID.BARRICADE_5724:
litBarricades.remove(npcLocation);
break;
}
}
@Subscribe
public void onNpcDespawned(NpcDespawned npcDespawned) {
NPC npc = npcDespawned.getNpc();
final WorldPoint npcLocation = npc.getWorldLocation();
switch(npc.getId()) {
case NpcID.BARRICADE:
case NpcID.BARRICADE_5724:
highlightBarricades.remove(npc);
break;
case NpcID.BARRICADE_5723:
case NpcID.BARRICADE_5725:
highlightBarricades.remove(npc);
litBarricades.remove(npcLocation);
break;
}
}
}
18
Source : StealingArtefactsPlugin.java
with GNU General Public License v3.0
from open-osrs
with GNU General Public License v3.0
from open-osrs
@Extension
@PluginDescriptor(name = "Stealing Artefacts", enabledByDefault = false, description = "A plugin for the Stealing Artefacts minigame.", tags = { "stealing", "artefacts", "artifacts", "thieving", "minigame", "zeah" })
@Slf4j
@Singleton
public clreplaced StealingArtefactsPlugin extends Plugin {
private static final String HOUSE_TEXT = "^You need to recover an artefact for me\\. It can be found in the " + "([a-zA-Z\\-]+) house in the residential district over on the west side of town\\.$";
private static final String HOUSE_TEXT_PREFIX = HOUSE_TEXT.substring(1, 31);
private static final Pattern HOUSE_TEXT_PATTERN = Pattern.compile(HOUSE_TEXT);
private static final String CONFIG_GROUP_NAME = "stealingartefacts";
private static final String CONFIG_ITEM_NAME_INFOBOX = "houseInfoBox";
private static final String CONFIG_ITEM_NAME_HINT_ARROW = "displayHintArrow";
private static final String NPC_NAME_CAPTAIN_KHALED = "Captain Khaled";
private static final Set<Integer> REGION_IDS = Set.of(6970, 6971, 7226, 7227);
private static final int REGION_ID_HOUSE = 6970;
private static final int REGION_ID_CAPTAIN_KHALED = 7226;
private static final Set<Integer> ARTEFACTS = Set.of(ItemID.STOLEN_PENDANT, ItemID.STOLEN_GARNET_RING, ItemID.STOLEN_CIRCLET, ItemID.STOLEN_FAMILY_HEIRLOOM, ItemID.STOLEN_JEWELRY_BOX);
private boolean displayHouseInfoBox = false;
private boolean displayHintArrow = false;
@Getter(AccessLevel.PACKAGE)
private StealingArtefactsHouse stealingArtefactsHouse = StealingArtefactsHouse.CAPTAIN_KHALED;
private StealingArtefactsInfoBox stealingArtefactsInfoBox;
@Inject
private Client client;
@Inject
private ClientThread clientThread;
@Inject
private InfoBoxManager infoBoxManager;
@Inject
private ItemManager itemManager;
@Inject
private WorldMapPointManager worldMapPointManager;
@Inject
private StealingArtefactsConfig stealingArtefactsConfig;
@Provides
StealingArtefactsConfig getStealingArtefactsConfig(ConfigManager configManager) {
return configManager.getConfig(StealingArtefactsConfig.clreplaced);
}
@Override
protected void startUp() {
initConfig();
if (displayHouseInfoBox) {
addHouseInfoBox();
} else {
removeHouseInfoBox();
}
removeWorldMapPoint();
removeHintArrow();
if (displayHintArrow) {
addWorldMapPoint();
addHintArrow();
}
}
@Override
protected void shutDown() {
resetHouse();
removeHouseInfoBox();
removeWorldMapPoint();
removeHintArrow();
}
@Subscribe
private void onConfigChanged(ConfigChanged event) {
if (event.getGroup().equals(CONFIG_GROUP_NAME)) {
initConfig();
switch(event.getKey()) {
case CONFIG_ITEM_NAME_INFOBOX:
if (displayHouseInfoBox) {
addHouseInfoBox();
} else {
removeHouseInfoBox();
}
break;
case CONFIG_ITEM_NAME_HINT_ARROW:
removeWorldMapPoint();
removeHintArrow();
if (displayHintArrow) {
addWorldMapPoint();
addHintArrow();
}
break;
default:
break;
}
}
}
@Subscribe
private void onWidgetLoaded(WidgetLoaded widgetLoaded) {
if (isConfigSettingEnabled() && widgetLoaded.getGroupId() == WidgetID.DIALOG_NPC_GROUP_ID && isPlayerInRegion(REGION_ID_CAPTAIN_KHALED)) {
clientThread.invokeLater(this::updateStealingArtefactsHouse);
}
}
@Subscribe
private void onItemContainerChanged(ItemContainerChanged event) {
if (isConfigSettingEnabled() && !stealingArtefactsHouse.equals(StealingArtefactsHouse.CAPTAIN_KHALED) && event.getContainerId() == InventoryID.INVENTORY.getId() && isPlayerInRegion(REGION_ID_HOUSE) && containsArtefact(event.gereplacedemContainer())) {
resetHouse();
removeWorldMapPoint();
removeHintArrow();
if (displayHintArrow) {
addWorldMapPoint();
addHintArrow();
}
}
}
@Subscribe
private void onNpcSpawned(NpcSpawned event) {
NPC npc = event.getNpc();
if (displayHintArrow && Objects.equals(npc.getName(), NPC_NAME_CAPTAIN_KHALED) && stealingArtefactsHouse.equals(StealingArtefactsHouse.CAPTAIN_KHALED) && !client.getHintArrowType().equals(HintArrowType.NPC)) {
removeHintArrow();
client.setHintArrow(npc);
}
}
@Subscribe
private void onGameStateChanged(GameStateChanged event) {
if (displayHintArrow && event.getGameState().equals(GameState.LOGGED_IN)) {
removeWorldMapPoint();
removeHintArrow();
addWorldMapPoint();
addHintArrow();
}
}
private void initConfig() {
displayHouseInfoBox = stealingArtefactsConfig.displayHouseInfoBox();
displayHintArrow = stealingArtefactsConfig.displayHintArrow();
}
/**
* Parses any existing npc dialog widget text and updates the artefact house and hint arrows if applicable.
*/
private void updateStealingArtefactsHouse() {
Widget widgetDialogNpcText = client.getWidget(WidgetInfo.DIALOG_NPC_TEXT);
if (widgetDialogNpcText == null) {
return;
}
String text = widgetDialogNpcText.getText();
if (!text.startsWith(HOUSE_TEXT_PREFIX)) {
return;
}
StealingArtefactsHouse stealingArtefactsHouse = getStealingArtefactsHouseFromNpcDialogText(Text.sanitizeMultilineText(text));
if (stealingArtefactsHouse == null) {
return;
}
this.stealingArtefactsHouse = stealingArtefactsHouse;
removeWorldMapPoint();
removeHintArrow();
if (displayHintArrow) {
addWorldMapPoint();
addHintArrow();
}
}
private StealingArtefactsHouse getStealingArtefactsHouseFromNpcDialogText(String text) {
StealingArtefactsHouse stealingArtefactsHouse = null;
Matcher matcher = HOUSE_TEXT_PATTERN.matcher(text);
if (matcher.find()) {
String houseName = matcher.group(1);
try {
stealingArtefactsHouse = StealingArtefactsHouse.fromName(houseName);
} catch (IllegalArgumentException e) {
log.debug("Unsupported StealingArtefactsHouse name: {}", houseName);
}
}
return stealingArtefactsHouse;
}
private boolean containsArtefact(ItemContainer itemContainer) {
boolean containsArtefact = false;
for (Item item : itemContainer.gereplacedems()) {
int itemId = item.getId();
if (ARTEFACTS.contains(itemId)) {
containsArtefact = true;
break;
}
}
return containsArtefact;
}
private void addHouseInfoBox() {
if (stealingArtefactsInfoBox == null) {
stealingArtefactsInfoBox = new StealingArtefactsInfoBox(itemManager.getImage(ItemID.HAIR_CLIP), this);
infoBoxManager.addInfoBox(stealingArtefactsInfoBox);
}
}
private void removeHouseInfoBox() {
if (stealingArtefactsInfoBox != null) {
infoBoxManager.removeInfoBox(stealingArtefactsInfoBox);
stealingArtefactsInfoBox = null;
}
}
private void addHintArrow() {
if (stealingArtefactsHouse == StealingArtefactsHouse.CAPTAIN_KHALED) {
for (NPC npc : client.getCachedNPCs()) {
if (npc == null) {
continue;
}
if (Objects.equals(npc.getName(), NPC_NAME_CAPTAIN_KHALED)) {
client.setHintArrow(npc);
return;
}
}
}
client.setHintArrow(stealingArtefactsHouse.getWorldPoint());
}
private void removeHintArrow() {
if (client.hasHintArrow()) {
client.clearHintArrow();
}
}
private void addWorldMapPoint() {
if (isPlayerInStealingArtefactsRegion()) {
StealingArtefactsWorldMapPoint stealingArtefactsWorldMapPoint = new StealingArtefactsWorldMapPoint(stealingArtefactsHouse.getWorldPoint(), itemManager.getImage(ItemID.HAIR_CLIP));
stealingArtefactsWorldMapPoint.setTooltip(stealingArtefactsHouse.toString());
worldMapPointManager.add(stealingArtefactsWorldMapPoint);
}
}
private void removeWorldMapPoint() {
worldMapPointManager.removeIf(StealingArtefactsWorldMapPoint.clreplaced::isInstance);
}
private boolean isPlayerInStealingArtefactsRegion() {
Player player = client.getLocalPlayer();
if (player == null) {
return false;
}
WorldPoint worldPoint = player.getWorldLocation();
if (worldPoint == null) {
return false;
}
return REGION_IDS.contains(worldPoint.getRegionID());
}
private boolean isPlayerInRegion(int regionId) {
Player player = client.getLocalPlayer();
if (player == null) {
return false;
}
WorldPoint worldPoint = player.getWorldLocation();
if (worldPoint == null) {
return false;
}
return worldPoint.getRegionID() == regionId;
}
private boolean isConfigSettingEnabled() {
return displayHouseInfoBox || displayHintArrow;
}
private void resetHouse() {
stealingArtefactsHouse = StealingArtefactsHouse.CAPTAIN_KHALED;
}
}
18
Source : ShayzienInfirmaryPlugin.java
with GNU General Public License v3.0
from open-osrs
with GNU General Public License v3.0
from open-osrs
@Extension
@PluginDescriptor(name = "Shayzien Infirmary", enabledByDefault = false, description = "Shows the status of wounded soldiers", tags = { "shayzien", "infirmary", "soldiers" })
public clreplaced ShayzienInfirmaryPlugin extends Plugin {
@Getter(AccessLevel.PACKAGE)
private List<NPC> unhealedSoldiers = new ArrayList<>();
@Inject
private OverlayManager overlayManager;
@Inject
private Client client;
@Inject
private ShayzienInfirmaryOverlay overlay;
@Override
protected void startUp() {
loadPlugin();
}
@Override
protected void shutDown() {
unloadPlugin();
}
private void loadPlugin() {
overlayManager.add(overlay);
}
private void unloadPlugin() {
overlayManager.remove(overlay);
}
@Subscribe
private void onGameTick(GameTick event) {
if (isNotAtInfirmary()) {
return;
}
unhealedSoldiers.clear();
for (NPC npc : client.getNpcs()) {
if (isUnhealedSoldierId(npc.getId())) {
unhealedSoldiers.add(npc);
}
}
}
private boolean isSoldierId(int npcId) {
return (npcId >= 6826 && npcId <= 6857);
}
private boolean isUnhealedSoldierId(int npcId) {
return (isSoldierId(npcId) && npcId % 2 == 0);
}
boolean isNotAtInfirmary() {
return client.getLocalPlayer().getWorldLocation().getRegionID() != 6200;
}
}
See More Examples