Advertisement
Guest User

JoinTeam Clas

a guest
Nov 25th, 2017
70
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package onJoin;
  2.  
  3. import org.bukkit.Material;
  4. import org.bukkit.entity.Player;
  5. import org.bukkit.event.EventHandler;
  6. import org.bukkit.event.Listener;
  7. import org.bukkit.event.block.Action;
  8. import org.bukkit.event.player.PlayerInteractEvent;
  9. import org.bukkit.event.player.PlayerJoinEvent;
  10. import org.bukkit.inventory.ItemStack;
  11. import org.bukkit.inventory.meta.ItemMeta;
  12.  
  13. import me.McVier3ck.team.Team;
  14. import net.md_5.bungee.api.ChatColor;
  15.  
  16. public class JoinTeam implements Listener {
  17.  
  18. String Red = "RedTeam";
  19.  
  20. String Blue = "BlueTeam";
  21.  
  22.  
  23. Team RedTeam = new Team(Red);
  24.  
  25. Team BlueTeam = new Team(Blue);
  26.  
  27. public void ChooseTeam(PlayerJoinEvent event) {
  28.  
  29. Player p = event.getPlayer();
  30.  
  31. if(p.getWorld().equals("warmode")){
  32.  
  33. Team.joinRandomTeam(p);
  34.  
  35. if(RedTeam.containsPlayer(p)){
  36. p.sendMessage(ChatColor.RED + "You are on RED Team.");
  37.  
  38. }
  39. if(BlueTeam.containsPlayer(p)){
  40. p.sendMessage(ChatColor.DARK_BLUE + "You are on BLUE Team.");
  41.  
  42. }
  43.  
  44. }
  45.  
  46. }
  47.  
  48.  
  49. public void TeamDefault(){
  50.  
  51. //CanBreakBlocks
  52. RedTeam.setCanBreak(false);
  53. BlueTeam.setCanBreak(false);
  54.  
  55. //SetChatColor
  56. RedTeam.setColor(ChatColor.RED);
  57. BlueTeam.setColor(ChatColor.DARK_BLUE);
  58.  
  59. //FriendlyFire
  60. RedTeam.setFriendlyFire(true);
  61. BlueTeam.setFriendlyFire(true);
  62.  
  63.  
  64. }
  65.  
  66. @SuppressWarnings("deprecation")
  67. @EventHandler
  68. public void ManualTeam(PlayerInteractEvent event) {
  69.  
  70. Player p = event.getPlayer();
  71. Action a = event.getAction();
  72.  
  73. ItemStack joinred = new ItemStack(Material.INK_SACK, 1, (byte) 1);
  74. ItemMeta joinredmeta = joinred.getItemMeta();
  75. joinredmeta.setDisplayName(ChatColor.RED + "JOIN RED TEAM");
  76.  
  77. ItemStack joinblue = new ItemStack(Material.INK_SACK, 1, (byte) 4);
  78. ItemMeta joinbluemeta = joinblue.getItemMeta();
  79. joinbluemeta.setDisplayName(ChatColor.DARK_BLUE + "JOIN BLUE TEAM");
  80.  
  81. ItemStack leaveteam = new ItemStack(Material.INK_SACK, 1, (byte) 8);
  82. ItemMeta leaveteammeta = leaveteam.getItemMeta();
  83. leaveteammeta.setDisplayName(ChatColor.GRAY + "LEAVE A TEAM");
  84.  
  85. if(a.equals(Action.RIGHT_CLICK_AIR)) {
  86. if(p.getItemInHand() == joinred){
  87. if(BlueTeam.containsPlayer(p)){
  88. p.sendMessage(ChatColor.RED + "You are already in Team Blue.");
  89.  
  90. }
  91.  
  92. if(RedTeam.containsPlayer(p)){
  93. p.sendMessage(ChatColor.RED + "You are already in this Team.");
  94.  
  95. }
  96. else
  97. RedTeam.joinTeam(p);
  98. p.sendMessage(ChatColor.RED + "You have joined Team Red.");
  99.  
  100. }
  101. if(p.getItemInHand() == joinblue) {
  102. if(BlueTeam.containsPlayer(p)){
  103. p.sendMessage(ChatColor.DARK_BLUE + "You are already in this Team.");
  104. }
  105. if(RedTeam.containsPlayer(p)){
  106. p.sendMessage(ChatColor.DARK_BLUE + "You are already in Team Red.");
  107. }
  108. else {
  109. BlueTeam.joinTeam(p);
  110. p.sendMessage(ChatColor.DARK_BLUE + "You have joined Team Blue.");
  111.  
  112. }
  113.  
  114. }
  115. if(p.getItemInHand() == leaveteam) {
  116. if(RedTeam.containsPlayer(p)) {
  117. RedTeam.leaveTeam(p);
  118. p.sendMessage(ChatColor.GRAY + "You have left Team Red.");
  119.  
  120. }
  121. if(BlueTeam.containsPlayer(p)) {
  122. BlueTeam.leaveTeam(p);
  123. p.sendMessage(ChatColor.GRAY + "You have left Team Blue");
  124. }
  125. else {
  126. p.sendMessage(ChatColor.GRAY + "You are not in a Team.");
  127. }
  128.  
  129. }
  130.  
  131. }
  132.  
  133. }
  134.  
  135. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement