Mirror von
https://github.com/TheSilentPro/HeadDB.git
synchronisiert 2024-12-25 02:20:09 +01:00
Fix economy
Dieser Commit ist enthalten in:
Ursprung
282a711dcb
Commit
d279c764d9
1
.gitignore
vendored
1
.gitignore
vendored
@ -3,7 +3,6 @@ target/
|
||||
src/test/
|
||||
|
||||
dependency-reduced-pom.xml
|
||||
build.properties
|
||||
build/
|
||||
|
||||
.classpath
|
||||
|
2
pom.xml
2
pom.xml
@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>tsp.headdb</groupId>
|
||||
<artifactId>HeadDB</artifactId>
|
||||
<version>5.0.0-rc.8</version>
|
||||
<version>5.0.0-rc.9</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HeadDB</name>
|
||||
|
@ -15,6 +15,7 @@ public class CommandInfo extends SubCommand {
|
||||
public void handle(CommandSender sender, String[] args) {
|
||||
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, "&7Build: " + HeadDB.getInstance().getDescription().getVersion());
|
||||
PlayerUtils.sendMessage(sender, "&7GitHub: &6https://github.com/TheSilentPro/HeadDB");
|
||||
} else {
|
||||
PlayerUtils.sendMessage(sender, "&7Running &6HeadDB &7by &6TheSilentPro (Silent)");
|
||||
|
@ -213,48 +213,38 @@ public class Utils {
|
||||
.replace("%cost%", HeadDB.getInstance().getDecimalFormat().format(cost))
|
||||
);
|
||||
|
||||
try (Promise<Boolean> economyPromise = optional.get().purchase(player, cost)) {
|
||||
// TODO: Might not need to be sync.
|
||||
return economyPromise.thenApplySync((success) -> {
|
||||
if (success) {
|
||||
HeadDB.getInstance().getLocalization().sendMessage(player, "completePayment", msg -> msg
|
||||
.replace("%name%", head.getName())
|
||||
.replace("%cost%", cost.toString()));
|
||||
} else {
|
||||
HeadDB.getInstance().getLocalization().sendMessage(player, "invalidFunds", msg -> msg.replace("%name%", head.getName()));
|
||||
}
|
||||
return success;
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
HeadDB.getInstance().getLog().severe("Failed to process payment: " + ex.getMessage());
|
||||
return Promise.exceptionally(ex);
|
||||
}
|
||||
return optional.get().purchase(player, cost).thenApplyAsync(success -> {
|
||||
if (success) {
|
||||
HeadDB.getInstance().getLocalization().sendMessage(player, "completePayment", msg -> msg
|
||||
.replace("%name%", head.getName())
|
||||
.replace("%cost%", cost.toString()));
|
||||
} else {
|
||||
HeadDB.getInstance().getLocalization().sendMessage(player, "invalidFunds", msg -> msg.replace("%name%", head.getName()));
|
||||
}
|
||||
return success;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static void purchase(Player player, Head head, int amount) {
|
||||
// Bukkit API - Has to be sync.
|
||||
try (Promise<Boolean> paymentPromise = processPayment(player, head, amount)) {
|
||||
paymentPromise.thenAcceptSync((success) -> {
|
||||
if (success) {
|
||||
ItemStack item = head.getItem(player.getUniqueId());
|
||||
item.setAmount(amount);
|
||||
player.getInventory().addItem(item);
|
||||
HeadDB.getInstance().getConfig().getStringList("commands.purchase").forEach(command -> {
|
||||
if (command.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (Hooks.PAPI.enabled()) {
|
||||
command = PlaceholderAPI.setPlaceholders(player, command);
|
||||
}
|
||||
processPayment(player, head, amount).thenAcceptSync(success -> {
|
||||
if (success) {
|
||||
ItemStack item = head.getItem(player.getUniqueId());
|
||||
item.setAmount(amount);
|
||||
player.getInventory().addItem(item);
|
||||
HeadDB.getInstance().getConfig().getStringList("commands.purchase").forEach(command -> {
|
||||
if (command.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
if (Hooks.PAPI.enabled()) {
|
||||
command = PlaceholderAPI.setPlaceholders(player, command);
|
||||
}
|
||||
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
});
|
||||
}
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static Optional<String> getTexture(ItemStack head) {
|
||||
|
1
src/main/resources/build.properties
Normale Datei
1
src/main/resources/build.properties
Normale Datei
@ -0,0 +1 @@
|
||||
version=${project.version}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren