Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package skywars.notjacob.handlers;
- import java.io.File;
- import java.io.IOException;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.Player;
- public class playerHandler {
- private fileHandler fh;
- private islandYML isY;
- public void setup(Player p) throws IOException {
- File f = new File(fh.path + "users/" + p.getUniqueId().toString() + ".yml");
- YamlConfiguration yml = YamlConfiguration.loadConfiguration(f);
- f.createNewFile();
- yml.addDefault("ELO", 100);
- yml.addDefault("wins", 0);
- yml.addDefault("losses", 0);
- yml.addDefault("kills", 0);
- yml.addDefault("deaths", 0);
- yml.addDefault("ingame", false);
- yml.addDefault("island", 0);
- yml.addDefault("dead", false);
- yml.options().copyDefaults(true);
- yml.save(f);
- }
- public float elo(Player p) {
- File f = new File(fh.path + "users/" + p.getUniqueId().toString() + ".yml");
- YamlConfiguration yml = YamlConfiguration.loadConfiguration(f);
- return yml.getInt("ELO");
- }
- public boolean ingame(Player p) {
- File f = new File(fh.path + "users/" + p.getUniqueId().toString() + ".yml");
- YamlConfiguration yml = YamlConfiguration.loadConfiguration(f);
- return yml.getBoolean("ingame") ? true : false;
- }
- public float wins(Player p) {
- File f = new File(fh.path + "users/" + p.getUniqueId().toString() + ".yml");
- YamlConfiguration yml = YamlConfiguration.loadConfiguration(f);
- return yml.getInt("wins");
- }
- public float losses(Player p) {
- File f = new File(fh.path + "users/" + p.getUniqueId().toString() + ".yml");
- YamlConfiguration yml = YamlConfiguration.loadConfiguration(f);
- return yml.getInt("losses");
- }
- public float kills(Player p) {
- File f = new File(fh.path + "users/" + p.getUniqueId().toString() + ".yml");
- YamlConfiguration yml = YamlConfiguration.loadConfiguration(f);
- return yml.getInt("kills");
- }
- public float deaths(Player p) {
- File f = new File(fh.path + "users/" + p.getUniqueId().toString() + ".yml");
- YamlConfiguration yml = YamlConfiguration.loadConfiguration(f);
- return yml.getInt("deaths");
- }
- public Island island(Player player) {
- File f = new File(fh.path + "users/" + player.getUniqueId().toString() + ".yml");
- YamlConfiguration yml = YamlConfiguration.loadConfiguration(f);
- return new Island(yml.getInt("island"), (SkywarsPlayer) player, isY.getLocation(yml.getInt("island")));
- }
- public void delete(Player p) {
- File f = new File(fh.path + "users/" + p.getUniqueId().toString() + ".yml");
- f.delete();
- }
- public boolean dead(Player p) {
- File f = new File(fh.path + "users/" + p.getUniqueId().toString() + ".yml");
- YamlConfiguration yml = YamlConfiguration.loadConfiguration(f);
- return yml.getBoolean("dead");
- }
- public void setElo(float elo, Player p) {
- File f = new File(fh.path + "users/" + p.getUniqueId().toString() + ".yml");
- YamlConfiguration yml = YamlConfiguration.loadConfiguration(f);
- yml.set("ELO", elo);
- try {
- yml.save(f);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public void setDead(boolean dead, Player p) {
- File f = new File(fh.path + "users/" + p.getUniqueId().toString() + ".yml");
- YamlConfiguration yml = YamlConfiguration.loadConfiguration(f);
- yml.set("dead", dead);
- try {
- yml.save(f);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public void setWins(float wins, Player p) {
- File f = new File(fh.path + "users/" + p.getUniqueId().toString() + ".yml");
- YamlConfiguration yml = YamlConfiguration.loadConfiguration(f);
- yml.set("wins", wins);
- try {
- yml.save(f);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public void setLosses(float losses, Player p) {
- File f = new File(fh.path + "users/" + p.getUniqueId().toString() + ".yml");
- YamlConfiguration yml = YamlConfiguration.loadConfiguration(f);
- yml.set("losses", losses);
- try {
- yml.save(f);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public void setDeaths(float deaths, Player p) {
- File f = new File(fh.path + "users/" + p.getUniqueId().toString() + ".yml");
- YamlConfiguration yml = YamlConfiguration.loadConfiguration(f);
- yml.set("deaths", deaths);
- try {
- yml.save(f);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public void setKills(float kills, Player p) {
- File f = new File(fh.path + "users/" + p.getUniqueId().toString() + ".yml");
- YamlConfiguration yml = YamlConfiguration.loadConfiguration(f);
- yml.set("kills", kills);
- try {
- yml.save(f);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public void setIngame(boolean ingame, Player p) {
- File f = new File(fh.path + "users/" + p.getUniqueId().toString() + ".yml");
- YamlConfiguration yml = YamlConfiguration.loadConfiguration(f);
- yml.set("ingame", ingame);
- try {
- yml.save(f);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public void setIsland(float id, Player p) {
- File f = new File(fh.path + "users/" + p.getUniqueId().toString() + ".yml");
- YamlConfiguration yml = YamlConfiguration.loadConfiguration(f);
- yml.set("island", id);
- try {
- yml.save(f);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment