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


Java Transaction.getOriginal方法代码示例

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


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

示例1: onBlockBreak

import org.spongepowered.api.data.Transaction; //导入方法依赖的package包/类
@Listener(order = Order.LAST)
public void onBlockBreak(ChangeBlockEvent.Break event) {
    for (Transaction<BlockSnapshot> blockSnapshotTransaction : event.getTransactions()) {
        final BlockSnapshot original = blockSnapshotTransaction.getOriginal();

        if (original.getState().getType() == BlockTypes.STANDING_SIGN
                || original.getState().getType() == BlockTypes.WALL_SIGN) {
            if (original.getLocation().isPresent()) {
                final Location3D location3D = WorldLocationConverter.of(original.getLocation().get());

                // iterate all arenas of all minigames to see if sign is registered
                //TODO: This is more expensive than it needs to be.
                //      We should maintain a global index of registered signs.
                if (InfernoCore.getMinigames().values().stream()
                        .filter(minigame -> minigame.getArenas().stream()
                                .filter(arena -> arena.getLobbySignAt(location3D).isPresent()).count() > 0)
                        .count() > 0) {
                    event.setCancelled(true);
                }
            }
        }
    }
}
 
开发者ID:caseif,项目名称:Inferno,代码行数:24,代码来源:LobbyListener.java

示例2: onBlockBreak

import org.spongepowered.api.data.Transaction; //导入方法依赖的package包/类
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event, @Root Player player) {
    List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
    for (Transaction<BlockSnapshot> transaction : transactions) {

        BlockSnapshot snapshot = transaction.getOriginal();
        BlockState blockState = snapshot.getState();
        String blockTypeId = blockState.getType().getId();
        String blockStateId = blockState.getId();

        PermHandler ph = PermHandler.getInstance();

        if (!ph.checkPerm(player, "protectionperms.block.break." + blockTypeId,
                "protectionperms.block.break." + blockStateId)) {
            event.setCancelled(true);
            player.sendMessage(ChatTypes.ACTION_BAR,
                    Text.of(TextColors.RED, "You don't have permission to break " + blockState.getName() + '!'));
            break;
        }
    }
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:22,代码来源:BreakListener.java

示例3: onChangeBlock

import org.spongepowered.api.data.Transaction; //导入方法依赖的package包/类
public void onChangeBlock(ChangeBlockEvent event) {
    List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
    Transaction<BlockSnapshot> first = transactions.get(0);
    BlockSnapshot original = first.getOriginal();
    Optional<World> world = SpongeMain.THIS.getServer().getWorld(original.getWorldUniqueId());
    String worldName = world.get().getName();
    Location loc = SpongeUtil.getLocation(worldName, original.getPosition());
    PlotArea area = loc.getPlotArea();
    if (area == null) {
        return;
    }
    Plot plot = area.getPlot(loc);
    if (plot == null) {
        if (!loc.isPlotArea()) {
            return;
        }
        event.setCancelled(true);
        return;
    }
    event.filter(loc1 -> !SpongeUtil.getLocation(worldName, loc1).isPlotRoad());
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:22,代码来源:MainListener.java

示例4: handleChangeBlock

import org.spongepowered.api.data.Transaction; //导入方法依赖的package包/类
private void handleChangeBlock(String name, ChangeBlockEvent.Break.Post event, Player player) {
    BatchPoints batch = newBatch();
    for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
        Point.Builder p = newPoint(name);
        addPlayer(p, player);
        BlockSnapshot original = transaction.getOriginal();
        p.tag("block_original", original.getState().getId());
        p.tag("block_final", transaction.getFinal().getState().getId());
        original.getLocation().ifPresent(loc -> {
            addLocation(p, loc);
        });

        batch.point(p.build());
    }

    connection.write(batch);
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:18,代码来源:Stats.java

示例5: onSignDestroy

import org.spongepowered.api.data.Transaction; //导入方法依赖的package包/类
@Listener
public void onSignDestroy(ChangeBlockEvent.Break event, @Root Player p) {
    for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
        BlockSnapshot snapshot = transaction.getOriginal();
        if (snapshot.supports(Keys.SIGN_LINES) && snapshot.getLocation().isPresent()) {
            List<Text> texts = snapshot.get(Keys.SIGN_LINES).get();
            //Checking for sign contents
            for (UCSign usign : UltimateCore.get().getSignService().get().getRegisteredSigns()) {
                if (texts.get(0).toPlain().equalsIgnoreCase("[" + usign.getIdentifier() + "]")) {
                    if (!p.hasPermission(usign.getDestroyPermission().get())) {
                        Messages.send(p, "core.nopermissions");
                    }
                    SignDestroyEvent cevent = new SignDestroyEvent(usign, snapshot.getLocation().get(), Cause.builder().owner(UltimateCore.getContainer()).notifier(p).build());
                    Sponge.getEventManager().post(cevent);
                    if (!cevent.isCancelled() && usign.onDestroy(p, event, texts)) {
                        Messages.send(p, "sign.destroy", "%sign%", usign.getIdentifier());
                    }
                }
            }
        }
    }
}
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:23,代码来源:SignListener.java

示例6: onBlockPlaceAfterPiston

import org.spongepowered.api.data.Transaction; //导入方法依赖的package包/类
@Listener
public void onBlockPlaceAfterPiston(ChangeBlockEvent.Place event, @First Piston piston) {
    World world = piston.getWorld();
    CustomWorld blockAccess = WorldManager.toCustomWorld(world);
    Vector3i pistonPos = piston.getLocation().getBlockPosition();
    if (!WorldManager.getPistonTracker(world).isTracked(pistonPos)) {
        return;
    }
    for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
        if (!transaction.isValid()) {
            continue;
        }
        BlockSnapshot orig = transaction.getOriginal();
        if (orig.getState().getType() == BlockTypes.PISTON_EXTENSION) {
            Vector3i newPos = orig.getPosition();
            Tuple<Vector3i, ImmutablePair<EnhancedCustomBlock, BlockData>> oldData =
                    WorldManager.getPistonTracker(world).restore(newPos);
            if (oldData == null) {
                continue;
            }
            Vector3i oldPos = oldData.getFirst();
            EnhancedCustomBlock block = oldData.getSecond().getLeft();
            BlockData data = oldData.getSecond().getRight();
            BlockSnapshot finalBlock = transaction.getFinal();
            BlockSnapshot newBlock = block.onMovedByPiston(blockAccess, newPos, finalBlock, data, oldPos);
            transaction.setValid(newBlock != null);
            if (newBlock != null) {
                if (finalBlock != newBlock) {
                    finalBlock = newBlock;
                    transaction.setCustom(finalBlock);
                }
                if (data != null) {
                    data.setPos(newPos);
                }
                blockAccess.setBlockWithData(newPos, block, data);
            }
        }
    }
}
 
开发者ID:simon816,项目名称:Industrialization,代码行数:40,代码来源:CustomBlockEventListeners.java

示例7: onExplosion

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

    GPTimings.EXPLOSION_EVENT.startTimingIfSync();
    Object source = event.getCause().root();
    final User user = CauseContextHelper.getEventUser(event);
    GPClaim targetClaim = null;
    for (Transaction<BlockSnapshot> transaction : event.getTransactions()) {
        BlockSnapshot blockSnapshot = transaction.getOriginal();
        Location<World> location = blockSnapshot.getLocation().orElse(null);
        if (location == null) {
            continue;
        }

        targetClaim =  GriefPreventionPlugin.instance.dataStore.getClaimAt(blockSnapshot.getLocation().get(), targetClaim);
        if (GPFlags.EXPLOSION_SURFACE && location.getPosition().getY() > ((net.minecraft.world.World) world).getSeaLevel() && GPPermissionHandler.getClaimPermission(event, location, targetClaim, GPPermissions.EXPLOSION_SURFACE, source, blockSnapshot, user, true) == Tristate.FALSE) {
            event.setCancelled(true);
            GPTimings.EXPLOSION_EVENT.stopTimingIfSync();
            return;
        }

        if (GPPermissionHandler.getClaimPermission(event, location, targetClaim, GPPermissions.EXPLOSION, source, blockSnapshot, user, true) == Tristate.FALSE) {
            // Avoid lagging server from large explosions.
            if (event.getTransactions().size() > 100) {
                event.setCancelled(true);
                GPTimings.EXPLOSION_EVENT.stopTimingIfSync();
                return;
            }
            transaction.setValid(false);
            GPTimings.EXPLOSION_EVENT.stopTimingIfSync();
            return;
        }
    }
    GPTimings.EXPLOSION_EVENT.stopTimingIfSync();
}
 
开发者ID:MinecraftPortCentral,项目名称:GriefPrevention,代码行数:40,代码来源:BlockEventHandler.java

示例8: onBlockBreak

import org.spongepowered.api.data.Transaction; //导入方法依赖的package包/类
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event, @Named(NamedCause.SOURCE) Entity srcEnt) {
  if (!isApplicable(srcEnt)) {
    return;
  }

  List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
  for (Transaction<BlockSnapshot> block : transactions) {
    BlockSnapshot original = block.getOriginal();
    if (original.getCreator().isPresent()) {
      continue;
    }

    Optional<Location<World>> optLoc = original.getLocation();

    if (!optLoc.isPresent()) {
      continue;
    }

    Location<World> loc = optLoc.get();

    BlockState state = original.getState();

    // Prevent item dupe glitch by removing the position before subsequent breaks
    markedOrePoints.remove(loc);
    if (config.getDropModification().blocks(state)) {
      markedOrePoints.add(loc);
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:31,代码来源:BuildWorldWrapper.java

示例9: onPlayerInteract

import org.spongepowered.api.data.Transaction; //导入方法依赖的package包/类
@Listener
public void onPlayerInteract(ChangeBlockEvent event) {
  for (Transaction<BlockSnapshot> block : event.getTransactions()) {
    BlockSnapshot snapshot = block.getOriginal();
    Optional<CursedMineInstance> optInst = manager.getApplicableZone(snapshot);
    if (optInst.isPresent() && triggerBlocks.contains(snapshot.getState().getType())) {
      optInst.get().activatePumps();
      break;
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:12,代码来源:CursedMineListener.java

示例10: getOriginalBlock

import org.spongepowered.api.data.Transaction; //导入方法依赖的package包/类
public static BlockSnapshot getOriginalBlock(List<Transaction<BlockSnapshot>> transactions) {
	for (Transaction<BlockSnapshot> block : transactions) {
		BlockSnapshot original = block.getOriginal();

		return original;
	}
	return null;
}
 
开发者ID:Volition21,项目名称:BlockTrackR,代码行数:9,代码来源:BTRBlockTools.java

示例11: transactions

import org.spongepowered.api.data.Transaction; //导入方法依赖的package包/类
/**
 * Observes a BlockTransaction
 *
 * @param transaction the transaction to observe
 * @return the observed data
 */
public static Map<String, Object> transactions(Transaction<BlockSnapshot> transaction)
{
    Map<String, Object> data = new HashMap<>();
    BlockSnapshot original = transaction.getOriginal();
    if (original.getLocation().isPresent())
    {
        //System.out.print(transaction.getFinal().getLocation().get().getPosition() +  " " + transaction.getFinal().getState().getType() + "\n");
        //data.put(LOCATION, location(transaction.getFinal().getLocation().get()));
        ORIGINAL.put(data, blockSnapshot(original));
        REPLACEMENT.put(data, blockSnapshot(transaction.getFinal()));
    }
    return data;
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:20,代码来源:Observe.java

示例12: onBlockBreak

import org.spongepowered.api.data.Transaction; //导入方法依赖的package包/类
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event, @First Player player)
{
    for (Transaction<BlockSnapshot> transaction : event.getTransactions())
    {
        BlockSnapshot orig = transaction.getOriginal();
        BlockType type = orig.getState().getType();
        if (type == STANDING_SIGN || type == WALL_SIGN)
        {
            Optional<ImmutableMarketSignData> signData = orig.get(ImmutableMarketSignData.class);
            if (signData.isPresent())
            {
                if (signData.get().getSignType() != null)
                {
                    event.setCancelled(true);
                    return;
                }
            }
        }

        Location<World> origLoc = orig.getLocation().get();
        for (Direction blockFace : BlockUtil.BLOCK_FACES)
        {
            if (blockFace == DOWN)
            {
                continue;
            }
            Location<World> relative = origLoc.getRelative(blockFace);
            if (!relative.get(MarketSignData.class).isPresent())
            {
                continue;
            }
            if (blockFace == UP)
            {
                if (relative.getBlockType() == STANDING_SIGN)
                {
                    event.setCancelled(true);
                    return;
                }
            }
            else
            {
                if (relative.getBlockType() == WALL_SIGN
                 && relative.get(Keys.DIRECTION).get() == blockFace)
                {
                    event.setCancelled(true);
                    return;
                }
            }
        }
    }
}
 
开发者ID:CubeEngine,项目名称:modules-extra,代码行数:53,代码来源:MarketSignListener.java


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