Fix a few things, remove bad code
This commit is contained in:
@@ -3,7 +3,6 @@ package com.drtshock.playervaults.util;
|
||||
import com.drtshock.playervaults.PlayerVaults;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
@@ -18,15 +17,14 @@ import org.bukkit.entity.Player;
|
||||
*/
|
||||
public class EconomyOperations {
|
||||
|
||||
private static File CONFIG_FILE;
|
||||
private static YamlConfiguration BUKKIT_CONFIG = new YamlConfiguration();
|
||||
|
||||
public static PlayerVaults PLUGIN;
|
||||
|
||||
public EconomyOperations(PlayerVaults instance) throws FileNotFoundException, IOException, InvalidConfigurationException {
|
||||
public EconomyOperations(PlayerVaults instance) throws IOException, InvalidConfigurationException {
|
||||
PLUGIN = instance;
|
||||
CONFIG_FILE = new File(PLUGIN.getDataFolder(), "config.yml");
|
||||
BUKKIT_CONFIG.load(CONFIG_FILE);
|
||||
File config = new File(PLUGIN.getDataFolder(), "config.yml");
|
||||
BUKKIT_CONFIG.load(config);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -34,17 +32,19 @@ public class EconomyOperations {
|
||||
* @param player The player to pay.
|
||||
* @return The transaction success.
|
||||
*/
|
||||
public static boolean payToOpen(Player player) {
|
||||
public static boolean payToOpen(Player player, int number) {
|
||||
if (!BUKKIT_CONFIG.getBoolean("economy.enabled") || player.hasPermission("playervaults.free") || !PlayerVaults.USE_VAULT)
|
||||
return true;
|
||||
|
||||
double cost = BUKKIT_CONFIG.getDouble("economy.cost-to-open", 10);
|
||||
EconomyResponse resp = PlayerVaults.ECON.withdrawPlayer(player.getName(), cost);
|
||||
if (resp.transactionSuccess()) {
|
||||
player.sendMessage(Lang.TITLE.toString() + Lang.COST_TO_OPEN.toString().replaceAll("%price", "" + cost));
|
||||
return true;
|
||||
if (PlayerVaults.VM.vaultExists(player.getName(), number)) {
|
||||
return payToCreate(player);
|
||||
} else {
|
||||
double cost = BUKKIT_CONFIG.getDouble("economy.cost-to-create", 100);
|
||||
EconomyResponse resp = PlayerVaults.ECON.withdrawPlayer(player.getName(), cost);
|
||||
if (resp.transactionSuccess()) {
|
||||
player.sendMessage(Lang.TITLE.toString() + Lang.COST_TO_OPEN.toString().replaceAll("%price", "" + cost));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -71,9 +71,9 @@ public class Serialization {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Inventory toInventory(List<String> stringItems, int number, boolean large) {
|
||||
public static Inventory toInventory(List<String> stringItems, int number) {
|
||||
VaultHolder holder = new VaultHolder(number);
|
||||
Inventory inv = Bukkit.createInventory(holder, (large) ? 54 : 27, ChatColor.RED + "Vault #" + number);
|
||||
Inventory inv = Bukkit.createInventory(holder, 54, ChatColor.RED + "Vault #" + number);
|
||||
holder.setInventory(inv);
|
||||
List<ItemStack> contents = new ArrayList<ItemStack>();
|
||||
for (String piece : stringItems) {
|
||||
|
||||
@@ -15,7 +15,7 @@ import org.xml.sax.SAXException;
|
||||
public class Updater {
|
||||
|
||||
public Updater(String v) throws SAXException, IOException, ParserConfigurationException {
|
||||
oldVersion = v.substring(0, 5);
|
||||
String oldVersion = v.substring(0, 5);
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL("http://dev.bukkit.org/projects/playervaults/files.rss").openConnection();
|
||||
connection.setConnectTimeout(10000);
|
||||
connection.setReadTimeout(10000);
|
||||
@@ -31,7 +31,6 @@ public class Updater {
|
||||
update = !newVersion.equals(oldVersion);
|
||||
}
|
||||
|
||||
private String oldVersion;
|
||||
private String newVersion;
|
||||
private String link;
|
||||
private boolean update;
|
||||
|
||||
@@ -60,7 +60,7 @@ public class VaultManager {
|
||||
* @param holder The holder of the vault.
|
||||
* @param number The vault number.
|
||||
*/
|
||||
public Inventory loadVault(String holder, int number, boolean large) {
|
||||
public Inventory loadVault(String holder, int number) {
|
||||
VaultViewInfo info = new VaultViewInfo(holder, number);
|
||||
Inventory inv = null;
|
||||
if (PlayerVaults.OPENINVENTORIES.containsKey(info.toString())) {
|
||||
@@ -73,7 +73,7 @@ public class VaultManager {
|
||||
vaultHolder.setInventory(inv);
|
||||
} else {
|
||||
List<String> data = new ArrayList<String>();
|
||||
for (int x = 0; x < ((large) ? 54 : 27); x++) {
|
||||
for (int x = 0; x < 54; x++) {
|
||||
String line = playerFile.getString("vault" + number + "." + x);
|
||||
if (line != null) {
|
||||
data.add(line);
|
||||
@@ -81,7 +81,7 @@ public class VaultManager {
|
||||
data.add("null");
|
||||
}
|
||||
}
|
||||
inv = Serialization.toInventory(data, number, large);
|
||||
inv = Serialization.toInventory(data, number);
|
||||
}
|
||||
PlayerVaults.OPENINVENTORIES.put(info.toString(), inv);
|
||||
}
|
||||
@@ -103,11 +103,16 @@ public class VaultManager {
|
||||
vaultHolder.setInventory(inv);
|
||||
return inv;
|
||||
} else {
|
||||
Inventory inv = Serialization.toInventory(data, number, true);
|
||||
Inventory inv = Serialization.toInventory(data, number);
|
||||
return inv;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean vaultExists(String holder, int number) {
|
||||
YamlConfiguration playerFile = getPlayerVaultFile(holder);
|
||||
return playerFile.contains("vault" + number);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a players vault.
|
||||
* @param sender The sender of whom to send messages to.
|
||||
|
||||
Reference in New Issue
Block a user