diff --git a/plugin.yml b/plugin.yml
index 354c7469..5baa5ab5 100644
--- a/plugin.yml
+++ b/plugin.yml
@@ -1,5 +1,5 @@
name: Vault
-version: 2.2.1
+version: 2.3.0
description: A PR-friendly version of Vault; Where PRs are actually accepted.
authors: [cereal, Sleaker, mung3r, creatorfromhell]
website: https://tnemc.net
diff --git a/pom.xml b/pom.xml
index a503e88d..bcf6578d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
UTF-8
1.13.1-R0.1-SNAPSHOT
${project.groupId}.${project.artifactId}
- 2.2
+ 2.3
diff --git a/src/net/milkbowl/vault/Vault.java b/src/net/milkbowl/vault/Vault.java
index 9dcf1363..f8e3bc84 100644
--- a/src/net/milkbowl/vault/Vault.java
+++ b/src/net/milkbowl/vault/Vault.java
@@ -37,6 +37,7 @@
import java.io.BufferedReader;
import java.io.InputStreamReader;
+import java.math.BigDecimal;
import java.net.URL;
import java.net.URLConnection;
import java.util.Collection;
@@ -45,7 +46,7 @@
public class Vault extends JavaPlugin {
- private static final String VAULT_BUKKIT_URL = "https://dev.bukkit.org/projects/Vault";
+ private static final String VAULT_BUKKIT_URL = "https://www.spigotmc.org/resources/vaultunlocked.117277/";
private Logger log;
private String newVersionTitle = "";
private double newVersion = 0;
@@ -108,8 +109,9 @@ public boolean onCommand(CommandSender sender, Command command, String commandLa
private void convertCommand(CommandSender sender, String[] args) {
final Collection> econs = this.getServer().getServicesManager().getRegistrations(Economy.class);
+ final Collection> econs2 = this.getServer().getServicesManager().getRegistrations(net.milkbowl.vault2.economy.Economy.class);
- if (econs == null || econs.size() < 2) {
+ if (econs == null || econs.size() < 2 && econs2.isEmpty()) {
sender.sendMessage("You must have at least 2 economies loaded to convert.");
return;
@@ -118,8 +120,11 @@ private void convertCommand(CommandSender sender, String[] args) {
sender.sendMessage("You must specify only the economy to convert from and the economy to convert to. (names should not contain spaces)");
return;
}
+
Economy econ1 = null;
Economy econ2 = null;
+ net.milkbowl.vault2.economy.Economy econ1Unlocked = null;
+ net.milkbowl.vault2.economy.Economy econ2Unlocked = null;
final StringBuilder economies = new StringBuilder();
for (RegisteredServiceProvider econ : econs) {
@@ -140,12 +145,30 @@ private void convertCommand(CommandSender sender, String[] args) {
economies.append(econName);
}
- if (econ1 == null) {
+ for (RegisteredServiceProvider econ : econs2) {
+
+ final String econName = econ.getProvider().getName().replace(" ", "");
+ if (econName.equalsIgnoreCase(args[0])) {
+
+ econ1Unlocked = econ.getProvider();
+ } else if (econName.equalsIgnoreCase(args[1])) {
+
+ econ2Unlocked = econ.getProvider();
+ }
+
+ if (economies.length() > 0) {
+
+ economies.append(", ");
+ }
+ economies.append(econName);
+ }
+
+ if (econ1 == null && econ1Unlocked == null) {
sender.sendMessage("Could not find " + args[0] + " loaded on the server, check your spelling.");
sender.sendMessage("Valid economies are: " + economies);
return;
- } else if (econ2 == null) {
+ } else if (econ2 == null && econ2Unlocked == null) {
sender.sendMessage("Could not find " + args[1] + " loaded on the server, check your spelling.");
sender.sendMessage("Valid economies are: " + economies);
@@ -153,19 +176,60 @@ private void convertCommand(CommandSender sender, String[] args) {
}
sender.sendMessage("This may take some time to convert, expect server lag.");
+ final boolean useUnlocked1 = (econ1Unlocked != null);
+ final boolean useUnlocked2 = (econ2Unlocked != null);
+ final String pluginID = "vault conversion";
+
for (OfflinePlayer op : Bukkit.getServer().getOfflinePlayers()) {
- if (econ1.hasAccount(op)) {
- if (econ2.hasAccount(op)) {
- continue;
+
+ if(useUnlocked1) {
+ if(useUnlocked2) {
+ if(econ2Unlocked.hasAccount(op.getUniqueId())) {
+ continue;
+ }
+ econ2Unlocked.createAccount(op.getUniqueId(), op.getName());
+ final BigDecimal diff = econ1Unlocked.getBalance(pluginID, op.getUniqueId()).subtract(econ2Unlocked.getBalance(pluginID, op.getUniqueId()));
+ if(diff.compareTo(BigDecimal.ZERO) > 0) {
+ econ2Unlocked.deposit(pluginID, op.getUniqueId(), diff);
+ } else if (diff.compareTo(BigDecimal.ZERO) < 0) {
+ econ2Unlocked.withdraw(pluginID, op.getUniqueId(), diff.negate());
+ }
+ } else {
+ if(econ2.hasAccount(op)) {
+ continue;
+ }
+ econ2.createPlayerAccount(op);
+ final BigDecimal diff = econ1Unlocked.getBalance(pluginID, op.getUniqueId()).subtract(BigDecimal.valueOf(econ2.getBalance(op)));
+ if(diff.compareTo(BigDecimal.ZERO) > 0) {
+ econ2.depositPlayer(op, diff.doubleValue());
+ } else if (diff.compareTo(BigDecimal.ZERO) < 0) {
+ econ2.withdrawPlayer(op, diff.negate().doubleValue());
+ }
}
- econ2.createPlayerAccount(op);
- double diff = econ1.getBalance(op) - econ2.getBalance(op);
- if (diff > 0) {
- econ2.depositPlayer(op, diff);
- } else if (diff < 0) {
- econ2.withdrawPlayer(op, -diff);
+ } else {
+ if(useUnlocked2) {
+ if(econ2Unlocked.hasAccount(op.getUniqueId())) {
+ continue;
+ }
+ econ2Unlocked.createAccount(op.getUniqueId(), op.getName());
+ final BigDecimal diff = BigDecimal.valueOf(econ1.getBalance(op)).subtract(econ2Unlocked.getBalance(pluginID, op.getUniqueId()));
+ if(diff.compareTo(BigDecimal.ZERO) > 0) {
+ econ2Unlocked.deposit(pluginID, op.getUniqueId(), diff);
+ } else if (diff.compareTo(BigDecimal.ZERO) < 0) {
+ econ2Unlocked.withdraw(pluginID, op.getUniqueId(), diff.negate());
+ }
+ } else {
+ if(econ2.hasAccount(op)) {
+ continue;
+ }
+ econ2.createPlayerAccount(op);
+ final BigDecimal diff = BigDecimal.valueOf(econ1.getBalance(op)).subtract(BigDecimal.valueOf(econ2.getBalance(op)));
+ if(diff.compareTo(BigDecimal.ZERO) > 0) {
+ econ2.depositPlayer(op, diff.doubleValue());
+ } else if (diff.compareTo(BigDecimal.ZERO) < 0) {
+ econ2.withdrawPlayer(op, diff.negate().doubleValue());
+ }
}
-
}
}
sender.sendMessage("Conversion complete, please verify the data before using it.");