From da3019ae3d0d8fb99e7a2403d62ccd79f9fc4ffe Mon Sep 17 00:00:00 2001 From: MattBDev <4009945+MattBDev@users.noreply.github.com> Date: Wed, 9 Oct 2019 16:15:26 -0400 Subject: [PATCH] More compile fixes and upstream mergesa --- buildSrc/build.gradle.kts | 1 - buildSrc/src/main/kotlin/LibsConfig.kt | 1 - buildSrc/src/main/kotlin/PlatformConfig.kt | 2 +- .../fawe/bukkit/wrapper/AsyncWorld.java | 51 +++++-- .../java/com/boydti/fawe/config/Settings.java | 8 +- .../java/com/sk89q/worldedit/EditSession.java | 8 +- .../com/sk89q/worldedit/LocalSession.java | 1 - .../worldedit/command/BiomeCommands.java | 6 +- .../worldedit/command/ClipboardCommands.java | 124 +++++++++--------- .../sk89q/worldedit/command/ToolCommands.java | 17 +-- .../com/sk89q/worldedit/entity/Player.java | 5 - .../worldedit/event/extent/PasteEvent.java | 20 ++- .../worldedit/extension/platform/Actor.java | 6 + .../platform/PlatformCommandManager.java | 9 +- .../extension/platform/PlatformManager.java | 80 +++++------ .../worldedit/world/biome/BiomeType.java | 11 +- 16 files changed, 191 insertions(+), 159 deletions(-) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 53c14fc9e..5f4bc4a8a 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -25,5 +25,4 @@ dependencies { implementation("com.github.jengelman.gradle.plugins:shadow:5.1.0") implementation("net.ltgt.apt-eclipse:net.ltgt.apt-eclipse.gradle.plugin:0.21") implementation("net.ltgt.apt-idea:net.ltgt.apt-idea.gradle.plugin:0.21") - implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.9.7") } diff --git a/buildSrc/src/main/kotlin/LibsConfig.kt b/buildSrc/src/main/kotlin/LibsConfig.kt index b4897f677..11e8ecd2b 100644 --- a/buildSrc/src/main/kotlin/LibsConfig.kt +++ b/buildSrc/src/main/kotlin/LibsConfig.kt @@ -16,7 +16,6 @@ fun Project.applyLibrariesConfiguration() { apply(plugin = "java-base") apply(plugin = "maven") apply(plugin = "com.github.johnrengelman.shadow") - apply(plugin = "com.jfrog.artifactory") configurations { create("shade") diff --git a/buildSrc/src/main/kotlin/PlatformConfig.kt b/buildSrc/src/main/kotlin/PlatformConfig.kt index 069ad3fde..02459931e 100644 --- a/buildSrc/src/main/kotlin/PlatformConfig.kt +++ b/buildSrc/src/main/kotlin/PlatformConfig.kt @@ -24,7 +24,7 @@ fun Project.applyPlatformAndCoreConfiguration() { apply(plugin = "maven") //apply(plugin = "checkstyle") apply(plugin = "com.github.johnrengelman.shadow") - apply(plugin = "com.jfrog.artifactory") + //apply(plugin = "com.jfrog.artifactory") ext["internalVersion"] = "$version;${rootProject.ext["gitCommitHash"]}" diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java index 0d878aaeb..7313eed5e 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/wrapper/AsyncWorld.java @@ -10,8 +10,18 @@ import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.PassthroughExtent; import com.sk89q.worldedit.function.operation.Operation; +import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockState; +import java.io.File; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.UUID; +import java.util.concurrent.CompletableFuture; +import java.util.function.Predicate; +import java.util.function.Supplier; import org.bukkit.BlockChangeDelegate; import org.bukkit.Bukkit; import org.bukkit.Chunk; @@ -55,16 +65,6 @@ import org.bukkit.util.Consumer; import org.bukkit.util.RayTraceResult; import org.bukkit.util.Vector; import org.jetbrains.annotations.NotNull; - -import java.io.File; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; -import java.util.function.Predicate; -import java.util.function.Supplier; import org.jetbrains.annotations.Nullable; /** @@ -647,14 +647,17 @@ public class AsyncWorld extends PassthroughExtent implements World { parent.setThunderDuration(duration); } + @Override public boolean createExplosion(double x, double y, double z, float power) { return this.createExplosion(x, y, z, power, false, true); } + @Override public boolean createExplosion(double x, double y, double z, float power, boolean setFire) { return this.createExplosion(x, y, z, power, setFire, true); } + @Override public boolean createExplosion(final double x, final double y, final double z, final float power, final boolean setFire, final boolean breakBlocks) { return TaskManager.IMP.sync(new RunnableVal() { @Override @@ -664,14 +667,28 @@ public class AsyncWorld extends PassthroughExtent implements World { }); } + @Override + public boolean createExplosion(double x, double y, double z, float power, boolean setFire, + boolean breakBlocks, @Nullable Entity source) { + return TaskManager.IMP.sync(new RunnableVal() { + @Override + public void run(Boolean value) { + this.value = parent.createExplosion(x, y, z, power, setFire, breakBlocks, source); + } + }); + } + + @Override public boolean createExplosion(Location loc, float power) { return this.createExplosion(loc, power, false); } + @Override public boolean createExplosion(Location loc, float power, boolean setFire) { return this.createExplosion(loc.getX(), loc.getY(), loc.getZ(), power, setFire); } + @NotNull @Override public Environment getEnvironment() { return parent.getEnvironment(); @@ -810,7 +827,7 @@ public class AsyncWorld extends PassthroughExtent implements World { @Override public Biome getBiome(int x, int z) { - return adapter.adapt(getExtent().getBiomeType(x, z)); + return adapter.adapt(getExtent().getBiome(BlockVector2.at(x, z))); } @Override @@ -1301,6 +1318,18 @@ public class AsyncWorld extends PassthroughExtent implements World { return TaskManager.IMP.sync(() -> parent.createExplosion(source, loc, power, setFire, breakBlocks)); } + @Override + public boolean createExplosion(@NotNull Location loc, float power, boolean setFire, + boolean breakBlocks) { + return false; + } + + @Override + public boolean createExplosion(@NotNull Location loc, float power, boolean setFire, + boolean breakBlocks, @Nullable Entity source) { + return false; + } + @Override public void spawnParticle(Particle particle, List receivers, Player source, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) { diff --git a/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java b/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java index 38f2241f9..e8b53b2c5 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/config/Settings.java @@ -1,7 +1,7 @@ package com.boydti.fawe.config; import com.boydti.fawe.object.FaweLimit; -import com.sk89q.worldedit.entity.Player; +import com.sk89q.worldedit.extension.platform.Actor; import java.io.File; import java.util.ArrayList; import java.util.Collections; @@ -466,9 +466,9 @@ public class Settings extends Config { save(file); } - public FaweLimit getLimit(Player player) { + public FaweLimit getLimit(Actor actor) { FaweLimit limit; - if (player.hasPermission("fawe.limit.*") || player.hasPermission("fawe.bypass")) { + if (actor.hasPermission("fawe.limit.*") || actor.hasPermission("fawe.bypass")) { limit = FaweLimit.MAX.copy(); } else { limit = new FaweLimit(); @@ -478,7 +478,7 @@ public class Settings extends Config { boolean limitFound = false; for (String key : keys) { - if (player.hasPermission("fawe.limit." + key) || !limitFound && key.equals("default")) { + if (actor.hasPermission("fawe.limit." + key) || !limitFound && key.equals("default")) { limitFound = true; LIMITS newLimit = LIMITS.get(key); limit.MAX_ACTIONS = Math.max(limit.MAX_ACTIONS, newLimit.MAX_ACTIONS != -1 ? newLimit.MAX_ACTIONS : Integer.MAX_VALUE); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index dc9adb337..a700f6826 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -2388,10 +2388,6 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { * @return number of patches created * @throws MaxChangedBlocksException thrown if too many blocks are changed */ - public int makePumpkinPatches(BlockVector3 position, int apothem) throws MaxChangedBlocksException { - return makePumpkinPatches(position, apothem, 0.02); - } - public int makePumpkinPatches(BlockVector3 position, int apothem, double density) throws MaxChangedBlocksException { // We want to generate pumpkins GardenPatchGenerator generator = new GardenPatchGenerator(this); @@ -2665,8 +2661,8 @@ public class EditSession extends PassthroughExtent implements AutoCloseable { return deformRegion(region, zero, unit, expressionString, WorldEdit.getInstance().getConfiguration().calculationTimeout); } - public int deformRegion(Region region, Vector3 zero, Vector3 unit, String expressionString, - int timeout) throws ExpressionException, MaxChangedBlocksException { + public int deformRegion(final Region region, final Vector3 zero, final Vector3 unit, final String expressionString, + final int timeout) throws ExpressionException, MaxChangedBlocksException { final Expression expression = Expression.compile(expressionString, "x", "y", "z"); expression.optimize(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java index 412adfaf8..f2a8e442a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalSession.java @@ -578,7 +578,6 @@ public class LocalSession implements TextureHolder { this.worldOverride = worldOverride; } - public void unregisterTools(Player player) { for (Tool tool : tools) { if (tool instanceof BrushTool) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java index 9f19edfae..cf13879d2 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java @@ -122,7 +122,7 @@ public class BiomeCommands { if (useLineOfSight) { Location blockPosition = player.getBlockTrace(300); if (blockPosition == null) { - BBC.NO_BLOCK.send(player); + player.printError(BBC.NO_BLOCK.s()); return; } @@ -144,8 +144,8 @@ public class BiomeCommands { biomes.add(world.getBiome(pt)); } } else { - RegionVisitor visitor = new RegionVisitor(region, position -> { - biomes.add(world.getBiome(position.toBlockVector2())); + RegionVisitor visitor = new RegionVisitor(region, pt -> { + biomes.add(world.getBiome(pt.toBlockVector2())); return true; }); Operations.completeBlindly(visitor); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index 2fee668a2..e9731968b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -50,6 +50,7 @@ import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; import com.sk89q.worldedit.command.util.Logging; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.extent.PasteEvent; +import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; @@ -74,6 +75,7 @@ import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionSelector; import com.sk89q.worldedit.regions.selector.CuboidRegionSelector; import com.sk89q.worldedit.session.ClipboardHolder; +import com.sk89q.worldedit.world.World; import java.io.File; import java.io.IOException; import java.io.OutputStream; @@ -117,31 +119,31 @@ public class ClipboardCommands { desc = "Copy the selection to the clipboard" ) @CommandPermissions("worldedit.clipboard.copy") - public void copy(Player player, LocalSession session, EditSession editSession, + public void copy(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Switch(name = 'e', desc = "Skip copy entities") boolean skipEntities, @Switch(name = 'b', desc = "Also copy biomes") boolean copyBiomes, @ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "") - Mask maskOpt, InjectedValueAccess context) throws WorldEditException { + Mask mask, InjectedValueAccess context) throws WorldEditException { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); long volume = ((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1); - FaweLimit limit = player.getLimit(); + FaweLimit limit = actor.getLimit(); if (volume >= limit.MAX_CHECKS) { throw FaweException.MAX_CHECKS; } - player.checkConfirmationRegion(() -> { + actor.checkConfirmationRegion(() -> { session.setClipboard(null); - BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId()); + BlockArrayClipboard clipboard = new BlockArrayClipboard(region, actor.getUniqueId()); session.setClipboard(new ClipboardHolder(clipboard)); - clipboard.setOrigin(session.getPlacementPosition(player)); + clipboard.setOrigin(session.getPlacementPosition(actor)); ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint()); copy.setCopyingEntities(!skipEntities); copy.setCopyingBiomes(copyBiomes); @@ -152,13 +154,13 @@ public class ClipboardCommands { copy.setSourceMask(sourceMask); editSession.setSourceMask(null); } - if (maskOpt != null && maskOpt != Masks.alwaysTrue()) { - copy.setSourceMask(maskOpt); + if (mask != null && mask != Masks.alwaysTrue()) { + copy.setSourceMask(mask); } Operations.completeLegacy(copy); - BBC.COMMAND_COPY.send(player, region.getArea()); - if (!player.hasPermission("fawe.tips")) { - BBC.TIP_PASTE.or(BBC.TIP_DOWNLOAD, BBC.TIP_ROTATE, BBC.TIP_COPYPASTE, BBC.TIP_REPLACE_MARKER, BBC.TIP_COPY_PATTERN).send(player); + BBC.COMMAND_COPY.send(actor, region.getArea()); + if (!actor.hasPermission("fawe.tips")) { + BBC.TIP_PASTE.or(BBC.TIP_DOWNLOAD, BBC.TIP_ROTATE, BBC.TIP_COPYPASTE, BBC.TIP_REPLACE_MARKER, BBC.TIP_COPY_PATTERN).send(actor); } }, "/copy", region, context); } @@ -168,7 +170,7 @@ public class ClipboardCommands { desc = "Lazily copy the selection to the clipboard" ) @CommandPermissions("worldedit.clipboard.lazycopy") - public void lazyCopy(Player player, LocalSession session, EditSession editSession, + public void lazyCopy(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Switch(name = 'e', desc = "Skip copy entities") boolean skipEntities, @@ -179,7 +181,7 @@ public class ClipboardCommands { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); - FaweLimit limit = player.getLimit(); + FaweLimit limit = actor.getLimit(); if (volume >= limit.MAX_CHECKS) { throw new FaweException(BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS); } @@ -187,11 +189,11 @@ public class ClipboardCommands { ReadOnlyClipboard lazyClipboard = ReadOnlyClipboard.of(editSession, region, !skipEntities, copyBiomes); BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard); - clipboard.setOrigin(session.getPlacementPosition(player)); + clipboard.setOrigin(session.getPlacementPosition(actor)); session.setClipboard(new ClipboardHolder(clipboard)); - BBC.COMMAND_COPY.send(player, region.getArea()); - if (!player.hasPermission("fawe.tips")) { - BBC.TIP_PASTE.or(BBC.TIP_LAZYCOPY, BBC.TIP_DOWNLOAD, BBC.TIP_ROTATE, BBC.TIP_COPYPASTE, BBC.TIP_REPLACE_MARKER, BBC.TIP_COPY_PATTERN).send(player); + BBC.COMMAND_COPY.send(actor, region.getArea()); + if (!actor.hasPermission("fawe.tips")) { + BBC.TIP_PASTE.or(BBC.TIP_LAZYCOPY, BBC.TIP_DOWNLOAD, BBC.TIP_ROTATE, BBC.TIP_COPYPASTE, BBC.TIP_REPLACE_MARKER, BBC.TIP_COPY_PATTERN).send(actor); } } @@ -200,7 +202,7 @@ public class ClipboardCommands { desc = "Lazily cut the selection to the clipboard" ) @CommandPermissions("worldedit.clipboard.lazycut") - public void lazyCut(Player player, LocalSession session, EditSession editSession, + public void lazyCut(Actor actor, LocalSession session, EditSession editSession, @Selection final Region region, @Switch(name = 'e', desc = "Skip copy entities") boolean skipEntities, @@ -210,8 +212,8 @@ public class ClipboardCommands { boolean copyBiomes) throws WorldEditException { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); - long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); - FaweLimit limit = player.getLimit(); + long volume = ((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1); + FaweLimit limit = actor.getLimit(); if (volume >= limit.MAX_CHECKS) { throw FaweException.MAX_CHECKS; } @@ -222,9 +224,9 @@ public class ClipboardCommands { ReadOnlyClipboard lazyClipboard = new WorldCutClipboard(editSession, region, !skipEntities, copyBiomes); BlockArrayClipboard clipboard = new BlockArrayClipboard(region, lazyClipboard); - clipboard.setOrigin(session.getPlacementPosition(player)); + clipboard.setOrigin(session.getPlacementPosition(actor)); session.setClipboard(new ClipboardHolder(clipboard)); - BBC.COMMAND_CUT_LAZY.send(player, region.getArea()); + BBC.COMMAND_CUT_LAZY.send(actor, region.getArea()); } @Command( @@ -235,7 +237,7 @@ public class ClipboardCommands { ) @CommandPermissions("worldedit.clipboard.cut") @Logging(REGION) - public void cut(Player player, LocalSession session, EditSession editSession, + public void cut(Actor actor, LocalSession session, EditSession editSession, @Selection Region region, @Arg(desc = "Pattern to leave in place of the selection", def = "air") Pattern leavePattern, @@ -244,24 +246,24 @@ public class ClipboardCommands { @Switch(name = 'b', desc = "Also copy biomes, source biomes are unaffected") boolean copyBiomes, @ArgFlag(name = 'm', desc = "Set the exclude mask, matching blocks become air", def = "") - Mask maskOpt, + Mask mask, InjectedValueAccess context) throws WorldEditException { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); long volume = (((long) max.getX() - (long) min.getX() + 1) * ((long) max.getY() - (long) min.getY() + 1) * ((long) max.getZ() - (long) min.getZ() + 1)); - FaweLimit limit = player.getLimit(); + FaweLimit limit = actor.getLimit(); if (volume >= limit.MAX_CHECKS) { throw FaweException.MAX_CHECKS; } if (volume >= limit.MAX_CHANGES) { throw FaweException.MAX_CHANGES; } - player.checkConfirmationRegion(() -> { + actor.checkConfirmationRegion(() -> { session.setClipboard(null); - BlockArrayClipboard clipboard = new BlockArrayClipboard(region, player.getUniqueId()); - clipboard.setOrigin(session.getPlacementPosition(player)); + BlockArrayClipboard clipboard = new BlockArrayClipboard(region, actor.getUniqueId()); + clipboard.setOrigin(session.getPlacementPosition(actor)); ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint()); copy.setSourceFunction(new BlockReplace(editSession, leavePattern)); @@ -274,15 +276,15 @@ public class ClipboardCommands { copy.setSourceMask(sourceMask); editSession.setSourceMask(null); } - if (maskOpt != null) { - copy.setSourceMask(maskOpt); + if (mask != null) { + copy.setSourceMask(mask); } Operations.completeLegacy(copy); session.setClipboard(new ClipboardHolder(clipboard)); - BBC.COMMAND_CUT_SLOW.send(player, region.getArea()); - if (!player.hasPermission("fawe.tips")) { - BBC.TIP_LAZYCUT.send(player); + BBC.COMMAND_CUT_SLOW.send(actor, region.getArea()); + if (!actor.hasPermission("fawe.tips")) { + BBC.TIP_LAZYCUT.send(actor); } }, "cut", region, context); @@ -437,7 +439,7 @@ public class ClipboardCommands { ) @CommandPermissions("worldedit.clipboard.paste") @Logging(PLACEMENT) - public void paste(Player player, LocalSession session, EditSession editSession, + public void paste(Actor actor, World world, LocalSession session, EditSession editSession, @Switch(name = 'a', desc = "Skip air blocks") boolean ignoreAirBlocks, @Switch(name = 'o', desc = "Paste at the original position") @@ -454,14 +456,14 @@ public class ClipboardCommands { ClipboardHolder holder = session.getClipboard(); if (holder.getTransform().isIdentity() && editSession.getSourceMask() == null) { - place(player, session, editSession, ignoreAirBlocks, atOrigin, selectPasted); + place(actor, world, session, editSession, ignoreAirBlocks, atOrigin, selectPasted); return; } Clipboard clipboard = holder.getClipboard(); Region region = clipboard.getRegion(); - BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(player); - checkPaste(player, editSession, to, holder, clipboard); + BlockVector3 to = atOrigin ? clipboard.getOrigin() : session.getPlacementPosition(actor); + checkPaste(actor, editSession, to, holder, clipboard); Operation operation = holder .createPaste(editSession) .to(to) @@ -476,18 +478,18 @@ public class ClipboardCommands { BlockVector3 clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); Vector3 realTo = to.toVector3().add(holder.getTransform().apply(clipboardOffset.toVector3())); Vector3 max = realTo.add(holder.getTransform().apply(region.getMaximumPoint().subtract(region.getMinimumPoint()).toVector3())); - RegionSelector selector = new CuboidRegionSelector(player.getWorld(), realTo.toBlockPoint(), max.toBlockPoint()); - session.setRegionSelector(player.getWorld(), selector); + RegionSelector selector = new CuboidRegionSelector(world, realTo.toBlockPoint(), max.toBlockPoint()); + session.setRegionSelector(world, selector); selector.learnChanges(); - selector.explainRegionAdjust(player, session); + selector.explainRegionAdjust(actor, session); } - BBC.COMMAND_PASTE.send(player, to); - if (!player.hasPermission("fawe.tips")) { - BBC.TIP_COPYPASTE.or(BBC.TIP_SOURCE_MASK, BBC.TIP_REPLACE_MARKER).send(player, to); + BBC.COMMAND_PASTE.send(actor, to); + if (!actor.hasPermission("fawe.tips")) { + BBC.TIP_COPYPASTE.or(BBC.TIP_SOURCE_MASK, BBC.TIP_REPLACE_MARKER).send(actor, to); } } - private void checkPaste(Player player, EditSession editSession, BlockVector3 to, ClipboardHolder holder, Clipboard clipboard) { + private void checkPaste(Actor player, EditSession editSession, BlockVector3 to, ClipboardHolder holder, Clipboard clipboard) { URI uri = null; if (holder instanceof URIClipboardHolder) { uri = ((URIClipboardHolder) holder).getURI(clipboard); @@ -506,7 +508,7 @@ public class ClipboardCommands { @CommandPermissions("worldedit.clipboard.place") @Logging(PLACEMENT) - public void place(Player player, LocalSession session, final EditSession editSession, + public void place(Actor actor, World world, LocalSession session, final EditSession editSession, @Switch(name = 'a', desc = "Skip air blocks") boolean ignoreAirBlocks, @Switch(name = 'o', desc = "Paste at the original position") @@ -516,8 +518,8 @@ public class ClipboardCommands { ClipboardHolder holder = session.getClipboard(); final Clipboard clipboard = holder.getClipboard(); final BlockVector3 origin = clipboard.getOrigin(); - final BlockVector3 to = atOrigin ? origin : session.getPlacementPosition(player); - checkPaste(player, editSession, to, holder, clipboard); + final BlockVector3 to = atOrigin ? origin : session.getPlacementPosition(actor); + checkPaste(actor, editSession, to, holder, clipboard); Schematic schem = new Schematic(clipboard); schem.paste(editSession, to, !ignoreAirBlocks); @@ -527,15 +529,15 @@ public class ClipboardCommands { BlockVector3 clipboardOffset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); BlockVector3 realTo = to.add(holder.getTransform().apply(clipboardOffset.toVector3()).toBlockPoint()); BlockVector3 max = realTo.add(holder.getTransform().apply(region.getMaximumPoint().subtract(region.getMinimumPoint()).toVector3()).toBlockPoint()); - RegionSelector selector = new CuboidRegionSelector(player.getWorld(), realTo, max); - session.setRegionSelector(player.getWorld(), selector); + RegionSelector selector = new CuboidRegionSelector(world, realTo, max); + session.setRegionSelector(world, selector); selector.learnChanges(); - selector.explainRegionAdjust(player, session); + selector.explainRegionAdjust(actor, session); } - BBC.COMMAND_PASTE.send(player, to); + BBC.COMMAND_PASTE.send(actor, to); - if (!player.hasPermission("fawe.tips")) { - BBC.TIP_COPYPASTE.send(player); + if (!actor.hasPermission("fawe.tips")) { + BBC.TIP_COPYPASTE.send(actor); } } @@ -547,7 +549,7 @@ public class ClipboardCommands { "Multiple rotations can be stacked. Interpolation is not performed so angles should be a multiple of 90 degrees.\n" ) @CommandPermissions("worldedit.clipboard.rotate") - public void rotate(Player player, LocalSession session, + public void rotate(Actor actor, LocalSession session, @Arg(desc = "Amount to rotate on the y-axis") double yRotate, @Arg(desc = "Amount to rotate on the x-axis", def = "0") @@ -560,9 +562,9 @@ public class ClipboardCommands { transform = transform.rotateX(-xRotate); transform = transform.rotateZ(-zRotate); holder.setTransform(holder.getTransform().combine(transform)); - BBC.COMMAND_ROTATE.send(player); - if (!player.hasPermission("fawe.tips")) { - BBC.TIP_FLIP.or(BBC.TIP_DEFORM, BBC.TIP_TRANSFORM).send(player); + actor.print(BBC.COMMAND_ROTATE.s()); + if (!actor.hasPermission("fawe.tips")) { + BBC.TIP_FLIP.or(BBC.TIP_DEFORM, BBC.TIP_TRANSFORM).send(actor); } } @@ -571,7 +573,7 @@ public class ClipboardCommands { desc = "Flip the contents of the clipboard across the origin" ) @CommandPermissions("worldedit.clipboard.flip") - public void flip(Player player, LocalSession session, + public void flip(Actor actor, LocalSession session, @Arg(desc = "The direction to flip, defaults to look direction.", def = Direction.AIM) @Direction BlockVector3 direction) throws WorldEditException { @@ -579,7 +581,7 @@ public class ClipboardCommands { AffineTransform transform = new AffineTransform(); transform = transform.scale(direction.abs().multiply(-2).add(1, 1, 1).toVector3()); holder.setTransform(holder.getTransform().combine(transform)); - BBC.COMMAND_FLIPPED.send(player); + actor.print(BBC.COMMAND_FLIPPED.s()); } @Command( @@ -587,8 +589,8 @@ public class ClipboardCommands { desc = "Clear your clipboard" ) @CommandPermissions("worldedit.clipboard.clear") - public void clearClipboard(Player player, LocalSession session) throws WorldEditException { + public void clearClipboard(Actor actor, LocalSession session) throws WorldEditException { session.setClipboard(null); - BBC.CLIPBOARD_CLEARED.send(player); + actor.print(BBC.CLIPBOARD_CLEARED.s()); } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java index 8e3d0e97d..e9a44d460 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ToolCommands.java @@ -146,20 +146,21 @@ public class ToolCommands { // } @Command( - name = "/selwand", - aliases = "selwand", + name = "selwand", + aliases = "/selwand", desc = "Selection wand tool" ) @CommandPermissions("worldedit.setwand") public void selwand(Player player, LocalSession session) throws WorldEditException { + final ItemType itemType = player.getItemInHand(HandSide.MAIN_HAND).getType(); session.setTool(player, new SelectionWand()); player.print("Selection wand bound to " + itemType.getName() + "."); } @Command( - name = "/navwand", - aliases = "navwand", + name = "navwand", + aliases = "/navwand", desc = "Navigation wand tool" ) @CommandPermissions("worldedit.setwand") @@ -288,10 +289,10 @@ public class ToolCommands { ) @CommandPermissions("worldedit.tool.lrbuild") public void longrangebuildtool(Player player, LocalSession session, - @Arg(desc = "Pattern to set on left-click") - Pattern primary, - @Arg(desc = "Pattern to set on right-click") - Pattern secondary) throws WorldEditException { + @Arg(desc = "Pattern to set on left-click") + Pattern primary, + @Arg(desc = "Pattern to set on right-click") + Pattern secondary) throws WorldEditException { BaseItemStack itemStack = player.getItemInHand(HandSide.MAIN_HAND); session.setTool(player, new LongRangeBuildTool(primary, secondary)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java index 00d8e9119..ec9206f81 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java @@ -21,7 +21,6 @@ package com.sk89q.worldedit.entity; import com.boydti.fawe.Fawe; import com.boydti.fawe.config.Settings; -import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.brush.visualization.VirtualWorld; import com.boydti.fawe.object.clipboard.DiskOptimizedClipboard; import com.boydti.fawe.regions.FaweMaskManager; @@ -320,10 +319,6 @@ public interface Player extends Entity, Actor { */ > void sendFakeBlock(BlockVector3 pos, @Nullable B block); - default FaweLimit getLimit() { - return Settings.IMP.getLimit(this); - } - public Region[] getCurrentRegions(); Region[] getCurrentRegions(FaweMaskManager.MaskType type); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/PasteEvent.java b/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/PasteEvent.java index 386a2d80e..45f74c4b9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/PasteEvent.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/event/extent/PasteEvent.java @@ -19,37 +19,35 @@ package com.sk89q.worldedit.event.extent; -import com.sk89q.worldedit.entity.Player; +import static com.sk89q.worldedit.EditSession.Stage; + import com.sk89q.worldedit.event.Cancellable; import com.sk89q.worldedit.event.Event; +import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.BlockVector3; - import java.net.URI; - -import static com.sk89q.worldedit.EditSession.Stage; - public class PasteEvent extends Event implements Cancellable { - private final Player player; + private final Actor actor; private final Clipboard clipboard; private final URI uri; private final BlockVector3 to; private final Extent extent; private boolean cancelled; - public PasteEvent(Player player, Clipboard clipboard, URI uri, Extent extent, BlockVector3 to) { - this.player = player; + public PasteEvent(Actor actor, Clipboard clipboard, URI uri, Extent extent, BlockVector3 to) { + this.actor = actor; this.clipboard = clipboard; this.uri = uri; this.extent = extent; this.to = to; } - public Player getPlayer() { - return player; + public Actor getActor() { + return actor; } public Clipboard getClipboard() { @@ -85,7 +83,7 @@ public class PasteEvent extends Event implements Cancellable { * @return a new event */ public PasteEvent clone(Stage stage) { - PasteEvent clone = new PasteEvent(player, clipboard, uri, extent, to); + PasteEvent clone = new PasteEvent(actor, clipboard, uri, extent, to); return clone; } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java index 09f95f3aa..f1d5dacf4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/Actor.java @@ -21,6 +21,8 @@ package com.sk89q.worldedit.extension.platform; import com.boydti.fawe.Fawe; import com.boydti.fawe.config.BBC; +import com.boydti.fawe.config.Settings; +import com.boydti.fawe.object.FaweLimit; import com.sk89q.worldedit.entity.Metadatable; import com.sk89q.worldedit.event.platform.CommandEvent; import com.sk89q.worldedit.internal.cui.CUIEvent; @@ -243,4 +245,8 @@ public interface Actor extends Identifiable, SessionOwner, Subject, Metadatable setMeta("faweActionTick", tick); return tick > time; } + + default FaweLimit getLimit() { + return Settings.IMP.getLimit(this); + } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java index 77e36f49b..57d6e71ae 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java @@ -75,7 +75,6 @@ import com.sk89q.worldedit.command.SnapshotUtilCommandsRegistration; import com.sk89q.worldedit.command.SuperPickaxeCommands; import com.sk89q.worldedit.command.SuperPickaxeCommandsRegistration; import com.sk89q.worldedit.command.ToolCommands; -import com.sk89q.worldedit.command.ToolCommandsRegistration; import com.sk89q.worldedit.command.ToolUtilCommands; import com.sk89q.worldedit.command.ToolUtilCommandsRegistration; import com.sk89q.worldedit.command.UtilityCommands; @@ -138,8 +137,6 @@ import java.util.stream.Stream; import javax.annotation.Nullable; import org.enginehub.piston.Command; import org.enginehub.piston.CommandManager; -import org.enginehub.piston.config.ConfigHolder; -import org.enginehub.piston.config.TextConfig; import org.enginehub.piston.converter.ArgumentConverter; import org.enginehub.piston.converter.ArgumentConverters; import org.enginehub.piston.converter.ConversionResult; @@ -380,12 +377,11 @@ public final class PlatformCommandManager { ); registerSubCommands( "brush", - Lists.newArrayList("br", "/brush", "/br", "/tool", "tool"), + Lists.newArrayList("br", "/brush", "/br"), "Brushing commands", commandManager, c -> { c.accept(BrushCommandsRegistration.builder(), new BrushCommands(worldEdit)); - c.accept(ToolCommandsRegistration.builder(), new ToolCommands(worldEdit)); }, manager -> { PaintBrushCommands.register(commandManagerService, manager, registration); @@ -656,7 +652,8 @@ public final class PlatformCommandManager { } else { System.out.println("Invalid context " + context); } - Optional editSessionOpt = context.injectedValue(Key.of(EditSession.class)); + Optional editSessionOpt = + context.injectedValue(Key.of(EditSession.class)); if (editSessionOpt.isPresent()) { EditSession editSession = editSessionOpt.get(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java index 1196a6519..4b669f087 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java @@ -38,6 +38,7 @@ import com.sk89q.worldedit.command.tool.TraceTool; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.event.platform.BlockInteractEvent; import com.sk89q.worldedit.event.platform.ConfigurationLoadEvent; +import com.sk89q.worldedit.event.platform.Interaction; import com.sk89q.worldedit.event.platform.PlatformInitializeEvent; import com.sk89q.worldedit.event.platform.PlatformReadyEvent; import com.sk89q.worldedit.event.platform.PlayerInputEvent; @@ -69,9 +70,7 @@ public class PlatformManager { private static final Logger logger = LoggerFactory.getLogger(PlatformManager.class); private final WorldEdit worldEdit; - private final PlatformCommandManager platformCommandManager; - private final List platforms = new ArrayList<>(); private final Map preferences = new EnumMap<>(Capability.class); private @Nullable String firstSeenVersion; @@ -116,7 +115,6 @@ public class PlatformManager { } else { firstSeenVersion = platform.getVersion(); } - } /** @@ -260,6 +258,7 @@ public class PlatformManager { if (base instanceof Player) { Player player = (Player) base; + Player permActor = queryCapability(Capability.PERMISSIONS).matchPlayer(player); if (permActor == null) { permActor = player; @@ -338,42 +337,45 @@ public class PlatformManager { if (event.isCancelled()) return; } - switch (event.getType()) { - case HIT: { - // superpickaxe is special because its primary interaction is a left click, not a right click - // in addition, it is implicitly bound to all pickaxe items, not just a single tool item - if (session.hasSuperPickAxe()) { - final BlockTool superPickaxe = session.getSuperPickaxe(); - if (superPickaxe != null && superPickaxe.canUse(player) && player.isHoldingPickAxe()) { - player.runAction(() -> reset(superPickaxe).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location), false, true); - event.setCancelled(true); - return; - } - } - - Tool tool = session.getTool(player); - if (tool instanceof DoubleActionBlockTool && tool.canUse(player)) { - player.runAction(() -> reset(((DoubleActionBlockTool) tool)).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location), false, true); + if (event.getType() == Interaction.HIT) { + // superpickaxe is special because its primary interaction is a left click, not a right click + // in addition, it is implicitly bound to all pickaxe items, not just a single tool item + if (session.hasSuperPickAxe() && player.isHoldingPickAxe()) { + final BlockTool superPickaxe = session.getSuperPickaxe(); + if (superPickaxe != null && superPickaxe.canUse(player)) { + player.runAction(() -> reset(superPickaxe) + .actPrimary(queryCapability(Capability.WORLD_EDITING), + getConfiguration(), player, session, location), false, true); event.setCancelled(true); + return; } - break; } - case OPEN: { - Tool tool = session.getTool(player); - if (tool instanceof BlockTool && tool.canUse(player)) { - if (player.checkAction()) { - player.runAction(() -> { - if (tool instanceof BrushTool) { - ((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location); - } else { - reset((BlockTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session, location); - } - }, false, true); - event.setCancelled(true); - } + Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType()); + if (tool instanceof DoubleActionBlockTool && tool.canUse(player)) { + player.runAction(() -> reset(((DoubleActionBlockTool) tool)) + .actSecondary(queryCapability(Capability.WORLD_EDITING), + getConfiguration(), player, session, location), false, true); + event.setCancelled(true); + } + + } else if (event.getType() == Interaction.OPEN) { + Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType()); + if (tool instanceof BlockTool && tool.canUse(player)) { + if (player.checkAction()) { + player.runAction(() -> { + if (tool instanceof BrushTool) { + ((BlockTool) tool) + .actPrimary(queryCapability(Capability.WORLD_EDITING), + getConfiguration(), player, session, location); + } else { + reset((BlockTool) tool) + .actPrimary(queryCapability(Capability.WORLD_EDITING), + getConfiguration(), player, session, location); + } + }, false, true); + event.setCancelled(true); } - break; } } } catch (Throwable e) { @@ -425,9 +427,10 @@ public class PlatformManager { event.setCancelled(true); return; } - Tool tool = session.getTool(player); + Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType()); if (tool instanceof DoubleActionTraceTool && tool.canUse(player)) { - player.runAsyncIfFree(() -> reset((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session)); + player.runAsyncIfFree(() -> reset((DoubleActionTraceTool) tool).actSecondary(queryCapability(Capability.WORLD_EDITING), + getConfiguration(), player, session)); event.setCancelled(true); return; } @@ -448,10 +451,11 @@ public class PlatformManager { event.setCancelled(true); return; } - Tool tool = session.getTool(player); + Tool tool = session.getTool(player.getItemInHand(HandSide.MAIN_HAND).getType()); if (tool instanceof TraceTool && tool.canUse(player)) { //todo this needs to be fixed so the event is canceled after actPrimary is used and returns true - player.runAction(() -> reset((TraceTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), getConfiguration(), player, session), false, true); + player.runAction(() -> reset((TraceTool) tool).actPrimary(queryCapability(Capability.WORLD_EDITING), + getConfiguration(), player, session), false, true); event.setCancelled(true); return; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeType.java index 3e47c5d8b..aa5e00fbc 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/biome/BiomeType.java @@ -19,14 +19,16 @@ package com.sk89q.worldedit.world.biome; +import com.sk89q.worldedit.function.pattern.BiomePattern; +import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.registry.Keyed; -import com.sk89q.worldedit.registry.RegistryItem; import com.sk89q.worldedit.registry.NamespacedRegistry; +import com.sk89q.worldedit.registry.RegistryItem; /** * All the types of biomes in the game. */ -public class BiomeType implements RegistryItem, Keyed { +public class BiomeType implements RegistryItem, Keyed, BiomePattern { public static final NamespacedRegistry REGISTRY = new NamespacedRegistry<>("biome type"); @@ -80,4 +82,9 @@ public class BiomeType implements RegistryItem, Keyed { public boolean equals(Object obj) { return obj instanceof BiomeType && this.id.equals(((BiomeType) obj).id); } + + @Override + public BiomeType apply(BlockVector2 position) { + return this; + } }