Base64 vault management
This commit is contained in:
@@ -5,6 +5,7 @@ import com.drtshock.playervaults.util.Lang;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
@@ -22,6 +23,7 @@ import java.util.logging.Level;
|
||||
/**
|
||||
* Class to handle vault operations with new UUIDs.
|
||||
*/
|
||||
@Deprecated
|
||||
public class UUIDVaultManager {
|
||||
|
||||
private static UUIDVaultManager instance;
|
||||
@@ -30,7 +32,7 @@ public class UUIDVaultManager {
|
||||
instance = this;
|
||||
}
|
||||
|
||||
private final File directory = PlayerVaults.getInstance().getVaultData();
|
||||
private final File directory = PlayerVaults.getInstance().getUuidData();
|
||||
private final Map<String, YamlConfiguration> cachedVaultFiles = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
@@ -135,7 +137,6 @@ public class UUIDVaultManager {
|
||||
* @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, String title) {
|
||||
@@ -156,24 +157,28 @@ public class UUIDVaultManager {
|
||||
*
|
||||
* @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(UUID holder, int number) {
|
||||
YamlConfiguration playerFile = getPlayerVaultFile(holder);
|
||||
List<String> data = playerFile.getStringList("vault" + number);
|
||||
OfflinePlayer player = Bukkit.getOfflinePlayer(holder);
|
||||
if (player == null || !player.hasPlayedBefore()) {
|
||||
return null;
|
||||
}
|
||||
String title = Lang.VAULT_TITLE.toString().replace("%number", String.valueOf(number)).replace("%p", Bukkit.getOfflinePlayer(holder).getName());
|
||||
if (data == null) {
|
||||
ConfigurationSection section = playerFile.getConfigurationSection("vault" + number);
|
||||
int maxSize = VaultOperations.getMaxVaultSize(holder);
|
||||
|
||||
String title = Lang.VAULT_TITLE.toString().replace("%number", String.valueOf(number));
|
||||
|
||||
if (section == null) {
|
||||
VaultHolder vaultHolder = new VaultHolder(number);
|
||||
Inventory inv = Bukkit.createInventory(vaultHolder, VaultOperations.getMaxVaultSize(player), Lang.VAULT_TITLE.toString().replace("%number", String.valueOf(number)).replace("%p", player.getName()));
|
||||
Inventory inv = Bukkit.createInventory(vaultHolder, maxSize, title);
|
||||
vaultHolder.setInventory(inv);
|
||||
return inv;
|
||||
} else {
|
||||
return Serialization.toInventory(data, number, VaultOperations.getMaxVaultSize(player), title);
|
||||
List<String> data = new ArrayList<>();
|
||||
for (String s : section.getKeys(false)) {
|
||||
String value = section.getString(s);
|
||||
data.add(value);
|
||||
}
|
||||
|
||||
return Serialization.toInventory(data, number, maxSize, title);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -182,7 +187,6 @@ public class UUIDVaultManager {
|
||||
*
|
||||
* @param holder holder of the vault.
|
||||
* @param number vault number.
|
||||
*
|
||||
* @return true if the vault file and vault number exist in that file, otherwise false.
|
||||
*/
|
||||
public boolean vaultExists(String holder, int number) {
|
||||
@@ -200,7 +204,6 @@ public class UUIDVaultManager {
|
||||
* @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, final String holder, final int number) throws IOException {
|
||||
@@ -264,7 +267,6 @@ public class UUIDVaultManager {
|
||||
* 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) {
|
||||
|
||||
Reference in New Issue
Block a user