@@ -88,83 +88,70 @@ object DeeperCommands {
8888 }
8989
9090 when {
91- Plugins .isEnabled(" FastAsyncWorldEdit" ) -> {
92- try {
93- val pos1 = BlockVector3 .at(
94- (player.location.x + range),
95- (player.location.y + range),
96- (player.location.z + range)
97- )
98- val pos2 = BlockVector3 .at(
99- (player.location.x - range),
100- (player.location.y - range),
101- (player.location.z - range)
102- )
103-
104- val region = CuboidRegion (pos1, pos2)
105- val clipboard = BlockArrayClipboard (region)
106- val wep = WorldEditPlugin .getInstance().bukkitImplAdapter
107- val weWorld: World = wep.adapt(player.world)
108- val editSession: EditSession = WorldEdit .getInstance().newEditSessionBuilder()
109- .world(weWorld)
110- .limitUnlimited()
111- .build()
112-
113- val loc = player.location
114- val linkedSection =
115- loc.correspondingSection ? : error(" Corresponding Section not found" )
116-
117- val linkedBlock = loc.getCorrespondingLocation(section, linkedSection)?.block
118- ? : error(" Corresponding Location not found" )
119-
120- val offset = if (pos2.y < 0 ) pos2.y else 0
121- TaskManager .taskManager().taskNowAsync {
122- player.success(" Blocks syncing..." )
123- editSession.use { editSession ->
124- // Copy
125- val forwardExtentCopy =
126- ForwardExtentCopy (
127- editSession, region, clipboard, region.minimumPoint
91+ Plugins .isEnabled(" FastAsyncWorldEdit" ) -> runCatching {
92+ val pos1 = BlockVector3 .at(
93+ (player.location.x + range),
94+ (player.location.y + range),
95+ (player.location.z + range)
96+ )
97+ val pos2 = BlockVector3 .at(
98+ (player.location.x - range),
99+ (player.location.y - range),
100+ (player.location.z - range)
101+ )
102+
103+ val region = CuboidRegion (pos1, pos2)
104+ val clipboard = BlockArrayClipboard (region)
105+ val wep = WorldEditPlugin .getInstance().bukkitImplAdapter
106+ val weWorld: World = wep.adapt(player.world)
107+ val editSession: EditSession = WorldEdit .getInstance().newEditSessionBuilder()
108+ .world(weWorld).limitUnlimited().build()
109+
110+ val loc = player.location
111+ val linkedSection = loc.correspondingSection ? : error(" Corresponding Section not found" )
112+
113+ val linkedBlock = loc.getCorrespondingLocation(section, linkedSection)?.block
114+ ? : error(" Corresponding Location not found" )
115+
116+ val offset = pos2.y().coerceAtLeast(0 )
117+ TaskManager .taskManager().taskNowAsync {
118+ player.success(" Blocks syncing..." )
119+ editSession.use { editSession ->
120+ // Copy
121+ val forwardExtentCopy = ForwardExtentCopy (editSession, region, clipboard, region.minimumPoint)
122+ forwardExtentCopy.isCopyingEntities = false
123+ forwardExtentCopy.isCopyingBiomes = true
124+ Operations .complete(forwardExtentCopy)
125+
126+ // Paste
127+ val operation: Operation = ClipboardHolder (clipboard)
128+ .createPaste(editSession)
129+ .to(
130+ BlockVector3 .at(
131+ linkedBlock.x - range,
132+ linkedBlock.y - range - offset,
133+ linkedBlock.z - range
128134 )
129- forwardExtentCopy.isCopyingEntities = false
130- forwardExtentCopy.isCopyingBiomes = true
131- Operations .complete(forwardExtentCopy)
132-
133- // Paste
134- val operation: Operation = ClipboardHolder (clipboard)
135- .createPaste(editSession)
136- .to(
137- BlockVector3 .at(
138- linkedBlock.x - range,
139- linkedBlock.y - range - offset,
140- linkedBlock.z - range
141- )
142- ).build()
143- Operations .complete(operation)
144- }
145- player.success(" Blocks synced (FAWE)" )
135+ ).build()
136+ Operations .complete(operation)
146137 }
147- } catch (e: Exception ) {
148- player.error(""" An error occurred: ${e.message} """ )
138+ player.success(" Blocks synced (FAWE)" )
149139 }
140+ }.onFailure {
141+ player.error(""" An error occurred: ${it.message} """ )
150142 }
151143
152144 range <= 100 -> {
153145 // Get blocks in range specified
154- for (x in - range.. range) {
155- for (y in - range.. range) {
156- for (z in - range.. range) {
157- val block = player.world.getBlockAt(
158- (player.location.x + x).toInt(),
159- (player.location.y + y).toInt(),
160- (player.location.z + z).toInt()
161- )
162-
163- block.sync { original, corr ->
164- if (original.type != corr.type) corr.blockData =
165- original.blockData.clone()
166- }
167- }
146+ for (x in - range.. range) for (y in - range.. range) for (z in - range.. range) {
147+ val block = player.world.getBlockAt(
148+ (player.location.x + x).toInt(),
149+ (player.location.y + y).toInt(),
150+ (player.location.z + z).toInt()
151+ )
152+
153+ block.sync { original, corr ->
154+ if (original.type != corr.type) corr.blockData = original.blockData.clone()
168155 }
169156 }
170157
0 commit comments