本文整理汇总了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);
}