More work on getting commands to compile

This commit is contained in:
MattBDev 2019-07-21 22:49:08 -04:00
parent f5c202af6d
commit 9c3122a227
57 changed files with 1149 additions and 1144 deletions

View File

@ -4,9 +4,27 @@ import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FawePlayer;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.worldedit.extension.platform.PlatformCommandManager;
import com.sk89q.worldedit.util.command.parametric.ExceptionConverter;
import com.sk89q.worldedit.internal.command.exception.ExceptionConverter;
import com.thevoxelbox.voxelsniper.api.command.VoxelCommand;
import com.thevoxelbox.voxelsniper.command.*;
import com.thevoxelbox.voxelsniper.command.VoxelBrushCommand;
import com.thevoxelbox.voxelsniper.command.VoxelBrushToolCommand;
import com.thevoxelbox.voxelsniper.command.VoxelCenterCommand;
import com.thevoxelbox.voxelsniper.command.VoxelChunkCommand;
import com.thevoxelbox.voxelsniper.command.VoxelDefaultCommand;
import com.thevoxelbox.voxelsniper.command.VoxelGoToCommand;
import com.thevoxelbox.voxelsniper.command.VoxelHeightCommand;
import com.thevoxelbox.voxelsniper.command.VoxelInkCommand;
import com.thevoxelbox.voxelsniper.command.VoxelInkReplaceCommand;
import com.thevoxelbox.voxelsniper.command.VoxelListCommand;
import com.thevoxelbox.voxelsniper.command.VoxelPaintCommand;
import com.thevoxelbox.voxelsniper.command.VoxelPerformerCommand;
import com.thevoxelbox.voxelsniper.command.VoxelReplaceCommand;
import com.thevoxelbox.voxelsniper.command.VoxelSniperCommand;
import com.thevoxelbox.voxelsniper.command.VoxelUndoCommand;
import com.thevoxelbox.voxelsniper.command.VoxelUndoUserCommand;
import com.thevoxelbox.voxelsniper.command.VoxelVoxelCommand;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -14,9 +32,6 @@ import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import java.util.HashMap;
import java.util.Map;
public class VoxelSniperListener implements Listener {

View File

@ -17,7 +17,7 @@ public CloneStampBrush() {
/**
* The clone method is used to grab a snapshot of the selected area dictated blockPositionY targetBlock.x y z v.brushSize v.voxelHeight and v.cCen.
* <p/>
* x y z -- initial center of the selection v.brushSize -- the radius of the cylinder v.voxelHeight -- the heigth of the cylinder c.cCen -- the offset on
* x y z -- initial center of the selection v.brushSize -- the radius of the cylinder v.voxelHeight -- the height of the cylinder c.cCen -- the offset on
* the Y axis of the selection ( bottom of the cylinder ) as blockPositionY: Bottom_Y = targetBlock.y + v.cCen;
*
* @param v Sniper Caller
@ -71,7 +71,7 @@ public CloneStampBrush() {
}
}
}
v.sendMessage(ChatColor.GREEN + String.valueOf(this.clone.size()) + ChatColor.AQUA + " blocks copied sucessfully.");
v.sendMessage(ChatColor.GREEN + String.valueOf(this.clone.size()) + ChatColor.AQUA + " blocks copied successfully.");
}
@Override

View File

@ -174,7 +174,7 @@ public class ErodeBrush extends Brush {
vm.brushName(this.getName());
vm.size();
vm.custom(ChatColor.AQUA + "Erosion minimum exposed faces set to " + this.currentPreset.getErosionFaces());
vm.custom(ChatColor.BLUE + "Fill minumum touching faces set to " + this.currentPreset.getFillFaces());
vm.custom(ChatColor.BLUE + "Fill minimum touching faces set to " + this.currentPreset.getFillFaces());
vm.custom(ChatColor.DARK_BLUE + "Erosion recursion amount set to " + this.currentPreset.getErosionRecursion());
vm.custom(ChatColor.DARK_GREEN + "Fill recursion amount set to " + this.currentPreset.getFillRecursion());
}
@ -252,9 +252,9 @@ public class ErodeBrush extends Brush {
/**
* Generates a concat string of all options.
*
* @param seperator Seperator for delimiting entries.
* @param separator Separator for delimiting entries.
*/
public static String getValuesString(String seperator) {
public static String getValuesString(String separator) {
StringBuilder valuesString = new StringBuilder();
boolean delimiterHelper = true;
@ -262,7 +262,7 @@ public class ErodeBrush extends Brush {
if (delimiterHelper) {
delimiterHelper = false;
} else {
valuesString.append(seperator);
valuesString.append(separator);
}
valuesString.append(preset.name());
}

View File

@ -102,10 +102,10 @@ public class Rot3DBrush extends Brush {
private void rotate(final SnipeData v) {
// basically 1) make it a sphere we are rotating in, not a cylinder
// 2) do three rotations in a row, one in each dimension, unless some dimensions are set to zero or udnefined or whatever, then skip those.
// --> Why not utilize Sniper'world new oportunities and have arrow rotate all 3, powder rotate x, goldsisc y, otherdisc z. Or something like that. Or
// 2) do three rotations in a row, one in each dimension, unless some dimensions are set to zero or undefined or whatever, then skip those.
// --> Why not utilize Sniper'world new opportunities and have arrow rotate all 3, powder rotate x, goldsisc y, otherdisc z. Or something like that. Or
// we
// could just use arrow and powder and just differenciate between left and right click that gis 4 different situations
// could just use arrow and powder and just differentiate between left and right click that gis 4 different situations
// --> Well, there would be 7 different possibilities... X, Y, Z, XY, XZ, YZ, XYZ, and different numbers of parameters for each, so I think each having
// and item is too confusing. How about this: arrow = rotate one dimension, based on the face you click, and takes 1 param... powder: rotates all three
// at once, and takes 3 params.

View File

@ -27,8 +27,8 @@ public class SnowConeBrush extends Brush {
}
final int brushSizeDoubled = 2 * brushSize;
final int[][] snowcone = new int[brushSizeDoubled + 1][brushSizeDoubled + 1]; // Will hold block IDs
final int[][] snowconeData = new int[brushSizeDoubled + 1][brushSizeDoubled + 1]; // Will hold data values for snowcone
final int[][] snowCone = new int[brushSizeDoubled + 1][brushSizeDoubled + 1]; // Will hold block IDs
final int[][] snowConeData = new int[brushSizeDoubled + 1][brushSizeDoubled + 1]; // Will hold data values for snowCone
final int[][] yOffset = new int[brushSizeDoubled + 1][brushSizeDoubled + 1];
// prime the arrays
@ -44,12 +44,12 @@ public class SnowConeBrush extends Brush {
}
}
}
snowcone[x][z] = this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z);
snowconeData[x][z] = this.clampY(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z).getPropertyId();
snowCone[x][z] = this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z);
snowConeData[x][z] = this.clampY(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z).getPropertyId();
}
}
// figure out new snowheights
// figure out new snowHeights
for (int x = 0; x <= brushSizeDoubled; x++) {
final double xSquared = Math.pow(x - brushSize, 2);
@ -61,35 +61,35 @@ public class SnowConeBrush extends Brush {
if (snowData >= 0) { // no funny business
switch (snowData) {
case 0:
if (BlockTypes.get(snowcone[x][z]).getMaterial().isAir()) {
snowcone[x][z] = BlockTypes.SNOW.getInternalId();
snowconeData[x][z] = 0;
if (BlockTypes.get(snowCone[x][z]).getMaterial().isAir()) {
snowCone[x][z] = BlockTypes.SNOW.getInternalId();
snowConeData[x][z] = 0;
}
break;
case 7: // Turn largest snowtile into snowblock
if (snowcone[x][z] == BlockTypes.SNOW.getInternalId()) {
snowcone[x][z] = BlockTypes.SNOW_BLOCK.getInternalId();
snowconeData[x][z] = 0;
case 7: // Turn largest snowTile into snow block
if (snowCone[x][z] == BlockTypes.SNOW.getInternalId()) {
snowCone[x][z] = BlockTypes.SNOW_BLOCK.getInternalId();
snowConeData[x][z] = 0;
}
break;
default: // Increase snowtile size, if smaller than target
default: // Increase snowTile size, if smaller than target
if (snowData > snowconeData[x][z]) {
if (snowData > snowConeData[x][z]) {
BlockType blockType =
BlockTypes.get(snowcone[x][z]);
BlockTypes.get(snowCone[x][z]);
if (blockType.getMaterial().isAir()) {
snowconeData[x][z] = snowData;
snowcone[x][z] = BlockTypes.SNOW.getInternalId();
snowConeData[x][z] = snowData;
snowCone[x][z] = BlockTypes.SNOW.getInternalId();
snowconeData[x][z] = snowData;
snowConeData[x][z] = snowData;
} else if (blockType == BlockTypes.SNOW_BLOCK) {
snowconeData[x][z] = snowData;
snowConeData[x][z] = snowData;
}
} else if (yOffset[x][z] > 0 && snowcone[x][z] == BlockTypes.SNOW.getInternalId()) {
snowconeData[x][z]++;
if (snowconeData[x][z] == 7) {
snowconeData[x][z] = 0;
snowcone[x][z] = BlockTypes.SNOW_BLOCK.getInternalId();
} else if (yOffset[x][z] > 0 && snowCone[x][z] == BlockTypes.SNOW.getInternalId()) {
snowConeData[x][z]++;
if (snowConeData[x][z] == 7) {
snowConeData[x][z] = 0;
snowCone[x][z] = BlockTypes.SNOW_BLOCK.getInternalId();
}
}
break;
@ -103,11 +103,11 @@ public class SnowConeBrush extends Brush {
for (int x = 0; x <= brushSizeDoubled; x++) {
for (int z = 0; z <= brushSizeDoubled; z++) {
if (this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z) != snowcone[x][z] || this.clampY(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z).getPropertyId() != snowconeData[x][z]) {
if (this.getBlockIdAt(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z) != snowCone[x][z] || this.clampY(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z).getPropertyId() != snowConeData[x][z]) {
undo.put(this.clampY(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z));
}
this.setBlockIdAt(blockPositionZ - brushSize + z, blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], snowcone[x][z]);
this.clampY(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z).setPropertyId(snowconeData[x][z]);
this.setBlockIdAt(blockPositionZ - brushSize + z, blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], snowCone[x][z]);
this.clampY(blockPositionX - brushSize + x, blockPositionY - yOffset[x][z], blockPositionZ - brushSize + z).setPropertyId(snowConeData[x][z]);
}
}

View File

@ -22,11 +22,11 @@ import java.util.logging.Logger;
*
* new extra: n = no undo
*
* The main benefit of this system is that it provides the least possible number of characters in the paramaters
* The main benefit of this system is that it provides the least possible number of characters in the parameters
* while guaranteeing that all sensible combinations will be made. Additionally, the names will be VERY consistent
*
* EX Old System: /b b isrcup (use /v, /vi, /vr and /vir, update graphics and no physics)
* EX New System: /b b ccup (two characters shorter, good because snipers have been complaing about keystrokes)
* EX New System: /b b ccup (two characters shorter, good because snipers have been complaining about keystrokes)
*
*/

View File

@ -43,12 +43,12 @@ public class VoxelBrushCommand extends VoxelCommand {
Bukkit.getPluginManager().callEvent(event);
snipeData.getVoxelMessage().size();
return true;
} catch (NumberFormatException ingored) {
} catch (NumberFormatException ignored) {
}
Class<? extends IBrush> brush = plugin.getBrushManager().getBrushForHandle(args[0]);
if (brush != null) {
IBrush orignalBrush = sniper.getBrush(currentToolId);
IBrush originalBrush = sniper.getBrush(currentToolId);
sniper.setBrush(currentToolId, brush);
if (args.length > 1) {
@ -63,7 +63,7 @@ public class VoxelBrushCommand extends VoxelCommand {
return true;
}
}
SniperBrushChangedEvent event = new SniperBrushChangedEvent(sniper, currentToolId, orignalBrush, sniper.getBrush(currentToolId));
SniperBrushChangedEvent event = new SniperBrushChangedEvent(sniper, currentToolId, originalBrush, sniper.getBrush(currentToolId));
sniper.displayInfo();
return true;
} else {

View File

@ -458,10 +458,10 @@ public class FaweBukkit implements IFawe, Listener {
e.printStackTrace();
}
}
final Plugin preciousstonesPlugin = Bukkit.getServer().getPluginManager().getPlugin("PreciousStones");
if (preciousstonesPlugin != null && preciousstonesPlugin.isEnabled()) {
final Plugin preciousStonesPlugin = Bukkit.getServer().getPluginManager().getPlugin("PreciousStones");
if (preciousStonesPlugin != null && preciousStonesPlugin.isEnabled()) {
try {
managers.add(new PreciousStonesFeature(preciousstonesPlugin, this));
managers.add(new PreciousStonesFeature(preciousStonesPlugin, this));
Fawe.debug("Plugin 'PreciousStones' found. Using it now.");
} catch (final Throwable e) {
e.printStackTrace();

View File

@ -284,7 +284,7 @@ public class BukkitQueue extends SimpleCharQueueExtent {
}
final int[] blockToPalette = FaweCache.BLOCK_TO_PALETTE.get();
final int[] paletteToBlock = FaweCache.PALETTE_TO_BLOCK.get();
final long[] blockstates = FaweCache.BLOCK_STATES.get();
final long[] blockStates = FaweCache.BLOCK_STATES.get();
final int[] blocksCopy = FaweCache.SECTION_BLOCKS.get();
try {
int num_palette = 0;
@ -317,9 +317,9 @@ public class BukkitQueue extends SimpleCharQueueExtent {
final int blockBitArrayEnd = (bitsPerEntry * 4096) >> 6;
if (num_palette == 1) {
for (int i = 0; i < blockBitArrayEnd; i++) blockstates[i] = 0;
for (int i = 0; i < blockBitArrayEnd; i++) blockStates[i] = 0;
} else {
final BitArray4096 bitArray = new BitArray4096(blockstates, bitsPerEntry);
final BitArray4096 bitArray = new BitArray4096(blockStates, bitsPerEntry);
bitArray.fromRaw(blocksCopy);
}
@ -327,7 +327,7 @@ public class BukkitQueue extends SimpleCharQueueExtent {
final DataPaletteBlock<IBlockData> dataPaletteBlocks = section.getBlocks();
// private DataPalette<T> h;
// protected DataBits a;
final long[] bits = Arrays.copyOfRange(blockstates, 0, blockBitArrayEnd);
final long[] bits = Arrays.copyOfRange(blockStates, 0, blockBitArrayEnd);
final DataBits nmsBits = new DataBits(bitsPerEntry, 4096, bits);
final DataPalette<IBlockData> palette;
// palette = new DataPaletteHash<>(Block.REGISTRY_ID, bitsPerEntry, dataPaletteBlocks, GameProfileSerializer::d, GameProfileSerializer::a);

View File

@ -1,78 +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.bukkit.util;
import org.enginehub.piston.annotation.Command;
import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.minecraft.util.commands.CommandsManager;
import org.bukkit.command.CommandExecutor;
import org.bukkit.plugin.Plugin;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@Deprecated
@SuppressWarnings("deprecation")
public class CommandsManagerRegistration extends CommandRegistration {
protected CommandsManager<?> commands;
public CommandsManagerRegistration(Plugin plugin, CommandsManager<?> commands) {
super(plugin);
this.commands = commands;
}
public CommandsManagerRegistration(Plugin plugin, CommandExecutor executor, CommandsManager<?> commands) {
super(plugin, executor);
this.commands = commands;
}
public boolean register(Class<?> clazz) {
return registerAll(commands.registerAndReturn(clazz));
}
public boolean registerAll(List<Command> registered) {
List<CommandInfo> toRegister = new ArrayList<>();
for (Command command : registered) {
List<String> permissions = null;
Method cmdMethod = commands.getMethods().get(null).get(command.aliases()[0]);
Map<String, Method> childMethods = commands.getMethods().get(cmdMethod);
if (cmdMethod != null && cmdMethod.isAnnotationPresent(CommandPermissions.class)) {
permissions = Arrays.asList(cmdMethod.getAnnotation(CommandPermissions.class).value());
} else if (cmdMethod != null && childMethods != null && !childMethods.isEmpty()) {
permissions = new ArrayList<>();
for (Method m : childMethods.values()) {
if (m.isAnnotationPresent(CommandPermissions.class)) {
permissions.addAll(Arrays.asList(m.getAnnotation(CommandPermissions.class).value()));
}
}
}
toRegister.add(new CommandInfo(command.usage(), command.desc(), command.aliases(), commands, permissions == null ? null : permissions.toArray(new String[permissions.size()])));
}
return register(toRegister);
}
}

View File

@ -25,24 +25,24 @@ import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
public class BukkitTextAdapter {
public static String reduceToText(Component component) {
StringBuilder text = new StringBuilder();
appendTextTo(text, component);
return text.toString();
}
private static void appendTextTo(StringBuilder builder, Component component) {
if (component instanceof TextComponent) {
builder.append(((TextComponent) component).content());
} else if (component instanceof TranslatableComponent) {
builder.append(((TranslatableComponent) component).key());
public static String reduceToText(Component component) {
StringBuilder text = new StringBuilder();
appendTextTo(text, component);
return text.toString();
}
for (Component child : component.children()) {
appendTextTo(builder, child);
}
}
private BukkitTextAdapter() {
}
private static void appendTextTo(StringBuilder builder, Component component) {
if (component instanceof TextComponent) {
builder.append(((TextComponent) component).content());
} else if (component instanceof TranslatableComponent) {
builder.append(((TranslatableComponent) component).key());
}
for (Component child : component.children()) {
appendTextTo(builder, child);
}
}
private BukkitTextAdapter() {
}
}

View File

@ -199,9 +199,9 @@ public class BukkitWorld extends AbstractWorld {
// We have to restore the block if it was outside
if (!region.contains(pt)) {
editSession.setBlock(pt, history[index]);
editSession.smartSetBlock(pt, history[index]);
} else { // Otherwise fool with history
editSession.setBlock().add(new BlockChange(pt, history[index], editSession.getFullBlock(pt)));
editSession.getChangeSet().add(new BlockChange(pt, history[index], editSession.getFullBlock(pt)));
}
}
}
@ -318,14 +318,13 @@ public class BukkitWorld extends AbstractWorld {
@Override
public boolean equals(Object other) {
World ref = worldRef.get();
if (ref == null) {
if (worldRef.get() == null) {
return false;
} else if (other == null) {
return false;
} else if ((other instanceof BukkitWorld)) {
World otherWorld = ((BukkitWorld) other).worldRef.get();
return ref.equals(otherWorld);
return otherWorld != null && otherWorld.equals(getWorld());
} else if (other instanceof com.sk89q.worldedit.world.World) {
return ((com.sk89q.worldedit.world.World) other).getName().equals(getName());
} else {
@ -420,8 +419,21 @@ public class BukkitWorld extends AbstractWorld {
getWorld().getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).breakNaturally();
}
private static volatile boolean hasWarnedImplError = false;
@Override
public com.sk89q.worldedit.world.block.BlockState getBlock(BlockVector3 position) {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) {
try {
return adapter.getBlock(BukkitAdapter.adapt(getWorld(), position)).toImmutableState();
} catch (Exception e) {
if (!hasWarnedImplError) {
hasWarnedImplError = true;
logger.warn("Unable to retrieve block via impl adapter", e);
}
}
}
Block bukkitBlock = getWorld().getBlockAt(position.getBlockX(), position.getBlockY(), position.getBlockZ());
return BukkitAdapter.adapt(bukkitBlock.getBlockData());
}

View File

@ -21,7 +21,6 @@
package com.sk89q.worldedit.bukkit;
import com.bekvon.bukkit.residence.commands.command;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
@ -37,15 +36,12 @@ import org.bukkit.event.player.PlayerCommandSendEvent;
import org.bukkit.event.player.PlayerGameModeChangeEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.EquipmentSlot;
import org.enginehub.piston.Command;
import org.enginehub.piston.CommandManager;
import org.enginehub.piston.inject.InjectedValueStore;
import org.enginehub.piston.inject.Key;
import org.enginehub.piston.inject.MapBackedValueStore;
import java.util.Iterator;
import java.util.Optional;
import java.util.function.Predicate;
/**
* Handles all events thrown in relation to a Player
@ -75,22 +71,16 @@ public class WorldEditListener implements Listener {
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onPlayerCommandSend(PlayerCommandSendEvent event) {
InjectedValueStore store = null;
InjectedValueStore store = MapBackedValueStore.create();
store.injectValue(Key.of(Actor.class), context ->
Optional.of(plugin.wrapCommandSender(event.getPlayer())));
CommandManager commandManager = plugin.getWorldEdit().getPlatformManager().getPlatformCommandManager().getCommandManager();
Iterator<String> iter = event.getCommands().iterator();
while (iter.hasNext()) {
String name = iter.next();
Optional<Command> optional = commandManager.getCommand(name);
if (optional.isPresent()) {
if (store == null) {
store = MapBackedValueStore.create();
store.injectValue(Key.of(Actor.class), context -> Optional.of(plugin.wrapCommandSender(event.getPlayer())));
}
if (!optional.get().getCondition().satisfied(store)) {
iter.remove();
}
}
}
event.getCommands().removeIf(name ->
// remove if in the manager and not satisfied
commandManager.getCommand(name)
.filter(command -> !command.getCondition().satisfied(store))
.isPresent()
);
}
/**

View File

@ -217,7 +217,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
public void setupRegistries() {
// Biome
for (Biome biome : Biome.values()) {
BiomeType.REGISTRY.register("minecraft:" + biome.name().toLowerCase(Locale.ROOT), new BiomeType("minecraft:" + biome.name().toLowerCase(Locale.ROOT)));
String lowerCaseBiomeName = biome.name().toLowerCase(Locale.ROOT);
BiomeType.REGISTRY.register("minecraft:" + lowerCaseBiomeName, new BiomeType("minecraft:" + lowerCaseBiomeName));
}
// Block & Item
for (Material material : Material.values()) {
@ -254,7 +255,8 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
for (org.bukkit.entity.EntityType entityType : org.bukkit.entity.EntityType.values()) {
String mcid = entityType.getName();
if (mcid != null) {
EntityType.REGISTRY.register("minecraft:" + mcid.toLowerCase(Locale.ROOT), new EntityType("minecraft:" + mcid.toLowerCase(Locale.ROOT)));
String lowerCaseMcId = mcid.toLowerCase(Locale.ROOT);
EntityType.REGISTRY.register("minecraft:" + lowerCaseMcId, new EntityType("minecraft:" + lowerCaseMcId));
}
}
}
@ -426,7 +428,7 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
// code of WorldEdit expects it
String[] split = new String[args.length + 1];
System.arraycopy(args, 0, split, 1, args.length);
split[0] = cmd.getName();
split[0] = "/" + cmd.getName();
CommandEvent event = new CommandEvent(wrapCommandSender(sender), Joiner.on(" ").join(split));
getWorldEdit().getEventBus().post(event);
@ -441,11 +443,12 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
// code of WorldEdit expects it
String[] split = new String[args.length + 1];
System.arraycopy(args, 0, split, 1, args.length);
split[0] = cmd.getName();
split[0] = "/" + cmd.getName();
CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), Joiner.on(" ").join(split));
String arguments = Joiner.on(" ").join(split);
CommandSuggestionEvent event = new CommandSuggestionEvent(wrapCommandSender(sender), arguments);
getWorldEdit().getEventBus().post(event);
return event.getSuggestions();
return CommandUtil.fixSuggestions(arguments, event.getSuggestions());
}
*/
@ -581,13 +584,9 @@ public class WorldEditPlugin extends JavaPlugin { //implements TabCompleter
CommandSuggestionEvent suggestEvent = new CommandSuggestionEvent(wrapCommandSender(event.getSender()), event.getBuffer());
getWorldEdit().getEventBus().post(suggestEvent);
List<String> suggestions = suggestEvent.getSuggestions();
if (suggestions != null && !suggestions.isEmpty()) {
event.setCompletions(suggestions);
event.setHandled(true);
}
//event.setCompletions(CommandUtil.fixSuggestions(event.getBuffer(), suggestEvent.getSuggestions()));
//event.setHandled(true);
event.setCompletions(CommandUtil.fixSuggestions(event.getBuffer(), suggestEvent.getSuggestions()));
event.setHandled(true);
}
}
}

View File

@ -54,7 +54,7 @@ public class BukkitImplLoader {
"** will be blank, and so on. There will be no support for entity\n" +
"** and block property-related functions.\n" +
"**\n" +
"** Please see http://wiki.sk89q.com/wiki/WorldEdit/Bukkit_adapters\n" +
"** Please see https://worldedit.rtfd.io/en/latest/faq/#bukkit-adapters\n" +
"**********************************************\n";
/**

View File

@ -112,11 +112,11 @@ public final class FaweCache implements Trimable {
*/
public int[] paletteToBlock;
public int blockstatesLength;
public int blockStatesLength;
/**
* Reusable buffer array, MUST check blockstatesLength for actual length
* Reusable buffer array, MUST check blockStatesLength for actual length
*/
public long[] blockstates;
public long[] blockStates;
}
private static final IterableThreadLocal<Palette> PALETTE_CACHE = new IterableThreadLocal<Palette>() {
@ -149,7 +149,7 @@ public final class FaweCache implements Trimable {
private static Palette toPalette(int layerOffset, int[] blocksInts, char[] blocksChars) {
int[] blockToPalette = BLOCK_TO_PALETTE.get();
int[] paletteToBlock = PALETTE_TO_BLOCK.get();
long[] blockstates = BLOCK_STATES.get();
long[] blockStates = BLOCK_STATES.get();
int[] blocksCopy = SECTION_BLOCKS.get();
int blockIndexStart = layerOffset << 12;
@ -193,10 +193,10 @@ public final class FaweCache implements Trimable {
int blockBitArrayEnd = (bitsPerEntry * 4096) >> 6;
if (num_palette == 1) {
// Set a value, because minecraft needs it for some reason
blockstates[0] = 0;
blockStates[0] = 0;
blockBitArrayEnd = 1;
} else {
BitArray4096 bitArray = new BitArray4096(blockstates, bitsPerEntry);
BitArray4096 bitArray = new BitArray4096(blockStates, bitsPerEntry);
bitArray.fromRaw(blocksCopy);
}
@ -205,8 +205,8 @@ public final class FaweCache implements Trimable {
palette.paletteToBlockLength = num_palette;
palette.paletteToBlock = paletteToBlock;
palette.blockstatesLength = blockBitArrayEnd;
palette.blockstates = blockstates;
palette.blockStatesLength = blockBitArrayEnd;
palette.blockStates = blockStates;
return palette;
} catch (Throwable e) {

View File

@ -24,8 +24,8 @@ public class FaweVersion {
public static FaweVersion tryParse(String version, String commit, String date) {
try {
return new FaweVersion(version, commit, date);
} catch (Exception ignore) {
ignore.printStackTrace();
} catch (Exception exception) {
exception.printStackTrace();
return new FaweVersion(0, 0, 0, 0, 0);
}
}
@ -41,4 +41,4 @@ public class FaweVersion {
public boolean isNewer(FaweVersion other) {
return other.build < this.build;
}
}
}

View File

@ -1,37 +1,25 @@
package com.boydti.fawe.command;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.object.RunnableVal4;
import com.boydti.fawe.object.changeset.AnvilHistory;
import com.boydti.fawe.object.clipboard.remap.ClipboardRemapper;
import com.boydti.fawe.object.mask.FaweBlockMatcher;
import com.boydti.fawe.util.MainUtil;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
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.function.pattern.Pattern;
import com.sk89q.worldedit.internal.annotation.Selection;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import java.io.IOException;
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 java.io.IOException;
import java.io.RandomAccessFile;
import static com.google.common.base.Preconditions.checkNotNull;
@Command(aliases = {"/anvil"}, desc = "Manipulate billions of blocks: [More Info](https://github.com/boy0001/FastAsyncWorldedit/wiki/Anvil-API)")
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class AnvilCommands {
/**
@ -247,11 +235,10 @@ public class AnvilCommands {
desc = "Trim chunks in a Plot World",
descFooter = "Unclaimed chunks will be deleted\n" +
"Unmodified chunks will be deleted\n" +
"Use -v to also delete unvisited chunks\n"
"Unmodified chunks will be deleted\n"
)
@CommandPermissions("worldedit.anvil.trimallplots")
public void trimAllPlots(Player player, @Switch(name='v', desc = "TODO") boolean deleteUnvisited) throws WorldEditException {
public void trimAllPlots(Player player, @Switch(name='v', desc = "Delete unvisited chunks") boolean deleteUnvisited) throws WorldEditException {
// String folder = player.getWorld().getName(); TODO NOT IMPLEMENTED
// int visitTime = deleteUnvisited ? 1 : -1;
// PlotTrimFilter filter = new PlotTrimFilter(player.getWorld(), 0, visitTime, 600000);
@ -266,7 +253,6 @@ public class AnvilCommands {
@Command(
name = "deletebiomechunks",
desc = "Delete chunks matching a specific biome"
)
@CommandPermissions("worldedit.anvil.trimallair")
@ -280,7 +266,6 @@ public class AnvilCommands {
@Command(
name = "trimallair",
desc = "Trim all air in the world"
)
@CommandPermissions("worldedit.anvil.trimallair")
@ -310,7 +295,7 @@ public class AnvilCommands {
name = "replaceallpattern",
aliases = {"reap", "repallpat"},
desc = "Replace all blocks in the selection with another"
)
)
@CommandPermissions("worldedit.anvil.replaceall")
public void replaceAllPattern(Player player, String folder, @Arg(name = "from", desc = "String", def = "") String from, final Pattern to, @Switch(name='d', desc = "TODO") boolean useData, @Switch(name='m', desc = "TODO") boolean useMap) throws WorldEditException {
// MCAFilterCounter filter; TODO NOT IMPLEMENTED
@ -339,7 +324,7 @@ public class AnvilCommands {
@Command(
name = "countall",
desc = "Count all blocks in a world"
)
)
@CommandPermissions("worldedit.anvil.countall")
public void countAll(Player player, EditSession editSession, String folder, String arg, @Switch(name='d', desc = "TODO") boolean useData) throws WorldEditException {
// Set<BaseBlock> searchBlocks = worldEdit.getBlocks(player, arg, true);
@ -413,7 +398,7 @@ public class AnvilCommands {
@Command(
name = "count",
desc = "Count blocks in a selection"
)
)
@CommandPermissions("worldedit.anvil.count")
public void count(Player player, EditSession editSession, @Selection Region selection, String arg, @Switch(name='d', desc = "TODO") boolean useData) throws WorldEditException {
// Set<BaseBlock> searchBlocks = worldEdit.getBlocks(player, arg, true); TODO NOT IMPLEMENTED
@ -621,8 +606,7 @@ public class AnvilCommands {
@Command(
name = "paste",
desc = "Paste chunks from your anvil clipboard",
descFooter =
"Paste the chunks from your anvil clipboard.\n" +
descFooter = "Paste the chunks from your anvil clipboard.\n" +
"The -c flag will align the paste to the chunks."
)
@CommandPermissions("worldedit.anvil.pastechunks")

View File

@ -82,10 +82,6 @@ public class CFICommand extends MethodCommands {
dispatcher.call(cmd, context.getLocals(), new String[0]);
return;
}
case 2:
String cmd = Commands.getAlias(CFICommands.class, "empty") + " " + context.getJoinedStrings(0);
dispatcher.call(cmd, context.getLocals(), new String[0]);
return;
}
}
dispatcher.call(remaining, context.getLocals(), new String[0]);

View File

@ -1,13 +1,16 @@
package com.boydti.fawe.command;
import static com.boydti.fawe.util.image.ImageUtil.load;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.beta.IQueueExtent;
import com.boydti.fawe.beta.SingleFilterBlock;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Commands;
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RunnableVal;
import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator;
import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
import com.boydti.fawe.util.CleanTextureUtil;
import com.boydti.fawe.util.FilteredTextureUtil;
@ -18,17 +21,14 @@ import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.TextureUtil;
import com.boydti.fawe.util.chat.Message;
import com.boydti.fawe.util.image.ImageUtil;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import java.util.stream.IntStream;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.inject.InjectedValueAccess;
import com.sk89q.minecraft.util.commands.CommandException;
import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.EmptyClipboardException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.MethodCommands;
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.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext;
@ -44,14 +44,11 @@ import com.sk89q.worldedit.registry.state.PropertyKey;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.session.request.Request;
import com.sk89q.worldedit.util.Location;
import org.enginehub.piston.annotation.param.Switch;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.awt.image.DataBufferInt;
import java.io.ByteArrayOutputStream;
@ -67,15 +64,18 @@ import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.IntStream;
import javax.imageio.ImageIO;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
import static com.boydti.fawe.util.image.ImageUtil.load;
import org.enginehub.piston.annotation.param.Switch;
import org.enginehub.piston.inject.InjectedValueAccess;
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class CFICommands extends MethodCommands {
private final Dispatcher dispathcer;
private final Dispatcher dispatcher;
/**
* Create a new instance.
@ -84,7 +84,7 @@ public class CFICommands extends MethodCommands {
*/
public CFICommands(WorldEdit worldEdit, Dispatcher dispatcher) {
super(worldEdit);
this.dispathcer = dispatcher;
this.dispatcher = dispatcher;
}
public static File getFolder(String worldName) {
@ -99,7 +99,7 @@ public class CFICommands extends MethodCommands {
desc = "Start CFI with a height map as a base"
)
@CommandPermissions("worldedit.anvil.cfi")
public void heightmap(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Arg(name = "yscale", desc = "double", def = "1") double yscale) throws ParameterException {
public void heightmap(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Arg(name = "yscale", desc = "double", def = "1") double yscale) {
if (yscale != 0) {
int[] raw = ((DataBufferInt) image.load().getRaster().getDataBuffer()).getData();
int[] table = IntStream.range(0, 256).map(i -> Math.min(255, (int) (i * yscale)))
@ -121,7 +121,7 @@ public class CFICommands extends MethodCommands {
desc = "Start CFI with an empty map as a base"
)
@CommandPermissions("worldedit.anvil.cfi")
public void heightmap(FawePlayer fp, int width, int length) {
public void heightMap(FawePlayer fp, int width, int length) {
HeightMapMCAGenerator generator = new HeightMapMCAGenerator(width, length, getFolder(generateName()));
setup(generator, fp);
}
@ -145,7 +145,7 @@ public class CFICommands extends MethodCommands {
desc = "Info about using brushes with CFI"
)
@CommandPermissions("worldedit.anvil.cfi")
public void brush(FawePlayer fp) throws ParameterException {
public void brush(FawePlayer fp) {
CFISettings settings = assertSettings(fp);
settings.popMessages(fp);
Message msg;
@ -232,7 +232,7 @@ public class CFICommands extends MethodCommands {
desc = "Set the floor and main block"
)
@CommandPermissions("worldedit.anvil.cfi")
public void column(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
public void column(FawePlayer fp, Pattern pattern, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) {
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (image != null) {
gen.setColumn(load(image), pattern, !disableWhiteOnly);
@ -251,14 +251,14 @@ public class CFICommands extends MethodCommands {
desc = "Set the floor (default: grass)"
)
@CommandPermissions("worldedit.anvil.cfi")
public void floorCmd(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
public void floorCmd(FawePlayer fp, Pattern pattern, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) {
floor(fp, pattern, image, mask, disableWhiteOnly);
fp.sendMessage("Set floor!");
assertSettings(fp).resetComponent();
component(fp);
}
private void floor(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException {
private void floor(FawePlayer fp, Pattern pattern, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) {
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (image != null) {
gen.setFloor(load(image), pattern, !disableWhiteOnly);
@ -274,14 +274,14 @@ public class CFICommands extends MethodCommands {
desc = "Set the main block (default: stone)"
)
@CommandPermissions("worldedit.anvil.cfi")
public void mainCmd(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
public void mainCmd(FawePlayer fp, Pattern pattern, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly){
main(fp, pattern, image, mask, disableWhiteOnly);
fp.sendMessage("Set main!");
assertSettings(fp).resetComponent();
component(fp);
}
public void main(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
public void main(FawePlayer fp, Pattern pattern, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly){
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (image != null) {
gen.setMain(load(image), pattern, !disableWhiteOnly);
@ -300,7 +300,7 @@ public class CFICommands extends MethodCommands {
"e.g. Tallgrass"
)
@CommandPermissions("worldedit.anvil.cfi")
public void overlay(FawePlayer fp, Pattern pattern, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
public void overlay(FawePlayer fp, Pattern pattern, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly){
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (image != null) {
gen.setOverlay(load(image), pattern, !disableWhiteOnly);
@ -322,13 +322,13 @@ public class CFICommands extends MethodCommands {
" - A good value for radius and iterations would be 1 8."
)
@CommandPermissions("worldedit.anvil.cfi")
public void smoothCmd(FawePlayer fp, int radius, int iterations, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
public void smoothCmd(FawePlayer fp, int radius, int iterations, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) {
smooth(fp, radius, iterations, image, mask, disableWhiteOnly);
assertSettings(fp).resetComponent();
component(fp);
}
private void smooth(FawePlayer fp, int radius, int iterations, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
private void smooth(FawePlayer fp, int radius, int iterations, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) {
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (image != null) {
gen.smooth(load(image), !disableWhiteOnly, radius, iterations);
@ -342,7 +342,7 @@ public class CFICommands extends MethodCommands {
desc = "Create some snow"
)
@CommandPermissions("worldedit.anvil.cfi")
public void snow(FawePlayer fp, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
public void snow(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) {
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
floor(fp, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, mask, disableWhiteOnly);
main(fp, BlockTypes.SNOW_BLOCK, image, mask, disableWhiteOnly);
@ -361,7 +361,7 @@ public class CFICommands extends MethodCommands {
"Below 50 will prefer to color with blocks"
)
@CommandPermissions("worldedit.anvil.cfi")
public void biomepriority(FawePlayer fp, int value) throws ParameterException {
public void biomepriority(FawePlayer fp, int value) {
assertSettings(fp).getGenerator().setBiomePriority(value);
coloring(fp);
}
@ -374,7 +374,7 @@ public class CFICommands extends MethodCommands {
"`#clipboard` will only use the blocks present in your clipboard."
)
@CommandPermissions("worldedit.anvil.cfi")
public void paletteblocks(FawePlayer fp, Player player, LocalSession session, @Arg(name = "arg", desc = "String", def = "") String arg) throws ParameterException, EmptyClipboardException, InputParseException, FileNotFoundException {
public void paletteblocks(FawePlayer fp, Player player, LocalSession session, @Arg(name = "arg", desc = "String", def = "") String arg) throws EmptyClipboardException, InputParseException, FileNotFoundException {
if (arg == null) {
msg("What blocks do you want to color with?").newline()
.text("[All]").cmdTip(alias() + " PaletteBlocks *").text(" - All available blocks")
@ -452,7 +452,7 @@ public class CFICommands extends MethodCommands {
"Randomization will allow mixing biomes when coloring with biomes"
)
@CommandPermissions("worldedit.anvil.cfi")
public void randomization(FawePlayer fp, boolean enabled) throws ParameterException {
public void randomization(FawePlayer fp, boolean enabled) {
assertSettings(fp).getGenerator().setTextureRandomVariation(enabled);
coloring(fp);
}
@ -466,7 +466,7 @@ public class CFICommands extends MethodCommands {
"Using 0 73 for the min/max would use the simplest 73% of blocks for coloring, and is a reasonable value."
)
@CommandPermissions("worldedit.anvil.cfi")
public void complexity(FawePlayer fp, int min, int max) throws ParameterException, FileNotFoundException {
public void complexity(FawePlayer fp, int min, int max) throws FileNotFoundException {
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (min == 0 && max == 100) {
gen.setTextureUtil(Fawe.get().getTextureUtil());
@ -485,7 +485,7 @@ public class CFICommands extends MethodCommands {
" - The distance is the spacing between each schematic"
)
@CommandPermissions("worldedit.anvil.cfi")
public void schem(FawePlayer fp, @Optional FawePrimitiveBinding.ImageUri imageMask, Mask mask, String schematic, int rarity, int distance, boolean rotate) throws ParameterException, IOException, WorldEditException {
public void schem(FawePlayer fp, FawePrimitiveBinding.ImageUri imageMask, Mask mask, String schematic, int rarity, int distance, boolean rotate) throws IOException, WorldEditException {
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
World world = fp.getWorld();
@ -511,7 +511,7 @@ public class CFICommands extends MethodCommands {
" - If a mask is used, the biome will be set anywhere the mask applies"
)
@CommandPermissions("worldedit.anvil.cfi")
public void biome(FawePlayer fp, BiomeType biome, @Optional FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException{
public void biome(FawePlayer fp, BiomeType biome, FawePrimitiveBinding.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) {
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (image != null) {
gen.setBiome(load(image), biome, !disableWhiteOnly);
@ -530,7 +530,7 @@ public class CFICommands extends MethodCommands {
desc = "Generate vanilla caves"
)
@CommandPermissions("worldedit.anvil.cfi")
public void caves(FawePlayer fp) throws ParameterException, WorldEditException {
public void caves(FawePlayer fp) throws WorldEditException {
assertSettings(fp).getGenerator().addCaves();
msg("Added caves!").send(fp);
populate(fp);
@ -542,7 +542,7 @@ public class CFICommands extends MethodCommands {
descFooter = "Use a specific pattern and settings to generate ore"
)
@CommandPermissions("worldedit.anvil.cfi")
public void ore(FawePlayer fp, Mask mask, Pattern pattern, int size, int frequency, int rariry, int minY, int maxY) throws ParameterException, WorldEditException {
public void ore(FawePlayer fp, Mask mask, Pattern pattern, int size, int frequency, int rariry, int minY, int maxY) throws WorldEditException {
assertSettings(fp).getGenerator().addOre(mask, pattern, size, frequency, rariry, minY, maxY);
msg("Added ore!").send(fp);
populate(fp);
@ -553,7 +553,7 @@ public class CFICommands extends MethodCommands {
desc = "Generate the vanilla ores"
)
@CommandPermissions("worldedit.anvil.cfi")
public void ores(FawePlayer fp, Mask mask) throws ParameterException, WorldEditException {
public void ores(FawePlayer fp, Mask mask) throws WorldEditException {
assertSettings(fp).getGenerator().addDefaultOres(mask);
msg("Added ores!").send(fp);
populate(fp);
@ -565,7 +565,7 @@ public class CFICommands extends MethodCommands {
descFooter = "Set the terrain height either based on an image heightmap, or a numeric value."
)
@CommandPermissions("worldedit.anvil.cfi")
public void height(FawePlayer fp, String arg) throws ParameterException, WorldEditException {
public void height(FawePlayer fp, String arg) throws WorldEditException {
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
if (!MathMan.isInteger(arg)) {
gen.setHeight(ImageUtil.getImage(arg));
@ -581,7 +581,7 @@ public class CFICommands extends MethodCommands {
desc = "Change the block used for water\ne.g. Lava"
)
@CommandPermissions("worldedit.anvil.cfi")
public void waterId(FawePlayer fp, BlockStateHolder block) throws ParameterException, WorldEditException {
public void waterId(FawePlayer fp, BlockStateHolder block) throws WorldEditException {
CFISettings settings = assertSettings(fp);
settings.getGenerator().setWaterId(block.getBlockType().getInternalId());
msg("Set water id!").send(fp);
@ -595,7 +595,7 @@ public class CFICommands extends MethodCommands {
desc = "Change the block used for the base\ne.g. Bedrock"
)
@CommandPermissions("worldedit.anvil.cfi")
public void baseId(FawePlayer fp, BlockStateHolder block) throws ParameterException, WorldEditException {
public void baseId(FawePlayer fp, BlockStateHolder block) throws WorldEditException {
CFISettings settings = assertSettings(fp);
settings.getGenerator().setBedrockId(block.getBlockType().getInternalId());
msg("Set base id!").send(fp);
@ -610,7 +610,7 @@ public class CFICommands extends MethodCommands {
" - A value of 0 is the default and will not modify the height"
)
@CommandPermissions("worldedit.anvil.cfi")
public void worldthickness(FawePlayer fp, int height) throws ParameterException, WorldEditException {
public void worldthickness(FawePlayer fp, int height) throws WorldEditException {
assertSettings(fp).getGenerator().setWorldThickness(height);
msg("Set world thickness!").send(fp);
component(fp);
@ -623,7 +623,7 @@ public class CFICommands extends MethodCommands {
" - A value of 0 is the default and will only set the top block"
)
@CommandPermissions("worldedit.anvil.cfi")
public void floorthickness(FawePlayer fp, int height) throws ParameterException, WorldEditException {
public void floorthickness(FawePlayer fp, int height) throws WorldEditException {
assertSettings(fp).getGenerator().setFloorThickness(height);
msg("Set floor thickness!").send(fp);
component(fp);
@ -635,7 +635,7 @@ public class CFICommands extends MethodCommands {
desc = "Resend the CFI chunks"
)
@CommandPermissions("worldedit.anvil.cfi")
public void update(FawePlayer fp) throws ParameterException, WorldEditException {
public void update(FawePlayer fp) throws WorldEditException {
assertSettings(fp).getGenerator().update();
msg("Chunks refreshed!").send(fp);
mainMenu(fp);
@ -647,7 +647,7 @@ public class CFICommands extends MethodCommands {
desc = "Teleport to the CFI virtual world"
)
@CommandPermissions("worldedit.anvil.cfi")
public void tp(FawePlayer fp) throws ParameterException, WorldEditException {
public void tp(FawePlayer fp) throws WorldEditException {
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
msg("Teleporting...").send(fp);
Vector3 origin = gen.getOrigin();
@ -665,7 +665,7 @@ public class CFICommands extends MethodCommands {
" - By default water is disabled (with a value of 0)"
)
@CommandPermissions("worldedit.anvil.cfi")
public void waterheight(FawePlayer fp, int height) throws ParameterException, WorldEditException {
public void waterheight(FawePlayer fp, int height) throws WorldEditException {
assertSettings(fp).getGenerator().setWaterHeight(height);
msg("Set water height!").send(fp);
component(fp);
@ -678,7 +678,7 @@ public class CFICommands extends MethodCommands {
)
// ![79,174,212,5:3,5:4,18,161,20]
@CommandPermissions("worldedit.anvil.cfi")
public void glass(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException, WorldEditException {
public void glass(FawePlayer fp, FawePrimitiveBinding.ImageUri image, FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException {
CFISettings settings = assertSettings(fp);
settings.getGenerator().setColorWithGlass(load(image));
msg("Set color with glass!").send(fp);
@ -695,7 +695,7 @@ public class CFICommands extends MethodCommands {
"The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance"
)
@CommandPermissions("worldedit.anvil.cfi")
public void color(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException, WorldEditException {
public void color(FawePlayer fp, FawePrimitiveBinding.ImageUri image, FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException {
CFISettings settings = assertSettings(fp);
HeightMapMCAGenerator gen = settings.getGenerator();
if (imageMask != null) {
@ -719,7 +719,7 @@ public class CFICommands extends MethodCommands {
"The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance"
)
@CommandPermissions("worldedit.anvil.cfi")
public void blockbiome(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException, WorldEditException {
public void blockbiome(FawePlayer fp, FawePrimitiveBinding.ImageUri image, FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException {
CFISettings settings = assertSettings(fp);
settings.getGenerator().setBlockAndBiomeColor(load(image), mask, load(imageMask), !disableWhiteOnly);
msg("Set color with blocks and biomes!").send(fp);
@ -735,7 +735,7 @@ public class CFICommands extends MethodCommands {
" - If you changed the block to something other than grass you will not see anything."
)
@CommandPermissions("worldedit.anvil.cfi")
public void biomecolor(FawePlayer fp, FawePrimitiveBinding.ImageUri image, @Optional FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws ParameterException, WorldEditException {
public void biomecolor(FawePlayer fp, FawePrimitiveBinding.ImageUri image, FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException {
CFISettings settings = assertSettings(fp);
settings.getGenerator().setBiomeColor(load(image));
msg("Set color with biomes!").send(fp);
@ -750,7 +750,7 @@ public class CFICommands extends MethodCommands {
desc = "Color the world using an image"
)
@CommandPermissions("worldedit.anvil.cfi")
public void coloring(FawePlayer fp) throws ParameterException {
public void coloring(FawePlayer fp) {
CFISettings settings = assertSettings(fp);
settings.popMessages(fp);
settings.setCategory("coloring");
@ -834,7 +834,7 @@ public class CFICommands extends MethodCommands {
desc = "Select a mask"
)
@CommandPermissions("worldedit.anvil.cfi")
public void mask(FawePlayer fp, @Optional FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly, InjectedValueAccess context) throws ParameterException{
public void mask(FawePlayer fp, FawePrimitiveBinding.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly, InjectedValueAccess context){
CFISettings settings = assertSettings(fp);
String[] split = getArguments(context).split(" ");
int index = 2;
@ -859,7 +859,7 @@ public class CFICommands extends MethodCommands {
desc = "Select a pattern"
)
@CommandPermissions("worldedit.anvil.cfi")
public void pattern(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern", def = "") Pattern pattern, InjectedValueAccess context) throws ParameterException, CommandException {
public void pattern(FawePlayer fp, @Arg(name = "pattern", desc = "Pattern", def = "") Pattern pattern, InjectedValueAccess context) {
CFISettings settings = assertSettings(fp);
String[] split = getArguments(context).split(" ");
int index = 2;
@ -869,7 +869,7 @@ public class CFICommands extends MethodCommands {
StringBuilder cmd = new StringBuilder(alias() + " pattern ");
if (pattern != null) {
dispathcer.call(settings.getCategory(), context.getLocals(), new String[0]);
dispatcher.call(settings.getCategory(), context.getLocals(), new String[0]);
} else {
msg(">> Current Settings <<").newline()
.text("Pattern ").text("[Click Here]").suggestTip(cmd + " stone")
@ -883,7 +883,7 @@ public class CFICommands extends MethodCommands {
desc = "Download the current image"
)
@CommandPermissions("worldedit.anvil.cfi")
public void download(FawePlayer fp) throws ParameterException, IOException {
public void download(FawePlayer fp) throws IOException {
CFISettings settings = assertSettings(fp);
BufferedImage image = settings.getGenerator().draw();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@ -899,7 +899,7 @@ public class CFICommands extends MethodCommands {
desc = "Select an image"
)
@CommandPermissions("worldedit.anvil.cfi")
public void image(FawePlayer fp, @Optional FawePrimitiveBinding.ImageUri image, InjectedValueAccess context) throws ParameterException, CommandException {
public void image(FawePlayer fp, @Optional FawePrimitiveBinding.ImageUri image, InjectedValueAccess context) throws CommandException {
CFISettings settings = getSettings(fp);
String[] split = getArguments(context).split(" ");
int index = 2;
@ -921,7 +921,7 @@ public class CFICommands extends MethodCommands {
return;
} else {
String next = Commands.getAlias(CFICommands.class, "heightmap " + settings.imageArg);
dispathcer.call(next, context.getLocals(), new String[0]);
dispatcher.call(next, context.getLocals(), new String[0]);
return;
}
}
@ -932,7 +932,7 @@ public class CFICommands extends MethodCommands {
desc = ""
)
@CommandPermissions("worldedit.anvil.cfi")
public void populate(FawePlayer fp) throws ParameterException {
public void populate(FawePlayer fp) {
CFISettings settings = assertSettings(fp);
settings.popMessages(fp);
settings.setCategory("populate");
@ -949,7 +949,7 @@ public class CFICommands extends MethodCommands {
desc = "Components menu"
)
@CommandPermissions("worldedit.anvil.cfi")
public void component(FawePlayer fp) throws ParameterException {
public void component(FawePlayer fp) {
CFISettings settings = assertSettings(fp);
settings.popMessages(fp);
settings.setCategory("component");
@ -1027,7 +1027,7 @@ public class CFICommands extends MethodCommands {
}
private CFISettings assertSettings(FawePlayer fp) throws ParameterException {
private CFISettings assertSettings(FawePlayer fp) {
CFISettings settings = getSettings(fp);
if (!settings.hasGenerator()) {
throw new ParameterException("Please use /" + alias());

View File

@ -1,16 +1,16 @@
package com.boydti.fawe.command;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.util.command.parametric.BindingHelper;
public class FaweBinding extends BindingHelper {
private final WorldEdit worldEdit;
public FaweBinding(WorldEdit worldEdit) {
this.worldEdit = worldEdit;
}
public WorldEdit getWorldEdit() {
return worldEdit;
}
}
//package com.boydti.fawe.command;
//
//import com.sk89q.worldedit.WorldEdit;
//import com.sk89q.worldedit.util.command.parametric.BindingHelper;
//
//public class FaweBinding extends BindingHelper {
// private final WorldEdit worldEdit;
//
// public FaweBinding(WorldEdit worldEdit) {
// this.worldEdit = worldEdit;
// }
//
// public WorldEdit getWorldEdit() {
// return worldEdit;
// }
//}

View File

@ -1,29 +1,29 @@
package com.boydti.fawe.command;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.util.command.parametric.ParameterData;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class MaskBinding extends FaweBinding {
private final WorldEdit worldEdit;
public MaskBinding(WorldEdit worldEdit) {
super(worldEdit);
this.worldEdit = worldEdit;
}
@Override
public List<String> getSuggestions(ParameterData parameter, String prefix) {
if (prefix.isEmpty()) {
return Stream.concat(Stream.of("#"), BlockTypes.getNameSpaces().stream().map(n -> n + ":")).collect(Collectors.toList());
}
return super.getSuggestions(parameter, prefix);
}
}
//package com.boydti.fawe.command;
//
//import com.sk89q.worldedit.WorldEdit;
//import com.sk89q.worldedit.util.command.parametric.ParameterData;
//import com.sk89q.worldedit.world.block.BlockTypes;
//
//import java.util.ArrayList;
//import java.util.HashSet;
//import java.util.List;
//import java.util.Set;
//import java.util.stream.Collectors;
//import java.util.stream.Stream;
//
//public class MaskBinding extends FaweBinding {
// private final WorldEdit worldEdit;
//
// public MaskBinding(WorldEdit worldEdit) {
// super(worldEdit);
// this.worldEdit = worldEdit;
// }
//
// @Override
// public List<String> getSuggestions(ParameterData parameter, String prefix) {
// if (prefix.isEmpty()) {
// return Stream.concat(Stream.of("#"), BlockTypes.getNameSpaces().stream().map(n -> n + ":")).collect(Collectors.toList());
// }
// return super.getSuggestions(parameter, prefix);
// }
//}

View File

@ -1,26 +1,26 @@
package com.boydti.fawe.command;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.util.command.parametric.ParameterData;
import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class PatternBinding extends FaweBinding {
private final WorldEdit worldEdit;
public PatternBinding(WorldEdit worldEdit) {
super(worldEdit);
this.worldEdit = worldEdit;
}
@Override
public List<String> getSuggestions(ParameterData parameter, String prefix) {
if (prefix.isEmpty()) {
return Stream.concat(Stream.of("#"), BlockTypes.getNameSpaces().stream()).collect(Collectors.toList());
}
return super.getSuggestions(parameter, prefix);
}
}
//package com.boydti.fawe.command;
//
//import com.sk89q.worldedit.WorldEdit;
//import com.sk89q.worldedit.util.command.parametric.ParameterData;
//import com.sk89q.worldedit.world.block.BlockTypes;
//
//import java.util.List;
//import java.util.stream.Collectors;
//import java.util.stream.Stream;
//
//public class PatternBinding extends FaweBinding {
// private final WorldEdit worldEdit;
//
// public PatternBinding(WorldEdit worldEdit) {
// super(worldEdit);
// this.worldEdit = worldEdit;
// }
//
// @Override
// public List<String> getSuggestions(ParameterData parameter, String prefix) {
// if (prefix.isEmpty()) {
// return Stream.concat(Stream.of("#"), BlockTypes.getNameSpaces().stream()).collect(Collectors.toList());
// }
// return super.getSuggestions(parameter, prefix);
// }
//}

View File

@ -21,8 +21,10 @@ import java.io.IOException;
import java.util.function.Function;
public class PlotLoader {
@Deprecated
public static void autoClaimFromDatabase(PlotPlayer player, PlotArea area, PlotId start, com.github.intellectualsites.plotsquared.plot.object.RunnableVal<Plot> whenDone) {
public static void autoClaimFromDatabase(PlotPlayer player, PlotArea area, PlotId start,
com.github.intellectualsites.plotsquared.plot.object.RunnableVal<Plot> whenDone) {
final Plot plot = area.getNextFreePlot(player, start);
if (plot == null) {
whenDone.run(null);
@ -30,15 +32,12 @@ public class PlotLoader {
}
whenDone.value = plot;
plot.owner = player.getUUID();
DBFunc.createPlotSafe(plot, whenDone, new Runnable() {
@Override
public void run() {
autoClaimFromDatabase(player, area, plot.getId(), whenDone);
}
});
DBFunc.createPlotSafe(plot, whenDone,
() -> autoClaimFromDatabase(player, area, plot.getId(), whenDone));
}
public void load(FawePlayer fp, CFICommands.CFISettings settings, Function<File, Boolean> createTask) throws IOException {
public void load(FawePlayer fp, CFICommands.CFISettings settings,
Function<File, Boolean> createTask) throws IOException {
PlotAreaManager manager = PlotSquared.get().getPlotAreaManager();
if (manager instanceof SinglePlotAreaManager) {
SinglePlotAreaManager sManager = (SinglePlotAreaManager) manager;
@ -49,7 +48,8 @@ public class PlotLoader {
Plot plot = TaskManager.IMP.sync(new RunnableVal<Plot>() {
@Override
public void run(Plot o) {
int currentPlots = Settings.Limit.GLOBAL ? player.getPlotCount() : player.getPlotCount(area.worldname);
int currentPlots = Settings.Limit.GLOBAL ? player.getPlotCount()
: player.getPlotCount(area.worldname);
int diff = player.getAllowedPlots() - currentPlots;
if (diff < 1) {
Captions.CANT_CLAIM_MORE_PLOTS_NUM.send(player, -diff);
@ -73,12 +73,7 @@ public class PlotLoader {
File folder = CFICommands.getFolder(plot.getWorldName());
Boolean result = createTask.apply(folder);
if (result == Boolean.TRUE) {
TaskManager.IMP.sync(new RunnableVal<Object>() {
@Override
public void run(Object value) {
plot.teleportPlayer(player);
}
});
TaskManager.IMP.sync(() -> plot.teleportPlayer(player));
}
return;
}

View File

@ -25,7 +25,7 @@ public class Rollback extends FaweCommand {
}
@Override
public boolean execute(final FawePlayer player, final String... args) {
public boolean execute(FawePlayer player, String... args) {
if (!Settings.IMP.HISTORY.USE_DATABASE) {
BBC.SETTING_DISABLE.send(player, "history.use-database (Import with /frb #import )");
return false;
@ -50,12 +50,11 @@ public class Rollback extends FaweCommand {
}
World world = player.getWorld();
switch (args[0]) {
default: {
default:
BBC.COMMAND_SYNTAX.send(player, "/frb info u:<uuid> r:<radius> t:<time>");
return false;
}
case "i":
case "info": {
case "info":
if (args.length < 2) {
BBC.COMMAND_SYNTAX.send(player, "/frb <info|undo> u:<uuid> r:<radius> t:<time>");
return false;
@ -88,16 +87,15 @@ public class Rollback extends FaweCommand {
player.sendMessage("&8 - &7(" + percentString + ")");
}
player.sendMessage("&d==================================================");
player.sendMessage("&dSize: " + (((double) (total / 1024)) / 1000) + "MB");
player.sendMessage("&dSize: " + (double) (total / 1024) / 1000 + "MB");
player.sendMessage("&dTo rollback: /frb undo");
player.sendMessage("&d==================================================");
player.setMeta(FawePlayer.METADATA_KEYS.ROLLBACK, edits);
}
});
break;
}
case "undo":
case "revert": {
case "revert":
if (!player.hasPermission("fawe.rollback.perform")) {
BBC.NO_PERM.send(player, "fawe.rollback.perform");
return false;
@ -124,12 +122,11 @@ public class Rollback extends FaweCommand {
}
};
task.run();
}
}
return true;
}
public void rollback(final FawePlayer player, final boolean shallow, final String[] args, final RunnableVal<List<DiskStorageHistory>> result) {
public void rollback(FawePlayer player, boolean shallow, String[] args, RunnableVal<List<DiskStorageHistory>> result) {
UUID user = null;
int radius = Integer.MAX_VALUE;
long time = Long.MAX_VALUE;
@ -142,7 +139,7 @@ public class Rollback extends FaweCommand {
switch (split[0].toLowerCase()) {
case "username":
case "user":
case "u": {
case "u":
try {
if (split[1].length() > 16) {
user = UUID.fromString(split[1]);
@ -156,25 +153,21 @@ public class Rollback extends FaweCommand {
return;
}
break;
}
case "r":
case "radius": {
case "radius":
if (!MathMan.isInteger(split[1])) {
player.sendMessage("&dInvalid radius: " + split[1]);
return;
}
radius = Integer.parseInt(split[1]);
break;
}
case "t":
case "time": {
case "time":
time = MainUtil.timeToSec(split[1]) * 1000;
break;
}
default: {
default:
BBC.COMMAND_SYNTAX.send(player, "/frb <info|undo> u:<uuid> r:<radius> t:<time>");
return;
}
}
}
Location origin = player.getLocation();

View File

@ -14,7 +14,6 @@ import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.WEManager;
import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper;
import com.boydti.fawe.wrappers.PlayerWrapper;
import org.enginehub.piston.inject.InjectedValueAccess;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.EmptyClipboardException;
import com.sk89q.worldedit.IncompleteRegionException;
@ -45,14 +44,13 @@ import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Field;
import java.text.NumberFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicInteger;
import org.enginehub.piston.inject.InjectedValueAccess;
import org.jetbrains.annotations.NotNull;
public abstract class FawePlayer<T> extends Metadatable {
@ -149,15 +147,11 @@ public abstract class FawePlayer<T> extends Metadatable {
private void setConfirmTask(@NotNull Runnable task, InjectedValueAccess context, String command) {
CommandEvent event = new CommandEvent(getPlayer(), command);
if (task != null) {
Runnable newTask = () -> PlatformCommandManager.getInstance().handleCommandTask(() -> {
task.run();
return null;
}, context, getPlayer(), getSession(), event);
setMeta("cmdConfirm", newTask);
} else {
setMeta("cmdConfirm", event);
}
Runnable newTask = () -> PlatformCommandManager.getInstance().handleCommandTask(() -> {
task.run();
return null;
}, context, getPlayer(), getSession(), event);
setMeta("cmdConfirm", newTask);
}
public void checkConfirmation(@NotNull Runnable task, String command, int times, int limit, InjectedValueAccess context) throws RegionOperationException {

View File

@ -1,5 +1,7 @@
package com.boydti.fawe.object.brush;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.object.brush.scroll.ScrollAction;
import com.boydti.fawe.object.extent.ResettableExtent;
@ -19,7 +21,6 @@ import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.internal.expression.runtime.Constant;
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
@ -27,8 +28,6 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import static com.google.common.base.Preconditions.checkNotNull;
public class BrushSettings {
public enum SettingType {
BRUSH,
@ -64,10 +63,7 @@ public class BrushSettings {
if (constructor == null) {
return new BrushSettings();
}
String[] split = constructor.split(" ");
String args = constructor.replaceAll(split[0] + "[ ]?", "");
BrushSettings bs = (BrushSettings) manager.parse(Brush.class, args, player);
BrushSettings bs = (BrushSettings) manager.parseArgs(constructor);
bs.constructor.put(SettingType.BRUSH, constructor);
if (settings.containsKey(SettingType.PERMISSIONS.name())) {
bs.permissions.addAll((Collection<? extends String>) settings.get(SettingType.PERMISSIONS.name()));

View File

@ -14,7 +14,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
public class ScalableHeightMap implements com.boydti.fawe.object.brush.heightmap.HeightMap {
public class ScalableHeightMap implements HeightMap {
public int size2;
public int size;
@ -103,10 +103,10 @@ public class ScalableHeightMap implements com.boydti.fawe.object.brush.heightmap
for (int x = 0; x < width; x++) {
for (int z = 0; z < length; z++) {
int pixel = heightFile.getRGB(x, z);
int red = (pixel >> 16) & 0xFF;
int green = (pixel >> 8) & 0xFF;
int blue = (pixel >> 0) & 0xFF;
int alpha = (pixel >> 24) & 0xFF;
int red = pixel >> 16 & 0xFF;
int green = pixel >> 8 & 0xFF;
int blue = pixel >> 0 & 0xFF;
int alpha = pixel >> 24 & 0xFF;
int intensity = (int) (alpha * ((red + green + blue) * third) * alphaInverse);
array[x][z] = (byte) intensity;
}

View File

@ -11,21 +11,21 @@ public enum Perm {
public String s;
public String cat;
Perm(final String perm, final String cat) {
Perm(String perm, String cat) {
this.s = perm;
this.cat = cat;
}
public boolean has(final FawePlayer<?> player) {
public boolean has(FawePlayer<?> player) {
return this.hasPermission(player, this);
}
public boolean hasPermission(final FawePlayer<?> player, final Perm perm) {
public boolean hasPermission(FawePlayer<?> player, Perm perm) {
return hasPermission(player, perm.s);
}
public static boolean hasPermission(final FawePlayer<?> player, final String perm) {
if ((player == null) || player.hasPermission(ADMIN.s)) {
public static boolean hasPermission(FawePlayer<?> player, String perm) {
if (player == null || player.hasPermission(ADMIN.s)) {
return true;
}
if (player.hasPermission(perm)) {
@ -33,8 +33,8 @@ public enum Perm {
}
final String[] nodes = perm.split("\\.");
final StringBuilder n = new StringBuilder();
for (int i = 0; i < (nodes.length - 1); i++) {
n.append(nodes[i] + ("."));
for (int i = 0; i < nodes.length - 1; i++) {
n.append(nodes[i]).append(".");
if (player.hasPermission(n + "*")) {
return true;
}

View File

@ -32,7 +32,7 @@ public class RandomTextureUtil extends CachedTextureUtil {
private int random(int i) {
if (i < 0) {
int i1 = (-i);
int i1 = -i;
return -ThreadLocalRandom.current().nextInt(i1);
} else {
return ThreadLocalRandom.current().nextInt(i);

View File

@ -1,7 +1,5 @@
package com.boydti.fawe.util;
import com.sk89q.util.StringUtil;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
@ -10,17 +8,17 @@ import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.function.Function;
import java.util.function.IntConsumer;
import java.util.function.IntFunction;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class StringMan {
public static String replaceFromMap(final String string, final Map<String, String> replacements) {
public static String replaceFromMap(String string, Map<String, String> replacements) {
final StringBuilder sb = new StringBuilder(string);
int size = string.length();
for (final Entry<String, String> entry : replacements.entrySet()) {
for (Entry<String, String> entry : replacements.entrySet()) {
if (size == 0) {
break;
}
@ -122,7 +120,6 @@ public class StringMan {
boolean neg = false;
int numIndex = 1;
int len = string.length();
outer:
for (int i = len - 1; i >= 0; i--) {
char c = string.charAt(i);
switch (c) {
@ -138,10 +135,10 @@ public class StringMan {
return val;
}
public static String removeFromSet(final String string, final Collection<String> replacements) {
public static String removeFromSet(String string, Collection<String> replacements) {
final StringBuilder sb = new StringBuilder(string);
int size = string.length();
for (final String key : replacements) {
for (String key : replacements) {
if (size == 0) {
break;
}
@ -178,8 +175,9 @@ public class StringMan {
boolean inQuotes = false;
for (int current = 0; current < input.length(); current++) {
char currentChar = input.charAt(current);
boolean atLastChar = (current == input.length() - 1);
if (!atLastChar && (bracket > 0 || (currentChar == '{' && ++bracket > 0) || (current == '}' && --bracket <= 0)))
boolean atLastChar = current == input.length() - 1;
if (!atLastChar && (bracket > 0 || currentChar == '{' && ++bracket > 0
|| current == '}' && --bracket <= 0))
continue;
if (currentChar == '\"') inQuotes = !inQuotes; // toggle state
if (atLastChar) result.add(input.substring(start));
@ -195,9 +193,9 @@ public class StringMan {
return result;
}
public static int intersection(final Set<String> options, final String[] toCheck) {
public static int intersection(Set<String> options, String[] toCheck) {
int count = 0;
for (final String check : toCheck) {
for (String check : toCheck) {
if (options.contains(check)) {
count++;
}
@ -213,7 +211,7 @@ public class StringMan {
return String.format("%1$" + n + "s", s);
}
public static String getString(final Object obj) {
public static String getString(Object obj) {
if (obj == null) {
return "null";
}
@ -221,18 +219,18 @@ public class StringMan {
return (String) obj;
}
if (obj.getClass().isArray()) {
String result = "";
StringBuilder result = new StringBuilder();
String prefix = "";
for (int i = 0; i < Array.getLength(obj); i++) {
result += prefix + getString(Array.get(obj, i));
result.append(prefix).append(getString(Array.get(obj, i)));
prefix = ",";
}
return "{ " + result + " }";
} else if (obj instanceof Collection<?>) {
StringBuilder result = new StringBuilder();
String prefix = "";
for (final Object element : (Collection<?>) obj) {
for (Object element : (Collection<?>) obj) {
result.append(prefix).append(getString(element));
prefix = ",";
}
@ -242,7 +240,7 @@ public class StringMan {
}
}
public static String replaceFirst(final char c, final String s) {
public static String replaceFirst(char c, String s) {
if (s == null) {
return "";
}
@ -253,8 +251,8 @@ public class StringMan {
final char[] newChars = new char[chars.length];
int used = 0;
boolean found = false;
for (final char cc : chars) {
if (!found && (c == cc)) {
for (char cc : chars) {
if (!found && c == cc) {
found = true;
} else {
newChars[used++] = cc;
@ -268,7 +266,7 @@ public class StringMan {
return s;
}
public static String replaceAll(final String string, final Object... pairs) {
public static String replaceAll(String string, Object... pairs) {
final StringBuilder sb = new StringBuilder(string);
for (int i = 0; i < pairs.length; i += 2) {
final String key = pairs[i] + "";
@ -284,56 +282,57 @@ public class StringMan {
return sb.toString();
}
public static boolean isAlphanumeric(final String str) {
public static boolean isAlphanumeric(String str) {
for (int i = 0; i < str.length(); i++) {
final char c = str.charAt(i);
if ((c < 0x30) || ((c >= 0x3a) && (c <= 0x40)) || ((c > 0x5a) && (c <= 0x60)) || (c > 0x7a)) {
if (c < 0x30 || c >= 0x3a && c <= 0x40 || c > 0x5a && c <= 0x60 ||
c > 0x7a) {
return false;
}
}
return true;
}
public static boolean isAlphanumericUnd(final CharSequence str) {
public static boolean isAlphanumericUnd(CharSequence str) {
for (int i = 0; i < str.length(); i++) {
final char c = str.charAt(i);
if ((c < 0x30) || ((c >= 0x3a) && (c <= 0x40)) || ((c > 0x5a) && (c <= 0x60)) || (c > 0x7a) || (c == '_')) {
if (c < 0x30 || c >= 0x3a && c <= 0x40 || c > 0x5a && c <= 0x60 || c > 0x7a) {
return false;
}
}
return true;
}
public static boolean isAlpha(final String str) {
public static boolean isAlpha(String str) {
for (int i = 0; i < str.length(); i++) {
final char c = str.charAt(i);
if ((c <= 0x40) || ((c > 0x5a) && (c <= 0x60)) || (c > 0x7a)) {
if (c <= 0x40 || c > 0x5a && c <= 0x60 || c > 0x7a) {
return false;
}
}
return true;
}
public static String join(final Collection<?> collection, final String delimiter) {
public static String join(Collection<?> collection, String delimiter) {
return join(collection.toArray(), delimiter);
}
public static String joinOrdered(final Collection<?> collection, final String delimiter) {
public static String joinOrdered(Collection<?> collection, String delimiter) {
final Object[] array = collection.toArray();
Arrays.sort(array, Comparator.comparingInt(Object::hashCode));
return join(array, delimiter);
}
public static String join(final Collection<?> collection, final char delimiter) {
public static String join(Collection<?> collection, char delimiter) {
return join(collection.toArray(), delimiter + "");
}
public static boolean isAsciiPrintable(final char c) {
return (c >= ' ') && (c < '');
public static boolean isAsciiPrintable(char c) {
return c >= ' ' && c < '';
}
public static boolean isAsciiPrintable(final String s) {
for (final char c : s.toCharArray()) {
public static boolean isAsciiPrintable(String s) {
for (char c : s.toCharArray()) {
if (!isAsciiPrintable(c)) {
return false;
}
@ -427,7 +426,7 @@ public class StringMan {
return p[n];
}
public static <T> String join(Collection<T> arr, final String delimiter, Function<T, String> funx) {
public static <T> String join(Collection<T> arr, String delimiter, Function<T, String> funx) {
final StringBuilder result = new StringBuilder();
int i = 0;
for (T obj : arr) {
@ -440,7 +439,7 @@ public class StringMan {
return result.toString();
}
public static String join(final Object[] array, final String delimiter) {
public static String join(Object[] array, String delimiter) {
switch (array.length) {
case 0:
return "";
@ -489,16 +488,13 @@ public class StringMan {
return negative ? -value : value;
}
public static String join(final int[] array, final String delimiter) {
final Integer[] wrapped = new Integer[array.length];
for (int i = 0; i < array.length; i++) {
wrapped[i] = array[i];
}
public static String join(int[] array, String delimiter) {
final Integer[] wrapped = Arrays.stream(array).boxed().toArray(Integer[]::new);
return join(wrapped, delimiter);
}
public static boolean isEqualToAny(final String a, final String... args) {
for (final String arg : args) {
public static boolean isEqualToAny(String a, String... args) {
for (String arg : args) {
if (StringMan.isEqual(a, arg)) {
return true;
}
@ -506,8 +502,8 @@ public class StringMan {
return false;
}
public static boolean isEqualIgnoreCaseToAny(final String a, final String... args) {
for (final String arg : args) {
public static boolean isEqualIgnoreCaseToAny(String a, String... args) {
for (String arg : args) {
if (StringMan.isEqualIgnoreCase(a, arg)) {
return true;
}
@ -515,19 +511,18 @@ public class StringMan {
return false;
}
public static boolean isEqual(final String a, final String b) {
return ((a == b) || ((a != null) && (b != null) && (a.length() == b.length()) && (a.hashCode() == b.hashCode()) && a.equals(b)));
public static boolean isEqual(String a, String b) {
return a == b || a != null && b != null && a.length() == b.length()
&& a.hashCode() == b.hashCode()
&& a.equals(b);
}
public static boolean isEqualIgnoreCase(final String a, final String b) {
return ((a == b) || ((a != null) && (b != null) && (a.length() == b.length()) && a.equalsIgnoreCase(b)));
public static boolean isEqualIgnoreCase(String a, String b) {
return Objects.equals(a, b) ||
a != null && b != null && a.length() == b.length() && a.equalsIgnoreCase(b);
}
public static String repeat(final String s, final int n) {
final StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) {
sb.append(s);
}
return sb.toString();
public static String repeat(String s, int n) {
return IntStream.range(0, n).mapToObj(i -> s).collect(Collectors.joining());
}
}

View File

@ -271,12 +271,12 @@ public abstract class TaskManager {
return sync(function, Integer.MAX_VALUE);
}
public void wait(AtomicBoolean running, int timout) {
public void wait(AtomicBoolean running, int timeout) {
try {
long start = System.currentTimeMillis();
synchronized (running) {
while (running.get()) {
running.wait(timout);
running.wait(timeout);
if (running.get() && System.currentTimeMillis() - start > Settings.IMP.QUEUE.DISCARD_AFTER_MS) {
new RuntimeException("FAWE is taking a long time to execute a task (might just be a symptom): ").printStackTrace();
Fawe.debug("For full debug information use: /fawe threads");

View File

@ -1,23 +1,26 @@
package com.boydti.fawe.web;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.MainUtil;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.UtilityCommands;
import java.io.*;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import java.util.function.Consumer;
public class SchemSync implements Runnable {
private final static char PORT = 62522;
private final File tokensFile;
@ -38,7 +41,8 @@ public class SchemSync implements Runnable {
}
public SchemSync() {
this.tokensFile = MainUtil.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.TOKENS, "tokens.txt");
this.tokensFile = MainUtil
.getFile(Fawe.imp().getDirectory(), Settings.IMP.PATHS.TOKENS, "tokens.txt");
this.worldEdit = WorldEdit.getInstance();
LocalConfiguration config = worldEdit.getConfiguration();
this.working = worldEdit.getWorkingDirectoryFile(config.saveDir);
@ -60,33 +64,39 @@ public class SchemSync implements Runnable {
public synchronized void run() {
try {
byte[] header = new byte[32];
try (ServerSocket serverSocket = this.serverSocket = new ServerSocket(PORT)){
try (ServerSocket serverSocket = this.serverSocket = new ServerSocket(PORT)) {
while (!Thread.interrupted()) {
try {
try (Socket clientSocket = this.clientSocket = serverSocket.accept()){
try (Socket clientSocket = this.clientSocket = serverSocket.accept()) {
try (InputStream in = clientSocket.getInputStream()) {
int read = in.read(header);
if (read != header.length) close(Error.INVALID_HEADER_LENGTH);
if (read != header.length) {
close(Error.INVALID_HEADER_LENGTH);
}
ByteBuffer buf = ByteBuffer.wrap(header);
UUID uuid = new UUID(buf.getLong(), buf.getLong());
UUID expectedToken = tokens.get(uuid);
if (expectedToken == null) close(Error.TOKEN_REJECTED);
if (expectedToken == null) {
close(Error.TOKEN_REJECTED);
}
UUID receivedToken = new UUID(buf.getLong(), buf.getLong());
if (!receivedToken.equals(expectedToken)) continue;
if (!receivedToken.equals(expectedToken)) {
continue;
}
try (DataInputStream dis = new DataInputStream(in)) {
File dir = new File(working, uuid.toString());
int data = dis.readByte() & 0xFF;
switch (data) {
case 0: {// list
try (DataOutputStream out = new DataOutputStream(clientSocket.getOutputStream())) {
case 0: // list
try (DataOutputStream out = new DataOutputStream(
clientSocket.getOutputStream())) {
out.write(1);
UtilityCommands.allFiles(dir.listFiles(), true, new Consumer<File>() {
@Override
public void accept(File file) {
UtilityCommands.allFiles(dir.listFiles(), true,
file -> {
try {
String path = dir.toURI()
.relativize(file.toURI()).getPath();
@ -94,12 +104,10 @@ public class SchemSync implements Runnable {
} catch (IOException e) {
e.printStackTrace();
}
}
});
});
}
break;
}
case 1: {// get
case 1: // get
String input = dis.readUTF();
File file = new File(dir, input);
if (!MainUtil.isInSubDirectory(dir, file)) {
@ -110,12 +118,12 @@ public class SchemSync implements Runnable {
}
// todo send file
}
}
}
}
}
} catch (FaweException ignore) {}
} catch (FaweException ignore) {
}
}
}
} catch (IOException e) {

View File

@ -26,9 +26,11 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class CommandContext {
protected final String command;
protected final List<String> parsedArgs;
@ -55,7 +57,7 @@ public class CommandContext {
this(args.split(" ", -1), valueFlags);
}
public CommandContext(String args, Set<Character> valueFlags, boolean allowHangingFlag)
public CommandContext(String args, Set<Character> valueFlags, boolean allowHangingFlag)
throws CommandException {
this(args.split(" ", -1), valueFlags, allowHangingFlag, new CommandLocals());
}
@ -107,7 +109,7 @@ public class CommandContext {
List<String> argList = new ArrayList<>(args.length);
for (int i = 1; i < args.length; ++i) {
isHanging = false;
String arg = args[i];
if (arg.isEmpty()) {
isHanging = true;
@ -216,7 +218,7 @@ public class CommandContext {
parsedArgs.add(arg);
}
}
this.suggestionContext = suggestionContext;
}
@ -248,17 +250,14 @@ public class CommandContext {
}
return buffer.toString();
}
public String getRemainingString(int start) {
return getString(start, parsedArgs.size() - 1);
}
public String getString(int start, int end) {
StringBuilder buffer = new StringBuilder(parsedArgs.get(start));
for (int i = start + 1; i < end + 1; ++i) {
buffer.append(" ").append(parsedArgs.get(i));
}
return buffer.toString();
return IntStream.range(start + 1, end + 1).mapToObj(i -> " " + parsedArgs.get(i))
.collect(Collectors.joining("", parsedArgs.get(start), ""));
}
public int getInteger(int index) throws NumberFormatException {

View File

@ -20,9 +20,6 @@
package com.sk89q.minecraft.util.commands;
import com.sk89q.util.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
@ -33,6 +30,9 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.enginehub.piston.inject.InjectedValueAccess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Manager for handling commands. This allows you to easily process commands,

View File

@ -1,53 +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.minecraft.util.commands;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
public class SimpleInjector implements Injector {
private static final Logger log = LoggerFactory.getLogger(SimpleInjector.class);
private Object[] args;
private Class<?>[] argClasses;
public SimpleInjector(Object... args) {
this.args = args;
argClasses = new Class[args.length];
for (int i = 0; i < args.length; ++i) {
argClasses[i] = args[i].getClass();
}
}
@Override
public Object getInstance(Class<?> clazz) {
try {
Constructor<?> ctr = clazz.getConstructor(argClasses);
ctr.setAccessible(true);
return ctr.newInstance(args);
} catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
log.error("Error initializing commands class " + clazz, e);
return null;
}
}
}

View File

@ -19,6 +19,8 @@
package com.sk89q.worldedit.command;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.command.FawePrimitiveBinding;
import com.boydti.fawe.config.BBC;
@ -65,6 +67,7 @@ import com.sk89q.worldedit.EmptyClipboardException;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.factory.TreeGeneratorFactory;
import com.sk89q.worldedit.command.tool.BrushTool;
import com.sk89q.worldedit.command.tool.InvalidToolBindException;
import com.sk89q.worldedit.command.tool.brush.Brush;
@ -74,6 +77,7 @@ import com.sk89q.worldedit.command.tool.brush.CylinderBrush;
import com.sk89q.worldedit.command.tool.brush.GravityBrush;
import com.sk89q.worldedit.command.tool.brush.HollowCylinderBrush;
import com.sk89q.worldedit.command.tool.brush.HollowSphereBrush;
import com.sk89q.worldedit.command.tool.brush.OperationFactoryBrush;
import com.sk89q.worldedit.command.tool.brush.SmoothBrush;
import com.sk89q.worldedit.command.tool.brush.SphereBrush;
import com.sk89q.worldedit.command.util.CommandPermissions;
@ -83,28 +87,27 @@ import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import com.sk89q.worldedit.function.Contextual;
import com.sk89q.worldedit.function.factory.Deform;
import com.sk89q.worldedit.function.factory.Paint;
import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.annotation.Range;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.regions.factory.RegionFactory;
import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.TreeGenerator;
import com.sk89q.worldedit.world.block.BlockID;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
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.inject.InjectedValueAccess;
import org.enginehub.piston.inject.Key;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileInputStream;
@ -113,9 +116,13 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
import java.util.List;
import java.util.Optional;
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.inject.InjectedValueAccess;
import org.enginehub.piston.inject.Key;
/**
* Commands to set brush shape.
@ -191,13 +198,15 @@ public class BrushCommands extends MethodCommands {
aliases = {"recurse", "r"},
desc = "Set all connected blocks",
descFooter = "Set all connected blocks\n" +
"The -d flag Will apply in depth first order\n" +
"Note: Set a mask to recurse along specific blocks"
)
@CommandPermissions("worldedit.brush.recursive")
public BrushSettings recursiveBrush(Player player, LocalSession session, EditSession editSession, Pattern fill,
@Arg(desc = "The radius to sample for blending", def = "5")
Expression radius, @Switch(name='d', desc = "TODO") boolean depthFirst, InjectedValueAccess context) throws WorldEditException {
Expression radius,
@Switch(name='d', desc = "Apply in depth first order")
boolean depthFirst,
InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
return set(session, context,
new RecurseBrush(depthFirst))
@ -210,15 +219,17 @@ public class BrushCommands extends MethodCommands {
name = "line",
aliases = {"l"},
desc = "Create lines",
descFooter = "Create lines.\n" +
"The -h flag creates only a shell\n" +
"The -s flag selects the clicked point after drawing\n" +
"The -f flag creates a flat line"
)
@CommandPermissions("worldedit.brush.line")
public BrushSettings lineBrush(Player player, LocalSession session, Pattern fill,
@Arg(desc = "The radius to sample for blending", def = "0")
Expression radius, @Switch(name='h', desc = "TODO") boolean shell, @Switch(name='s', desc = "TODO") boolean select, @Switch(name='f', desc = "TODO") boolean flat, InjectedValueAccess context) throws WorldEditException {
Expression radius,
@Switch(name='h', desc = "Create only a shell")
boolean shell,
@Switch(name='s', desc = "Selects the clicked point after drawing")
boolean select,
@Switch(name='f', desc = "Create a flat line")
boolean flat, InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
return set(session, context,
new LineBrush(shell, select, flat))
@ -265,17 +276,19 @@ public class BrushCommands extends MethodCommands {
@Command(
name = "catenary",
aliases = {"cat", "gravityline", "saggedline"},
desc = "Create a hanging line between two points",
descFooter = "Create a hanging line between two points.\n" +
"The lengthFactor controls how long the line is\n" +
"The -h flag creates only a shell\n" +
"The -s flag selects the clicked point after drawing\n" +
"The -d flag sags the catenary toward the facing direction\n"
desc = "Create a hanging line between two points"
)
@CommandPermissions("worldedit.brush.spline")
public BrushSettings catenaryBrush(LocalSession session, Pattern fill, @Arg(def = "1.2", desc = "Length of wire compared to distance between points") @Range(min=1) double lengthFactor,
@Arg(desc = "The radius to sample for blending", def = "0")
Expression radius, @Switch(name='h', desc = "TODO") boolean shell, @Switch(name='s', desc = "TODO") boolean select, @Switch(name='d', desc = "TODO") boolean facingDirection, InjectedValueAccess context) throws WorldEditException {
Expression radius,
@Switch(name='h', desc = "Create only a shell")
boolean shell,
@Switch(name='s', desc = "Select the clicked point after drawing")
boolean select,
@Switch(name='d', desc = "sags the catenary toward the facing direction")
boolean facingDirection,
InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
Brush brush = new CatenaryBrush(shell, select, facingDirection, lengthFactor);
return set(session, context,
@ -384,18 +397,16 @@ public class BrushCommands extends MethodCommands {
@Command(
name = "stencil",
desc = "Use a height map to paint a surface",
descFooter = "Use a height map to paint any surface.\n" +
"The -w flag will only apply at maximum saturation\n" +
"The -r flag will apply random rotation"
descFooter = "Use a height map to paint any surface.\n"
)
@CommandPermissions("worldedit.brush.stencil")
public BrushSettings stencilBrush(Player player, LocalSession session, Pattern fill,
@Arg(name = "radius", desc = "Expression", def = "5") Expression radius,
@Arg(name = "image", desc = "String", def = "") String image,
@Arg(def = "0", desc = "rotation") @Step(90) @Range(min=0, max=360) final int rotation,
@Arg(name = "yscale", desc = "double", def = "1") final double yscale,
@Switch(name='w', desc = "TODO") boolean onlyWhite,
@Switch(name='r', desc = "TODO") boolean randomRotate,
@Arg(def = "0", desc = "rotation") @Range(min=0, max=360) int rotation,
@Arg(name = "yscale", desc = "double", def = "1") double yscale,
@Switch(name='w', desc = "Apply at maximum saturation") boolean onlyWhite,
@Switch(name='r', desc = "Apply random rotation") boolean randomRotate,
InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
worldEdit.checkMaxBrushRadius(radius);
InputStream stream = getHeightmapStream(image);
@ -418,16 +429,13 @@ public class BrushCommands extends MethodCommands {
name = "image",
aliases = {"color"},
desc = "Use a height map to paint a surface",
descFooter = "Use a height map to paint any surface.\n" +
"The -a flag will use image alpha\n" +
"The -f blends the image with the existing terrain"
)
descFooter = "Use a height map to paint any surface.\n")
@CommandPermissions("worldedit.brush.stencil")
public BrushSettings imageBrush(LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius,
FawePrimitiveBinding.ImageUri imageUri,
@Arg(def = "1", desc = "scale height") @Range(min=Double.MIN_NORMAL) final double yscale,
@Switch(name='a', desc = "TODO") boolean alpha,
@Switch(name='f', desc = "TODO") boolean fadeOut,
@Arg(def = "1", desc = "scale height") @Range(min=Double.MIN_NORMAL) double yscale,
@Switch(name='a', desc = "Use image Alpha") boolean alpha,
@Switch(name='f', desc = "Blend the image with existing terrain") boolean fadeOut,
InjectedValueAccess context) throws WorldEditException, IOException {
BufferedImage image = imageUri.load();
worldEdit.checkMaxBrushRadius(radius);
@ -454,7 +462,10 @@ public class BrushCommands extends MethodCommands {
"The -r flag will apply random rotation"
)
@CommandPermissions("worldedit.brush.surface")
public BrushSettings surfaceBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, InjectedValueAccess context) throws WorldEditException {
public BrushSettings surfaceBrush(LocalSession session, Pattern fill,
@Arg(name = "radius", desc = "Expression", def = "5")
Expression radius,
InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
return set(session, context, new SurfaceSphereBrush()).setFill(fill).setSize(radius);
}
@ -504,8 +515,7 @@ public class BrushCommands extends MethodCommands {
}
return set(session, context,
new PopulateSchem(mask, holders, (int) density, rotate))
.setSize(radius);
new PopulateSchem(mask, holders, (int) density, rotate)).setSize(radius);
} catch (IOException e) {
throw new RuntimeException(e);
}
@ -521,9 +531,7 @@ public class BrushCommands extends MethodCommands {
@CommandPermissions("worldedit.brush.layer")
public BrushSettings surfaceLayer(LocalSession session, Expression radius, List<BlockState> layers, InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
return set(session, context,
new LayerBrush(layers.toArray(new BlockState[0])))
.setSize(radius);
return set(session, context, new LayerBrush(layers.toArray(new BlockState[0]))).setSize(radius);
}
@Command(
@ -537,10 +545,7 @@ public class BrushCommands extends MethodCommands {
@CommandPermissions("worldedit.brush.splatter")
public BrushSettings splatterBrush(LocalSession session, Pattern fill, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "points", desc = "double", def = "1") double points, @Arg(name = "recursion", desc = "double", def = "5") double recursion, @Arg(name = "solid", desc = "boolean", def = "true") boolean solid, InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
return set(session, context,
new SplatterBrush((int) points, (int) recursion, solid))
.setSize(radius)
.setFill(fill);
return set(session, context, new SplatterBrush((int) points, (int) recursion, solid)).setSize(radius).setFill(fill);
}
@Command(
@ -596,7 +601,6 @@ public class BrushCommands extends MethodCommands {
aliases = { "copy" },
desc = "Choose the clipboard brush (Recommended: `/br copypaste`)",
descFooter = "Chooses the clipboard brush.\n" +
"The -a flag makes it not paste air.\n" +
"Without the -p flag, the paste will appear centered at the target location. " +
"With the flag, then the paste will appear relative to where you had " +
"stood relative to the copied area when you copied it."
@ -700,7 +704,7 @@ public class BrushCommands extends MethodCommands {
"Snow Pic: https://i.imgur.com/Hrzn0I4.png"
)
@CommandPermissions("worldedit.brush.height")
public BrushSettings heightBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") final String image, @Arg(def = "0", desc = "rotation") @Step(90) @Range(min=0, max=360) final int rotation, @Arg(name = "yscale", desc = "double", def = "1") final double yscale, @Switch(name='r', desc = "TODO") boolean randomRotate, @Switch(name='l', desc = "TODO") boolean layers, @Switch(name='s', desc = "TODO") boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
public BrushSettings heightBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Range(min=0, max=360) int rotation, @Arg(name = "yscale", desc = "double", def = "1") double yscale, @Switch(name='r', desc = "TODO") boolean randomRotate, @Switch(name='l', desc = "TODO") boolean layers, @Switch(name='s', desc = "TODO") boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
return terrainBrush(player, session, radius, image, rotation, yscale, false, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context);
}
@ -714,21 +718,23 @@ public class BrushCommands extends MethodCommands {
" - The `-s` flag disables smoothing"
)
@CommandPermissions("worldedit.brush.height")
public BrushSettings cliffBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Step(90) @Range(min=0, max=360) final int rotation, @Arg(name = "yscale", desc = "double", def = "1") final double yscale, @Switch(name='r', desc = "TODO") boolean randomRotate, @Switch(name='l', desc = "TODO") boolean layers, @Switch(name='s', desc = "TODO") boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
public BrushSettings cliffBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Step(90) @Range(min=0, max=360) int rotation, @Arg(name = "yscale", desc = "double", def = "1") double yscale, @Switch(name='r', desc = "TODO") boolean randomRotate, @Switch(name='l', desc = "TODO") boolean layers, @Switch(name='s', desc = "TODO") boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
return terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CYLINDER, context);
}
@Command(
name = "flatten",
aliases = {"flatmap", "flat"},
descFooter = "Flatten brush flattens terrain\n" +
" - The `-r` flag enables random off-axis rotation\n" +
" - The `-l` flag will work on snow layers\n" +
" - The `-s` flag disables smoothing",
desc = "This brush raises or lowers land towards the clicked point"
)
@CommandPermissions("worldedit.brush.height")
public BrushSettings flattenBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") final String image, @Arg(def = "0", desc = "rotation") @Step(90) @Range(min=0, max=360) final int rotation, @Arg(name = "yscale", desc = "double", def = "1") final double yscale, @Switch(name='r', desc = "TODO") boolean randomRotate, @Switch(name='l', desc = "TODO") boolean layers, @Switch(name='s', desc = "TODO") boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
public BrushSettings flattenBrush(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Arg(name = "image", desc = "String", def = "") String image, @Arg(def = "0", desc = "rotation") @Step(90) @Range(min=0, max=360) int rotation, @Arg(name = "yscale", desc = "double", def = "1") double yscale,
@Switch(name='r', desc = "Enables random off-axis rotation")
boolean randomRotate,
@Switch(name='l', desc = "Will work on snow layers")
boolean layers,
@Switch(name='s', desc = "Disables smoothing")
boolean dontSmooth, InjectedValueAccess context) throws WorldEditException, FileNotFoundException {
return terrainBrush(player, session, radius, image, rotation, yscale, true, randomRotate, layers, !dontSmooth, ScalableHeightMap.Shape.CONE, context);
}
@ -759,7 +765,7 @@ public class BrushCommands extends MethodCommands {
private InputStream getHeightmapStream(String filename) throws FileNotFoundException {
if (filename == null) return null;
String filenamePng = (filename.endsWith(".png") ? filename : filename + ".png");
String filenamePng = filename.endsWith(".png") ? filename : filename + ".png";
File file = new File(Fawe.imp().getDirectory(), Settings.IMP.PATHS.HEIGHTMAP + File.separator + filenamePng);
if (file.exists()) return new FileInputStream(file);
URI uri = ImageUtil.getImageURI(filename);
@ -773,13 +779,11 @@ public class BrushCommands extends MethodCommands {
desc = "Copy Paste brush",
descFooter = "Left click the base of an object to copy.\n" +
"Right click to paste\n" +
"The -r flag Will apply random rotation on paste\n" +
"The -a flag Will apply auto view based rotation on paste\n" +
"Note: Works well with the clipboard scroll action\n" +
"Video: https://www.youtube.com/watch?v=RPZIaTbqoZw"
)
@CommandPermissions("worldedit.brush.copy")
public BrushSettings copy(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Switch(name='r', desc = "TODO") boolean randomRotate, @Switch(name='a', desc = "TODO") boolean autoRotate, InjectedValueAccess context) throws WorldEditException {
public BrushSettings copy(Player player, LocalSession session, @Arg(name = "radius", desc = "Expression", def = "5") Expression radius, @Switch(name='r', desc = "Apply random rotation on paste") boolean randomRotate, @Switch(name='a', desc = "Apply auto view based rotation on paste") boolean autoRotate, InjectedValueAccess context) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
player.print(BBC.BRUSH_COPY.f(radius));
@ -861,7 +865,8 @@ public class BrushCommands extends MethodCommands {
}
public BrushSettings set(LocalSession session, InjectedValueAccess context, Brush brush) throws InvalidToolBindException {
Player plr = context.injectedValue(Key.of(Player.class)).orElseThrow(() -> new IllegalStateException("No player"));
Player plr = context.injectedValue(Key.of(Player.class))
.orElseThrow(() -> new IllegalStateException("No player"));
BrushSettings bs = new BrushSettings();
BrushTool tool = session.getBrushTool(plr, false);
if (tool != null) {
@ -873,11 +878,65 @@ public class BrushCommands extends MethodCommands {
}
}
}
String[] perms = getPermissions(context);
bs.addPermissions(perms);
String args = getArguments(context);
bs.addSetting(BrushSettings.SettingType.BRUSH, args.substring(args.indexOf(' ') + 1));
return bs.setBrush(brush);
return bs;
}
@Command(
name = "forest",
desc = "Forest brush, creates a forest in the area"
)
@CommandPermissions("worldedit.brush.forest")
public void forest(Player player, LocalSession localSession,
@Arg(desc = "The shape of the region")
RegionFactory shape,
@Arg(desc = "The size of the brush", def = "5")
double radius,
@Arg(desc = "The density of the brush", def = "20")
double density,
@Arg(desc = "The type of tree to use")
TreeGenerator.TreeType type) throws WorldEditException {
setOperationBasedBrush(player, localSession, radius,
new Paint(new TreeGeneratorFactory(type), density / 100), shape, "worldedit.brush.forest");
}
@Command(
name = "raise",
desc = "Raise brush, raise all blocks by one"
)
@CommandPermissions("worldedit.brush.raise")
public void raise(Player player, LocalSession localSession,
@Arg(desc = "The shape of the region")
RegionFactory shape,
@Arg(desc = "The size of the brush", def = "5")
double radius) throws WorldEditException {
setOperationBasedBrush(player, localSession, radius,
new Deform("y-=1"), shape, "worldedit.brush.raise");
}
@Command(
name = "lower",
desc = "Lower brush, lower all blocks by one"
)
@CommandPermissions("worldedit.brush.lower")
public void lower(Player player, LocalSession localSession,
@Arg(desc = "The shape of the region")
RegionFactory shape,
@Arg(desc = "The size of the brush", def = "5")
double radius) throws WorldEditException {
setOperationBasedBrush(player, localSession, radius,
new Deform("y+=1"), shape, "worldedit.brush.lower");
}
static void setOperationBasedBrush(Player player, LocalSession session, double radius,
Contextual<? extends Operation> factory,
RegionFactory shape,
String permission) throws WorldEditException {
WorldEdit.getInstance().checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player.getItemInHand(HandSide.MAIN_HAND).getType());
tool.setSize(radius);
tool.setFill(null);
tool.setBrush(new OperationFactoryBrush(factory, shape, session), permission);
player.print("Set brush to " + factory);
}
}

View File

@ -11,14 +11,17 @@ 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.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.inject.InjectedValueAccess;
import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.command.tool.BrushTool;
import com.sk89q.worldedit.entity.Player;
@ -30,7 +33,6 @@ import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.internal.annotation.Range;
import com.sk89q.worldedit.util.command.parametric.Optional;
import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.annotation.param.Switch;
@ -48,22 +50,24 @@ import java.util.zip.GZIPInputStream;
* Tool commands.
*/
@Command(aliases = {"brush", "br", "/b"}, desc = "Tool commands")
public class BrushOptionsCommands extends MethodCommands {
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class BrushOptionsCommands {
public BrushOptionsCommands(WorldEdit we) {
super(we);
private WorldEdit worldEdit;
public BrushOptionsCommands(WorldEdit worldEdit) {
this.worldEdit = worldEdit;
}
@Command(
name = "savebrush",
aliases = {"save"},
desc = "Save your current brush",
descFooter = "Save your current brush\n" +
"use the -g flag to save globally"
)
name = "savebrush",
aliases = {"save"},
desc = "Save your current brush",
descFooter = "Save your current brush use the -g flag to save globally"
)
@CommandPermissions("worldedit.brush.save")
public void saveBrush(Player player, LocalSession session, String name, @Switch(name='g', desc = "TODO") boolean root) throws WorldEditException, IOException {
public void saveBrush(Player player, LocalSession session, String name,
@Switch(name = 'g', desc = "TODO") boolean root) throws WorldEditException, IOException {
BrushTool tool = session.getBrushTool(player);
if (tool != null) {
root |= name.startsWith("../");
@ -81,7 +85,8 @@ public class BrushOptionsCommands extends MethodCommands {
parent.mkdirs();
}
file.createNewFile();
try (DataOutputStream out = new DataOutputStream(new PGZIPOutputStream(new FileOutputStream(file)))) {
try (DataOutputStream out = new DataOutputStream(
new PGZIPOutputStream(new FileOutputStream(file)))) {
out.writeUTF(tool.toString());
} catch (Throwable e) {
e.printStackTrace();
@ -93,12 +98,13 @@ public class BrushOptionsCommands extends MethodCommands {
}
@Command(
name = "loadbrush",
aliases = {"load"},
desc = "load a brush"
)
name = "loadbrush",
aliases = {"load"},
desc = "Load a brush"
)
@CommandPermissions("worldedit.brush.load")
public void loadBrush(Player player, LocalSession session, String name) throws WorldEditException, IOException {
public void loadBrush(Player player, LocalSession session, String name)
throws WorldEditException, IOException {
name = FileSystems.getDefault().getPath(name).getFileName().toString();
File folder = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes");
name = name.endsWith(".jsgz") ? name : name + ".jsgz";
@ -107,16 +113,12 @@ public class BrushOptionsCommands extends MethodCommands {
file = new File(folder, name);
}
if (!file.exists()) {
File[] files = folder.listFiles(new FileFilter() {
@Override
public boolean accept(File pathname) {
return false;
}
});
File[] files = folder.listFiles(pathname -> false);
BBC.BRUSH_NOT_FOUND.send(player, name);
return;
}
try (DataInputStream in = new DataInputStream(new GZIPInputStream(new FileInputStream(file)))) {
try (DataInputStream in = new DataInputStream(
new GZIPInputStream(new FileInputStream(file)))) {
String json = in.readUTF();
BrushTool tool = BrushTool.fromString(player, session, json);
BaseItem item = player.getItemInHand(HandSide.MAIN_HAND);
@ -129,14 +131,15 @@ public class BrushOptionsCommands extends MethodCommands {
}
@Command(
name = "/listbrush",
desc = "List saved brushes",
descFooter = "List all brushes in the brush directory\n" +
" -p <page> prints the requested page\n"
name = "/listbrush",
desc = "List saved brushes",
descFooter = "List all brushes in the brush directory\n" +
" -p <page> prints the requested page\n"
)
@CommandPermissions("worldedit.brush.list")
public void list(Actor actor, InjectedValueAccess args, @Switch(name='p', desc = "TODO") @Arg(name = "page", desc = "int", def = "1") int page) throws WorldEditException {
public void list(Actor actor, InjectedValueAccess args,
@Switch(name = 'p', desc = "Prints the requested page")
int page) throws WorldEditException {
String baseCmd = Commands.getAlias(BrushCommands.class, "brush") + " " + Commands.getAlias(BrushOptionsCommands.class, "loadbrush");
File dir = MainUtil.getFile(Fawe.imp().getDirectory(), "brushes");
UtilityCommands.list(dir, actor, args, page, null, true, baseCmd);
@ -149,25 +152,25 @@ public class BrushOptionsCommands extends MethodCommands {
}
@Command(
name = "none",
aliases = {"/none"},
desc = "Unbind a bound tool from your current item"
)
public void none(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
name = "none",
aliases = {"/none"},
desc = "Unbind a bound tool from your current item"
)
public void none(Player player, LocalSession session) throws WorldEditException {
session.setTool(player, null);
BBC.TOOL_NONE.send(player);
}
@Command(
name = "/",
aliases = {","},
desc = "Toggle the super pickaxe function"
name = "/",
aliases = {","},
desc = "Toggle the super pickaxe function"
)
@CommandPermissions("worldedit.superpickaxe")
public void togglePickaxe(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
String newState = args.getString(0, null);
public void togglePickaxe(Player player, LocalSession session,
@Arg(desc = "state", def = "on") String state) throws WorldEditException {
if (session.hasSuperPickAxe()) {
if ("on".equals(newState)) {
if ("on".equals(state)) {
BBC.SUPERPICKAXE_ENABLED.send(player);
return;
}
@ -175,7 +178,7 @@ public class BrushOptionsCommands extends MethodCommands {
session.disableSuperPickAxe();
BBC.SUPERPICKAXE_DISABLED.send(player);
} else {
if ("off".equals(newState)) {
if ("off".equals(state)) {
BBC.SUPERPICKAXE_DISABLED.send(player);
return;
@ -186,54 +189,57 @@ public class BrushOptionsCommands extends MethodCommands {
}
@Command(
name = "primary",
desc = "Set the right click brush",
descFooter = "Set the right click brush"
)
name = "primary",
desc = "Set the right click brush",
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, InjectedValueAccess args)
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);
CommandEvent event = new CommandEvent(player, cmd);
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
BrushTool newTool = session.getBrushTool(item.getType(), player, false);
BrushTool newTool = session.getBrushTool(item, player, false);
if (newTool != null && tool != null) {
newTool.setSecondary(tool.getSecondary());
}
}
@Command(
name = "secondary",
desc = "Set the left click brush",
descFooter = "Set the left click brush"
)
name = "secondary",
desc = "Set the left click brush",
descFooter = "Set the left click brush"
)
@CommandPermissions("worldedit.brush.secondary")
public void secondary(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
public void secondary(Player player, LocalSession session, InjectedValueAccess args)
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);
CommandEvent event = new CommandEvent(player, cmd);
PlatformCommandManager.getInstance().handleCommandOnCurrentThread(event);
BrushTool newTool = session.getBrushTool(item.getType(), player, false);
BrushTool newTool = session.getBrushTool(item, player, false);
if (newTool != null && tool != null) {
newTool.setPrimary(tool.getPrimary());
}
}
@Command(
name = "visualize",
aliases = {"visual", "vis"},
desc = "Toggle between different visualization modes",
descFooter = "Toggle between different visualization modes\n" +
"0 = No visualization\n" +
"1 = Single block at target position\n" +
"2 = Glass showing what blocks will be changed"
)
name = "visualize",
aliases = {"visual", "vis"},
desc = "Toggle between different visualization modes",
descFooter = "Toggle between different visualization modes\n" +
"0 = No visualization\n" +
"1 = Single block at target position\n" +
"2 = Glass showing what blocks will be changed"
)
@CommandPermissions("worldedit.brush.visualize")
public void visual(Player player, LocalSession session, @Range(min = 0, max = 2)int mode) throws WorldEditException {
public void visual(Player player, LocalSession session, @Range(min = 0, max = 2) int mode)
throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
BBC.BRUSH_NONE.send(player);
@ -246,12 +252,13 @@ public class BrushOptionsCommands extends MethodCommands {
}
@Command(
name = "target",
aliases = {"tar"},
desc = "Toggle between different target modes"
)
name = "target",
aliases = {"tar"},
desc = "Toggle between different target modes"
)
@CommandPermissions("worldedit.brush.target")
public void target(Player player, LocalSession session, @Arg(name = "mode", desc = "int", def = "0") int mode) throws WorldEditException {
public void target(Player player, LocalSession session,
@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);
@ -264,12 +271,13 @@ public class BrushOptionsCommands extends MethodCommands {
}
@Command(
name = "targetmask",
aliases = {"tarmask", "tm"},
desc = "Set the targeting mask"
name = "targetmask",
aliases = {"tarmask", "tm"},
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,
InjectedValueAccess context) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
BBC.BRUSH_NONE.send(player);
@ -286,12 +294,13 @@ public class BrushOptionsCommands extends MethodCommands {
}
@Command(
name = "targetoffset",
aliases = {"to"},
desc = "Set the targeting mask"
name = "targetoffset",
aliases = {"to"},
desc = "Set the targeting mask"
)
@CommandPermissions("worldedit.brush.targetoffset")
public void targetOffset(Player player, EditSession editSession, LocalSession session, int offset) throws WorldEditException {
public void targetOffset(Player player, EditSession editSession, LocalSession session,
int offset) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
BBC.BRUSH_NONE.send(player);
@ -302,11 +311,15 @@ public class BrushOptionsCommands extends MethodCommands {
}
@Command(
name = "scroll",
desc = "Toggle between different target modes"
name = "scroll",
desc = "Toggle between different target modes"
)
@CommandPermissions("worldedit.brush.scroll")
public void scroll(Player player, EditSession editSession, LocalSession session, @Optional @Switch(name='h', desc = "TODO") boolean offHand, InjectedValueAccess args) throws WorldEditException {
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 {
BrushTool bt = session.getBrushTool(player, false);
if (bt == null) {
BBC.BRUSH_NONE.send(player);
@ -315,23 +328,25 @@ public class BrushOptionsCommands extends MethodCommands {
BrushSettings settings = offHand ? bt.getOffHand() : bt.getContext();
ScrollAction action = ScrollAction.fromArguments(bt, player, session, args.getJoinedStrings(0), true);
settings.setScrollAction(action);
if (args.getString(0).equalsIgnoreCase("none")) {
if (modes.equalsIgnoreCase("none")) {
BBC.BRUSH_SCROLL_ACTION_UNSET.send(player);
} else if (action != null) {
String full = args.getJoinedStrings(0);
settings.addSetting(BrushSettings.SettingType.SCROLL_ACTION, full);
BBC.BRUSH_SCROLL_ACTION_SET.send(player, full);
settings.addSetting(BrushSettings.SettingType.SCROLL_ACTION, modes);
BBC.BRUSH_SCROLL_ACTION_SET.send(player, modes);
}
bt.update();
}
@Command(
name = "mask",
aliases = {"/mask"},
desc = "Set the brush destination mask"
name = "mask",
aliases = {"/mask"},
desc = "Set the brush destination mask"
)
@CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"})
public void mask(Player player, LocalSession session, EditSession editSession, @Optional @Switch(name='h', desc = "TODO") boolean offHand, InjectedValueAccess context) throws WorldEditException {
public void mask(Player player, LocalSession session, EditSession editSession,
@Switch(name = 'h', desc = "TODO")
boolean offHand, InjectedValueAccess context)
throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
player.print(BBC.BRUSH_NONE.f());
@ -356,13 +371,16 @@ public class BrushOptionsCommands extends MethodCommands {
}
@Command(
name = "smask",
aliases = {"/smask", "/sourcemask", "sourcemask"},
desc = "Set the brush source mask",
descFooter = "Set the brush source mask"
name = "smask",
aliases = {"/smask", "/sourcemask", "sourcemask"},
desc = "Set the brush source mask",
descFooter = "Set the brush source mask"
)
@CommandPermissions({"worldedit.brush.options.mask", "worldedit.mask.brush"})
public void smask(Player player, LocalSession session, EditSession editSession, @Optional @Switch(name='h', desc = "TODO") boolean offHand, InjectedValueAccess context) throws WorldEditException {
public void smask(Player player, LocalSession session, EditSession editSession,
@Switch(name = 'h', desc = "TODO")
boolean offHand,
InjectedValueAccess context) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
player.print(BBC.BRUSH_NONE.f());
@ -378,20 +396,25 @@ public class BrushOptionsCommands extends MethodCommands {
parserContext.setWorld(player.getWorld());
parserContext.setSession(session);
parserContext.setExtent(editSession);
Mask mask = worldEdit.getMaskFactory().parseFromInput(context.getJoinedStrings(0), parserContext);
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));
settings.addSetting(BrushSettings.SettingType.SOURCE_MASK,
context.getString(context.argsLength() - 1));
settings.setSourceMask(mask);
tool.update();
BBC.BRUSH_SOURCE_MASK.send(player);
}
@Command(
name = "transform",
desc = "Set the brush transform"
name = "transform",
desc = "Set the brush transform"
)
@CommandPermissions({"worldedit.brush.options.transform", "worldedit.transform.brush"})
public void transform(Player player, LocalSession session, EditSession editSession, @Optional @Switch(name='h', desc = "TODO") boolean offHand, InjectedValueAccess context) throws WorldEditException {
public void transform(Player player, LocalSession session, EditSession editSession,
@Switch(name = 'h', desc = "TODO")
boolean offHand,
InjectedValueAccess context) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
player.print(BBC.BRUSH_NONE.f());
@ -416,12 +439,16 @@ public class BrushOptionsCommands extends MethodCommands {
}
@Command(
name = "mat",
aliases = {"material"},
desc = "Set the brush material"
)
name = "mat",
aliases = {"material"},
desc = "Set the brush material"
)
@CommandPermissions("worldedit.brush.options.material")
public void material(Player player, EditSession editSession, LocalSession session, Pattern pattern, @Switch(name='h', desc = "TODO") boolean offHand, InjectedValueAccess context) throws WorldEditException {
public void material(Player player, EditSession editSession, LocalSession session,
Pattern pattern,
@Switch(name = 'h', desc = "TODO")
boolean offHand,
InjectedValueAccess context) throws WorldEditException {
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
player.print(BBC.BRUSH_NONE.f());
@ -440,12 +467,14 @@ public class BrushOptionsCommands extends MethodCommands {
}
@Command(
name = "range",
desc = "Set the brush range"
)
name = "range",
desc = "Set the brush range"
)
@CommandPermissions("worldedit.brush.options.range")
public void range(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
int range = Math.max(0, Math.min(256, args.getInteger(0)));
public void range(Player player, LocalSession session,
@Arg(desc = "Range")
int range) throws WorldEditException {
range = Math.max(0, Math.min(256, range));
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {
player.print(BBC.BRUSH_NONE.f());
@ -456,12 +485,15 @@ public class BrushOptionsCommands extends MethodCommands {
}
@Command(
name = "size",
desc = "Set the brush size"
)
name = "size",
desc = "Set the brush size"
)
@CommandPermissions("worldedit.brush.options.size")
public void size(Player player, LocalSession session, InjectedValueAccess args, @Switch(name='h', desc = "TODO") boolean offHand) throws WorldEditException {
int radius = args.getInteger(0);
public void size(Player player, LocalSession session,
@Arg(desc = "The size of the brush", def = "5")
int radius,
@Switch(name = 'h', desc = "TODO")
boolean offHand) throws WorldEditException {
worldEdit.checkMaxBrushRadius(radius);
BrushTool tool = session.getBrushTool(player, false);
if (tool == null) {

View File

@ -99,14 +99,16 @@ import java.util.zip.ZipOutputStream;
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class ClipboardCommands {
private WorldEdit worldEdit;
/**
* Create a new instance.
*
* @param worldEdit reference to WorldEdit
*/
public ClipboardCommands(WorldEdit worldEdit) {
super(worldEdit);
checkNotNull(worldEdit);
this.worldEdit = worldEdit;
}
@ -262,7 +264,7 @@ public class ClipboardCommands {
ForwardExtentCopy copy = new ForwardExtentCopy(editSession, region, clipboard, region.getMinimumPoint());
copy.setSourceFunction(new BlockReplace(editSession, leavePattern));
copy.setCopyingEntities(copyEntities);
copy.setCopyingEntities(!skipEntities);
copy.setRemovingEntities(true);
copy.setCopyingBiomes(copyBiomes);
Mask sourceMask = editSession.getSourceMask();

View File

@ -19,6 +19,9 @@
package com.sk89q.worldedit.command;
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
import static com.sk89q.worldedit.internal.command.CommandUtil.requireIV;
import com.google.common.collect.ImmutableSet;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalSession;
@ -34,6 +37,7 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.regions.RegionOperationException;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import java.util.List;
import org.enginehub.piston.Command;
import org.enginehub.piston.CommandManager;
import org.enginehub.piston.CommandManagerService;
@ -42,11 +46,6 @@ import org.enginehub.piston.annotation.param.Arg;
import org.enginehub.piston.inject.Key;
import org.enginehub.piston.part.SubCommandPart;
import java.util.List;
import static com.sk89q.worldedit.command.util.Logging.LogMode.REGION;
import static com.sk89q.worldedit.internal.command.CommandUtil.requireIV;
/**
* Extracted from {@link SelectionCommands} to allow importing of {@link Command}.
*/
@ -54,8 +53,8 @@ import static com.sk89q.worldedit.internal.command.CommandUtil.requireIV;
public class ExpandCommands {
public static void register(CommandRegistrationHandler registration,
CommandManager commandManager,
CommandManagerService commandManagerService) {
CommandManager commandManager,
CommandManagerService commandManagerService) {
// Collect the general expand command
CommandManager collect = commandManagerService.newCommandManager();
@ -121,13 +120,13 @@ public class ExpandCommands {
)
@Logging(REGION)
public void expand(Player player, LocalSession session,
@Arg(desc = "Amount to expand the selection by, can be `vert` to expand to the whole vertical column")
int amount,
@Arg(desc = "Amount to expand the selection by in the other direction", def = "0")
int reverseAmount,
@Arg(desc = "Direction to expand", def = Direction.AIM)
@MultiDirection
List<BlockVector3> direction) throws WorldEditException {
@Arg(desc = "Amount to expand the selection by, can be `vert` to expand to the whole vertical column")
int amount,
@Arg(desc = "Amount to expand the selection by in the other direction", def = "0")
int reverseAmount,
@Arg(desc = "Direction to expand", def = Direction.AIM)
@MultiDirection
List<BlockVector3> direction) throws WorldEditException {
Region region = session.getSelection(player.getWorld());
int oldSize = region.getArea();

View File

@ -247,14 +247,14 @@ public class GenerationCommands {
@CommandPermissions("worldedit.generation.sphere")
@Logging(PLACEMENT)
public void sphere(FawePlayer fp, Player player, LocalSession session, EditSession editSession,
@Arg(desc = "The pattern of blocks to generate")
Pattern pattern,
@Arg(desc = "The radii of the sphere. Order is N/S, U/D, E/W")
BlockVector3 radii,
@Switch(name = 'r', desc = "Raise the bottom of the sphere to the placement position")
boolean raised,
@Switch(name = 'h', desc = "Make a hollow sphere")
boolean hollow) throws WorldEditException {
@Arg(desc = "The pattern of blocks to generate")
Pattern pattern,
@Arg(desc = "The radii of the sphere. Order is N/S, U/D, E/W")
BlockVector3 radii,
@Switch(name = 'r', desc = "Raise the bottom of the sphere to the placement position")
boolean raised,
@Switch(name = 'h', desc = "Make a hollow sphere")
boolean hollow, InjectedValueAccess context) throws WorldEditException {
BlockVector3 pos = session.getPlacementPosition(player);
BlockVector3 finalPos = raised ? pos.add(0, radii.getY(), 0) : pos;
fp.checkConfirmationRadius(() -> {

View File

@ -19,6 +19,8 @@
package com.sk89q.worldedit.command;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.config.BBC;
@ -33,7 +35,6 @@ import com.boydti.fawe.object.changeset.DiskStorageHistory;
import com.boydti.fawe.regions.FaweMaskManager;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan;
import org.enginehub.piston.inject.InjectedValueAccess;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
@ -41,11 +42,10 @@ 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.internal.annotation.Range;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.internal.annotation.Range;
import org.enginehub.piston.annotation.param.Switch;
import com.sk89q.worldedit.world.World;
import java.io.File;
import java.util.UUID;
@ -53,14 +53,13 @@ import java.util.concurrent.atomic.AtomicInteger;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
import static com.google.common.base.Preconditions.checkNotNull;
import org.enginehub.piston.annotation.param.Switch;
import org.enginehub.piston.inject.InjectedValueAccess;
/**
* Commands to undo, redo, and clear history.
*/
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
//@Command(aliases = {}, desc = "Commands to undo, redo, and clear history: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Features#History)")
public class HistoryCommands extends MethodCommands {
private final WorldEdit worldEdit;
@ -83,7 +82,7 @@ public class HistoryCommands extends MethodCommands {
" - Import from disk: /frb #import"
)
@CommandPermissions("worldedit.history.rollback")
public void faweRollback(final Player player, LocalSession session, final String user, @Arg(def = "0", desc = "radius") @Range(min = 0) int radius, @Arg(name = "time", desc = "String", def = "0") String time, @Switch(name='r', desc = "TODO") boolean restore) throws WorldEditException {
public void faweRollback(Player player, LocalSession session, String user, @Arg(def = "0", desc = "radius") @Range(min = 0) int radius, @Arg(name = "time", desc = "String", def = "0") String time, @Switch(name='r', desc = "TODO") boolean restore) throws WorldEditException {
if (!Settings.IMP.HISTORY.USE_DATABASE) {
BBC.SETTING_DISABLE.send(player, "history.use-database (Import with /frb #import )");
return;
@ -209,7 +208,7 @@ public class HistoryCommands extends MethodCommands {
" - Import from disk: /frb #import"
)
@CommandPermissions("worldedit.history.rollback")
public void restore(final Player player, LocalSession session, final String user, @Arg(def = "0", desc = "radius") @Range(min = 0) int radius, @Arg(name = "time", desc = "String", def = "0") String time) throws WorldEditException {
public void restore(Player player, LocalSession session, String user, @Arg(def = "0", desc = "radius") @Range(min = 0) int radius, @Arg(name = "time", desc = "String", def = "0") String time) throws WorldEditException {
faweRollback(player, session, user, radius, time, true);
}

View File

@ -22,7 +22,6 @@ package com.sk89q.worldedit.command;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.sk89q.worldedit.command.util.Logging.LogMode.POSITION;
import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.config.BBC;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.WorldEdit;
@ -32,7 +31,6 @@ import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.command.util.Logging;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
@ -41,7 +39,6 @@ import org.enginehub.piston.annotation.param.Switch;
/**
* Commands for moving the player around.
*/
@Command(aliases = {}, desc = "Commands for moving the player around: [More Info](https://goo.gl/uQTUiT)")
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class NavigationCommands {

View File

@ -51,8 +51,7 @@ public class PatternCommands extends MethodCommands {
@Command(
name = "#existing",
aliases = {"#*", "*", ".*"},
desc = "Use the block that is already there",
usage = "[properties]"
desc = "Use the block that is already there"
)
public Pattern existing(Extent extent, @Arg(name = "properties", desc = "String", def = "") String properties) { // TODO FIXME , @Arg(name = "properties", desc = "String", def = "") String properties
if (properties == null) return new ExistingPattern(extent);

View File

@ -31,18 +31,17 @@ 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.beta.filters.DistrFilter;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.beta.IQueueExtent;
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 org.enginehub.piston.inject.InjectedValueAccess;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
@ -62,6 +61,7 @@ import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.visitor.LayerVisitor;
import com.sk89q.worldedit.internal.annotation.Direction;
import com.sk89q.worldedit.internal.annotation.Range;
import com.sk89q.worldedit.internal.annotation.Selection;
import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.math.BlockVector2;
@ -78,7 +78,6 @@ 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.internal.annotation.Range;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
@ -94,11 +93,11 @@ 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;
/**
* Commands that operate on regions.
*/
//@Command(aliases = {}, desc = "Commands that operate on regions: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Region_operations)")
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class RegionCommands extends MethodCommands {
@ -114,6 +113,39 @@ 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"
@ -210,7 +242,7 @@ public class RegionCommands extends MethodCommands {
@Selection Region region,
@Arg(desc = "The pattern of blocks to place")
Pattern pattern,
@Range(min = 0) @Arg(desc = "The thickness of the line", def = "0")
@Arg(desc = "The thickness of the line", def = "0")
int thickness,
@Switch(name = 'h', desc = "Generate only a shell")
boolean shell) throws WorldEditException {
@ -218,6 +250,8 @@ public class RegionCommands extends MethodCommands {
player.printError("//line only works with cuboid selections");
return 0;
}
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
CuboidRegion cuboidregion = (CuboidRegion) region;
BlockVector3 pos1 = cuboidregion.getPos1();
BlockVector3 pos2 = cuboidregion.getPos2();
@ -235,26 +269,26 @@ public class RegionCommands extends MethodCommands {
@CommandPermissions("worldedit.region.curve")
@Logging(REGION)
public void curve(FawePlayer player, EditSession editSession,
@Selection Region region,
@Arg(desc = "The pattern of blocks to place")
Pattern pattern,
@Range(min = 0) @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 {
@Selection Region region,
@Arg(desc = "The pattern of blocks to place")
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)) {
player.printError("//curve only works with convex polyhedral selections");
return;
}
checkCommandArgument(thickness >= 0, "Thickness must be >= 0");
player.checkConfirmationRegion(() -> {
ConvexPolyhedralRegion cpregion = (ConvexPolyhedralRegion) region;
List<BlockVector3> vectors = new ArrayList<>(cpregion.getVertices());
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
int blocksChanged = editSession.drawSpline(pattern, vectors, 0, 0, 0, 10, thickness, !shell);
BBC.VISITOR_BLOCK.send(player, blocksChanged);
BBC.VISITOR_BLOCK.send(player, blocksChanged);
}, getArguments(context), region, context);
}
@ -265,12 +299,20 @@ public class RegionCommands extends MethodCommands {
)
@CommandPermissions("worldedit.region.replace")
@Logging(REGION)
public void replace(FawePlayer player, EditSession editSession, @Selection Region region, @Arg(name = "from", desc = "Mask", def = "") Mask from, Pattern to, InjectedValueAccess context) throws WorldEditException {
public void replace(FawePlayer player, 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")
Pattern to, InjectedValueAccess context) throws WorldEditException {
player.checkConfirmationRegion(() -> {
int affected = editSession.replaceBlocks(region, from == null ? new ExistingBlockMask(editSession) : from, to);
BBC.VISITOR_BLOCK.send(player, affected);
if (!player.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(player);
if (!player.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(player);
}
}, getArguments(context), region, context);
}
@ -305,8 +347,8 @@ public class RegionCommands extends MethodCommands {
@CommandPermissions("worldedit.region.overlay")
@Logging(REGION)
public void overlay(FawePlayer player, EditSession editSession, @Selection Region region,
@Arg(desc = "The pattern of blocks to overlay")
Pattern pattern, InjectedValueAccess context) throws WorldEditException {
@Arg(desc = "The pattern of blocks to overlay")
Pattern pattern, InjectedValueAccess context) throws WorldEditException {
player.checkConfirmationRegion(() -> {
int affected = editSession.overlayCuboidBlocks(region, pattern);
BBC.VISITOR_BLOCK.send(player, affected);
@ -339,14 +381,16 @@ public class RegionCommands extends MethodCommands {
}, getArguments(context), region, context);
}
@org.enginehub.piston.annotation.Command(
@Command(
name = "/center",
aliases = { "/middle" },
desc = "Set the center block(s)"
)
@Logging(REGION)
@CommandPermissions("worldedit.region.center")
public void center(Player player, EditSession editSession, @Selection Region region, Pattern pattern) throws WorldEditException {
public void center(Player player, EditSession editSession, @Selection Region region,
@Arg(desc = "The pattern of blocks to set")
Pattern pattern) throws WorldEditException {
int affected = editSession.center(region, pattern);
BBC.VISITOR_BLOCK.send(player, affected);
}
@ -370,7 +414,9 @@ public class RegionCommands extends MethodCommands {
)
@CommandPermissions("worldedit.region.walls")
@Logging(REGION)
public void walls(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, InjectedValueAccess context) throws WorldEditException {
public void walls(FawePlayer player, EditSession editSession, @Selection Region region,
@Arg(desc = "The pattern of blocks to set")
Pattern pattern, InjectedValueAccess context) throws WorldEditException {
player.checkConfirmationRegion(() -> {
int affected = editSession.makeWalls(region, pattern);
BBC.VISITOR_BLOCK.send(player, affected);
@ -384,7 +430,9 @@ public class RegionCommands extends MethodCommands {
)
@CommandPermissions("worldedit.region.faces")
@Logging(REGION)
public void faces(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, InjectedValueAccess context) throws WorldEditException {
public void faces(FawePlayer player, EditSession editSession, @Selection Region region,
@Arg(desc = "The pattern of blocks to set")
Pattern pattern, InjectedValueAccess context) throws WorldEditException {
player.checkConfirmationRegion(() -> {
int affected = editSession.makeCuboidFaces(region, pattern);
BBC.VISITOR_BLOCK.send(player, affected);
@ -398,7 +446,12 @@ public class RegionCommands extends MethodCommands {
)
@CommandPermissions("worldedit.region.smooth")
@Logging(REGION)
public void smooth(FawePlayer player, EditSession editSession, @Selection Region region, @Arg(name = "iterations", desc = "int", def = "1") int iterations, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='s', desc = "TODO") boolean snow, InjectedValueAccess context) throws WorldEditException {
public void smooth(FawePlayer player, 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 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));
@ -464,24 +517,27 @@ public class RegionCommands extends MethodCommands {
)
@CommandPermissions("worldedit.region.move")
@Logging(ORIENTATION_REGION)
public void move(FawePlayer player, LocalSession session, EditSession editSession,
public void move(FawePlayer player, EditSession editSession, LocalSession session,
@Selection Region region,
@Arg(desc = "# of blocks to move", def = "1")
int count,
@Arg(desc = "The direction to move", def = Direction.AIM)
@Direction(includeDiagonals = true)
BlockVector3 direction,
@Arg(desc = "The pattern of blocks to leave", def = "air")
Pattern replace,
@Switch(name = 's', desc = "Shift the selection to the target location")
boolean moveSelection,
@Switch(name = 'a', desc = "Ignore air blocks")
boolean ignoreAirBlocks,
@Switch(name='b', desc = "TODO") boolean copyBiomes,
@Switch(name='e', desc = "TODO") boolean skipEntities,
@Switch(name='a', desc = "TODO") boolean skipAir,
InjectedValueAccess context) throws WorldEditException {
@Arg(desc = "# of blocks to move", def = "1")
int count,
@Arg(desc = "The direction to move", def = Direction.AIM)
@Direction(includeDiagonals = true)
BlockVector3 direction,
@Arg(desc = "The pattern of blocks to leave", def = "air")
Pattern replace,
@Switch(name = 's', desc = "Shift the selection to the target location")
boolean moveSelection,
@Switch(name = 'a', desc = "Ignore air blocks")
boolean ignoreAirBlocks,
@Switch(name='b', desc = "TODO")
boolean copyBiomes,
@Switch(name='e', desc = "TODO")
boolean skipEntities,
@Switch(name='a', desc = "TODO")
boolean skipAir,
InjectedValueAccess context) throws WorldEditException {
checkCommandArgument(count >= 1, "Count must be >= 1");
player.checkConfirmationRegion(() -> {
int affected = editSession.moveRegion(region, direction, count, !skipAir, !skipEntities, copyBiomes, replace);
@ -526,18 +582,19 @@ public class RegionCommands extends MethodCommands {
@CommandPermissions("worldedit.region.stack")
@Logging(ORIENTATION_REGION)
public void stack(FawePlayer player, EditSession editSession, LocalSession session,
@Selection Region region,
@Arg(desc = "# of copies to stack", def = "1")
int count,
@Arg(desc = "The direction to stack", def = Direction.AIM)
@Direction(includeDiagonals = true)
BlockVector3 direction,
@Switch(name = 's', desc = "Shift the selection to the last stacked copy")
boolean moveSelection,
@Switch(name = 'b', desc = "//TODO") boolean copyBiomes,
@Switch(name = 'e', desc = "//TODO") boolean skipEntities,
@Switch(name = 'a', desc = "Ignore air blocks")
boolean ignoreAirBlocks, @Switch(name='m', desc = "TODO") Mask sourceMask, InjectedValueAccess context) throws WorldEditException {
@Selection Region region,
@Arg(desc = "# of copies to stack", def = "1")
int count,
@Arg(desc = "The direction to stack", def = Direction.AIM)
@Direction(includeDiagonals = true)
BlockVector3 direction,
@Switch(name = 's', desc = "Shift the selection to the last stacked copy")
boolean moveSelection,
@Switch(name = 'b', desc = "//TODO") boolean copyBiomes,
@Switch(name = 'e', desc = "//TODO") boolean skipEntities,
@Switch(name = 'a', desc = "Ignore air blocks")
boolean ignoreAirBlocks,
@Switch(name='m', desc = "TODO") Mask sourceMask, InjectedValueAccess context) throws WorldEditException {
player.checkConfirmationStack(() -> {
if (sourceMask != null) {
editSession.addSourceMask(sourceMask);
@ -562,24 +619,22 @@ public class RegionCommands extends MethodCommands {
}
@Command(
name = "/deform",
desc = "Deforms a selected region with an expression",
descFooter =
"Deforms a selected region with an expression\n" +
"The expression is executed for each block and is expected\n" +
"to modify the variables x, y and z to point to a new block\n" +
"to fetch. See also tinyurl.com/wesyntax."
)
name = "/deform",
desc = "Deforms a selected region with an expression",
descFooter = "The expression is executed for each block and is expected\n" +
"to modify the variables x, y and z to point to a new block\n" +
"to fetch. See also https://tinyurl.com/weexpr"
)
@CommandPermissions("worldedit.region.deform")
@Logging(ALL)
public void deform(FawePlayer fp, Player player, LocalSession session, EditSession editSession, InjectedValueAccess context,
@Selection Region region,
@Arg(desc = "The expression to use", variable = true)
List<String> expression,
@Switch(name = 'r', desc = "Use the game's coordinate origin")
boolean useRawCoords,
@Switch(name = 'o', desc = "Use the selection's center as origin")
boolean offset) throws WorldEditException {
@Selection Region region,
@Arg(desc = "The expression to use", variable = true)
List<String> expression,
@Switch(name = 'r', desc = "Use the game's coordinate origin")
boolean useRawCoords,
@Switch(name = 'o', desc = "Use the selection's center as origin")
boolean offset) throws WorldEditException {
final Vector3 zero;
Vector3 unit;
@ -651,7 +706,7 @@ public class RegionCommands extends MethodCommands {
}
@Command(
name = "/hollow",
name = "/hollow",
desc = "Hollows out the object contained in this selection",
descFooter = "Hollows out the object contained in this selection.\n" +
"Optionally fills the hollowed out part with the given block.\n" +
@ -661,11 +716,11 @@ public class RegionCommands extends MethodCommands {
@CommandPermissions("worldedit.region.hollow")
@Logging(REGION)
public void hollow(FawePlayer player, EditSession editSession,
@Selection Region region,
@Arg(desc = "Thickness of the shell to leave", def = "0")
int thickness,
@Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air")
Pattern pattern,
@Selection Region region,
@Arg(desc = "Thickness of the shell to leave", def = "0")
int thickness,
@Arg(desc = "The pattern of blocks to replace the hollowed area with", def = "air")
Pattern pattern,
@Switch(name='m', desc = "Mask to hollow with") Mask mask,
InjectedValueAccess context) throws WorldEditException {
Mask finalMask = mask == null ? new SolidBlockMask(editSession) : mask;
@ -682,10 +737,11 @@ public class RegionCommands extends MethodCommands {
@CommandPermissions("worldedit.region.forest")
@Logging(REGION)
public void forest(Player player, EditSession editSession, @Selection Region region,
@Arg(desc = "The type of tree to place", def = "tree")
TreeType type,
@Arg(desc = "The density of the forest", def = "5")
double density) throws WorldEditException {
@Arg(desc = "The type of tree to place", def = "tree")
TreeType type,
@Arg(desc = "The density of the forest", def = "5")
double density) throws WorldEditException {
checkCommandArgument(0 <= density && density <= 100, "Density must be in [0, 100]");
int affected = editSession.makeForest(region, density / 100, type);
BBC.COMMAND_TREE.send(player, affected);
}
@ -697,8 +753,9 @@ public class RegionCommands extends MethodCommands {
@CommandPermissions("worldedit.region.flora")
@Logging(REGION)
public void flora(FawePlayer player, EditSession editSession, @Selection Region region,
@Arg(desc = "The density of the forest", def = "5")
double density, InjectedValueAccess context) throws WorldEditException {
@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]");
player.checkConfirmationRegion(() -> {
FloraGenerator generator = new FloraGenerator(editSession);
GroundFunction ground = new GroundFunction(new ExistingBlockMask(editSession), generator);

View File

@ -114,10 +114,11 @@ public class ScriptingCommands {
file = new FileInputStream(f);
}
DataInputStream in = new DataInputStream(file);
byte[] data = new byte[in.available()];
in.readFully(data);
in.close();
byte[] data;
try (DataInputStream in = new DataInputStream(file)) {
data = new byte[in.available()];
in.readFully(data);
}
script = new String(data, 0, data.length, StandardCharsets.UTF_8);
} catch (IOException e) {
actor.printError("Script read error: " + e.getMessage());
@ -131,11 +132,10 @@ public class ScriptingCommands {
WorldEdit worldEdit = WorldEdit.getInstance();
LocalSession session = worldEdit.getSessionManager().get(actor);
CraftScriptEngine engine = null;
CraftScriptEngine engine;
Object result = null;
try {
engine = new RhinoCraftScriptEngine();
} catch (NoClassDefFoundError e) {
actor.printError("Failed to find an installed script engine.");
@ -182,10 +182,11 @@ public class ScriptingCommands {
)
@CommandPermissions("worldedit.scripting.execute")
@Logging(ALL)
public void execute(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
final String[] scriptArgs = args.getSlice(1);
final String filename = args.getString(0);
public void execute(Player player, LocalSession session,
@Arg(desc = "Filename of the CraftScript to load")
String filename,
@Arg(desc = "Arguments to the CraftScript", def = "", variable = true)
List<String> args) throws WorldEditException {
if (!player.hasPermission("worldedit.scripting.execute." + filename)) {
BBC.SCRIPTING_NO_PERM.send(player);
return;
@ -204,7 +205,8 @@ public class ScriptingCommands {
player.printError("More info: https://github.com/boy0001/CraftScripts/");
return;
}
runScript(LocationMaskedPlayerWrapper.unwrap(player), f, scriptArgs);
worldEdit.runScript(LocationMaskedPlayerWrapper.unwrap(player), f, Stream.concat(Stream.of(filename), args.stream())
.toArray(String[]::new));
}
@Command(

View File

@ -27,7 +27,7 @@ import com.boydti.fawe.object.clipboard.URIClipboardHolder;
import com.boydti.fawe.object.mask.IdMask;
import com.boydti.fawe.object.regions.selector.FuzzyRegionSelector;
import com.boydti.fawe.object.regions.selector.PolyhedralRegionSelector;
import com.boydti.fawe.util.ExtentTraverser;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
@ -38,7 +38,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.input.ParserContext;
import com.sk89q.worldedit.extension.platform.permission.ActorSelectorLimits;
import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.clipboard.Clipboard;
@ -470,7 +469,7 @@ public class SelectionCommands {
public void count(Player player, LocalSession session, EditSession editSession,
@Arg(desc = "The mask of blocks to match")
Mask mask) throws WorldEditException {
int count = editSession.countBlock(session.getSelection(player.getWorld()), mask);
int count = editSession.countBlocks(session.getSelection(player.getWorld()), mask);
BBC.SELECTION_COUNT.send(player, count);
}

View File

@ -29,24 +29,29 @@ 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.util.formatting.component.PaginationBox;
import com.sk89q.worldedit.util.formatting.text.Component;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException;
import com.sk89q.worldedit.world.snapshot.Snapshot;
import com.sk89q.worldedit.world.storage.MissingWorldException;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
import java.io.File;
import java.io.IOException;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
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.ArgFlag;
/**
* Snapshot commands.
*/
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
@Command(aliases = {"snapshot", "snap"}, desc = "List, load and view information related to snapshots")
public class SnapshotCommands {
private static final DateTimeFormatter dateFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z");
@ -63,8 +68,8 @@ public class SnapshotCommands {
)
@CommandPermissions("worldedit.snapshots.list")
public void list(Player player,
@Arg(desc = "# of snapshots to list", def = "5")
int num) throws WorldEditException {
@ArgFlag(name = 'p', desc = "Page of results to return", def = "1")
int page) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
@ -77,15 +82,7 @@ public class SnapshotCommands {
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName());
if (!snapshots.isEmpty()) {
num = Math.min(40, Math.max(5, num));
BBC.SNAPSHOT_LIST_HEADER.send(player, player.getWorld().getName());
for (byte i = 0; i < Math.min(num, snapshots.size()); i++) {
player.print((i + 1) + ". " + snapshots.get(i).getName());
}
BBC.SNAPSHOT_LIST_FOOTER.send(player);
player.print(new SnapshotListBox(player.getWorld().getName(), snapshots).create(page));
} else {
BBC.SNAPSHOT_NOT_AVAILABLE.send(player);
@ -200,19 +197,19 @@ public class SnapshotCommands {
return;
}
try {
Snapshot snapshot = config.snapshotRepo.getSnapshotBefore(date, player.getWorld().getName());
try {
Snapshot snapshot = config.snapshotRepo.getSnapshotBefore(date, player.getWorld().getName());
if (snapshot == null) {
player.printError("Couldn't find a snapshot before "
+ dateFormat.withZone(session.getTimeZone().toZoneId()).format(date) + ".");
} else {
session.setSnapshot(snapshot);
BBC.SNAPSHOT_SET.send(player, snapshot.getName());
}
} catch (MissingWorldException ex) {
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player);
if (snapshot == null) {
player.printError("Couldn't find a snapshot before "
+ dateFormat.withZone(session.getTimeZone()).format(date) + ".");
} else {
session.setSnapshot(snapshot);
BBC.SNAPSHOT_SET.send(player, snapshot.getName());
}
} catch (MissingWorldException ex) {
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player);
}
}
@Command(
@ -231,18 +228,40 @@ public class SnapshotCommands {
return;
}
try {
Snapshot snapshot = config.snapshotRepo.getSnapshotAfter(date, player.getWorld().getName());
if (snapshot == null) {
player.printError("Couldn't find a snapshot after "
+ dateFormat.withZone(session.getTimeZone().toZoneId()).format(date) + ".");
} else {
session.setSnapshot(snapshot);
BBC.SNAPSHOT_SET.send(player, snapshot.getName());
}
} catch (MissingWorldException ex) {
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player);
try {
Snapshot snapshot = config.snapshotRepo.getSnapshotAfter(date, player.getWorld().getName());
if (snapshot == null) {
player.printError("Couldn't find a snapshot after "
+ dateFormat.withZone(session.getTimeZone()).format(date) + ".");
} else {
session.setSnapshot(snapshot);
BBC.SNAPSHOT_SET.send(player, snapshot.getName());
}
} catch (MissingWorldException ex) {
BBC.SNAPSHOT_NOT_FOUND_WORLD.send(player);
}
}
private static class SnapshotListBox extends PaginationBox {
private final List<Snapshot> snapshots;
SnapshotListBox(String world, List<Snapshot> snapshots) {
super("Snapshots for: " + world, "/snap list -p %page%");
this.snapshots = snapshots;
}
@Override
public Component getComponent(int number) {
final Snapshot snapshot = snapshots.get(number);
return TextComponent.of(number + 1 + ". ", TextColor.GOLD)
.append(TextComponent.of(snapshot.getName(), TextColor.LIGHT_PURPLE)
.hoverEvent(HoverEvent.of(HoverEvent.Action.SHOW_TEXT, TextComponent.of("Click to use")))
.clickEvent(ClickEvent.of(ClickEvent.Action.RUN_COMMAND, "/snap use " + snapshot.getName())));
}
@Override
public int getComponentsSize() {
return snapshots.size();
}
}
}

View File

@ -20,9 +20,6 @@
package com.sk89q.worldedit.command;
import com.boydti.fawe.config.BBC;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.inject.InjectedValueAccess;
import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.LocalConfiguration;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
@ -30,9 +27,14 @@ import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.tool.AreaPickaxe;
import com.sk89q.worldedit.command.tool.RecursivePickaxe;
import com.sk89q.worldedit.command.tool.SinglePickaxe;
import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.entity.Player;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
@Command(aliases = {"superpickaxe", "pickaxe", "sp"}, desc = "Super-pickaxe commands: [More Info](https://goo.gl/aBtGHo)")
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class SuperPickaxeCommands {
private final WorldEdit we;
@ -41,9 +43,9 @@ public class SuperPickaxeCommands {
}
@Command(
name = "single",
desc = "Enable the single block super pickaxe mode"
)
name = "single",
desc = "Enable the single block super pickaxe mode"
)
@CommandPermissions("worldedit.superpickaxe")
public void single(Player player, LocalSession session) throws WorldEditException {
session.setSuperPickaxe(new SinglePickaxe());
@ -52,14 +54,15 @@ public class SuperPickaxeCommands {
}
@Command(
name = "area",
desc = "Enable the area super pickaxe pickaxe mode"
)
name = "area",
desc = "Enable the area super pickaxe pickaxe mode"
)
@CommandPermissions("worldedit.superpickaxe.area")
public void area(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
public void area(Player player, LocalSession session,
@Arg(desc = "The range of the area pickaxe")
int range) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
int range = args.getInteger(0);
if (range > config.maxSuperPickaxeSize) {
BBC.TOOL_RANGE_ERROR.send(player, config.maxSuperPickaxeSize);
@ -72,15 +75,16 @@ public class SuperPickaxeCommands {
}
@Command(
name = "recur",
aliases = {"recursive"},
desc = "Enable the recursive super pickaxe pickaxe mode"
)
name = "recursive",
aliases = { "recur" },
desc = "Enable the recursive super pickaxe pickaxe mode"
)
@CommandPermissions("worldedit.superpickaxe.recursive")
public void recursive(Player player, LocalSession session, InjectedValueAccess args) throws WorldEditException {
public void recursive(Player player, LocalSession session,
@Arg(desc = "The range of the recursive pickaxe")
double range) throws WorldEditException {
LocalConfiguration config = we.getConfiguration();
double range = args.getDouble(0);
if (range > config.maxSuperPickaxeSize) {
BBC.TOOL_RANGE_ERROR.send(player, config.maxSuperPickaxeSize);

View File

@ -10,39 +10,30 @@ import com.boydti.fawe.object.extent.ResettableExtent;
import com.boydti.fawe.object.extent.ScaleTransform;
import com.boydti.fawe.object.extent.TransformExtent;
import com.boydti.fawe.util.ExtentTraverser;
import org.enginehub.piston.annotation.Command;
import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator;
import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extent.transform.BlockTransformExtent;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.util.command.parametric.Optional;
import java.util.Set;
import org.enginehub.piston.annotation.Command;
import org.enginehub.piston.annotation.CommandContainer;
import org.enginehub.piston.annotation.param.Arg;
@Command(aliases = {"transforms"},
desc = "Help for the various transforms. [More Info](https://git.io/v9KHO)",
descFooter = "Transforms modify how a block is placed\n" +
" - Use [brackets] for arguments\n" +
" - Use , to OR multiple\n" +
" - Use & to AND multiple\n" +
"More Info: https://git.io/v9KHO"
)
public class TransformCommands extends MethodCommands {
public TransformCommands(WorldEdit worldEdit) {
super(worldEdit);
}
@CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class)
public class TransformCommands {
@Command(
name = "#linear",
aliases = {"#l"},
desc = "Sequentially pick from a list of transform"
)
)
public ResettableExtent linear(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
if (other instanceof RandomTransform) {
Set<ResettableExtent> extents = ((RandomTransform) other).getExtents();
return new LinearTransform(extents.toArray(new ResettableExtent[extents.size()]));
return new LinearTransform(extents.toArray(new ResettableExtent[0]));
}
return other;
}
@ -51,11 +42,11 @@ public class TransformCommands extends MethodCommands {
name = "#linear3d",
aliases = {"#l3d"},
desc = "Use the x,y,z coordinate to pick a transform from the list"
)
)
public ResettableExtent linear3d(Actor actor, LocalSession session, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
if (other instanceof RandomTransform) {
Set<ResettableExtent> extents = ((RandomTransform) other).getExtents();
return new Linear3DTransform(extents.toArray(new ResettableExtent[extents.size()]));
return new Linear3DTransform(extents.toArray(new ResettableExtent[0]));
}
return other;
}
@ -63,7 +54,7 @@ public class TransformCommands extends MethodCommands {
@Command(
name = "#pattern",
desc = "Always use a specific pattern"
)
)
public ResettableExtent pattern(Actor actor, LocalSession session, Pattern pattern, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
return new PatternTransform(other, pattern);
}
@ -71,7 +62,7 @@ public class TransformCommands extends MethodCommands {
@Command(
name = "#offset",
desc = "Offset transform"
)
)
public ResettableExtent offset(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
return new OffsetExtent(other, (int) x, (int) y, (int) z);
}
@ -88,7 +79,7 @@ public class TransformCommands extends MethodCommands {
@Command(
name = "#scale",
desc = "All changes will be scaled"
)
)
public ResettableExtent scale(Actor actor, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
return new ScaleTransform(other, x, y, z);
}
@ -96,10 +87,10 @@ public class TransformCommands extends MethodCommands {
@Command(
name = "#rotate",
desc = "All changes will be rotate around the initial position"
)
)
public ResettableExtent rotate(Player player, LocalSession session, double x, double y, double z, @Arg(name = "other", desc = "ResettableExtent", def = "#null") ResettableExtent other) {
ExtentTraverser traverser = new ExtentTraverser(other).find(TransformExtent.class);
BlockTransformExtent affine = (TransformExtent) (traverser != null ? traverser.get() : null);
ExtentTraverser<TransformExtent> traverser = new ExtentTraverser(other).find(TransformExtent.class);
BlockTransformExtent affine = traverser != null ? traverser.get() : null;
if (affine == null) {
other = affine = new TransformExtent(other);
}
@ -108,6 +99,6 @@ public class TransformCommands extends MethodCommands {
transform = transform.rotateY(y);
transform = transform.rotateZ(z);
affine.setTransform(transform);
return (ResettableExtent) other;
return other;
}
}

View File

@ -22,7 +22,6 @@ package com.sk89q.worldedit.command;
import static com.sk89q.worldedit.command.util.Logging.LogMode.PLACEMENT;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.DelegateConsumer;
@ -32,7 +31,6 @@ import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.chat.Message;
import com.boydti.fawe.util.image.ImageUtil;
import org.enginehub.piston.inject.InjectedValueAccess;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalConfiguration;
@ -63,16 +61,13 @@ import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.function.visitor.EntityVisitor;
import com.sk89q.worldedit.internal.annotation.Range;
import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.CylinderRegion;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.command.CommandMapping;
import com.sk89q.worldedit.util.command.Dispatcher;
import com.sk89q.worldedit.internal.annotation.Range;
import com.sk89q.worldedit.util.formatting.component.SubtleFormat;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.format.TextColor;
@ -99,12 +94,12 @@ 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.inject.InjectedValueAccess;
/**
* Utility commands.
*/
@CommandContainer(superTypes = {CommandPermissionsConditionGenerator.Registration.class, CommandQueuedConditionGenerator.Registration.class})
//@Command(aliases = {}, desc = "Various utility commands: [More Info](http://wiki.sk89q.com/wiki/WorldEdit/Utilities)")
public class UtilityCommands {
private final WorldEdit we;
@ -774,7 +769,7 @@ public class UtilityCommands {
return page;
}
public static int getFiles(File dir, Actor actor, InjectedValueAccess args, @Range(min = 0) int page, int perPage, String formatName, boolean playerFolder, Consumer<File> forEachFile) {
public static int getFiles(File dir, Actor actor, InjectedValueAccess args, @org.jetbrains.annotations.Range(from = 0, to = ) int page, int perPage, String formatName, boolean playerFolder, Consumer<File> forEachFile) {
Consumer<File> rootFunction = forEachFile;
//schem list all <path>

View File

@ -31,7 +31,7 @@ public class DefaultTransformParser extends FaweParser<ResettableExtent> {
public DefaultTransformParser(WorldEdit worldEdit) {
super(worldEdit);
this.dispatcher = new SimpleDispatcher();
this.register(new TransformCommands(worldEdit));
this.register(new TransformCommands());
}
@Override

View File

@ -29,12 +29,9 @@ import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.task.ThrowableSupplier;
import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.wrappers.LocationMaskedPlayerWrapper;
import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.reflect.TypeToken;
import com.sk89q.minecraft.util.commands.CommandLocals;
import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.IncompleteRegionException;
import com.sk89q.worldedit.LocalConfiguration;
@ -42,36 +39,46 @@ import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.ApplyBrushCommands;
import com.sk89q.worldedit.command.BiomeCommands;
//import com.sk89q.worldedit.command.BiomeCommandsRegistration;
import com.sk89q.worldedit.command.BiomeCommandsRegistration;
import com.sk89q.worldedit.command.BrushCommands;
import com.sk89q.worldedit.command.BrushCommandsRegistration;
import com.sk89q.worldedit.command.ChunkCommands;
//import com.sk89q.worldedit.command.ChunkCommandsRegistration;
import com.sk89q.worldedit.command.ChunkCommandsRegistration;
import com.sk89q.worldedit.command.ClipboardCommands;
//import com.sk89q.worldedit.command.ClipboardCommandsRegistration;
import com.sk89q.worldedit.command.ClipboardCommandsRegistration;
import com.sk89q.worldedit.command.ExpandCommands;
import com.sk89q.worldedit.command.GeneralCommands;
//import com.sk89q.worldedit.command.GeneralCommandsRegistration;
import com.sk89q.worldedit.command.GeneralCommandsRegistration;
import com.sk89q.worldedit.command.GenerationCommands;
import com.sk89q.worldedit.command.GenerationCommandsRegistration;
import com.sk89q.worldedit.command.HistoryCommands;
//import com.sk89q.worldedit.command.HistoryCommandsRegistration;
import com.sk89q.worldedit.command.HistoryCommandsRegistration;
import com.sk89q.worldedit.command.NavigationCommands;
//import com.sk89q.worldedit.command.NavigationCommandsRegistration;
import com.sk89q.worldedit.command.NavigationCommandsRegistration;
import com.sk89q.worldedit.command.PaintBrushCommands;
import com.sk89q.worldedit.command.RegionCommands;
import com.sk89q.worldedit.command.RegionCommandsRegistration;
import com.sk89q.worldedit.command.SchematicCommands;
//import com.sk89q.worldedit.command.SchematicCommandsRegistration;
import com.sk89q.worldedit.command.SchematicCommandsRegistration;
import com.sk89q.worldedit.command.ScriptingCommands;
import com.sk89q.worldedit.command.ScriptingCommandsRegistration;
import com.sk89q.worldedit.command.SelectionCommands;
import com.sk89q.worldedit.command.SelectionCommandsRegistration;
import com.sk89q.worldedit.command.SnapshotCommands;
//import com.sk89q.worldedit.command.SnapshotCommandsRegistration;
import com.sk89q.worldedit.command.SnapshotCommandsRegistration;
import com.sk89q.worldedit.command.SnapshotUtilCommands;
import com.sk89q.worldedit.command.SnapshotUtilCommandsRegistration;
import com.sk89q.worldedit.command.SuperPickaxeCommands;
//import com.sk89q.worldedit.command.SuperPickaxeCommandsRegistration;
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.TransformCommands;
import com.sk89q.worldedit.command.UtilityCommands;
import com.sk89q.worldedit.command.UtilityCommandsRegistration;
import com.sk89q.worldedit.command.WorldEditCommands;
//import com.sk89q.worldedit.command.WorldEditCommandsRegistration;
import com.sk89q.worldedit.command.WorldEditCommandsRegistration;
import com.sk89q.worldedit.command.argument.Arguments;
import com.sk89q.worldedit.command.argument.BooleanConverter;
import com.sk89q.worldedit.command.argument.CommaSeparatedValuesConverter;
@ -84,9 +91,7 @@ import com.sk89q.worldedit.command.argument.RegionFactoryConverter;
import com.sk89q.worldedit.command.argument.RegistryConverter;
import com.sk89q.worldedit.command.argument.VectorConverter;
import com.sk89q.worldedit.command.argument.ZonedDateTimeConverter;
import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.command.util.CommandPermissions;
import com.sk89q.worldedit.command.util.CommandQueued;
import com.sk89q.worldedit.command.util.CommandQueuedCondition;
import com.sk89q.worldedit.command.util.PermissionCondition;
import com.sk89q.worldedit.command.util.SubCommandPermissionCondition;
@ -117,8 +122,6 @@ import java.io.File;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Optional;
@ -133,9 +136,7 @@ import javax.annotation.Nullable;
import org.enginehub.piston.Command;
import org.enginehub.piston.CommandManager;
import org.enginehub.piston.TextConfig;
import org.enginehub.piston.converter.ArgumentConverter;
import org.enginehub.piston.converter.ArgumentConverters;
import org.enginehub.piston.converter.ConversionResult;
import org.enginehub.piston.exception.CommandException;
import org.enginehub.piston.exception.CommandExecutionException;
import org.enginehub.piston.exception.ConditionFailedException;
@ -156,6 +157,7 @@ import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Handles the registration and invocation of commands.
*
@ -179,14 +181,9 @@ public final class PlatformCommandManager {
private final InjectedValueStore globalInjectedValues;
private final DynamicStreamHandler dynamicHandler = new DynamicStreamHandler();
private final WorldEditExceptionConverter exceptionConverter;
private final CommandRegistrationHandler registration;
public final CommandRegistrationHandler registration;
private static PlatformCommandManager INSTANCE;
/*
Command types
*/
/**
* Create a new instance.
*
@ -230,7 +227,7 @@ public final class PlatformCommandManager {
DirectionConverter.register(worldEdit, commandManager);
FactoryConverter.register(worldEdit, commandManager);
for (int count = 2; count <= 3; count++) {
commandManager.registerConverter(Key.of(double.class, com.sk89q.worldedit.extension.platform.Annotations.radii(count)),
commandManager.registerConverter(Key.of(double.class, Annotations.radii(count)),
CommaSeparatedValuesConverter.wrapAndLimit(ArgumentConverters.get(
TypeToken.of(double.class)
), count)
@ -261,17 +258,17 @@ public final class PlatformCommandManager {
});
});
globalInjectedValues.injectValue(Key.of(EditSession.class),
context -> {
LocalSession localSession = context.injectedValue(Key.of(LocalSession.class))
.orElseThrow(() -> new IllegalStateException("No LocalSession"));
return context.injectedValue(Key.of(Player.class))
.map(player -> {
EditSession editSession = localSession.createEditSession(player);
editSession.enableStandardMode();
return editSession;
});
});
globalInjectedValues.injectValue(Key.of(InjectedValueAccess.class), context -> Optional.of(context));
context -> {
LocalSession localSession = context.injectedValue(Key.of(LocalSession.class))
.orElseThrow(() -> new IllegalStateException("No LocalSession"));
return context.injectedValue(Key.of(Player.class))
.map(player -> {
EditSession editSession = localSession.createEditSession(player);
editSession.enableStandardMode();
return editSession;
});
});
globalInjectedValues.injectValue(Key.of(InjectedValueAccess.class), Optional::of);
}
private <CI> void registerSubCommands(String name, List<String> aliases, String desc,
@ -309,121 +306,141 @@ public final class PlatformCommandManager {
private void registerAllCommands() {
if (Settings.IMP.ENABLED_COMPONENTS.COMMANDS) {
// TODO NOT IMPLEMENTED dunno why these have issues generating
// registerSubCommands(
// "schematic",
// ImmutableList.of("schem", "/schematic", "/schem"),
// "Schematic commands for saving/loading areas",
// SchematicCommandsRegistration.builder(),
// new SchematicCommands(worldEdit)
// );
// registerSubCommands(
// "snapshot",
// ImmutableList.of("snap"),
// "Snapshot commands for restoring backups",
// SnapshotCommandsRegistration.builder(),
// new SnapshotCommands(worldEdit)
// );
// registerSubCommands(
// "superpickaxe",
// ImmutableList.of("pickaxe", "sp"),
// "Super-pickaxe commands",
// SuperPickaxeCommandsRegistration.builder(),
// new SuperPickaxeCommands(worldEdit)
// );
// registerSubCommands(
// "brush",
// ImmutableList.of("br", "/brush", "/br"),
// "Brushing commands",
// BrushCommandsRegistration.builder(),
// new BrushCommands(worldEdit),
// (Consumer<CommandManager>) manager -> {
// PaintBrushCommands.register(commandManagerService, manager, registration);
// ApplyBrushCommands.register(commandManagerService, manager, registration);
// }
// );
// registerSubCommands(
// "worldedit",
// ImmutableList.of("we"),
// "WorldEdit commands",
// WorldEditCommandsRegistration.builder(),
// new WorldEditCommands(worldEdit)
// );
// this.registration.register(
// commandManager,
// BiomeCommandsRegistration.builder(),
// new BiomeCommands()
// );
// this.registration.register(
// commandManager,
// ChunkCommandsRegistration.builder(),
// new ChunkCommands(worldEdit)
// );
// this.registration.register(
// commandManager,
// ClipboardCommandsRegistration.builder(),
// new ClipboardCommands(worldEdit)
// );
// this.registration.register(
// commandManager,
// GeneralCommandsRegistration.builder(),
// new GeneralCommands(worldEdit)
// );
// this.registration.register(
// commandManager,
// GenerationCommandsRegistration.builder(),
// new GenerationCommands(worldEdit)
// );
// this.registration.register(
// commandManager,
// HistoryCommandsRegistration.builder(),
// new HistoryCommands(worldEdit)
// );
// this.registration.register(
// commandManager,
// NavigationCommandsRegistration.builder(),
// new NavigationCommands(worldEdit)
// );
// this.registration.register(
// commandManager,
// RegionCommandsRegistration.builder(),
// new RegionCommands(worldEdit)
// );
// this.registration.register(
// commandManager,
// ScriptingCommandsRegistration.builder(),
// new ScriptingCommands(worldEdit)
// );
// this.registration.register(
// commandManager,
// SelectionCommandsRegistration.builder(),
// new SelectionCommands(worldEdit)
// );
// ExpandCommands.register(registration, commandManager, commandManagerService);
// this.registration.register(
// commandManager,
// SnapshotUtilCommandsRegistration.builder(),
// new SnapshotUtilCommands(worldEdit)
// );
// this.registration.register(
// commandManager,
// ToolCommandsRegistration.builder(),
// new ToolCommands(worldEdit)
// );
// this.registration.register(
// commandManager,
// ToolUtilCommandsRegistration.builder(),
// new ToolUtilCommands(worldEdit)
// );
// this.registration.register(
// commandManager,
// UtilityCommandsRegistration.builder(),
// new UtilityCommands(worldEdit)
// );
// this.registration.register(
// commandManager,
// AnvilCommandsRegistration.builder(),
// new AnvilCommands(worldEdit)
// );
registerSubCommands(
"schematic",
ImmutableList.of("schem", "/schematic", "/schem"),
"Schematic commands for saving/loading areas",
SchematicCommandsRegistration.builder(),
new SchematicCommands(worldEdit)
);
registerSubCommands(
"snapshot",
ImmutableList.of("snap"),
"Snapshot commands for restoring backups",
SnapshotCommandsRegistration.builder(),
new SnapshotCommands(worldEdit)
);
registerSubCommands(
"superpickaxe",
ImmutableList.of("pickaxe", "sp"),
"Super-pickaxe commands",
SuperPickaxeCommandsRegistration.builder(),
new SuperPickaxeCommands(worldEdit)
);
registerSubCommands(
"brush",
ImmutableList.of("br", "/brush", "/br"),
"Brushing commands",
BrushCommandsRegistration.builder(),
new BrushCommands(worldEdit),
manager -> {
PaintBrushCommands.register(commandManagerService, manager, registration);
ApplyBrushCommands.register(commandManagerService, manager, registration);
}
);
registerSubCommands(
"brush",
ImmutableList.of("br", "/b"),
"Tool commands",
BrushOptionsCommandsRegistration.builder(),
new BrushOptionsCommands(worldEdit)
);
registerSubCommands(
"worldedit",
ImmutableList.of("we"),
"WorldEdit commands",
WorldEditCommandsRegistration.builder(),
new WorldEditCommands(worldEdit)
);
registerSubCommands(
"/anvil",
ImmutableList.of(),
"Manipulate billions of blocks https://github.com/boy0001/FastAsyncWorldedit/wiki/Anvil-API",
AnvilCommandsRegistration.builder(),
new AnvilCommands(worldEdit)
);
registerSubCommands(
"transforms",
ImmutableList.of(),
"Transforms modify how a block is placed\n" +
" - Use [brackets] for arguments\n" +
" - Use , to OR multiple\n" +
" - Use & to AND multiple\n" +
"More Info: https://git.io/v9KHO",
TransformCommandsRegistration.builder(),
new TransformCommands()
);
this.registration.register(
commandManager,
BiomeCommandsRegistration.builder(),
new BiomeCommands()
);
this.registration.register(
commandManager,
ChunkCommandsRegistration.builder(),
new ChunkCommands(worldEdit)
);
this.registration.register(
commandManager,
ClipboardCommandsRegistration.builder(),
new ClipboardCommands(worldEdit)
);
this.registration.register(
commandManager,
GeneralCommandsRegistration.builder(),
new GeneralCommands(worldEdit)
);
this.registration.register(
commandManager,
GenerationCommandsRegistration.builder(),
new GenerationCommands(worldEdit)
);
this.registration.register(
commandManager,
HistoryCommandsRegistration.builder(),
new HistoryCommands(worldEdit)
);
this.registration.register(
commandManager,
NavigationCommandsRegistration.builder(),
new NavigationCommands(worldEdit)
);
this.registration.register(
commandManager,
RegionCommandsRegistration.builder(),
new RegionCommands(worldEdit)
);
this.registration.register(
commandManager,
ScriptingCommandsRegistration.builder(),
new ScriptingCommands(worldEdit)
);
this.registration.register(
commandManager,
SelectionCommandsRegistration.builder(),
new SelectionCommands(worldEdit)
);
ExpandCommands.register(registration, commandManager, commandManagerService);
this.registration.register(
commandManager,
SnapshotUtilCommandsRegistration.builder(),
new SnapshotUtilCommands(worldEdit)
);
this.registration.register(
commandManager,
ToolCommandsRegistration.builder(),
new ToolCommands(worldEdit)
);
this.registration.register(
commandManager,
ToolUtilCommandsRegistration.builder(),
new ToolUtilCommands(worldEdit)
);
this.registration.register(
commandManager,
UtilityCommandsRegistration.builder(),
new UtilityCommands(worldEdit)
);
}
}
@ -531,22 +548,10 @@ public final class PlatformCommandManager {
dynamicHandler.setHandler(null);
}
private Stream<Substring> parseArgs(String input) {
public Stream<Substring> parseArgs(String input) {
return new CommandArgParser(CommandArgParser.spaceSplit(input.substring(1))).parseArgs();
}
public <T> Collection<T> parse(Class<T> clazz, String arguments, @Nullable Actor actor) {
List<T> def = Collections.emptyList();
Optional<ArgumentConverter<T>> converterOptional = commandManager.getConverter(Key.of(clazz));
if (converterOptional.isPresent()) {
ArgumentConverter<T> converter = converterOptional.get();
MemoizingValueAccess injectedValues = initializeInjectedValues(() -> arguments, actor);
ConversionResult<T> result = converter.convert(arguments, injectedValues);
return result.orElse(def);
}
return def;
}
private Actor wrapActor(Actor actor, InjectedValueStore context) {
if (actor instanceof Player) {
final Set<String> failedPermissions = new LinkedHashSet<>();
@ -630,17 +635,19 @@ public final class PlatformCommandManager {
Request.request().setWorld(((World) extent));
}
}
LocalConfiguration config = worldEdit.getConfiguration();
MemoizingValueAccess context = initializeInjectedValues(event::getArguments, actor);
ThrowableSupplier<Throwable> task =
() -> commandManager.execute(context,Lists.newArrayList(split));
() -> commandManager.execute(context, ImmutableList.copyOf(split));
handleCommandTask(task, context, session, event);
handleCommandTask(task, context, actor, session, event);
}
public Object handleCommandTask(ThrowableSupplier<Throwable> task, InjectedValueAccess context, @Nullable LocalSession session, CommandEvent event) {
Actor actor = context.injectedValue(Key.of(Actor.class)).orElseThrow(() -> new IllegalStateException("No player"));
public Object handleCommandTask(ThrowableSupplier<Throwable> task, InjectedValueAccess context, @NotNull Actor actor, @Nullable LocalSession session, CommandEvent event) {
Request.reset();
long start = System.currentTimeMillis();
try {
@ -694,8 +701,7 @@ public final class PlatformCommandManager {
} else {
System.out.println("Invalid context " + context);
}
Optional<EditSession> editSessionOpt =
context.injectedValue(Key.of(EditSession.class));
Optional<EditSession> editSessionOpt = context.injectedValue(Key.of(EditSession.class));
if (editSessionOpt.isPresent()) {
EditSession editSession = editSessionOpt.get();

View File

@ -70,7 +70,7 @@ public class CommandScriptLoader {
BrushCommands processor = new BrushCommands(WorldEdit.getInstance());
for (FunctionParametricCallable cmd : cmds) {
ProcessedCallable processed = new ProcessedCallable(cmd, processor);
PlatformCommandManager.getInstance().registerCommand(aliases, cmd.getCommand(), processed);
PlatformCommandManager.getInstance().registration.register(aliases, cmd.getCommand(), processed);
}
}
return;

View File

@ -49,7 +49,6 @@ public class NashornCraftScriptEngine implements CraftScriptEngine {
synchronized (NashornCraftScriptEngine.class) {
if (FACTORY == null) FACTORY = new NashornScriptEngineFactory();
}
;
ScriptEngine engine = FACTORY.getScriptEngine("--language=es6");
SimpleBindings bindings = new SimpleBindings();

View File

@ -47,7 +47,7 @@ public class RhinoCraftScriptEngine implements CraftScriptEngine {
@Override
public Object evaluate(String script, String filename, Map<String, Object> args)
throws ScriptException, Throwable {
throws Throwable {
RhinoContextFactory factory = new RhinoContextFactory(timeLimit);
Context cx = factory.enterContext();
ScriptableObject scriptable = new ImporterTopLevel(cx);

View File

@ -90,7 +90,7 @@ configure(subprojects + project("core:ap")) {
def textExtrasVersion = "3.0.2"
project("core") {
def textVersion = "3.0.1"
def textVersion = "3.0.2"
def pistonVersion = '0.4.3-SNAPSHOT'
dependencies {
@ -98,6 +98,7 @@ project("core") {
shade "net.kyori:text-serializer-gson:$textVersion"
shade "net.kyori:text-serializer-legacy:$textVersion"
shade "net.kyori:text-serializer-plain:$textVersion"
shade "net.kyori:text-feature-pagination:$textVersion"
shade('com.sk89q:jchronic:0.2.4a') {
exclude(group: "junit", module: "junit")
}