Reformat
This commit is contained in:
@@ -18,17 +18,15 @@ package com.drtshock.playervaults.vaultmanagement;
|
||||
|
||||
import com.drtshock.playervaults.PlayerVaults;
|
||||
import com.drtshock.playervaults.util.Lang;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import net.milkbowl.vault.economy.EconomyResponse;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A class that handles all economy operations.
|
||||
*/
|
||||
@@ -48,6 +46,7 @@ public class EconomyOperations {
|
||||
*
|
||||
* @param player The player to pay.
|
||||
* @param number The vault number to open.
|
||||
*
|
||||
* @return The transaction success.
|
||||
*/
|
||||
public static boolean payToOpen(Player player, int number) {
|
||||
@@ -71,6 +70,7 @@ public class EconomyOperations {
|
||||
* Have a player pay to create a vault.
|
||||
*
|
||||
* @param player The player to pay.
|
||||
*
|
||||
* @return The transaction success
|
||||
*/
|
||||
public static boolean payToCreate(Player player) {
|
||||
@@ -92,6 +92,7 @@ public class EconomyOperations {
|
||||
*
|
||||
* @param player The player to receive the money.
|
||||
* @param number The vault number to delete.
|
||||
*
|
||||
* @return The transaction success.
|
||||
*/
|
||||
public static boolean refundOnDelete(Player player, int number) {
|
||||
|
||||
@@ -16,13 +16,6 @@
|
||||
*/
|
||||
package com.drtshock.playervaults.vaultmanagement;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
@@ -33,11 +26,13 @@ import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
/**
|
||||
* Fancy JSON serialization mostly by evilmidget38.
|
||||
*
|
||||
* @author evilmidget38, gomeow
|
||||
*
|
||||
*/
|
||||
public class Serialization {
|
||||
|
||||
|
||||
@@ -20,8 +20,7 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
/**
|
||||
* Represents a VaultHolder to assist in detection of Player Vaults from other
|
||||
* plugins.
|
||||
* Represents a VaultHolder to assist in detection of Player Vaults from other plugins.
|
||||
*/
|
||||
public class VaultHolder implements InventoryHolder {
|
||||
|
||||
|
||||
@@ -18,23 +18,20 @@ package com.drtshock.playervaults.vaultmanagement;
|
||||
|
||||
import com.drtshock.playervaults.PlayerVaults;
|
||||
import com.drtshock.playervaults.util.Lang;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A class for managing actual IO to the files, loading inventories, and saving
|
||||
* them.
|
||||
* A class for managing actual IO to the files, loading inventories, and saving them.
|
||||
*/
|
||||
public class VaultManager {
|
||||
|
||||
@@ -43,6 +40,7 @@ public class VaultManager {
|
||||
public VaultManager(PlayerVaults instance) {
|
||||
this.plugin = instance;
|
||||
}
|
||||
|
||||
private final String directory = "plugins" + File.separator + "PlayerVaults" + File.separator + "vaults";
|
||||
|
||||
/**
|
||||
@@ -51,6 +49,7 @@ public class VaultManager {
|
||||
* @param inventory The inventory to be saved.
|
||||
* @param player The player of whose file to save to.
|
||||
* @param number The vault number.
|
||||
*
|
||||
* @throws IOException Uh oh!
|
||||
*/
|
||||
public void saveVault(Inventory inventory, String player, int number) throws IOException {
|
||||
@@ -92,7 +91,7 @@ public class VaultManager {
|
||||
if (playerFile.getConfigurationSection("vault" + number) == null) {
|
||||
VaultHolder vaultHolder = new VaultHolder(number);
|
||||
Player player = Bukkit.getPlayer(holder);
|
||||
if(player == null) {
|
||||
if (player == null) {
|
||||
return null;
|
||||
}
|
||||
if (EconomyOperations.payToCreate(player)) {
|
||||
@@ -145,12 +144,12 @@ public class VaultManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an inventory from file. Returns null if the inventory doesn't exist.
|
||||
* SHOULD ONLY BE USED INTERNALLY
|
||||
* Get an inventory from file. Returns null if the inventory doesn't exist. SHOULD ONLY BE USED INTERNALLY
|
||||
*
|
||||
* @param playerFile the YamlConfiguration file.
|
||||
* @param size the size of the vault.
|
||||
* @param number the vault number.
|
||||
*
|
||||
* @return inventory if exists, otherwise null.
|
||||
*/
|
||||
private Inventory getInventory(YamlConfiguration playerFile, int size, int number) {
|
||||
@@ -167,11 +166,11 @@ public class VaultManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an inventory without storing references to it. Used for dropping a
|
||||
* players inventories on death.
|
||||
* Gets an inventory without storing references to it. Used for dropping a players inventories on death.
|
||||
*
|
||||
* @param holder The holder of the vault.
|
||||
* @param number The vault number.
|
||||
*
|
||||
* @return The inventory of the specified holder and vault number.
|
||||
*/
|
||||
public Inventory getVault(String holder, int number) {
|
||||
@@ -199,12 +198,13 @@ public class VaultManager {
|
||||
* @param sender The sender of whom to send messages to.
|
||||
* @param holder The vault holder.
|
||||
* @param number The vault number.
|
||||
*
|
||||
* @throws IOException Uh oh!
|
||||
*/
|
||||
public void deleteVault(CommandSender sender, String holder, int number) throws IOException {
|
||||
String name = holder.toLowerCase();
|
||||
File file = new File(directory + File.separator + name.toLowerCase() + ".yml");
|
||||
if(!file.exists()) {
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
FileConfiguration playerFile = YamlConfiguration.loadConfiguration(file);
|
||||
@@ -223,6 +223,7 @@ public class VaultManager {
|
||||
* Get the holder's vault file. Create if doesn't exist.
|
||||
*
|
||||
* @param holder The vault holder.
|
||||
*
|
||||
* @return The holder's vault config file.
|
||||
*/
|
||||
public YamlConfiguration getPlayerVaultFile(String holder) {
|
||||
@@ -247,6 +248,7 @@ public class VaultManager {
|
||||
*
|
||||
* @param holder The vault holder of whose file to save.
|
||||
* @param yaml The config to save.
|
||||
*
|
||||
* @throws IOException Uh oh!
|
||||
*/
|
||||
public void saveFile(String holder, YamlConfiguration yaml) throws IOException {
|
||||
|
||||
@@ -18,23 +18,22 @@ package com.drtshock.playervaults.vaultmanagement;
|
||||
|
||||
import com.drtshock.playervaults.PlayerVaults;
|
||||
import com.drtshock.playervaults.util.Lang;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class VaultOperations {
|
||||
|
||||
/**
|
||||
* Check whether or not the player has permission to open the requested
|
||||
* vault.
|
||||
* Check whether or not the player has permission to open the requested vault.
|
||||
*
|
||||
* @param sender The person to check.
|
||||
* @param number The vault number.
|
||||
*
|
||||
* @return Whether or not they have permission.
|
||||
*/
|
||||
public static boolean checkPerms(CommandSender sender, int number) {
|
||||
@@ -53,8 +52,8 @@ public class VaultOperations {
|
||||
* Get the max size vault a player is allowed to have.
|
||||
*
|
||||
* @param player that is having his permissions checked.
|
||||
* @return max size as integer. If no max size is set then it will default
|
||||
* to 54.
|
||||
*
|
||||
* @return max size as integer. If no max size is set then it will default to 54.
|
||||
*/
|
||||
public static int getMaxVaultSize(Player player) {
|
||||
if (player == null) {
|
||||
@@ -73,6 +72,7 @@ public class VaultOperations {
|
||||
*
|
||||
* @param player The player to open to.
|
||||
* @param arg The vault number to open.
|
||||
*
|
||||
* @return Whether or not the player was allowed to open it.
|
||||
*/
|
||||
public static boolean openOwnVault(Player player, String arg) {
|
||||
@@ -107,6 +107,7 @@ public class VaultOperations {
|
||||
* @param player The player to open to.
|
||||
* @param holder The user to whom the requested vault belongs.
|
||||
* @param arg The vault number to open.
|
||||
*
|
||||
* @return Whether or not the player was allowed to open it.
|
||||
*/
|
||||
public static boolean openOtherVault(Player player, String holder, String arg) {
|
||||
|
||||
@@ -17,8 +17,7 @@
|
||||
package com.drtshock.playervaults.vaultmanagement;
|
||||
|
||||
/**
|
||||
* A class that stores information about a vault viewing including the holder of
|
||||
* the vault, and the vault number.
|
||||
* A class that stores information about a vault viewing including the holder of the vault, and the vault number.
|
||||
*/
|
||||
public class VaultViewInfo {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user