hopefully save correctly
This commit is contained in:
@@ -23,7 +23,7 @@ public class VaultManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String title;
|
String title;
|
||||||
private String directory = "plugins" + File.separator + "PlayerVaults" + File.separator + "vaults";
|
private final String directory = "plugins" + File.separator + "PlayerVaults" + File.separator + "vaults";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method to save player's vault.
|
* Method to save player's vault.
|
||||||
@@ -37,12 +37,12 @@ public class VaultManager {
|
|||||||
System.out.println("savevault");
|
System.out.println("savevault");
|
||||||
// Get the player's file and serialize the inventory.
|
// Get the player's file and serialize the inventory.
|
||||||
String ser = Serialization.toBase64(inv);
|
String ser = Serialization.toBase64(inv);
|
||||||
YamlConfiguration file = playerVaultFile(player.getName());
|
YamlConfiguration yaml = playerVaultFile(player.getName());
|
||||||
System.out.println("serial: " + ser);
|
System.out.println("serial: " + ser);
|
||||||
// Prepare to save D:
|
// Prepare to save :D?
|
||||||
file.createSection("vault" + number);
|
yaml.createSection("vault" + number);
|
||||||
file.set("vault" + number + "", ser);
|
yaml.set("vault" + number + "", ser);
|
||||||
saveFile(player.getName());
|
saveFile(player.getName(), yaml);
|
||||||
Commands.inVault.remove(player.getName());
|
Commands.inVault.remove(player.getName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,6 @@ public class VaultManager {
|
|||||||
Inventory inv = Serialization.fromBase64(data);
|
Inventory inv = Serialization.fromBase64(data);
|
||||||
player.openInventory(inv);
|
player.openInventory(inv);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteVault(CommandSender sender, String target, int number) throws IOException {
|
public void deleteVault(CommandSender sender, String target, int number) throws IOException {
|
||||||
@@ -76,11 +75,9 @@ public class VaultManager {
|
|||||||
section.set(null, 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);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
sender.sendMessage(title + " That doesn't exist!");
|
sender.sendMessage(title + " That doesn't exist!");
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,10 +98,8 @@ public class VaultManager {
|
|||||||
return playerFile;
|
return playerFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveFile(String name) throws IOException {
|
public void saveFile(String name, YamlConfiguration yaml) throws IOException {
|
||||||
File file = new File(directory + File.separator + name.toLowerCase() + ".yml");
|
File file = new File(directory + File.separator + name.toLowerCase() + ".yml");
|
||||||
YamlConfiguration yaml = YamlConfiguration.loadConfiguration(file);
|
|
||||||
yaml.save(file);
|
yaml.save(file);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user