Merge branch 'development'

This commit is contained in:
Christian Koop 2022-03-18 17:44:49 +01:00
commit 6e6ffe0efc
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
3 changed files with 46 additions and 17 deletions

22
pom.xml
View File

@ -1,8 +1,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0">
<modelVersion>4.0.0</modelVersion>
<groupId>com.songoda</groupId>
<artifactId>EpicHeads</artifactId>
<modelVersion>4.0.0</modelVersion>
<version>3.3.0</version>
<version>3.3.1</version>
<build>
<defaultGoal>clean install</defaultGoal>
<finalName>EpicHeads-${project.version}</finalName>
@ -11,15 +13,18 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>replacer</artifactId>
<version>1.5.3</version>
<executions>
<execution>
<phase>prepare-package</phase>
@ -28,6 +33,7 @@
</goals>
</execution>
</executions>
<configuration>
<file>${project.build.directory}/classes/plugin.yml</file>
<replacements>
@ -38,10 +44,12 @@
</replacements>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0-SNAPSHOT</version>
<executions>
<execution>
<id>shaded</id>
@ -49,15 +57,18 @@
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>false</shadedArtifactAttached>
<createDependencyReducedPom>false</createDependencyReducedPom>
<minimizeJar>true</minimizeJar>
<artifactSet>
<includes>
<include>com.songoda:SongodaCore</include>
</includes>
</artifactSet>
<filters>
<filter>
<artifact>*:*</artifact>
@ -68,6 +79,7 @@
</excludes>
</filter>
</filters>
<relocations>
<relocation>
<pattern>com.songoda.core</pattern>
@ -80,12 +92,14 @@
</plugin>
</plugins>
</build>
<pluginRepositories>
<pluginRepository>
<id>apache.snapshots</id>
<url>https://repository.apache.org/snapshots/</url>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>public</id>
@ -96,6 +110,7 @@
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
@ -103,10 +118,11 @@
<version>1.18</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore</artifactId>
<version>2.6.9</version>
<version>2.6.12</version>
<scope>compile</scope>
</dependency>
</dependencies>

View File

@ -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;
}

View File

@ -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;
}