Java Code Examples for org.bukkit.event.entity.EntityDeathEvent#getEntityType()
The following examples show how to use
org.bukkit.event.entity.EntityDeathEvent#getEntityType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DragonRushListener.java From UhcCore with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onEntityDeath(EntityDeathEvent e){ if (e.getEntityType() != EntityType.ENDER_DRAGON){ return; } if (e.getEntity().getKiller() == null) { return; } Player killer = e.getEntity().getKiller(); UhcPlayer uhcKiller = getPlayersManager().getUhcPlayer(killer); List<UhcPlayer> spectators = new ArrayList<>(); for (UhcPlayer playingPlayer : getPlayersManager().getAllPlayingPlayers()){ if (!playingPlayer.isInTeamWith(uhcKiller)){ spectators.add(playingPlayer); } } for (UhcPlayer spectator : spectators){ spectator.setState(PlayerState.DEAD); try { Player all = spectator.getPlayer(); all.setGameMode(GameMode.SPECTATOR); all.teleport(killer); }catch (UhcPlayerNotOnlineException exeption){ // Nothing } } getPlayersManager().checkIfRemainingPlayers(); }
Example 2
Source File: CutCleanListener.java From UhcCore with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onEntityDeath(EntityDeathEvent e) { for(int i=0 ; i<e.getDrops().size() ; i++){ UniversalMaterial replaceBy = null; UniversalMaterial type = UniversalMaterial.ofType(e.getDrops().get(i).getType()); if (type != null) { switch (type) { case RAW_BEEF: replaceBy = UniversalMaterial.COOKED_BEEF; break; case RAW_CHICKEN: replaceBy = UniversalMaterial.COOKED_CHICKEN; break; case RAW_MUTTON: replaceBy = UniversalMaterial.COOKED_MUTTON; break; case RAW_RABBIT: replaceBy = UniversalMaterial.COOKED_RABBIT; break; case RAW_PORK: replaceBy = UniversalMaterial.COOKED_PORKCHOP; break; default: break; } } if(replaceBy != null){ ItemStack cookedFood = e.getDrops().get(i).clone(); cookedFood.setType(replaceBy.getType()); e.getDrops().set(i, cookedFood); } } if (e.getEntityType() == EntityType.COW) { e.getDrops().add(new ItemStack(Material.LEATHER)); } }
Example 3
Source File: EggsScenarioListener.java From UhcCore with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onEntityDeath(EntityDeathEvent e){ if (e.getEntityType() != EntityType.CHICKEN){ return; } int i = RandomUtils.randomInteger(0, 99); if (i < 5){ e.getDrops().add(new ItemStack(Material.EGG)); } }
Example 4
Source File: EntityDeathListener.java From UhcCore with GNU General Public License v3.0 | 5 votes |
private void handleMobLoot(EntityDeathEvent event){ EntityType entity = event.getEntityType(); if(mobLoots.containsKey(entity)){ MobLootConfiguration lootConfig = mobLoots.get(entity); event.getDrops().clear(); event.getDrops().add(lootConfig.getLoot().clone()); event.setDroppedExp(lootConfig.getAddXp()); UhcItems.spawnExtraXp(event.getEntity().getLocation(),lootConfig.getAddXp()); } }
Example 5
Source File: EntityDeathListener.java From UhcCore with GNU General Public License v3.0 | 5 votes |
private void handleOfflineZombieDeath(EntityDeathEvent event){ if (event.getEntityType() != EntityType.ZOMBIE){ return; } Zombie zombie = (Zombie) event.getEntity(); GameManager gm = GameManager.getGameManager(); if (zombie.getCustomName() == null){ return; } UhcPlayer uhcPlayer = null; for (UhcPlayer player : gm.getPlayersManager().getPlayersList()){ if (player.getOfflineZombie() != null && player.getOfflineZombie().equals(zombie)){ // found player uhcPlayer = player; break; } } if (uhcPlayer == null){ return; } event.getDrops().clear(); uhcPlayer.setOfflineZombie(null); gm.getPlayersManager().killOfflineUhcPlayer(uhcPlayer, zombie.getLocation(), new HashSet<>(uhcPlayer.getStoredItems()), zombie.getKiller()); }
Example 6
Source File: PowerUps.java From HolographicDisplays with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onEntityDeath(EntityDeathEvent event) { if (event.getEntityType() == EntityType.ZOMBIE) { // Remove normal drops and exp. event.getDrops().clear(); event.setDroppedExp(0); // Spawn the floating item with a label. final Hologram hologram = HologramsAPI.createHologram(this, event.getEntity().getLocation().add(0.0, 0.9, 0.0)); hologram.appendTextLine(ChatColor.AQUA + "" + ChatColor.BOLD + "Speed PowerUp"); ItemLine icon = hologram.appendItemLine(new ItemStack(Material.SUGAR)); icon.setPickupHandler(new PickupHandler() { @Override public void onPickup(Player player) { // Play an effect. player.playEffect(hologram.getLocation(), Effect.MOBSPAWNER_FLAMES, null); // 30 seconds of speed II. player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 30 * 20, 1), true); // Delete the hologram. hologram.delete(); } }); } }
Example 7
Source File: BonusXpListener.java From MarriageMaster with GNU General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEntityDeath(EntityDeathEvent event) { if(event.getEntityType() != EntityType.PLAYER) { Player killer = event.getEntity().getKiller(); if(killer != null) { calculator.process(event, killer, event.getDroppedExp(), null); } } }