本文整理汇总了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);
}
}
}
}
}
示例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;
}
}
}
示例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());
}
示例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);
}
示例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());
}
}
}
}
}
}
示例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);
}
}
}
}
示例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();
}
示例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);
}
}
}
示例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;
}
}
}
示例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;
}
示例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;
}
示例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;
}
}
}
}
}