Guest User

TeamCODE for bukkit - made by ahuby09

a guest
Apr 10th, 2014
180
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.blueninjn.minigame;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. import org.bukkit.Bukkit;
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.Material;
  8. import org.bukkit.command.Command;
  9. import org.bukkit.command.CommandSender;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.event.EventHandler;
  12. import org.bukkit.event.Listener;
  13. import org.bukkit.event.block.NotePlayEvent;
  14. import org.bukkit.event.entity.EntityDamageByEntityEvent;
  15. import org.bukkit.event.player.PlayerChatEvent;
  16. import org.bukkit.inventory.ItemStack;
  17. import org.bukkit.plugin.java.JavaPlugin;
  18. import org.kitteh.tag.AsyncPlayerReceiveNameTagEvent;
  19. import org.kitteh.tag.TagAPI;
  20.  
  21. @SuppressWarnings("deprecation")
  22. public class minigame extends JavaPlugin implements Listener{
  23.    
  24.     //startup and close down and register of events
  25.    String version = "0.1";
  26.    ArrayList<Player> TeamRed = new ArrayList<Player>();
  27.    ArrayList<Player> TeamBlue = new ArrayList<Player>();
  28. public void onEnable() {
  29.     System.out.print("MiniGamePlugin" + version + "Enabled");
  30.     Bukkit.getServer().getPluginManager().registerEvents(this, this);
  31. }
  32. public void onDisable() {
  33.     System.out.print("MiniGamePlugin" + version + "Disabled");
  34. }
  35. //end of startup and close down and register of events
  36. //all events
  37.  
  38. @EventHandler
  39. public void Chatevent(PlayerChatEvent e){
  40.     if(TeamBlue.contains(e.getPlayer())){
  41.         String msg = e.getMessage();
  42.         e.setMessage(ChatColor.BLUE + msg);
  43.         e.getPlayer().setDisplayName(ChatColor.BLUE + e.getPlayer().getName());
  44.     }
  45.     if(TeamRed.contains(e.getPlayer())){
  46.         String msg = e.getMessage();
  47.         e.setMessage(ChatColor.RED + msg);
  48.         e.getPlayer().setDisplayName(ChatColor.RED + e.getPlayer().getName());
  49.     }
  50. }
  51. @EventHandler
  52. public void OnMove(NotePlayEvent e){
  53.     for(Player t : Bukkit.getOnlinePlayers()){
  54.         TagAPI.refreshPlayer(t);
  55.         }
  56. }
  57.  
  58. @EventHandler
  59. public void entityDamage(EntityDamageByEntityEvent e){
  60.     if (e.getDamager() instanceof Player && e.getEntity() instanceof Player){
  61.         Player damager = (Player)e.getDamager();
  62.         Player damaged = (Player)e.getEntity();
  63.         if(TeamBlue.contains(damager)){
  64.         if(TeamBlue.contains(damaged)){
  65.             e.setCancelled(true);
  66.         }else{
  67.             if(TeamRed.contains(damager)){
  68.                 if(TeamRed.contains(damaged)){
  69.                     e.setCancelled(true);
  70.                 }
  71.             }
  72.         }
  73.     }
  74. }}
  75. @EventHandler
  76. public void onNameTag(AsyncPlayerReceiveNameTagEvent event) {
  77.     if(TeamBlue.contains(event.getNamedPlayer())) {
  78.         event.setTag(ChatColor.BLUE +event.getNamedPlayer().getName());
  79.     }
  80.     if(TeamRed.contains(event.getNamedPlayer())) {
  81.         event.setTag(ChatColor.RED +event.getNamedPlayer().getName());
  82.     }
  83.    
  84. }
  85.  
  86.  
  87. //end of events
  88.  
  89.  
  90.  
  91.  
  92. //all team stuff and commands
  93. public boolean onCommand(CommandSender sender, Command command, String label,
  94.         String[] args) {
  95.     Player player = (Player)sender;
  96.     if(label.equalsIgnoreCase("blue")){
  97.         if(TeamRed.contains(player)){
  98.             player.sendMessage("you are already in a team !");
  99.             }else if(TeamBlue.contains(player)){
  100.                 TeamBlue.remove(player);
  101.                 player.sendMessage("you have been removed from the blue team");
  102.                 player.getInventory().setHelmet(new ItemStack(Material.WOOL, 0, (short) 0));
  103.             }else{
  104.             TeamBlue.add(player);
  105.             player.sendMessage("You have been added to team blue");
  106.             player.getInventory().setHelmet(new ItemStack(Material.WOOL, 1, (short) 9));
  107.             player.getInventory().setBoots(new ItemStack(Material.LEATHER_BOOTS, 1));
  108.             player.getInventory().setLeggings(new ItemStack(Material.LEATHER_LEGGINGS, 1, (short) 3));
  109.             player.getInventory().setChestplate(new ItemStack(Material.LEATHER_CHESTPLATE));
  110.             }
  111.        
  112.     }
  113.    
  114.     if(label.equalsIgnoreCase("red")){
  115.         if(TeamBlue.contains(player)){
  116.             player.sendMessage("you are already in a team !");
  117.             }else if(TeamRed.contains(player)){
  118.             TeamRed.remove(player);
  119.             player.sendMessage("you have been removed from the Red team");
  120.             player.getInventory().setHelmet(new ItemStack(Material.WOOL, 0, (short) 0));
  121.             }else{
  122.            
  123.             TeamRed.add(player);
  124.             player.getInventory().setHelmet(new ItemStack(Material.WOOL, 1, (short) 14));
  125.             player.sendMessage("You have been added to team red");
  126.            
  127.             }
  128.     }
  129.     if(label.equalsIgnoreCase("whoisblue")){
  130.         player.sendMessage(TeamBlue.toString());
  131.     }
  132.     if(label.equalsIgnoreCase("whoisred")){
  133.         player.sendMessage(TeamRed.toString());
  134.        
  135.     }
  136.    
  137.     if(label.equalsIgnoreCase("MyTeam")){
  138.         if(TeamBlue.contains(player)){
  139.             player.sendMessage("you are in the blue team");
  140.         }
  141.         else if(TeamRed.contains(player)){
  142.             player.sendMessage("you are in the red team");
  143.         }else{
  144.             player.sendMessage("you are not in a team");
  145.         }
  146.     }
  147.     return false;
  148. }
  149.  
  150.  
  151.  
  152. }
RAW Paste Data