diff --git a/pom.xml b/pom.xml index 1975bb7..49fb2ab 100644 --- a/pom.xml +++ b/pom.xml @@ -1,8 +1,10 @@ + 4.0.0 + com.songoda EpicHeads - 4.0.0 - 3.3.0 + 3.3.1 + clean install EpicHeads-${project.version} @@ -11,15 +13,18 @@ org.apache.maven.plugins maven-compiler-plugin 3.8.0 + 1.8 1.8 + com.google.code.maven-replacer-plugin replacer 1.5.3 + prepare-package @@ -28,6 +33,7 @@ + ${project.build.directory}/classes/plugin.yml @@ -38,10 +44,12 @@ + org.apache.maven.plugins maven-shade-plugin 3.3.0-SNAPSHOT + shaded @@ -49,15 +57,18 @@ shade + false false true + com.songoda:SongodaCore + *:* @@ -68,6 +79,7 @@ + com.songoda.core @@ -80,12 +92,14 @@ + apache.snapshots https://repository.apache.org/snapshots/ + public @@ -96,6 +110,7 @@ https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + org.spigotmc @@ -103,10 +118,11 @@ 1.18 provided + com.songoda SongodaCore - 2.6.9 + 2.6.12 compile diff --git a/src/main/java/com/songoda/epicheads/EpicHeads.java b/src/main/java/com/songoda/epicheads/EpicHeads.java index 43d7240..80d5f5d 100644 --- a/src/main/java/com/songoda/epicheads/EpicHeads.java +++ b/src/main/java/com/songoda/epicheads/EpicHeads.java @@ -9,7 +9,16 @@ import com.songoda.core.gui.GuiManager; import com.songoda.core.hooks.EconomyManager; import com.songoda.core.hooks.PluginHook; import com.songoda.core.hooks.economies.Economy; -import com.songoda.epicheads.commands.*; +import com.songoda.epicheads.commands.CommandAdd; +import com.songoda.epicheads.commands.CommandBase64; +import com.songoda.epicheads.commands.CommandEpicHeads; +import com.songoda.epicheads.commands.CommandGive; +import com.songoda.epicheads.commands.CommandGiveToken; +import com.songoda.epicheads.commands.CommandHelp; +import com.songoda.epicheads.commands.CommandReload; +import com.songoda.epicheads.commands.CommandSearch; +import com.songoda.epicheads.commands.CommandSettings; +import com.songoda.epicheads.commands.CommandUrl; import com.songoda.epicheads.head.Category; import com.songoda.epicheads.head.Head; import com.songoda.epicheads.head.HeadManager; @@ -37,13 +46,12 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.net.URL; -import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.Optional; import java.util.UUID; public class EpicHeads extends SongodaPlugin { - private static EpicHeads INSTANCE; private final GuiManager guiManager = new GuiManager(this); @@ -133,8 +141,9 @@ public class EpicHeads extends SongodaPlugin { // Adding in favorites. if (storage.containsGroup("players")) { for (StorageRow row : storage.getRowsByGroup("players")) { - if (row.get("uuid").asObject() == null) + if (row.get("uuid").asObject() == null) { continue; + } EPlayer player = new EPlayer( UUID.fromString(row.get("uuid").asString()), @@ -155,7 +164,7 @@ public class EpicHeads extends SongodaPlugin { private void downloadHeads() { try { InputStream is = new URL("http://www.head-db.com/dump").openStream(); - BufferedReader rd = new BufferedReader(new InputStreamReader(is, Charset.forName("UTF-8"))); + BufferedReader rd = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8)); String jsonText = readAll(rd); JSONParser parser = new JSONParser(); JSONArray json = (JSONArray) parser.parse(jsonText); @@ -163,8 +172,8 @@ public class EpicHeads extends SongodaPlugin { try (FileWriter file = new FileWriter(getDataFolder() + "/heads.json")) { file.write(json.toJSONString()); } - } catch (Exception e) { - System.out.println("Failed to download heads."); + } catch (Exception ex) { + getLogger().warning("Failed to download heads: " + ex.getMessage()); } } @@ -240,15 +249,19 @@ public class EpicHeads extends SongodaPlugin { config.set("Main.Disabled Global Heads", null); } - System.out.println("loaded " + headManager.getHeads().size() + " Heads."); + getLogger().info("Loaded " + headManager.getHeads().size() + " heads"); + } catch (IOException | ParseException ex) { + getLogger().warning(() -> { + if (ex instanceof ParseException) { + return "Disabling plugin, failed to parse heads: " + ex.getMessage(); + } + + return "Disabling plugin, failed to load heads: " + ex.getMessage(); + }); - } catch (IOException e) { - System.out.println("Heads file not found. Plugin disabling."); - return false; - } catch (ParseException e) { - System.out.println("Failed to parse heads file. Plugin disabling."); return false; } + return true; } diff --git a/src/main/java/com/songoda/epicheads/commands/CommandUrl.java b/src/main/java/com/songoda/epicheads/commands/CommandUrl.java index 7926337..d651f13 100644 --- a/src/main/java/com/songoda/epicheads/commands/CommandUrl.java +++ b/src/main/java/com/songoda/epicheads/commands/CommandUrl.java @@ -33,7 +33,7 @@ public class CommandUrl extends AbstractCommand { String url = ItemUtils.getDecodedTexture(encodededStr); - plugin.getLocale().newMessage("http://textures.minecraft.net/texture/" + url).sendPrefixedMessage(player); + player.sendMessage(plugin.getLocale().newMessage("http://textures.minecraft.net/texture/" + url).getPrefixedMessage()); return ReturnType.SUCCESS; }