clue plugin: add clue dev command
This commit is contained in:
@@ -41,6 +41,8 @@ import java.util.List;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
|
import joptsimple.internal.Strings;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.ChatMessageType;
|
import net.runelite.api.ChatMessageType;
|
||||||
@@ -61,7 +63,7 @@ import net.runelite.api.TileObject;
|
|||||||
import net.runelite.api.coords.LocalPoint;
|
import net.runelite.api.coords.LocalPoint;
|
||||||
import net.runelite.api.coords.WorldPoint;
|
import net.runelite.api.coords.WorldPoint;
|
||||||
import net.runelite.api.events.ChatMessage;
|
import net.runelite.api.events.ChatMessage;
|
||||||
import net.runelite.client.events.ConfigChanged;
|
import net.runelite.api.events.CommandExecuted;
|
||||||
import net.runelite.api.events.GameStateChanged;
|
import net.runelite.api.events.GameStateChanged;
|
||||||
import net.runelite.api.events.GameTick;
|
import net.runelite.api.events.GameTick;
|
||||||
import net.runelite.api.events.ItemContainerChanged;
|
import net.runelite.api.events.ItemContainerChanged;
|
||||||
@@ -74,6 +76,7 @@ import net.runelite.api.widgets.WidgetID;
|
|||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
|
import net.runelite.client.events.ConfigChanged;
|
||||||
import net.runelite.client.game.ItemManager;
|
import net.runelite.client.game.ItemManager;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
@@ -165,6 +168,10 @@ public class ClueScrollPlugin extends Plugin
|
|||||||
@Inject
|
@Inject
|
||||||
private WorldMapPointManager worldMapPointManager;
|
private WorldMapPointManager worldMapPointManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Named("developerMode")
|
||||||
|
boolean developerMode;
|
||||||
|
|
||||||
private BufferedImage emoteImage;
|
private BufferedImage emoteImage;
|
||||||
private BufferedImage mapArrow;
|
private BufferedImage mapArrow;
|
||||||
private Integer clueItemId;
|
private Integer clueItemId;
|
||||||
@@ -409,9 +416,13 @@ public class ClueScrollPlugin extends Plugin
|
|||||||
resetClue(true);
|
resetClue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we have a clue, save that knowledge
|
final Widget clueScrollText = client.getWidget(WidgetInfo.CLUE_SCROLL_TEXT);
|
||||||
// so the clue window doesn't have to be open.
|
|
||||||
updateClue(findClueScroll());
|
if (clueScrollText != null)
|
||||||
|
{
|
||||||
|
ClueScroll clueScroll = findClueScroll(clueScrollText.getText());
|
||||||
|
updateClue(clueScroll);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@@ -426,6 +437,18 @@ public class ClueScrollPlugin extends Plugin
|
|||||||
updateClue(BeginnerMapClue.forWidgetID(event.getGroupId()));
|
updateClue(BeginnerMapClue.forWidgetID(event.getGroupId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
public void onCommandExecuted(CommandExecuted commandExecuted)
|
||||||
|
{
|
||||||
|
if (developerMode && commandExecuted.getCommand().equals("clue"))
|
||||||
|
{
|
||||||
|
String text = Strings.join(commandExecuted.getArguments(), " ");
|
||||||
|
ClueScroll clueScroll = findClueScroll(text);
|
||||||
|
log.debug("Found clue scroll for '{}': {}", text, clueScroll);
|
||||||
|
updateClue(clueScroll);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public BufferedImage getClueScrollImage()
|
public BufferedImage getClueScrollImage()
|
||||||
{
|
{
|
||||||
return itemManager.getImage(ItemID.CLUE_SCROLL_MASTER);
|
return itemManager.getImage(ItemID.CLUE_SCROLL_MASTER);
|
||||||
@@ -483,17 +506,10 @@ public class ClueScrollPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private ClueScroll findClueScroll()
|
private ClueScroll findClueScroll(String rawText)
|
||||||
{
|
{
|
||||||
final Widget clueScrollText = client.getWidget(WidgetInfo.CLUE_SCROLL_TEXT);
|
|
||||||
|
|
||||||
if (clueScrollText == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove line breaks and also the rare occasion where there are double line breaks
|
// Remove line breaks and also the rare occasion where there are double line breaks
|
||||||
final String text = Text.sanitizeMultilineText(clueScrollText.getText()).toLowerCase();
|
final String text = Text.sanitizeMultilineText(rawText).toLowerCase();
|
||||||
|
|
||||||
// Early return if this is same clue as already existing one
|
// Early return if this is same clue as already existing one
|
||||||
if (clue instanceof TextClueScroll)
|
if (clue instanceof TextClueScroll)
|
||||||
@@ -506,7 +522,7 @@ public class ClueScrollPlugin extends Plugin
|
|||||||
|
|
||||||
if (text.startsWith("i'd like to hear some music."))
|
if (text.startsWith("i'd like to hear some music."))
|
||||||
{
|
{
|
||||||
return MusicClue.forText(clueScrollText.getText());
|
return MusicClue.forText(rawText);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text.contains("degrees") && text.contains("minutes"))
|
if (text.contains("degrees") && text.contains("minutes"))
|
||||||
@@ -561,7 +577,7 @@ public class ClueScrollPlugin extends Plugin
|
|||||||
return hotColdClue;
|
return hotColdClue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final SkillChallengeClue skillChallengeClue = SkillChallengeClue.forText(text, clueScrollText.getText());
|
final SkillChallengeClue skillChallengeClue = SkillChallengeClue.forText(text, rawText);
|
||||||
|
|
||||||
if (skillChallengeClue != null)
|
if (skillChallengeClue != null)
|
||||||
{
|
{
|
||||||
@@ -569,7 +585,7 @@ public class ClueScrollPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// three step cryptic clues need unedited text to check which steps are already done
|
// three step cryptic clues need unedited text to check which steps are already done
|
||||||
final ThreeStepCrypticClue threeStepCrypticClue = ThreeStepCrypticClue.forText(text, clueScrollText.getText());
|
final ThreeStepCrypticClue threeStepCrypticClue = ThreeStepCrypticClue.forText(text, rawText);
|
||||||
|
|
||||||
if (threeStepCrypticClue != null)
|
if (threeStepCrypticClue != null)
|
||||||
{
|
{
|
||||||
@@ -577,7 +593,7 @@ public class ClueScrollPlugin extends Plugin
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We have unknown clue, reset
|
// We have unknown clue, reset
|
||||||
log.warn("Encountered unhandled clue text: {}", clueScrollText.getText());
|
log.warn("Encountered unhandled clue text: {}", rawText);
|
||||||
resetClue(true);
|
resetClue(true);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -748,6 +764,8 @@ public class ClueScrollPlugin extends Plugin
|
|||||||
|
|
||||||
resetClue(false);
|
resetClue(false);
|
||||||
checkClueNPCs(clue, client.getCachedNPCs());
|
checkClueNPCs(clue, client.getCachedNPCs());
|
||||||
|
// If we have a clue, save that knowledge
|
||||||
|
// so the clue window doesn't have to be open.
|
||||||
this.clue = clue;
|
this.clue = clue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user