3
0
Mirror von https://github.com/TheSilentPro/HeadDB.git synchronisiert 2024-12-26 19:02:39 +01:00
Dieser Commit ist enthalten in:
Silent 2023-12-30 00:10:47 +01:00
Ursprung 282a711dcb
Commit d279c764d9
5 geänderte Dateien mit 29 neuen und 38 gelöschten Zeilen

1
.gitignore vendored
Datei anzeigen

@ -3,7 +3,6 @@ target/
src/test/ src/test/
dependency-reduced-pom.xml dependency-reduced-pom.xml
build.properties
build/ build/
.classpath .classpath

Datei anzeigen

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

Datei anzeigen

@ -15,6 +15,7 @@ public class CommandInfo extends SubCommand {
public void handle(CommandSender sender, String[] args) { public void handle(CommandSender sender, String[] args) {
if (HeadDB.getInstance().getConfig().getBoolean("showAdvancedPluginInfo")) { if (HeadDB.getInstance().getConfig().getBoolean("showAdvancedPluginInfo")) {
PlayerUtils.sendMessage(sender, "&7Running &6HeadDB - " + Utils.getVersion().orElse(HeadDB.getInstance().getDescription().getVersion() + " &7(&4UNKNOWN SEMVER&7)")); PlayerUtils.sendMessage(sender, "&7Running &6HeadDB - " + Utils.getVersion().orElse(HeadDB.getInstance().getDescription().getVersion() + " &7(&4UNKNOWN SEMVER&7)"));
//PlayerUtils.sendMessage(sender, "&7Build: " + HeadDB.getInstance().getDescription().getVersion());
PlayerUtils.sendMessage(sender, "&7GitHub: &6https://github.com/TheSilentPro/HeadDB"); PlayerUtils.sendMessage(sender, "&7GitHub: &6https://github.com/TheSilentPro/HeadDB");
} else { } else {
PlayerUtils.sendMessage(sender, "&7Running &6HeadDB &7by &6TheSilentPro (Silent)"); PlayerUtils.sendMessage(sender, "&7Running &6HeadDB &7by &6TheSilentPro (Silent)");

Datei anzeigen

@ -213,48 +213,38 @@ public class Utils {
.replace("%cost%", HeadDB.getInstance().getDecimalFormat().format(cost)) .replace("%cost%", HeadDB.getInstance().getDecimalFormat().format(cost))
); );
try (Promise<Boolean> economyPromise = optional.get().purchase(player, cost)) { return optional.get().purchase(player, cost).thenApplyAsync(success -> {
// TODO: Might not need to be sync. if (success) {
return economyPromise.thenApplySync((success) -> { HeadDB.getInstance().getLocalization().sendMessage(player, "completePayment", msg -> msg
if (success) { .replace("%name%", head.getName())
HeadDB.getInstance().getLocalization().sendMessage(player, "completePayment", msg -> msg .replace("%cost%", cost.toString()));
.replace("%name%", head.getName()) } else {
.replace("%cost%", cost.toString())); HeadDB.getInstance().getLocalization().sendMessage(player, "invalidFunds", msg -> msg.replace("%name%", head.getName()));
} else { }
HeadDB.getInstance().getLocalization().sendMessage(player, "invalidFunds", msg -> msg.replace("%name%", head.getName())); return success;
} });
return success;
});
} catch (Exception ex) {
HeadDB.getInstance().getLog().severe("Failed to process payment: " + ex.getMessage());
return Promise.exceptionally(ex);
}
} }
} }
public static void purchase(Player player, Head head, int amount) { public static void purchase(Player player, Head head, int amount) {
// Bukkit API - Has to be sync. // Bukkit API - Has to be sync.
try (Promise<Boolean> paymentPromise = processPayment(player, head, amount)) { processPayment(player, head, amount).thenAcceptSync(success -> {
paymentPromise.thenAcceptSync((success) -> { if (success) {
if (success) { ItemStack item = head.getItem(player.getUniqueId());
ItemStack item = head.getItem(player.getUniqueId()); item.setAmount(amount);
item.setAmount(amount); player.getInventory().addItem(item);
player.getInventory().addItem(item); HeadDB.getInstance().getConfig().getStringList("commands.purchase").forEach(command -> {
HeadDB.getInstance().getConfig().getStringList("commands.purchase").forEach(command -> { if (command.isEmpty()) {
if (command.isEmpty()) { return;
return; }
} if (Hooks.PAPI.enabled()) {
if (Hooks.PAPI.enabled()) { command = PlaceholderAPI.setPlaceholders(player, command);
command = PlaceholderAPI.setPlaceholders(player, command); }
}
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command); Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
}); });
} }
}); });
} catch (Exception ex) {
ex.printStackTrace();
}
} }
public static Optional<String> getTexture(ItemStack head) { public static Optional<String> getTexture(ItemStack head) {

Datei anzeigen

@ -0,0 +1 @@
version=${project.version}