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


Java DropItemEvent类代码示例

本文整理汇总了Java中org.spongepowered.api.event.item.inventory.DropItemEvent的典型用法代码示例。如果您正苦于以下问题:Java DropItemEvent类的具体用法?Java DropItemEvent怎么用?Java DropItemEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onItemDrop

import org.spongepowered.api.event.item.inventory.DropItemEvent; //导入依赖的package包/类
@Listener
public void onItemDrop(DropItemEvent.Dispense event, @Root Player player) {

    PermHandler ph = PermHandler.getInstance();
    
    event.filterEntities(entity -> {
        if (entity.getType().equals(EntityTypes.ITEM)) {
            Item item = (Item) entity;
            ItemType itemType = item.getItemType();
            String itemId = itemType.getId();
            if (!ph.checkPerm(player, "protectionperms.item.drop." + itemId + ".dispense")) {
                player.sendMessage(ChatTypes.ACTION_BAR, Text.of(TextColors.RED, "You don't have permission to drop " + itemType.getName() + '!'));
                return false;
            }
        }
        return true;
    });
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:19,代码来源:DropItemDispenseListener.java

示例2: fireDropItemEvent

import org.spongepowered.api.event.item.inventory.DropItemEvent; //导入依赖的package包/类
private void fireDropItemEvent(World world, Vector3i pos) {
    List<ItemStack> stacks = getDroppedItems();
    if (stacks.isEmpty()) {
        return;
    }
    List<Entity> entities = Lists.newArrayList();
    for (ItemStack stack : stacks) {
        Entity drop = createItemDrop(world, pos, stack);
        entities.add(drop);
    }
    Cause cause = Cause.source(BlockSpawnCause.builder()
            .type(SpawnTypes.DROPPED_ITEM)
            .block(world.createSnapshot(pos))
            .build())
            .build();
    DropItemEvent.Destruct harvestEvent = SpongeEventFactory.createDropItemEventDestruct(cause, entities);
    if (Sponge.getEventManager().post(harvestEvent)) {
        return;
    }
    for (Entity entity : harvestEvent.getEntities()) {
        world.spawnEntity(entity, cause);
    }
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:24,代码来源:PipeBlock.java

示例3: onEntityDropItemDeath

import org.spongepowered.api.event.item.inventory.DropItemEvent; //导入依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onEntityDropItemDeath(DropItemEvent.Destruct event, @Root Living livingEntity) {
    if (!GPFlags.ITEM_DROP || event.getEntities().isEmpty()) {
        return;
    }

    final World world = event.getEntities().get(0).getWorld();
    if (!GriefPreventionPlugin.instance.claimsEnabledForWorld(world.getProperties())) {
        return;
    }

    GPTimings.ENTITY_DROP_ITEM_DEATH_EVENT.startTimingIfSync();
    // special rule for creative worlds: killed entities don't drop items or experience orbs
    if (GriefPreventionPlugin.instance.claimModeIsActive(livingEntity.getLocation().getExtent().getProperties(), ClaimsMode.Creative)) {
        event.setCancelled(true);
        GPTimings.ENTITY_DROP_ITEM_DEATH_EVENT.stopTimingIfSync();
        return;
    }

    GPTimings.ENTITY_DROP_ITEM_DEATH_EVENT.stopTimingIfSync();
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:22,代码来源:EntityEventHandler.java

示例4: onDropItem

import org.spongepowered.api.event.item.inventory.DropItemEvent; //导入依赖的package包/类
@Listener
public void onDropItem(DropItemEvent.Dispense event, @Root Player player)
{
	if (!player.hasPermission("essentialcmds.blacklist.bypass"))
	{
		event.filterEntities(e -> {
			if (e.get(RepresentedItemData.class).isPresent())
			{
				RepresentedItemData itemData = e.get(RepresentedItemData.class).get();
				boolean blacklisted = Utils.getBlacklistItems().contains(itemData.item().get().getType().getId());

				if (blacklisted)
				{
					if (Utils.areBlacklistMsgsEnabled())
						player.sendMessage(Text.of(TextColors.RED, "The item ", TextColors.GRAY, itemData.item().get().getType().getId(), TextColors.RED, " has been confiscated as it is blacklisted."));
				}

				return !blacklisted;
			}
			return false;
		});
	}
}
 
开发者ID:hsyyid,项目名称:EssentialCmds,代码行数:24,代码来源:BlacklistListener.java

示例5: onItemDrop

import org.spongepowered.api.event.item.inventory.DropItemEvent; //导入依赖的package包/类
@Listener
public void onItemDrop(DropItemEvent.Destruct event, @Named(NamedCause.SOURCE) BlockSpawnCause spawnCause) {
  BlockSnapshot blockSnapshot = spawnCause.getBlockSnapshot();

  Optional<Location<World>> optLocation = blockSnapshot.getLocation();
  if (!optLocation.isPresent()) {
    return;
  }

  Location<World> loc = optLocation.get();
  if (!markedOrePoints.remove(loc)) {
    return;
  }

  event.getEntities().clear();
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:17,代码来源:BuildWorldWrapper.java

示例6: onItemDrop

import org.spongepowered.api.event.item.inventory.DropItemEvent; //导入依赖的package包/类
@Listener
public void onItemDrop(DropItemEvent.Destruct event, @Named(NamedCause.SOURCE) BlockSpawnCause spawnCause) {
  if (event.getCause().containsType(Player.class)) {
    return;
  }

  BlockSnapshot blockSnapshot = spawnCause.getBlockSnapshot();

  Optional<Location<World>> optLocation = blockSnapshot.getLocation();
  if (!optLocation.isPresent()) {
    return;
  }

  Location<World> location = optLocation.get();
  while (true) {
    location = location.add(0, -1, 0);
    if (location.getBlockType() != BlockTypes.CACTUS) {
      break;
    }
    location.setBlockType(BlockTypes.AIR, Cause.source(SkreePlugin.container()).build());
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:23,代码来源:AntiCactusFarmListener.java

示例7: onDropItem

import org.spongepowered.api.event.item.inventory.DropItemEvent; //导入依赖的package包/类
@Listener
public void onDropItem(DropItemEvent.Dispense event) {
  event.getEntities().stream().filter(entity -> entity instanceof Item).forEach(entity -> {
    ItemStack stack = ((EntityItem) entity).getEntityItem();
    if (isZoneSlaveItem(stack)) {
      Optional<Player> optPlayer = event.getCause().first(Player.class);
      if (optPlayer.isPresent()) {
        Player player = optPlayer.get();
        if (!notifyGroupOwner(stack, player, false)) {
          // TODO Log this, as it shouldn't happen
        }
        player.sendMessage(
            Text.of(TextColors.RED, "You've declined your group invite.")
        );
      }
      entity.remove();
    }
  });
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:20,代码来源:ZoneSlaveOrb.java

示例8: onEntityDrop

import org.spongepowered.api.event.item.inventory.DropItemEvent; //导入依赖的package包/类
@Listener
public void onEntityDrop(DropItemEvent.Destruct event, @Named(NamedCause.SOURCE) EntitySpawnCause spawnCause) {
  Entity entity = spawnCause.getEntity();
  if (!(entity instanceof Animal)) {
    return;
  }

  Optional<TheButcherShopInstance> optInst = manager.getApplicableZone(entity);
  if (!optInst.isPresent()) {
    return;
  }

  event.getEntities().clear();

  Item item = (Item) entity.getLocation().createEntity(EntityTypes.ITEM);
  item.offer(Keys.REPRESENTED_ITEM, newItemStack("skree:unpackaged_meat").createSnapshot());

  event.getEntities().add(item);
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:20,代码来源:TheButcherShopListener.java

示例9: onDrop

import org.spongepowered.api.event.item.inventory.DropItemEvent; //导入依赖的package包/类
@Listener
public void onDrop(DropItemEvent.Dispense event, @Root EntitySpawnCause cause) {
    if (cause.getEntity() instanceof Player) {
        //TODO exempt check
    }

    ModuleConfig config = Modules.BLACKLIST.get().getConfig().get();
    CommentedConfigurationNode hnode = config.get();
    for (Entity en : event.getEntities()) {
        if (!(en instanceof Item)) continue;
        Item item = (Item) en;
        CommentedConfigurationNode node = hnode.getNode("items", item.getItemType().getId());
        if (!node.isVirtual()) {
            if (node.getNode("deny-drop").getBoolean()) {
                event.setCancelled(true);
            }
        }
    }
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:20,代码来源:ItemListener.java

示例10: onDropItem

import org.spongepowered.api.event.item.inventory.DropItemEvent; //导入依赖的package包/类
@Listener
public void onDropItem(DropItemEvent event, @Root @Has(ViewerData.class) Player player) {
    Optional<String> camId = player.get(VigilateKeys.CAMERA);

    if(camId.isPresent() && Vigilate.getInstance().getCameras().containsKey(camId.get())){
        Vigilate.getInstance().getCameras().get(camId.get()).endViewCamera(player);
    } else {
        Camera.resetPlayer(player);
    }

    event.setCancelled(true);
}
 
开发者ID:Lergin,项目名称:Vigilate,代码行数:13,代码来源:DropListener.java

示例11: onDropItem

import org.spongepowered.api.event.item.inventory.DropItemEvent; //导入依赖的package包/类
@Listener
public void onDropItem(final DropItemEvent.Dispense event, @First Player player) {
    if (player.hasPermission("safeguard.mod")) {
        return;
    }

    if (!SafeGuard.getZoneManager().allows(player, flag, player.getLocation())) {
        player.sendMessage(Format.error("Sorry, this zone doesn't allow you to do that."));
        event.setCancelled(true);
    }
}
 
开发者ID:prism,项目名称:SafeGuard,代码行数:12,代码来源:DropItemListener.java

示例12: onDropItem

import org.spongepowered.api.event.item.inventory.DropItemEvent; //导入依赖的package包/类
@Listener
public void onDropItem(DropItemEvent.Destruct event) {
    java.util.Optional<Player> player = event.getCause().first(Player.class);
    if (player.isPresent() && event.getCause().root() instanceof BlockSpawnCause) {
        Optional<Challenger> challenger = Main.getMinigame().getChallenger(player.get().getUniqueId());
        if (challenger.isPresent()) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:caseif,项目名称:InfernoSpleef,代码行数:11,代码来源:BlockListener.java

示例13: onItemDropDeath

import org.spongepowered.api.event.item.inventory.DropItemEvent; //导入依赖的package包/类
@Listener
public void onItemDropDeath(DropItemEvent.Destruct event, @Root Player player) {

    PermHandler ph = PermHandler.getInstance();
        
        event.filterEntities(entity -> {
            if (entity.getType().equals(EntityTypes.ITEM)) {
                Item item = (Item) entity;
                String itemId = item.getItemType().getId();
                return ph.checkPerm(player, "protectionperms.item.drop." + itemId + ".death");
            }
            return true;
        });
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:15,代码来源:DropItemDeathListener.java

示例14: onDropItem

import org.spongepowered.api.event.item.inventory.DropItemEvent; //导入依赖的package包/类
@Listener
public void onDropItem(DropItemEvent event) {
	Optional<Player> clicker = event.getCause().first(Player.class);
	if (!clicker.isPresent()) return;
	if (!VillagerShops.openShops.containsKey(clicker.get().getUniqueId())) return;
	event.setCancelled(true);
}
 
开发者ID:DosMike,项目名称:VillagerShops,代码行数:8,代码来源:EventListeners.java

示例15: onBlockDropItems

import org.spongepowered.api.event.item.inventory.DropItemEvent; //导入依赖的package包/类
@Listener
public void onBlockDropItems(DropItemEvent.Destruct event, @Root BlockSpawnCause blockCause) {
    if (blockCause.getType() != SpawnTypes.DROPPED_ITEM) {
        return;
    }
    BlockSnapshot blockSnapshot = blockCause.getBlockSnapshot();
    CustomWorld world = WorldManager.toCustomWorld(blockSnapshot.getLocation().get().getExtent());
    Vector3i pos = blockSnapshot.getPosition();
    BlockNature block = world.getBlock(pos);
    if (block == null) {
        return;
    }
    boolean allowDrop = block.onBlockHarvest(world, pos, event.getEntities());
    event.setCancelled(!allowDrop);
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:16,代码来源:CustomBlockEventListeners.java


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