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


Java ExplosionEvent.Detonate方法代码示例

本文整理汇总了Java中org.spongepowered.api.event.world.ExplosionEvent.Detonate方法的典型用法代码示例。如果您正苦于以下问题:Java ExplosionEvent.Detonate方法的具体用法?Java ExplosionEvent.Detonate怎么用?Java ExplosionEvent.Detonate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spongepowered.api.event.world.ExplosionEvent的用法示例。


在下文中一共展示了ExplosionEvent.Detonate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onExplosion

import org.spongepowered.api.event.world.ExplosionEvent; //导入方法依赖的package包/类
@Listener
public void onExplosion(final ExplosionEvent.Detonate event) {
    Optional<Entity> optional = event.getCause().first(Entity.class);
    if (optional.isPresent()) {
        for (Location<World> location : event.getAffectedLocations()) {
            if (Keys.getLockableBlocks().contains(location.getBlockType())) {
                try {
                    // Are there locks on this block?
                    if (!Keys.getStorageAdapter().getLocks(location).isEmpty()) {
                        event.setCancelled(true);
                    }
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
 
开发者ID:prism,项目名称:Keys,代码行数:19,代码来源:ExplosionListener.java

示例2: onExplosion

import org.spongepowered.api.event.world.ExplosionEvent; //导入方法依赖的package包/类
@Listener
public void onExplosion(ExplosionEvent.Detonate event) {
	Optional<Player> source = event.getCause().first(Player.class);
	if (!source.isPresent() && event.getExplosion().getSourceExplosive().isPresent()) {
		Explosive e = event.getExplosion().getSourceExplosive().get();
		Optional<UUID> creator = e.getCreator();
		if (creator.isPresent()) source = Sponge.getServer().getPlayer(creator.get());
	}
	
	List<Location<World>> denied = new LinkedList<>();
	for (NPCguard g : VillagerShops.npcs) {
		if (g.playershopcontainer != null && 
				event.getAffectedLocations().contains(g.playershopcontainer)) {
				denied.add(g.playershopcontainer);
		}
	}
	event.getAffectedLocations().removeAll(denied);
}
 
开发者ID:DosMike,项目名称:VillagerShops,代码行数:19,代码来源:EventListeners.java

示例3: onEntityExplosionDetonate

import org.spongepowered.api.event.world.ExplosionEvent; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onEntityExplosionDetonate(ExplosionEvent.Detonate event) {
    if (!GPFlags.EXPLOSION || !GriefPreventionPlugin.instance.claimsEnabledForWorld(event.getTargetWorld().getProperties())) {
        return;
    }

    GPTimings.ENTITY_EXPLOSION_DETONATE_EVENT.startTimingIfSync();
    final User user = CauseContextHelper.getEventUser(event);
    Iterator<Entity> iterator = event.getEntities().iterator();
    GPClaim targetClaim = null;
    while (iterator.hasNext()) {
        Entity entity = iterator.next();
        targetClaim =  GriefPreventionPlugin.instance.dataStore.getClaimAt(entity.getLocation(), targetClaim);

        if (GPPermissionHandler.getClaimPermission(event, entity.getLocation(), targetClaim, GPPermissions.ENTITY_DAMAGE, event.getCause().root(), entity, user) == Tristate.FALSE) {
            iterator.remove();
        }
    }
    GPTimings.ENTITY_EXPLOSION_DETONATE_EVENT.stopTimingIfSync();
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:21,代码来源:EntityEventHandler.java

示例4: onBlockExplode

import org.spongepowered.api.event.world.ExplosionEvent; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onBlockExplode(ExplosionEvent.Detonate e){
	RedProtect.get().logger.debug("default","Is BlockListener - BlockExplodeEvent event");
	
	for (Location<World> bex:e.getAffectedLocations()){
		Region r = RedProtect.get().rm.getTopRegion(bex);
		if (!cont.canWorldBreak(bex.createSnapshot())){
			e.setCancelled(true);
			return;
    	}
		if (r != null && !r.canFire()){
			e.setCancelled(true);
			return;
		}
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:17,代码来源:RPMine18.java

示例5: onBlockExplode

import org.spongepowered.api.event.world.ExplosionEvent; //导入方法依赖的package包/类
@Listener(order = Order.LAST)
public void onBlockExplode(ExplosionEvent.Detonate event)
{
    if (!this.module.getConfig().protectBlockFromExplosion) return;

    Iterator<Location<World>> it = event.getAffectedLocations().iterator();
    while (it.hasNext())
    {
        Location<World> worldLocation = it.next();
        if (manager.getLock(worldLocation) != null)
        {
            event.getAffectedLocations().clear();
            break;
        }
    }

    event.filterEntities(input -> manager.getLockForEntityUID(input.getUniqueId()) != null);
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:19,代码来源:LockerBlockListener.java

示例6: onExplosion

import org.spongepowered.api.event.world.ExplosionEvent; //导入方法依赖的package包/类
@Listener
public void onExplosion(final ExplosionEvent.Detonate event) {
    Optional<Entity> optional = event.getCause().first(Entity.class);
    if (optional.isPresent()) {
        for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
            if (SafeGuard.getZoneManager().zoneExists(transaction.getOriginal().getLocation().get())) {
                transaction.setValid(false);
            }
        }
    }
}
 
开发者ID:prism,项目名称:SafeGuard,代码行数:12,代码来源:ExplosionListener.java

示例7: onExplosionOccurs

import org.spongepowered.api.event.world.ExplosionEvent; //导入方法依赖的package包/类
@Listener
public void onExplosionOccurs(ExplosionEvent.Detonate evt) {
    ExplosionOccursScriptEvent event = (ExplosionOccursScriptEvent) clone();
    event.internal = evt;
    event.location = new LocationTag(evt.getExplosion().getLocation());
    ListTag locs = new ListTag();
    for (Location<World> loc : evt.getAffectedLocations()) {
        locs.getInternal().add(new LocationTag(loc));
    }
    event.blocks = locs;
    ListTag ents = new ListTag();
    for (Entity ent : evt.getEntities()) {
        ents.getInternal().add(new EntityTag(ent));
    }
    event.entities = ents;
    Explosion exp = evt.getExplosion();
    MapTag data = new MapTag();
    data.getInternal().put("radius", new NumberTag(exp.getRadius()));
    data.getInternal().put("fire", new BooleanTag(exp.canCauseFire()));
    data.getInternal().put("break_blocks", new BooleanTag(exp.shouldBreakBlocks()));
    data.getInternal().put("damage_entities", new BooleanTag(exp.shouldDamageEntities()));
    data.getInternal().put("smoke", new BooleanTag(exp.shouldPlaySmoke()));
    event.explosion_data = data;
    event.cancelled = evt.isCancelled();
    event.run();
    evt.setCancelled(event.cancelled);
}
 
开发者ID:DenizenScript,项目名称:Denizen2Sponge,代码行数:28,代码来源:ExplosionOccursScriptEvent.java

示例8: onEntityExplode

import org.spongepowered.api.event.world.ExplosionEvent; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)	
public void onEntityExplode(ExplosionEvent.Detonate e) {
	    	
	World w = e.getTargetWorld();
    for (Location<World> b:e.getAffectedLocations()) {
        Region r = RedProtect.get().rm.getTopRegion(b);
    	if (r == null && !RedProtect.get().cfgs.getGlobalFlag(w.getName(),"entity-block-damage")){
    		e.setCancelled(true);
    		return;
    	} 
    }
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:13,代码来源:RPGlobalListener.java

示例9: onExplosion

import org.spongepowered.api.event.world.ExplosionEvent; //导入方法依赖的package包/类
@Listener
public void onExplosion(ExplosionEvent e) {
    if (e instanceof ExplosionEvent.Detonate) {
        ExplosionEvent.Detonate event = (Detonate) e;
        World world = event.getTargetWorld();
        String worldName = world.getName();
        if (!PS.get().hasPlotArea(worldName)) {
            return;
        }
        Optional<Explosive> source = event.getExplosion().getSourceExplosive();
        if (!source.isPresent()) {
            event.setCancelled(true);
            return;
        }
        Explosive tnt = source.get();
        UUID creator = tnt.getCreator().orElse(null);
        Location current = SpongeUtil.getLocation(tnt);
        Plot currentPlot = current.getPlot();
        if (currentPlot == null) {
            if (current.isPlotArea()) {
                event.setCancelled(true);
            }
            return;
        }
        if (creator != null) {
            if (!currentPlot.isAdded(creator)) {
                event.setCancelled(true);
                return;
            }
        }
        if (!currentPlot.getFlag(Flags.EXPLOSION).or(false)) {
            event.setCancelled(true);
            return;
        }

        event.getAffectedLocations().removeIf(worldLocation -> currentPlot.equals(SpongeUtil.getLocation(worldLocation.getExtent().getName(), worldLocation).getPlot()));
        event.filterEntities(entity -> currentPlot.equals(SpongeUtil.getLocation(entity).getPlot()));
    }
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:40,代码来源:MainListener.java


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