From 2aed521382d6758f352f6a20c002c43274d3701e Mon Sep 17 00:00:00 2001 From: Silent Date: Tue, 22 Mar 2022 00:39:38 +0100 Subject: [PATCH] patch 4.2.4 --- pom.xml | 2 +- src/main/java/tsp/headdb/api/HeadAPI.java | 1 - src/main/java/tsp/headdb/economy/TreasuryProvider.java | 2 +- .../java/tsp/headdb/implementation/HeadDatabase.java | 9 ++++----- src/main/java/tsp/headdb/inventory/Button.java | 10 ++++------ src/main/java/tsp/headdb/inventory/PagedPane.java | 1 - src/main/java/tsp/headdb/storage/PlayerDataFile.java | 7 ++++--- 7 files changed, 14 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index f00de03..ff45991 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ tsp.headdb HeadDB - 4.2.2 + 4.2.4 jar diff --git a/src/main/java/tsp/headdb/api/HeadAPI.java b/src/main/java/tsp/headdb/api/HeadAPI.java index 2be3278..c6112eb 100644 --- a/src/main/java/tsp/headdb/api/HeadAPI.java +++ b/src/main/java/tsp/headdb/api/HeadAPI.java @@ -16,7 +16,6 @@ import javax.annotation.Nullable; import java.util.List; import java.util.Objects; import java.util.UUID; -import java.util.stream.Collectors; /** * This class provides simple methods diff --git a/src/main/java/tsp/headdb/economy/TreasuryProvider.java b/src/main/java/tsp/headdb/economy/TreasuryProvider.java index 6b56682..9d905cf 100644 --- a/src/main/java/tsp/headdb/economy/TreasuryProvider.java +++ b/src/main/java/tsp/headdb/economy/TreasuryProvider.java @@ -89,7 +89,7 @@ public class TreasuryProvider implements BasicEconomyProvider { currency = provider.getPrimaryCurrency(); } else { provider.getCurrencies().stream() - .filter(currency -> currency.getIdentifier().equalsIgnoreCase(rawCurrency)) + .filter(c -> c.getIdentifier().equalsIgnoreCase(rawCurrency)) .findFirst() .ifPresentOrElse(c -> currency = c, () -> Log.error("Could not find currency: " + rawCurrency)); } diff --git a/src/main/java/tsp/headdb/implementation/HeadDatabase.java b/src/main/java/tsp/headdb/implementation/HeadDatabase.java index b53f50b..834a1a3 100644 --- a/src/main/java/tsp/headdb/implementation/HeadDatabase.java +++ b/src/main/java/tsp/headdb/implementation/HeadDatabase.java @@ -20,7 +20,6 @@ import java.net.URLConnection; import java.util.ArrayList; import java.util.Collections; import java.util.EnumMap; -import java.util.HashMap; import java.util.List; import java.util.Locale; import java.util.Map; @@ -146,10 +145,10 @@ public class HeadDatabase { for (Category category : categories) { Log.debug("Caching heads from: " + category.getName()); - List heads = new ArrayList<>(); + List results = new ArrayList<>(); try { // First the original api is fetched - heads = gather("https://minecraft-heads.com/scripts/api.php?cat=" + category.getName() + "&tags=true", category); + results = gather("https://minecraft-heads.com/scripts/api.php?cat=" + category.getName() + "&tags=true", category); } catch (ParseException | IOException e) { Log.debug("[" + plugin.getName() + "] Failed to fetch heads (no-cache) from category " + category.getName() + " | Stack Trace:"); Log.debug(e); @@ -158,7 +157,7 @@ public class HeadDatabase { Log.info("Attempting fallback provider for: " + category.getName()); try { // If the original fails and fallback is enabled, fetch from static archive - heads = gather("https://heads.pages.dev/archive/" + category.getName() + ".json", category); + results = gather("https://heads.pages.dev/archive/" + category.getName() + ".json", category); } catch (IOException | ParseException ex) { Log.error("Failed to fetch heads for " + category.getName() + "! (OF)"); // OF = Original-Fallback, both failed Log.error(ex); @@ -167,7 +166,7 @@ public class HeadDatabase { } updated = System.nanoTime(); - result.put(category, heads); + result.put(category, results); } resultSet.accept(result); diff --git a/src/main/java/tsp/headdb/inventory/Button.java b/src/main/java/tsp/headdb/inventory/Button.java index 7d1040d..2fabb66 100644 --- a/src/main/java/tsp/headdb/inventory/Button.java +++ b/src/main/java/tsp/headdb/inventory/Button.java @@ -12,7 +12,7 @@ import java.util.function.Consumer; public class Button { private static int counter = 0; - private static final int id = counter++; + private static final int ID = counter++; private final ItemStack itemStack; private Consumer action; @@ -67,14 +67,12 @@ public class Button { if (this == o) { return true; } - if (!(o instanceof Button button)) { - return false; - } - return id == button.id; + + return o instanceof Button; } @Override public int hashCode() { - return Objects.hash(id); + return Objects.hash(ID); } } diff --git a/src/main/java/tsp/headdb/inventory/PagedPane.java b/src/main/java/tsp/headdb/inventory/PagedPane.java index e41edfb..5f58768 100644 --- a/src/main/java/tsp/headdb/inventory/PagedPane.java +++ b/src/main/java/tsp/headdb/inventory/PagedPane.java @@ -18,7 +18,6 @@ import tsp.headdb.util.Utils; import java.util.*; import java.util.Map.Entry; -import java.util.stream.Collectors; /** * A paged pane. Credits @ I Al Ianstaan diff --git a/src/main/java/tsp/headdb/storage/PlayerDataFile.java b/src/main/java/tsp/headdb/storage/PlayerDataFile.java index 5e1f8ec..676c2bc 100644 --- a/src/main/java/tsp/headdb/storage/PlayerDataFile.java +++ b/src/main/java/tsp/headdb/storage/PlayerDataFile.java @@ -116,8 +116,9 @@ public class PlayerDataFile { public void load() { try { main = new JsonParser().parse(new FileReader(file)).getAsJsonObject(); - } catch (FileNotFoundException e) { - e.printStackTrace(); + } catch (FileNotFoundException ex) { + Log.error("Failed to load player_data.json!"); + Log.error(ex); } } @@ -131,7 +132,7 @@ public class PlayerDataFile { writer.write(main.toString()); Log.debug("Saved data to " + file.getName()); } catch (IOException ex) { - Log.error("Failed to save player_data.json contents!"); + Log.error("Failed to save player_data.json!"); Log.error(ex); } }