Advertisement
Guest User

PlayerDeathEvent

a guest
Feb 15th, 2014
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.41 KB | None | 0 0
  1.     @EventHandler
  2.     public void Deaths(PlayerDeathEvent e) {
  3.         e.setDeathMessage("");
  4.         e.getDrops().clear();
  5.         e.setDroppedExp(0);
  6.        
  7.         //long startTime = System.currentTimeMillis();
  8.        
  9.         if(plugin.playersIngame.containsKey(e.getEntity())) {
  10.             if(e.getEntity().getKiller() != null) {
  11.                 if(plugin.playersIngame.containsKey(e.getEntity().getKiller())) {
  12.                     Player p = (Player)e.getEntity();
  13.                     Player killer = p.getKiller();
  14.                    
  15.                     String arena = plugin.playersIngame.get(killer);
  16.                     Game g = plugin.games.get(arena);
  17.                    
  18.                     g.AddPoints(killer, arena);
  19.                    
  20.                     plugin.sb.addDeath(p);
  21.                     //if(g != null && p != null) {
  22.                         if(g.killstreak.containsKey(p)) {
  23.                             g.killstreak.put(p, 0);
  24.                         }
  25.                     //}
  26.                     plugin.sb.updateScoreboard(p);
  27.                    
  28.                    
  29.                     plugin.sb.addKill(killer);
  30.                     if (plugin.games.get(arena) != null) {
  31.                         Game ga = plugin.games.get(arena);
  32.                         if (!ga.killstreak.containsKey(killer)) {
  33.                             ga.killstreak.put(killer, 1);
  34.                         } else { // ------------------------------------------------------
  35.                                     // KILLSTREAKS
  36.                             int newold = (plugin.games.get(arena).killstreak
  37.                                     .get(killer) + 1);
  38.                             // int newold = (old + 1);
  39.  
  40.                             switch (newold) {
  41.                             case 6:
  42.                                 ItemStack is = new ItemStack(
  43.                                         Material.SLIME_BALL);
  44.                                 ItemMeta im = is.getItemMeta();
  45.                                 im.setDisplayName(ChatColor.GREEN + "Grenade");
  46.                                 is.setItemMeta(im);
  47.  
  48.                                 killer.getInventory().addItem(is);
  49.  
  50.                                 killer.updateInventory();
  51.                                 killer.sendMessage(ChatColor.DARK_GRAY
  52.                                         + "["
  53.                                         + ChatColor.GOLD
  54.                                         + "LTPSidesBattle"
  55.                                         + ChatColor.DARK_GRAY
  56.                                         + "] "
  57.                                         + ChatColor.GREEN
  58.                                         + "Du hast deine 6er Killstreak erreicht");
  59.                                 killer.sendMessage(ChatColor.DARK_GRAY + "["
  60.                                         + ChatColor.GOLD + "LTPSidesBattle"
  61.                                         + ChatColor.DARK_GRAY + "] "
  62.                                         + ChatColor.GREEN
  63.                                         + "Du hast eine Granate erhalten");
  64.  
  65.                                 // Iterator itr =
  66.                                 // plugin.games.get(arena).players.iterator();
  67.                                 // while (itr.hasNext()) {
  68.                                 // Player player = (Player) itr.next();
  69.                                 // player.sendMessage(ChatColor.RED +
  70.                                 // killer.getName() +
  71.                                 // ChatColor.GOLD +
  72.                                 // " hat seine 6er Killstreak erreicht");
  73.                                 // }
  74.                                 break;
  75.                             case 4:
  76.                                 ItemStack issl = new ItemStack(
  77.                                         Material.NETHER_STAR);
  78.                                 ItemMeta imml = issl.getItemMeta();
  79.                                 imml.setDisplayName(ChatColor.GREEN + "Flash");
  80.                                 issl.setItemMeta(imml);
  81.  
  82.                                 killer.getInventory().addItem(issl);
  83.                                 killer.updateInventory();
  84.                                 killer.sendMessage(ChatColor.DARK_GRAY
  85.                                         + "["
  86.                                         + ChatColor.GOLD
  87.                                         + "LTPSidesBattle"
  88.                                         + ChatColor.DARK_GRAY
  89.                                         + "] "
  90.                                         + ChatColor.GREEN
  91.                                         + "Du hast deine 4er Killstreak erreicht");
  92.                                 killer.sendMessage(ChatColor.DARK_GRAY + "["
  93.                                         + ChatColor.GOLD + "LTPSidesBattle"
  94.                                         + ChatColor.DARK_GRAY + "] "
  95.                                         + ChatColor.GREEN
  96.                                         + "Du hast eine Flash-Granate erhalten");
  97.  
  98.                                 // Iterator itr =
  99.                                 // plugin.games.get(arena).players.iterator();
  100.                                 // while (itr.hasNext()) {
  101.                                 // Player player = (Player) itr.next();
  102.                                 // player.sendMessage(ChatColor.RED +
  103.                                 // killer.getName() +
  104.                                 // ChatColor.GOLD +
  105.                                 // " hat seine 4er Killstreak erreicht");
  106.                                 // }
  107.                                 break;
  108.                             default:
  109.                                 break;
  110.                             }
  111.  
  112.                             if (newold != 6)
  113.                                 plugin.games.get(arena).killstreak.put(killer,
  114.                                         newold);
  115.                             else if (newold >= 6) {
  116.                                 plugin.games.get(arena).killstreak.put(killer,
  117.                                         0);
  118.                                 plugin.sb.updateScoreboard(killer);
  119.                             }
  120.                             // KillStreakLogic(killer, arena, p);
  121.                         }
  122.                     }
  123.                     plugin.sb.updateScoreboard(killer);
  124.                    
  125.                    
  126.                     if(plugin.games.get(arena) != null) {
  127.                         //if(killer != null && p != null) {
  128.                             plugin.games.get(arena).addKillMessage(p, killer, KillMessageType.Normal);
  129.                         //}
  130.                     }
  131.                     //e.setDeathMessage(ChatColor.GOLD + e.getEntity().getKiller().getName() + ChatColor.YELLOW + " [" + ChatColor.GOLD + "Bow" + ChatColor.YELLOW + "] " + ChatColor.GOLD + e.getEntity().getName());
  132.                 }
  133.             }
  134.         }
  135.        
  136.         //long endTime = System.currentTimeMillis();
  137.         //long duration = endTime - startTime;
  138.        
  139.         //Bukkit.broadcastMessage("Time(ms):" + duration);
  140.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement