本文整理汇总了Java中org.bukkit.event.player.PlayerPickupItemEvent.isCancelled方法的典型用法代码示例。如果您正苦于以下问题:Java PlayerPickupItemEvent.isCancelled方法的具体用法?Java PlayerPickupItemEvent.isCancelled怎么用?Java PlayerPickupItemEvent.isCancelled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.event.player.PlayerPickupItemEvent
的用法示例。
在下文中一共展示了PlayerPickupItemEvent.isCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onItemPickup
import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onItemPickup(PlayerPickupItemEvent e) {
if (e.isCancelled()) {
return;
}
ItemStack item = e.getItem().getItemStack();
if (item.getType().equals(Material.WRITTEN_BOOK)) {
BookMeta meta = (BookMeta) item.getItemMeta();
if (meta.getTitle().equals("Quest Log")) {
e.getItem().remove();
e.setCancelled(true);
QuestManagerPlugin.questManagerPlugin.getPlayerManager().getPlayer(
e.getPlayer().getUniqueId()).addQuestBook();
}
}
}
示例2: onInventoryChange
import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryChange(PlayerPickupItemEvent e) {
if (this.participants == null) {
return;
}
if (state) {
return;
}
if (!e.isCancelled() && e.getItem().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);
}
}
}
}
示例3: d
import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
@Override
public void d(final EntityHuman entityhuman) {
if (!this.world.isClientSide && this.inGround && (this.shake <= 0)) {
boolean pickup = (this.fromPlayer == 1) || ((this.fromPlayer == 2) && entityhuman.abilities.canInstantlyBuild);
ItemStack itemstack = this.getItemStack();
if ((this.fromPlayer == 1) && !entityhuman.inventory.pickup(itemstack)) {
pickup = false;
}
final EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
final PlayerPickupItemEvent event = new PlayerPickupItemEvent((Player) entityhuman.getBukkitEntity(), new CraftItem(this.world.getServer(), this, item), 0);
this.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
if (pickup) {
this.makeSound("random.pop", 0.2F, (((this.random.nextFloat() - this.random.nextFloat()) * 0.7F) + 1.0F) * 2.0F);
entityhuman.receive(this, 1);
this.die();
}
}
}
示例4: onPlayerPickupItem
import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
if (!event.isCancelled()) {
ItemStack item1 = event.getItem().getItemStack();
if (materials.contains(item1.getType()) && event.getPlayer().getInventory().contains(item1.getType())) {
for (ItemStack item2 : event.getPlayer().getInventory().getContents()) {
if (item2 != null && Items.toMaxDurability(item1).equals(Items.toMaxDurability(item2))) {
event.setCancelled(true);
event.getItem().remove();
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 0.1F, 1);
int result = item2.getDurability() - (item1.getType().getMaxDurability() - item1.getDurability());
item2.setDurability((short) (result < 0 ? 0 : result));
break;
}
}
}
}
}
示例5: onItemPickup
import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.MONITOR)
public void onItemPickup(PlayerPickupItemEvent event) {
if (event.getItem().hasMetadata(RMetadata.META_NO_PICKUP)) {
event.setCancelled(true);
return;
}
if (event.getRemaining() == 0 && !event.isCancelled())
removeLabel(event.getItem());
}
示例6: onPlayerPickupItem
import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
// When this event is fired, the ItemStack in the Item being picked up is temporarily
// set to the amount that will actually be picked up, while the difference from the
// actual amount in the stack is available from getRemaining(). When the event returns,
// the original amount is restored to the stack, meaning that we can't change the amount
// from inside the event, so instead we replace the entire stack.
int initialQuantity = event.getItem().getItemStack().getAmount();
PlayerItemTransferEvent transferEvent = new PlayerItemTransferEvent(
event, ItemTransferEvent.Type.PICKUP, event.getPlayer(),
Optional.empty(),
Optional.of(new InventorySlot<>(event.getPlayer().getInventory())),
event.getItem().getItemStack(), event.getItem(),
initialQuantity, event.getPlayer().getOpenInventory().getCursor()
);
this.callEvent(transferEvent);
int quantity = Math.min(transferEvent.getQuantity(), initialQuantity);
if(!event.isCancelled() && quantity < initialQuantity) {
event.setCancelled(true);
if(quantity > 0) {
ItemStack stack = event.getItem().getItemStack().clone();
stack.setAmount(stack.getAmount() - quantity);
event.getItem().setItemStack(stack);
stack = stack.clone();
stack.setAmount(quantity);
event.getPlayer().getInventory().addItem(stack);
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ENTITY_ITEM_PICKUP, 1, 1);
}
}
}
示例7: onItemPickUp
import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onItemPickUp(PlayerPickupItemEvent e) {
if (e.isCancelled()) {
return;
}
Item item = e.getItem();
ItemStack is = item.getItemStack();
if (isMoneyItem(is)) {
e.setCancelled(true);
BigDecimal money = new BigDecimal(Double.valueOf(ChatColor.stripColor(is.getItemMeta().getLore().get(0))
.replaceAll("[^0-9.]", "")))
.setScale(DefaultConfig.getDecimalPlaces(), BigDecimal.ROUND_HALF_EVEN);
EntityType entityType = EntityType.valueOf(is.getItemMeta().getLore().get(1));
EntityProperties ep = EntityManager.getEntityProperties(entityType);
if (ep == null) {
return;
}
UUID uuid = UUID.fromString(is.getItemMeta().getLore().get(2));
if (!DefaultConfig.isMoneyItemAnyonePickUp() && !uuid.equals(e.getPlayer().getUniqueId())) {
return;
}
WorldProperties wp = EntityManager.getWorldProperties(ep, e.getItem().getLocation().getWorld().getName());
if (wp != null) {
item.remove();
Bukkit.getPluginManager().callEvent(new KMEarnMoneyPickedUpEvent(wp.getMoneyProperties(),
e.getPlayer(), money));
}
}
}
示例8: onInventoryChange
import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onInventoryChange(PlayerPickupItemEvent e) {
if (this.participants == null) {
return;
}
if (!e.isCancelled() && e.getItem().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.getItem().getItemStack().getAmount();
e.getPlayer().getInventory().addItem(e.getItem().getItemStack());
update();
int pos = e.getPlayer().getInventory().first(itemType);
ItemStack item = e.getPlayer().getInventory().getItem(pos);
item.setAmount(item.getAmount() - count);
if (e.getItem().getItemStack().hasItemMeta()) {
item.setItemMeta(e.getItem().getItemStack().getItemMeta());
}
e.getPlayer().getInventory().setItem(pos, item);
return;
}
}
}
}
示例9: onPlayerPickupItem
import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
if (!event.isCancelled()) {
ItemStack item1 = event.getItem().getItemStack();
if (materials.contains(item1.getType())) {
if (event.getPlayer().getInventory().contains(item1.getType())) {
ItemStack toRepair = null;
boolean itemsMatch = false;
for (ItemStack item2 : event.getPlayer().getInventory().getContents()) {
if (item2 != null) {
if (item1.getType() == item2.getType()) {
if (item1.getEnchantments() != null && item2.getEnchantments() != null) {
if (item1.getEnchantments().equals(item2.getEnchantments())) {
itemsMatch = true;
}
} else {
if (item1.getEnchantments() == null && item2.getEnchantments() == null) {
itemsMatch = true;
}
}
if (itemsMatch) {
toRepair = item2;
}
}
}
}
if (itemsMatch) {
event.setCancelled(true);
event.getItem().remove();
event.getPlayer().playSound(event.getPlayer().getLocation(), Sound.ITEM_PICKUP, 0.1F, 1);
toRepair.setDurability((short) (toRepair.getDurability() - (item1.getType().getMaxDurability() - item1.getDurability()) < 0 ? 0 : toRepair.getDurability() - (item1.getType().getMaxDurability() - item1.getDurability())));
}
}
}
}
}
示例10: b_
import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
public void b_(EntityHuman entityhuman) {
if (!this.world.isStatic && this.inGround && this.shake <= 0) {
// CraftBukkit start
ItemStack itemstack = new ItemStack(Items.ARROW);
if (this.fromPlayer == 1 && entityhuman.inventory.canHold(itemstack) > 0) {
EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
PlayerPickupItemEvent event = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), this, item), 0);
// event.setCancelled(!entityhuman.canPickUpLoot); TODO
this.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
}
// CraftBukkit end
boolean flag = this.fromPlayer == 1 || this.fromPlayer == 2 && entityhuman.abilities.canInstantlyBuild;
if (this.fromPlayer == 1 && !entityhuman.inventory.pickup(new ItemStack(Items.ARROW, 1))) {
flag = false;
}
if (flag) {
this.makeSound("random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
entityhuman.receive(this, 1);
this.die();
}
}
}
示例11: onPlayerPickupItem
import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onPlayerPickupItem(PlayerPickupItemEvent e) {
plugin.tm.cancelSpectator(e);
if (!e.isCancelled()) {
plugin.gm.checkTarget(e);
}
}
示例12: onPickupEvent
import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGHEST)
public void onPickupEvent(PlayerPickupItemEvent event) {
Player player = event.getPlayer();
if (event.isCancelled() || !plugin.isSkyWorld(player.getWorld())) {
clearDropInfo(event.getItem());
return;
}
if (wasDroppedBy(player, event) || hasPermission(player, "usb.mod.bypassprotection") || plugin.playerIsOnIsland(player) || plugin.playerIsInSpawn(player)) {
clearDropInfo(event.getItem());
return; // Allowed
}
// You are on another's island, and the stuff dropped weren't yours.
event.setCancelled(true);
plugin.notifyPlayer(player, tr("You cannot pick up other players' loot when you are a visitor!"));
}
示例13: b_
import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
public void b_(EntityHuman entityhuman) {
if (!this.world.isStatic && this.inGround && this.shake <= 0) {
// CraftBukkit start
ItemStack itemstack = new ItemStack(Item.ARROW);
if (this.fromPlayer == 1 && entityhuman.inventory.canHold(itemstack) > 0) {
EntityItem item = new EntityItem(this.world, this.locX, this.locY, this.locZ, itemstack);
PlayerPickupItemEvent event = new PlayerPickupItemEvent((org.bukkit.entity.Player) entityhuman.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.world.getServer(), this, item), 0);
// event.setCancelled(!entityhuman.canPickUpLoot); TODO
this.world.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return;
}
}
// CraftBukkit end
boolean flag = this.fromPlayer == 1 || this.fromPlayer == 2 && entityhuman.abilities.canInstantlyBuild;
if (this.fromPlayer == 1 && !entityhuman.inventory.pickup(new ItemStack(Item.ARROW, 1))) {
flag = false;
}
if (flag) {
this.makeSound("random.pop", 0.2F, ((this.random.nextFloat() - this.random.nextFloat()) * 0.7F + 1.0F) * 2.0F);
entityhuman.receive(this, 1);
this.die();
}
}
}
示例14: onPlayerPickupItem
import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
@EventHandler
public void onPlayerPickupItem(PlayerPickupItemEvent event) {
if (event.isCancelled()) return;
Player player = event.getPlayer();
if (this.manager.isRoutePlayer(player)) {
event.setCancelled(true);
}
}
示例15: onCollideWithPlayer
import org.bukkit.event.player.PlayerPickupItemEvent; //导入方法依赖的package包/类
public void onCollideWithPlayer(EntityPlayer p_70100_1_)
{
if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0)
{
// CraftBukkit start
ItemStack itemstack = new ItemStack(Items.arrow);
if (this.canBePickedUp == 1 && p_70100_1_.inventory.canHold(itemstack) > 0)
{
EntityItem item = new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, itemstack);
PlayerPickupItemEvent event = new PlayerPickupItemEvent((org.bukkit.entity.Player) p_70100_1_.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.worldObj.getServer(), this, item), 0);
// event.setCancelled(!entityplayer.canPickUpLoot); TODO
this.worldObj.getServer().getPluginManager().callEvent(event);
if (event.isCancelled())
{
return;
}
}
// CraftBukkit end
boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && p_70100_1_.capabilities.isCreativeMode;
if (this.canBePickedUp == 1 && !p_70100_1_.inventory.addItemStackToInventory(new ItemStack(Items.arrow, 1)))
{
flag = false;
}
if (flag)
{
this.playSound("random.pop", 0.2F, ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.0F) * 2.0F);
p_70100_1_.onItemPickup(this, 1);
this.setDead();
}
}
}