From 023589c75ae72ddc5ff75fa7235bce4d102b2ad1 Mon Sep 17 00:00:00 2001 From: Cow Date: Mon, 27 Jul 2020 23:50:02 +0200 Subject: Added new stats to `/moo stalkskyblock` - new stats: skill average, slayer levels, pets - also new alias: `/moo ss` - new alias for `moo stalk`: `/moo s` - also: stalking = bad! --- src/main/java/eu/olli/cowlection/util/ApiUtils.java | 15 ++++++++------- src/main/java/eu/olli/cowlection/util/Utils.java | 3 +++ 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'src/main/java/eu/olli/cowlection/util') diff --git a/src/main/java/eu/olli/cowlection/util/ApiUtils.java b/src/main/java/eu/olli/cowlection/util/ApiUtils.java index f4f23ff..04a67cd 100644 --- a/src/main/java/eu/olli/cowlection/util/ApiUtils.java +++ b/src/main/java/eu/olli/cowlection/util/ApiUtils.java @@ -2,14 +2,15 @@ package eu.olli.cowlection.util; import com.google.gson.JsonArray; import com.google.gson.JsonParser; +import com.google.gson.JsonSyntaxException; import com.mojang.util.UUIDTypeAdapter; import eu.olli.cowlection.Cowlection; import eu.olli.cowlection.command.exception.ThrowingConsumer; import eu.olli.cowlection.config.MooConfig; import eu.olli.cowlection.data.Friend; +import eu.olli.cowlection.data.HyPlayerData; import eu.olli.cowlection.data.HySkyBlockStats; import eu.olli.cowlection.data.HyStalkingData; -import eu.olli.cowlection.data.HyPlayerData; import org.apache.http.HttpStatus; import java.io.BufferedReader; @@ -44,7 +45,7 @@ public class ApiUtils { } else { return GsonUtils.fromJson(reader, Friend.class); } - } catch (IOException e) { + } catch (IOException | JsonSyntaxException e) { e.printStackTrace(); } return null; @@ -64,7 +65,7 @@ public class ApiUtils { return nameHistoryData.get(nameHistoryData.size() - 1).getAsJsonObject().get("name").getAsString(); } } - } catch (IOException e) { + } catch (IOException | JsonSyntaxException e) { e.printStackTrace(); } return null; @@ -79,7 +80,7 @@ public class ApiUtils { if (reader != null) { return GsonUtils.fromJson(reader, HyStalkingData.class); } - } catch (IOException e) { + } catch (IOException | JsonSyntaxException e) { e.printStackTrace(); } return null; @@ -94,7 +95,7 @@ public class ApiUtils { if (reader != null) { return GsonUtils.fromJson(reader, HySkyBlockStats.class); } - } catch (IOException e) { + } catch (IOException | JsonSyntaxException e) { e.printStackTrace(); } return null; @@ -109,7 +110,7 @@ public class ApiUtils { if (reader != null) { return GsonUtils.fromJson(reader, HyPlayerData.class); } - } catch (IOException e) { + } catch (IOException | JsonSyntaxException e) { e.printStackTrace(); } return null; @@ -118,7 +119,7 @@ public class ApiUtils { private static BufferedReader makeApiCall(String url) throws IOException { HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection(); connection.setConnectTimeout(5000); - connection.setReadTimeout(5000); + connection.setReadTimeout(10000); connection.addRequestProperty("User-Agent", "Forge Mod " + Cowlection.MODNAME + "/" + Cowlection.VERSION + " (" + Cowlection.GITURL + ")"); connection.getResponseCode(); diff --git a/src/main/java/eu/olli/cowlection/util/Utils.java b/src/main/java/eu/olli/cowlection/util/Utils.java index 92f4c9e..629a3dd 100644 --- a/src/main/java/eu/olli/cowlection/util/Utils.java +++ b/src/main/java/eu/olli/cowlection/util/Utils.java @@ -174,6 +174,9 @@ public final class Utils { * @see Source */ public static String convertArabicToRoman(int number) { + if (number == 0) { + return "0"; + } String romanOnes = arabicToRomanChars(number % 10, "I", "V", "X"); number /= 10; -- cgit