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