当前位置: 首页>>代码示例>>Java>>正文


Java CraftEventFactory.callPlayerDeathEvent方法代码示例

本文整理汇总了Java中org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerDeathEvent方法的典型用法代码示例。如果您正苦于以下问题:Java CraftEventFactory.callPlayerDeathEvent方法的具体用法?Java CraftEventFactory.callPlayerDeathEvent怎么用?Java CraftEventFactory.callPlayerDeathEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.craftbukkit.event.CraftEventFactory的用法示例。


在下文中一共展示了CraftEventFactory.callPlayerDeathEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: die

import org.bukkit.craftbukkit.event.CraftEventFactory; //导入方法依赖的package包/类
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]));
            }
        }
    }

    ChatMessage chatmessage = this.aR().b();

    String deathmessage = chatmessage.toString();
    org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage);

    String deathMessage = event.getDeathMessage();

    if (deathMessage != null && deathMessage.length() > 0) {
        if (deathMessage.equals(chatmessage.toString())) {
            this.server.getPlayerList().sendMessage(chatmessage);
        } else {
            this.server.getPlayerList().sendMessage(ChatMessage.d(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();
    // CraftBukkit end

    // CraftBukkit - Get our scores instead
    Collection<ScoreboardScore> collection = this.world.getServer().getScoreboardManager().getScoreboardScores(IScoreboardCriteria.c, this.getLocalizedName(), new java.util.ArrayList<ScoreboardScore>());
    Iterator iterator = collection.iterator();

    while (iterator.hasNext()) {
        ScoreboardScore scoreboardscore = (ScoreboardScore) iterator.next(); // CraftBukkit - Use our scores instead

        scoreboardscore.incrementScore();
    }

    EntityLiving entityliving = this.aS();

    if (entityliving != null) {
        entityliving.b(this, this.bb);
    }

    this.a(StatisticList.y, 1);
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:71,代码来源:EntityPlayer.java


注:本文中的org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerDeathEvent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。