Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package DCNetwork.KitPVP.Player;
- import DCNetwork.KitPVP.KitPVP;
- import DCNetwork.KitPVP.Util.YMLFactory;
- import org.bukkit.Material;
- import org.bukkit.configuration.ConfigurationSection;
- import org.bukkit.entity.Player;
- import java.io.File;
- /**
- * Created by Luke on 25/07/2014.
- */
- public class PlayerData {
- private YMLFactory.YML dataFile;
- private Player player;
- private void refreshConfig() {
- dataFile.saveConfig();
- }
- public PlayerData(Player player) {
- this.player = player;
- File data = new File(KitPVP.instance.getDataFolder(), "data");
- if(!data.exists()){
- data.mkdir();
- }
- dataFile = YMLFactory.buildYML("data" + File.separator + player.getUniqueId().toString() + ".data", KitPVP.instance);
- refreshConfig();
- }
- private void check() {
- if (!dataFile.getConfig().contains("kills")) {
- dataFile.getConfig().set("kills", 0);
- }
- if (!dataFile.getConfig().contains("deaths")) {
- dataFile.getConfig().set("deaths", 0);
- }
- if (!dataFile.getConfig().contains("highestKillStreak")) {
- dataFile.getConfig().set("highestKillStreak", 0);
- }
- if (!dataFile.getConfig().contains("currentKillStreak")) {
- dataFile.getConfig().set("currentKillStreak", 0);
- }
- if (!dataFile.getConfig().contains("lastKitUsed")) {
- dataFile.getConfig().set("lastKitUsed", "fisherBob");
- }
- if (!dataFile.getConfig().contains("kitdata")) {
- dataFile.getConfig().createSection("kitdata");
- dataFile.getConfig().getConfigurationSection("kitdata").set("fisherBob", true);
- dataFile.getConfig().getConfigurationSection("kitdata").set("2", false);
- dataFile.getConfig().getConfigurationSection("kitdata").set("3", false);
- dataFile.getConfig().getConfigurationSection("kitdata").set("4", false);
- dataFile.getConfig().getConfigurationSection("kitdata").set("5", false);
- dataFile.getConfig().getConfigurationSection("kitdata").set("6", false);
- dataFile.getConfig().getConfigurationSection("kitdata").set("7", false);
- dataFile.getConfig().getConfigurationSection("kitdata").set("8", false);
- dataFile.getConfig().getConfigurationSection("kitdata").set("9", false);
- dataFile.getConfig().getConfigurationSection("kitdata").set("10", false);
- }
- refreshConfig();
- }
- public void setKit(String kitID, boolean value) {
- dataFile.getConfig().getConfigurationSection("kitdata").set(kitID, value);
- refreshConfig();
- }
- public boolean getKit(String kitID) {
- return dataFile.getConfig().getConfigurationSection("kitdata").getBoolean(kitID);
- }
- public void setKills(int kills) {
- refreshConfig();
- dataFile.getConfig().set("kills", kills);
- }
- public int getKills() {
- return dataFile.getConfig().getInt("kills");
- }
- public void setDeaths(int deaths) {
- dataFile.getConfig().set("deaths", deaths);
- refreshConfig();
- }
- public int getDeaths() {
- return dataFile.getConfig().getInt("deaths");
- }
- public void setHighestKillStreak(int highestKillStreak) {
- dataFile.getConfig().set("highestKillStreak", highestKillStreak);
- refreshConfig();
- }
- public int getHighestKillStreak() {
- return dataFile.getConfig().getInt("highestKillStreak");
- }
- public void setCurrentKillStreak(int currentKillStreak) {
- dataFile.getConfig().set("currentKillStreak", currentKillStreak);
- if (currentKillStreak > getHighestKillStreak()) {
- setHighestKillStreak(currentKillStreak);
- }
- refreshConfig();
- }
- public int getCurrentKillStreak() {
- return dataFile.getConfig().getInt("currentKillStreak");
- }
- public void setLastKitUsed(String kitID) {
- dataFile.getConfig().set("lastKitUsed", kitID);
- refreshConfig();
- }
- public String getLastKitUsed() {
- return dataFile.getConfig().getString("lastKitUsed");
- }
- public double getKDR() {
- return (getKills() / getDeaths()) * 100;
- }
- public double getArmorWorth() {
- double armorworth = 0;
- if (player.getInventory().getHelmet().getType() == Material.LEATHER_HELMET) {
- armorworth = armorworth + 0.5;
- } else {
- if (player.getInventory().getHelmet().getType() == Material.GOLD_HELMET || player.getInventory().getHelmet().getType() == Material.CHAINMAIL_HELMET || player.getInventory().getHelmet().getType() == Material.IRON_HELMET) {
- armorworth++;
- } else {
- if (player.getInventory().getHelmet().getType() == Material.DIAMOND_HELMET) {
- armorworth = armorworth + 0.5;
- }
- }
- }
- if (player.getInventory().getChestplate().getType() == Material.LEATHER_CHESTPLATE) {
- armorworth = armorworth + 1.5;
- } else {
- if (player.getInventory().getChestplate().getType() == Material.GOLD_CHESTPLATE || player.getInventory().getChestplate().getType() == Material.CHAINMAIL_CHESTPLATE) {
- armorworth = armorworth + 2.5;
- } else {
- if (player.getInventory().getChestplate().getType() == Material.IRON_CHESTPLATE) {
- armorworth = armorworth + 3;
- } else {
- if (player.getInventory().getChestplate().getType() == Material.DIAMOND_CHESTPLATE) {
- armorworth = armorworth + 4;
- }
- }
- }
- }
- if (player.getInventory().getLeggings().getType() == Material.LEATHER_LEGGINGS) {
- armorworth++;
- } else {
- if (player.getInventory().getLeggings().getType() == Material.GOLD_LEGGINGS) {
- armorworth = armorworth + 1.5;
- } else {
- if (player.getInventory().getLeggings().getType() == Material.CHAINMAIL_LEGGINGS) {
- armorworth = armorworth + 2;
- } else {
- if (player.getInventory().getLeggings().getType() == Material.IRON_LEGGINGS) {
- armorworth = armorworth + 2.5;
- } else {
- if (player.getInventory().getLeggings().getType() == Material.DIAMOND_LEGGINGS) {
- armorworth = armorworth + 3;
- }
- }
- }
- }
- }
- if (player.getInventory().getBoots().getType() == Material.LEATHER_BOOTS || player.getInventory().getBoots().getType() == Material.GOLD_BOOTS || player.getInventory().getBoots().getType() == Material.CHAINMAIL_BOOTS) {
- armorworth = armorworth + 0.5;
- } else {
- if (player.getInventory().getBoots().getType() == Material.IRON_BOOTS) {
- armorworth++;
- } else {
- if (player.getInventory().getBoots().getType() == Material.DIAMOND_BOOTS) {
- armorworth = armorworth + 1.5;
- }
- }
- }
- return armorworth;
- }
- public double getWorth() {
- return (getCurrentKillStreak() * getKDR()) + (getArmorWorth());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement