PlayerFiles generate
This commit is contained in:
@@ -54,7 +54,7 @@ public class Listeners implements Listener
|
||||
public void onJoin(PlayerJoinEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
vm.checkFile(player);
|
||||
plugin.playerVaultFile(player);
|
||||
if(player.isOp() && Main.update)
|
||||
{
|
||||
player.sendMessage(ChatColor.GREEN + "Version " + Main.name + " of PlayerVaults is up for download!");
|
||||
|
||||
@@ -15,6 +15,7 @@ import me.shock.playervaults.util.Updater;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.craftbukkit.libs.jline.internal.Log;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@@ -119,7 +120,7 @@ public class Main extends JavaPlugin {
|
||||
* New, genius way to write it :)
|
||||
*/
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(new File(getDataFolder() + File.separator + "lang.yml"));
|
||||
FileOutputStream fos = new FileOutputStream(lang);
|
||||
InputStream is = getResource("lang.yml");
|
||||
byte[] linebuffer = new byte[4096];
|
||||
int lineLength = 0;
|
||||
@@ -135,11 +136,28 @@ public class Main extends JavaPlugin {
|
||||
}
|
||||
|
||||
private YamlConfiguration lang() {
|
||||
File file = new File(getDataFolder() + "/lang.yml");
|
||||
File file = new File(getDataFolder() + File.separator + "lang.yml");
|
||||
YamlConfiguration lang = YamlConfiguration.loadConfiguration(file);
|
||||
return lang;
|
||||
}
|
||||
|
||||
public YamlConfiguration playerVaultFile(Player player) {
|
||||
File folder = new File(getDataFolder() + File.separator + "vaults");
|
||||
if(!folder.exists()) {
|
||||
folder.mkdir();
|
||||
}
|
||||
File file = new File(getDataFolder() + File.separator + "vaults" + File.separator + player.getName().toLowerCase() + ".yml");
|
||||
if(!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
YamlConfiguration playerFile = YamlConfiguration.loadConfiguration(file);
|
||||
return playerFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Methods to get values from the config.
|
||||
* public so any class / plugin can get them.
|
||||
|
||||
@@ -20,18 +20,6 @@ public class VaultManager
|
||||
private Main plugin;
|
||||
String title;
|
||||
|
||||
public void checkFile(Player player)
|
||||
{
|
||||
String name = player.getName().toLowerCase();
|
||||
|
||||
File file = new File(plugin.getDataFolder() + File.separator + "vaults" + name + ".yml");
|
||||
if(!file.exists())
|
||||
{
|
||||
file.mkdir();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to save player's vault.
|
||||
* Serialize his inventory.
|
||||
@@ -44,18 +32,15 @@ public class VaultManager
|
||||
if(plugin.inVault().containsKey(player.getName()))
|
||||
{
|
||||
// Get the player's file and serialize the inventory.
|
||||
String name = player.getName().toLowerCase();
|
||||
String ser = Serialization.toBase64(inv);
|
||||
File file = new File(plugin.getDataFolder() + File.separator + "vaults" + name + ".yml");
|
||||
FileConfiguration playerFile = YamlConfiguration.loadConfiguration(file);
|
||||
YamlConfiguration file = plugin.playerVaultFile(player);
|
||||
|
||||
// Prepare to save D:
|
||||
playerFile.set("vault" + number + "", ser);
|
||||
file.set("vault" + number + "", ser);
|
||||
if(plugin.debugMode())
|
||||
{
|
||||
plugin.getLogger().log(Level.INFO, "[PlayerVaults] Saved " + " " + number + " for " + player.getName());
|
||||
}
|
||||
playerFile.save(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user