@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerPickupItem(final PlayerPickupItemEvent event) {
this.plugin.entering(this.getClass(), "onPlayerPickupItem");
final Item i = event.getItem();
if (this.itemMap.containsKey(i)) {
this.plugin.debug("Item is handled by an Altar");
final String playerName = event.getPlayer().getName();
final String awaitedPlayerName = this.itemMap.get(i);
if (!playerName.equals(awaitedPlayerName)) {
if (this.plugin.isDebugEnabled()) {
this.plugin.debug("Not the right player (" + playerName + "), cancel pickup. Awaited '" + awaitedPlayerName + '\'');
}
event.setCancelled(true);
} else {
this.plugin.debug("Right player, allow pickup");
this.itemMap.remove(i);
final Altar altar = this.plugin.getAltars().get(new ChunkCoord(i.getLocation().getChunk()));
if (altar != null) {
this.plugin.getItemProvidedToLockedTransition().doTransition(altar);
}
}
}
this.plugin.exiting(this.getClass(), "onPlayerPickupItem");
}
ItemListener.java 文件源码
java
阅读 28
收藏 0
点赞 0
评论 0
项目:NPlugins
作者:
评论列表
文章目录