• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java EntitySpawnCause类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: onEntitySpawn

import org.spongepowered.api.event.cause.entity.spawn.EntitySpawnCause; //导入依赖的package包/类
@Listener(order=Order.FIRST, beforeModifications = true)
public void onEntitySpawn(SpawnEntityEvent event, @First Player player, @First EntitySpawnCause entitySpawnCause)
{
	if (!ConfigHandler.getNode("worlds").getNode(event.getTargetWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	if (player.hasPermission("nations.admin.bypass.perm.build"))
	{
		return;
	}
	if (entitySpawnCause.getType() == SpawnTypes.PLACEMENT)
	{
		try {
			if (!DataHandler.getPerm("build", player.getUniqueId(), event.getEntities().get(0).getLocation()))
				event.setCancelled(true);
		} catch (IndexOutOfBoundsException e) {}
	}
}
 
开发者ID:Arckenver,项目名称:Nations,代码行数:20,代码来源:BuildPermListener.java


示例2: spawnItem

import org.spongepowered.api.event.cause.entity.spawn.EntitySpawnCause; //导入依赖的package包/类
public void spawnItem(Location<World> location, ItemStackSnapshot snapshot, Object notifier) {
    World world = location.getExtent();
    Item rejectedItem = (Item) world.createEntity(EntityTypes.ITEM, location.getPosition());

    Cause cause = Cause.source(
            EntitySpawnCause.builder()
                    .entity(rejectedItem)
                    .type(SpawnTypes.PLUGIN)
                    .build()
            )
            .owner(CustomItemLibrary.getInstance().getPluginContainer())
            .notifier(notifier)
            .build();

    rejectedItem.offer(Keys.REPRESENTED_ITEM, snapshot);
    world.spawnEntity(rejectedItem, cause);
}
 
开发者ID:Limeth,项目名称:CustomItemLibrary,代码行数:18,代码来源:Util.java


示例3: onEntityDrop

import org.spongepowered.api.event.cause.entity.spawn.EntitySpawnCause; //导入依赖的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


示例4: spawn

import org.spongepowered.api.event.cause.entity.spawn.EntitySpawnCause; //导入依赖的package包/类
private Optional<Entity> spawn(EntityType entityType, Entity causeAndLocation) {
	Location<World> location = causeAndLocation.getLocation();
	EntityUniverse entityUniverse = location.getExtent();
	Optional<Entity> optionalEntity = entityUniverse.createEntity(entityType, location.getPosition());
	if (optionalEntity.isPresent()) {
		Entity newEntity = optionalEntity.get();
		Cause cause = Cause.source(EntitySpawnCause.builder().entity(causeAndLocation).type(SpawnTypes.PLUGIN).build()).build();
		boolean isSpawned = entityUniverse.spawnEntity(newEntity, cause);
		if (!isSpawned) {
			logger.error("Could not spawn new Entity: " + entityType.getName());
			return Optional.empty();
		}
		return Optional.of(newEntity);
	} else {
		logger.error("Could not create new Entity: " + entityType.getName());
		return Optional.empty();
	}
}
 
开发者ID:vorburger,项目名称:SwissKnightMinecraft,代码行数:19,代码来源:LearningPlugin.java


示例5: onDrop

import org.spongepowered.api.event.cause.entity.spawn.EntitySpawnCause; //导入依赖的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


示例6: putItemInWorld

import org.spongepowered.api.event.cause.entity.spawn.EntitySpawnCause; //导入依赖的package包/类
static public void putItemInWorld(ItemStackSnapshot itemStackSnapshop, Location<World> spawnLocation) {
	Extent extent = spawnLocation.getExtent();
	Entity item = extent.createEntity(EntityTypes.ITEM, spawnLocation.getPosition());
	item.offer(Keys.REPRESENTED_ITEM, itemStackSnapshop);
	extent.spawnEntity(item, Cause.source(EntitySpawnCause.builder()
			.entity(item).type(SpawnTypes.PLUGIN).build()).build());

}
 
开发者ID:TheoKah,项目名称:CarrotShop,代码行数:9,代码来源:Shop.java


示例7: onEntityDrop

import org.spongepowered.api.event.cause.entity.spawn.EntitySpawnCause; //导入依赖的package包/类
@Listener
public void onEntityDrop(DropItemEvent.Destruct event, @Named(NamedCause.SOURCE) EntitySpawnCause spawnCause) {
  Entity entity = spawnCause.getEntity();
  if (!Creature.class.isAssignableFrom(entity.getType().getEntityClass())) {
    return;
  }

  if (isApplicable(entity.getLocation())) {
    event.setCancelled(true);
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:12,代码来源:ZoneCreatureDropBlocker.java


示例8: onInventoryTransfer

import org.spongepowered.api.event.cause.entity.spawn.EntitySpawnCause; //导入依赖的package包/类
@Listener
public void onInventoryTransfer(AffectSlotEvent e, @First EntitySpawnCause c) {
	Entity entity = c.getEntity();
	if (!(entity instanceof Player)) return;
	onInventoryTransfer(e, (Player) entity);
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:7,代码来源:InventoryChangeListener.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AuthInfo类代码示例发布时间:2022-05-23
下一篇:
Java ITiledSpriteVertexBufferObject类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap