本文整理汇总了Java中org.bukkit.event.entity.PlayerDeathEvent.getDrops方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerDeathEvent.getDrops方法的具体用法?Java PlayerDeathEvent.getDrops怎么用?Java PlayerDeathEvent.getDrops使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.entity.PlayerDeathEvent
的用法示例。
在下文中一共展示了PlayerDeathEvent.getDrops方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onPlayerDeath(PlayerDeathEvent event) {
Player player = event.getEntity();
World world = player.getWorld();
Location location = player.getLocation();
Collection<ItemStack> drops = event.getDrops();
if (!drops.isEmpty()) {
Iterator<ItemStack> iterator = drops.iterator();
// Drop the items manually so we can add meta to prevent
// PVP Protected players from collecting them.
long stamp = System.currentTimeMillis() + +ITEM_PICKUP_DELAY;
while (iterator.hasNext()) {
itemUUIDPickupDelays.put(world.dropItemNaturally(location, iterator.next()).getUniqueId(), stamp);
iterator.remove();
}
}
clearCooldown(player);
}
示例2: deathDrop
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void deathDrop(PlayerDeathEvent e) {
World w = e.getEntity().getWorld();
Location l = e.getEntity().getLocation();
EntityItem ei;
NBTTagCompound nbt;
NBTTagShort nbts = new NBTTagShort(itemAge);
for (ItemStack d : e.getDrops()) {
ei = ((EntityItem)((CraftItem)w.dropItemNaturally(l, d)).getHandle());
nbt = new NBTTagCompound();
ei.b(nbt);
nbt.set("Age", nbts);
ei.a(nbt);
}
e.getDrops().clear();
}
示例3: onPlayerDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerDeath(PlayerDeathEvent event) {
if (!InventoryManager.playerIsLoaded(event.getEntity())) {
return;
}
List<ItemStack> drops = event.getDrops();
for (int i = 0; i < drops.size(); i++) {
ItemStack drop = drops.get(i);
if (drop != null && (InventoryLocker.isLockedSlot(drop) || InventoryManager.isEmptySlot(drop))) {
event.getDrops().set(i, new ItemStack(Material.AIR));
}
}
}
示例4: onDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler
public void onDeath(PlayerDeathEvent event) {
event.setDeathMessage(null);
for (ItemStack i : event.getDrops()) {
i.setType(Material.AIR);
}
}
示例5: onDeath
import org.bukkit.event.entity.PlayerDeathEvent; //导入方法依赖的package包/类
@EventHandler (priority = EventPriority.HIGH)
public void onDeath(PlayerDeathEvent e){
final Player player = e.getEntity();
final Location loc = player.getLocation();
final GamePlayer target = SkyWarsReloaded.getPC().getPlayer(player.getUniqueId());
Entity ent = e.getEntity();
Location spawn = SkyWarsReloaded.getCfg().getSpawn();
if (spawn != null) {
String world = spawn.getWorld().getName();
if(player.getLocation().getWorld().getName().equalsIgnoreCase(world)) {
List<ItemStack> drops = e.getDrops();
ListIterator<ItemStack> litr = drops.listIterator();
while(litr.hasNext()){
ItemStack item = litr.next();
if ((item.getData().getItemType().equals(SkyWarsReloaded.getCfg().getKitMenuItem().getData().getItemType()) && item.getEnchantments().keySet().equals(SkyWarsReloaded.getCfg().getKitMenuItem().getEnchantments().keySet()))) {
litr.remove();
} else if ((item.getData().getItemType().equals(SkyWarsReloaded.getCfg().getExitGameItem().getData().getItemType()) && item.getEnchantments().keySet().equals(SkyWarsReloaded.getCfg().getExitGameItem().getEnchantments().keySet()))) {
litr.remove();
} else if ((item.getData().getItemType().equals(SkyWarsReloaded.getCfg().getSpectateItem().getData().getItemType()) && item.getEnchantments().keySet().equals(SkyWarsReloaded.getCfg().getSpectateItem().getEnchantments().keySet()))) {
litr.remove();
} else if ((item.getData().getItemType().equals(SkyWarsReloaded.getCfg().getJoinItem().getData().getItemType()) && item.getEnchantments().keySet().equals(SkyWarsReloaded.getCfg().getJoinItem().getEnchantments().keySet()))) {
litr.remove();
} else if ((item.getData().getItemType().equals(SkyWarsReloaded.getCfg().getOptionsItem().getData().getItemType()) && item.getEnchantments().keySet().equals(SkyWarsReloaded.getCfg().getOptionsItem().getEnchantments().keySet()))) {
litr.remove();
} else if ((item.getData().getItemType().equals(SkyWarsReloaded.getCfg().getLobbyMenuItem().getData().getItemType()) && item.getEnchantments().keySet().equals(SkyWarsReloaded.getCfg().getLobbyMenuItem().getEnchantments().keySet()))) {
litr.remove();
}
}
}
}
DamageCause damageCause = DamageCause.CUSTOM;
if (ent.getLastDamageCause() != null) {
damageCause = ent.getLastDamageCause().getCause();
}
final DamageCause dCause = damageCause;
if (target.inGame()) {
e.setDeathMessage("");
Game game = target.getGame();
if (game.getState() == GameState.PLAYING) {
target.getGame().onPlayerDeath(target, dCause, loc);
}
}
}