From f71d037a35476d11ff56745cbcea67ceeb940478 Mon Sep 17 00:00:00 2001 From: flamin_scotsman Date: Tue, 10 Mar 2015 21:55:51 +0000 Subject: [PATCH] Change cycler tool to use EditSession rather than changing the world directly --- .../worldedit/command/tool/BlockDataCyler.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java index 41bff5f2a..60045d3da 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java @@ -19,9 +19,12 @@ package com.sk89q.worldedit.command.tool; +import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.LocalConfiguration; import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.blocks.BaseBlock; +import com.sk89q.worldedit.blocks.BlockData; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Platform; @@ -54,12 +57,19 @@ public class BlockDataCyler implements DoubleActionBlockTool { } int increment = forward ? 1 : -1; - data = (new BaseBlock(type, data)).cycleData(increment); + BaseBlock block = new BaseBlock(type, BlockData.cycle(type, data, increment)); + EditSession editSession = session.createEditSession(player); if (data < 0) { player.printError("That block's data cannot be cycled!"); } else { - world.setBlockData(clicked.toVector(), data); + try { + editSession.setBlock(clicked.toVector(), block); + } catch (MaxChangedBlocksException e) { + player.printError("Max blocks change limit reached."); + } finally { + session.remember(editSession); + } } return true;