Dieser Commit ist enthalten in:
Silent 2022-03-22 00:39:38 +01:00
Ursprung 119a4bcfac
Commit 2aed521382
7 geänderte Dateien mit 14 neuen und 18 gelöschten Zeilen

Datei anzeigen

@ -6,7 +6,7 @@
<groupId>tsp.headdb</groupId> <groupId>tsp.headdb</groupId>
<artifactId>HeadDB</artifactId> <artifactId>HeadDB</artifactId>
<version>4.2.2</version> <version>4.2.4</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>

Datei anzeigen

@ -16,7 +16,6 @@ import javax.annotation.Nullable;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import java.util.UUID; import java.util.UUID;
import java.util.stream.Collectors;
/** /**
* This class provides simple methods * This class provides simple methods

Datei anzeigen

@ -89,7 +89,7 @@ public class TreasuryProvider implements BasicEconomyProvider {
currency = provider.getPrimaryCurrency(); currency = provider.getPrimaryCurrency();
} else { } else {
provider.getCurrencies().stream() provider.getCurrencies().stream()
.filter(currency -> currency.getIdentifier().equalsIgnoreCase(rawCurrency)) .filter(c -> c.getIdentifier().equalsIgnoreCase(rawCurrency))
.findFirst() .findFirst()
.ifPresentOrElse(c -> currency = c, () -> Log.error("Could not find currency: " + rawCurrency)); .ifPresentOrElse(c -> currency = c, () -> Log.error("Could not find currency: " + rawCurrency));
} }

Datei anzeigen

@ -20,7 +20,6 @@ import java.net.URLConnection;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.EnumMap; import java.util.EnumMap;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
@ -146,10 +145,10 @@ public class HeadDatabase {
for (Category category : categories) { for (Category category : categories) {
Log.debug("Caching heads from: " + category.getName()); Log.debug("Caching heads from: " + category.getName());
List<Head> heads = new ArrayList<>(); List<Head> results = new ArrayList<>();
try { try {
// First the original api is fetched // 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) { } catch (ParseException | IOException e) {
Log.debug("[" + plugin.getName() + "] Failed to fetch heads (no-cache) from category " + category.getName() + " | Stack Trace:"); Log.debug("[" + plugin.getName() + "] Failed to fetch heads (no-cache) from category " + category.getName() + " | Stack Trace:");
Log.debug(e); Log.debug(e);
@ -158,7 +157,7 @@ public class HeadDatabase {
Log.info("Attempting fallback provider for: " + category.getName()); Log.info("Attempting fallback provider for: " + category.getName());
try { try {
// If the original fails and fallback is enabled, fetch from static archive // 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) { } catch (IOException | ParseException ex) {
Log.error("Failed to fetch heads for " + category.getName() + "! (OF)"); // OF = Original-Fallback, both failed Log.error("Failed to fetch heads for " + category.getName() + "! (OF)"); // OF = Original-Fallback, both failed
Log.error(ex); Log.error(ex);
@ -167,7 +166,7 @@ public class HeadDatabase {
} }
updated = System.nanoTime(); updated = System.nanoTime();
result.put(category, heads); result.put(category, results);
} }
resultSet.accept(result); resultSet.accept(result);

Datei anzeigen

@ -12,7 +12,7 @@ import java.util.function.Consumer;
public class Button { public class Button {
private static int counter = 0; private static int counter = 0;
private static final int id = counter++; private static final int ID = counter++;
private final ItemStack itemStack; private final ItemStack itemStack;
private Consumer<InventoryClickEvent> action; private Consumer<InventoryClickEvent> action;
@ -67,14 +67,12 @@ public class Button {
if (this == o) { if (this == o) {
return true; return true;
} }
if (!(o instanceof Button button)) {
return false; return o instanceof Button;
}
return id == button.id;
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id); return Objects.hash(ID);
} }
} }

Datei anzeigen

@ -18,7 +18,6 @@ import tsp.headdb.util.Utils;
import java.util.*; import java.util.*;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.stream.Collectors;
/** /**
* A paged pane. Credits @ I Al Ianstaan * A paged pane. Credits @ I Al Ianstaan

Datei anzeigen

@ -116,8 +116,9 @@ public class PlayerDataFile {
public void load() { public void load() {
try { try {
main = new JsonParser().parse(new FileReader(file)).getAsJsonObject(); main = new JsonParser().parse(new FileReader(file)).getAsJsonObject();
} catch (FileNotFoundException e) { } catch (FileNotFoundException ex) {
e.printStackTrace(); Log.error("Failed to load player_data.json!");
Log.error(ex);
} }
} }
@ -131,7 +132,7 @@ public class PlayerDataFile {
writer.write(main.toString()); writer.write(main.toString());
Log.debug("Saved data to " + file.getName()); Log.debug("Saved data to " + file.getName());
} catch (IOException ex) { } catch (IOException ex) {
Log.error("Failed to save player_data.json contents!"); Log.error("Failed to save player_data.json!");
Log.error(ex); Log.error(ex);
} }
} }