Revert "Prevented returning bestMatch as searched items"

This reverts commit 3788c3f0
This commit is contained in:
Salmonllama 2020-09-12 15:37:53 -04:00
parent 3788c3f042
commit c83c93d339
4 changed files with 8 additions and 35 deletions

View File

@ -6,9 +6,6 @@
package dev.salmonllama.fsbot.endpoints.scapefashion;
import com.google.gson.Gson;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.UnsupportedEncodingException;
import java.net.URI;
import java.net.URLEncoder;
@ -24,8 +21,6 @@ public class ScapeFashionConnection {
private final String OSRS_REQUEST_URL = "https://api.scape.fashion";
private final String OSRS_LINK_URL = "https://scape.fashion";
private static final Logger logger = LoggerFactory.getLogger(ScapeFashionConnection.class);
public ScapeFashionConnection() {}
// Uses the color endpoint to search for items
@ -48,27 +43,21 @@ public class ScapeFashionConnection {
return response;
}
public ScapeFashionResult osrsItem(String item) throws Exception {
private ScapeFashionResult osrsItem(String item) throws Exception {
String uri = OSRS_REQUEST_URL + "/items/" + encode(item);
String link = OSRS_LINK_URL + "/items/" + encode(item);
var response = makeRequest(uri);
response.setLink(link);
if (response.getItems().get(0).getName().toLowerCase().equals(item.toLowerCase())) {
response.getItems().remove(0);
}
return response;
}
public ScapeFashionResult osrsItem(String item, ScapeFashionSlotOsrs slot) throws Exception {
private ScapeFashionResult osrsItem(String item, ScapeFashionSlotOsrs slot) throws Exception {
String uri = OSRS_REQUEST_URL + "/items/" + encode(item) + "?slot=" + encode(slot.getValue());
String link = OSRS_LINK_URL + "/items/" + encode(item) + "?slot=" + encode(slot.getValue());
var response = makeRequest(uri);
response.setLink(link);
if (response.getItems().get(0).getName().toLowerCase().equals(item.toLowerCase())) {
response.getItems().remove(0);
}
return response;
}
@ -96,9 +85,6 @@ public class ScapeFashionConnection {
var response = makeRequest(uri);
response.setLink(link);
if (response.getItems().get(0).getName().toLowerCase().equals(item.toLowerCase())) {
response.getItems().remove(0);
}
return response;
}
@ -108,9 +94,6 @@ public class ScapeFashionConnection {
var response = makeRequest(uri);
response.setLink(link);
if (response.getItems().get(0).getName().toLowerCase().equals(item.toLowerCase())) {
response.getItems().remove(0);
}
return response;
}
@ -132,6 +115,6 @@ public class ScapeFashionConnection {
}
private String encode(String value) throws UnsupportedEncodingException {
return URLEncoder.encode(value, StandardCharsets.UTF_8.toString()).replace("+", "%20");
return URLEncoder.encode(value, StandardCharsets.UTF_8.toString());
}
}

View File

@ -8,8 +8,8 @@ package dev.salmonllama.fsbot.guthix;
public enum CommandCategory {
DEVELOPER("Developer"),
GENERAL("General"),
OSRS_ITEM_SEARCH("07Search"),
RS3_ITEM_SEARCH("RS3Search"),
OSRS_ITEM_SEARCH("Oldschool Item Search"),
RS3_ITEM_SEARCH("Runescape Item Search"),
STAFF("Staff");
private final String category;

View File

@ -23,10 +23,10 @@ import java.util.HashMap;
*/
public class Guthix implements MessageCreateListener {
@SuppressWarnings("unused")
private final DiscordApi api;
private DiscordApi api;
private final Registry registry;
private final PermissionManager manager;
private Registry registry;
private PermissionManager manager;
public Guthix(DiscordApi api) {
this.api = api;

View File

@ -8,14 +8,8 @@ package dev.salmonllama.fsbot.utilities;
import dev.salmonllama.fsbot.config.BotConfig;
import dev.salmonllama.fsbot.guthix.CommandContext;
import org.javacord.api.entity.message.embed.EmbedBuilder;
import org.javacord.api.util.logging.ExceptionLogger;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.*;
import java.util.Arrays;
import java.util.function.Consumer;
import java.util.function.Function;
public class DiscordUtilities {
public static void handleException(Exception e, CommandContext ctx) {
@ -36,8 +30,4 @@ public class DiscordUtilities {
ctx.getApi().getTextChannelById(BotConfig.ACTIVITY_LOG).ifPresent(channel -> channel.sendMessage(embed));
}
public static void report(Class<? extends Throwable>... throwable) {
System.out.println(Arrays.stream(throwable));
}
}