mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
fix some more compilation issues
This commit is contained in:
@ -11,7 +11,11 @@ import com.boydti.fawe.object.extent.ResettableExtent;
|
||||
import com.boydti.fawe.object.io.PGZIPOutputStream;
|
||||
import com.boydti.fawe.util.MainUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.sk89q.worldedit.command.argument.Arguments;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.internal.command.CommandArgParser;
|
||||
import org.enginehub.piston.annotation.Command;
|
||||
import org.enginehub.piston.annotation.CommandContainer;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
@ -44,6 +48,7 @@ import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.util.List;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
/**
|
||||
@ -194,12 +199,12 @@ public class BrushOptionsCommands {
|
||||
descFooter = "Set the right click brush"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.primary")
|
||||
public void primary(Player player, LocalSession session, InjectedValueAccess args)
|
||||
throws WorldEditException {
|
||||
public void primary(Player player, LocalSession session,
|
||||
@Arg(desc = "The brush command", variable = true) List<String> command) throws WorldEditException {
|
||||
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
session.setTool(item, null, player);
|
||||
String cmd = "brush " + args.getJoinedStrings(0);
|
||||
String cmd = "brush " + StringMan.join(command, " ");
|
||||
CommandEvent event = new CommandEvent(player, cmd);
|
||||
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
BrushTool newTool = session.getBrushTool(item, player, false);
|
||||
@ -214,12 +219,13 @@ public class BrushOptionsCommands {
|
||||
descFooter = "Set the left click brush"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.secondary")
|
||||
public void secondary(Player player, LocalSession session, InjectedValueAccess args)
|
||||
public void secondary(Player player, LocalSession session,
|
||||
@Arg(desc = "The brush command", variable = true) List<String> command)
|
||||
throws WorldEditException {
|
||||
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
session.setTool(item, null, player);
|
||||
String cmd = "brush " + args.getJoinedStrings(0);
|
||||
String cmd = "brush " + StringMan.join(command, " ");
|
||||
CommandEvent event = new CommandEvent(player, cmd);
|
||||
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
|
||||
BrushTool newTool = session.getBrushTool(item, player, false);
|
||||
@ -276,21 +282,14 @@ public class BrushOptionsCommands {
|
||||
desc = "Set the targeting mask"
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.targetmask")
|
||||
public void targetMask(Player player, EditSession editSession, LocalSession session,
|
||||
InjectedValueAccess context) throws WorldEditException {
|
||||
public void targetMask(Player player, EditSession editSession, LocalSession session, Mask mask) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
BBC.BRUSH_NONE.send(player);
|
||||
return;
|
||||
}
|
||||
ParserContext parserContext = new ParserContext();
|
||||
parserContext.setActor(player);
|
||||
parserContext.setWorld(player.getWorld());
|
||||
parserContext.setSession(session);
|
||||
parserContext.setExtent(editSession);
|
||||
Mask mask = worldEdit.getMaskFactory().parseFromInput(context.getJoinedStrings(0), parserContext);
|
||||
tool.setTraceMask(mask);
|
||||
BBC.BRUSH_TARGET_MASK_SET.send(player, context.getJoinedStrings(0));
|
||||
BBC.BRUSH_TARGET_MASK_SET.send(player, mask.toString());
|
||||
}
|
||||
|
||||
@Command(
|
||||
@ -316,17 +315,20 @@ public class BrushOptionsCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.scroll")
|
||||
public void scroll(Player player, EditSession editSession, LocalSession session,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
@Arg(desc="Target Modes")
|
||||
String modes, InjectedValueAccess args) throws WorldEditException {
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
@Arg(desc="Target Modes")
|
||||
String modes,
|
||||
@Arg(desc = "The scroll action", variable = true)
|
||||
List<String> command) throws WorldEditException {
|
||||
// TODO NOT IMPLEMENTED Convert ScrollAction to an argument converter
|
||||
BrushTool bt = session.getBrushTool(player, false);
|
||||
if (bt == null) {
|
||||
BBC.BRUSH_NONE.send(player);
|
||||
return;
|
||||
}
|
||||
BrushSettings settings = offHand ? bt.getOffHand() : bt.getContext();
|
||||
ScrollAction action = ScrollAction.fromArguments(bt, player, session, args.getJoinedStrings(0), true);
|
||||
ScrollAction action = ScrollAction.fromArguments(bt, player, session, StringMan.join(command, " "), true);
|
||||
settings.setScrollAction(action);
|
||||
if (modes.equalsIgnoreCase("none")) {
|
||||
BBC.BRUSH_SCROLL_ACTION_UNSET.send(player);
|
||||
@ -344,27 +346,26 @@ public class BrushOptionsCommands {
|
||||
)
|
||||
@CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"})
|
||||
public void mask(Player player, LocalSession session, EditSession editSession,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand, InjectedValueAccess context)
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
@Arg(desc = "The destination mask", def = "")
|
||||
Mask mask,
|
||||
Arguments arguments)
|
||||
throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.f());
|
||||
return;
|
||||
}
|
||||
if (context.argsLength() == 0) {
|
||||
if (mask == null) {
|
||||
BBC.BRUSH_MASK_DISABLED.send(player);
|
||||
tool.setMask(null);
|
||||
return;
|
||||
}
|
||||
ParserContext parserContext = new ParserContext();
|
||||
parserContext.setActor(player);
|
||||
parserContext.setWorld(player.getWorld());
|
||||
parserContext.setSession(session);
|
||||
parserContext.setExtent(editSession);
|
||||
Mask mask = worldEdit.getMaskFactory().parseFromInput(context.getJoinedStrings(0), parserContext);
|
||||
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
||||
settings.addSetting(BrushSettings.SettingType.MASK, context.getString(context.argsLength() - 1));
|
||||
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
|
||||
System.out.println(lastArg + " TODO check this is not the whole command");
|
||||
settings.addSetting(BrushSettings.SettingType.MASK, lastArg);
|
||||
settings.setMask(mask);
|
||||
tool.update();
|
||||
BBC.BRUSH_MASK.send(player);
|
||||
@ -378,29 +379,24 @@ public class BrushOptionsCommands {
|
||||
)
|
||||
@CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"})
|
||||
public void smask(Player player, LocalSession session, EditSession editSession,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
InjectedValueAccess context) throws WorldEditException {
|
||||
@Arg(desc = "The destination mask", def = "")
|
||||
Mask mask,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
Arguments arguments) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.f());
|
||||
return;
|
||||
}
|
||||
if (context.argsLength() == 0) {
|
||||
if (mask == null) {
|
||||
BBC.BRUSH_SOURCE_MASK_DISABLED.send(player);
|
||||
tool.setSourceMask(null);
|
||||
return;
|
||||
}
|
||||
ParserContext parserContext = new ParserContext();
|
||||
parserContext.setActor(player);
|
||||
parserContext.setWorld(player.getWorld());
|
||||
parserContext.setSession(session);
|
||||
parserContext.setExtent(editSession);
|
||||
Mask mask = worldEdit.getMaskFactory()
|
||||
.parseFromInput(context.getJoinedStrings(0), parserContext);
|
||||
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
||||
settings.addSetting(BrushSettings.SettingType.SOURCE_MASK,
|
||||
context.getString(context.argsLength() - 1));
|
||||
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
|
||||
settings.addSetting(BrushSettings.SettingType.SOURCE_MASK, lastArg);
|
||||
settings.setSourceMask(mask);
|
||||
tool.update();
|
||||
BBC.BRUSH_SOURCE_MASK.send(player);
|
||||
@ -412,27 +408,23 @@ public class BrushOptionsCommands {
|
||||
)
|
||||
@CommandPermissions({"worldedit.brush.options.transform", "worldedit.transform.brush"})
|
||||
public void transform(Player player, LocalSession session, EditSession editSession,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
InjectedValueAccess context) throws WorldEditException {
|
||||
@Arg(desc = "The transform", def = "") ResettableExtent transform,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
Arguments arguments) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.f());
|
||||
return;
|
||||
}
|
||||
if (context.argsLength() == 0) {
|
||||
if (transform == null) {
|
||||
BBC.BRUSH_TRANSFORM_DISABLED.send(player);
|
||||
tool.setTransform(null);
|
||||
return;
|
||||
}
|
||||
ParserContext parserContext = new ParserContext();
|
||||
parserContext.setActor(player);
|
||||
parserContext.setWorld(player.getWorld());
|
||||
parserContext.setSession(session);
|
||||
parserContext.setExtent(editSession);
|
||||
ResettableExtent transform = Fawe.get().getTransformParser().parseFromInput(context.getJoinedStrings(0), parserContext);
|
||||
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
||||
settings.addSetting(BrushSettings.SettingType.TRANSFORM, context.getString(context.argsLength() - 1));
|
||||
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
|
||||
settings.addSetting(BrushSettings.SettingType.TRANSFORM, lastArg);
|
||||
settings.setTransform(transform);
|
||||
tool.update();
|
||||
BBC.BRUSH_TRANSFORM.send(player);
|
||||
@ -445,23 +437,24 @@ public class BrushOptionsCommands {
|
||||
)
|
||||
@CommandPermissions("worldedit.brush.options.material")
|
||||
public void material(Player player, EditSession editSession, LocalSession session,
|
||||
Pattern pattern,
|
||||
@Arg(desc = "brush material pattern", def = "") Pattern pattern,
|
||||
@Switch(name = 'h', desc = "TODO")
|
||||
boolean offHand,
|
||||
InjectedValueAccess context) throws WorldEditException {
|
||||
Arguments arguments) throws WorldEditException {
|
||||
BrushTool tool = session.getBrushTool(player, false);
|
||||
if (tool == null) {
|
||||
player.print(BBC.BRUSH_NONE.f());
|
||||
return;
|
||||
}
|
||||
if (context.argsLength() == 0) {
|
||||
BBC.BRUSH_TRANSFORM_DISABLED.send(player);
|
||||
if (pattern == null) {
|
||||
BBC.BRUSH_MATERIAL.send(player);
|
||||
tool.setFill(null);
|
||||
return;
|
||||
}
|
||||
BrushSettings settings = offHand ? tool.getOffHand() : tool.getContext();
|
||||
settings.setFill(pattern);
|
||||
settings.addSetting(BrushSettings.SettingType.FILL, context.getString(context.argsLength() - 1));
|
||||
String lastArg = Iterables.getLast(CommandArgParser.spaceSplit(arguments.get())).getSubstring();
|
||||
settings.addSetting(BrushSettings.SettingType.FILL, lastArg);
|
||||
tool.update();
|
||||
BBC.BRUSH_MATERIAL.send(player);
|
||||
}
|
||||
|
@ -27,7 +27,9 @@ import com.boydti.fawe.util.CachedTextureUtil;
|
||||
import com.boydti.fawe.util.CleanTextureUtil;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.boydti.fawe.util.RandomTextureUtil;
|
||||
import com.boydti.fawe.util.StringMan;
|
||||
import com.boydti.fawe.util.TextureUtil;
|
||||
import com.sk89q.worldedit.extension.input.InputParseException;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalConfiguration;
|
||||
@ -297,26 +299,28 @@ public class GeneralCommands {
|
||||
desc = "Set the global mask"
|
||||
)
|
||||
@CommandPermissions("worldedit.global-texture")
|
||||
public void gtexture(FawePlayer player, LocalSession session, EditSession editSession, @Arg(name = "context", desc = "InjectedValueAccess", def = "") InjectedValueAccess context) throws WorldEditException, FileNotFoundException, ParameterException {
|
||||
if (context == null || context.argsLength() == 0) {
|
||||
public void gtexture(FawePlayer player, LocalSession session, EditSession editSession, @Arg(name = "context", desc = "InjectedValueAccess", def = "") List<String> arguments) throws WorldEditException, FileNotFoundException {
|
||||
// gtexture <randomize> <min=0> <max=100>
|
||||
// TODO NOT IMPLEMENTED convert this to an ArgumentConverter
|
||||
if (arguments.isEmpty()) {
|
||||
session.setTextureUtil(null);
|
||||
BBC.TEXTURE_DISABLED.send(player);
|
||||
} else {
|
||||
String arg = context.getString(0);
|
||||
String arg = arguments.get(0);
|
||||
String argLower = arg.toLowerCase();
|
||||
|
||||
TextureUtil util = Fawe.get().getTextureUtil();
|
||||
int randomIndex = 1;
|
||||
boolean checkRandomization = true;
|
||||
if (context.argsLength() >= 2 && MathMan.isInteger(context.getString(0)) && MathMan.isInteger(context.getString(1))) {
|
||||
if (arguments.size() >= 2 && MathMan.isInteger(arguments.get(0)) && MathMan.isInteger(arguments.get(1))) {
|
||||
// complexity
|
||||
int min = Integer.parseInt(context.getString(0));
|
||||
int max = Integer.parseInt(context.getString(1));
|
||||
if (min < 0 || max > 100) throw new ParameterException("Complexity must be in the range 0-100");
|
||||
int min = Integer.parseInt(arguments.get(0));
|
||||
int max = Integer.parseInt(arguments.get(1));
|
||||
if (min < 0 || max > 100) throw new InputParseException("Complexity must be in the range 0-100");
|
||||
if (min != 0 || max != 100) util = new CleanTextureUtil(util, min, max);
|
||||
|
||||
randomIndex = 2;
|
||||
} else if (context.argsLength() == 1 && argLower.equals("true") || argLower.equals("false")) {
|
||||
} else if (arguments.size() == 1 && argLower.equals("true") || argLower.equals("false")) {
|
||||
if (argLower.equals("true")) util = new RandomTextureUtil(util);
|
||||
checkRandomization = false;
|
||||
} else {
|
||||
@ -337,14 +341,14 @@ public class GeneralCommands {
|
||||
}
|
||||
}
|
||||
if (checkRandomization) {
|
||||
if (context.argsLength() > randomIndex) {
|
||||
boolean random = Boolean.parseBoolean(context.getString(randomIndex));
|
||||
if (arguments.size() > randomIndex) {
|
||||
boolean random = Boolean.parseBoolean(arguments.get(randomIndex));
|
||||
if (random) util = new RandomTextureUtil(util);
|
||||
}
|
||||
}
|
||||
if (!(util instanceof CachedTextureUtil)) util = new CachedTextureUtil(util);
|
||||
session.setTextureUtil(util);
|
||||
BBC.TEXTURE_SET.send(player, context.getJoinedStrings(0));
|
||||
BBC.TEXTURE_SET.send(player, StringMan.join(arguments, " "));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,28 +19,11 @@
|
||||
|
||||
package com.sk89q.worldedit.command;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.ORIENTATION_REGION;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
||||
import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument;
|
||||
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
|
||||
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
||||
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.beta.IQueueExtent;
|
||||
import com.boydti.fawe.beta.filters.DistrFilter;
|
||||
import com.boydti.fawe.beta.filters.SetFilter;
|
||||
import com.boydti.fawe.beta.implementation.QueueHandler;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.object.FaweLimit;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.exception.FaweException;
|
||||
import com.boydti.fawe.object.visitor.Fast2DIterator;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
@ -50,7 +33,6 @@ import com.sk89q.worldedit.command.util.CommandPermissions;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
|
||||
import com.sk89q.worldedit.command.util.Logging;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Capability;
|
||||
import com.sk89q.worldedit.function.GroundFunction;
|
||||
import com.sk89q.worldedit.function.generator.FloraGenerator;
|
||||
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
|
||||
@ -78,23 +60,27 @@ import com.sk89q.worldedit.regions.RegionOperationException;
|
||||
import com.sk89q.worldedit.regions.Regions;
|
||||
import com.sk89q.worldedit.util.Location;
|
||||
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
|
||||
import com.sk89q.worldedit.world.World;
|
||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import com.sk89q.worldedit.world.biome.BiomeTypes;
|
||||
import com.sk89q.worldedit.world.biome.Biomes;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.registry.BiomeRegistry;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
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.Switch;
|
||||
import org.enginehub.piston.inject.InjectedValueAccess;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.ALL;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.ORIENTATION_REGION;
|
||||
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
|
||||
import static com.sk89q.worldedit.internal.command.CommandUtil.checkCommandArgument;
|
||||
import static com.sk89q.worldedit.regions.Regions.asFlatRegion;
|
||||
import static com.sk89q.worldedit.regions.Regions.maximumBlockY;
|
||||
import static com.sk89q.worldedit.regions.Regions.minimumBlockY;
|
||||
|
||||
/**
|
||||
* Commands that operate on regions.
|
||||
*/
|
||||
@ -113,39 +99,6 @@ public class RegionCommands extends MethodCommands {
|
||||
this.worldEdit = worldEdit;
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
name = "debugtest",
|
||||
desc = "debugtest"
|
||||
)
|
||||
@CommandPermissions("fawe.admin.debug")
|
||||
public void debugtest(Player player, @Selection Region region) throws WorldEditException {
|
||||
QueueHandler queueHandler = Fawe.get().getQueueHandler();
|
||||
World world = player.getWorld();
|
||||
DistrFilter filter = new DistrFilter();
|
||||
long start = System.currentTimeMillis();
|
||||
queueHandler.apply(world, region, filter);
|
||||
long diff = System.currentTimeMillis() - start;
|
||||
System.out.println(diff);
|
||||
}
|
||||
|
||||
@Command(
|
||||
name = "db2",
|
||||
desc = "db2"
|
||||
)
|
||||
@CommandPermissions("fawe.admin.debug")
|
||||
public void db2(Player player, @Selection Region region, String blockStr) throws WorldEditException {
|
||||
QueueHandler queueHandler = Fawe.get().getQueueHandler();
|
||||
World world = player.getWorld();
|
||||
BlockState block = BlockState.get(blockStr);
|
||||
SetFilter filter = new SetFilter(block);
|
||||
long start = System.currentTimeMillis();
|
||||
queueHandler.apply(world, region, filter);
|
||||
long diff = System.currentTimeMillis() - start;
|
||||
System.out.println(diff);
|
||||
}
|
||||
|
||||
|
||||
@Command(
|
||||
name = "/fixlighting",
|
||||
desc = "Get the light at a position"
|
||||
@ -366,7 +319,7 @@ public class RegionCommands extends MethodCommands {
|
||||
BlockVector3 max = region.getMaximumPoint();
|
||||
int maxY = max.getBlockY();
|
||||
Iterable<BlockVector2> flat = Regions.asFlatRegion(region).asFlatRegion();
|
||||
Iterator<BlockVector2> iter = new Fast2DIterator(flat, editSession).iterator();
|
||||
Iterator<BlockVector2> iter = flat.iterator();
|
||||
int y = 0;
|
||||
int affected = 0;
|
||||
while (iter.hasNext()) {
|
||||
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.command.composition;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
import com.sk89q.worldedit.command.argument.RegionFunctionParser;
|
||||
import com.sk89q.worldedit.function.Contextual;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.factory.Apply;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.util.command.argument.CommandArgs;
|
||||
import com.sk89q.worldedit.util.command.composition.CommandExecutor;
|
||||
import com.sk89q.worldedit.util.command.composition.SimpleCommand;
|
||||
|
||||
public class ApplyCommand extends SimpleCommand<Contextual<? extends Operation>> {
|
||||
|
||||
private final CommandExecutor<Contextual<? extends RegionFunction>> functionParser;
|
||||
private final String description;
|
||||
|
||||
public ApplyCommand() {
|
||||
this(new RegionFunctionParser(), "Applies a function to every block");
|
||||
}
|
||||
|
||||
public ApplyCommand(CommandExecutor<Contextual<? extends RegionFunction>> functionParser, String description) {
|
||||
checkNotNull(functionParser, "functionParser");
|
||||
checkNotNull(description, "description");
|
||||
this.functionParser = functionParser;
|
||||
this.description = description;
|
||||
addParameter(functionParser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Apply call(CommandArgs args, CommandLocals locals) throws CommandException {
|
||||
Contextual<? extends RegionFunction> function = functionParser.call(args, locals);
|
||||
return new Apply(function);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean testPermission0(CommandLocals locals) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,84 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.command.composition;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
import com.sk89q.minecraft.util.commands.WrappedCommandException;
|
||||
import com.sk89q.worldedit.IncompleteRegionException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.argument.BooleanFlag;
|
||||
import com.sk89q.worldedit.command.argument.StringParser;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.function.Contextual;
|
||||
import com.sk89q.worldedit.function.factory.Deform;
|
||||
import com.sk89q.worldedit.function.factory.Deform.Mode;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.util.command.argument.CommandArgs;
|
||||
import com.sk89q.worldedit.util.command.composition.FlagParser.Flag;
|
||||
import com.sk89q.worldedit.util.command.composition.FlagParser.FlagData;
|
||||
import com.sk89q.worldedit.util.command.composition.SimpleCommand;
|
||||
|
||||
public class DeformCommand extends SimpleCommand<Contextual<? extends Operation>> {
|
||||
|
||||
private final Flag<Boolean> rawCoordsFlag = addFlag('r', new BooleanFlag("Raw coords mode"));
|
||||
private final Flag<Boolean> offsetFlag = addFlag('o', new BooleanFlag("Offset mode"));
|
||||
private final StringParser expressionParser = addParameter(new StringParser("expression", "Expression to apply", "y-=0.2"));
|
||||
|
||||
@Override
|
||||
public Deform call(CommandArgs args, CommandLocals locals) throws CommandException {
|
||||
FlagData flagData = getFlagParser().call(args, locals);
|
||||
String expression = expressionParser.call(args, locals);
|
||||
boolean rawCoords = rawCoordsFlag.get(flagData, false);
|
||||
boolean offset = offsetFlag.get(flagData, false);
|
||||
|
||||
Deform deform = new Deform(expression);
|
||||
|
||||
if (rawCoords) {
|
||||
deform.setMode(Mode.RAW_COORD);
|
||||
} else if (offset) {
|
||||
deform.setMode(Mode.OFFSET);
|
||||
Player player = (Player) locals.get(Actor.class);
|
||||
LocalSession session = WorldEdit.getInstance().getSessionManager().get(locals.get(Actor.class));
|
||||
try {
|
||||
deform.setOffset(session.getPlacementPosition(player).toVector3());
|
||||
} catch (IncompleteRegionException e) {
|
||||
throw new WrappedCommandException(e);
|
||||
}
|
||||
} else {
|
||||
deform.setMode(Mode.UNIT_CUBE);
|
||||
}
|
||||
|
||||
return deform;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Apply math expression to area";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean testPermission0(CommandLocals locals) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.command.composition;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
import com.sk89q.worldedit.command.argument.NumberParser;
|
||||
import com.sk89q.worldedit.command.argument.RegionFunctionParser;
|
||||
import com.sk89q.worldedit.function.Contextual;
|
||||
import com.sk89q.worldedit.function.RegionFunction;
|
||||
import com.sk89q.worldedit.function.factory.Paint;
|
||||
import com.sk89q.worldedit.util.command.argument.CommandArgs;
|
||||
import com.sk89q.worldedit.util.command.composition.CommandExecutor;
|
||||
import com.sk89q.worldedit.util.command.composition.SimpleCommand;
|
||||
|
||||
public class PaintCommand extends SimpleCommand<Paint> {
|
||||
|
||||
private final NumberParser densityCommand = addParameter(new NumberParser("density", "0-100", "20"));
|
||||
private final CommandExecutor<? extends Contextual<? extends RegionFunction>> functionParser;
|
||||
|
||||
public PaintCommand() {
|
||||
this(new RegionFunctionParser());
|
||||
}
|
||||
|
||||
public PaintCommand(CommandExecutor<? extends Contextual<? extends RegionFunction>> functionParser) {
|
||||
this.functionParser = functionParser;
|
||||
addParameter(functionParser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paint call(CommandArgs args, CommandLocals locals) throws CommandException {
|
||||
double density = densityCommand.call(args, locals).doubleValue() / 100.0;
|
||||
Contextual<? extends RegionFunction> function = functionParser.call(args, locals);
|
||||
return new Paint(function, density);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "Applies a function to surfaces";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean testPermission0(CommandLocals locals) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,102 +0,0 @@
|
||||
/*
|
||||
* WorldEdit, a Minecraft world manipulation toolkit
|
||||
* Copyright (C) sk89q <http://www.sk89q.com>
|
||||
* Copyright (C) WorldEdit team and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU Lesser General Public License as published by the
|
||||
* Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.command.composition;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.CommandException;
|
||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||
import com.sk89q.worldedit.command.util.CommandPermissionsException;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
import com.sk89q.worldedit.MaxBrushRadiusException;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.command.argument.NumberParser;
|
||||
import com.sk89q.worldedit.command.argument.RegionFactoryParser;
|
||||
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
|
||||
import com.sk89q.worldedit.command.tool.brush.OperationFactoryBrush;
|
||||
import com.sk89q.worldedit.entity.Player;
|
||||
import com.sk89q.worldedit.extension.platform.Actor;
|
||||
import com.sk89q.worldedit.function.Contextual;
|
||||
import com.sk89q.worldedit.function.operation.Operation;
|
||||
import com.sk89q.worldedit.regions.factory.RegionFactory;
|
||||
import com.sk89q.worldedit.util.command.argument.CommandArgs;
|
||||
import com.sk89q.worldedit.util.command.composition.CommandExecutor;
|
||||
import com.sk89q.worldedit.util.command.composition.SimpleCommand;
|
||||
|
||||
public class ShapedBrushCommand extends SimpleCommand<Object> {
|
||||
|
||||
private final CommandExecutor<? extends Contextual<? extends Operation>> delegate;
|
||||
private final String permission;
|
||||
|
||||
private final RegionFactoryParser regionFactoryParser = addParameter(new RegionFactoryParser());
|
||||
private final NumberParser radiusCommand = addParameter(new NumberParser("size", "The size of the brush", "5"));
|
||||
|
||||
public ShapedBrushCommand(CommandExecutor<? extends Contextual<? extends Operation>> delegate, String permission) {
|
||||
checkNotNull(delegate, "delegate");
|
||||
this.permission = permission;
|
||||
this.delegate = delegate;
|
||||
addParameter(delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object call(CommandArgs args, CommandLocals locals) throws CommandException {
|
||||
if (!testPermission(locals)) {
|
||||
throw new CommandPermissionsException();
|
||||
}
|
||||
|
||||
RegionFactory regionFactory = regionFactoryParser.call(args, locals);
|
||||
int radius = radiusCommand.call(args, locals).intValue();
|
||||
Contextual<? extends Operation> factory = delegate.call(args, locals);
|
||||
|
||||
Player player = (Player) locals.get(Actor.class);
|
||||
LocalSession session = WorldEdit.getInstance().getSessionManager().get(player);
|
||||
|
||||
try {
|
||||
WorldEdit.getInstance().checkMaxBrushRadius(radius);
|
||||
BrushTool tool = session.getBrushTool(player);
|
||||
tool.setSize(radius);
|
||||
tool.setFill(null);
|
||||
tool.setBrush(new OperationFactoryBrush(factory, regionFactory, session), permission);
|
||||
} catch (MaxBrushRadiusException | InvalidToolBindException e) {
|
||||
WorldEdit.getInstance().getPlatformManager().getPlatformCommandManager().getExceptionConverter().convert(e);
|
||||
}
|
||||
|
||||
player.print("Set brush to " + factory);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return delegate.getDescription();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testPermission0(CommandLocals locals) {
|
||||
Actor sender = locals.get(Actor.class);
|
||||
if (sender == null) {
|
||||
throw new RuntimeException("Uh oh! No 'Actor' specified so that we can check permissions");
|
||||
} else {
|
||||
return sender.hasPermission(permission);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -76,7 +76,7 @@ public class FloodFillTool implements BlockTool {
|
||||
try {
|
||||
Mask mask = initialType.toMask(editSession);
|
||||
BlockReplace function = new BlockReplace(editSession, pattern);
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(mask, function, range, editSession.getQueue());
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(mask, function, range);
|
||||
visitor.visit(origin);
|
||||
Operations.completeLegacy(visitor);
|
||||
} catch (MaxChangedBlocksException e) {
|
||||
|
@ -78,7 +78,7 @@ public class RecursivePickaxe implements BlockTool {
|
||||
final int radius = (int) range;
|
||||
final BlockReplace replace = new BlockReplace(editSession, (BlockTypes.AIR.getDefaultState()));
|
||||
editSession.setMask(null);
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(new IdMask(editSession), replace, radius, editSession);
|
||||
RecursiveVisitor visitor = new RecursiveVisitor(new IdMask(editSession), replace, radius);
|
||||
visitor.visit(pos);
|
||||
Operations.completeBlindly(visitor);
|
||||
|
||||
|
Reference in New Issue
Block a user