本文整理汇总了Java中org.bukkit.event.player.PlayerDropItemEvent.getItemDrop方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerDropItemEvent.getItemDrop方法的具体用法?Java PlayerDropItemEvent.getItemDrop怎么用?Java PlayerDropItemEvent.getItemDrop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerDropItemEvent
的用法示例。
在下文中一共展示了PlayerDropItemEvent.getItemDrop方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerDropItem
import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event) {
if(this.ignoreNextDropEvent) {
this.ignoreNextDropEvent = false;
} else {
// If the ignore flag is clear, this drop was caused by something other than
// an inventory click (e.g. drop key, death, etc), so an event has not yet been fired
int initialQuantity = event.getItemDrop().getItemStack().getAmount();
ItemStack stack = event.getItemDrop().getItemStack();
PlayerItemTransferEvent transferEvent = new PlayerItemTransferEvent(event, ItemTransferEvent.Type.DROP, event.getPlayer(),
Optional.of(new InventorySlot(event.getPlayer().getInventory())),
Optional.empty(),
stack, event.getItemDrop(), initialQuantity,
event.getPlayer().getOpenInventory().getCursor());
this.callEvent(transferEvent);
if(!transferEvent.isCancelled() && transferEvent.getQuantity() < initialQuantity) {
int diff = initialQuantity - transferEvent.getQuantity();
stack.setAmount(stack.getAmount() - diff);
stack = stack.clone();
stack.setAmount(diff);
event.getPlayer().getInventory().addItem(stack);
}
}
}
示例2: onItemDrop
import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onItemDrop(PlayerDropItemEvent event)
{
System.out.println("Item drop");
Item item = event.getItemDrop();
ItemStack stack = item.getItemStack();
Location location = item.getLocation();
Player player = event.getPlayer();
String playerName = player == null ? "null" : player.getName();
DropItemObsel obsel = new DropItemObsel(
new Date().getTime(),
stack.getType().toString(),
stack.getAmount(),
stack.getData().getData(),
location.getBlockX(),
location.getBlockY(),
location.getBlockZ(),
location.getWorld().getName(),
playerName);
JSONObselManager.getInstance().addObsel(obsel);
}
示例3: StopDrops
import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
public void StopDrops(PlayerDropItemEvent event)
{
Player player = event.getPlayer();
Item item = event.getItemDrop();
if(item != null)
{
ItemStack stack = item.getItemStack();
if(stack != null)
{
if(KitUtils.isSoulbound(stack))
{
player.playSound(player.getLocation(), Sound.BLAZE_HIT, 1.0F, 0.3F);
event.getItemDrop().remove();
}
}
}
}
示例4: onPlayerDropItem
import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerDropItem(PlayerDropItemEvent event)
{
Item dropped = event.getItemDrop();
GunPlayer gp = plugin.getGunPlayer(event.getPlayer());
ItemStack lastHold = gp.getLastHeldItem();
if (lastHold != null)
{
Gun gun = gp.getGun(dropped.getItemStack());
if (gun != null)
{
if (lastHold.getType() == dropped.getItemStack().getType())
{
if (gun.isHasClip() && gun.isChanged() && gun.isReloadGunOnDrop())
{
gun.reloadGun();
event.setCancelled(true);
}
}
}
}
}
示例5: onPlayerDropItem
import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerDropItem(PlayerDropItemEvent event) {
try {
ExchangeRule[] rules = ExchangeRule.parseBulkRuleBlock(event.getItemDrop().getItemStack());
Item drop = event.getItemDrop();
for(ExchangeRule rule : rules) {
ItemStack item = rule.toItemStack();
Item ruleDrop = drop.getWorld().dropItem(drop.getLocation(), item);
ruleDrop.setVelocity(drop.getVelocity());
}
drop.remove();
}
catch (ExchangeRuleParseException e) {
}
}
示例6: handleItemDrop
import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void handleItemDrop(final PlayerDropItemEvent event) {
ParticipantState player = PGM.getMatchManager().getParticipantState(event.getPlayer());
if(player == null) return;
Competitor team = player.getParty();
Item itemDrop = event.getItemDrop();
ItemStack item = itemDrop.getItemStack();
if (this.isDestroyableWool(item, team)) {
this.droppedWools.put(itemDrop, player.getPlayerId());
}
}
示例7: onItemDrop
import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onItemDrop(PlayerDropItemEvent e) {
Item item = e.getItemDrop();
Bukkit.getScheduler().scheduleSyncDelayedTask(hcf, new Runnable() {
public void run() {
item.remove();
}
}, 20L * 60L * 3L);
}
示例8: onPlayerDropItemEvent
import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerDropItemEvent(PlayerDropItemEvent event) {
User user = API.to(event.getPlayer());
if (user == null) return;
Item entity = event.getItemDrop();
ItemStack item = entity.getItemStack().clone();
UItem object = UItemManager.getInstance().getItem(item);
if (object == null) return;
UItemEvent result = object.call(new UItemEventDrop(user, object, item));
if (result.isCancelled()) event.setCancelled(true);
item = result.getItem();
if (item == null) entity.remove();
else entity.setItemStack(item.clone());
}
示例9: onPlayerDropItem
import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
/**
* Monitor PlayerDropItemEvents.
* <p>
* These events are monitored for the purpose of flagging sharable
* dropped items, as well as removing ability buffs from pickaxes
* and shovels.
*
* @param event The event to monitor
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerDropItem(PlayerDropItemEvent event) {
Item drop = event.getItemDrop();
ItemStack dropStack = drop.getItemStack();
if (ItemUtils.isSharable(dropStack)) {
drop.setMetadata(mcMMO.droppedItemKey, mcMMO.metadataValue);
}
SkillUtils.removeAbilityBuff(dropStack);
}
示例10: onPlayerDropItem
import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDropItem(PlayerDropItemEvent e) {
if (e.getItemDrop() != null && MarketManager.isMarketItem(e.getItemDrop().getItemStack())) {
e.getItemDrop().setItemStack(new ItemStack(Material.AIR));
}
}