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


Java PlayerDropItemEvent.isCancelled方法代码示例

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


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

示例1: onInventoryChange

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryChange(PlayerDropItemEvent e) {
	if (this.participants == null) {
		return;
	}
	if (state) {
		return;
	}
	if (!e.isCancelled() && e.getItemDrop().getItemStack().getType() == itemType) {
		
		for (QuestPlayer qp : participants.getParticipants()) {
			if (qp.getPlayer().getUniqueId().equals(e.getPlayer().getUniqueId())) {
				final Requirement req = this;
				Bukkit.getScheduler().runTaskLater(QuestManagerPlugin.questManagerPlugin, req::update, 1);
			}
		
		}
	}
}
 
开发者ID:Dove-Bren,项目名称:QuestManager,代码行数:20,代码来源:DeliverRequirement.java

示例2: onPlayerDropItem

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDropItem(PlayerDropItemEvent event) {
    if (!event.isCancelled() && TeamUtils.getTeamByPlayer(event.getPlayer()) != null && event.getItemDrop().getItemStack().getType().equals(Material.WOOL)) {
        for (TeamModule team : TeamUtils.getTeams()) {
            if (!team.isObserver() && TeamUtils.getTeamByPlayer(event.getPlayer()) != team) {
                for (GameObjective obj : TeamUtils.getShownObjectives(team)) {
                    if (obj instanceof WoolObjective && event.getItemDrop().getItemStack().getData().getData() == ((WoolObjective) obj).getColor().getData()) {
                        if (!items.containsKey(event.getPlayer())) {
                            items.put(event.getPlayer(), new ArrayList<Item>());
                        }
                        List<Item> list = items.get(event.getPlayer());
                        list.add(event.getItemDrop());
                        items.put(event.getPlayer(), list);
                    }
                }
            }
        }
    }
}
 
开发者ID:dentmaged,项目名称:Cardinal-Plus,代码行数:20,代码来源:Snowflakes.java

示例3: onDropEvent

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onDropEvent(PlayerDropItemEvent event) {
    if (event.isCancelled() || event.getPlayer() == null) {
        return;
    }
    Player player = event.getPlayer();
    if (!plugin.isSkyWorld(player.getWorld())) {
        return;
    }
    if (!visitorsCanDrop && !plugin.playerIsOnIsland(player) && !plugin.playerIsInSpawn(player)) {
        event.setCancelled(true);
        plugin.notifyPlayer(player, tr("\u00a7eVisitors can't drop items!"));
        return;
    }
    addDropInfo(player, event.getItemDrop().getItemStack());
}
 
开发者ID:rlf,项目名称:uSkyBlock,代码行数:17,代码来源:ItemDropEvents.java

示例4: onDrop

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onDrop(PlayerDropItemEvent e) {
    if (e.isCancelled()) {
        return;
    }
    if (!Utils.isInArena(e.getPlayer())) {
        return;
    }
    e.setCancelled(true);
}
 
开发者ID:Soldier233,项目名称:ArchersBattle,代码行数:11,代码来源:InventoryListener.java

示例5: onDrop

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onDrop(PlayerDropItemEvent e) {
	if (e.isCancelled()) {
		return;
	}
	Player p = e.getPlayer();
	if (!p.getOpenInventory().getTitle().contains(ConfigManager.getInstance().getBackpackTitle())) {
		return;
	}
	e.setCancelled(true);
	p.sendMessage(Messages.getMessages().getNoDrop().replace("&", "§"));
}
 
开发者ID:Soldier233,项目名称:SlimefunBugFixer,代码行数:13,代码来源:Listeners.java

示例6: onInventoryChange

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryChange(PlayerDropItemEvent e) {
	if (this.participants == null) {
		return;
	}
	if (!e.isCancelled() && e.getItemDrop().getItemStack().getType() == itemType) {
		
		for (QuestPlayer qp : participants.getParticipants()) {
			if (qp.getPlayer().getUniqueId().equals(e.getPlayer().getUniqueId())) {
				//adjust for that stupid 'hasn't happened yet' error
				int count = e.getItemDrop().getItemStack().getAmount();
				e.getPlayer().getInventory().addItem(e.getItemDrop().getItemStack());
				update();
				
				int pos = e.getPlayer().getInventory().first(itemType);
				ItemStack item = e.getPlayer().getInventory().getItem(pos);
				item.setAmount(item.getAmount() - count);
				if (e.getItemDrop().getItemStack().hasItemMeta()) {
					item.setItemMeta(e.getItemDrop().getItemStack().getItemMeta());
				}
				e.getPlayer().getInventory().setItem(pos, item);
				
				return;
			}
		}
		
	}
}
 
开发者ID:Dove-Bren,项目名称:QuestManager,代码行数:29,代码来源:PossessRequirement.java

示例7: OnPlayerDropItem

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void OnPlayerDropItem(PlayerDropItemEvent event) {
	if (event.isCancelled()) {
		return;
	}
	ItemStack stack = event.getItemDrop().getItemStack();

	if (LoreMaterial.isCustom(stack)) {
		LoreMaterial.getMaterial(stack).onItemDrop(event);
	}
}
 
开发者ID:netizen539,项目名称:civcraft,代码行数:12,代码来源:CustomItemManager.java

示例8: onItemDrop

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler(priority=EventPriority.HIGHEST)
public void onItemDrop(PlayerDropItemEvent event) {
	if (event.isCancelled()) {
		return;
	}
	if (event.getPlayer().getGameMode() == GameMode.CREATIVE) {
		return;
	}
	String playerID = PlayerConverter.getID((Player) event.getPlayer());
	if (playerID == null) {
		return;
	}
	ItemStack item = event.getItemDrop().getItemStack();
	if (item == null) {
		return;
	}
	try {
		// if journal is dropped, remove it so noone else can pick it up
		if (Journal.isJournal(playerID, item)) {
			event.getItemDrop().remove();
		} else if (Utils.isQuestItem(item)) {
			BetonQuest.getInstance().getPlayerData(playerID).addItem(item.clone(), item.getAmount());
			event.getItemDrop().remove();
		}
	} catch (Exception e) {
		// if there is any problem with checking the item, prevent dropping it
		// it will be frustrating for user but at least they won't duplicate items
		event.setCancelled(true);
		e.printStackTrace();
	}
}
 
开发者ID:Co0sh,项目名称:BetonQuest,代码行数:32,代码来源:QuestItemHandler.java

示例9: a

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
public EntityItem a(ItemStack itemstack, boolean flag, boolean flag1) {
    if (itemstack == null) {
        return null;
    } else if (itemstack.count == 0) {
        return null;
    } else {
        EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.getHeadHeight(), this.locZ, itemstack);

        entityitem.pickupDelay = 40;
        if (flag1) {
            entityitem.b(this.getName());
        }

        float f = 0.1F;
        float f1;

        if (flag) {
            f1 = this.random.nextFloat() * 0.5F;
            float f2 = this.random.nextFloat() * 3.1415927F * 2.0F;

            entityitem.motX = (double) (-MathHelper.sin(f2) * f1);
            entityitem.motZ = (double) (MathHelper.cos(f2) * f1);
            entityitem.motY = 0.20000000298023224D;
        } else {
            f = 0.3F;
            entityitem.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
            entityitem.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
            entityitem.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f + 0.1F);
            f = 0.02F;
            f1 = this.random.nextFloat() * 3.1415927F * 2.0F;
            f *= this.random.nextFloat();
            entityitem.motX += Math.cos((double) f1) * (double) f;
            entityitem.motY += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
            entityitem.motZ += Math.sin((double) f1) * (double) f;
        }

        // CraftBukkit start - fire PlayerDropItemEvent
        Player player = (Player) this.getBukkitEntity();
        CraftItem drop = new CraftItem(this.world.getServer(), entityitem);

        PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand();
            if (flag1 && (cur == null || cur.getAmount() == 0)) {
                // The complete stack was dropped
                player.getInventory().setItemInHand(drop.getItemStack());
            } else if (flag1 && cur.isSimilar(drop.getItemStack()) && drop.getItemStack().getAmount() == 1) {
                // Only one item is dropped
                cur.setAmount(cur.getAmount() + 1);
                player.getInventory().setItemInHand(cur);
            } else {
                // Fallback
                player.getInventory().addItem(drop.getItemStack());
            }
            return null;
        }
        // CraftBukkit end

        this.a(entityitem);
        this.a(StatisticList.s, 1);
        return entityitem;
    }
}
 
开发者ID:OvercastNetwork,项目名称:CraftBukkit,代码行数:66,代码来源:EntityHuman.java

