This commit is contained in:
Trent Hensler
2013-03-07 15:33:56 -06:00
parent e5ed68f8d3
commit ef30ff91b5
4 changed files with 11 additions and 13 deletions
@@ -65,10 +65,10 @@ public class VaultOperations {
sender.sendMessage(pv + "Opening vault " + ChatColor.GREEN + number); sender.sendMessage(pv + "Opening vault " + ChatColor.GREEN + number);
return true; return true;
} }
}
else { else {
Feedback.noPerms(sender); Feedback.noPerms(sender);
} }
}
return false; return false;
} }
public static void deleteOwnVault(Player sender, String arg) { public static void deleteOwnVault(Player sender, String arg) {
@@ -7,7 +7,6 @@ import java.io.IOException;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -22,7 +21,9 @@ public class VaultManager {
this.plugin = instance; this.plugin = instance;
} }
String title; String title = ChatColor.DARK_RED + "[" + ChatColor.WHITE + "PlayerVaults" +
ChatColor.DARK_RED + "]" + ChatColor.WHITE + ": ";
private final String directory = "plugins" + File.separator + "PlayerVaults" + File.separator + "vaults"; private final String directory = "plugins" + File.separator + "PlayerVaults" + File.separator + "vaults";
/** /**
@@ -33,7 +34,6 @@ public class VaultManager {
* @throws IOException * @throws IOException
*/ */
public void saveVault(Inventory inv, String player, int number) throws IOException { public void saveVault(Inventory inv, String player, int number) throws IOException {
// Get the player's file and serialize the inventory.
String ser = Serialization.toBase64(inv); String ser = Serialization.toBase64(inv);
YamlConfiguration yaml = playerVaultFile(player); YamlConfiguration yaml = playerVaultFile(player);
yaml.set("vault" + number + "", ser); yaml.set("vault" + number + "", ser);
@@ -61,15 +61,13 @@ public class VaultManager {
public void deleteVault(CommandSender sender, String target, int number) throws IOException { public void deleteVault(CommandSender sender, String target, int number) throws IOException {
String name = target.toLowerCase(); String name = target.toLowerCase();
File file = new File(directory + name + ".yml"); File file = new File(directory + File.separator + name.toLowerCase() + ".yml");
FileConfiguration playerFile = YamlConfiguration.loadConfiguration(file); FileConfiguration playerFile = YamlConfiguration.loadConfiguration(file);
if(file.exists()) { if(file.exists()) {
ConfigurationSection section = playerFile.getConfigurationSection("vault" + number); playerFile.set("vault" + number, null);
section.set(null, null);
sender.sendMessage(title + "Deleting " + ChatColor.GREEN + " " + number); sender.sendMessage(title + "Deleting " + ChatColor.GREEN + " " + number);
playerFile.save(file); playerFile.save(file);
} } else {
else {
sender.sendMessage(title + " That doesn't exist!"); sender.sendMessage(title + " That doesn't exist!");
} }
} }