Revert "Apparently needed to reformat."
This reverts commit 101098ae7b.
This commit is contained in:
@@ -120,7 +120,7 @@ public class PlayerVaults extends JavaPlugin {
|
||||
|
||||
player.closeInventory();
|
||||
}
|
||||
|
||||
|
||||
saveSignsFile();
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.drtshock.playervaults.util.Lang;
|
||||
import com.drtshock.playervaults.vaultmanagement.UUIDVaultManager;
|
||||
import com.drtshock.playervaults.vaultmanagement.VaultOperations;
|
||||
import com.drtshock.playervaults.vaultmanagement.VaultViewInfo;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
@@ -56,7 +57,7 @@ public class Listeners implements Listener {
|
||||
Inventory inv = player.getOpenInventory().getTopInventory();
|
||||
if (inv.getViewers().size() == 1) {
|
||||
VaultViewInfo info = PlayerVaults.getInstance().getInVault().get(player.getUniqueId().toString());
|
||||
if (Bukkit.isPrimaryThread() && player.getUniqueId().equals(info.getHolderUUID())) {
|
||||
if(Bukkit.isPrimaryThread() && player.getUniqueId().equals(info.getHolderUUID())){
|
||||
// Running in main thread, and it's the player's own vault. So we can just cache this until logout.
|
||||
UUIDVaultManager.getInstance().getCachedVaults().setCachedVault(info.getHolderUUID(), info.getNumber(), inv);
|
||||
} else {
|
||||
@@ -76,7 +77,7 @@ public class Listeners implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public void flushVaultCache(Player player) {
|
||||
public void flushVaultCache(Player player){
|
||||
UUIDVaultManager.getInstance().getCachedVaults().flushVaultCacheToFile(player.getUniqueId());
|
||||
}
|
||||
|
||||
|
||||
@@ -24,8 +24,7 @@ import java.util.zip.ZipFile;
|
||||
* <b>AT ALL</b>. <br> If you fail to include this option in your config, your plugin will be <b>REJECTED</b> when you
|
||||
* attempt to submit it to dev.bukkit.org.
|
||||
* <p/>
|
||||
* An example of a good configuration option would be something similar to 'auto-update: true' - if this value is set
|
||||
* to
|
||||
* An example of a good configuration option would be something similar to 'auto-update: true' - if this value is set to
|
||||
* false you may NOT run the auto-updater. <br> If you are unsure about these rules, please read the plugin submission
|
||||
* guidelines: http://goo.gl/8iU5l
|
||||
*
|
||||
|
||||
@@ -1,46 +1,47 @@
|
||||
package com.drtshock.playervaults.vaultmanagement;
|
||||
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
@SuppressWarnings("serial") public class CachedVaults extends HashMap<UUID, CachedVaultsMap> {
|
||||
public void setCachedVault(UUID playerUUID, int id, Inventory inventory) {
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class CachedVaults extends HashMap<UUID, CachedVaultsMap> {
|
||||
public void setCachedVault(UUID playerUUID, int id, Inventory inventory){
|
||||
CachedVaultsMap vaultCacheMap = this.containsKey(playerUUID) ? this.get(playerUUID) : new CachedVaultsMap();
|
||||
vaultCacheMap.setCachedVault(id, inventory);
|
||||
this.put(playerUUID, vaultCacheMap);
|
||||
}
|
||||
|
||||
public Inventory getCachedVault(UUID playerUUID, int id) {
|
||||
|
||||
public Inventory getCachedVault(UUID playerUUID, int id){
|
||||
return this.containsKey(playerUUID) ? this.get(playerUUID).getCachedVault(id) : null;
|
||||
}
|
||||
|
||||
public boolean hasVaultCached(UUID playerUUID, int id) {
|
||||
|
||||
public boolean hasVaultCached(UUID playerUUID, int id){
|
||||
return this.containsKey(playerUUID) && this.get(playerUUID).getCachedVault(id) != null;
|
||||
}
|
||||
|
||||
public void clearVaultCache(UUID playerUUID) {
|
||||
if (this.containsKey(playerUUID)) {
|
||||
|
||||
public void clearVaultCache(UUID playerUUID){
|
||||
if(this.containsKey(playerUUID)){
|
||||
this.get(playerUUID).clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteVaultCache(UUID playerUUID) {
|
||||
|
||||
public void deleteVaultCache(UUID playerUUID){
|
||||
this.remove(playerUUID);
|
||||
}
|
||||
|
||||
public void flushVaultCacheToFile(UUID playerUUID) {
|
||||
if (this.containsKey(playerUUID)) {
|
||||
for (java.util.Map.Entry<Integer, Inventory> data : this.get(playerUUID).entrySet()) {
|
||||
|
||||
public void flushVaultCacheToFile(UUID playerUUID){
|
||||
if(this.containsKey(playerUUID)){
|
||||
for(java.util.Map.Entry<Integer, Inventory> data : this.get(playerUUID).entrySet()){
|
||||
try {
|
||||
UUIDVaultManager.getInstance().saveVault(data.getValue(), playerUUID, data.getKey());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.deleteVaultCache(playerUUID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
package com.drtshock.playervaults.vaultmanagement;
|
||||
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@SuppressWarnings("serial") public class CachedVaultsMap extends HashMap<Integer, Inventory> {
|
||||
public void setCachedVault(int id, Inventory inventory) {
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
public class CachedVaultsMap extends HashMap<Integer, Inventory> {
|
||||
public void setCachedVault(int id, Inventory inventory){
|
||||
this.put(id, inventory);
|
||||
}
|
||||
|
||||
public Inventory getCachedVault(int id) {
|
||||
|
||||
public Inventory getCachedVault(int id){
|
||||
return this.containsKey(id) ? this.get(id) : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
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.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -10,11 +15,8 @@ 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;
|
||||
import java.util.UUID;
|
||||
import com.drtshock.playervaults.PlayerVaults;
|
||||
import com.drtshock.playervaults.util.Lang;
|
||||
|
||||
/**
|
||||
* Class to handle vault operations with new UUIDs.
|
||||
@@ -31,7 +33,7 @@ public class UUIDVaultManager {
|
||||
|
||||
private final File directory = PlayerVaults.getInstance().getVaultData();
|
||||
|
||||
public CachedVaults getCachedVaults() {
|
||||
public CachedVaults getCachedVaults(){
|
||||
return cachedVaults;
|
||||
}
|
||||
|
||||
@@ -71,7 +73,7 @@ public class UUIDVaultManager {
|
||||
* @param number The vault number.
|
||||
*/
|
||||
public Inventory loadOwnVault(Player player, int number, int size) {
|
||||
if (cachedVaults.hasVaultCached(player.getUniqueId(), number)) {
|
||||
if(cachedVaults.hasVaultCached(player.getUniqueId(), number)){
|
||||
return cachedVaults.getCachedVault(player.getUniqueId(), number);
|
||||
}
|
||||
|
||||
@@ -117,7 +119,7 @@ public class UUIDVaultManager {
|
||||
* @param number The vault number.
|
||||
*/
|
||||
public Inventory loadOtherVault(UUID holder, int number, int size) {
|
||||
if (cachedVaults.hasVaultCached(holder, number)) {
|
||||
if(cachedVaults.hasVaultCached(holder, number)){
|
||||
return cachedVaults.getCachedVault(holder, number);
|
||||
}
|
||||
|
||||
@@ -143,7 +145,7 @@ public class UUIDVaultManager {
|
||||
}
|
||||
PlayerVaults.getInstance().getOpenInventories().put(info.toString(), inv);
|
||||
}
|
||||
|
||||
|
||||
cachedVaults.setCachedVault(holder, number, inv);
|
||||
return inv;
|
||||
}
|
||||
@@ -210,11 +212,11 @@ public class UUIDVaultManager {
|
||||
* @throws IOException Uh oh!
|
||||
*/
|
||||
public void deleteVault(CommandSender sender, UUID holder, int number) throws IOException {
|
||||
File file = new File(directory, holder.toString() + ".yml");
|
||||
File file = new File(directory, holder.toString() + ".yml");
|
||||
if (!file.exists()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
cachedVaults.clearVaultCache(holder);
|
||||
|
||||
FileConfiguration playerFile = YamlConfiguration.loadConfiguration(file);
|
||||
|
||||
Reference in New Issue
Block a user