diff --git a/pom.xml b/pom.xml
index 60939a7..89f0551 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
tsp.headdb
HeadDB
- 3.2.0
+ 3.2.1
jar
HeadDB
diff --git a/src/main/java/tsp/headdb/HeadDB.java b/src/main/java/tsp/headdb/HeadDB.java
index 6a17958..9b44b7d 100644
--- a/src/main/java/tsp/headdb/HeadDB.java
+++ b/src/main/java/tsp/headdb/HeadDB.java
@@ -93,12 +93,12 @@ public class HeadDB extends JavaPlugin {
}
private void createLocalizationFile() {
- if (getClass().getResource("messages.yml") != null && !new File(getDataFolder() + "/messages.yml").exists()) {
+ File messagesFile = new File(getDataFolder().getAbsolutePath() + "/messages.yml");
+ if (!messagesFile.exists()) {
saveResource("messages.yml", false);
Log.debug("Localization loaded from jar file.");
}
- File messagesFile = new File(getDataFolder() + "/messages.yml");
this.localization = new Localization(messagesFile);
this.localization.load();
}
diff --git a/src/main/java/tsp/headdb/command/CommandHeadDB.java b/src/main/java/tsp/headdb/command/CommandHeadDB.java
index 10d9c0a..2d779f8 100644
--- a/src/main/java/tsp/headdb/command/CommandHeadDB.java
+++ b/src/main/java/tsp/headdb/command/CommandHeadDB.java
@@ -45,6 +45,12 @@ public class CommandHeadDB implements CommandExecutor {
return true;
}
+ if (sub.equalsIgnoreCase("reload") || sub.equalsIgnoreCase("r")) {
+ HeadDB.getInstance().getLocalization().load();
+ Utils.sendMessage(sender, "&aReloaded messages file!");
+ return true;
+ }
+
if (sub.equalsIgnoreCase("search") || sub.equalsIgnoreCase("s")) {
if (!sender.hasPermission("headdb.search")) {
Utils.sendMessage(sender, localization.getMessage("noPermission"));
@@ -153,6 +159,7 @@ public class CommandHeadDB implements CommandExecutor {
Utils.sendMessage(sender, "&7&oParameters:&c command &9(aliases)&c arguments... &7- Description");
Utils.sendMessage(sender, "&7 > &c/hdb &7- Opens the database");
Utils.sendMessage(sender, "&7 > &c/hdb info &9(i) &7- Plugin Information");
+ Utils.sendMessage(sender, "&7 > &c/hdb reload &9(r) &7- Reloads the messages file");
Utils.sendMessage(sender, "&7 > &c/hdb search &9(s) &c &7- Search for heads matching a name");
Utils.sendMessage(sender, "&7 > &c/hdb tagsearch &9(ts) &c &7- Search for heads matching a tag");
Utils.sendMessage(sender, "&7 > &c/hdb update &9(u) &7- Forcefully update the database");
diff --git a/src/main/java/tsp/headdb/util/Localization.java b/src/main/java/tsp/headdb/util/Localization.java
index 019556d..ab86949 100644
--- a/src/main/java/tsp/headdb/util/Localization.java
+++ b/src/main/java/tsp/headdb/util/Localization.java
@@ -7,7 +7,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.File;
-import java.util.function.UnaryOperator;
/**
* Localization class for a messages file
@@ -31,15 +30,7 @@ public class Localization {
Validate.notNull(data, "File data is null.");
Validate.notNull(key, "Message key can not be null.");
- return Utils.colorize(data.getString(key));
- }
-
- public String getMessage(@Nonnull String key, @Nonnull UnaryOperator function) {
- Validate.notNull(data, "File data is null.");
- Validate.notNull(key, "Message key can not be null.");
- Validate.notNull(function, "Function can not be null.");
-
- return function.apply(getMessage(key));
+ return Utils.colorize(data.getString(key, "null"));
}
public void load() {
diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml
index 651efb6..bbfc5ae 100644
--- a/src/main/resources/messages.yml
+++ b/src/main/resources/messages.yml
@@ -1,5 +1,5 @@
noPermission: "&cNo permission!"
-onlyPlayers: "&c&cOnly players may open the database."
+onlyPlayers: "&cOnly players may open the database."
databaseOpen: "&7Opening &cHead Database"
invalidPlayer: "&cPlayer is not online!"
localFavorites: "&cLocal heads can not be added to favorites!"