Guest User

Clans

a guest
Nov 20th, 2015
138
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package Clans.ClansSettings;
  2.  
  3. import Clans.SettingsMessages.MessageManager;
  4. import org.bukkit.entity.Player;
  5.  
  6. import java.util.ArrayList;
  7. import java.util.HashMap;
  8.  
  9. public class Clans {
  10. static String clanName;
  11. static MessageManager sm = new MessageManager();
  12. private static ArrayList<Clans> clans = new ArrayList<>();
  13.  
  14. private static HashMap<String, Clans> playersClan = new HashMap<>();
  15.  
  16.  
  17. public Clans(String clanname) {
  18. this.clanName = clanname;
  19. clans.add(this);
  20.  
  21. }
  22.  
  23. public static void createClan(String nameOfClan, Player player) {
  24. Clans clan = new Clans(nameOfClan);
  25. if (!hasClan(player)) {
  26. if (!clanExists(clan)) {
  27. playersClan.put(player.getName(), clan);
  28. sm.info(player,"O clan" + clan + "foi criado!");
  29. }
  30. sm.severe(player, "O clan" + clan + "ja existe!");
  31. }
  32. sm.severe(player , "Tu ja tens um clan!");
  33. }
  34.  
  35. public static void deleteClan(Player player, Clans clan) {
  36.  
  37. if (clanExists(clan)) {
  38. if (hasClan(player)) {
  39. clans.remove(clan);
  40. sm.info(player, "Apagaste o clan " + clan + "!");
  41. }
  42. sm.severe(player, "Nao tens clan!");
  43. }
  44. sm.severe(player , "O clan " + clan + " nao existe!");
  45. }
  46.  
  47. public static void addPlayer(Player player, Player target, Clans clan) {
  48. if (hasClan(player)) {
  49.  
  50. if (hasClan(target)) {
  51. sm.severe(player , "O player " + target.getName() + " ja tem clan!");
  52. }
  53. playersClan.put(player.getName(), clan);
  54. sm.info(player , "O player " + target.getName() + " foi adicionado ao teu clan");
  55. }
  56. sm.severe(player , "Nao tens clan!");
  57. }
  58.  
  59.  
  60. public static void removePlayer(Player player, Player target, Clans clan) {
  61. if (hasClan(player)) {
  62.  
  63. if (getClan(player) == getClan(target)) {
  64. playersClan.remove(target.getName());
  65. }
  66. player.sendMessage("Ele nao é do teu clan");
  67. }
  68. sm.severe(player ,"Nao tens um clan");
  69. }
  70.  
  71. public static void leaveClan(Player player, Clans clan){
  72. if(hasClan(player)){
  73. playersClan.remove(player.getName());
  74. }
  75. sm.severe(player, "Nao tens clan.");
  76. }
  77.  
  78. public static boolean hasClan(Player player) {
  79.  
  80. if (playersClan.containsKey(player.getName())) {
  81. return true;
  82. }
  83.  
  84. return false;
  85. }
  86.  
  87. public static boolean clanExists(Clans clan) {
  88.  
  89. if (clans.contains(clan)) {
  90. return true;
  91. }
  92.  
  93. return false;
  94. }
  95.  
  96. public static Clans getClan(Player player) {
  97.  
  98. return playersClan.get(player.getName());
  99. }
  100.  
  101. public static String getClan() {
  102.  
  103. return clanName;
  104. }
  105. }
RAW Paste Data