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

Java NotifyNeighborBlockEvent类代码示例

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

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



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

示例1: notifyNeighbors

import org.spongepowered.api.event.block.NotifyNeighborBlockEvent; //导入依赖的package包/类
@Listener
public void notifyNeighbors(final NotifyNeighborBlockEvent event, @First LocatableBlock cause) {
    final LockManager lockManager = Latch.getLockManager();
    event.getNeighbors().entrySet().removeIf(neighbor -> {
        final Optional<Lock> optionalLock = lockManager.getLock(cause.getLocation().getBlockRelative(neighbor.getKey()));

        if (optionalLock.isPresent()) {
            final Lock lock = optionalLock.get();

            if (!lock.getProtectFromRedstone()) {
                return false;
            }

            final Optional<Player> optionalPlayer = event.getCause().first(Player.class);

            //noinspection OptionalIsPresent
            return !optionalPlayer.isPresent() || !lock.canAccess(optionalPlayer.get().getUniqueId());
        }
        return false;
    });
}
 
开发者ID:ichorpowered,项目名称:latch,代码行数:22,代码来源:NotifyNeighborListener.java


示例2: onBlockNotify

import org.spongepowered.api.event.block.NotifyNeighborBlockEvent; //导入依赖的package包/类
@Listener
public void onBlockNotify(NotifyNeighborBlockEvent event, @First BlockSnapshot notifySource) {
    Optional<Location<World>> loc = notifySource.getLocation();
    if (!loc.isPresent()) {
        return;
    }
    Vector3i origin = loc.get().getBlockPosition();
    CustomWorld world = WorldManager.toCustomWorld(loc.get().getExtent());
    for (Iterator<Entry<Direction, BlockState>> iterator = event.getNeighbors().entrySet().iterator(); iterator
            .hasNext();) {
        Direction side = iterator.next().getKey();
        Vector3i notifyPos = origin.add(side.asBlockOffset());
        BlockNature block = world.getBlock(notifyPos);
        if (block != null) {
            boolean allow =
                    block.onNeighborNotify(world, notifyPos, notifySource.getPosition(), side.getOpposite());
            if (!allow) {
                iterator.remove();
            }
        }
    }
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:23,代码来源:CustomBlockEventListeners.java


示例3: processResult

import org.spongepowered.api.event.block.NotifyNeighborBlockEvent; //导入依赖的package包/类
public static Tristate processResult(GPClaim claim, String permission, Tristate permissionValue, Subject subject) {
    if (GriefPreventionPlugin.debugActive) {
        if (subject == null) {
            if (eventSubject != null) {
                subject = eventSubject;
            } else if (currentEvent.getCause().root() instanceof User) {
                subject = (Subject) currentEvent.getCause().root();
            } else {
                subject = GriefPreventionPlugin.GLOBAL_SUBJECT;
            }
        }
        if (currentEvent instanceof CollideEvent || currentEvent instanceof NotifyNeighborBlockEvent) {
            if (claim.getWorld().getProperties().getTotalTime() % 100 == 0L) {
                GriefPreventionPlugin.addEventLogEntry(currentEvent, claim, eventLocation, eventSource, eventTarget, subject, permission, permissionValue);
            }
        } else {
            GriefPreventionPlugin.addEventLogEntry(currentEvent, claim, eventLocation, eventSource, eventTarget, subject, permission, permissionValue);
        }
    }

    return permissionValue;
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:23,代码来源:GPPermissionHandler.java


示例4: onFireSpread

import org.spongepowered.api.event.block.NotifyNeighborBlockEvent; //导入依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)	
   public void onFireSpread(NotifyNeighborBlockEvent  e, @First BlockSnapshot source){
	
	Map<Direction, BlockState> dirs = e.getNeighbors();
   	
   	for (Direction dir:dirs.keySet()){
   		BlockSnapshot b = source.getLocation().get().getRelative(dir).createSnapshot();
   		BlockState bstate = source.getState();
       	Region r = RedProtect.get().rm.getTopRegion(b.getLocation().get());   
   		if (r != null){
       		return;
       	}
   		
   		if ((bstate.getType().equals(BlockTypes.FIRE) || bstate.getType().getName().contains("lava")) && 
   				!RedProtect.get().cfgs.getGlobalFlag(b.getLocation().get().getExtent().getName(),"fire-spread")){
   			e.setCancelled(true);
   			return;
   		}
   	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:21,代码来源:RPGlobalListener.java


示例5: printEventByType

import org.spongepowered.api.event.block.NotifyNeighborBlockEvent; //导入依赖的package包/类
private static void printEventByType(PrintStream out, Event event) {
    if (event instanceof ChangeBlockEvent) {
        printChangeBlock(out, (ChangeBlockEvent) event);
    } else if (event instanceof InteractBlockEvent) {
        printInteractBlock(out, (InteractBlockEvent) event);
    } else if (event instanceof NotifyNeighborBlockEvent) {
        printNotifyEvent(out, (NotifyNeighborBlockEvent) event);
    } else if (event instanceof InteractInventoryEvent) {
        printInteractInventory(out, (InteractInventoryEvent) event);
    } else {
        out.println(event.toString());
    }
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:14,代码来源:DebugUtils.java


示例6: onRedstoneChangeNotify

import org.spongepowered.api.event.block.NotifyNeighborBlockEvent; //导入依赖的package包/类
@Listener
public void onRedstoneChangeNotify(NotifyNeighborBlockEvent event, @Root LocatableBlock block)
{
    for (Map.Entry<Direction, BlockState> entry : event.getOriginalNeighbors().entrySet())
    {
        Location<World> loc = block.getLocation().getRelative(entry.getKey());
        List<Region> regionsAt = manager.getRegionsAt(loc);
        if (isRedstoneChange(entry.getValue()))
        {
            // Redstone is disabled entirely?
            if (checkSetting(event, null, regionsAt, () -> null, s -> s.deadCircuit, UNDEFINED) == FALSE)
            {
                return;
            }
            if (true)
            {
                // TODO this check is spammed way too often (also with wrong notifier mabye?)
                return;
            }
            // Redstone is disabled for player?
            Optional<Player> player = event.getCause().getContext().get(EventContextKeys.NOTIFIER).filter(p -> p instanceof Player).map(Player.class::cast);
            if (player.isPresent())
            {
                if (checkSetting(event, player.get(), regionsAt, () -> usePermission.get(UseType.REDSTONE), s -> s.use.all.redstone, UNDEFINED) == FALSE)
                {
                    return;
                }
            }
        }
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:32,代码来源:SettingsListener.java


示例7: onNotifyNeighborBlock

import org.spongepowered.api.event.block.NotifyNeighborBlockEvent; //导入依赖的package包/类
public void onNotifyNeighborBlock(NotifyNeighborBlockEvent event) {
    AtomicBoolean cancelled = new AtomicBoolean(false);
    //        SpongeUtil.printCause("physics", event.getCause());
    //        PlotArea area = plotloc.getPlotArea();
    //        event.filterDirections(new Predicate<Direction>() {
    //            
    //            @Override
    //            public boolean test(Direction dir) {
    //                if (cancelled.get()) {
    //                    return true;
    //                }
    //                org.spongepowered.api.world.Location<World> loc = relatives.get(dir);
    //                com.intellectualcrafters.plot.object.Location plotloc = SpongeUtil.getLocation(loc.getExtent().getPluginName(), loc);
    //                if (area == null) {
    //                    return true;
    //                }
    //                plot = area.get
    //                Plot plot = plotloc.getPlot();
    //                if (plot == null) {
    //                    if (MainUtil.isPlotAreaAbs(plotloc)) {
    //                        cancelled.set(true);
    //                        return false;
    //                    }
    //                    cancelled.set(true);
    //                    return true;
    //                }
    //                org.spongepowered.api.world.Location<World> relative = loc.getRelative(dir);
    //                com.intellectualcrafters.plot.object.Location relLoc = SpongeUtil.getLocation(relative.getExtent().getPluginName(), relative);
    //                if (plot.equals(MainUtil.getPlot(relLoc))) {
    //                    return true;
    //                }
    //                return false;
    //            }
    //        });
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:36,代码来源:MainListener.java


示例8: printNotifyEvent

import org.spongepowered.api.event.block.NotifyNeighborBlockEvent; //导入依赖的package包/类
private static void printNotifyEvent(PrintStream out, NotifyNeighborBlockEvent event) {
    out.println(event.getNeighbors());
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:4,代码来源:DebugUtils.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java ChunkRegionLoader类代码示例发布时间:2022-05-23
下一篇:
Java Instructions类代码示例发布时间: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