Java 类org.bukkit.event.entity.PlayerDeathEvent 实例源码

项目:EscapeLag    文件:RespawnAction.java   
@EventHandler(priority = EventPriority.MONITOR)
public void autoRespawn(PlayerDeathEvent evt) {
    if (canAutoRespawn) {
        final Player player = evt.getEntity();
        Bukkit.getScheduler().runTaskLater(EscapeLag.MainThis, new Runnable() {
            @Override
            @SuppressWarnings("all")
            public void run() {
                if(VersionLevel.isSpigot()){
                    player.spigot().respawn();
                    if (sendTitleAutoRespawn) {
                        if(VersionLevel.isHigherEquals(Version.MINECRAFT_1_8_R2)){
                            player.sendTitle(titleAutoRespawn, subtitleAutoRespawn);
                        }else{
                            AzureAPI.log("错误!你不应该开启自动复活的title显示,无法显示!因为你的服务器版本低于1.8.4!");
                        }
                    }
                }
            }
        }, 1);
    }
}
项目:bskyblock    文件:VisitorGuard.java   
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onVisitorDeath(final PlayerDeathEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (!Util.inWorld(e.getEntity())) {
        return;
    }
    // Mute death messages
    if (Settings.muteDeathMessages) {
        e.setDeathMessage(null);
    }
    // If visitors will keep items and their level on death. This overrides any global settings.
    // If the player is not a visitor then they die and lose everything - sorry :-(
    Island island = plugin.getIslands().getProtectedIslandAt(e.getEntity().getLocation());
    if (island != null && !island.getMembers().contains(e.getEntity().getUniqueId()) && island.getFlag(SettingsFlag.KEEP_INVENTORY)) {
        // They are a visitor
        InventorySave.getInstance().savePlayerInventory(e.getEntity());
        e.getDrops().clear();
        e.setKeepLevel(true);
        e.setDroppedExp(0);
    }
}
项目:WC    文件:PlayerEvent.java   
@EventHandler
 public void onDeath(PlayerDeathEvent e){
  Entity en1 = e.getEntity();
  Entity en = e.getEntity().getKiller();

  if (en instanceof Player){
      Player pl = (Player)en1;
         Player p = (Player)en;

if(manager.isInPvP(p)){
             vu.killMoney(p, pl);
            e.setKeepInventory(true);

    pvpc.removeCooldown(p);
    pvpc.removeCooldown(pl);

            p.sendMessage(Message.prefix + ChatColor.DARK_GREEN + " Ya no estás en pvp, puedes desconectarte.");
            pl.sendMessage(Message.prefix + ChatColor.DARK_GREEN + " Ya no estás en pvp, puedes desconectarte.");
         }

     }
 }
项目:WC    文件:WorldInteract.java   
@EventHandler
public void playerDie(PlayerDeathEvent e){
    Player p = e.getEntity();
    Location l = p.getLocation();
    Economy eco = new Economy(p);
    DecimalFormat df = new DecimalFormat("0.##");
    double money = 0;

    try {
         money = new Double(df.format(eco.getMoney() * 0.04).replace(",", "."));
    }catch(NumberFormatException ex){
        WCServer.log(WCServer.Level.WARNING, "Intentando crear un double con ,");
    }

    if (eco.getMoney() - money <= 0) return;
    eco.removeMoney(money);

    l.getWorld().dropItemNaturally(l, new ItemMaker(Material.GOLD_INGOT).setDisplayName("&2" + money + "&6€ de &c" + p.getName()).build());

    Teams.TeamsInfo team = plugin.getTeams().getTeam(WCTWD.getPlayer(p));

    e.setDeathMessage(Utils.colorize(team.getColor() + p.getName() + " &7ha muerto por un &cataque Zombie"));
}
项目:PlayerStevesBattleGrounds    文件:Battles.java   
@EventHandler
private void onPlayerDeath(PlayerDeathEvent e) {
    e.setDeathMessage(null);
    e.setDroppedExp(0);
    e.getEntity().setGameMode(GameMode.SPECTATOR);
    PlayerTagMetadata.updateMetadata(e.getEntity(), PlayerTag.SPECTATING);

    if(e.getEntity().hasMetadata("last_hurt_by")) {
        Player killer = (Player) e.getEntity().getMetadata("last_hurt_by").get(0).value();
        plugin.getServer().broadcastMessage(Lang.build("messages.game.kill", e.getEntity().getName(),
                killer.getName()));
        if(killer.isOnline()) {
            Score s = killer.getScoreboard().getObjective(DisplaySlot.SIDEBAR).getScore(scoreboardLabelKills);
            s.setScore(s.getScore() + 1);
        }
    } else {
        plugin.getServer().broadcastMessage(Lang.build("messages.game.died", e.getEntity().getName()));
    }

    rerankPlayers();
}
项目:ProjectAres    文件:ItemKeepPlayerFacet.java   
/**
 * NOTE: Must be called before {@link tc.oc.pgm.tracker.trackers.DeathTracker#onPlayerDeath(PlayerDeathEvent)}
 */
@SuppressWarnings("deprecation")
@TargetedEventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void processPlayerDeath(PlayerDeathEvent event) {
    if(!player.isParticipating()) return;
    if(!rules.canKeepAny()) return;

    final Map<Slot, ItemStack> carrying = new HashMap<>();
    Slot.Player.player().forEach(slot -> slot.item(event.getEntity())
                                             .ifPresent(item -> carrying.put(slot, item)));

    kept.clear();

    carrying.forEach((slot, item) -> {
        if(rules.canKeep(slot, item)) {
            event.getDrops().remove(item);
            kept.put(slot, item);
        }
    });
}
项目:FactionsXL    文件:PlayerListener.java   
@EventHandler
public void onDeath(PlayerDeathEvent event) {
    Player killedP = event.getEntity();
    Player killerP = event.getEntity().getKiller();
    FPlayer killedF = fPlayers.getByPlayer(killedP);
    FPlayer killerF = killerP != null ? fPlayers.getByPlayer(killerP) : null;
    double loss = fConfig.getPowerDeathLoss();
    double newPower = killedF.getPower() - loss;
    killedF.setPower(newPower < fConfig.getMinPower() ? fConfig.getMinPower() : newPower);
    if (killerP != null) {
        killerF.setPower(killerF.getPower() + loss);
        ParsingUtil.sendMessage(killedP, FMessage.DEATH_PLAYER_KILL_KILLED.getMessage(), killerF, String.valueOf(loss), String.valueOf(killedF.getPower()));
        ParsingUtil.sendMessage(killerP, FMessage.DEATH_PLAYER_KILL_KILLER.getMessage(), killedF, String.valueOf(loss), String.valueOf(killerF.getPower()));
    } else {
        ParsingUtil.sendMessage(killedP, FMessage.DEATH_DEFAULT_DEATH.getMessage(), String.valueOf(loss), String.valueOf(killedF.getPower()));
    }
}
项目:MockBukkit    文件:PlayerMock.java   
@Override
public void setHealth(double health)
{
    if (health <= 0)
    {
        this.health = 0;
        PlayerDeathEvent event = new PlayerDeathEvent(this, new ArrayList<>(), 0, name + " got killed");
        Bukkit.getPluginManager().callEvent(event);
    }
    else if (health > maxHealth)
    {
        this.health = maxHealth;
    }
    else
    {
        this.health = health;
    }
}
项目:mczone    文件:GameEvents.java   
@EventHandler
  public void onPlayerDeath(PlayerDeathEvent event) {
    String dmessage = event.getDeathMessage() + "!";
Team.getTeam(event.getEntity()).leave(event.getEntity());
    event.setDeathMessage(null);
      if (State.PRE)
          return;

if (event.getEntity().getKiller() instanceof Player) {
    Hive.getInstance().getDatabase().update(String.format("INSERT INTO kills (server,game_id,player,target) VALUES ('%s',%d,'%s','%s')","walls",Walls.ID,event.getEntity().getKiller().getName(),event.getEntity().getName()));
      }
else {
    Hive.getInstance().getDatabase().update(String.format("INSERT INTO kills (server,game_id,player,target) VALUES ('%s',%d,'%s','%s')","walls",Walls.ID,"natural",event.getEntity().getName()));
}

      Chat.server(dmessage.replace(event.getEntity().getName(), event.getEntity().getDisplayName() + "&c"));
      Walls.getSpectators().add(event.getEntity().getName());
      Player p = event.getEntity();
      Chat.player(p, "&2You are now a spectator and can watch the game.");
      Walls.updateSpectators();
p.setFlying(true);
  }
