diff --git a/README.md b/README.md
index 5ef191f..3fe5947 100644
--- a/README.md
+++ b/README.md
@@ -9,5 +9,5 @@ You may download it either via the [Releases Page](https://github.com/TheSilentP
You may report issues on the [Issue Tracker](https://github.com/TheSilentPro/HeadDB/issues).
# API
-All API methods can be found in the [HeadAPI](https://github.com/TheSilentPro/HeadDB/blob/master/src/main/java/tsp/headdb/api/HeadAPI.java) class.
+All API methods can be found in the [HeadAPI](https://github.com/TheSilentPro/HeadDB/blob/master/src/main/java/tsp/headdb/core/api/HeadAPI.java) class.
Alternatively you may view the [javadocs](https://javadocs.pages.dev/headdb/4.0.0/tsp/headdb/api/HeadAPI).
diff --git a/pom.xml b/pom.xml
index 40282a4..903e410 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
tsp.headdb
HeadDB
- 5.0.0-rc.1
+ 5.0.0-rc.2
jar
HeadDB
diff --git a/src/main/java/tsp/headdb/HeadDB.java b/src/main/java/tsp/headdb/HeadDB.java
index 0316dbc..d12914b 100644
--- a/src/main/java/tsp/headdb/HeadDB.java
+++ b/src/main/java/tsp/headdb/HeadDB.java
@@ -8,6 +8,7 @@ import tsp.headdb.core.command.CommandInfo;
import tsp.headdb.core.command.CommandLanguage;
import tsp.headdb.core.command.CommandMain;
import tsp.headdb.core.command.CommandManager;
+import tsp.headdb.core.command.CommandReload;
import tsp.headdb.core.command.CommandSearch;
import tsp.headdb.core.command.CommandSettings;
@@ -60,7 +61,7 @@ public class HeadDB extends SmartPlugin {
instance.commandManager = new CommandManager();
loadCommands();
- new Metrics(this, 9152);
+ initMetrics();
ensureLatestVersion();
instance.logger.info("Done!");
}
@@ -72,6 +73,18 @@ public class HeadDB extends SmartPlugin {
}
}
+ private void initMetrics() {
+ Metrics metrics = new Metrics(this, 9152);
+
+ metrics.addCustomChart(new Metrics.SimplePie("economy_provider", () -> {
+ if (getEconomyProvider().isPresent()) {
+ return this.getConfig().getString("economy.provider");
+ }
+
+ return "None";
+ }));
+ }
+
private void ensureLatestVersion() {
PluginUtils.isLatestVersion(this, 84967, latest -> {
if (Boolean.FALSE.equals(latest)) {
@@ -133,6 +146,7 @@ public class HeadDB extends SmartPlugin {
new CommandSearch().register();
new CommandGive().register();
new CommandUpdate().register();
+ new CommandReload().register();
new CommandTexture().register();
new CommandLanguage().register();
new CommandSettings().register();
diff --git a/src/main/java/tsp/headdb/core/command/CommandHelp.java b/src/main/java/tsp/headdb/core/command/CommandHelp.java
index 497282c..3f415b6 100644
--- a/src/main/java/tsp/headdb/core/command/CommandHelp.java
+++ b/src/main/java/tsp/headdb/core/command/CommandHelp.java
@@ -20,6 +20,7 @@ public class CommandHelp extends SubCommand {
PlayerUtils.sendMessage(sender, "&7/hdb &9search(s) &b(id:|tg:)&c &7- Search for specific heads.");
PlayerUtils.sendMessage(sender, "&7/hdb &9give(g) &b(t:)&c &b[amount] &7- Give the player a specific head.");
PlayerUtils.sendMessage(sender, "&7/hdb &9update(u) &7- Manually update the database.");
+ PlayerUtils.sendMessage(sender, "&7/hdb &9reload(r) &7- Reload configuration files.");
PlayerUtils.sendMessage(sender, "&7/hdb &9language(l) &7- Change your language.");
PlayerUtils.sendMessage(sender, "&7/hdb &9settings(st) &7- Open the settings menu.");
PlayerUtils.sendMessage(sender, "&7/hdb &9texture(t) &7- Get the texture for the head your item.");
diff --git a/src/main/java/tsp/headdb/core/command/CommandInfo.java b/src/main/java/tsp/headdb/core/command/CommandInfo.java
index 69145b2..8c7ec7f 100644
--- a/src/main/java/tsp/headdb/core/command/CommandInfo.java
+++ b/src/main/java/tsp/headdb/core/command/CommandInfo.java
@@ -3,6 +3,7 @@ package tsp.headdb.core.command;
import org.bukkit.command.CommandSender;
import tsp.headdb.HeadDB;
import tsp.headdb.core.util.BuildProperties;
+import tsp.headdb.core.util.Utils;
import tsp.smartplugin.player.PlayerUtils;
public class CommandInfo extends SubCommand {
@@ -16,7 +17,7 @@ public class CommandInfo extends SubCommand {
if (HeadDB.getInstance().getConfig().getBoolean("showAdvancedPluginInfo")) {
BuildProperties build = HeadDB.getInstance().getBuildProperties();
PlayerUtils.sendMessage(sender, "&7Running &6HeadDB - " + build.getVersion());
- PlayerUtils.sendMessage(sender, "&7Created by &6" + HeadDB.getInstance().getDescription().getAuthors());
+ PlayerUtils.sendMessage(sender, "&7Created by &6" + Utils.toString(HeadDB.getInstance().getDescription().getAuthors()));
PlayerUtils.sendMessage(sender, "&7Compiled on &6" + build.getTimestamp() + " &7by &6" + build.getAuthor());
} else {
PlayerUtils.sendMessage(sender, "&7Running &6HeadDB &7by &6TheSilentPro (Silent)");
diff --git a/src/main/java/tsp/headdb/core/command/CommandLanguage.java b/src/main/java/tsp/headdb/core/command/CommandLanguage.java
index ea53642..fb6c36d 100644
--- a/src/main/java/tsp/headdb/core/command/CommandLanguage.java
+++ b/src/main/java/tsp/headdb/core/command/CommandLanguage.java
@@ -3,8 +3,7 @@ package tsp.headdb.core.command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import tsp.headdb.HeadDB;
-
-import java.util.Set;
+import tsp.headdb.core.util.Utils;
public class CommandLanguage extends SubCommand {
@@ -21,7 +20,7 @@ public class CommandLanguage extends SubCommand {
String lang = args[1];
if (!getLocalization().getData().containsKey(lang)) {
- getLocalization().sendMessage(sender, "invalidLanguage", msg -> msg.replace("%languages%", toString(getLocalization().getData().keySet())));
+ getLocalization().sendMessage(sender, "invalidLanguage", msg -> msg.replace("%languages%", Utils.toString(getLocalization().getData().keySet())));
return;
}
@@ -34,18 +33,4 @@ public class CommandLanguage extends SubCommand {
getLocalization().sendMessage(sender, "languageChanged", msg -> msg.replace("%language%", lang));
}
- private String toString(Set set) {
- String[] array = set.toArray(new String[0]);
-
- StringBuilder builder = new StringBuilder();
- for (int i = 0; i < array.length; i++) {
- builder.append(array[i]);
- if (i < array.length - 1) {
- builder.append(",");
- }
- }
-
- return builder.toString();
- }
-
}
diff --git a/src/main/java/tsp/headdb/core/command/CommandMain.java b/src/main/java/tsp/headdb/core/command/CommandMain.java
index ef07b94..c7a30c3 100644
--- a/src/main/java/tsp/headdb/core/command/CommandMain.java
+++ b/src/main/java/tsp/headdb/core/command/CommandMain.java
@@ -167,7 +167,7 @@ public class CommandMain extends HeadDBCommand implements CommandExecutor, TabCo
}));
// Fill
- Utils.fill(pane, Utils.getItemFromConfig("gui.main.fill", Material.BLACK_STAINED_GLASS));
+ Utils.fill(pane, Utils.getItemFromConfig("gui.main.fill", Material.BLACK_STAINED_GLASS_PANE));
pane.open(player);
return;
diff --git a/src/main/java/tsp/headdb/core/command/CommandReload.java b/src/main/java/tsp/headdb/core/command/CommandReload.java
new file mode 100644
index 0000000..144237f
--- /dev/null
+++ b/src/main/java/tsp/headdb/core/command/CommandReload.java
@@ -0,0 +1,23 @@
+package tsp.headdb.core.command;
+
+import org.bukkit.command.CommandSender;
+import tsp.headdb.HeadDB;
+
+import java.util.HashSet;
+
+// Todo: async
+public class CommandReload extends SubCommand {
+
+ public CommandReload() {
+ super("reload", new HashSet<>(0), "r");
+ }
+
+ @Override
+ public void handle(CommandSender sender, String[] args) {
+ getLocalization().sendMessage(sender, "reloadCommand");
+ getLocalization().load();
+ HeadDB.getInstance().reloadConfig();
+ getLocalization().sendMessage(sender, "reloadCommandDone");
+ }
+
+}
diff --git a/src/main/java/tsp/headdb/core/command/CommandUpdate.java b/src/main/java/tsp/headdb/core/command/CommandUpdate.java
index 711e527..f66124d 100644
--- a/src/main/java/tsp/headdb/core/command/CommandUpdate.java
+++ b/src/main/java/tsp/headdb/core/command/CommandUpdate.java
@@ -1,5 +1,6 @@
package tsp.headdb.core.command;
+import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import tsp.headdb.HeadDB;
import tsp.headdb.core.api.HeadAPI;
@@ -13,7 +14,10 @@ public class CommandUpdate extends SubCommand {
@Override
public void handle(CommandSender sender, String[] args) {
getLocalization().sendMessage(sender, "updateDatabase");
- HeadAPI.getDatabase().update((time, result) -> HeadDB.getInstance().getLog().debug("Database Updated! Heads: " + result.values().size() + " | Took: " + time + "ms"));
+ HeadAPI.getDatabase().update((time, result) -> {
+ HeadDB.getInstance().getLog().debug("Database Updated! Heads: " + result.values().size() + " | Took: " + time + "ms");
+ Bukkit.getScheduler().runTask(HeadDB.getInstance(), () -> getLocalization().sendMessage(sender, "updateDatabaseDone", msg -> msg.replace("%size%", String.valueOf(result.values().size()))));
+ });
}
}
diff --git a/src/main/java/tsp/headdb/core/util/Utils.java b/src/main/java/tsp/headdb/core/util/Utils.java
index b65af22..8648699 100644
--- a/src/main/java/tsp/headdb/core/util/Utils.java
+++ b/src/main/java/tsp/headdb/core/util/Utils.java
@@ -40,6 +40,20 @@ public class Utils {
private static final HeadDB instance = HeadDB.getInstance();
+ public static String toString(Collection set) {
+ String[] array = set.toArray(new String[0]);
+
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0; i < array.length; i++) {
+ builder.append(array[i]);
+ if (i < array.length - 1) {
+ builder.append(",");
+ }
+ }
+
+ return builder.toString();
+ }
+
public static Optional validateUniqueId(@Nonnull String raw) {
try {
return Optional.of(UUID.fromString(raw));
@@ -206,6 +220,7 @@ public class Utils {
ConfigurationSection section = HeadDB.getInstance().getConfig().getConfigurationSection(path);
Validate.notNull(section, "Section can not be null!");
+ System.out.println("Checking for: provided material in '" + section.getName() + "' -> " + section.getString("material"));
Material material = Material.matchMaterial(section.getString("material", def.name()));
if (material == null) {
material = def;
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index e784093..03d2adf 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -9,9 +9,6 @@ localHeads: true
# Permission: headdb.category.
requireCategoryPermission: false
-# If enabled, the menu will close after purchasing a head (even if the purchase fails).
-closeOnPurchase: false
-
# Economy Options
economy:
enable: false
diff --git a/src/main/resources/messages/en.yml b/src/main/resources/messages/en.yml
index 57ea293..eb82795 100644
--- a/src/main/resources/messages/en.yml
+++ b/src/main/resources/messages/en.yml
@@ -10,6 +10,9 @@ invalidPageIndex: "&cThat page is out of bounds! Max: %pages%"
openDatabase: "" # Intentionally empty. Sent when the main gui is opened
updateDatabase: "&7Updating..."
+updateDatabaseDone: "&7Done! Total Heads: &6%size%"
+reloadCommand: "&7Reloading, please wait before using the plugin..."
+reloadCommandDone: "&7Reload Complete!"
searchCommand: "&7Searching for heads matching: &6%query%"
searchCommandResults: "&7Found &6%size% &7matches!"
giveCommand: "&7Gave &6x%size% %name% &7to &6%receiver%"