3
0
Mirror von https://github.com/TheSilentPro/HeadDB.git synchronisiert 2024-12-27 11:20:05 +01:00

Merge pull request #41 from TheSilentPro/v5

v5 rc.2
Dieser Commit ist enthalten in:
Silent 2022-11-24 00:12:07 +01:00 committet von GitHub
Commit 97c542e9b5
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
12 geänderte Dateien mit 69 neuen und 26 gelöschten Zeilen

Datei anzeigen

@ -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. <br>
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. <br>
Alternatively you may view the [javadocs](https://javadocs.pages.dev/headdb/4.0.0/tsp/headdb/api/HeadAPI).

Datei anzeigen

@ -6,7 +6,7 @@
<groupId>tsp.headdb</groupId>
<artifactId>HeadDB</artifactId>
<version>5.0.0-rc.1</version>
<version>5.0.0-rc.2</version>
<packaging>jar</packaging>
<name>HeadDB</name>

Datei anzeigen

@ -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();

Datei anzeigen

@ -20,6 +20,7 @@ public class CommandHelp extends SubCommand {
PlayerUtils.sendMessage(sender, "&7/hdb &9search(s) &b(id:|tg:)&c<query> &7- Search for specific heads.");
PlayerUtils.sendMessage(sender, "&7/hdb &9give(g) &b(t:)&c<id> <player> &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.");

Datei anzeigen

@ -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)");

Datei anzeigen

@ -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<String> 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();
}
}

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -40,6 +40,20 @@ public class Utils {
private static final HeadDB instance = HeadDB.getInstance();
public static String toString(Collection<String> 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<UUID> 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;

Datei anzeigen

@ -9,9 +9,6 @@ localHeads: true
# Permission: headdb.category.<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

Datei anzeigen

@ -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%"