Created
January 18, 2016 18:12
-
-
Save NavidK0/67f75b47fa904443554f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.lastabyss.psciv.util; | |
import org.bukkit.Bukkit; | |
import org.bukkit.OfflinePlayer; | |
import org.bukkit.configuration.file.YamlConfiguration; | |
import org.bukkit.entity.Player; | |
import org.bukkit.inventory.ItemStack; | |
import java.io.File; | |
import java.io.IOException; | |
import java.util.UUID; | |
/** | |
* @author Navid | |
*/ | |
public class KitPlayer { | |
private UUID uniqueId; | |
private YamlConfiguration data; | |
private Kit kit; | |
public KitPlayer(Player player) { | |
uniqueId = player.getUniqueId(); | |
File dataFile = new File(YourPlugin.instance.getDataFolder(), uniqueId.toString() + ".yml"); | |
if (!dataFile.exists()) try { | |
dataFile.createNewFile(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
data = YamlConfiguration.loadConfiguration(dataFile); | |
} | |
public void loadKit() { | |
//TODO: Do loading here | |
kit = YourCacheClass.loadKit(this); | |
} | |
public void saveKit() { | |
//TODO: Do saving here | |
YourCacheClass.saveKit(this); | |
} | |
public UUID getUniqueId() { | |
return uniqueId; | |
} | |
public YamlConfiguration getData() { | |
return data; | |
} | |
/** | |
* Returns an offline player that has this uniqueId. | |
* | |
* @return | |
*/ | |
public OfflinePlayer getPlayer() { | |
Player player = Bukkit.getPlayer(uniqueId); | |
if (player == null) { | |
return Bukkit.getOfflinePlayer(uniqueId); | |
} | |
return player; | |
} | |
public Kit getKit() { | |
return kit; | |
} | |
public void setKit(Kit kit) { | |
this.kit = kit; | |
} | |
@Override | |
public boolean equals(Object obj) { | |
if (obj instanceof KitPlayer) { | |
return ((KitPlayer) obj).getUniqueId().equals(this.getUniqueId()); | |
} else return super.equals(obj); | |
} | |
} | |
class Kit { | |
private ItemStack[] contents; | |
private ItemStack[] armor; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment