public static PlayerDeathEvent callPlayerDeathEvent(
      EntityPlayer victim, List<org.bukkit.inventory.ItemStack> drops, String deathMessage) {
    BukkitPlayer entity = (BukkitPlayer) getBukkitEntity(victim);
    PlayerDeathEvent event =
        new PlayerDeathEvent(entity, drops, victim.experienceValue, 0, deathMessage);
    org.bukkit.World world = entity.getWorld();
    Bukkit.getServer().getPluginManager().callEvent(event);

    /*victim.keepLevel = event.getKeepLevel();
    victim.newLevel = event.getNewLevel();
    victim.newTotalExp = event.getNewTotalExp();
    victim.expToDrop = event.getDroppedExp();
    victim.newExp = event.getNewExp();*/

    for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
      if (stack == null || stack.getType() == Material.AIR) continue;

      if (stack instanceof BukkitItemStack) {
        // Use the internal item to preserve possible data.
        victim.dropItemWithOffset(stack.getTypeId(), stack.getAmount(), 0.0F);
      } else {
        world.dropItemNaturally(entity.getLocation(), stack);
      }
    }

    return event;
  }
 @EventHandler
 public void onPlayerDeath(PlayerDeathEvent event) {
   if (event.getEntity().getKiller() == null) {
     return;
   } else {
     Player p = event.getEntity();
     plugin.punished.put(p, p.getKiller());
     p.sendMessage(
         ChatColor.GRAY
             + "You have been slain by "
             + ChatColor.RED
             + p.getKiller().getName()
             + ChatColor.GRAY
             + "!");
     if (lastIndict.containsKey(p)) {
       if (System.currentTimeMillis() < (lastIndict.get(p) + plugin.timeBetweenIndicts)) {
         p.sendMessage(
             ChatColor.GRAY + "Not enough time has passed for their karma to be affected again!");
         return;
       }
     }
     p.sendMessage(
         ChatColor.GRAY
             + "Please use "
             + ChatColor.RED
             + "'/indict'"
             + ChatColor.GRAY
             + " to punish the crime or "
             + ChatColor.GREEN
             + "'/forgive' "
             + ChatColor.GRAY
             + "to absolve them!");
     lastIndict.put(p, System.currentTimeMillis());
   }
 }
Ejemplo n.º 3
0
 // ================================================================================================
 @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
 public void onPlayerDeath(PlayerDeathEvent event) {
   if (plugin.playerIsAffected(
       event
           .getEntity()
           .getPlayer())) // TODO this will trigger, regardless of the death cause. Should be
                          // checking if player died from coldDamage!
   {
     // TODO make maxJailDuration function. Finally there will be more than one jail!
     // duration will become higher when a player dies more often.
     if (Arctica.minJailDuration > 0) {
       plugin
           .getServer()
           .dispatchCommand(
               plugin.getServer().getConsoleSender(),
               "tjail "
                   + event.getEntity().getPlayer().getName()
                   + " "
                   + Arctica.jailName
                   + " "
                   + Arctica.minJailDuration
                   + "m");
     }
   }
 }
  public void PlayerDeath(PlayerDeathEvent event) {
    Entity entity = event.getEntity();

    if (entity instanceof TNTPrimed) {
      TNTPrimed tnt = (TNTPrimed) entity;
      event.getEntity().getWorld().createExplosion(tnt.getLocation(), 0);
    }
  }
 @EventHandler
 public void onDeath(PlayerDeathEvent event) {
   Spellbook spellbook = MagicSpells.getSpellbook(event.getEntity());
   for (PassiveSpell spell : spells) {
     if (spellbook.hasSpell(spell)) {
       spell.activate(event.getEntity());
     }
   }
 }
Ejemplo n.º 6
0
  // register that we killed the Player who fired this event
  public void registerKill(PlayerDeathEvent e) {
    // sanity check...
    if (e.getEntity().getKiller() != getPlayer()) return;

    // get the name of the player who died, record one kill against them
    AutoRefPlayer apl = getTeam().getMatch().getPlayer(e.getEntity());
    kills.put(apl, 1 + kills.get(apl));
    ++totalKills;
  }
Ejemplo n.º 7
0
 /** Handles player death events, removes the death message. */
 @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
 public void onPlayerDeath(PlayerDeathEvent event) {
   String playerName = event.getEntity().getName();
   if (ultimateGames.getPlayerManager().isPlayerInArena(playerName)) {
     Arena arena = ultimateGames.getPlayerManager().getPlayerArena(playerName);
     arena.getGame().getGamePlugin().onPlayerDeath(arena, event);
     event.setDeathMessage("");
   }
 }
Ejemplo n.º 8
0
 @EventHandler
 public void onDeath(PlayerDeathEvent event) {
   _death++;
   String player = event.getEntity().getName();
   _death_players.put(
       player, _death_players.containsKey(player) ? _death_players.get(player) + 1 : 1);
   String world = event.getEntity().getWorld().getName();
   _death_worlds.put(world, _death_worlds.containsKey(world) ? _death_worlds.get(world) + 1 : 1);
 }
Ejemplo n.º 9
0
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onPlayerDeath(PlayerDeathEvent e) {
   e.setDroppedExp(0);
   PlayerDetails p = getPlayerDetails(e.getEntity());
   if (p == null) // make way for hacky plugins!
   return;
   p.setHealth(0);
   p.giveMana = false;
 }
Ejemplo n.º 10
0
  @EventHandler
  public void onDeath(PlayerDeathEvent e) {
    Player p = (Player) e.getEntity();

    if (adminMode.contains(p.getName())) {
      adminMode.remove(p.getName());
      respawn.add(p.getName());
      e.getDrops().clear();
    }
  }
Ejemplo n.º 11
0
 @EventHandler
 public void onDeath(PlayerDeathEvent e) throws IOException {
   Player p = e.getEntity();
   if (p.hasPermission("kits.deathinv")) {
     InventoryNBTSer.setInv(p, plugin.folder);
     e.getDrops().clear();
   }
   if (p.hasPermission("kits.deathexp")) {
     e.setDroppedExp(0);
   }
 }
Ejemplo n.º 12
0
  @EventHandler
  public void onPlayerDeath(PlayerDeathEvent e) {
    if (e.getDeathMessage() == null) {
      return;
    } else if (e.getDeathMessage().endsWith(" died")) {
      e.setDeathMessage(null);
    }

    if (Arcade.getMatches().getStatus() != ArcadeMatchStatus.RUNNING) {
      e.getDrops().clear();
    }
  }
Ejemplo n.º 13
0
  public void die(DamageSource damagesource) {
    // CraftBukkit start
    if (this.dead) {
      return;
    }

    java.util.List<org.bukkit.inventory.ItemStack> loot =
        new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
    boolean keepInventory = this.world.getGameRules().getBoolean("keepInventory");

    if (!keepInventory) {
      for (int i = 0; i < this.inventory.items.length; ++i) {
        if (this.inventory.items[i] != null) {
          loot.add(CraftItemStack.asCraftMirror(this.inventory.items[i]));
        }
      }

      for (int i = 0; i < this.inventory.armor.length; ++i) {
        if (this.inventory.armor[i] != null) {
          loot.add(CraftItemStack.asCraftMirror(this.inventory.armor[i]));
        }
      }
    }

    org.bukkit.event.entity.PlayerDeathEvent event =
        CraftEventFactory.callPlayerDeathEvent(
            this, loot, damagesource.getLocalizedDeathMessage(this));

    String deathMessage = event.getDeathMessage();

    if (deathMessage != null && deathMessage.length() > 0) {
      this.server.getPlayerList().k(event.getDeathMessage());
    }

    // CraftBukkit - we clean the player's inventory after the EntityDeathEvent is called so plugins
    // can get the exact state of the inventory.
    if (!keepInventory) {
      for (int i = 0; i < this.inventory.items.length; ++i) {
        this.inventory.items[i] = null;
      }

      for (int i = 0; i < this.inventory.armor.length; ++i) {
        this.inventory.armor[i] = null;
      }
    }

    this.closeInventory();

    // Update effects on player death
    this.updateEffects = true;
    // CraftBukkit end
  }
Ejemplo n.º 14
0
 /**
  * Saves the player's death and resets their spawn point to the team spawn
  *
  * @param event
  */
 @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
 public void onDeath(final PlayerDeathEvent event) {
   // getLogger().info("DEBUG: death");
   Player player = event.getEntity();
   // Check if player died in-game
   if (!player.getWorld().equals(getBeaconzWorld())) {
     // getLogger().info("DEBUG: not in world");
     return;
   }
   // If in the lobby, ignore
   if (getGameMgr().isLocationInLobby(player.getLocation())) {
     // getLogger().info("DEBUG: died in lobby");
     return;
   }
   // Get game
   Game game = getGameMgr().getGame(player.getLocation());
   if (game != null) {
     Team team = game.getScorecard().getTeam(player);
     // getLogger().info("DEBUG: team is " + team.getDisplayName());
     // Store new spawn point
     Location spawnPoint = game.getScorecard().getTeamSpawnPoint(team);
     // getLogger().info("DEBUG: new spawn point is " + spawnPoint);
     if (event.getKeepInventory()) {
       // Store the inventory for this player because they will get it when they come back
       // Will also store their exp
       // getLogger().info("DEBUG: keep inventory is true");
       getBeaconzStore().storeInventory(player, game.getName(), spawnPoint);
     } else {
       // getLogger().info("DEBUG: keep inventory is false");
       // Their inventory is going to get dumped on the floor so they need to have their
       // possessions removed
       getBeaconzStore().clearItems(player, game.getName(), spawnPoint);
     }
     if (!event.getKeepLevel()) {
       // getLogger().info("DEBUG: lose level! - new exp = " + event.getNewExp());
       // If they don't get to keep their level, their exp needs updating to what they'll get in
       // this world.
       getBeaconzStore().setExp(player, game.getName(), event.getNewExp());
     } else {
       // getLogger().info("DEBUG: keep level");
     }
     // They are dead, so when they respawn they need to have full health (otherwise they will die
     // repeatedly)
     getBeaconzStore().setHealth(player, game.getName(), player.getMaxHealth());
     // They will also get full food level
     getBeaconzStore().setFood(player, game.getName(), 20);
     // Make a note of their death status
     deadPlayers.put(player.getUniqueId(), spawnPoint);
   } else {
     // getLogger().info("DEBUG: game is null");
   }
 }
Ejemplo n.º 15
0
 @EventHandler
 public void onPlayerDeath(PlayerDeathEvent event) {
   MinestarPlayer thisPlayer = MinestarCore.getPlayer(event.getEntity().getName());
   if (thisPlayer.getMinestarGroup().equals(MinestarGroup.ADMIN)
       && event.getEntity().getGameMode() != GameMode.ADVENTURE) {
     // 25 % Drop chance
     if (randomizer.nextInt(4) == 0) {
       ItemStack bedrockStack = new ItemStack(Material.BEDROCK);
       bedrockStack.setAmount(1);
       event.getEntity().getWorld().dropItem(event.getEntity().getLocation(), bedrockStack);
     }
   }
 }
Ejemplo n.º 16
0
 // <Index = 3>
 @EventHandler
 public void onPlayerDeath(PlayerDeathEvent event) {
   Player att = event.getEntity().getKiller();
   String pName = event.getEntity().getName();
   if (att instanceof Player && att.getEntityId() != event.getEntity().getEntityId()) {
     String aName = att.getName();
     SQL.addKill(aName);
     SQL.addMoney(aName, SQL.getMoney(pName) > SQL.getMoney(aName) ? 10 : 5);
     ScoreboardHandler.addKill(aName);
   }
   SQL.addDeath(pName);
   event.getDrops().clear();
 }
Ejemplo n.º 17
0
 @EventHandler(priority = EventPriority.NORMAL)
 public void onPlayerDeath(final PlayerDeathEvent event) {
   if (event.getDeathMessage() == null) {
     return;
   }
   for (final IRCChannel c : Variables.channels) {
     if (!c.getBlockedEvents().contains("game_death")) {
       IRC.sendMessageToChannel(
           c.getChannel(),
           ColorUtils.formatGametoIRC(event.getEntity().getDisplayName() + " has died."));
     }
   }
 }
Ejemplo n.º 18
0
  @EventHandler
  public void onEntityDeath(PlayerDeathEvent e) {
    if (e.getEntity() instanceof Player) {
      Player p = (Player) e.getEntity();

      int id = gm.getPlayerGameId(p);
      if (id != -1) {
        gm.getPlayerClass(p).PlayerDeath();

        gm.getGame(id).killPlayer(p, e.getDeathMessage());
        e.setDeathMessage(null);
      }
    }
  }
Ejemplo n.º 19
0
 /**
  * Handles players deaths. Checks if the the player was killed player. If the player was killed by
  * the player set the killers name to red.
  *
  * @param event The player death event
  */
 @EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
 public void onPlayerDeath(PlayerDeathEvent event) {
   Player killer;
   String nickCommand;
   if (!(event.getEntity().getKiller() == null)) {
     killer = event.getEntity().getKiller();
     // Sets a player to a PEX group with a red name for 4 hours
     nickCommand = ("pex user " + killer.getName() + " group add PlayerKiller * 14400");
     killer.setCustomNameVisible(true);
     plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), nickCommand);
     // Essentials bug workaround, a players name does not change color until /list is called once
     plugin.getServer().dispatchCommand(plugin.getServer().getConsoleSender(), "list");
   }
 }
Ejemplo n.º 20
0
  @EventHandler(priority = EventPriority.HIGHEST)
  private void onDeath(PlayerDeathEvent evt) {
    evt.getDrops().clear();

    final Player player = evt.getEntity().getPlayer();
    final PlayerDataClass playerData =
        plugin.getPlayerHandler().findPlayer(player.getDisplayName());

    if (playerData != null) {

      setUnscoped(player, playerData);

      plugin.getPlayerLocationListener().removePlayerFromPoint(playerData);

      if (evt.getEntity().getKiller() != null) {
        Player killer = evt.getEntity().getKiller();
        PlayerDataClass killerData = plugin.getPlayerHandler().findPlayer(killer.getDisplayName());

        playerData.setDeaths(playerData.getDeaths() + 1);
        if (killer != null) {
          killerData.setKills(killerData.getKills() + 1);
        }
      }
      if (playerData.getType().equals("spy") && playerData.getDisguised() != null) {
        playerData.setDisguised(null);
      }

      if (player.isDead()) {
        player.setHealth(20);
      }

      plugin
          .getServer()
          .getScheduler()
          .scheduleSyncDelayedTask(
              plugin,
              new Runnable() {
                public void run() {
                  if (plugin.getPlayerHandler().findPlayer(player.getDisplayName()) != null) {
                    plugin.getLogger().info("Respawning: " + player.getName());
                    plugin.getPlayerHandler().spawnPlayer(playerData);
                    TagAPI.refreshPlayer(player);
                  }
                }
              },
              5L);
    } else {
      plugin.getGameManager().teleportToSpawn(player);
    }
  }
	@EventHandler(priority = EventPriority.LOWEST)
	public void onPlayerDeathEvent(final PlayerDeathEvent event)
	{
		final User user = ess.getUser(event.getEntity());
		if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back"))
		{
			user.setLastLocation();
			user.sendMessage(_("backAfterDeath"));
		}
		if (!ess.getSettings().areDeathMessagesEnabled())
		{
			event.setDeathMessage("");
		}
	}
 /**
  * * When player dies, save their back position, so they can return if they have permissions to do
  * so.
  *
  * @param e
  * @return
  */
 @EventHandler(priority = EventPriority.NORMAL)
 public void saveBackPosition(PlayerDeathEvent e) {
   Player p = e.getEntity();
   if (!Permissions.checkPermEx(p, "cex.back.deathcoords")) return;
   String pName = p.getName();
   Command_cex_back.lastLocations.put(pName, p.getLocation());
 }
Ejemplo n.º 23
0
 @EventHandler(priority = EventPriority.MONITOR)
 public void onDeathEvent(PlayerDeathEvent event) {
   Player player = event.getEntity();
   if (!plugin.isSkyWorld(player.getWorld())) {
     return;
   }
   if (!visitorsCanDrop && !plugin.playerIsOnIsland(player) && !plugin.playerIsInSpawn(player)) {
     event.getDrops().clear();
     plugin.notifyPlayer(player, "\u00a7eVisitors can't drop items!");
     return;
   }
   // Take over the drop, since Bukkit don't do this in a Metadatable format.
   for (ItemStack stack : event.getDrops()) {
     addDropInfo(player, stack);
   }
 }
 @EventHandler
 public void onPlayerDeath(PlayerDeathEvent e) {
   Iterator<ItemStack> it = e.getDrops().iterator();
   while (it.hasNext()) {
     if (isSoulbound(it.next())) it.remove();
   }
 }
 @EventHandler
 public void onPlayerDeath(PlayerDeathEvent event) {
   Player player = event.getEntity().getPlayer();
   if (event.getDeathMessage().contains("died")) {
     if (purple == true) {
       event.setDeathMessage(
           player.getName() + " was killed by " + ChatColor.DARK_PURPLE + "the purple lords");
     } else if (black == true) {
       event.setDeathMessage(
           player.getName() + " was killed by " + ChatColor.GRAY + "the darkness");
     } else {
       event.setDeathMessage(player.getName() + " was killed by an admin");
     }
     return;
   }
 }
Ejemplo n.º 26
0
 @EventHandler(priority = EventPriority.HIGHEST)
 public void onPlayerKilled(PlayerDeathEvent event) {
   // players don't drop leather armor or iron swords on death
   List<ItemStack> drops = event.getDrops();
   for (int i = 0; i < drops.size(); i++)
     if (!isAllowedToDrop(drops.get(i).getType())) drops.remove(i--);
 }
Ejemplo n.º 27
0
 @EventHandler
 public void onDeath(PlayerDeathEvent event) {
   if (isFilly(event.getEntity())) {
     ArrayList<ItemStack> removeMe = new ArrayList<ItemStack>();
     for (ItemStack is : event.getDrops()) {
       if (is.getType() == Material.WRITTEN_BOOK) {
         BookMeta bm = (BookMeta) is.getItemMeta();
         if ((bm.hasAuthor() && bm.getAuthor().equals("TheQueenOfPink"))
             && (bm.hasTitle() && bm.getTitle().equals("MineLittlePony.se Handbook"))) {
           removeMe.add(is);
         }
       }
     }
     event.getDrops().removeAll(removeMe);
   }
 }
Ejemplo n.º 28
0
  // register that we just died
  public void registerDeath(PlayerDeathEvent e) {
    // sanity check...
    if (e.getEntity() != getPlayer()) return;

    // get the last damage cause, and mark that as the cause of one death
    AutoRefPlayer.DamageCause dc =
        AutoRefPlayer.DamageCause.fromDamageEvent(e.getEntity().getLastDamageCause());
    deaths.put(dc, 1 + deaths.get(dc));
    ++totalDeaths;

    AutoRefMatch match = getTeam().getMatch();
    Location loc = e.getEntity().getLocation();
    match.addEvent(
        new TranscriptEvent(
            match, TranscriptEvent.EventType.PLAYER_DEATH, e.getDeathMessage(), loc, this, dc.p));
  }
Ejemplo n.º 29
0
  @EventHandler
  public void onPlayerDeath(PlayerDeathEvent e) {
    Player p = e.getEntity();
    Player k = p.getKiller();

    if (k instanceof Player && p instanceof Player) {
      if (FileUtils.hasBounty(p.getName())) {
        p.sendMessage(
            config
                .getString("bountyVictim")
                .replace("%prefix", config.getString("Prefix"))
                .replace("%target", k.getName())
                .replace("&", "¤"));
        k.sendMessage(
            config
                .getString("bountyMurderer")
                .replace("%prefix", config.getString("Prefix"))
                .replace("%target", p.getName())
                .replace("&", "¤"));

        Bountys.economy.depositPlayer(k, FileUtils.getBounty(p.getName()));

        FileUtils.removeBounty(p.getName());
      }
    }
  }
Ejemplo n.º 30
0
 @EventHandler
 public void DeathEvent(PlayerDeathEvent e) {
   Player player = e.getEntity();
   if (UtilsIceTag.players.contains(player)) {
     if (UtilsIceTag.started == true) {
       this.hg.removePlayer(player);
       hg.broadcastMSG(player.getName() + " Died");
       if (UtilsIceTag.players.size() <= 1) {
         Player winner = null;
         for (Player pl : UtilsIceTag.players) {
           winner = pl;
         }
         if (winner != null) {
           hg.broadcastMSG(winner.getName() + " Won!!!");
           winner.teleport(winner.getWorld().getSpawnLocation().add(0.50, 0, 0.50));
         }
         hg.stopGame();
       } else {
         hg.broadcastMSG(UtilsIceTag.players.size() + " Remaining");
       }
     } else {
       this.hg.removePlayer(player);
     }
   }
 }