Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.36 KB | None | 0 0
  1. package fr.lifecraft;
  2.  
  3. import java.util.List;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.Material;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.inventory.ItemStack;
  10. import org.bukkit.inventory.meta.ItemMeta;
  11. import org.bukkit.potion.PotionEffect;
  12.  
  13. import fr.lifecraft.utils.CardinalDirection;
  14. import fr.lifecraft.utils.SoundSupport;
  15.  
  16. public class LifePlayer {
  17.  
  18. Player p;
  19. int ks;
  20. LifePlayer combat;
  21.  
  22. public LifePlayer(Player p) {
  23. this.p = p;
  24. ks = 0;
  25. combat = null;
  26. }
  27.  
  28. public Player getBukkitPlayer() {
  29. return p;
  30. }
  31.  
  32. public boolean hasKit(Kit kit) {
  33. return LifeKits.getInstance().kit.containsKey(this) && LifeKits.getInstance().kit.get(this) == kit;
  34. }
  35.  
  36. public boolean hasKit() {
  37. return LifeKits.getInstance().kit.containsKey(this);
  38. }
  39.  
  40. public void setKit(Kit kit) {
  41. LifeKits.getInstance().kit.put(this, kit);
  42. }
  43.  
  44. private void removeKit() {
  45. LifeKits.getInstance().kit.remove(this);
  46. }
  47.  
  48. public BasicalKit getKit() {
  49. return LifeKits.getInstance().kit.get(this);
  50. }
  51.  
  52. public void clearPots() {
  53. for(PotionEffect ef : p.getActivePotionEffects()) p.removePotionEffect(ef.getType());
  54. }
  55.  
  56. public void clearArmor() {
  57. p.getInventory().setArmorContents(null);
  58. }
  59.  
  60. public void clearInv() {
  61. p.getInventory().clear();
  62. p.getInventory().setArmorContents(null);
  63. }
  64.  
  65. public void clearKits() {
  66. if(hasKit()) removeKit();
  67. }
  68.  
  69. public void clear() {
  70. clearKits();
  71. clearInv();
  72. clearPots();
  73. }
  74.  
  75. public CardinalDirection getCardinalDirection() {
  76. double rotation = (p.getLocation().getYaw() - 90.0f) % 360.0f;
  77. if (rotation < 0.0) {
  78. rotation += 360.0;
  79. }
  80. if (0.0 <= rotation && rotation < 67.5) {
  81. return CardinalDirection.NORTH;
  82. }
  83. if (67.5 <= rotation && rotation < 157.5) {
  84. return CardinalDirection.EAST;
  85. }
  86. if (157.5 <= rotation && rotation < 247.5) {
  87. return CardinalDirection.SOUTH;
  88. }
  89. if (247.5 <= rotation && rotation < 337.5) {
  90. return CardinalDirection.WEST;
  91. }
  92. if (337.5 <= rotation && rotation < 360.0) {
  93. return CardinalDirection.NORTH;
  94. }
  95. return null;
  96. }
  97.  
  98. public void giveSoup() {
  99. final ItemStack soup = new ItemStack(Material.MUSHROOM_SOUP, 1);
  100. final ItemMeta meta = soup.getItemMeta();
  101. meta.setDisplayName("§6Soupe");
  102. soup.setItemMeta(meta);
  103. int i = 0;
  104. while (i <= 40) {
  105. ++i;
  106. p.getInventory().addItem(new ItemStack[] { soup });
  107. }
  108. }
  109.  
  110. public void cooldown(int seconds, List<LifePlayer> cooldown, String before) {
  111. cooldown.add(this);
  112. if(before != null) {
  113. p.sendMessage(ChatColor.translateAlternateColorCodes('&', before));
  114. }
  115.  
  116. Bukkit.getScheduler().runTaskLater(LifeKits.getInstance(), new Runnable() {
  117.  
  118. @Override
  119. public void run() {
  120. cooldown.remove(this);
  121.  
  122. p.sendMessage("§8§l>> §eVous pouvez de nouveau utiliser votre habilité !");
  123.  
  124. p.playSound(p.getLocation(), SoundSupport.LEVEL_UP.bukkitSound(), 1, 0);
  125. }
  126. }, seconds * 20);
  127. }
  128.  
  129. public void addKillstreak() {
  130. ks++;
  131. }
  132.  
  133. public void resetKillstreak() {
  134. ks = 0;
  135. }
  136.  
  137. public int getKillstreak() {
  138. return ks;
  139. }
  140.  
  141. public void setInCombat(LifePlayer lp) {
  142. combat = lp;
  143. }
  144.  
  145. public boolean inInCombat() {
  146. return combat != null;
  147. }
  148.  
  149. public static LifePlayer get(Player p) {
  150. return LifeKits.getInstance().players.get(p);
  151. }
  152.  
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement