mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-19 15:09:24 +00:00
Improve default configs
This commit is contained in:
@@ -51,8 +51,8 @@ public class VersionHelper {
|
||||
}
|
||||
updateFuture.complete(true);
|
||||
} catch (Exception exception) {
|
||||
plugin.getPluginLogger().warn("Error occurred when checking update.", exception);
|
||||
updateFuture.complete(false);
|
||||
plugin.getPluginLogger().warn("Error occurred when checking update.");
|
||||
updateFuture.completeExceptionally(exception);
|
||||
}
|
||||
});
|
||||
return updateFuture;
|
||||
|
||||
@@ -20,34 +20,60 @@ package net.momirealms.customfishing.bukkit.integration;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
public class VaultHook {
|
||||
|
||||
private static Economy economy;
|
||||
private static boolean isHooked = false;
|
||||
|
||||
public static boolean initialize() {
|
||||
RegisteredServiceProvider<Economy> rsp = Bukkit.getServicesManager().getRegistration(Economy.class);
|
||||
if (rsp == null) {
|
||||
return false;
|
||||
}
|
||||
economy = rsp.getProvider();
|
||||
return true;
|
||||
public static void init() {
|
||||
Singleton.initialize();
|
||||
VaultHook.isHooked = true;
|
||||
}
|
||||
|
||||
public static Economy getEconomy() {
|
||||
return economy;
|
||||
public static boolean isHooked() {
|
||||
return isHooked;
|
||||
}
|
||||
|
||||
public static void deposit(OfflinePlayer player, double amount) {
|
||||
economy.depositPlayer(player, amount);
|
||||
public static void deposit(Player player, double amount) {
|
||||
Singleton.deposit(player, amount);
|
||||
}
|
||||
|
||||
public static void withdraw(OfflinePlayer player, double amount) {
|
||||
economy.withdrawPlayer(player, amount);
|
||||
Singleton.withdraw(player, amount);
|
||||
}
|
||||
|
||||
public static double getBalance(OfflinePlayer player) {
|
||||
return economy.getBalance(player);
|
||||
return Singleton.getBalance(player);
|
||||
}
|
||||
|
||||
private static class Singleton {
|
||||
private static Economy economy;
|
||||
|
||||
private static boolean initialize() {
|
||||
RegisteredServiceProvider<Economy> rsp = Bukkit.getServicesManager().getRegistration(Economy.class);
|
||||
if (rsp == null) {
|
||||
return false;
|
||||
}
|
||||
economy = rsp.getProvider();
|
||||
return true;
|
||||
}
|
||||
|
||||
private static Economy getEconomy() {
|
||||
return economy;
|
||||
}
|
||||
|
||||
private static void deposit(OfflinePlayer player, double amount) {
|
||||
economy.depositPlayer(player, amount);
|
||||
}
|
||||
|
||||
private static void withdraw(OfflinePlayer player, double amount) {
|
||||
economy.withdrawPlayer(player, amount);
|
||||
}
|
||||
|
||||
private static double getBalance(OfflinePlayer player) {
|
||||
return economy.getBalance(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -628,6 +628,7 @@ public class BukkitActionManager implements ActionManager<Player> {
|
||||
MathValue<Player> value = MathValue.auto(args);
|
||||
return context -> {
|
||||
if (Math.random() > chance) return;
|
||||
if (!VaultHook.isHooked()) return;
|
||||
VaultHook.deposit(context.getHolder(), value.evaluate(context));
|
||||
};
|
||||
});
|
||||
@@ -635,6 +636,7 @@ public class BukkitActionManager implements ActionManager<Player> {
|
||||
MathValue<Player> value = MathValue.auto(args);
|
||||
return context -> {
|
||||
if (Math.random() > chance) return;
|
||||
if (!VaultHook.isHooked()) return;
|
||||
VaultHook.withdraw(context.getHolder(), value.evaluate(context));
|
||||
};
|
||||
});
|
||||
|
||||
@@ -131,7 +131,7 @@ public class BukkitIntegrationManager implements IntegrationManager {
|
||||
registerSeasonProvider(new CustomCropsSeasonProvider());
|
||||
}
|
||||
if (isHooked("Vault")) {
|
||||
VaultHook.initialize();
|
||||
VaultHook.init();
|
||||
}
|
||||
if (isHooked("BattlePass")){
|
||||
BattlePassQuest battlePassQuest = new BattlePassQuest();
|
||||
|
||||
@@ -257,13 +257,13 @@ mechanics:
|
||||
message_action:
|
||||
type: message
|
||||
value: 'You earned {money_formatted} coins from the fish! You can get {rest_formatted} more coins from market today'
|
||||
command_action:
|
||||
type: command
|
||||
value: 'money give {player} {money}'
|
||||
# Requires Vault and any economy plugin
|
||||
# money_action:
|
||||
# type: give-money
|
||||
# value: '{money}'
|
||||
# Requires Vault and any economy plugin
|
||||
money_action:
|
||||
type: give-money
|
||||
value: '{money}'
|
||||
# command_action:
|
||||
# type: command
|
||||
# value: 'money give {player} {money}'
|
||||
deny-icon:
|
||||
material: REDSTONE_BLOCK
|
||||
display:
|
||||
@@ -312,13 +312,12 @@ mechanics:
|
||||
message_action:
|
||||
type: message
|
||||
value: 'You earned {money_formatted} coins from the fish! You can get {rest_formatted} more coins from market today'
|
||||
command_action:
|
||||
type: command
|
||||
value: 'money give {player} {money}'
|
||||
# Requires Vault and any economy plugin
|
||||
# money_action:
|
||||
# type: give-money
|
||||
# value: '{money}'
|
||||
money_action:
|
||||
type: give-money
|
||||
value: '{money}'
|
||||
# command_action:
|
||||
# type: command
|
||||
# value: 'money give {player} {money}'
|
||||
deny-icon:
|
||||
material: REDSTONE_BLOCK
|
||||
display:
|
||||
|
||||
Reference in New Issue
Block a user