Advertisement
Guest User

Untitled

a guest
Jul 19th, 2013
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.96 KB | None | 0 0
  1. package ked;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5.  
  6. import org.bukkit.Bukkit;
  7. import org.bukkit.ChatColor;
  8. import org.bukkit.Color;
  9. import org.bukkit.Location;
  10. import org.bukkit.Material;
  11. import org.bukkit.World;
  12. import org.bukkit.entity.EntityType;
  13. import org.bukkit.entity.Player;
  14. import org.bukkit.event.EventHandler;
  15. import org.bukkit.event.Listener;
  16. import org.bukkit.event.entity.PlayerDeathEvent;
  17. import org.bukkit.inventory.ItemStack;
  18.  
  19. import com.google.common.io.Files;
  20.  
  21. import de.kumpelblase2.remoteentities.EntityManager;
  22. import de.kumpelblase2.remoteentities.RemoteEntities;
  23. import de.kumpelblase2.remoteentities.api.RemoteEntity;
  24. import de.kumpelblase2.remoteentities.api.RemoteEntityType;
  25.  
  26. public class PlayerDeathListener implements Listener
  27. {
  28.        
  29.         public String prefix = ChatColor.GOLD + "[" + ChatColor.ITALIC + ChatColor.BLUE + "Meep" + ChatColor.GRAY + "Ages" + ChatColor.RESET + ChatColor.GOLD + "]";
  30.        
  31.         public static int BLUE_POINTS = 0;
  32.         public static int RED_POINTS = 0;
  33.         public static int MAX = 50;
  34.         private MeepAges plugin;
  35.  
  36.         public PlayerDeathListener(MeepAges plugin2) {
  37.                
  38.                 this.plugin = plugin2;
  39.                
  40.         }
  41.  
  42.         @EventHandler
  43.         public void onPlayerDeath(PlayerDeathEvent event)
  44.         {
  45.                 Player p = (Player) event.getEntity().getKiller();
  46.                 Player dead = event.getEntity();
  47.                 if(PlayerJoinListener.red.contains(p.getDisplayName()) &&
  48.                                 PlayerJoinListener.red.contains(dead.getDisplayName()))
  49.                 {
  50.                         p.kickPlayer(prefix + "Killing your team mates is mean!");
  51.                         Bukkit.getServer().broadcastMessage(prefix + p.getDisplayName() + Color.RED +
  52.                         "Killed His Team Mate! -3 points For Red Team");
  53.                         RED_POINTS = RED_POINTS - 3;
  54.                 }
  55.        
  56.                 else
  57.                 {
  58.                         if(PlayerJoinListener.red.contains(p.getDisplayName()) &&
  59.                                         PlayerJoinListener.blue.contains(dead))
  60.                         {
  61.                                 RED_POINTS = RED_POINTS+1;
  62.                         }
  63.                         else
  64.                         {
  65.                                 if(PlayerJoinListener.blue.contains(p.getDisplayName()) &&
  66.                                                 PlayerJoinListener.blue.contains(dead.getDisplayName()))
  67.                                 {
  68.                                         p.kickPlayer(prefix + "Killing your team mates is mean!");
  69.                                         Bukkit.getServer().broadcastMessage(prefix + p.getDisplayName() + Color.RED +
  70.                                         "Killed His Team Mate! -3 points For Blue Team");
  71.                                         BLUE_POINTS = BLUE_POINTS - 3;
  72.                                 }
  73.                                 else
  74.                                 {
  75.                                         if(PlayerJoinListener.blue.contains(p.getDisplayName())
  76.                                                         && PlayerJoinListener.red.contains(dead.getDisplayName()))
  77.                                         {
  78.                                                 BLUE_POINTS = BLUE_POINTS+1;
  79.                                         }
  80.                                 }
  81.                         }
  82.                 }
  83.                 if(RED_POINTS == MAX)
  84.                 {
  85.                         Bukkit.getWorld("world").spawnEntity(
  86.                                         new Location(Bukkit.getWorld("world"), 58, 66.000, -546), EntityType.VILLAGER);
  87.                         Bukkit.getServer().broadcastMessage(prefix + Color.BLUE + "The King Has Spawned For Blue Team! Kill It!");
  88.                         if(!(EntityType.VILLAGER.isAlive()))
  89.                         {
  90.                                 if(RED_POINTS == MAX && RED_POINTS > BLUE_POINTS)
  91.                                 {
  92.                                 Bukkit.getServer().broadcastMessage(prefix + Color.RED + "Red Team Wins!");
  93.                                 try {
  94.                                         Thread.sleep(4000);
  95.                                 } catch (InterruptedException e) {
  96.                                         // TODO Auto-generated catch block
  97.                                         e.printStackTrace();
  98.                                 }
  99.                                 copyFile.switchMap();
  100.                                 Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "reload");
  101.                         }
  102.                 }
  103.         }
  104.         else
  105.         {
  106.                 if(BLUE_POINTS == MAX)
  107.                 {
  108.                         Bukkit.getWorld("world").spawnEntity(
  109.                                         new Location(Bukkit.getWorld("world"), 56, 66.000, -653), EntityType.VILLAGER);
  110.                         Bukkit.getServer().broadcastMessage(prefix + Color.BLUE + "The King Has Spawned For Blue Team! Kill It!");
  111.                         if(!(EntityType.VILLAGER.isAlive()))
  112.                         {
  113.                                 if(BLUE_POINTS == MAX && BLUE_POINTS> RED_POINTS)
  114.                                 {
  115.                                 Bukkit.getServer().broadcastMessage(prefix + Color.RED + "Blue Team Wins!");
  116.                                 try {
  117.                                         Thread.sleep(4000);
  118.                                 } catch (InterruptedException e) {
  119.                                         // TODO Auto-generated catch block
  120.                                         e.printStackTrace();
  121.                                 }
  122.                                 copyFile.switchMap();
  123.                                 Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "reload");
  124.                         }
  125.                 }
  126.           }
  127.         }
  128.   }
  129. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement