本文整理汇总了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);
}
}
}
}
示例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);
}
}
}
}
}
}
示例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());
}
示例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);
}
示例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("&", "§"));
}
示例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;
}
}
}
}
示例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);
}
}
示例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();
}
}
示例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;
}
}
示例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;
}
}
示例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());
}
}
示例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;
}
}
示例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;
}
}
示例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;
}
}
示例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());
}