项目:SurvivalAPI    文件:CookieHeadModule.java   
/**
 * Drop player head on kill
 *
 * @param event Event
 */
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
    ItemStack head = new ItemStack(Material.SKULL_ITEM, 1, (short) 3);

    SkullMeta skullMeta = (SkullMeta)head.getItemMeta();
    skullMeta.setOwner(event.getEntity().getName());
    skullMeta.setDisplayName(ChatColor.AQUA + "Tête de " + event.getEntity().getName());

    head.setItemMeta(skullMeta);
    event.getDrops().add(head);

    List<PotionEffect> effectList = new ArrayList<>();
    effectList.addAll(event.getEntity().getActivePotionEffects());

    this.effects.put(event.getEntity().getName(), effectList);
}
项目:SurvivalAPI    文件:StockupModule.java   
/**
 * Give x absorption to all players on deaths
 *
 * @param event The player death event instance
 */
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
    for (SurvivalPlayer player : (Collection<SurvivalPlayer>) SamaGamesAPI.get().getGameManager().getGame().getInGamePlayers().values())
    {
        if (!player.getUUID().equals(event.getEntity().getUniqueId()))
        {
            Player p = player.getPlayerIfOnline();

            if (p == null)
                continue;

            EntityPlayer entityPlayer = ((CraftPlayer) p).getHandle();
            entityPlayer.setAbsorptionHearts(entityPlayer.getAbsorptionHearts() + (int) this.moduleConfiguration.get("hearts"));
        }
    }
}
项目:SurvivalAPI    文件:KillSwitchModule.java   
/**
 * When a player is dead, swap inventories
 *
 * @param event Event
 */
