本文整理汇总了Java中org.bukkit.event.entity.EntityDeathEvent.getEntity方法的典型用法代码示例。如果您正苦于以下问题:Java EntityDeathEvent.getEntity方法的具体用法?Java EntityDeathEvent.getEntity怎么用?Java EntityDeathEvent.getEntity使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.EntityDeathEvent
的用法示例。
在下文中一共展示了EntityDeathEvent.getEntity方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEndermanDeath
import org.bukkit.event.entity.EntityDeathEvent; //导入方法依赖的package包/类
/**
* Drops the Enderman's block when he dies if he has one
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEndermanDeath(final EntityDeathEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
}
if (!Settings.endermanDeathDrop)
return;
if (!Util.inWorld(e.getEntity())) {
return;
}
if (!(e.getEntity() instanceof Enderman)) {
// plugin.getLogger().info("Not an Enderman!");
return;
}
// Get the block the enderman is holding
Enderman ender = (Enderman) e.getEntity();
MaterialData m = ender.getCarriedMaterial();
if (m != null && !m.getItemType().equals(Material.AIR)) {
// Drop the item
// plugin.getLogger().info("Dropping item " + m.toString());
e.getEntity().getWorld().dropItemNaturally(e.getEntity().getLocation(), m.toItemStack(1));
}
}
示例2: onMobDie
import org.bukkit.event.entity.EntityDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void onMobDie(EntityDeathEvent e){
AllItems items = new AllItems();
Location l = e.getEntity().getLocation();
World w = l.getWorld();
e.getDrops().clear();
e.setDroppedExp(0);
if (e.getEntity() instanceof Zombie){
if (new Random().nextInt(5) >= 3){
w.dropItemNaturally(l, new ItemMaker(Material.EMERALD).setAmount(new Random().nextInt(4) + 1).build());
if (new Random().nextBoolean()){
w.dropItemNaturally(l, items.weapons.get(new Random().nextInt(items.weapons.size())));
} else {
w.dropItemNaturally(l, items.health.get(new Random().nextInt(items.health.size())));
}
}
}
if (e.getEntity() instanceof Giant){
if (new Random().nextInt(5) > 3){
w.dropItemNaturally(l, new ItemMaker(Material.NETHER_STAR).setAmount(new Random().nextInt(4) + 1).build());
}
}
}
示例3: onEntityDeath
import org.bukkit.event.entity.EntityDeathEvent; //导入方法依赖的package包/类
/**
* Utilizes a random chance to either spawn a skeleton with gold armor or resources.
*
* @param event The event
*/
@EventHandler
public void onEntityDeath(EntityDeathEvent event) {
Entity entity = event.getEntity();
if (entity instanceof Sheep) {
double chance = Math.random();
if (0.25 > chance) {
Skeleton skeleton = entity.getWorld().spawn(entity.getLocation(), Skeleton.class);
skeleton.getEquipment().setArmorContents(
new ItemStack[]{
new ItemStack(Material.GOLD_HELMET),
new ItemStack(Material.GOLD_CHESTPLATE),
new ItemStack(Material.GOLD_LEGGINGS),
new ItemStack(Material.GOLD_BOOTS)
}
);
} else if (0.5 > chance) {
event.getDrops().add(new ItemStack(Material.IRON_INGOT));
} else if (0.75 > chance) {
event.getDrops().add(new ItemStack(Material.GOLD_INGOT));
} else {
event.getDrops().add(new ItemStack(Material.DIAMOND));
}
}
}
示例4: onEntityDeath
import org.bukkit.event.entity.EntityDeathEvent; //导入方法依赖的package包/类
/**
* Drop cooked food
*
* @param event Event
*/
@EventHandler
public void onEntityDeath(EntityDeathEvent event)
{
LivingEntity entity = event.getEntity();
List<ItemStack> newDrops = null;
if (this.drops.containsKey(entity.getType()))
{
newDrops = new ArrayList<>();
for (ConfigurationBuilder.IRapidFoodHook rapidFoodHook : this.drops.get(entity.getType()))
newDrops.addAll(rapidFoodHook.getDrops(event.getDrops(), this.random));
}
if (newDrops != null && !newDrops.isEmpty())
{
event.getDrops().clear();
event.getDrops().addAll(newDrops);
}
event.setDroppedExp(event.getDroppedExp() * 2);
}
示例5: onEntityDeath
import org.bukkit.event.entity.EntityDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDeath(EntityDeathEvent evt) { // If a pinata is killed, have a 12% chance of dropping something extra.
if (evt.getEntity() instanceof Zombie && getArena().contains(evt.getEntity().getLocation()) && Utils.randChance(8))
evt.getDrops().add(Utils.randElement(
ItemManager.createItem(Material.DIAMOND, ChatColor.AQUA + "Rock Candy", "So delicious, so rare."),
ItemManager.createItem(Material.CAKE, ChatColor.LIGHT_PURPLE + "Birthday Cake", "Happy 3rd Anniversary, Kineticraft!"),
ItemManager.createItem(Material.SEA_LANTERN, ChatColor.RED + "Jaw Breaker", "Suck it, Piñatas!"),
ItemManager.createItem(Material.IRON_BLOCK, ChatColor.RED + "Hershey's Kiss", "Mmmm, so chocolatey."),
ItemManager.createItem(Material.TNT, ChatColor.LIGHT_PURPLE + "Pop Rocks", "An explosion for your taste buds."),
ItemManager.createItem(Material.MAGMA_CREAM, ChatColor.RED + "Atomic Fireball", "It burns so good."),
ItemManager.createItem(Material.EXP_BOTTLE, ChatColor.AQUA + "Soda", "Refreshing and fizzy."),
ItemManager.createItem(Material.SLIME_BALL, ChatColor.AQUA + "Taffy", "Chewy...careful not to glue your teeth together!"),
ItemManager.createItem(Material.NETHER_STALK, ChatColor.RED + "Twizzlers", "Gimme some sugar."),
ItemManager.createItem(Material.MYCEL, ChatColor.RED + "Fudge", "What the fudge!?"),
ItemManager.createItem(Material.WEB, ChatColor.LIGHT_PURPLE + "Cotton Candy", "So fluffy!"),
ItemManager.createItem(Material.RAW_FISH, (byte) 1, ChatColor.LIGHT_PURPLE + "Swedish Fish", "A yummy, gummy candy."),
ItemManager.createItem(Material.RED_ROSE, (byte) 2, ChatColor.AQUA + "Lollipop", "I'm a sucker for puns."),
ItemManager.createItem(Material.COOKIE, ChatColor.YELLOW + "Birthday Cookie", "You're one smart cookie!"),
ItemManager.createItem(Material.BLAZE_ROD, ChatColor.RED + "Hot Tamale", "You're one hot Tamale!"),
ItemManager.createItem(Material.PUMPKIN_PIE, ChatColor.GOLD + "Seasonal Treat", "Pumpkin Spice flavor ALL THE THINGS!"),
ItemManager.createItem(Material.EMERALD, ChatColor.GREEN + "Gumball", "I chews you! <3"),
ItemManager.createItem(Material.GOLDEN_APPLE, ChatColor.GOLD + "Caramel Apple", "...and we lived apple-y ever after <3"),
ItemManager.createItem(Material.HUGE_MUSHROOM_2, ChatColor.RED + "Strawberry Bon Bon", "You're the berry best."),
evt.getEntity().getEquipment().getHelmet(),
evt.getEntity().getEquipment().getItemInMainHand()));
}
示例6: onEntityDeath
import org.bukkit.event.entity.EntityDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDeath(EntityDeathEvent e) {
if (e.getEntity() instanceof Monster && e.getEntity().getKiller() instanceof Player) {
TOAUser u = TOA.getPlayer(e.getEntity().getKiller());
String name = e.getEntity().getCustomName().split(" ")[1];
int level = Utils.isInt(name) ? Integer.parseInt(name) : 0;
new Experience(u).addExp(Mob.getXP(level));
e.getDrops().clear();
e.setDroppedExp(0);
Drop.drop(MobType.parseMobType(e.getEntityType()), u.getUserData().getKit()).forEach(d -> {
BagEvents.addItem(u, d);
u.sendSound(Sounds.ITEM_PICKUP);
});
if (plugin.getSpawnTask().getCount() == 0) return;
plugin.getSpawnTask().setCount(plugin.getSpawnTask().getCount() - 1);
}
}
示例7: onMobDeath
import org.bukkit.event.entity.EntityDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void onMobDeath(EntityDeathEvent event) {
if(event.getEntity() instanceof Entity){
Entity e = (Entity) event.getEntity();
if(e.hasMetadata("challenge")){
event.getDrops().clear();
String[] meta = e.getMetadata("challenge").get(0).asString().split(", ");
final String player = meta[1];
plugin.getChallenges().addKill(Bukkit.getPlayer(player));
Bukkit.getPlayer(player).setLevel(plugin.getChallenges().getKillsLeft(Bukkit.getPlayer(player)));
if(e.getType().equals(EntityType.MAGMA_CUBE) || e.getType().equals(EntityType.SLIME)) {
e.remove();
}
if(plugin.getChallenges().getKillsLeft(Bukkit.getPlayer(player)) == 0){
plugin.getChallenges().finishChallenge(Bukkit.getPlayer(player), false);
}
}
}
}
示例8: onDragonDeath
import org.bukkit.event.entity.EntityDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void onDragonDeath(EntityDeathEvent event) {
if (!(event.getEntity() instanceof EnderDragon)) return;
EnderDragon dragon = (EnderDragon) event.getEntity();
DragonBattle dragonBattle = plugin.getNMSAbstract().getEnderDragonBattleFromDragon(dragon);
World world = event.getEntity().getWorld();
EndWorldWrapper worldWrapper = plugin.getDEDManager().getWorldWrapper(world);
BattleStateChangeEvent bscEventCrystals = new BattleStateChangeEvent(dragonBattle, dragon, BattleState.BATTLE_COMMENCED, BattleState.BATTLE_END);
Bukkit.getPluginManager().callEvent(bscEventCrystals);
new BukkitRunnable() {
@Override
public void run() {
if (plugin.getNMSAbstract().getEnderDragonDeathAnimationTime(dragon) >= 185) { // Dragon is dead at 200
new DragonDeathRunnable(plugin, worldWrapper, dragon);
this.cancel();
}
}
}.runTaskTimer(plugin, 0L, 1L);
}
示例9: kill
import org.bukkit.event.entity.EntityDeathEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void kill(EntityDeathEvent e) {
// 殺されたエンティティ
LivingEntity entity = e.getEntity();
// エンティティを殺したプレイヤー
Player player = entity.getKiller();
// null=プレイヤーが殺したのではないなら
if (player == null) {
return; // 何もしない
}
// 出力する
player.sendMessage("このMOBはスポナーから沸いたMOB" +
(isSpawnerSpawn(entity) ? "です。" : "ではありません。")); // <-三項演算子、説明は要らないよね?
}
示例10: onEntityDeath
import org.bukkit.event.entity.EntityDeathEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onEntityDeath(EntityDeathEvent event) {
Entity killedEntity = event.getEntity();
if (killedEntity instanceof LivingEntity) {
LivingEntity livingEntity = (LivingEntity)killedEntity;
Player killer = livingEntity.getKiller();
if (killer != null && getPlayer() == killer) {
if (entityIds.contains(EntityUtilities.getEntityId(livingEntity)) &&
(getZone() == null || getZone().isInside(livingEntity.getLocation()))) {
advance();
}
}
}
}
示例11: onEntityDeath
import org.bukkit.event.entity.EntityDeathEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onEntityDeath(EntityDeathEvent event) {
if (_scenario.isActive() && _currentWave != null) {
Entity entity = event.getEntity();
if (entity instanceof Player) {
try {
_scenario.getPlayers().remove((Player)entity);
if (_scenario.getEventListener() != null) {
_scenario.getEventListener().playerDied((Player)entity, _scenario.getPlayers());
}
}
catch (Exception ex) { }
}
else {
_currentWave.processEntityDeath(entity);
}
}
}
示例12: monsterDies
import org.bukkit.event.entity.EntityDeathEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void monsterDies(EntityDeathEvent event) {
if (_apocalypseOn && event.getEntity().getLastDamageCause().getCause() != DamageCause.FIRE_TICK) {
if (event.getEntity() instanceof Monster) {
_monsterDead++;
}
if (_monsterDead >= _maxMonsters) {
_completed = true;
distributeLoot();
resetEvent();
}
try {
_spawner.spawnMonsterCloseToPlayer(event.getEntity().getLocation());
}
catch (Exception ex) {
_logger.info("exception raised in Mayhem.monsterDies(EntityDeathEvent event) while using the ApocalypseSpawner");
}
}
}
示例13: onEntityDeath
import org.bukkit.event.entity.EntityDeathEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onEntityDeath(EntityDeathEvent event) {
Entity entity = event.getEntity();
World world = entity.getWorld();
PluginConfig worldConfig = plugin.getConfig(world);
if (entity instanceof Creature && plugin.isActive(world) && plugin.isFeatureEnabled(world, Feature.SPAWN_ON_KILL)) {
Creature creature = (Creature) entity;
EntityDamageEvent lastDamage = entity.getLastDamageCause();
if (lastDamage != null && creature.getTarget() instanceof Player && playerCauses.contains(lastDamage.getCause()) && worldConfig.getStringList(Config.FEATURE_SPAWN_ON_KILL_MOBS).contains(creature.getType().name().toUpperCase())) {
if (this.random.nextInt(100) < worldConfig.getInt(Config.FEATURE_SPAWN_ON_KILL_CHANCE)) {
String mobName = ListUtils.getRandom(worldConfig.getStringList(Config.FEATURE_SPAWN_ON_KILL_SPAWN));
EntityType creatureType = EntityType.fromName(mobName.toUpperCase());
if (creatureType != null) {
world.spawnEntity(creature.getLocation(), creatureType);
//world.spawn(creature.getLocation(), creatureType.getEntityClass(), SpawnReason.NATURAL);
}
}
}
}
}
示例14: onEntityDeath
import org.bukkit.event.entity.EntityDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void onEntityDeath(EntityDeathEvent e) {
Player killer = e.getEntity().getKiller();
if ((e.getEntity() instanceof Player)) {
Player playerKilled = (Player) e.getEntity();
incrementStatistic(Statistic.PLAYERS_KILLED);
incrementPlayerStat(playerKilled, PlayerStat.DEATHS);
if (killer instanceof Player) {
incrementPlayerStat(killer, PlayerStat.PLAYERS_KILLED);
}
} else {
incrementStatistic(Statistic.MOBS_KILLED);
if (killer instanceof Player) {
incrementPlayerStat(killer, PlayerStat.MOBS_KILLED);
}
}
}
示例15: on
import org.bukkit.event.entity.EntityDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void on(EntityDeathEvent event) {
if (!(event.getEntity() instanceof Spider)) return;
Entity entity = ((CraftEntity) event.getEntity()).getHandle();
// spawn 5 random webs
for (int i = 0; i < 5; i++) {
spawnRandomWeb(entity);
}
// spawn 30 random particle effects
for (int i = 0; i < 30; i++) {
spawnRandomRedstoneParticle(entity);
}
}