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.stream.Stream;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
import joptsimple.internal.Strings;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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.WorldPoint;
|
||||
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.GameTick;
|
||||
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.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.events.ConfigChanged;
|
||||
import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
@@ -165,6 +168,10 @@ public class ClueScrollPlugin extends Plugin
|
||||
@Inject
|
||||
private WorldMapPointManager worldMapPointManager;
|
||||
|
||||
@Inject
|
||||
@Named("developerMode")
|
||||
boolean developerMode;
|
||||
|
||||
private BufferedImage emoteImage;
|
||||
private BufferedImage mapArrow;
|
||||
private Integer clueItemId;
|
||||
@@ -409,9 +416,13 @@ public class ClueScrollPlugin extends Plugin
|
||||
resetClue(true);
|
||||
}
|
||||
|
||||
// If we have a clue, save that knowledge
|
||||
// so the clue window doesn't have to be open.
|
||||
updateClue(findClueScroll());
|
||||
final Widget clueScrollText = client.getWidget(WidgetInfo.CLUE_SCROLL_TEXT);
|
||||
|
||||
if (clueScrollText != null)
|
||||
{
|
||||
ClueScroll clueScroll = findClueScroll(clueScrollText.getText());
|
||||
updateClue(clueScroll);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -426,6 +437,18 @@ public class ClueScrollPlugin extends Plugin
|
||||
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()
|
||||
{
|
||||
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
|
||||
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
|
||||
if (clue instanceof TextClueScroll)
|
||||
@@ -506,7 +522,7 @@ public class ClueScrollPlugin extends Plugin
|
||||
|
||||
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"))
|
||||
@@ -561,7 +577,7 @@ public class ClueScrollPlugin extends Plugin
|
||||
return hotColdClue;
|
||||
}
|
||||
|
||||
final SkillChallengeClue skillChallengeClue = SkillChallengeClue.forText(text, clueScrollText.getText());
|
||||
final SkillChallengeClue skillChallengeClue = SkillChallengeClue.forText(text, rawText);
|
||||
|
||||
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
|
||||
final ThreeStepCrypticClue threeStepCrypticClue = ThreeStepCrypticClue.forText(text, clueScrollText.getText());
|
||||
final ThreeStepCrypticClue threeStepCrypticClue = ThreeStepCrypticClue.forText(text, rawText);
|
||||
|
||||
if (threeStepCrypticClue != null)
|
||||
{
|
||||
@@ -577,7 +593,7 @@ public class ClueScrollPlugin extends Plugin
|
||||
}
|
||||
|
||||
// We have unknown clue, reset
|
||||
log.warn("Encountered unhandled clue text: {}", clueScrollText.getText());
|
||||
log.warn("Encountered unhandled clue text: {}", rawText);
|
||||
resetClue(true);
|
||||
return null;
|
||||
}
|
||||
@@ -748,6 +764,8 @@ public class ClueScrollPlugin extends Plugin
|
||||
|
||||
resetClue(false);
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user