Examples of PlayerDeathEvent


Examples of org.bukkit.event.entity.PlayerDeathEvent

        EntityDamageEvent lastDamage = entity.getBukkitEntity().getLastDamageCause();
        if (lastDamage != null && lastDamage instanceof EntityDamageByEntityEvent) {
            context.put("damager", new dEntity(((EntityDamageByEntityEvent) lastDamage).getDamager()));
        }

        PlayerDeathEvent subEvent = null;

        if (event instanceof PlayerDeathEvent) {
            subEvent = (PlayerDeathEvent) event;
            context.put("message", new Element(subEvent.getDeathMessage()));

            // Null check to prevent NPCs from causing an NPE
            if (player != null)
                context.put("inventory", player.getInventory());
        }

        String determination = EventManager.doEvents(Arrays.asList
                ("entity dies",
                        entity.identifyType() + " dies",
                        entity.identifySimple() + " dies",
                        entity.identifySimple() + " death",
                        "entity death",
                        entity.identifyType() + " death"),
                npc, player, context, true);

        // Handle message
        if (determination.toUpperCase().startsWith("DROPS ")) {
            determination = determination.substring(6);
        }

        if (determination.toUpperCase().startsWith("NO_DROPS")) {
            event.getDrops().clear();
            if (determination.endsWith("_OR_XP")) {
                event.setDroppedExp(0);
            }
        }

        else if (determination.toUpperCase().equals("NO_XP")) {
            event.setDroppedExp(0);
        }

        // Drops
        else if (aH.Argument.valueOf(determination).matchesArgumentList(dItem.class)) {
            dList drops = dList.valueOf(determination);
            drops.filter(dItem.class);
            event.getDrops().clear();
            for (String drop : drops) {
                dItem item = dItem.valueOf(drop);
                if (item != null)
                    event.getDrops().add(item.getItemStack());
            }

        }

        // XP
        else if (aH.Argument.valueOf(determination)
                .matchesPrimitive(aH.PrimitiveType.Integer)) {
            int xp = Integer.valueOf(determination.substring(3));
            event.setDroppedExp(xp);
        }

        else if (!determination.toUpperCase().equals("NONE")) {
            if (event instanceof PlayerDeathEvent) {
                subEvent.setDeathMessage(determination);
            }
        }
    }
View Full Code Here

Examples of org.spout.vanilla.event.player.PlayerDeathEvent

   */
  private void onDeath() {
    EntityDeathEvent event;
    Entity owner = getOwner();
    if (owner instanceof Player) {
      event = new PlayerDeathEvent((Player) owner, lastDamageCause, lastDamager);
    } else {
      event = new EntityDeathEvent(owner, lastDamageCause, lastDamager);
    }
    if (!getEngine().getEventManager().callEvent(event).isCancelled()) {
      if (!(owner instanceof Player)) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.