Selective merge of commanding branch.

This commit is contained in:
MattBDev 2019-10-23 12:58:36 -04:00
parent 8768085479
commit fd408c64ed
17 changed files with 259 additions and 227 deletions

View File

@ -6,8 +6,7 @@ import com.boydti.fawe.util.MathMan;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockState;
import java.awt.image.BufferedImage;
import java.awt.image.Raster;
import java.io.IOException;
@ -79,7 +78,7 @@ public class ScalableHeightMap implements HeightMap {
MutableBlockVector3 bv = new MutableBlockVector3(pos);
for (int y = minY; y <= maxY; y++) {
bv.mutY(y);
BlockStateHolder block = clipboard.getBlock(bv);
BlockState block = clipboard.getBlock(bv);
if (!block.getBlockType().getMaterial().isAir()) {
highestY = y + 1;
}

View File

@ -27,7 +27,17 @@ public abstract class FaweClipboard {
public abstract <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block);
public abstract boolean hasBiomes();
/**
* Returns true if the clipboard has biome data. This can be checked since {@link Extent#getBiome(BlockVector2)}
* strongly suggests returning {@link com.sk89q.worldedit.world.biome.BiomeTypes#OCEAN} instead of {@code null}
* if biomes aren't present. However, it might not be desired to set areas to ocean if the clipboard is defaulting
* to ocean, instead of having biomes explicitly set.
*
* @return true if the clipboard has biome data set
*/
public boolean hasBiomes() {
return false;
}
public abstract boolean setBiome(int x, int z, BiomeType biome);

View File

@ -534,7 +534,7 @@ public class ClipboardCommands {
BBC.COMMAND_PASTE.send(actor, to);
if (!actor.hasPermission("fawe.tips")) {
BBC.TIP_COPYPASTE.send(actor);
actor.print(BBC.TIP_COPYPASTE.s());
}
}

View File

@ -144,10 +144,10 @@ public class GeneralCommands {
}
if (hasFastMode) {
session.setFastMode(false);
BBC.FAST_DISABLED.send(actor);
actor.print(BBC.FAST_DISABLED.s());
} else {
session.setFastMode(true);
BBC.FAST_ENABLED.send(actor);
actor.print(BBC.FAST_ENABLED.s());
}
}
@ -219,9 +219,9 @@ public class GeneralCommands {
public void gmask(Actor actor, LocalSession session, @Arg(desc = "The mask to set", def = "") Mask mask) {
session.setMask(mask);
if (mask == null) {
BBC.MASK_DISABLED.send(actor);
actor.print(BBC.MASK_DISABLED.s());
} else {
BBC.MASK.send(actor);
actor.print(BBC.MASK.s());
}
}
@ -232,9 +232,9 @@ public class GeneralCommands {
)
public void togglePlace(Player player, LocalSession session) {
if (session.togglePlacementPosition()) {
BBC.PLACE_ENABLED.send(player);
player.print(BBC.PLACE_ENABLED.s());
} else {
BBC.PLACE_DISABLED.send(player);
player.print(BBC.PLACE_DISABLED.s());
}
}

View File

@ -260,7 +260,9 @@ public class GenerationCommands {
BlockVector3 finalPos = raised ? pos.add(0, radii.getY(), 0) : pos;
actor.checkConfirmationRadius(() -> {
int affected = editSession.makeSphere(finalPos, pattern, radii.getX(), radii.getY(), radii.getZ(), !hollow);
if (actor instanceof Player) ((Player) actor).findFreePosition();
if (actor instanceof Player) {
((Player) actor).findFreePosition();
}
BBC.VISITOR_BLOCK.send(actor, affected);
}, "sphere", (int) max, context);
}
@ -336,7 +338,9 @@ public class GenerationCommands {
worldEdit.checkMaxRadius(size);
actor.checkConfirmationRadius(() -> {
int affected = editSession.makePyramid(pos, pattern, size, !hollow);
if (actor instanceof Player) ((Player) actor).findFreePosition();
if (actor instanceof Player) {
((Player) actor).findFreePosition();
}
BBC.VISITOR_BLOCK.send(actor, affected);
}, getArguments(context), size, context);
}
@ -397,7 +401,9 @@ public class GenerationCommands {
actor.checkConfirmationRegion(() -> {
try {
final int affected = editSession.makeShape(region, zero, unit1, pattern, String.join(" ", expression), hollow, session.getTimeout());
if (actor instanceof Player) ((Player) actor).findFreePosition();
if (actor instanceof Player) {
((Player) actor).findFreePosition();
}
BBC.VISITOR_BLOCK.send(actor, affected);
} catch (ExpressionException e) {
actor.printError(e.getMessage());

View File

@ -41,6 +41,7 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.internal.annotation.Range;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
@ -232,7 +233,7 @@ public class HistoryCommands {
times = Math.max(1, times);
LocalSession undoSession;
if (session.hasFastMode()) {
BBC.COMMAND_UNDO_DISABLED.send(player);
player.print(BBC.COMMAND_UNDO_DISABLED.s());
return;
}
if (playerName != null && !playerName.isEmpty()) {
@ -259,7 +260,7 @@ public class HistoryCommands {
worldEdit.flushBlockBag(player, undone);
}
if (undone == null) {
BBC.COMMAND_UNDO_ERROR.send(player);
player.printError(BBC.COMMAND_UNDO_ERROR.s());
}
}, "undo", times, 50, context);
}
@ -298,7 +299,7 @@ public class HistoryCommands {
if (timesRedone > 0) {
BBC.COMMAND_REDO_SUCCESS.send(player, timesRedone == 1 ? "" : " x" + timesRedone);
} else {
BBC.COMMAND_REDO_ERROR.send(player);
player.printError(BBC.COMMAND_REDO_ERROR.s());
}
}
@ -308,9 +309,9 @@ public class HistoryCommands {
desc = "Clear your history"
)
@CommandPermissions("worldedit.history.clear")
public void clearHistory(Player player, LocalSession session) {
public void clearHistory(Actor actor, LocalSession session) {
session.clearHistory();
BBC.COMMAND_HISTORY_CLEAR.send(player);
actor.print(BBC.COMMAND_HISTORY_CLEAR.s());
}
}

View File

@ -62,7 +62,7 @@ public class NavigationCommands {
@CommandPermissions("worldedit.navigation.unstuck")
public void unstuck(Player player) throws WorldEditException {
player.findFreePosition();
BBC.UNSTUCK.send(player);
player.print(BBC.UNSTUCK.s());
}
@Command(
@ -82,10 +82,10 @@ public class NavigationCommands {
}
}
if (ascentLevels == 0) {
BBC.ASCEND_FAIL.send(player);
player.printError(BBC.ASCEND_FAIL.s());
} else {
if (ascentLevels == 1) {
BBC.ASCENDED_SINGULAR.send(player);
player.print(BBC.ASCENDED_SINGULAR.s());
} else {
BBC.ASCENDED_PLURAL.send(player, ascentLevels);
}
@ -109,9 +109,9 @@ public class NavigationCommands {
}
}
if (descentLevels == 0) {
BBC.DESCEND_FAIL.send(player);
player.printError(BBC.DESCEND_FAIL.s());
} else if (descentLevels == 1) {
BBC.DESCEND_SINGULAR.send(player);
player.print(BBC.DESCEND_SINGULAR.s());
} else {
BBC.DESCEND_PLURAL.send(player, descentLevels);
}
@ -134,9 +134,9 @@ public class NavigationCommands {
boolean alwaysGlass = getAlwaysGlass(forceFlight, forceGlass);
if (player.ascendToCeiling(clearance, alwaysGlass)) {
BBC.WHOOSH.send(player);
player.print(BBC.WHOOSH.s());
} else {
BBC.ASCEND_FAIL.send(player);
player.printError(BBC.ASCEND_FAIL.s());
}
}
@ -147,9 +147,9 @@ public class NavigationCommands {
@CommandPermissions("worldedit.navigation.thru.command")
public void thru(Player player) throws WorldEditException {
if (player.passThroughForwardWall(6)) {
BBC.WHOOSH.send(player);
player.print(BBC.WHOOSH.s());
} else {
BBC.THRU_FAIL.send(player);
player.printError(BBC.THRU_FAIL.s());
}
}
@ -174,9 +174,9 @@ public class NavigationCommands {
} else {
player.findFreePosition(pos);
}
BBC.POOF.send(player);
player.print(BBC.POOF.s());
} else {
BBC.NO_BLOCK.send(player);
player.printError(BBC.NO_BLOCK.s());
}
}
@ -195,9 +195,9 @@ public class NavigationCommands {
boolean forceGlass) throws WorldEditException {
boolean alwaysGlass = getAlwaysGlass(forceFlight, forceGlass);
if (player.ascendUpwards(distance, alwaysGlass)) {
BBC.WHOOSH.send(player);
player.print(BBC.WHOOSH.s());
} else {
BBC.UP_FAIL.send(player);
player.printError(BBC.UP_FAIL.s());
}
}

View File

@ -33,7 +33,6 @@ import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.exception.FaweException;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
@ -108,16 +107,16 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.set")
@Logging(REGION)
public void set(Player fp, EditSession editSession,
public void set(Actor actor, EditSession editSession,
@Selection Region region,
@Arg(desc = "The pattern of blocks to set")
Pattern patternArg, InjectedValueAccess context) throws WorldEditException {
fp.checkConfirmationRegion(() -> {
int affected = editSession.setBlocks(region, patternArg);
Pattern pattern, InjectedValueAccess context) throws WorldEditException {
actor.checkConfirmationRegion(() -> {
int affected = editSession.setBlocks(region, pattern);
if (affected != 0) {
BBC.OPERATION.send(fp, affected);
if (!fp.hasPermission("fawe.tips"))
BBC.TIP_FAST.or(BBC.TIP_CANCEL, BBC.TIP_MASK, BBC.TIP_MASK_ANGLE, BBC.TIP_SET_LINEAR, BBC.TIP_SURFACE_SPREAD, BBC.TIP_SET_HAND).send(fp);
BBC.OPERATION.send(actor, affected);
if (!actor.hasPermission("fawe.tips"))
BBC.TIP_FAST.or(BBC.TIP_CANCEL, BBC.TIP_MASK, BBC.TIP_MASK_ANGLE, BBC.TIP_SET_LINEAR, BBC.TIP_SURFACE_SPREAD, BBC.TIP_SET_HAND).send(actor);
}
}, getArguments(context), region, context);
}
@ -215,7 +214,7 @@ public class RegionCommands {
public int line(Actor actor, EditSession editSession,
@Selection Region region,
@Arg(desc = "The pattern of blocks to place")
Pattern patternArgOpt,
Pattern pattern,
@Range(min = 1) @Arg(desc = "The thickness of the line", def = "0")
int thickness,
@Switch(name = 'h', desc = "Generate only a shell")
@ -229,7 +228,7 @@ public class RegionCommands {
CuboidRegion cuboidregion = (CuboidRegion) region;
BlockVector3 pos1 = cuboidregion.getPos1();
BlockVector3 pos2 = cuboidregion.getPos2();
int blocksChanged = editSession.drawLine(patternArgOpt, pos1, pos2, thickness, !shell);
int blocksChanged = editSession.drawLine(pattern, pos1, pos2, thickness, !shell);
BBC.VISITOR_BLOCK.send(actor, blocksChanged);
return blocksChanged;
@ -242,27 +241,27 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.curve")
@Logging(REGION)
public void curve(Player fp, EditSession editSession,
public void curve(Actor actor, EditSession editSession,
@Selection Region region,
@Arg(desc = "The pattern of blocks to place")
Pattern patternArg,
Pattern pattern,
@Arg(desc = "The thickness of the curve", def = "0")
int thickness,
@Switch(name = 'h', desc = "Generate only a shell")
boolean shell, InjectedValueAccess context) throws WorldEditException {
if (!(region instanceof ConvexPolyhedralRegion)) {
fp.printError("//curve only works with convex polyhedral selections");
actor.printError("//curve only works with convex polyhedral selections");
return;
}
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
fp.checkConfirmationRegion(() -> {
actor.checkConfirmationRegion(() -> {
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
List<BlockVector3> vectors = new ArrayList<>(cpregion.getVertices());
int blocksChanged = editSession.drawSpline(patternArg, vectors, 0, 0, 0, 10, thickness, !shell);
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
BBC.VISITOR_BLOCK.send(fp, blocksChanged);
BBC.VISITOR_BLOCK.send(actor, blocksChanged);
}, getArguments(context), region, context);
}
@ -273,7 +272,7 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.replace")
@Logging(REGION)
public void replace(Player fp, EditSession editSession, @Selection Region region,
public void replace(Actor actor, EditSession editSession, @Selection Region region,
@Arg(desc = "The mask representing blocks to replace", def = "")
Mask from,
@Arg(desc = "The pattern of blocks to replace with")
@ -282,14 +281,14 @@ public class RegionCommands {
from = new ExistingBlockMask(editSession);
}
Mask finalFrom = from;
fp.checkConfirmationRegion(() -> {
actor.checkConfirmationRegion(() -> {
int affected = editSession.replaceBlocks(region, finalFrom, to);
BBC.VISITOR_BLOCK.send(fp, affected);
if (!fp.hasPermission("fawe.tips")) {
BBC.VISITOR_BLOCK.send(actor, affected);
if (!actor.hasPermission("fawe.tips")) {
BBC.TIP_REPLACE_ID
.or(BBC.TIP_REPLACE_LIGHT, BBC.TIP_REPLACE_MARKER, BBC.TIP_TAB_COMPLETE,
BBC.TIP_REPLACE_REGEX, BBC.TIP_REPLACE_REGEX_2, BBC.TIP_REPLACE_REGEX_3,
BBC.TIP_REPLACE_REGEX_4, BBC.TIP_REPLACE_REGEX_5).send(fp);
BBC.TIP_REPLACE_REGEX_4, BBC.TIP_REPLACE_REGEX_5).send(actor);
}
}, getArguments(context), region, context);
}
@ -300,12 +299,12 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.overlay")
@Logging(REGION)
public void overlay(Player fp, EditSession editSession, @Selection Region region,
public void overlay(Actor actor, EditSession editSession, @Selection Region region,
@Arg(desc = "The pattern of blocks to overlay")
Pattern patternArg, InjectedValueAccess context) throws WorldEditException {
fp.checkConfirmationRegion(() -> {
int affected = editSession.overlayCuboidBlocks(region, patternArg);
BBC.VISITOR_BLOCK.send(fp, affected);
Pattern pattern, InjectedValueAccess context) throws WorldEditException {
actor.checkConfirmationRegion(() -> {
int affected = editSession.overlayCuboidBlocks(region, pattern);
BBC.VISITOR_BLOCK.send(actor, affected);
}, getArguments(context), region, context);
}
@ -344,8 +343,8 @@ public class RegionCommands {
@CommandPermissions("worldedit.region.center")
public void center(Actor actor, EditSession editSession, @Selection Region region,
@Arg(desc = "The pattern of blocks to set")
Pattern patternArg) throws WorldEditException {
int affected = editSession.center(region, patternArg);
Pattern pattern) throws WorldEditException {
int affected = editSession.center(region, pattern);
BBC.VISITOR_BLOCK.send(actor, affected);
}
@ -355,10 +354,10 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.naturalize")
@Logging(REGION)
public void naturalize(Player fp, EditSession editSession, @Selection Region region, InjectedValueAccess context) throws WorldEditException {
fp.checkConfirmationRegion(() -> {
public void naturalize(Actor actor, EditSession editSession, @Selection Region region, InjectedValueAccess context) throws WorldEditException {
actor.checkConfirmationRegion(() -> {
int affected = editSession.naturalizeCuboidBlocks(region);
BBC.VISITOR_BLOCK.send(fp, affected);
BBC.VISITOR_BLOCK.send(actor, affected);
}, getArguments(context), region, context);
}
@ -368,12 +367,12 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.walls")
@Logging(REGION)
public void walls(Player fp, EditSession editSession, @Selection Region region,
public void walls(Actor actor, EditSession editSession, @Selection Region region,
@Arg(desc = "The pattern of blocks to set")
Pattern patternArg, InjectedValueAccess context) throws WorldEditException {
fp.checkConfirmationRegion(() -> {
int affected = editSession.makeWalls(region, patternArg);
BBC.VISITOR_BLOCK.send(fp, affected);
Pattern pattern, InjectedValueAccess context) throws WorldEditException {
actor.checkConfirmationRegion(() -> {
int affected = editSession.makeWalls(region, pattern);
BBC.VISITOR_BLOCK.send(actor, affected);
}, getArguments(context), region, context);
}
@ -384,12 +383,12 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.faces")
@Logging(REGION)
public void faces(Player fp, EditSession editSession, @Selection Region region,
public void faces(Actor actor, EditSession editSession, @Selection Region region,
@Arg(desc = "The pattern of blocks to set")
Pattern patternArg, InjectedValueAccess context) throws WorldEditException {
fp.checkConfirmationRegion(() -> {
int affected = editSession.makeCuboidFaces(region, patternArg);
BBC.VISITOR_BLOCK.send(fp, affected);
Pattern pattern, InjectedValueAccess context) throws WorldEditException {
actor.checkConfirmationRegion(() -> {
int affected = editSession.makeCuboidFaces(region, pattern);
BBC.VISITOR_BLOCK.send(actor, affected);
}, getArguments(context), region, context);
}
@ -400,25 +399,25 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.smooth")
@Logging(REGION)
public void smooth(Player fp, EditSession editSession, @Selection Region region,
public void smooth(Actor actor, EditSession editSession, @Selection Region region,
@Arg(desc = "# of iterations to perform", def = "1")
int iterations,
@Arg(desc = "The mask of blocks to use as the height map", def = "")
Mask maskOpt,
Mask mask,
@Switch(name = 's', desc = "TODO") boolean snow, 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 = fp.getLimit();
FaweLimit limit = actor.getLimit();
if (volume >= limit.MAX_CHECKS) {
throw FaweCache.MAX_CHECKS;
}
fp.checkConfirmationRegion(() -> {
actor.checkConfirmationRegion(() -> {
try {
HeightMap heightMap = new HeightMap(editSession, region, maskOpt, snow);
HeightMap heightMap = new HeightMap(editSession, region, mask, snow);
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
int affected = heightMap.applyFilter(filter, iterations);
BBC.VISITOR_BLOCK.send(fp, affected);
BBC.VISITOR_BLOCK.send(actor, affected);
} catch (Throwable e) {
throw new RuntimeException(e);
}
@ -432,11 +431,11 @@ public class RegionCommands {
descFooter = "Bypass region restrictions"
)
@CommandPermissions("fawe.admin")
public void wea(Player player) throws WorldEditException {
if (player.togglePermission("fawe.bypass")) {
BBC.WORLDEDIT_BYPASSED.send(player);
public void wea(Actor actor) throws WorldEditException {
if (actor.togglePermission("fawe.bypass")) {
actor.print(BBC.WORLDEDIT_BYPASSED.s());
} else {
BBC.WORLDEDIT_RESTRICTED.send(player);
actor.print(BBC.WORLDEDIT_RESTRICTED.s());
}
}
@ -447,13 +446,13 @@ public class RegionCommands {
descFooter = "Select your current allowed region"
)
@CommandPermissions("fawe.worldeditregion")
public void wer(Player fp) throws WorldEditException {
final Region region = fp.getLargestRegion();
public void wer(Player player) throws WorldEditException {
final Region region = player.getLargestRegion();
if (region == null) {
BBC.NO_REGION.send(fp);
player.print(BBC.NO_REGION.s());
} else {
fp.setSelection(region);
BBC.SET_REGION.send(fp);
player.setSelection(region);
player.print(BBC.SET_REGION.s());
}
}
@ -464,7 +463,7 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.move")
@Logging(ORIENTATION_REGION)
public void move(Player player, World world, EditSession editSession, LocalSession session,
public void move(Actor actor, World world, EditSession editSession, LocalSession session,
@Selection Region region,
@Arg(desc = "# of blocks to move", def = "1")
int count,
@ -483,7 +482,7 @@ public class RegionCommands {
boolean skipEntities,
InjectedValueAccess context) throws WorldEditException {
checkCommandArgument(count >= 1, "Count must be >= 1");
player.checkConfirmationRegion(() -> {
actor.checkConfirmationRegion(() -> {
int affected = editSession.moveRegion(region, direction, count, !ignoreAirBlocks, !skipEntities, copyBiomes, replace);
if (moveSelection) {
@ -491,13 +490,13 @@ public class RegionCommands {
region.shift(direction.multiply(count));
session.getRegionSelector(world).learnChanges();
session.getRegionSelector(world).explainRegionAdjust(player, session);
session.getRegionSelector(world).explainRegionAdjust(actor, session);
} catch (RegionOperationException e) {
player.printError(e.getMessage());
actor.printError(e.getMessage());
}
}
BBC.VISITOR_BLOCK.send(player, affected);
BBC.VISITOR_BLOCK.send(actor, affected);
}, getArguments(context), region, context);
}
@ -511,7 +510,7 @@ public class RegionCommands {
@Logging(ORIENTATION_REGION)
public void fall(Player player, EditSession editSession, LocalSession session,
@Selection Region region,
@Arg(name = "replace", desc = "BlockStateHolder", def = "air") BlockStateHolder replace,
@Arg(desc = "BlockStateHolder", def = "air") BlockStateHolder replace,
@Switch(name = 'm', desc = "TODO") boolean notFullHeight,
InjectedValueAccess context) throws WorldEditException {
player.checkConfirmationRegion(() -> {
@ -526,7 +525,7 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.stack")
@Logging(ORIENTATION_REGION)
public void stack(Player player, EditSession editSession, LocalSession session,
public void stack(Actor actor, World world, EditSession editSession, LocalSession session,
@Selection Region region,
@Arg(desc = "# of copies to stack", def = "1")
int count,
@ -544,7 +543,7 @@ public class RegionCommands {
@ArgFlag(name = 'm', desc = "Source mask")
Mask sourceMask,
InjectedValueAccess context) throws WorldEditException {
player.checkConfirmationStack(() -> {
actor.checkConfirmationStack(() -> {
if (sourceMask != null) {
editSession.addSourceMask(sourceMask);
}
@ -557,14 +556,14 @@ public class RegionCommands {
final BlockVector3 shiftVector = direction.toVector3().multiply(count * (Math.abs(direction.dot(size)) + 1)).toBlockPoint();
region.shift(shiftVector);
session.getRegionSelector(player.getWorld()).learnChanges();
session.getRegionSelector(player.getWorld()).explainRegionAdjust(player, session);
session.getRegionSelector(world).learnChanges();
session.getRegionSelector(world).explainRegionAdjust(actor, session);
} catch (RegionOperationException e) {
player.printError(e.getMessage());
actor.printError(e.getMessage());
}
}
BBC.VISITOR_BLOCK.send(player, affected);
BBC.VISITOR_BLOCK.send(actor, affected);
}, getArguments(context), region, count, context);
}
@ -577,7 +576,7 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.deform")
@Logging(ALL)
public void deform(Player player, LocalSession session, EditSession editSession, InjectedValueAccess context,
public void deform(Actor actor, LocalSession session, EditSession editSession, InjectedValueAccess context,
@Selection Region region,
@Arg(desc = "The expression to use", variable = true)
List<String> expression,
@ -592,7 +591,7 @@ public class RegionCommands {
zero = Vector3.ZERO;
unit = Vector3.ONE;
} else if (offset) {
zero = session.getPlacementPosition(player).toVector3();
zero = session.getPlacementPosition(actor).toVector3();
unit = Vector3.ONE;
} else {
final Vector3 min = region.getMinimumPoint().toVector3();
@ -607,13 +606,15 @@ public class RegionCommands {
}
final Vector3 unit1 = unit;
player.checkConfirmationRegion(() -> {
actor.checkConfirmationRegion(() -> {
try {
final int affected = editSession.deformRegion(region, zero, unit1, String.join(" ", expression), session.getTimeout());
player.findFreePosition();
BBC.VISITOR_BLOCK.send(player, affected);
if (actor instanceof Player) {
((Player) actor).findFreePosition();
}
BBC.VISITOR_BLOCK.send(actor, affected);
} catch (ExpressionException e) {
player.printError(e.getMessage());
actor.printError(e.getMessage());
}
}, getArguments(context), region, context);
}
@ -665,19 +666,19 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.hollow")
@Logging(REGION)
public void hollow(Player fp, EditSession editSession,
public void hollow(Actor actor, EditSession editSession,
@Selection Region region,
@Range(min = 0) @Arg(desc = "Thickness of the shell to leave", def = "0")
int thickness,
@Arg(name = "pattern", desc = "The pattern of blocks to replace the hollowed area with", def = "air")
Pattern patternArgOpt,
@Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air")
Pattern pattern,
@ArgFlag(name = 'm', desc = "Mask to hollow with") Mask mask,
InjectedValueAccess context) throws WorldEditException {
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask;
fp.checkConfirmationRegion(() -> {
int affected = editSession.hollowOutRegion(region, thickness, patternArgOpt, finalMask);
BBC.VISITOR_BLOCK.send(fp, affected);
actor.checkConfirmationRegion(() -> {
int affected = editSession.hollowOutRegion(region, thickness, pattern, finalMask);
BBC.VISITOR_BLOCK.send(actor, affected);
}, getArguments(context), region, context);
}
@ -704,18 +705,18 @@ public class RegionCommands {
)
@CommandPermissions("worldedit.region.flora")
@Logging(REGION)
public void flora(Player fp, EditSession editSession, @Selection Region region,
public void flora(Actor actor, EditSession editSession, @Selection Region region,
@Arg(desc = "The density of the forest", def = "5")
double density, InjectedValueAccess context) throws WorldEditException {
checkCommandArgument(0 <= density && density <= 100, "Density must be in [0, 100]");
fp.checkConfirmationRegion(() -> {
actor.checkConfirmationRegion(() -> {
FloraGenerator generator = new FloraGenerator(editSession);
GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);
LayerVisitor visitor = new LayerVisitor(asFlatRegion(region), minimumBlockY(region), maximumBlockY(region), ground);
visitor.setMask(new NoiseFilter2D(new RandomNoise(), density / 100));
Operations.completeLegacy(visitor);
BBC.COMMAND_FLORA.send(fp, ground.getAffected());
BBC.COMMAND_FLORA.send(actor, ground.getAffected());
}, "/flora", region, context);
}

View File

@ -19,6 +19,10 @@
package com.sk89q.worldedit.command;
import static com.boydti.fawe.util.ReflectionUtils.as;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
@ -59,16 +63,6 @@ import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.util.io.Closer;
import com.sk89q.worldedit.util.io.file.FilenameException;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.ArgFlag;
import org.enginehub.piston.annotation.param.Switch;
import org.enginehub.piston.exception.StopExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
@ -91,10 +85,14 @@ import java.util.Map;
import java.util.UUID;
import java.util.concurrent.Callable;
import java.util.regex.Pattern;
import static com.boydti.fawe.util.ReflectionUtils.as;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.ArgFlag;
import org.enginehub.piston.annotation.param.Switch;
import org.enginehub.piston.exception.StopExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
//import com.boydti.fawe.object.schematic.visualizer.SchemVis;
@ -579,15 +577,17 @@ public class SchematicCommands {
descFooter = "Note: Format is not fully verified until loading."
)
@CommandPermissions("worldedit.schematic.list")
public void list(Actor actor, LocalSession session, @Arg(name = "filter", desc = "Filter for schematics", def = "all")
String filter, @ArgFlag(name = 'f', desc = "Restricts by format.", def = "")
String formatName,
public void list(Actor actor, LocalSession session,
@ArgFlag(name = 'p', desc = "Page to view.", def = "-1")
int page,
@Switch(name = 'd', desc = "Sort by date, oldest first")
boolean oldFirst,
@Switch(name = 'n', desc = "Sort by date, newest first")
boolean newFirst,
@ArgFlag(name = 'f', desc = "Restricts by format.")
String formatName,
@Arg(name = "filter", desc = "Filter for schematics", def = "all")
String filter,
Arguments arguments
) throws WorldEditException {
if (oldFirst && newFirst) {

View File

@ -117,7 +117,7 @@ public class SelectionCommands {
}
if (!session.getRegionSelector(world).selectPrimary(pos.toBlockPoint(), ActorSelectorLimits.forActor(actor))) {
actor.print(BBC.SELECTOR_ALREADY_SET.s());
actor.printError(BBC.SELECTOR_ALREADY_SET.s());
return;
}
@ -146,7 +146,7 @@ public class SelectionCommands {
}
if (!session.getRegionSelector(world).selectSecondary(pos.toBlockPoint(), ActorSelectorLimits.forActor(actor))) {
actor.print(BBC.SELECTOR_ALREADY_SET.s());
actor.printError(BBC.SELECTOR_ALREADY_SET.s());
return;
}
@ -165,14 +165,14 @@ public class SelectionCommands {
if (pos != null) {
if (!session.getRegionSelector(player.getWorld()).selectPrimary(pos.toBlockPoint(), ActorSelectorLimits.forActor(player))) {
player.print(BBC.SELECTOR_ALREADY_SET.s());
player.printError(BBC.SELECTOR_ALREADY_SET.s());
return;
}
session.getRegionSelector(player.getWorld())
.explainPrimarySelection(player, session, pos.toBlockPoint());
} else {
player.print(BBC.NO_BLOCK.s());
player.printError(BBC.NO_BLOCK.s());
}
}
@ -187,14 +187,14 @@ public class SelectionCommands {
if (pos != null) {
if (!session.getRegionSelector(player.getWorld()).selectSecondary(pos.toBlockPoint(), ActorSelectorLimits.forActor(player))) {
player.print(BBC.SELECTOR_ALREADY_SET.s());
player.printError(BBC.SELECTOR_ALREADY_SET.s());
return;
}
session.getRegionSelector(player.getWorld())
.explainSecondarySelection(player, session, pos.toBlockPoint());
} else {
player.print(BBC.NO_BLOCK.s());
player.printError(BBC.NO_BLOCK.s());
}
}

View File

@ -76,7 +76,7 @@ public class SnapshotCommands {
LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) {
BBC.SNAPSHOT_NOT_CONFIGURED.send(actor);
actor.printError(BBC.SNAPSHOT_NOT_CONFIGURED.s());
return;
}
@ -86,7 +86,7 @@ public class SnapshotCommands {
if (!snapshots.isEmpty()) {
actor.print(new SnapshotListBox(world.getName(), snapshots).create(page));
} else {
BBC.SNAPSHOT_NOT_AVAILABLE.send(actor);
actor.printError(BBC.SNAPSHOT_NOT_AVAILABLE.s());
// Okay, let's toss some debugging information!
File dir = config.snapshotRepo.getDirectory();
@ -101,7 +101,7 @@ public class SnapshotCommands {
}
}
} catch (MissingWorldException ex) {
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(actor);
actor.printError(BBC.SNAPSHOT_NOT_FOUND_WORLD.s());
}
}
@ -117,7 +117,7 @@ public class SnapshotCommands {
LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) {
BBC.SNAPSHOT_NOT_CONFIGURED.send(actor);
actor.printError(BBC.SNAPSHOT_NOT_CONFIGURED.s());
return;
}
@ -128,19 +128,19 @@ public class SnapshotCommands {
if (snapshot != null) {
session.setSnapshot(null);
BBC.SNAPSHOT_NEWEST.send(actor);
actor.print(BBC.SNAPSHOT_NEWEST.s());
} else {
BBC.SNAPSHOT_NOT_FOUND.send(actor);
actor.printError(BBC.SNAPSHOT_NOT_FOUND.s());
}
} catch (MissingWorldException ex) {
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(actor);
actor.printError(BBC.SNAPSHOT_NOT_FOUND_WORLD.s());
}
} else {
try {
session.setSnapshot(config.snapshotRepo.getSnapshot(name));
BBC.SNAPSHOT_SET.send(actor, name);
} catch (InvalidSnapshotException e) {
BBC.SNAPSHOT_NOT_AVAILABLE.send(actor);
actor.printError(BBC.SNAPSHOT_NOT_AVAILABLE.s());
}
}
}
@ -150,36 +150,36 @@ public class SnapshotCommands {
desc = "Choose the snapshot based on the list id"
)
@CommandPermissions("worldedit.snapshots.restore")
public void sel(Player player, LocalSession session,
public void sel(Actor actor, World world, LocalSession session,
@Arg(desc = "The list ID to select")
int index) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) {
BBC.SNAPSHOT_NOT_CONFIGURED.send(player);
actor.printError(BBC.SNAPSHOT_NOT_CONFIGURED.s());
return;
}
if (index < 1) {
BBC.SNAPSHOT_INVALID_INDEX.send(player);
actor.printError(BBC.SNAPSHOT_INVALID_INDEX.s());
return;
}
try {
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName());
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, world.getName());
if (snapshots.size() < index) {
player.printError("Invalid index, must be between 1 and " + snapshots.size() + ".");
actor.printError("Invalid index, must be between 1 and " + snapshots.size() + ".");
return;
}
Snapshot snapshot = snapshots.get(index - 1);
if (snapshot == null) {
BBC.SNAPSHOT_NOT_AVAILABLE.send(player);
actor.printError(BBC.SNAPSHOT_NOT_AVAILABLE.s());
return;
}
session.setSnapshot(snapshot);
BBC.SNAPSHOT_SET.send(player, snapshot.getName());
BBC.SNAPSHOT_SET.send(actor, snapshot.getName());
} catch (MissingWorldException e) {
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player);
actor.printError(BBC.SNAPSHOT_NOT_FOUND_WORLD.s());
}
}
@ -188,29 +188,29 @@ public class SnapshotCommands {
desc = "Choose the nearest snapshot before a date"
)
@CommandPermissions("worldedit.snapshots.restore")
public void before(Player player, LocalSession session,
public void before(Actor actor, World world, LocalSession session,
@Arg(desc = "The soonest date that may be used")
ZonedDateTime date) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) {
BBC.SNAPSHOT_NOT_CONFIGURED.send(player);
actor.printError(BBC.SNAPSHOT_NOT_CONFIGURED.s());
return;
}
try {
Snapshot snapshot = config.snapshotRepo.getSnapshotBefore(date, player.getWorld().getName());
Snapshot snapshot = config.snapshotRepo.getSnapshotBefore(date, world.getName());
if (snapshot == null) {
player.printError("Couldn't find a snapshot before "
actor.printError("Couldn't find a snapshot before "
+ dateFormat.withZone(session.getTimeZone()).format(date) + ".");
} else {
session.setSnapshot(snapshot);
BBC.SNAPSHOT_SET.send(player, snapshot.getName());
BBC.SNAPSHOT_SET.send(actor, snapshot.getName());
}
} catch (MissingWorldException ex) {
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player);
actor.printError(BBC.SNAPSHOT_NOT_FOUND_WORLD.s());
}
}
@ -219,28 +219,28 @@ public class SnapshotCommands {
desc = "Choose the nearest snapshot after a date"
)
@CommandPermissions("worldedit.snapshots.restore")
public void after(Player player, LocalSession session,
public void after(Actor actor, World world, LocalSession session,
@Arg(desc = "The soonest date that may be used")
ZonedDateTime date) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) {
BBC.SNAPSHOT_NOT_CONFIGURED.send(player);
actor.printError(BBC.SNAPSHOT_NOT_CONFIGURED.s());
return;
}
try {
Snapshot snapshot = config.snapshotRepo.getSnapshotAfter(date, player.getWorld().getName());
Snapshot snapshot = config.snapshotRepo.getSnapshotAfter(date, world.getName());
if (snapshot == null) {
player.printError("Couldn't find a snapshot after "
actor.printError("Couldn't find a snapshot after "
+ dateFormat.withZone(session.getTimeZone()).format(date) + ".");
} else {
session.setSnapshot(snapshot);
BBC.SNAPSHOT_SET.send(player, snapshot.getName());
actor.print("Snapshot set to: " + snapshot.getName());
}
} catch (MissingWorldException ex) {
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player);
actor.printError(BBC.SNAPSHOT_NOT_FOUND_WORLD.s());
}
}

View File

@ -68,7 +68,7 @@ public class SnapshotUtilCommands {
LocalConfiguration config = we.getConfiguration();
if (config.snapshotRepo == null) {
BBC.SNAPSHOT_NOT_CONFIGURED.send(actor);
actor.printError(BBC.SNAPSHOT_NOT_CONFIGURED.s());
return;
}
@ -79,7 +79,7 @@ public class SnapshotUtilCommands {
try {
snapshot = config.snapshotRepo.getSnapshot(snapshotName);
} catch (InvalidSnapshotException e) {
BBC.SNAPSHOT_NOT_AVAILABLE.send(actor);
actor.printError(BBC.SNAPSHOT_NOT_AVAILABLE.s());
return;
}
} else {
@ -92,7 +92,7 @@ public class SnapshotUtilCommands {
snapshot = config.snapshotRepo.getDefaultSnapshot(world.getName());
if (snapshot == null) {
BBC.SNAPSHOT_NOT_AVAILABLE.send(actor);
actor.printError(BBC.SNAPSHOT_NOT_AVAILABLE.s());
// Okay, let's toss some debugging information!
File dir = config.snapshotRepo.getDirectory();
@ -109,7 +109,7 @@ public class SnapshotUtilCommands {
return;
}
} catch (MissingWorldException ex) {
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(actor);
actor.printError(BBC.SNAPSHOT_NOT_FOUND_WORLD.s());
return;
}
}
@ -128,15 +128,16 @@ public class SnapshotUtilCommands {
if (restore.hadTotalFailure()) {
String error = restore.getLastErrorMessage();
if (!restore.getMissingChunks().isEmpty()) {
BBC.SNAPSHOT_ERROR_RESTORE.send(actor);
actor.printError(BBC.SNAPSHOT_ERROR_RESTORE.s());
} else if (error != null) {
actor.printError("Errors prevented any blocks from being restored.");
actor.printError("Last error: " + error);
} else {
BBC.SNAPSHOT_ERROR_RESTORE_CHUNKS.send(actor);
actor.printError(BBC.SNAPSHOT_ERROR_RESTORE_CHUNKS.s());
}
} else {
actor.print(String.format("Restored; %d missing chunks and %d other errors.",
actor.print(String.format("Restored; %d "
+ "missing chunks and %d other errors.",
restore.getMissingChunks().size(),
restore.getErrorChunks().size()));
}

View File

@ -50,7 +50,7 @@ public class SuperPickaxeCommands {
public void single(Player player, LocalSession session) throws WorldEditException {
session.setSuperPickaxe(new SinglePickaxe());
session.enableSuperPickAxe();
BBC.SUPERPICKAXE_AREA_ENABLED.send(player);
player.print(BBC.SUPERPICKAXE_AREA_ENABLED.s());
}
@Command(
@ -71,7 +71,7 @@ public class SuperPickaxeCommands {
session.setSuperPickaxe(new AreaPickaxe(range));
session.enableSuperPickAxe();
BBC.SUPERPICKAXE_AREA_ENABLED.send(player);
player.print(BBC.SUPERPICKAXE_AREA_ENABLED.s());
}
@Command(
@ -93,6 +93,6 @@ public class SuperPickaxeCommands {
session.setSuperPickaxe(new RecursivePickaxe(range));
session.enableSuperPickAxe();
BBC.SUPERPICKAXE_AREA_ENABLED.send(player);
player.print(BBC.SUPERPICKAXE_AREA_ENABLED.s());
}
}

View File

@ -82,7 +82,7 @@ public class ToolUtilCommands {
return;
}
if (maskOpt == null) {
BBC.BRUSH_MASK_DISABLED.send(player);
player.print(BBC.BRUSH_MASK_DISABLED.s());
tool.setMask(null);
return;
}
@ -91,7 +91,7 @@ public class ToolUtilCommands {
settings.addSetting(BrushSettings.SettingType.MASK, lastArg);
settings.setMask(maskOpt);
tool.update();
BBC.BRUSH_MASK.send(player);
player.print(BBC.BRUSH_MASK.s());
}
@Command(
@ -101,7 +101,8 @@ public class ToolUtilCommands {
)
@CommandPermissions("worldedit.brush.options.material")
public void material(Player player, LocalSession session,
@Arg(desc = "brush material pattern", def = "") Pattern patternOpt,
@Arg(desc = "The pattern of blocks to use")
Pattern pattern,
@Switch(name = 'h', desc = "TODO")
boolean offHand,
Arguments arguments) throws WorldEditException {
@ -110,17 +111,17 @@ public class ToolUtilCommands {
player.print(BBC.BRUSH_NONE.s());
return;
}
if (patternOpt == null) {
BBC.BRUSH_MATERIAL.send(player);
if (pattern == null) {
player.print(BBC.BRUSH_MATERIAL.s());
tool.setFill(null);
return;
}
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
settings.setFill(patternOpt);
settings.setFill(pattern);
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
settings.addSetting(BrushSettings.SettingType.FILL, lastArg);
tool.update();
BBC.BRUSH_MATERIAL.send(player);
player.print(BBC.BRUSH_MATERIAL.s());
}
@Command(
@ -129,7 +130,7 @@ public class ToolUtilCommands {
)
@CommandPermissions("worldedit.brush.options.range")
public void range(Player player, LocalSession session,
@Arg(desc = "Range")
@Arg(desc = "The range of the brush")
int range) throws WorldEditException {
range = Math.max(0, Math.min(256, range));
BrushTool tool = session.getBrushTool(player, false);
@ -138,7 +139,7 @@ public class ToolUtilCommands {
return;
}
tool.setRange(range);
BBC.BRUSH_RANGE.send(player);
player.print(BBC.BRUSH_RANGE.s());
}
@Command(
@ -148,19 +149,19 @@ public class ToolUtilCommands {
@CommandPermissions("worldedit.brush.options.size")
public void size(Player player, LocalSession session,
@Arg(desc = "The size of the brush", def = "5")
int radius,
int size,
@Switch(name = 'h', desc = "TODO")
boolean offHand) throws WorldEditException {
we.checkMaxBrushRadius(radius);
we.checkMaxBrushRadius(size);
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
player.print(BBC.BRUSH_NONE.s());
return;
}
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
settings.setSize(radius);
settings.setSize(size);
tool.update();
BBC.BRUSH_SIZE.send(player);
player.print(BBC.BRUSH_SIZE.s());
}
@Command(
@ -174,13 +175,14 @@ public class ToolUtilCommands {
Mask maskOpt) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
BBC.BRUSH_NONE.send(player);
player.print(BBC.BRUSH_NONE.s());
return;
}
tool.setTraceMask(maskOpt);
BBC.BRUSH_TARGET_MASK_SET.send(player, maskOpt.toString());
}
//todo none should be moved to the same class where it is in upstream
@Command(
name = "none",
aliases = {"/none"},
@ -269,11 +271,13 @@ public class ToolUtilCommands {
"2 = Glass showing what blocks will be changed"
)
@CommandPermissions("worldedit.brush.visualize")
public void visual(Player player, LocalSession session, @Arg(name = "mode", desc = "int", def = "0") @Range(min = 0, max = 2) int mode)
public void visual(Player player, LocalSession session,
@Arg(name = "mode", desc = "int", def = "0") @Range(min = 0, max = 2)
int mode)
throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
BBC.BRUSH_NONE.send(player);
player.print(BBC.BRUSH_NONE.s());
return;
}
VisualMode[] modes = VisualMode.values();
@ -292,7 +296,7 @@ public class ToolUtilCommands {
@Arg(name = "mode", desc = "int", def = "0") int mode) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
BBC.BRUSH_NONE.send(player);
player.print(BBC.BRUSH_NONE.s());
return;
}
TargetMode[] modes = TargetMode.values();
@ -311,7 +315,7 @@ public class ToolUtilCommands {
int offset) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
BBC.BRUSH_NONE.send(player);
player.print(BBC.BRUSH_NONE.s());
return;
}
tool.setTargetOffset(offset);
@ -333,7 +337,7 @@ public class ToolUtilCommands {
// TODO NOT IMPLEMENTED Convert ScrollAction to an argument converter
BrushTool bt = session.getBrushTool(player, false);
if (bt == null) {
BBC.BRUSH_NONE.send(player);
player.print(BBC.BRUSH_NONE.s());
return;
}
BrushSettings settings = offHand ? bt.getOffHand() : bt.getContext();
@ -369,7 +373,7 @@ public class ToolUtilCommands {
return;
}
if (maskArg == null) {
BBC.BRUSH_SOURCE_MASK_DISABLED.send(player);
player.print(BBC.BRUSH_SOURCE_MASK_DISABLED.s());
tool.setSourceMask(null);
return;
}
@ -378,7 +382,7 @@ public class ToolUtilCommands {
settings.addSetting(BrushSettings.SettingType.SOURCE_MASK, lastArg);
settings.setSourceMask(maskArg);
tool.update();
BBC.BRUSH_SOURCE_MASK.send(player);
player.print(BBC.BRUSH_SOURCE_MASK.s());
}
@Command(
@ -397,7 +401,7 @@ public class ToolUtilCommands {
return;
}
if (transform == null) {
BBC.BRUSH_TRANSFORM_DISABLED.send(player);
player.print(BBC.BRUSH_TRANSFORM_DISABLED.s());
tool.setTransform(null);
return;
}
@ -406,6 +410,6 @@ public class ToolUtilCommands {
settings.addSetting(BrushSettings.SettingType.TRANSFORM, lastArg);
settings.setTransform(transform);
tool.update();
BBC.BRUSH_TRANSFORM.send(player);
player.print(BBC.BRUSH_TRANSFORM.s());
}
}

View File

@ -1,5 +1,8 @@
package com.sk89q.worldedit.entity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public interface Metadatable {
/**
@ -13,36 +16,43 @@ public interface Metadatable {
<T> T getAndSetMeta(String key, T value);
/**
* Checks if the object contains any metadata.
*
* @return {@code true} if there is metadata set for the object
*/
boolean hasMeta();
/**
* Get the metadata for a key.
* Gets the metadata value to which the specified key is mapped,
* or {@code null} if the key is not set.
*
* @param <V>
* @param key
* @return
* @param key the key of the metadata value to retrieve
* @return the value of the metadata or {@code null} if none exists
*/
<V> V getMeta(String key);
/**
* Get the metadata for a specific key (or return the default provided)
* Gets the metadata value to which the specified key is mapped,
* or the default value if no metadata exists for the key.
*
* @param key
* @param def
* @param <V>
* @return
* @param key the key of the metadata value to retrieve
* @param defaultValue the value to return if there is no metadata for the given key
* @return the metadata value for the key, if present; else the default value
*/
default <V> V getMeta(String key, V def) {
@NotNull
default <V> V getMeta(String key, @NotNull V defaultValue) {
V value = (V) getMeta(key);
return value == null ? def : value; }
return value == null ? defaultValue : value; }
/**
* Delete the metadata for a key.
* - metadata is session only
* - deleting other plugin's metadata may cause issues
* Deletes the given metadata key from object. Do not delete metadata set by another plugin
* unless you know what you are doing.
*
* @param key
* @param key the key identifying the metadata to remove.
* @return the previous value associated with they given key
*/
@Nullable
<V> V deleteMeta(String key);
final class METADATA_KEYS {

View File

@ -19,11 +19,10 @@
package com.sk89q.worldedit.extent;
import com.boydti.fawe.beta.IBatchProcessor;
import com.boydti.fawe.object.HistoryExtent;
import com.boydti.fawe.object.changeset.FaweChangeSet;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.beta.IBatchProcessor;
import com.boydti.fawe.object.changeset.FaweChangeSet;
import com.boydti.fawe.object.clipboard.WorldCopyClipboard;
import com.boydti.fawe.object.exception.FaweException;
import com.sk89q.worldedit.MaxChangedBlocksException;
@ -142,9 +141,10 @@ public interface Extent extends InputExtent, OutputExtent {
/**
* Create an entity at the given location.
*
* @param entity the entity
* @param location the location
* @return a reference to the created entity, or null if the entity could not be created
* @param x the x coordinate
* @param y the y coordinate
* @param z the z coordinate
* @param uuid the unique identifier of the entity
*/
default @Nullable void removeEntity(int x, int y, int z, UUID uuid) {}

View File

@ -104,18 +104,18 @@ public interface ClipboardFormat {
Set<String> getFileExtensions();
/**
* Set the player's clipboard
* @param player
* Set the actor's clipboard
* @param actor
* @param uri
* @param in
* @throws IOException
* @param inputStream the input stream
* @throws IOException thrown on I/O error
*/
default URIClipboardHolder hold(Actor actor, URI uri, InputStream in) throws IOException {
default URIClipboardHolder hold(Actor actor, URI uri, InputStream inputStream) throws IOException {
checkNotNull(actor);
checkNotNull(uri);
checkNotNull(in);
checkNotNull(inputStream);
final ClipboardReader reader = getReader(in);
final ClipboardReader reader = getReader(inputStream);
final Clipboard clipboard;