@EventHandler
public void onEntityDeath(PlayerDeathEvent event)
{
    if (event.getEntity().getKiller() != null)
    {
        ItemStack[] content = event.getEntity().getInventory().getContents();
        ItemStack[] armor = event.getEntity().getInventory().getArmorContents();

        event.getEntity().getKiller().getInventory().setContents(content);
        event.getEntity().getKiller().getInventory().setArmorContents(armor);

        event.getDrops().clear();

        event.getEntity().getKiller().sendMessage(ChatColor.GOLD + "Vous avez échangé votre inventaire avec celui de " + event.getEntity().getName() + ".");
    }
}
项目:SurvivalAPI    文件:SpeedSwapModule.java   
/**
 * Toggle speed when player dies
 *
 * @param event Event
 */
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
    for (GamePlayer player : (Collection<GamePlayer>) SamaGamesAPI.get().getGameManager().getGame().getInGamePlayers().values())
    {
        Player p = player.getPlayerIfOnline();

        if (p == null)
            return;

        p.addPotionEffect((this.isSpeed ? PotionEffectType.SPEED : PotionEffectType.SLOW).createEffect(Integer.MAX_VALUE, 1));
    }

    this.isSpeed = !this.isSpeed;
}
项目:Kineticraft    文件:Dungeons.java   
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) // Handle dungeon death.
public void onPlayerDeath(PlayerDeathEvent evt) {
    if (!isDungeon(evt.getEntity()))
        return;

    evt.setKeepLevel(true); // Keep XP, but drop inventory. (Since you can't bring anything in)
    Player p = evt.getEntity();
    makeCorpse(p);
    p.setHealth(p.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue()); // Restore to max health.
    p.setGameMode(GameMode.SPECTATOR); // Set to spectator.
    p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 50, 2)); // Give blindness.
    p.sendTitle(new Title(ChatColor.RED + "Dungeon Failed"));
    getDungeon(p).alert(p.getName() + " has been eliminated.");
    Utils.stopNBS(p); //Disable music.
    Bukkit.getScheduler().runTaskLater(Core.getInstance(), () -> {
        Utils.toSpawn(p); // Teleport to spawn.
        p.setGameMode(GameMode.SURVIVAL);
    }, 50L);
}
项目:HCFCore    文件:ConquestTracker.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerDeath(PlayerDeathEvent event) {
    Faction currentEventFac = plugin.getTimerManager().getEventTimer().getEventFaction();
    if (currentEventFac instanceof ConquestFaction) {
        Player player = event.getEntity();
        PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
        if (playerFaction != null && SettingsYML.CONQUEST_POINT_LOSS_PER_DEATH > 0) {
            int oldPoints = getPoints(playerFaction);
            if (oldPoints == 0) return;

            int newPoints = takePoints(playerFaction, SettingsYML.CONQUEST_POINT_LOSS_PER_DEATH);
            event.setDeathMessage(null); // for some reason if it isn't handled manually, weird colour coding happens
            Bukkit.broadcastMessage(ChatColor.YELLOW + "[" + currentEventFac.getName() + "] " +
                    ChatColor.GOLD + playerFaction.getName() + " lost " +
                    SettingsYML.CONQUEST_POINT_LOSS_PER_DEATH + " points because " + player.getName() + " died." +
                    ChatColor.AQUA + " (" + newPoints + '/' + SettingsYML.CONQUEST_REQUIRED_WIN_POINTS + ')' + ChatColor.YELLOW + '.');
        }
    }
}
项目:HCFCore    文件:DeathbanListener.java   
@EventHandler(ignoreCancelled=true, priority=EventPriority.LOW)
/*     */   public void onPlayerDeath(PlayerDeathEvent event) {
/*  99 */     final Player player = event.getEntity();
/* 100 */     final Deathban deathban = this.plugin.getDeathbanManager().applyDeathBan(player, event.getDeathMessage());
/* 101 */     long remaining = deathban.getRemaining();
/* 102 */     if ((remaining <= 0L) || (player.hasPermission("hcf.deathban.bypass"))) {
/* 103 */       return;
/*     */     }
/*     */
/* 106 */     if ((RESPAWN_KICK_DELAY_MILLIS <= 0L) || (remaining < RESPAWN_KICK_DELAY_MILLIS)) {
/* 107 */       handleKick(player, deathban);
/* 108 */       return;
/*     */     }
/*     */
/*     */
/* 112 */     this.respawnTickTasks.put(player.getUniqueId(), new BukkitRunnable()
/*     */     {
            /*     */       public void run() {
/* 115 */         DeathbanListener.this.handleKick(player, deathban);
/*     */       }
/* 117 */     }.runTaskLater(this.plugin, RESPAWN_KICK_DELAY_TICKS).getTaskId());
/*     */   }
项目:HCFCore    文件:InvincibilityTimer.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerDeath(PlayerDeathEvent event) {
    Player player = event.getEntity();
    World world = player.getWorld();
    Location location = player.getLocation();
    Collection<ItemStack> drops = event.getDrops();
    if (!drops.isEmpty()) {
        Iterator<ItemStack> iterator = drops.iterator();

        // Drop the items manually so we can add meta to prevent
        // PVP Protected players from collecting them.
        long stamp = System.currentTimeMillis() + +ITEM_PICKUP_DELAY;
        while (iterator.hasNext()) {
            itemUUIDPickupDelays.put(world.dropItemNaturally(location, iterator.next()).getUniqueId(), stamp);
            iterator.remove();
        }
    }

    clearCooldown(player);
}
项目:HCFCore    文件:WorldListener.java   
@EventHandler
public void deathDrop(PlayerDeathEvent e) {
    World w = e.getEntity().getWorld();
    Location l = e.getEntity().getLocation();
    EntityItem ei;
    NBTTagCompound nbt;
    NBTTagShort nbts = new NBTTagShort(itemAge);
    for (ItemStack d : e.getDrops()) {
        ei = ((EntityItem)((CraftItem)w.dropItemNaturally(l, d)).getHandle());
        nbt = new NBTTagCompound();
        ei.b(nbt);
        nbt.set("Age", nbts);
        ei.a(nbt);
    }
    e.getDrops().clear();
}
项目:HCFCore    文件:ConquestTracker.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onPlayerDeath(PlayerDeathEvent event) {
    Faction currentEventFac = plugin.getTimerManager().getEventTimer().getEventFaction();
    if (currentEventFac instanceof ConquestFaction) {
        Player player = event.getEntity();
        PlayerFaction playerFaction = plugin.getFactionManager().getPlayerFaction(player);
        if (playerFaction != null && SettingsYML.CONQUEST_POINT_LOSS_PER_DEATH > 0) {
            int oldPoints = getPoints(playerFaction);
            if (oldPoints == 0) return;

            int newPoints = takePoints(playerFaction, SettingsYML.CONQUEST_POINT_LOSS_PER_DEATH);
            event.setDeathMessage(null); // for some reason if it isn't handled manually, weird colour coding happens
            Bukkit.broadcastMessage(ChatColor.YELLOW + "[" + currentEventFac.getName() + "] " +
                    ChatColor.GOLD + playerFaction.getName() + " lost " +
                    SettingsYML.CONQUEST_POINT_LOSS_PER_DEATH + " points because " + player.getName() + " died." +
                    ChatColor.AQUA + " (" + newPoints + '/' + SettingsYML.CONQUEST_REQUIRED_WIN_POINTS + ')' + ChatColor.YELLOW + '.');
        }
    }
}
项目:HCFCore    文件:DeathbanListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
public void onPlayerDeath(PlayerDeathEvent event) {
    Player player = event.getEntity();
    Deathban deathban = plugin.getDeathbanManager().applyDeathBan(player, event.getDeathMessage());
    long remaining = deathban.getRemaining();
    if (remaining <= 0L || player.hasPermission(DeathbanListener.DEATH_BAN_BYPASS_PERMISSION)) {
        return;
    }

    if (DeathbanListener.RESPAWN_KICK_DELAY_MILLIS <= 0L || remaining < DeathbanListener.RESPAWN_KICK_DELAY_MILLIS) {
        this.handleKick(player, deathban);
        return;
    }

    // Let the player see the death screen for 10 seconds
    this.respawnTickTasks.put(player.getUniqueId(), new BukkitRunnable() {
        @Override
        public void run() {
            DeathbanListener.this.handleKick(player, deathban);
        }
    }.runTaskLater(plugin, DeathbanListener.RESPAWN_KICK_DELAY_TICKS).getTaskId());
}
项目:HCFCore    文件:InvincibilityTimer.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerDeath(PlayerDeathEvent event) {
    Player player = event.getEntity();
    World world = player.getWorld();
    Location location = player.getLocation();
    Collection<ItemStack> drops = event.getDrops();
    if (!drops.isEmpty()) {
        Iterator<ItemStack> iterator = drops.iterator();

        // Drop the items manually so we can add meta to prevent
        // PVP Protected players from collecting them.
        long stamp = System.currentTimeMillis() + +ITEM_PICKUP_DELAY;
        while (iterator.hasNext()) {
            itemUUIDPickupDelays.put(world.dropItemNaturally(location, iterator.next()).getUniqueId(), stamp);
            iterator.remove();
        }
    }

    clearCooldown(player);
}
项目:Chambers    文件:PlayerDeathListener.java   
@EventHandler
public void onDeath(PlayerDeathEvent event) {
    Profile profile = Chambers.getInstance().getProfileManager().getProfileByUuid(event.getEntity().getUniqueId());
    if (profile.getTeam() != null) {
        Player player = event.getEntity();
        if (event.getEntity().getKiller() instanceof Player) {
            Player killer = (Player) event.getEntity().getKiller();
            Profile killerProfile = Chambers.getInstance().getProfileManager().getProfileByUuid(killer.getUniqueId());
            killerProfile.setKills(killerProfile.getKills() + 1);
            killerProfile.deposit(250);
            killer.sendMessage(ChatColor.YELLOW + "You have earned " + ChatColor.GREEN + "$250" + ChatColor.YELLOW + " for killing " + profile.getTeam().getColor() + player.getName() + ChatColor.YELLOW + ".");
        }
        reset(player);
        profile.setDeaths(profile.getDeaths() + 1);
        if (profile.getTeam().isRaidable()) {
            profile.setProfileStatus(ProfileStatus.SPECTATING);
            return;
        }
        profile.setRespawnTime(30);
        profile.setProfileStatus(ProfileStatus.RESPAWNING);
        new RespawnTask(profile, player, player.getLocation()).runTaskAsynchronously(Chambers.getInstance());
    }
}
项目:SkywarsSeries    文件:PlayerDeath.java   
private void handle(PlayerDeathEvent event, Game game) {
    Player player = event.getEntity();

    if (!game.isState(Game.GameState.ACTIVE) && !game.isState(Game.GameState.DEATHMATCH)) {
        return;
    }

    event.setDeathMessage(null);
    game.activateSpectatorSettings(player);

    if (game.getPlayers().size() <= 1) {
        try {
            GamePlayer winner = game.getPlayers().get(0);
            if (winner.isTeamClass()) {
                game.sendMessage("&a"); // Broadcast team win
            } else {
                game.sendMessage("&a" + winner.getName() + " won the game!"); // Indiv win
            }

            game.setState(Game.GameState.ENDING);
        } catch (IndexOutOfBoundsException ignored) {}
    }
}
项目:BedwarsXP    文件:OldEventListeners.java   
@EventHandler
public void onPlayerDeath(PlayerDeathEvent e) {
    Game bw = io.github.yannici.bedwars.Main.getInstance().getGameManager()
            .getGameOfPlayer(e.getEntity());
    if (bw == null) {
        return;
    }
    if (!Config.isGameEnabledXP(bw.getName())) {
        return;
    }
    Player p = e.getEntity();
    int dropped = 0;
    if (Config.isDirect) {
        dropped = (int) (Config.Death);
    } else {
        dropped = (int) (p.getLevel() * (Config.Death));
    }
    BedwarsXPPlayerDeathDropExpEvent event = new BedwarsXPPlayerDeathDropExpEvent(
            bw.getName(), p, dropped);
    Bukkit.getPluginManager().callEvent(event);
    dropped = event.getDroppedXP();
    int to = XPManager.getXP(bw.getName(), p) - dropped;
    if (to < 0) {
        to = 0;
    }
    e.setNewLevel(to);
    XPManager.setXP(bw.getName(), p, to);
}
项目:PVPAsWantedManager    文件:JailManager.java   
@EventHandler
public void PlayerDeathEvent(PlayerDeathEvent event){
    Player player = event.getEntity();
    if(isJailPlayer(player)){
        event.setDeathMessage(null);
        player.spigot().respawn();
        playerTeleportJail(player);
    }
}
项目:RPGPlus    文件:StatsGUI.java   
@EventHandler
public void playerDeath(PlayerDeathEvent e) {
    Player player = (Player) e.getEntity();   
    if (player.getKiller() instanceof Player) { 
        Bukkit.broadcastMessage(ChatColor.GREEN + player.getKiller().getName() + ChatColor.DARK_GRAY + " has killed " + ChatColor.GREEN + player.getName());
        for (PotionEffect effect : player.getActivePotionEffects())
            player.removePotionEffect(effect.getType());       
        Datafiles.addDeath(player.getName());
        Datafiles.addKill(player.getKiller().getName());
        }else{
          Datafiles.addDeath(player.getName());

    }
    }
项目:EscapeLag    文件:UnloadClear.java   
@EventHandler
public void DeathNoClear(PlayerDeathEvent event) {
    if (ConfigOptimize.UnloadClearDROPPED_ITEMNoCleatDeath != true) {
        return;
    }
    Player player = event.getEntity();
    Chunk chunk = player.getLocation().getChunk();
    DeathChunk.add(chunk);
}
项目:WC    文件:PlayerEvent.java   
@EventHandler
public void onDeath(PlayerDeathEvent e){
    Player p = e.getEntity();

    if(WCSurvival.getPlayer(p).hasPermission("noDrop")) {
        e.setKeepInventory(true);
        e.setKeepLevel(true);
    }
}
项目:Locked    文件:PlayerListener.java   
@EventHandler
public void onDeath(PlayerDeathEvent event) {
    Player player = event.getEntity();
    try {
        if (RankManager.getGuardLevel(player) == 1 || RankManager.getGuardLevel(player) == 2) {
            event.setKeepInventory(true);
        } else {
            event.setKeepInventory(false);
        }
    } catch (SQLException e) {
        e.printStackTrace();
    }
}
项目:ProjectAres    文件:MatchPlayerDeathEvent.java   
public MatchPlayerDeathEvent(PlayerDeathEvent parent, MatchPlayer victim, DamageInfo damageInfo, boolean predicted) {
    super(checkNotNull(victim).getMatch());
    this.parent = checkNotNull(parent);
    this.victim = victim;
    this.damageInfo = checkNotNull(damageInfo);
    this.predicted = predicted;
}
项目:McPlayUHC    文件:PlayerDeathListener.java   
@EventHandler
public void PlayerDeathListener(PlayerDeathEvent e) {
    Player p = e.getEntity();
    if (SettingsManager.deathchest) {
        int x = p.getLocation().getBlockX();
        int y = p.getLocation().getBlockY();
        int z = p.getLocation().getBlockZ();
        World w = p.getWorld();
        Location loc = new Location(w, x, y, z);
        loc.getBlock().setType(Material.CHEST);
        Chest c = (Chest) loc.getBlock().getState();
        c.getBlockInventory().setContents(p.getInventory().getArmorContents());
        c.getBlockInventory().setContents(p.getInventory().getContents());
    }
}
项目:ProjectAres    文件:DeathTracker.java   
/**
 * Must run after {@link tc.oc.pgm.spawns.SpawnMatchModule#onVanillaDeath}
 */
@EventHandler(priority = EventPriority.NORMAL)
public void onPlayerDeath(PlayerDeathEvent event) {
    logger.fine("Wrapping " + event);
    MatchPlayer victim = match.getParticipant(event.getEntity());
    if(victim == null || victim.isDead()) return;

    DamageInfo info = getLastDamage(victim);
    if(info == null) info = new GenericDamageInfo(EntityDamageEvent.DamageCause.CUSTOM);

    match.callEvent(new MatchPlayerDeathEvent(event, victim, info, CombatLogTracker.isCombatLog(event)));
}
项目:KingdomFactions    文件:PlayerDeathEventListener.java   
@EventHandler
public void onDeath(PlayerDeathEvent e) {


    KingdomFactionsPlayer player = PlayerModule.getInstance().getPlayer(e.getEntity());


    e.setKeepInventory(false);

     if(player.getKingdom().getType().equals(KingdomType.GEEN)) {
           player.getInventory().clear();
           player.getInventory().addItem(Item.getInstance().getItem(Material.COMPASS, ChatColor.RED + "Selecteer jouw kingdom", 1));
           player.updateInventory();
           player.teleport(player.getKingdom().getSpawn());
       }

    if (e.getEntity().getKiller() != null) {
        KingdomFactionsPlayer killer = PlayerModule.getInstance().getPlayer(e.getEntity().getKiller());
            e.setDeathMessage(getName(player) + " is verwond door " + getName(killer) + "!");
            if(player.getCombatTracker().isInCombat()) {
                player.getCombatTracker().clearCombat();
            }
             Bukkit.getScheduler().runTaskLater(KingdomFactionsPlugin.getInstance(), new Runnable() {
            @Override
            public void run() {
                if(!player.hasPermission("kingdomfactions.deathban.ignore")) {
                    if(Setting.USE_DEATHBAN.isEnabled()) {
                    DeathBanModule.getInstance().ban(player);
                    }
                }

            }
        }, 40L);

    } else {
        e.setDeathMessage(null);
    }
//  e.getEntity().spigot().respawn();
}
项目:NavyCraft2-Lite    文件:NavyCraft_PlayerListener.java   
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerDeath(PlayerDeathEvent event) {
    String deathMsg = event.getDeathMessage();

    String[] msgWords = deathMsg.split("\\s");
    if (msgWords.length == 5) {
        if (msgWords[1].equalsIgnoreCase("was") && msgWords[3].equalsIgnoreCase("by")) {
            Player p = plugin.getServer().getPlayer(msgWords[4]);
            if ((p != null) && PermissionInterface.CheckEnabledWorld(p.getLocation())) {
                int newExp = 100;

                plugin.getServer().broadcastMessage(ChatColor.GREEN + p.getName() + " receives " + ChatColor.YELLOW
                        + newExp + ChatColor.GREEN + " rank points!");

                syp = (Shipyard)plugin.getServer().getPluginManager().getPlugin("NavyCraft-Shipyard");
                if( syp != null ) {
                    syp.rewardExpPlayer(newExp, p);
                    syp.checkRankWorld(p, newExp, p.getWorld());
                    syp.saveExperience();
                }
            }
        }
    }

    if (!NavyCraft.playerKits.isEmpty() && NavyCraft.playerKits.contains(event.getEntity().getName())) {
        NavyCraft.playerKits.remove(event.getEntity().getName());
    }
}
项目:NavyCraft2-Lite    文件:MoveCraft_PlayerListener.java   
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerDeath(PlayerDeathEvent event) {
    String deathMsg = event.getDeathMessage();

    String[] msgWords = deathMsg.split("\\s");
    if (msgWords.length == 5) {
        if (msgWords[1].equalsIgnoreCase("was") && msgWords[3].equalsIgnoreCase("by")) {
            Player p = plugin.getServer().getPlayer(msgWords[4]);
            if ((p != null) && PermissionInterface.CheckEnabledWorld(p.getLocation())) {
                int newExp = 100;

                plugin.getServer().broadcastMessage(ChatColor.GREEN + p.getName() + " receives " + ChatColor.YELLOW
                        + newExp + ChatColor.GREEN + " rank points!");

                syp = (Shipyard)plugin.getServer().getPluginManager().getPlugin("NavyCraft-Shipyard");
                if( syp != null ) {
                    syp.rewardExpPlayer(newExp, p);
                    syp.checkRankWorld(p, newExp, p.getWorld());
                    syp.saveExperience();
                }
            }
        }
    }

    if (!NavyCraft.playerKits.isEmpty() && NavyCraft.playerKits.contains(event.getEntity().getName())) {
        NavyCraft.playerKits.remove(event.getEntity().getName());
    }
}
项目:ZorahPractice    文件:PlayerListener.java   
@EventHandler
public void onDeath(PlayerDeathEvent event) {
    event.setDeathMessage(null);

    for (ItemStack i : event.getDrops()) {
        i.setType(Material.AIR);
    }
}
项目:MockBukkit    文件:PlayerMockTest.java   
@Test
public void damage_ExactlyHealth_ZeroAndDeathEvent()
{
    player.damage(player.getHealth());
    assertEquals(0, player.getHealth(), 0);
    server.getPluginManager().assertEventFired(EntityDamageEvent.class);
    server.getPluginManager().assertEventFired(PlayerDeathEvent.class);
}
项目:NineSlots    文件:ClickListener.java   
@EventHandler
public void on(PlayerDeathEvent event) {
    event.getDrops().removeIf(item -> {
        if (item == null) {
            return false;
        }

        if (!item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) {
            return false;
        }

        return item.getItemMeta().getDisplayName().equals("§4§lBlocked Slot");
    });
}
项目:SurvivalAPI    文件:GameListener.java   
/**
 * Handle player death
 *
 * @param event Event
 */
