lNockl

Untitled

Sep 12th, 2016
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.76 KB | None | 0 0
  1. package com.gmail.filipenock.skywars.player;
  2.  
  3. import java.util.HashMap;
  4. import java.util.Map;
  5.  
  6. import org.bukkit.entity.Player;
  7.  
  8. import com.gmail.filipenock.skywars.game.Arena;
  9. import com.gmail.filipenock.skywars.interfaces.Storage;
  10. import com.gmail.filipenock.skywars.player.storage.YMLStorage;
  11.  
  12. import lombok.Getter;
  13. import lombok.Setter;
  14.  
  15. public class SkyPlayer {
  16.     @Getter@Setter
  17.     private Arena arena;
  18.     @Getter
  19.     private Player player;
  20.     @Getter
  21.     private Storage storage;
  22.     @Getter
  23.     private int kills, deaths, wins, coins;
  24.    
  25.     public SkyPlayer(Player p){
  26.         this.player=p;
  27.         this.storage=new YMLStorage(p);
  28.         this.kills=this.storage.getInt("kills");
  29.         this.deaths=this.storage.getInt("deaths");
  30.         this.wins=this.storage.getInt("wins");
  31.         this.coins=this.storage.getInt("coins");
  32.     }
  33.    
  34.     public boolean sendMessage(String message){
  35.         if(message==null)
  36.             return false;
  37.         player.sendMessage(message.replace("&", "ยง"));
  38.         return true;
  39.                
  40.     }
  41.    
  42.     public boolean Save(){
  43.         this.storage.set("kills", this.kills);
  44.         this.storage.set("deaths", this.deaths);
  45.         this.storage.set("wins", this.wins);
  46.         this.storage.set("coins", this.coins);
  47.         return true;
  48.     }
  49.    
  50.     /////////////////////////////////////
  51.    
  52.     protected static Map<Player, SkyPlayer>players =new HashMap<>();
  53.    
  54.     public static boolean addPlayer(Player p){
  55.         if(!players.containsKey(p))
  56.             return false;
  57.         players.put(p, new SkyPlayer(p));
  58.         return true;
  59.        
  60.     }
  61.    
  62.     public static boolean removePlayer(Player p){
  63.         if(!players.containsKey(p))
  64.             return false;
  65.         SkyPlayer sp=SkyPlayer.getSkyPlayer(p);
  66.         sp.Save();
  67.         players.remove(p);
  68.         return true;   
  69.        
  70.     }
  71.    
  72.     public static SkyPlayer getSkyPlayer(Player p){
  73.         if(!players.containsKey(p))
  74.             return players.get(p);
  75.         return null;
  76.     }
  77.  
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment