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


Java ChangeBlockEvent.Pre方法代码示例

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


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

示例1: onLiquidFlow

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener(order = Order.POST)
public void onLiquidFlow(ChangeBlockEvent.Pre e) {
	if (e.getLocations().isEmpty()) return;
			
	Location<World> loc = e.getLocations().get(0);
	BlockSnapshot snapshot = loc.getExtent().createSnapshot(loc.getBlockPosition());
	
	Optional<MatterProperty> matter = snapshot.getState().getProperty(MatterProperty.class);
	if (matter.isPresent() && matter.get().getValue() == Matter.LIQUID) {
		String name = "Water";
		BlockType type = snapshot.getState().getType();
		if (type == BlockTypes.LAVA || type == BlockTypes.FLOWING_LAVA)
			name = "Lava";
		db.addToQueue(new BlockQueueEntry(snapshot, ActionType.FLOW, name, new Date().getTime()));
	}
}
 
开发者ID:Karanum,项目名称:AdamantineShield,代码行数:17,代码来源:LiquidFlowListener.java

示例2: onPlayerChangeBlock

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener(order=Order.FIRST, beforeModifications = true)
public void onPlayerChangeBlock(ChangeBlockEvent.Pre event, @First Player player)
{
	if (!ConfigHandler.getNode("worlds").getNode(event.getTargetWorld().getName()).getNode("enabled").getBoolean())
	{
		return;
	}
	if (player.hasPermission("nations.admin.bypass.perm.build"))
	{
		return;
	}
	for (Location<World> loc : event.getLocations()) {
		if (!ConfigHandler.isWhitelisted("break", loc.getBlock().getId())
				&& !DataHandler.getPerm("build", player.getUniqueId(), loc))
		{
			event.setCancelled(true);
			try {
				player.sendMessage(Text.of(TextColors.RED, LanguageHandler.ERROR_PERM_BUILD));
			} catch (Exception e) {}
			return;
		}
	}
}
 
开发者ID:Arckenver,项目名称:Nations,代码行数:24,代码来源:BuildPermListener.java

示例3: onPreBlockChange

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onPreBlockChange(final ChangeBlockEvent.Pre event, @First LocatableBlock block) {
    final BlockType type = block.getBlockState().getType();

    if (type.equals(BlockTypes.PISTON) || type.equals(BlockTypes.STICKY_PISTON) || type.equals(BlockTypes.PISTON_EXTENSION) || type
        .equals(BlockTypes.PISTON_HEAD)) {
        //noinspection OptionalGetWithoutIsPresent
        final Location<World> location = block.getLocation().getBlockRelative(block.get(Keys.DIRECTION).get());

        final LockManager lockManager = Latch.getLockManager();

        if (lockManager.getLock(location).isPresent() || (lockManager.getLock(location.getBlockRelative(Direction.UP)).isPresent() && lockManager
            .isProtectBelowBlocks(location.getBlockRelative(Direction.UP).getBlockType()))) {
            event.setCancelled(true);
        }
    }
}
 
开发者ID:ichorpowered,项目名称:latch,代码行数:18,代码来源:ChangeBlockListener.java

示例4: changeBlock

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener(order = Order.POST)
@Exclude({ChangeBlockEvent.Post.class, ChangeBlockEvent.Pre.class})
public void changeBlock(ChangeBlockEvent event, @Root Player player) {
    // Just get the default key provider
    EventKeyProvider<Event> keyProvider = resolveKeyProvider(Event.class);

    final UUID uuid = player.getUniqueId();
    final int increment = 1;

    for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
        String key = keyProvider.provide(event);

        BlockSnapshot finalBlock = transaction.getFinal();
        // Check if the block is a "modifiable" block like a
        // redstone-related block so we can filter out crap like leaves
        // being changed somehow by the player
        //
        // Keys.DELAY is for repeaters, Keys.COMPARATOR_TYPE is for
        // comparators
        if (event instanceof ChangeBlockEvent.Modify
                && !(finalBlock.supports(Keys.POWERED) || finalBlock.supports(Keys.DELAY) || finalBlock.supports(Keys.COMPARATOR_TYPE))) {
            continue;
        } else if (event instanceof ChangeBlockEvent.Place || event instanceof ChangeBlockEvent.Modify) {
            key += ":" + transaction.getFinal().getState().getType().getId();
        } else if (event instanceof ChangeBlockEvent.Break) {
            key += ":" + transaction.getOriginal().getState().getType().getId();
        } else {
            continue;
        }

        BadgeUpEvent newEvent = new BadgeUpEvent(key, uuid, new Modifier(ModifierOperation.INC, increment));
        newEvent.addDataEntry("Transaction", transaction);
        send(newEvent);
    }
}
 
开发者ID:BadgeUp,项目名称:badgeup-sponge-client,代码行数:36,代码来源:GeneralEventListener.java

示例5: onPreChangeBlock

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onPreChangeBlock(ChangeBlockEvent.Pre event, @Root LocatableBlock block)
{
    for (Location<World> loc : event.getLocations()) {

        if (loc.getBlockType() != BlockTypes.AIR && loc.getBlockType() != block.getBlockState().getType()) {
            List<Region> regionsAt = manager.getRegionsAt(loc);
            if (this.checkSetting(event, null, regionsAt, () -> null, s -> s.blockDamage.block.getOrDefault(block.getBlockState().getType() , UNDEFINED), UNDEFINED) == FALSE)
            {
                return;
            }
        }
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:15,代码来源:SettingsListener.java

示例6: onBlockPistonExtend

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockPistonExtend(ChangeBlockEvent.Pre event, @First Player player)
{
    if (!this.module.getConfig().protectFromPistonMove) return;
    for (Location<World> loc : event.getLocations())
    {
        Lock lock = manager.getLock(loc);
        if (lock != null)
        {
            lock.handleBlockBreak(event, player);
            event.setCancelled(true);
            return;
        }
    }
}
 
开发者ID:CubeEngine,项目名称:modules-main,代码行数:16,代码来源:LockerBlockListener.java

示例7: onBlockChange

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockChange(ChangeBlockEvent event, @First Player p) {
    if (event instanceof ChangeBlockEvent.Pre || event instanceof ChangeBlockEvent.Post) {
        return;
    }
    UltimateUser up = UltimateCore.get().getUserService().getUser(p);
    if (up.get(JailKeys.JAIL).isPresent()) {
        if (!Modules.JAIL.get().getConfig().get().get().getNode("allow-block-modify").getBoolean()) {
            JailData data = up.get(JailKeys.JAIL).get();
            event.setCancelled(true);
            Messages.send(p, "jail.event.block", "%time%", (data.getEndtime() == -1L ? Messages.getFormatted("core.time.ever") : TimeUtil.formatDateDiff(data.getEndtime())), "%reason%", data.getReason());
        }
    }
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:15,代码来源:JailListener.java

示例8: onBlockPlace

import org.spongepowered.api.event.block.ChangeBlockEvent; //导入方法依赖的package包/类
@Listener
public void onBlockPlace(ChangeBlockEvent.Pre event) {
    Player player = SpongeUtil.getCause(event.getCause(), Player.class);
    if (player == null) {
        return;
    }
    PlotPlayer pp = SpongeUtil.getPlayer(player);
    List<org.spongepowered.api.world.Location<World>> locs = event.getLocations();
    org.spongepowered.api.world.Location<World> first = locs.get(0);
    String worldName = first.getExtent().getName();
    Location loc = SpongeUtil.getLocation(worldName, first.getPosition());
    PlotArea area = loc.getPlotArea();
    if (area == null) {
        return;
    }
    Plot plot = area.getPlot(loc);
    if (plot == null) {
        if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_ROAD, true)) {
            event.setCancelled(true);
        }
        return;
    }
    if (plot.hasOwner()) {
        if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
            return;
        } else {
            com.google.common.base.Optional<HashSet<PlotBlock>> place = plot.getFlag(Flags.PLACE);
            BlockState state = first.getBlock();
            if (!place.isPresent() || !place.get().contains(SpongeUtil.getPlotBlock(state))) {
                MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
                event.setCancelled(true);
                return;
            }
        }
    } else {
        if (Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
            return;
        }
        MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
        event.setCancelled(true);
        return;
    }
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:44,代码来源:MainListener.java


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