diff --git a/src/Client/WikiURL.java b/src/Client/WikiURL.java index eccc863b..5b1b7896 100644 --- a/src/Client/WikiURL.java +++ b/src/Client/WikiURL.java @@ -53,6 +53,16 @@ public static String getURL() throws IllegalArgumentException { return url.append(utm_source).toString(); } + public static String getURL(String... query) throws IllegalArgumentException { + StringBuilder url = new StringBuilder(wikiPrefix); + for (String q : query) { + url.append(q); + url.append("+"); + } + url.setLength(url.length() - 1); + return url.append(utm_source).toString(); + } + public static boolean shouldConsume() { return nextClickIsLookup && !MouseHandler.rightClick; } diff --git a/src/Game/Client.java b/src/Game/Client.java index 6469c9b0..926e1299 100644 --- a/src/Game/Client.java +++ b/src/Game/Client.java @@ -32,6 +32,7 @@ import Client.Speedrun; import Client.TwitchIRC; import Client.Util; +import Client.WikiURL; import Client.WorldMapWindow; import Replay.game.constants.Game.ItemAction; import java.applet.Applet; @@ -52,13 +53,7 @@ import java.net.URL; import java.net.URLConnection; import java.net.UnknownHostException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; +import java.util.*; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import javax.swing.JOptionPane; @@ -2186,6 +2181,20 @@ private static String processClientChatCommand(String line) { + "."; } } + } else if (command.startsWith("wiki")) { + final String[] args = command.split(" "); + final String[] query = Arrays.copyOfRange(command.split(" "), 1, args.length); + if (System.currentTimeMillis() - WikiURL.lastLookupTime > WikiURL.cooldownTimer) { + String wikiURL = WikiURL.getURL(query); + WikiURL.lastLookupTime = System.currentTimeMillis(); + Util.openLinkInBrowser(wikiURL); + } else { + Client.displayMessage( + String.format( + "@lre@Please wait %1d seconds between wiki queries", + WikiURL.cooldownTimer / 1000), + Client.CHAT_NONE); + } } for (int skill = 0; skill < NUM_SKILLS; skill++) {