Update vault size each time inventory is opened.

Before, the VaultViewInfo was being stored as name instead of uuid as well as not being removed when a vault was closed. This caused the same inventory to be accessed from memory each time the vault was opened after the first opening since the last restart when it would load from file. Since we are recreating the inventory each time, there will likely be a performance loss but we will update the vault title and size each time its opened. Resolves #58.
This commit is contained in:
drtshock
2015-04-27 14:02:51 -05:00
parent 8375d71e3e
commit ede738019a
8 changed files with 59 additions and 292 deletions
@@ -16,11 +16,16 @@
*/
package com.drtshock.playervaults.vaultmanagement;
import org.bukkit.Bukkit;
import java.util.UUID;
/**
* A class that stores information about a vault viewing including the holder of the vault, and the vault number.
*/
public class VaultViewInfo {
UUID uuid;
String holder;
int number;
@@ -30,20 +35,43 @@ public class VaultViewInfo {
* @param s The holder of the vault.
* @param i The vault number.
*/
@Deprecated
public VaultViewInfo(String s, int i) {
this.holder = s;
this.number = i;
}
/**
* Makes a VaultViewInfo object.
*
* @param uuid uuid of viewer.
* @param i vault number
*/
public VaultViewInfo(UUID uuid, int i) {
this.uuid = uuid;
this.number = i;
this.holder = Bukkit.getOfflinePlayer(uuid).getName();
}
/**
* Get the holder of the vault.
*
* @return The holder of the vault.
*/
@Deprecated
public String getHolder() {
return this.holder;
}
/**
* Get the vault holder's UUID.
*
* @return The vault holder's UUID.
*/
public UUID getHolderUUID() {
return this.uuid;
}
/**
* Get the vault number.
*
@@ -55,6 +83,6 @@ public class VaultViewInfo {
@Override
public String toString() {
return this.holder + " " + this.number;
return this.uuid + " " + this.number;
}
}