Fancier debug/help
This commit is contained in:
+2
-2
@@ -4,7 +4,6 @@ import com.drtshock.playervaults.PlayerVaults;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.io.BukkitObjectInputStream;
|
||||
import org.kitteh.cardboardbox.CardboardBox;
|
||||
import org.yaml.snakeyaml.external.biz.base64Coder.Base64Coder;
|
||||
|
||||
@@ -20,7 +19,7 @@ public class CardboardBoxSerialization {
|
||||
try {
|
||||
return Base64Coder.encodeLines(writeInventory(inventory.getContents()));
|
||||
} catch (IOException e) {
|
||||
throw new IllegalStateException("Failed to save items for " + target, e);
|
||||
throw PlayerVaults.getInstance().addException(new IllegalStateException("Failed to save items for " + target, e));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +34,7 @@ public class CardboardBoxSerialization {
|
||||
try {
|
||||
return readInventory(Base64Coder.decodeLines(data));
|
||||
} catch (IOException e) {
|
||||
PlayerVaults.getInstance().addException(new IllegalStateException("Failed to save items for " + target, e));
|
||||
PlayerVaults.getInstance().getLogger().log(Level.SEVERE, "Failed to load items for " + target, e);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -19,9 +19,13 @@
|
||||
package com.drtshock.playervaults.vaultmanagement;
|
||||
|
||||
import com.drtshock.playervaults.PlayerVaults;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -30,6 +34,33 @@ import java.io.File;
|
||||
*/
|
||||
public class EconomyOperations {
|
||||
|
||||
private static Economy economy;
|
||||
|
||||
public static boolean setup() {
|
||||
economy = null;
|
||||
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") != null) {
|
||||
RegisteredServiceProvider<Economy> provider = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
|
||||
if (provider != null) {
|
||||
economy = provider.getProvider();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String getName() {
|
||||
return economy == null ? "NONE" : economy.getName();
|
||||
}
|
||||
|
||||
public static String getPermsName() {
|
||||
RegisteredServiceProvider<Permission> provider = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
|
||||
if (provider != null) {
|
||||
Permission perm = provider.getProvider();
|
||||
return perm.getName();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Have a player pay to open a vault.
|
||||
*
|
||||
@@ -49,7 +80,7 @@ public class EconomyOperations {
|
||||
return true;
|
||||
}
|
||||
double cost = PlayerVaults.getInstance().getConf().getEconomy().getFeeToOpen();
|
||||
EconomyResponse resp = PlayerVaults.getInstance().getEconomy().withdrawPlayer(player, cost);
|
||||
EconomyResponse resp = economy.withdrawPlayer(player, cost);
|
||||
if (resp.transactionSuccess()) {
|
||||
PlayerVaults.getInstance().getTL().costToOpen().title().with("price", cost + "").send(player);
|
||||
return true;
|
||||
@@ -71,7 +102,7 @@ public class EconomyOperations {
|
||||
}
|
||||
|
||||
double cost = PlayerVaults.getInstance().getConf().getEconomy().getFeeToCreate();
|
||||
EconomyResponse resp = PlayerVaults.getInstance().getEconomy().withdrawPlayer(player, cost);
|
||||
EconomyResponse resp = economy.withdrawPlayer(player, cost);
|
||||
if (resp.transactionSuccess()) {
|
||||
PlayerVaults.getInstance().getTL().costToCreate().title().with("price", cost + "").send(player);
|
||||
return true;
|
||||
@@ -105,7 +136,7 @@ public class EconomyOperations {
|
||||
}
|
||||
|
||||
double cost = PlayerVaults.getInstance().getConf().getEconomy().getRefundOnDelete();
|
||||
EconomyResponse resp = PlayerVaults.getInstance().getEconomy().depositPlayer(player, cost);
|
||||
EconomyResponse resp = economy.depositPlayer(player, cost);
|
||||
if (resp.transactionSuccess()) {
|
||||
PlayerVaults.getInstance().getTL().refundAmount().title().with("price", cost + "").send(player);
|
||||
return true;
|
||||
|
||||
@@ -370,6 +370,7 @@ public class VaultManager {
|
||||
try {
|
||||
yaml.save(file);
|
||||
} catch (IOException e) {
|
||||
PlayerVaults.getInstance().addException(new IllegalStateException("Failed to save vault file for: " + holder, e));
|
||||
PlayerVaults.getInstance().getLogger().log(Level.SEVERE, "Failed to save vault file for: " + holder, e);
|
||||
}
|
||||
PlayerVaults.debug("Saved vault for " + holder);
|
||||
|
||||
Reference in New Issue
Block a user