Merge pull request #5992 from deathbeam/discord-raids
Add raiding activity to Discord plugin
This commit is contained in:
@@ -29,5 +29,6 @@ enum DiscordAreaType
|
|||||||
BOSSES,
|
BOSSES,
|
||||||
CITIES,
|
CITIES,
|
||||||
DUNGEONS,
|
DUNGEONS,
|
||||||
MINIGAMES;
|
MINIGAMES,
|
||||||
|
RAIDS
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -107,4 +107,15 @@ public interface DiscordConfig extends Config
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ConfigItem(
|
||||||
|
keyName = "showRaidingActivity",
|
||||||
|
name = "Show activity at raids",
|
||||||
|
description = "Configures if your activity at raids should be shown.",
|
||||||
|
position = 8
|
||||||
|
)
|
||||||
|
default boolean showRaidingActivity()
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,11 +25,15 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.client.plugins.discord;
|
package net.runelite.client.plugins.discord;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.Skill;
|
import net.runelite.api.Skill;
|
||||||
|
import net.runelite.api.Varbits;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
@@ -237,14 +241,25 @@ enum DiscordGameEventType
|
|||||||
MG_TROUBLE_BREWING("Trouble Brewing", DiscordAreaType.MINIGAMES, 15150),
|
MG_TROUBLE_BREWING("Trouble Brewing", DiscordAreaType.MINIGAMES, 15150),
|
||||||
MG_TZHAAR_FIGHT_CAVES("Tzhaar Fight Caves", DiscordAreaType.MINIGAMES, 9551),
|
MG_TZHAAR_FIGHT_CAVES("Tzhaar Fight Caves", DiscordAreaType.MINIGAMES, 9551),
|
||||||
MG_TZHAAR_FIGHT_PITS("Tzhaar Fight Pits", DiscordAreaType.MINIGAMES, 9552),
|
MG_TZHAAR_FIGHT_PITS("Tzhaar Fight Pits", DiscordAreaType.MINIGAMES, 9552),
|
||||||
MG_VOLCANIC_MINE("Volcanic Mine", DiscordAreaType.MINIGAMES, 15263, 15262);
|
MG_VOLCANIC_MINE("Volcanic Mine", DiscordAreaType.MINIGAMES, 15263, 15262),
|
||||||
|
|
||||||
|
// Raids
|
||||||
|
RAIDS_CHAMBERS_OF_XERIC("Chambers of Xeric", DiscordAreaType.RAIDS, Varbits.IN_RAID),
|
||||||
|
RAIDS_THEATRE_OF_BLOOD("Theatre of Blood", DiscordAreaType.RAIDS, Varbits.THEATRE_OF_BLOOD);
|
||||||
|
|
||||||
private static final Map<Integer, DiscordGameEventType> FROM_REGION = new HashMap<>();
|
private static final Map<Integer, DiscordGameEventType> FROM_REGION = new HashMap<>();
|
||||||
|
private static final List<DiscordGameEventType> FROM_VARBITS = new ArrayList<>();
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
for (DiscordGameEventType discordGameEventType : DiscordGameEventType.values())
|
for (DiscordGameEventType discordGameEventType : DiscordGameEventType.values())
|
||||||
{
|
{
|
||||||
|
if (discordGameEventType.getVarbits() != null)
|
||||||
|
{
|
||||||
|
FROM_VARBITS.add(discordGameEventType);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (discordGameEventType.getRegionIds() == null)
|
if (discordGameEventType.getRegionIds() == null)
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
@@ -266,6 +281,7 @@ enum DiscordGameEventType
|
|||||||
private boolean shouldTimeout;
|
private boolean shouldTimeout;
|
||||||
|
|
||||||
private DiscordAreaType discordAreaType;
|
private DiscordAreaType discordAreaType;
|
||||||
|
private Varbits varbits;
|
||||||
private int[] regionIds;
|
private int[] regionIds;
|
||||||
|
|
||||||
DiscordGameEventType(Skill skill)
|
DiscordGameEventType(Skill skill)
|
||||||
@@ -298,6 +314,15 @@ enum DiscordGameEventType
|
|||||||
this.shouldClear = true;
|
this.shouldClear = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DiscordGameEventType(String areaName, DiscordAreaType areaType, Varbits varbits)
|
||||||
|
{
|
||||||
|
this.details = exploring(areaType, areaName);
|
||||||
|
this.priority = -2;
|
||||||
|
this.discordAreaType = areaType;
|
||||||
|
this.varbits = varbits;
|
||||||
|
this.shouldClear = true;
|
||||||
|
}
|
||||||
|
|
||||||
private static String training(final Skill skill)
|
private static String training(final Skill skill)
|
||||||
{
|
{
|
||||||
return training(skill.getName());
|
return training(skill.getName());
|
||||||
@@ -330,6 +355,8 @@ enum DiscordGameEventType
|
|||||||
return "Location: " + areaName;
|
return "Location: " + areaName;
|
||||||
case MINIGAMES:
|
case MINIGAMES:
|
||||||
return "Playing: " + areaName;
|
return "Playing: " + areaName;
|
||||||
|
case RAIDS:
|
||||||
|
return "Raiding: " + areaName;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
@@ -369,4 +396,17 @@ enum DiscordGameEventType
|
|||||||
{
|
{
|
||||||
return FROM_REGION.get(regionId);
|
return FROM_REGION.get(regionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static DiscordGameEventType fromVarbit(final Client client)
|
||||||
|
{
|
||||||
|
for (DiscordGameEventType fromVarbit : FROM_VARBITS)
|
||||||
|
{
|
||||||
|
if (client.getVar(fromVarbit.getVarbits()) != 0)
|
||||||
|
{
|
||||||
|
return fromVarbit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ import net.runelite.api.coords.WorldPoint;
|
|||||||
import net.runelite.api.events.ConfigChanged;
|
import net.runelite.api.events.ConfigChanged;
|
||||||
import net.runelite.api.events.ExperienceChanged;
|
import net.runelite.api.events.ExperienceChanged;
|
||||||
import net.runelite.api.events.GameStateChanged;
|
import net.runelite.api.events.GameStateChanged;
|
||||||
|
import net.runelite.api.events.VarbitChanged;
|
||||||
import net.runelite.client.RuneLiteProperties;
|
import net.runelite.client.RuneLiteProperties;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
@@ -159,6 +160,22 @@ public class DiscordPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onVarbitChanged(VarbitChanged event)
|
||||||
|
{
|
||||||
|
if (!config.showRaidingActivity())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final DiscordGameEventType discordGameEventType = DiscordGameEventType.fromVarbit(client);
|
||||||
|
|
||||||
|
if (discordGameEventType != null)
|
||||||
|
{
|
||||||
|
discordState.triggerEvent(discordGameEventType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Schedule(
|
@Schedule(
|
||||||
period = 1,
|
period = 1,
|
||||||
unit = ChronoUnit.MINUTES
|
unit = ChronoUnit.MINUTES
|
||||||
|
|||||||
Reference in New Issue
Block a user