本文整理汇总了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;未经允许,请勿转载。 |
请发表评论