mirror of
https://github.com/zontreck/AutoMoneyPlugin
synced 2025-06-19 10:23:55 +00:00
Finish adding basic implementation
This commit is contained in:
parent
91f3ac0d41
commit
fd73d47d3a
3 changed files with 19 additions and 2 deletions
|
@ -2,6 +2,7 @@ package dev.zontreck.amp;
|
|||
|
||||
import io.papermc.lib.PaperLib;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse.ResponseType;
|
||||
|
||||
import java.util.Timer;
|
||||
|
||||
|
@ -28,6 +29,7 @@ public class AutoMoneyPlugin extends JavaPlugin {
|
|||
// Apply configuration
|
||||
Configuration.g_dPaymentAmount = getConfig().getDouble("amountToGive", 0.25);
|
||||
Configuration.g_iPaymentInterval = getConfig().getInt("duration", 60);
|
||||
Configuration.g_sBankAccount = getConfig().getString("bank", "");
|
||||
|
||||
// Setup the economy
|
||||
if (!setupEconomy()) {
|
||||
|
@ -64,7 +66,17 @@ public class AutoMoneyPlugin extends JavaPlugin {
|
|||
getServer().getOnlinePlayers().forEach(player -> {
|
||||
//player.sendMessage("You have been paid " + Configuration.g_dPaymentAmount + " for being online.");
|
||||
//player.giveExp((int) Configuration.g_dPaymentAmount);
|
||||
|
||||
// Check if a bank account is used.
|
||||
if(Configuration.g_sBankAccount.isEmpty()) {
|
||||
economy.depositPlayer(player, Configuration.g_dPaymentAmount);
|
||||
} else {
|
||||
var ecoReply = economy.bankWithdraw(Configuration.g_sBankAccount, Configuration.g_dPaymentAmount);
|
||||
if(ecoReply.type == ResponseType.SUCCESS) {
|
||||
economy.depositPlayer(player, Configuration.g_dPaymentAmount);
|
||||
} else {
|
||||
getLogger().severe("Failed to withdraw from bank account: " + ecoReply.errorMessage);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@ package dev.zontreck.amp;
|
|||
public class Configuration {
|
||||
public static double g_dPaymentAmount = 0.0;
|
||||
public static int g_iPaymentInterval = 0;
|
||||
public static String g_sBankAccount = "";
|
||||
|
||||
|
||||
public static boolean PaymentEnabled() {
|
||||
return g_iPaymentInterval > 0;
|
||||
|
|
|
@ -2,4 +2,7 @@
|
|||
amountToGive: 0.25
|
||||
|
||||
# Give every <duration> seconds
|
||||
duration: 60
|
||||
duration: 60
|
||||
|
||||
# Bank account if applicable. Leave blank if undesired.
|
||||
bank: ""
|
Loading…
Add table
Add a link
Reference in a new issue