mirror of
https://github.com/ColdeZhang/Dominion.git
synced 2024-11-24 08:23:05 +08:00
fix lite-version cant link to vault problem
This commit is contained in:
parent
11123822e4
commit
1ff19f5208
@ -11,7 +11,7 @@ var libraries = listOf<String>()
|
||||
libraries = libraries + "cn.lunadeer:MinecraftPluginUtils:2.0.7"
|
||||
|
||||
group = "cn.lunadeer"
|
||||
version = "2.14.1-beta"
|
||||
version = "2.14.2-beta"
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||
@ -40,6 +40,8 @@ allprojects {
|
||||
compileOnly("com.github.BlueMap-Minecraft:BlueMapAPI:v2.6.2")
|
||||
compileOnly("us.dynmap:DynmapCoreAPI:3.4")
|
||||
compileOnly("me.clip:placeholderapi:2.11.6")
|
||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7")
|
||||
compileOnly("net.milkbowl.vault:VaultUnlockedAPI:2.2")
|
||||
|
||||
if (!BuildFull) {
|
||||
libraries.forEach {
|
||||
|
@ -6,8 +6,8 @@ import cn.lunadeer.dominion.dtos.DominionDTO;
|
||||
import cn.lunadeer.dominion.dtos.PlayerDTO;
|
||||
import cn.lunadeer.dominion.managers.Translation;
|
||||
import cn.lunadeer.dominion.utils.Particle;
|
||||
import cn.lunadeer.dominion.utils.VaultConnect.VaultConnect;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.minecraftpluginutils.VaultConnect.VaultConnect;
|
||||
import cn.lunadeer.minecraftpluginutils.XLogger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
@ -3,7 +3,7 @@ package cn.lunadeer.dominion.managers;
|
||||
import cn.lunadeer.dominion.Dominion;
|
||||
import cn.lunadeer.dominion.dtos.Flag;
|
||||
import cn.lunadeer.dominion.utils.MessageDisplay;
|
||||
import cn.lunadeer.minecraftpluginutils.VaultConnect.VaultConnect;
|
||||
import cn.lunadeer.dominion.utils.VaultConnect.VaultConnect;
|
||||
import cn.lunadeer.minecraftpluginutils.XLogger;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
@ -0,0 +1,49 @@
|
||||
package cn.lunadeer.dominion.utils.VaultConnect;
|
||||
|
||||
import cn.lunadeer.minecraftpluginutils.XLogger;
|
||||
import cn.lunadeer.minecraftpluginutils.i18n.Localization;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class Vault implements VaultInterface {
|
||||
|
||||
private Economy econ = null;
|
||||
|
||||
@Override
|
||||
public boolean init(JavaPlugin plugin) {
|
||||
RegisteredServiceProvider<Economy> rsp = plugin.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
if (rsp != null) {
|
||||
econ = rsp.getProvider();
|
||||
return true;
|
||||
}
|
||||
XLogger.err(Localization.Utils_VaultNotAvailable);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return econ.currencyNamePlural();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return econ.currencyNameSingular();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void withdrawPlayer(Player player, double amount) {
|
||||
econ.withdrawPlayer(player, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void depositPlayer(Player player, double amount) {
|
||||
econ.depositPlayer(player, amount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(Player player) {
|
||||
return econ.getBalance(player);
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package cn.lunadeer.dominion.utils.VaultConnect;
|
||||
|
||||
import cn.lunadeer.minecraftpluginutils.XLogger;
|
||||
import cn.lunadeer.minecraftpluginutils.i18n.Localization;
|
||||
import net.milkbowl.vault2.economy.Economy;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class Vault2 implements VaultInterface {
|
||||
|
||||
private Economy econ = null;
|
||||
|
||||
@Override
|
||||
public boolean init(JavaPlugin plugin) {
|
||||
RegisteredServiceProvider<Economy> rsp = plugin.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
if (rsp != null) {
|
||||
econ = rsp.getProvider();
|
||||
return true;
|
||||
}
|
||||
XLogger.err(Localization.Utils_VaultUnlockedNotAvailable);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNamePlural() {
|
||||
return econ.defaultCurrencyNamePlural();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currencyNameSingular() {
|
||||
return econ.defaultCurrencyNameSingular();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void withdrawPlayer(Player player, double amount) {
|
||||
econ.withdraw("MPU", player.getUniqueId(), BigDecimal.valueOf(amount));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void depositPlayer(Player player, double amount) {
|
||||
econ.deposit("MPU", player.getUniqueId(), BigDecimal.valueOf(amount));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBalance(Player player) {
|
||||
return econ.getBalance("MPU", player.getUniqueId()).doubleValue();
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
package cn.lunadeer.dominion.utils.VaultConnect;
|
||||
|
||||
import cn.lunadeer.minecraftpluginutils.XLogger;
|
||||
import cn.lunadeer.minecraftpluginutils.i18n.Localization;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.server.ServiceRegisterEvent;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class VaultConnect implements Listener {
|
||||
|
||||
public static VaultConnect instance;
|
||||
private VaultInterface vaultInstance = null;
|
||||
private JavaPlugin plugin;
|
||||
|
||||
public VaultConnect(JavaPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
instance = this;
|
||||
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onEnable(ServiceRegisterEvent event) {
|
||||
}
|
||||
|
||||
public boolean economyAvailable() {
|
||||
if (vaultInstance == null) {
|
||||
Plugin vaultPlugin = this.plugin.getServer().getPluginManager().getPlugin("Vault");
|
||||
if (vaultPlugin == null) {
|
||||
XLogger.err(Localization.Utils_VaultNotAvailable);
|
||||
return false;
|
||||
}
|
||||
if (vaultPlugin.getDescription().getAuthors().contains("creatorfromhell")) {
|
||||
vaultInstance = new Vault2();
|
||||
} else {
|
||||
vaultInstance = new Vault();
|
||||
}
|
||||
if (!vaultInstance.init(plugin)) {
|
||||
vaultInstance = null;
|
||||
XLogger.err(Localization.Utils_NoEconomyPlugin);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
XLogger.debug("Vault connected.");
|
||||
return true;
|
||||
}
|
||||
|
||||
public String currencyNamePlural() {
|
||||
if (economyAvailable()) {
|
||||
return vaultInstance.currencyNamePlural();
|
||||
}
|
||||
XLogger.warn(Localization.Utils_NoEconomyPlugin);
|
||||
return "";
|
||||
}
|
||||
|
||||
public String currencyNameSingular() {
|
||||
if (economyAvailable()) {
|
||||
return vaultInstance.currencyNameSingular();
|
||||
}
|
||||
XLogger.warn(Localization.Utils_NoEconomyPlugin);
|
||||
return "";
|
||||
}
|
||||
|
||||
public void withdrawPlayer(Player player, double amount) {
|
||||
if (economyAvailable()) {
|
||||
vaultInstance.withdrawPlayer(player, amount);
|
||||
return;
|
||||
}
|
||||
XLogger.warn(Localization.Utils_NoEconomyPlugin);
|
||||
}
|
||||
|
||||
public void depositPlayer(Player player, double amount) {
|
||||
if (economyAvailable()) {
|
||||
vaultInstance.depositPlayer(player, amount);
|
||||
return;
|
||||
}
|
||||
XLogger.warn(Localization.Utils_NoEconomyPlugin);
|
||||
}
|
||||
|
||||
public double getBalance(Player player) {
|
||||
if (economyAvailable()) {
|
||||
return vaultInstance.getBalance(player);
|
||||
}
|
||||
XLogger.warn(Localization.Utils_NoEconomyPlugin);
|
||||
return 0;
|
||||
}
|
||||
|
||||
private static boolean foundClass(String className) {
|
||||
try {
|
||||
Class.forName(className);
|
||||
return true;
|
||||
} catch (ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.lunadeer.dominion.utils.VaultConnect;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public interface VaultInterface {
|
||||
|
||||
public boolean init(JavaPlugin plugin);
|
||||
|
||||
public String currencyNamePlural();
|
||||
|
||||
|
||||
public String currencyNameSingular();
|
||||
|
||||
public void withdrawPlayer(Player player, double amount);
|
||||
|
||||
public void depositPlayer(Player player, double amount);
|
||||
|
||||
public double getBalance(Player player);
|
||||
|
||||
}
|
BIN
logos/logo4.png
Normal file
BIN
logos/logo4.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
@ -5,8 +5,8 @@ import cn.lunadeer.dominion.Dominion;
|
||||
import cn.lunadeer.dominion.dtos.DominionDTO;
|
||||
import cn.lunadeer.dominion.managers.Translation;
|
||||
import cn.lunadeer.dominion.utils.Particle;
|
||||
import cn.lunadeer.dominion.utils.VaultConnect.VaultConnect;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.minecraftpluginutils.VaultConnect.VaultConnect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
|
@ -5,8 +5,8 @@ import cn.lunadeer.dominion.Dominion;
|
||||
import cn.lunadeer.dominion.dtos.DominionDTO;
|
||||
import cn.lunadeer.dominion.managers.Translation;
|
||||
import cn.lunadeer.dominion.utils.Particle;
|
||||
import cn.lunadeer.dominion.utils.VaultConnect.VaultConnect;
|
||||
import cn.lunadeer.minecraftpluginutils.Notification;
|
||||
import cn.lunadeer.minecraftpluginutils.VaultConnect.VaultConnect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
|
Loading…
Reference in New Issue
Block a user