@EventHandler
public void onPlayerDeath(PlayerDeathEvent event)
{
    if (this.game.hasPlayer(event.getEntity()) && !this.game.isSpectator(event.getEntity()))
    {
        try
        {
            this.game.stumpPlayer(event.getEntity().getUniqueId(), false, false);
        }
        catch (GameException e)
        {
            this.game.getPlugin().getLogger().log(Level.SEVERE, "Error stumping player", e);
        }

        event.getDrops().add(new ItemStack(Material.GOLDEN_APPLE));
        event.setDeathMessage("");

        if (event.getEntity().getKiller() != null)
            event.getEntity().getKiller().addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 20 * 20, 1));

        new DeadCorpses(event.getEntity()).spawn(event.getEntity().getLocation());

        if (deathSound)
            GameUtils.broadcastSound(Sound.WITHER_SPAWN);
    }
}
项目:SurvivalAPI    文件:ZombiesModule.java   
/**
 * When a player is dead, spawn a zombie
 *
 * @param event Event
 */
@EventHandler
public void onEntityDeath(PlayerDeathEvent event)
{
    Zombie zombie = (Zombie)event.getEntity().getWorld().spawnEntity(event.getEntity().getLocation(), EntityType.ZOMBIE);
    zombie.setCustomNameVisible(true);
    zombie.setCustomName(event.getEntity().getCustomName());

    event.getEntity().getActivePotionEffects().forEach(zombie::addPotionEffect);
}