diff options
author | Cow <cow@volloeko.de> | 2020-07-27 23:50:02 +0200 |
---|---|---|
committer | Cow <cow@volloeko.de> | 2020-07-27 23:50:02 +0200 |
commit | 023589c75ae72ddc5ff75fa7235bce4d102b2ad1 (patch) | |
tree | fbb43090ea1ff3d6b3a3b1fb15bbd2c5446ddc7e /src/main/java/eu/olli/cowlection/util | |
parent | 0027466a564a9a6bebbdeed05192a616175ea6f3 (diff) | |
download | Cowlection-023589c75ae72ddc5ff75fa7235bce4d102b2ad1.tar.gz Cowlection-023589c75ae72ddc5ff75fa7235bce4d102b2ad1.tar.bz2 Cowlection-023589c75ae72ddc5ff75fa7235bce4d102b2ad1.zip |
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!
Diffstat (limited to 'src/main/java/eu/olli/cowlection/util')
-rw-r--r-- | src/main/java/eu/olli/cowlection/util/ApiUtils.java | 15 | ||||
-rw-r--r-- | src/main/java/eu/olli/cowlection/util/Utils.java | 3 |
2 files changed, 11 insertions, 7 deletions
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 <a href="https://stackoverflow.com/a/48357180">Source</a> */ public static String convertArabicToRoman(int number) { + if (number == 0) { + return "0"; + } String romanOnes = arabicToRomanChars(number % 10, "I", "V", "X"); number /= 10; |