示例10: a

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
public EntityItem a(ItemStack itemstack, boolean flag) {
    if (itemstack == null) {
        return null;
    } else if (itemstack.count == 0) {
        return null;
    } else {
        EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.getHeadHeight(), this.locZ, itemstack);

        entityitem.pickupDelay = 40;
        float f = 0.1F;
        float f1;

        if (flag) {
            f1 = this.random.nextFloat() * 0.5F;
            float f2 = this.random.nextFloat() * 3.1415927F * 2.0F;

            entityitem.motX = (double) (-MathHelper.sin(f2) * f1);
            entityitem.motZ = (double) (MathHelper.cos(f2) * f1);
            entityitem.motY = 0.20000000298023224D;
        } else {
            f = 0.3F;
            entityitem.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
            entityitem.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
            entityitem.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f + 0.1F);
            f = 0.02F;
            f1 = this.random.nextFloat() * 3.1415927F * 2.0F;
            f *= this.random.nextFloat();
            entityitem.motX += Math.cos((double) f1) * (double) f;
            entityitem.motY += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
            entityitem.motZ += Math.sin((double) f1) * (double) f;
        }

        // CraftBukkit start
        Player player = (Player) this.getBukkitEntity();
        CraftItem drop = new CraftItem(this.world.getServer(), entityitem);

        PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            player.getInventory().addItem(drop.getItemStack());
            return null;
        }
        // CraftBukkit end

        this.a(entityitem);
        this.a(StatisticList.v, 1);
        return entityitem;
    }
}
 
开发者ID:AlmuraDev,项目名称:Almura-Server,代码行数:51,代码来源:EntityHuman.java

示例11: onItemDrop

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onItemDrop(PlayerDropItemEvent event) {
	if(!event.isCancelled()) {
		logChunk(event.getItemDrop().getLocation());
	}
}
 
开发者ID:maker56,项目名称:UltimateSurvivalGames,代码行数:7,代码来源:ResetListener.java

示例12: func_146097_a

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
public EntityItem func_146097_a(ItemStack p_146097_1_, boolean p_146097_2_, boolean p_146097_3_)
{
    if (p_146097_1_ == null)
    {
        return null;
    }
    else if (p_146097_1_.stackSize == 0)
    {
        return null;
    }
    else
    {
        EntityItem entityitem = new EntityItem(this.worldObj, this.posX, this.posY - 0.30000001192092896D + (double)this.getEyeHeight(), this.posZ, p_146097_1_);
        entityitem.delayBeforeCanPickup = 40;

        if (p_146097_3_)
        {
            entityitem.func_145799_b(this.getCommandSenderName());
        }

        float f = 0.1F;
        float f1;

        if (p_146097_2_)
        {
            f1 = this.rand.nextFloat() * 0.5F;
            float f2 = this.rand.nextFloat() * (float)Math.PI * 2.0F;
            entityitem.motionX = (double)(-MathHelper.sin(f2) * f1);
            entityitem.motionZ = (double)(MathHelper.cos(f2) * f1);
            entityitem.motionY = 0.20000000298023224D;
        }
        else
        {
            f = 0.3F;
            entityitem.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
            entityitem.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f);
            entityitem.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI) * f + 0.1F);
            f = 0.02F;
            f1 = this.rand.nextFloat() * (float)Math.PI * 2.0F;
            f *= this.rand.nextFloat();
            entityitem.motionX += Math.cos((double)f1) * (double)f;
            entityitem.motionY += (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.1F);
            entityitem.motionZ += Math.sin((double)f1) * (double)f;
        }

        // CraftBukkit start
        Player player = (Player) this.getBukkitEntity();
        CraftItem drop = new CraftItem(this.worldObj.getServer(), entityitem);
        PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
        this.worldObj.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled())
        {
            player.getInventory().addItem(drop.getItemStack());
            return null;
        }

        // CraftBukkit end
        this.joinEntityItemWithWorld(entityitem);
        this.addStat(StatList.dropStat, 1);
        return entityitem;
    }
}
 
开发者ID:xtrafrancyz,项目名称:Cauldron,代码行数:64,代码来源:EntityPlayer.java

示例13: a

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@Nullable
public EntityItem a(@Nullable ItemStack itemstack, boolean flag, boolean flag1) {
    if (itemstack == null) {
        return null;
    } else if (itemstack.count == 0) {
        return null;
    } else {
        double d0 = this.locY - 0.30000001192092896D + (double) this.getHeadHeight();
        EntityItem entityitem = new EntityItem(this.world, this.locX, d0, this.locZ, itemstack);

        entityitem.a(40);
        if (flag1) {
            entityitem.e(this.getName());
        }

        float f;
        float f1;

        if (flag) {
            f = this.random.nextFloat() * 0.5F;
            f1 = this.random.nextFloat() * 6.2831855F;
            entityitem.motX = (double) (-MathHelper.sin(f1) * f);
            entityitem.motZ = (double) (MathHelper.cos(f1) * f);
            entityitem.motY = 0.20000000298023224D;
        } else {
            f = 0.3F;
            entityitem.motX = (double) (-MathHelper.sin(this.yaw * 0.017453292F) * MathHelper.cos(this.pitch * 0.017453292F) * f);
            entityitem.motZ = (double) (MathHelper.cos(this.yaw * 0.017453292F) * MathHelper.cos(this.pitch * 0.017453292F) * f);
            entityitem.motY = (double) (-MathHelper.sin(this.pitch * 0.017453292F) * f + 0.1F);
            f1 = this.random.nextFloat() * 6.2831855F;
            f = 0.02F * this.random.nextFloat();
            entityitem.motX += Math.cos((double) f1) * (double) f;
            entityitem.motY += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
            entityitem.motZ += Math.sin((double) f1) * (double) f;
        }

        // CraftBukkit start - fire PlayerDropItemEvent
        Player player = (Player) this.getBukkitEntity();
        CraftItem drop = new CraftItem(this.world.getServer(), entityitem);

        PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            org.bukkit.inventory.ItemStack cur = player.getInventory().getItemInHand();
            if (flag1 && (cur == null || cur.getAmount() == 0)) {
                // The complete stack was dropped
                player.getInventory().setItemInHand(drop.getItemStack());
            } else if (flag1 && cur.isSimilar(drop.getItemStack()) && drop.getItemStack().getAmount() == 1) {
                // Only one item is dropped
                cur.setAmount(cur.getAmount() + 1);
                player.getInventory().setItemInHand(cur);
            } else {
                // Fallback
                player.getInventory().addItem(drop.getItemStack());
            }
            return null;
        }
        // CraftBukkit end

        ItemStack itemstack1 = this.a(entityitem);

        if (flag1) {
            if (itemstack1 != null) {
                this.a(StatisticList.e(itemstack1.getItem()), itemstack.count);
            }

            this.b(StatisticList.x);
        }

        return entityitem;
    }
}
 
开发者ID:bergerkiller,项目名称:SpigotSource,代码行数:74,代码来源:EntityHuman.java

示例14: a

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
public EntityItem a(ItemStack itemstack, boolean flag) {
    if (itemstack == null) {
        return null;
    } else {
        EntityItem entityitem = new EntityItem(this.world, this.locX, this.locY - 0.30000001192092896D + (double) this.getHeadHeight(), this.locZ, itemstack);

        entityitem.pickupDelay = 40;
        float f = 0.1F;
        float f1;

        if (flag) {
            f1 = this.random.nextFloat() * 0.5F;
            float f2 = this.random.nextFloat() * 3.1415927F * 2.0F;

            entityitem.motX = (double) (-MathHelper.sin(f2) * f1);
            entityitem.motZ = (double) (MathHelper.cos(f2) * f1);
            entityitem.motY = 0.20000000298023224D;
        } else {
            f = 0.3F;
            entityitem.motX = (double) (-MathHelper.sin(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
            entityitem.motZ = (double) (MathHelper.cos(this.yaw / 180.0F * 3.1415927F) * MathHelper.cos(this.pitch / 180.0F * 3.1415927F) * f);
            entityitem.motY = (double) (-MathHelper.sin(this.pitch / 180.0F * 3.1415927F) * f + 0.1F);
            f = 0.02F;
            f1 = this.random.nextFloat() * 3.1415927F * 2.0F;
            f *= this.random.nextFloat();
            entityitem.motX += Math.cos((double) f1) * (double) f;
            entityitem.motY += (double) ((this.random.nextFloat() - this.random.nextFloat()) * 0.1F);
            entityitem.motZ += Math.sin((double) f1) * (double) f;
        }

        // CraftBukkit start
        Player player = (Player) this.getBukkitEntity();
        CraftItem drop = new CraftItem(this.world.getServer(), entityitem);

        PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
        this.world.getServer().getPluginManager().callEvent(event);

        if (event.isCancelled()) {
            player.getInventory().addItem(drop.getItemStack());
            return null;
        }
        // CraftBukkit end

        this.a(entityitem);
        this.a(StatisticList.v, 1);
        return entityitem;
    }
}
 
开发者ID:didoupimpon,项目名称:Craft-city,代码行数:49,代码来源:EntityHuman.java

示例15: onPlayerDropItem

import org.bukkit.event.player.PlayerDropItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerDropItem(PlayerDropItemEvent event) {
  if (!event.isCancelled() && event.getPlayer() != null)
    tgym.afkTimer
        .put(event.getPlayer().getName(), System.currentTimeMillis());
}
 
开发者ID:Vild,项目名称:TimeGivesYouMoney,代码行数:7,代码来源:PlayerListener.java


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