Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-12-26 19:02:36 +01:00
(Breaking) Moved some packages around.
Most of the changes should not break *most* WorldEdit-using plugins, but implementations of WorldEdit are broken by this change.
Dieser Commit ist enthalten in:
Ursprung
6e70e8c862
Commit
469cb8c8b3
@ -10,8 +10,8 @@ import com.sk89q.worldedit.LocalPlayer;
|
|||||||
import com.sk89q.worldedit.LocalWorld;
|
import com.sk89q.worldedit.LocalWorld;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldVector;
|
import com.sk89q.worldedit.WorldVector;
|
||||||
import com.sk89q.worldedit.bags.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.cui.CUIEvent;
|
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||||
|
|
||||||
public class ForgePlayer extends LocalPlayer {
|
public class ForgePlayer extends LocalPlayer {
|
||||||
private EntityPlayerMP player;
|
private EntityPlayerMP player;
|
||||||
|
@ -2,20 +2,7 @@ package com.sk89q.jnbt;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.sk89q.jnbt.ByteArrayTag;
|
import com.sk89q.worldedit.world.storage.InvalidFormatException;
|
||||||
import com.sk89q.jnbt.ByteTag;
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
|
||||||
import com.sk89q.jnbt.DoubleTag;
|
|
||||||
import com.sk89q.jnbt.EndTag;
|
|
||||||
import com.sk89q.jnbt.FloatTag;
|
|
||||||
import com.sk89q.jnbt.IntTag;
|
|
||||||
import com.sk89q.jnbt.ListTag;
|
|
||||||
import com.sk89q.jnbt.LongTag;
|
|
||||||
import com.sk89q.jnbt.NBTConstants;
|
|
||||||
import com.sk89q.jnbt.ShortTag;
|
|
||||||
import com.sk89q.jnbt.StringTag;
|
|
||||||
import com.sk89q.jnbt.Tag;
|
|
||||||
import com.sk89q.worldedit.data.InvalidFormatException;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* JNBT License
|
* JNBT License
|
||||||
|
@ -30,9 +30,10 @@ import java.util.Map;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
import com.sk89q.worldedit.data.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.schematic.SchematicFormat;
|
import com.sk89q.worldedit.schematic.SchematicFormat;
|
||||||
|
import com.sk89q.worldedit.util.Countable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The clipboard remembers the state of a cuboid region.
|
* The clipboard remembers the state of a cuboid region.
|
||||||
|
@ -19,16 +19,24 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit;
|
package com.sk89q.worldedit;
|
||||||
|
|
||||||
import com.sk89q.worldedit.bags.BlockBag;
|
import com.sk89q.worldedit.extent.buffer.ForgetfulExtentBuffer;
|
||||||
|
import com.sk89q.worldedit.extent.cache.LastAccessExtentCache;
|
||||||
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
import com.sk89q.worldedit.blocks.BlockType;
|
import com.sk89q.worldedit.blocks.BlockType;
|
||||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||||
import com.sk89q.worldedit.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.expression.ExpressionException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
import com.sk89q.worldedit.expression.runtime.RValue;
|
import com.sk89q.worldedit.internal.expression.runtime.RValue;
|
||||||
import com.sk89q.worldedit.extent.*;
|
import com.sk89q.worldedit.extent.*;
|
||||||
|
import com.sk89q.worldedit.extent.inventory.BlockBagExtent;
|
||||||
import com.sk89q.worldedit.extent.reorder.MultiStageReorder;
|
import com.sk89q.worldedit.extent.reorder.MultiStageReorder;
|
||||||
|
import com.sk89q.worldedit.extent.validation.BlockChangeLimiter;
|
||||||
|
import com.sk89q.worldedit.extent.validation.DataValidatorExtent;
|
||||||
|
import com.sk89q.worldedit.extent.world.BlockQuirkExtent;
|
||||||
|
import com.sk89q.worldedit.extent.world.ChunkLoadingExtent;
|
||||||
|
import com.sk89q.worldedit.extent.world.FastModeExtent;
|
||||||
import com.sk89q.worldedit.function.GroundFunction;
|
import com.sk89q.worldedit.function.GroundFunction;
|
||||||
import com.sk89q.worldedit.function.RegionMaskingFilter;
|
import com.sk89q.worldedit.function.RegionMaskingFilter;
|
||||||
import com.sk89q.worldedit.function.block.Counter;
|
import com.sk89q.worldedit.function.block.Counter;
|
||||||
@ -54,10 +62,11 @@ import com.sk89q.worldedit.math.transform.AffineTransform;
|
|||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.patterns.Pattern;
|
||||||
import com.sk89q.worldedit.patterns.SingleBlockPattern;
|
import com.sk89q.worldedit.patterns.SingleBlockPattern;
|
||||||
import com.sk89q.worldedit.regions.*;
|
import com.sk89q.worldedit.regions.*;
|
||||||
import com.sk89q.worldedit.shape.ArbitraryBiomeShape;
|
import com.sk89q.worldedit.regions.shape.ArbitraryBiomeShape;
|
||||||
import com.sk89q.worldedit.shape.ArbitraryShape;
|
import com.sk89q.worldedit.regions.shape.ArbitraryShape;
|
||||||
import com.sk89q.worldedit.shape.RegionShape;
|
import com.sk89q.worldedit.regions.shape.RegionShape;
|
||||||
import com.sk89q.worldedit.shape.WorldEditExpressionEnvironment;
|
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
|
||||||
|
import com.sk89q.worldedit.util.Countable;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
import com.sk89q.worldedit.util.collection.DoubleArrayList;
|
import com.sk89q.worldedit.util.collection.DoubleArrayList;
|
||||||
import com.sk89q.worldedit.util.eventbus.EventBus;
|
import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit;
|
package com.sk89q.worldedit;
|
||||||
|
|
||||||
import com.sk89q.worldedit.bags.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||||
import com.sk89q.worldedit.util.eventbus.EventBus;
|
import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ import java.util.Set;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
import com.sk89q.worldedit.blocks.ItemID;
|
import com.sk89q.worldedit.blocks.ItemID;
|
||||||
import com.sk89q.worldedit.snapshots.SnapshotRepository;
|
import com.sk89q.worldedit.world.snapshot.SnapshotRepository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents WorldEdit's configuration.
|
* Represents WorldEdit's configuration.
|
||||||
|
@ -21,12 +21,12 @@ package com.sk89q.worldedit;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import com.sk89q.worldedit.bags.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
import com.sk89q.worldedit.blocks.BlockType;
|
import com.sk89q.worldedit.blocks.BlockType;
|
||||||
import com.sk89q.worldedit.blocks.ItemID;
|
import com.sk89q.worldedit.blocks.ItemID;
|
||||||
import com.sk89q.worldedit.cui.CUIEvent;
|
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||||
import com.sk89q.worldedit.util.TargetBlock;
|
import com.sk89q.worldedit.util.TargetBlock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -28,15 +28,15 @@ import com.sk89q.jchronic.Chronic;
|
|||||||
import com.sk89q.jchronic.Options;
|
import com.sk89q.jchronic.Options;
|
||||||
import com.sk89q.jchronic.utils.Span;
|
import com.sk89q.jchronic.utils.Span;
|
||||||
import com.sk89q.jchronic.utils.Time;
|
import com.sk89q.jchronic.utils.Time;
|
||||||
import com.sk89q.worldedit.snapshots.Snapshot;
|
import com.sk89q.worldedit.world.snapshot.Snapshot;
|
||||||
import com.sk89q.worldedit.tools.BrushTool;
|
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||||
import com.sk89q.worldedit.tools.SinglePickaxe;
|
import com.sk89q.worldedit.command.tool.SinglePickaxe;
|
||||||
import com.sk89q.worldedit.tools.BlockTool;
|
import com.sk89q.worldedit.command.tool.BlockTool;
|
||||||
import com.sk89q.worldedit.tools.Tool;
|
import com.sk89q.worldedit.command.tool.Tool;
|
||||||
import com.sk89q.worldedit.bags.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.cui.CUIRegion;
|
import com.sk89q.worldedit.internal.cui.CUIRegion;
|
||||||
import com.sk89q.worldedit.cui.CUIEvent;
|
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||||
import com.sk89q.worldedit.cui.SelectionShapeEvent;
|
import com.sk89q.worldedit.internal.cui.SelectionShapeEvent;
|
||||||
import com.sk89q.worldedit.masks.Mask;
|
import com.sk89q.worldedit.masks.Mask;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegionSelector;
|
import com.sk89q.worldedit.regions.CuboidRegionSelector;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
@ -23,9 +23,9 @@ import com.sk89q.minecraft.util.commands.*;
|
|||||||
import com.sk89q.minecraft.util.commands.Console;
|
import com.sk89q.minecraft.util.commands.Console;
|
||||||
import com.sk89q.util.StringUtil;
|
import com.sk89q.util.StringUtil;
|
||||||
import com.sk89q.worldedit.CuboidClipboard.FlipDirection;
|
import com.sk89q.worldedit.CuboidClipboard.FlipDirection;
|
||||||
import com.sk89q.worldedit.bags.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.blocks.*;
|
import com.sk89q.worldedit.blocks.*;
|
||||||
import com.sk89q.worldedit.commands.*;
|
import com.sk89q.worldedit.command.*;
|
||||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||||
import com.sk89q.worldedit.masks.*;
|
import com.sk89q.worldedit.masks.*;
|
||||||
import com.sk89q.worldedit.patterns.*;
|
import com.sk89q.worldedit.patterns.*;
|
||||||
@ -33,7 +33,8 @@ import com.sk89q.worldedit.regions.RegionSelector;
|
|||||||
import com.sk89q.worldedit.scripting.CraftScriptContext;
|
import com.sk89q.worldedit.scripting.CraftScriptContext;
|
||||||
import com.sk89q.worldedit.scripting.CraftScriptEngine;
|
import com.sk89q.worldedit.scripting.CraftScriptEngine;
|
||||||
import com.sk89q.worldedit.scripting.RhinoCraftScriptEngine;
|
import com.sk89q.worldedit.scripting.RhinoCraftScriptEngine;
|
||||||
import com.sk89q.worldedit.tools.*;
|
import com.sk89q.worldedit.command.tool.*;
|
||||||
|
import com.sk89q.worldedit.util.LogFormat;
|
||||||
import com.sk89q.worldedit.util.eventbus.EventBus;
|
import com.sk89q.worldedit.util.eventbus.EventBus;
|
||||||
|
|
||||||
import javax.script.ScriptException;
|
import javax.script.ScriptException;
|
||||||
|
@ -29,7 +29,7 @@ import com.sk89q.jnbt.ListTag;
|
|||||||
import com.sk89q.jnbt.NBTUtils;
|
import com.sk89q.jnbt.NBTUtils;
|
||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.data.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a chest block.
|
* Represents a chest block.
|
||||||
|
@ -30,7 +30,7 @@ import com.sk89q.jnbt.ListTag;
|
|||||||
import com.sk89q.jnbt.NBTUtils;
|
import com.sk89q.jnbt.NBTUtils;
|
||||||
import com.sk89q.jnbt.ShortTag;
|
import com.sk89q.jnbt.ShortTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.data.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a block that stores items.
|
* Represents a block that stores items.
|
||||||
|
@ -29,7 +29,7 @@ import com.sk89q.jnbt.ListTag;
|
|||||||
import com.sk89q.jnbt.NBTUtils;
|
import com.sk89q.jnbt.NBTUtils;
|
||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.data.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents dispensers.
|
* Represents dispensers.
|
||||||
|
@ -30,7 +30,7 @@ import com.sk89q.jnbt.NBTUtils;
|
|||||||
import com.sk89q.jnbt.ShortTag;
|
import com.sk89q.jnbt.ShortTag;
|
||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.data.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a furnace block.
|
* Represents a furnace block.
|
||||||
|
@ -21,7 +21,7 @@ package com.sk89q.worldedit.blocks;
|
|||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.data.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
@ -29,8 +29,8 @@ import com.sk89q.jnbt.ShortTag;
|
|||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.MobType;
|
import com.sk89q.worldedit.MobType;
|
||||||
import com.sk89q.worldedit.data.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
import com.sk89q.worldedit.data.InvalidFormatException;
|
import com.sk89q.worldedit.world.storage.InvalidFormatException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mob spawner block.
|
* A mob spawner block.
|
||||||
|
@ -26,7 +26,7 @@ import com.sk89q.jnbt.ByteTag;
|
|||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.data.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A note block.
|
* A note block.
|
||||||
|
@ -25,7 +25,7 @@ import java.util.Map;
|
|||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.data.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a sign block.
|
* Represents a sign block.
|
||||||
|
@ -26,7 +26,7 @@ import com.sk89q.jnbt.ByteTag;
|
|||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.jnbt.StringTag;
|
import com.sk89q.jnbt.StringTag;
|
||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.data.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A skull block.
|
* A skull block.
|
||||||
|
@ -28,7 +28,7 @@ import com.sk89q.worldedit.PlayerNeededException;
|
|||||||
import com.sk89q.worldedit.ServerInterface;
|
import com.sk89q.worldedit.ServerInterface;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldVector;
|
import com.sk89q.worldedit.WorldVector;
|
||||||
import com.sk89q.worldedit.bags.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
|
|
||||||
public class BukkitCommandSender extends LocalPlayer {
|
public class BukkitCommandSender extends LocalPlayer {
|
||||||
private CommandSender sender;
|
private CommandSender sender;
|
||||||
|
@ -32,8 +32,8 @@ import com.sk89q.worldedit.LocalWorld;
|
|||||||
import com.sk89q.worldedit.ServerInterface;
|
import com.sk89q.worldedit.ServerInterface;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldVector;
|
import com.sk89q.worldedit.WorldVector;
|
||||||
import com.sk89q.worldedit.bags.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.cui.CUIEvent;
|
import com.sk89q.worldedit.internal.cui.CUIEvent;
|
||||||
|
|
||||||
public class BukkitPlayer extends LocalPlayer {
|
public class BukkitPlayer extends LocalPlayer {
|
||||||
private Player player;
|
private Player player;
|
||||||
|
@ -22,7 +22,7 @@ package com.sk89q.worldedit.bukkit;
|
|||||||
import com.sk89q.worldedit.WorldVector;
|
import com.sk89q.worldedit.WorldVector;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import com.sk89q.worldedit.bags.*;
|
import com.sk89q.worldedit.extent.inventory.*;
|
||||||
import com.sk89q.worldedit.blocks.BaseItem;
|
import com.sk89q.worldedit.blocks.BaseItem;
|
||||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
|
@ -22,7 +22,7 @@ import com.sk89q.worldedit.Vector;
|
|||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.TileEntityBlock;
|
import com.sk89q.worldedit.blocks.TileEntityBlock;
|
||||||
import com.sk89q.worldedit.data.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
import com.sk89q.worldedit.foundation.Block;
|
import com.sk89q.worldedit.foundation.Block;
|
||||||
import net.minecraft.server.v1_7_R2.*;
|
import net.minecraft.server.v1_7_R2.*;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
@ -45,7 +45,7 @@ import com.sk89q.worldedit.LocalSession;
|
|||||||
import com.sk89q.worldedit.ServerInterface;
|
import com.sk89q.worldedit.ServerInterface;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditOperation;
|
import com.sk89q.worldedit.WorldEditOperation;
|
||||||
import com.sk89q.worldedit.bags.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
|
||||||
import com.sk89q.worldedit.bukkit.selections.Polygonal2DSelection;
|
import com.sk89q.worldedit.bukkit.selections.Polygonal2DSelection;
|
||||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||||
|
|
@ -1,293 +1,293 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.worldedit.CuboidClipboard;
|
import com.sk89q.worldedit.CuboidClipboard;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.LocalWorld.KillFlags;
|
import com.sk89q.worldedit.LocalWorld.KillFlags;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
import com.sk89q.worldedit.commands.UtilityCommands.FlagContainer;
|
import com.sk89q.worldedit.command.UtilityCommands.FlagContainer;
|
||||||
import com.sk89q.worldedit.masks.BlockMask;
|
import com.sk89q.worldedit.masks.BlockMask;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.patterns.Pattern;
|
||||||
import com.sk89q.worldedit.patterns.SingleBlockPattern;
|
import com.sk89q.worldedit.patterns.SingleBlockPattern;
|
||||||
import com.sk89q.worldedit.tools.BrushTool;
|
import com.sk89q.worldedit.command.tool.BrushTool;
|
||||||
import com.sk89q.worldedit.tools.brushes.ButcherBrush;
|
import com.sk89q.worldedit.command.tool.brush.ButcherBrush;
|
||||||
import com.sk89q.worldedit.tools.brushes.ClipboardBrush;
|
import com.sk89q.worldedit.command.tool.brush.ClipboardBrush;
|
||||||
import com.sk89q.worldedit.tools.brushes.CylinderBrush;
|
import com.sk89q.worldedit.command.tool.brush.CylinderBrush;
|
||||||
import com.sk89q.worldedit.tools.brushes.GravityBrush;
|
import com.sk89q.worldedit.command.tool.brush.GravityBrush;
|
||||||
import com.sk89q.worldedit.tools.brushes.HollowCylinderBrush;
|
import com.sk89q.worldedit.command.tool.brush.HollowCylinderBrush;
|
||||||
import com.sk89q.worldedit.tools.brushes.HollowSphereBrush;
|
import com.sk89q.worldedit.command.tool.brush.HollowSphereBrush;
|
||||||
import com.sk89q.worldedit.tools.brushes.SmoothBrush;
|
import com.sk89q.worldedit.command.tool.brush.SmoothBrush;
|
||||||
import com.sk89q.worldedit.tools.brushes.SphereBrush;
|
import com.sk89q.worldedit.command.tool.brush.SphereBrush;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Brush shape commands.
|
* Brush shape commands.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class BrushCommands {
|
public class BrushCommands {
|
||||||
private final WorldEdit we;
|
private final WorldEdit we;
|
||||||
|
|
||||||
public BrushCommands(WorldEdit we) {
|
public BrushCommands(WorldEdit we) {
|
||||||
this.we = we;
|
this.we = we;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "sphere", "s" },
|
aliases = { "sphere", "s" },
|
||||||
usage = "<block> [radius]",
|
usage = "<block> [radius]",
|
||||||
flags = "h",
|
flags = "h",
|
||||||
desc = "Choose the sphere brush",
|
desc = "Choose the sphere brush",
|
||||||
help =
|
help =
|
||||||
"Chooses the sphere brush.\n" +
|
"Chooses the sphere brush.\n" +
|
||||||
"The -h flag creates hollow spheres instead.",
|
"The -h flag creates hollow spheres instead.",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 2
|
max = 2
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.sphere")
|
@CommandPermissions("worldedit.brush.sphere")
|
||||||
public void sphereBrush(CommandContext args, LocalSession session,
|
public void sphereBrush(CommandContext args, LocalSession session,
|
||||||
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
double radius = args.argsLength() > 1 ? args.getDouble(1) : 2;
|
double radius = args.argsLength() > 1 ? args.getDouble(1) : 2;
|
||||||
we.checkMaxBrushRadius(radius);
|
we.checkMaxBrushRadius(radius);
|
||||||
|
|
||||||
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||||
Pattern fill = we.getBlockPattern(player, args.getString(0));
|
Pattern fill = we.getBlockPattern(player, args.getString(0));
|
||||||
tool.setFill(fill);
|
tool.setFill(fill);
|
||||||
tool.setSize(radius);
|
tool.setSize(radius);
|
||||||
|
|
||||||
if (args.hasFlag('h')) {
|
if (args.hasFlag('h')) {
|
||||||
tool.setBrush(new HollowSphereBrush(), "worldedit.brush.sphere");
|
tool.setBrush(new HollowSphereBrush(), "worldedit.brush.sphere");
|
||||||
} else {
|
} else {
|
||||||
tool.setBrush(new SphereBrush(), "worldedit.brush.sphere");
|
tool.setBrush(new SphereBrush(), "worldedit.brush.sphere");
|
||||||
}
|
}
|
||||||
|
|
||||||
player.print(String.format("Sphere brush shape equipped (%.0f).",
|
player.print(String.format("Sphere brush shape equipped (%.0f).",
|
||||||
radius));
|
radius));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "cylinder", "cyl", "c" },
|
aliases = { "cylinder", "cyl", "c" },
|
||||||
usage = "<block> [radius] [height]",
|
usage = "<block> [radius] [height]",
|
||||||
flags = "h",
|
flags = "h",
|
||||||
desc = "Choose the cylinder brush",
|
desc = "Choose the cylinder brush",
|
||||||
help =
|
help =
|
||||||
"Chooses the cylinder brush.\n" +
|
"Chooses the cylinder brush.\n" +
|
||||||
"The -h flag creates hollow cylinders instead.",
|
"The -h flag creates hollow cylinders instead.",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 3
|
max = 3
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.cylinder")
|
@CommandPermissions("worldedit.brush.cylinder")
|
||||||
public void cylinderBrush(CommandContext args, LocalSession session,
|
public void cylinderBrush(CommandContext args, LocalSession session,
|
||||||
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
double radius = args.argsLength() > 1 ? args.getDouble(1) : 2;
|
double radius = args.argsLength() > 1 ? args.getDouble(1) : 2;
|
||||||
we.checkMaxBrushRadius(radius);
|
we.checkMaxBrushRadius(radius);
|
||||||
|
|
||||||
int height = args.argsLength() > 2 ? args.getInteger(2) : 1;
|
int height = args.argsLength() > 2 ? args.getInteger(2) : 1;
|
||||||
we.checkMaxBrushRadius(height);
|
we.checkMaxBrushRadius(height);
|
||||||
|
|
||||||
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||||
Pattern fill = we.getBlockPattern(player, args.getString(0));
|
Pattern fill = we.getBlockPattern(player, args.getString(0));
|
||||||
tool.setFill(fill);
|
tool.setFill(fill);
|
||||||
tool.setSize(radius);
|
tool.setSize(radius);
|
||||||
|
|
||||||
if (args.hasFlag('h')) {
|
if (args.hasFlag('h')) {
|
||||||
tool.setBrush(new HollowCylinderBrush(height), "worldedit.brush.cylinder");
|
tool.setBrush(new HollowCylinderBrush(height), "worldedit.brush.cylinder");
|
||||||
} else {
|
} else {
|
||||||
tool.setBrush(new CylinderBrush(height), "worldedit.brush.cylinder");
|
tool.setBrush(new CylinderBrush(height), "worldedit.brush.cylinder");
|
||||||
}
|
}
|
||||||
|
|
||||||
player.print(String.format("Cylinder brush shape equipped (%.0f by %d).",
|
player.print(String.format("Cylinder brush shape equipped (%.0f by %d).",
|
||||||
radius, height));
|
radius, height));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "clipboard", "copy" },
|
aliases = { "clipboard", "copy" },
|
||||||
usage = "",
|
usage = "",
|
||||||
flags = "a",
|
flags = "a",
|
||||||
desc = "Choose the clipboard brush",
|
desc = "Choose the clipboard brush",
|
||||||
help =
|
help =
|
||||||
"Chooses the clipboard brush.\n" +
|
"Chooses the clipboard brush.\n" +
|
||||||
"The -a flag makes it not paste air.",
|
"The -a flag makes it not paste air.",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.clipboard")
|
@CommandPermissions("worldedit.brush.clipboard")
|
||||||
public void clipboardBrush(CommandContext args, LocalSession session,
|
public void clipboardBrush(CommandContext args, LocalSession session,
|
||||||
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
CuboidClipboard clipboard = session.getClipboard();
|
CuboidClipboard clipboard = session.getClipboard();
|
||||||
|
|
||||||
if (clipboard == null) {
|
if (clipboard == null) {
|
||||||
player.printError("Copy something first.");
|
player.printError("Copy something first.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector size = clipboard.getSize();
|
Vector size = clipboard.getSize();
|
||||||
|
|
||||||
we.checkMaxBrushRadius(size.getBlockX());
|
we.checkMaxBrushRadius(size.getBlockX());
|
||||||
we.checkMaxBrushRadius(size.getBlockY());
|
we.checkMaxBrushRadius(size.getBlockY());
|
||||||
we.checkMaxBrushRadius(size.getBlockZ());
|
we.checkMaxBrushRadius(size.getBlockZ());
|
||||||
|
|
||||||
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||||
tool.setBrush(new ClipboardBrush(clipboard, args.hasFlag('a')), "worldedit.brush.clipboard");
|
tool.setBrush(new ClipboardBrush(clipboard, args.hasFlag('a')), "worldedit.brush.clipboard");
|
||||||
|
|
||||||
player.print("Clipboard brush shape equipped.");
|
player.print("Clipboard brush shape equipped.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "smooth" },
|
aliases = { "smooth" },
|
||||||
usage = "[size] [iterations]",
|
usage = "[size] [iterations]",
|
||||||
flags = "n",
|
flags = "n",
|
||||||
desc = "Choose the terrain softener brush",
|
desc = "Choose the terrain softener brush",
|
||||||
help =
|
help =
|
||||||
"Chooses the terrain softener brush.\n" +
|
"Chooses the terrain softener brush.\n" +
|
||||||
"The -n flag makes it only consider naturally occuring blocks.",
|
"The -n flag makes it only consider naturally occuring blocks.",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 2
|
max = 2
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.smooth")
|
@CommandPermissions("worldedit.brush.smooth")
|
||||||
public void smoothBrush(CommandContext args, LocalSession session,
|
public void smoothBrush(CommandContext args, LocalSession session,
|
||||||
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
double radius = args.argsLength() > 0 ? args.getDouble(0) : 2;
|
double radius = args.argsLength() > 0 ? args.getDouble(0) : 2;
|
||||||
we.checkMaxBrushRadius(radius);
|
we.checkMaxBrushRadius(radius);
|
||||||
|
|
||||||
int iterations = args.argsLength() > 1 ? args.getInteger(1) : 4;
|
int iterations = args.argsLength() > 1 ? args.getInteger(1) : 4;
|
||||||
|
|
||||||
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||||
tool.setSize(radius);
|
tool.setSize(radius);
|
||||||
tool.setBrush(new SmoothBrush(iterations, args.hasFlag('n')), "worldedit.brush.smooth");
|
tool.setBrush(new SmoothBrush(iterations, args.hasFlag('n')), "worldedit.brush.smooth");
|
||||||
|
|
||||||
player.print(String.format("Smooth brush equipped (%.0f x %dx, using " + (args.hasFlag('n') ? "natural blocks only" : "any block") + ").",
|
player.print(String.format("Smooth brush equipped (%.0f x %dx, using " + (args.hasFlag('n') ? "natural blocks only" : "any block") + ").",
|
||||||
radius, iterations));
|
radius, iterations));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "ex", "extinguish" },
|
aliases = { "ex", "extinguish" },
|
||||||
usage = "[radius]",
|
usage = "[radius]",
|
||||||
desc = "Shortcut fire extinguisher brush",
|
desc = "Shortcut fire extinguisher brush",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.ex")
|
@CommandPermissions("worldedit.brush.ex")
|
||||||
public void extinguishBrush(CommandContext args, LocalSession session,
|
public void extinguishBrush(CommandContext args, LocalSession session,
|
||||||
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
double radius = args.argsLength() > 1 ? args.getDouble(1) : 5;
|
double radius = args.argsLength() > 1 ? args.getDouble(1) : 5;
|
||||||
we.checkMaxBrushRadius(radius);
|
we.checkMaxBrushRadius(radius);
|
||||||
|
|
||||||
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||||
Pattern fill = new SingleBlockPattern(new BaseBlock(0));
|
Pattern fill = new SingleBlockPattern(new BaseBlock(0));
|
||||||
tool.setFill(fill);
|
tool.setFill(fill);
|
||||||
tool.setSize(radius);
|
tool.setSize(radius);
|
||||||
tool.setMask(new BlockMask(new BaseBlock(BlockID.FIRE)));
|
tool.setMask(new BlockMask(new BaseBlock(BlockID.FIRE)));
|
||||||
tool.setBrush(new SphereBrush(), "worldedit.brush.ex");
|
tool.setBrush(new SphereBrush(), "worldedit.brush.ex");
|
||||||
|
|
||||||
player.print(String.format("Extinguisher equipped (%.0f).",
|
player.print(String.format("Extinguisher equipped (%.0f).",
|
||||||
radius));
|
radius));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "gravity", "grav" },
|
aliases = { "gravity", "grav" },
|
||||||
usage = "[radius]",
|
usage = "[radius]",
|
||||||
flags = "h",
|
flags = "h",
|
||||||
desc = "Gravity brush",
|
desc = "Gravity brush",
|
||||||
help =
|
help =
|
||||||
"This brush simulates the affect of gravity.\n" +
|
"This brush simulates the affect of gravity.\n" +
|
||||||
"The -h flag makes it affect blocks starting at the world's max y, " +
|
"The -h flag makes it affect blocks starting at the world's max y, " +
|
||||||
"instead of the clicked block's y + radius.",
|
"instead of the clicked block's y + radius.",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.gravity")
|
@CommandPermissions("worldedit.brush.gravity")
|
||||||
public void gravityBrush(CommandContext args, LocalSession session,
|
public void gravityBrush(CommandContext args, LocalSession session,
|
||||||
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
double radius = args.argsLength() > 0 ? args.getDouble(0) : 5;
|
double radius = args.argsLength() > 0 ? args.getDouble(0) : 5;
|
||||||
we.checkMaxBrushRadius(radius);
|
we.checkMaxBrushRadius(radius);
|
||||||
|
|
||||||
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||||
tool.setSize(radius);
|
tool.setSize(radius);
|
||||||
tool.setBrush(new GravityBrush(args.hasFlag('h')), "worldedit.brush.gravity");
|
tool.setBrush(new GravityBrush(args.hasFlag('h')), "worldedit.brush.gravity");
|
||||||
|
|
||||||
player.print(String.format("Gravity brush equipped (%.0f).",
|
player.print(String.format("Gravity brush equipped (%.0f).",
|
||||||
radius));
|
radius));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "butcher", "kill" },
|
aliases = { "butcher", "kill" },
|
||||||
usage = "[radius] [command flags]",
|
usage = "[radius] [command flags]",
|
||||||
desc = "Butcher brush",
|
desc = "Butcher brush",
|
||||||
help = "Kills nearby mobs within the specified radius.\n" +
|
help = "Kills nearby mobs within the specified radius.\n" +
|
||||||
"Any number of 'flags' that the //butcher command uses\n" +
|
"Any number of 'flags' that the //butcher command uses\n" +
|
||||||
"may be specified as an argument",
|
"may be specified as an argument",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 2
|
max = 2
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.butcher")
|
@CommandPermissions("worldedit.brush.butcher")
|
||||||
public void butcherBrush(CommandContext args, LocalSession session,
|
public void butcherBrush(CommandContext args, LocalSession session,
|
||||||
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
LocalPlayer player, EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
LocalConfiguration config = we.getConfiguration();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
|
|
||||||
double radius = args.argsLength() > 0 ? args.getDouble(0) : 5;
|
double radius = args.argsLength() > 0 ? args.getDouble(0) : 5;
|
||||||
double maxRadius = config.maxBrushRadius;
|
double maxRadius = config.maxBrushRadius;
|
||||||
// hmmmm not horribly worried about this because -1 is still rather efficient,
|
// hmmmm not horribly worried about this because -1 is still rather efficient,
|
||||||
// the problem arises when butcherMaxRadius is some really high number but not infinite
|
// the problem arises when butcherMaxRadius is some really high number but not infinite
|
||||||
// - original idea taken from https://github.com/sk89q/worldedit/pull/198#issuecomment-6463108
|
// - original idea taken from https://github.com/sk89q/worldedit/pull/198#issuecomment-6463108
|
||||||
if (player.hasPermission("worldedit.butcher")) {
|
if (player.hasPermission("worldedit.butcher")) {
|
||||||
maxRadius = Math.max(config.maxBrushRadius, config.butcherMaxRadius);
|
maxRadius = Math.max(config.maxBrushRadius, config.butcherMaxRadius);
|
||||||
}
|
}
|
||||||
if (radius > maxRadius) {
|
if (radius > maxRadius) {
|
||||||
player.printError("Maximum allowed brush radius: " + maxRadius);
|
player.printError("Maximum allowed brush radius: " + maxRadius);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FlagContainer flags = new FlagContainer(player);
|
FlagContainer flags = new FlagContainer(player);
|
||||||
if (args.argsLength() == 2) {
|
if (args.argsLength() == 2) {
|
||||||
String flagString = args.getString(1);
|
String flagString = args.getString(1);
|
||||||
// straight from the command, using contains instead of hasflag
|
// straight from the command, using contains instead of hasflag
|
||||||
flags.or(KillFlags.FRIENDLY , flagString.contains("f")); // No permission check here. Flags will instead be filtered by the subsequent calls.
|
flags.or(KillFlags.FRIENDLY , flagString.contains("f")); // No permission check here. Flags will instead be filtered by the subsequent calls.
|
||||||
flags.or(KillFlags.PETS , flagString.contains("p"), "worldedit.butcher.pets");
|
flags.or(KillFlags.PETS , flagString.contains("p"), "worldedit.butcher.pets");
|
||||||
flags.or(KillFlags.NPCS , flagString.contains("n"), "worldedit.butcher.npcs");
|
flags.or(KillFlags.NPCS , flagString.contains("n"), "worldedit.butcher.npcs");
|
||||||
flags.or(KillFlags.GOLEMS , flagString.contains("g"), "worldedit.butcher.golems");
|
flags.or(KillFlags.GOLEMS , flagString.contains("g"), "worldedit.butcher.golems");
|
||||||
flags.or(KillFlags.ANIMALS , flagString.contains("a"), "worldedit.butcher.animals");
|
flags.or(KillFlags.ANIMALS , flagString.contains("a"), "worldedit.butcher.animals");
|
||||||
flags.or(KillFlags.AMBIENT , flagString.contains("b"), "worldedit.butcher.ambient");
|
flags.or(KillFlags.AMBIENT , flagString.contains("b"), "worldedit.butcher.ambient");
|
||||||
flags.or(KillFlags.WITH_LIGHTNING, flagString.contains("l"), "worldedit.butcher.lightning");
|
flags.or(KillFlags.WITH_LIGHTNING, flagString.contains("l"), "worldedit.butcher.lightning");
|
||||||
}
|
}
|
||||||
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
BrushTool tool = session.getBrushTool(player.getItemInHand());
|
||||||
tool.setSize(radius);
|
tool.setSize(radius);
|
||||||
tool.setBrush(new ButcherBrush(flags.flags), "worldedit.brush.butcher");
|
tool.setBrush(new ButcherBrush(flags.flags), "worldedit.brush.butcher");
|
||||||
|
|
||||||
player.print(String.format("Butcher brush equipped (%.0f).",
|
player.print(String.format("Butcher brush equipped (%.0f).",
|
||||||
radius));
|
radius));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,179 +1,179 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.minecraft.util.commands.Logging;
|
import com.sk89q.minecraft.util.commands.Logging;
|
||||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.*;
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.*;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.data.LegacyChunkStore;
|
import com.sk89q.worldedit.world.storage.LegacyChunkStore;
|
||||||
import com.sk89q.worldedit.data.McRegionChunkStore;
|
import com.sk89q.worldedit.world.storage.McRegionChunkStore;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Chunk tools.
|
* Chunk tools.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class ChunkCommands {
|
public class ChunkCommands {
|
||||||
private final WorldEdit we;
|
private final WorldEdit we;
|
||||||
|
|
||||||
public ChunkCommands(WorldEdit we) {
|
public ChunkCommands(WorldEdit we) {
|
||||||
this.we = we;
|
this.we = we;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "chunkinfo" },
|
aliases = { "chunkinfo" },
|
||||||
usage = "",
|
usage = "",
|
||||||
desc = "Get information about the chunk that you are inside",
|
desc = "Get information about the chunk that you are inside",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.chunkinfo")
|
@CommandPermissions("worldedit.chunkinfo")
|
||||||
public void chunkInfo(CommandContext args, LocalSession session, LocalPlayer player,
|
public void chunkInfo(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
Vector pos = player.getBlockIn();
|
Vector pos = player.getBlockIn();
|
||||||
int chunkX = (int) Math.floor(pos.getBlockX() / 16.0);
|
int chunkX = (int) Math.floor(pos.getBlockX() / 16.0);
|
||||||
int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);
|
int chunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);
|
||||||
|
|
||||||
String folder1 = Integer.toString(WorldEdit.divisorMod(chunkX, 64), 36);
|
String folder1 = Integer.toString(WorldEdit.divisorMod(chunkX, 64), 36);
|
||||||
String folder2 = Integer.toString(WorldEdit.divisorMod(chunkZ, 64), 36);
|
String folder2 = Integer.toString(WorldEdit.divisorMod(chunkZ, 64), 36);
|
||||||
String filename = "c." + Integer.toString(chunkX, 36)
|
String filename = "c." + Integer.toString(chunkX, 36)
|
||||||
+ "." + Integer.toString(chunkZ, 36) + ".dat";
|
+ "." + Integer.toString(chunkZ, 36) + ".dat";
|
||||||
|
|
||||||
player.print("Chunk: " + chunkX + ", " + chunkZ);
|
player.print("Chunk: " + chunkX + ", " + chunkZ);
|
||||||
player.print("Old format: " + folder1 + "/" + folder2 + "/" + filename);
|
player.print("Old format: " + folder1 + "/" + folder2 + "/" + filename);
|
||||||
player.print("McRegion: region/" + McRegionChunkStore.getFilename(
|
player.print("McRegion: region/" + McRegionChunkStore.getFilename(
|
||||||
new Vector2D(chunkX, chunkZ)));
|
new Vector2D(chunkX, chunkZ)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "listchunks" },
|
aliases = { "listchunks" },
|
||||||
usage = "",
|
usage = "",
|
||||||
desc = "List chunks that your selection includes",
|
desc = "List chunks that your selection includes",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.listchunks")
|
@CommandPermissions("worldedit.listchunks")
|
||||||
public void listChunks(CommandContext args, LocalSession session, LocalPlayer player,
|
public void listChunks(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
Set<Vector2D> chunks = session.getSelection(player.getWorld()).getChunks();
|
Set<Vector2D> chunks = session.getSelection(player.getWorld()).getChunks();
|
||||||
|
|
||||||
for (Vector2D chunk : chunks) {
|
for (Vector2D chunk : chunks) {
|
||||||
player.print(LegacyChunkStore.getFilename(chunk));
|
player.print(LegacyChunkStore.getFilename(chunk));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "delchunks" },
|
aliases = { "delchunks" },
|
||||||
usage = "",
|
usage = "",
|
||||||
desc = "Delete chunks that your selection includes",
|
desc = "Delete chunks that your selection includes",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.delchunks")
|
@CommandPermissions("worldedit.delchunks")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void deleteChunks(CommandContext args, LocalSession session, LocalPlayer player,
|
public void deleteChunks(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
player.print("Note that this command does not yet support the mcregion format.");
|
player.print("Note that this command does not yet support the mcregion format.");
|
||||||
LocalConfiguration config = we.getConfiguration();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
|
|
||||||
Set<Vector2D> chunks = session.getSelection(player.getWorld()).getChunks();
|
Set<Vector2D> chunks = session.getSelection(player.getWorld()).getChunks();
|
||||||
FileOutputStream out = null;
|
FileOutputStream out = null;
|
||||||
|
|
||||||
if (config.shellSaveType == null) {
|
if (config.shellSaveType == null) {
|
||||||
player.printError("Shell script type must be configured: 'bat' or 'bash' expected.");
|
player.printError("Shell script type must be configured: 'bat' or 'bash' expected.");
|
||||||
} else if (config.shellSaveType.equalsIgnoreCase("bat")) {
|
} else if (config.shellSaveType.equalsIgnoreCase("bat")) {
|
||||||
try {
|
try {
|
||||||
out = new FileOutputStream("worldedit-delchunks.bat");
|
out = new FileOutputStream("worldedit-delchunks.bat");
|
||||||
OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
|
OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
|
||||||
writer.write("@ECHO off\r\n");
|
writer.write("@ECHO off\r\n");
|
||||||
writer.write("ECHO This batch file was generated by WorldEdit.\r\n");
|
writer.write("ECHO This batch file was generated by WorldEdit.\r\n");
|
||||||
writer.write("ECHO It contains a list of chunks that were in the selected region\r\n");
|
writer.write("ECHO It contains a list of chunks that were in the selected region\r\n");
|
||||||
writer.write("ECHO at the time that the /delchunks command was used. Run this file\r\n");
|
writer.write("ECHO at the time that the /delchunks command was used. Run this file\r\n");
|
||||||
writer.write("ECHO in order to delete the chunk files listed in this file.\r\n");
|
writer.write("ECHO in order to delete the chunk files listed in this file.\r\n");
|
||||||
writer.write("ECHO.\r\n");
|
writer.write("ECHO.\r\n");
|
||||||
writer.write("PAUSE\r\n");
|
writer.write("PAUSE\r\n");
|
||||||
|
|
||||||
for (Vector2D chunk : chunks) {
|
for (Vector2D chunk : chunks) {
|
||||||
String filename = LegacyChunkStore.getFilename(chunk);
|
String filename = LegacyChunkStore.getFilename(chunk);
|
||||||
writer.write("ECHO " + filename + "\r\n");
|
writer.write("ECHO " + filename + "\r\n");
|
||||||
writer.write("DEL \"world/" + filename + "\"\r\n");
|
writer.write("DEL \"world/" + filename + "\"\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.write("ECHO Complete.\r\n");
|
writer.write("ECHO Complete.\r\n");
|
||||||
writer.write("PAUSE\r\n");
|
writer.write("PAUSE\r\n");
|
||||||
writer.close();
|
writer.close();
|
||||||
player.print("worldedit-delchunks.bat written. Run it when no one is near the region.");
|
player.print("worldedit-delchunks.bat written. Run it when no one is near the region.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
player.printError("Error occurred: " + e.getMessage());
|
player.printError("Error occurred: " + e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
if (out != null) {
|
if (out != null) {
|
||||||
try {
|
try {
|
||||||
out.close();
|
out.close();
|
||||||
} catch (IOException ie) { }
|
} catch (IOException ie) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (config.shellSaveType.equalsIgnoreCase("bash")) {
|
} else if (config.shellSaveType.equalsIgnoreCase("bash")) {
|
||||||
try {
|
try {
|
||||||
out = new FileOutputStream("worldedit-delchunks.sh");
|
out = new FileOutputStream("worldedit-delchunks.sh");
|
||||||
OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
|
OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8");
|
||||||
writer.write("#!/bin/bash\n");
|
writer.write("#!/bin/bash\n");
|
||||||
writer.write("echo This shell file was generated by WorldEdit.\n");
|
writer.write("echo This shell file was generated by WorldEdit.\n");
|
||||||
writer.write("echo It contains a list of chunks that were in the selected region\n");
|
writer.write("echo It contains a list of chunks that were in the selected region\n");
|
||||||
writer.write("echo at the time that the /delchunks command was used. Run this file\n");
|
writer.write("echo at the time that the /delchunks command was used. Run this file\n");
|
||||||
writer.write("echo in order to delete the chunk files listed in this file.\n");
|
writer.write("echo in order to delete the chunk files listed in this file.\n");
|
||||||
writer.write("echo\n");
|
writer.write("echo\n");
|
||||||
writer.write("read -p \"Press any key to continue...\"\n");
|
writer.write("read -p \"Press any key to continue...\"\n");
|
||||||
|
|
||||||
for (Vector2D chunk : chunks) {
|
for (Vector2D chunk : chunks) {
|
||||||
String filename = LegacyChunkStore.getFilename(chunk);
|
String filename = LegacyChunkStore.getFilename(chunk);
|
||||||
writer.write("echo " + filename + "\n");
|
writer.write("echo " + filename + "\n");
|
||||||
writer.write("rm \"world/" + filename + "\"\n");
|
writer.write("rm \"world/" + filename + "\"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.write("echo Complete.\n");
|
writer.write("echo Complete.\n");
|
||||||
writer.write("read -p \"Press any key to continue...\"\n");
|
writer.write("read -p \"Press any key to continue...\"\n");
|
||||||
writer.close();
|
writer.close();
|
||||||
player.print("worldedit-delchunks.sh written. Run it when no one is near the region.");
|
player.print("worldedit-delchunks.sh written. Run it when no one is near the region.");
|
||||||
player.print("You will have to chmod it to be executable.");
|
player.print("You will have to chmod it to be executable.");
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
player.printError("Error occurred: " + e.getMessage());
|
player.printError("Error occurred: " + e.getMessage());
|
||||||
} finally {
|
} finally {
|
||||||
if (out != null) {
|
if (out != null) {
|
||||||
try {
|
try {
|
||||||
out.close();
|
out.close();
|
||||||
} catch (IOException ie) {
|
} catch (IOException ie) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.printError("Shell script type must be configured: 'bat' or 'bash' expected.");
|
player.printError("Shell script type must be configured: 'bat' or 'bash' expected.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,286 +1,286 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.minecraft.util.commands.Logging;
|
import com.sk89q.minecraft.util.commands.Logging;
|
||||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.*;
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.*;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.NestedCommand;
|
import com.sk89q.minecraft.util.commands.NestedCommand;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegionSelector;
|
import com.sk89q.worldedit.regions.CuboidRegionSelector;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clipboard commands.
|
* Clipboard commands.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class ClipboardCommands {
|
public class ClipboardCommands {
|
||||||
private final WorldEdit we;
|
private final WorldEdit we;
|
||||||
|
|
||||||
public ClipboardCommands(WorldEdit we) {
|
public ClipboardCommands(WorldEdit we) {
|
||||||
this.we = we;
|
this.we = we;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/copy" },
|
aliases = { "/copy" },
|
||||||
flags = "e",
|
flags = "e",
|
||||||
desc = "Copy the selection to the clipboard",
|
desc = "Copy the selection to the clipboard",
|
||||||
help = "Copy the selection to the clipboard\n" +
|
help = "Copy the selection to the clipboard\n" +
|
||||||
"Flags:\n" +
|
"Flags:\n" +
|
||||||
" -e controls whether entities are copied\n" +
|
" -e controls whether entities are copied\n" +
|
||||||
"WARNING: Pasting entities cannot yet be undone!",
|
"WARNING: Pasting entities cannot yet be undone!",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.copy")
|
@CommandPermissions("worldedit.clipboard.copy")
|
||||||
public void copy(CommandContext args, LocalSession session, LocalPlayer player,
|
public void copy(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
Region region = session.getSelection(player.getWorld());
|
Region region = session.getSelection(player.getWorld());
|
||||||
Vector min = region.getMinimumPoint();
|
Vector min = region.getMinimumPoint();
|
||||||
Vector max = region.getMaximumPoint();
|
Vector max = region.getMaximumPoint();
|
||||||
Vector pos = session.getPlacementPosition(player);
|
Vector pos = session.getPlacementPosition(player);
|
||||||
|
|
||||||
CuboidClipboard clipboard = new CuboidClipboard(
|
CuboidClipboard clipboard = new CuboidClipboard(
|
||||||
max.subtract(min).add(Vector.ONE),
|
max.subtract(min).add(Vector.ONE),
|
||||||
min, min.subtract(pos));
|
min, min.subtract(pos));
|
||||||
|
|
||||||
if (region instanceof CuboidRegion) {
|
if (region instanceof CuboidRegion) {
|
||||||
clipboard.copy(editSession);
|
clipboard.copy(editSession);
|
||||||
} else {
|
} else {
|
||||||
clipboard.copy(editSession, region);
|
clipboard.copy(editSession, region);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.hasFlag('e')) {
|
if (args.hasFlag('e')) {
|
||||||
for (LocalEntity entity : player.getWorld().getEntities(region)) {
|
for (LocalEntity entity : player.getWorld().getEntities(region)) {
|
||||||
clipboard.storeEntity(entity);
|
clipboard.storeEntity(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session.setClipboard(clipboard);
|
session.setClipboard(clipboard);
|
||||||
|
|
||||||
player.print("Block(s) copied.");
|
player.print("Block(s) copied.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/cut" },
|
aliases = { "/cut" },
|
||||||
usage = "[leave-id]",
|
usage = "[leave-id]",
|
||||||
desc = "Cut the selection to the clipboard",
|
desc = "Cut the selection to the clipboard",
|
||||||
help = "Copy the selection to the clipboard\n" +
|
help = "Copy the selection to the clipboard\n" +
|
||||||
"Flags:\n" +
|
"Flags:\n" +
|
||||||
" -e controls whether entities are copied\n" +
|
" -e controls whether entities are copied\n" +
|
||||||
"WARNING: Cutting and pasting entities cannot yet be undone!",
|
"WARNING: Cutting and pasting entities cannot yet be undone!",
|
||||||
flags = "e",
|
flags = "e",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.cut")
|
@CommandPermissions("worldedit.clipboard.cut")
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
public void cut(CommandContext args, LocalSession session, LocalPlayer player,
|
public void cut(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
BaseBlock block = new BaseBlock(BlockID.AIR);
|
BaseBlock block = new BaseBlock(BlockID.AIR);
|
||||||
LocalWorld world = player.getWorld();
|
LocalWorld world = player.getWorld();
|
||||||
|
|
||||||
if (args.argsLength() > 0) {
|
if (args.argsLength() > 0) {
|
||||||
block = we.getBlock(player, args.getString(0));
|
block = we.getBlock(player, args.getString(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
Region region = session.getSelection(world);
|
Region region = session.getSelection(world);
|
||||||
Vector min = region.getMinimumPoint();
|
Vector min = region.getMinimumPoint();
|
||||||
Vector max = region.getMaximumPoint();
|
Vector max = region.getMaximumPoint();
|
||||||
Vector pos = session.getPlacementPosition(player);
|
Vector pos = session.getPlacementPosition(player);
|
||||||
|
|
||||||
CuboidClipboard clipboard = new CuboidClipboard(
|
CuboidClipboard clipboard = new CuboidClipboard(
|
||||||
max.subtract(min).add(Vector.ONE),
|
max.subtract(min).add(Vector.ONE),
|
||||||
min, min.subtract(pos));
|
min, min.subtract(pos));
|
||||||
|
|
||||||
if (region instanceof CuboidRegion) {
|
if (region instanceof CuboidRegion) {
|
||||||
clipboard.copy(editSession);
|
clipboard.copy(editSession);
|
||||||
} else {
|
} else {
|
||||||
clipboard.copy(editSession, region);
|
clipboard.copy(editSession, region);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.hasFlag('e')) {
|
if (args.hasFlag('e')) {
|
||||||
LocalEntity[] entities = world.getEntities(region);
|
LocalEntity[] entities = world.getEntities(region);
|
||||||
for (LocalEntity entity : entities) {
|
for (LocalEntity entity : entities) {
|
||||||
clipboard.storeEntity(entity);
|
clipboard.storeEntity(entity);
|
||||||
}
|
}
|
||||||
world.killEntities(entities);
|
world.killEntities(entities);
|
||||||
}
|
}
|
||||||
session.setClipboard(clipboard);
|
session.setClipboard(clipboard);
|
||||||
|
|
||||||
editSession.setBlocks(region, block);
|
editSession.setBlocks(region, block);
|
||||||
player.print("Block(s) cut.");
|
player.print("Block(s) cut.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/paste" },
|
aliases = { "/paste" },
|
||||||
usage = "",
|
usage = "",
|
||||||
flags = "sao",
|
flags = "sao",
|
||||||
desc = "Paste the clipboard's contents",
|
desc = "Paste the clipboard's contents",
|
||||||
help =
|
help =
|
||||||
"Pastes the clipboard's contents.\n" +
|
"Pastes the clipboard's contents.\n" +
|
||||||
"Flags:\n" +
|
"Flags:\n" +
|
||||||
" -a skips air blocks\n" +
|
" -a skips air blocks\n" +
|
||||||
" -o pastes at the original position\n" +
|
" -o pastes at the original position\n" +
|
||||||
" -s selects the region after pasting",
|
" -s selects the region after pasting",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.paste")
|
@CommandPermissions("worldedit.clipboard.paste")
|
||||||
@Logging(PLACEMENT)
|
@Logging(PLACEMENT)
|
||||||
public void paste(CommandContext args, LocalSession session, LocalPlayer player,
|
public void paste(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
boolean atOrigin = args.hasFlag('o');
|
boolean atOrigin = args.hasFlag('o');
|
||||||
boolean pasteNoAir = args.hasFlag('a');
|
boolean pasteNoAir = args.hasFlag('a');
|
||||||
|
|
||||||
CuboidClipboard clipboard = session.getClipboard();
|
CuboidClipboard clipboard = session.getClipboard();
|
||||||
|
|
||||||
Vector pos = atOrigin ? session.getClipboard().getOrigin()
|
Vector pos = atOrigin ? session.getClipboard().getOrigin()
|
||||||
: session.getPlacementPosition(player);
|
: session.getPlacementPosition(player);
|
||||||
|
|
||||||
if (atOrigin) {
|
if (atOrigin) {
|
||||||
clipboard.place(editSession, pos, pasteNoAir);
|
clipboard.place(editSession, pos, pasteNoAir);
|
||||||
clipboard.pasteEntities(pos);
|
clipboard.pasteEntities(pos);
|
||||||
player.findFreePosition();
|
player.findFreePosition();
|
||||||
player.print("Pasted to copy origin. Undo with //undo");
|
player.print("Pasted to copy origin. Undo with //undo");
|
||||||
} else {
|
} else {
|
||||||
clipboard.paste(editSession, pos, pasteNoAir, true);
|
clipboard.paste(editSession, pos, pasteNoAir, true);
|
||||||
player.findFreePosition();
|
player.findFreePosition();
|
||||||
player.print("Pasted relative to you. Undo with //undo");
|
player.print("Pasted relative to you. Undo with //undo");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.hasFlag('s')) {
|
if (args.hasFlag('s')) {
|
||||||
LocalWorld world = player.getWorld();
|
LocalWorld world = player.getWorld();
|
||||||
Vector pos2 = pos.add(clipboard.getSize().subtract(1, 1, 1));
|
Vector pos2 = pos.add(clipboard.getSize().subtract(1, 1, 1));
|
||||||
if (!atOrigin) {
|
if (!atOrigin) {
|
||||||
pos2 = pos2.add(clipboard.getOffset());
|
pos2 = pos2.add(clipboard.getOffset());
|
||||||
pos = pos.add(clipboard.getOffset());
|
pos = pos.add(clipboard.getOffset());
|
||||||
}
|
}
|
||||||
session.setRegionSelector(world, new CuboidRegionSelector(world, pos, pos2));
|
session.setRegionSelector(world, new CuboidRegionSelector(world, pos, pos2));
|
||||||
session.getRegionSelector(world).learnChanges();
|
session.getRegionSelector(world).learnChanges();
|
||||||
session.getRegionSelector(world).explainRegionAdjust(player, session);
|
session.getRegionSelector(world).explainRegionAdjust(player, session);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/rotate" },
|
aliases = { "/rotate" },
|
||||||
usage = "<angle-in-degrees>",
|
usage = "<angle-in-degrees>",
|
||||||
desc = "Rotate the contents of the clipboard",
|
desc = "Rotate the contents of the clipboard",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.rotate")
|
@CommandPermissions("worldedit.clipboard.rotate")
|
||||||
public void rotate(CommandContext args, LocalSession session, LocalPlayer player,
|
public void rotate(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
int angle = args.getInteger(0);
|
int angle = args.getInteger(0);
|
||||||
|
|
||||||
if (angle % 90 == 0) {
|
if (angle % 90 == 0) {
|
||||||
CuboidClipboard clipboard = session.getClipboard();
|
CuboidClipboard clipboard = session.getClipboard();
|
||||||
clipboard.rotate2D(angle);
|
clipboard.rotate2D(angle);
|
||||||
player.print("Clipboard rotated by " + angle + " degrees.");
|
player.print("Clipboard rotated by " + angle + " degrees.");
|
||||||
} else {
|
} else {
|
||||||
player.printError("Angles must be divisible by 90 degrees.");
|
player.printError("Angles must be divisible by 90 degrees.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/flip" },
|
aliases = { "/flip" },
|
||||||
usage = "[dir]",
|
usage = "[dir]",
|
||||||
flags = "p",
|
flags = "p",
|
||||||
desc = "Flip the contents of the clipboard.",
|
desc = "Flip the contents of the clipboard.",
|
||||||
help =
|
help =
|
||||||
"Flips the contents of the clipboard.\n" +
|
"Flips the contents of the clipboard.\n" +
|
||||||
"The -p flag flips the selection around the player,\n" +
|
"The -p flag flips the selection around the player,\n" +
|
||||||
"instead of the selections center.",
|
"instead of the selections center.",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.flip")
|
@CommandPermissions("worldedit.clipboard.flip")
|
||||||
public void flip(CommandContext args, LocalSession session, LocalPlayer player,
|
public void flip(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
CuboidClipboard.FlipDirection dir = we.getFlipDirection(player,
|
CuboidClipboard.FlipDirection dir = we.getFlipDirection(player,
|
||||||
args.argsLength() > 0 ? args.getString(0).toLowerCase() : "me");
|
args.argsLength() > 0 ? args.getString(0).toLowerCase() : "me");
|
||||||
|
|
||||||
CuboidClipboard clipboard = session.getClipboard();
|
CuboidClipboard clipboard = session.getClipboard();
|
||||||
clipboard.flip(dir, args.hasFlag('p'));
|
clipboard.flip(dir, args.hasFlag('p'));
|
||||||
player.print("Clipboard flipped.");
|
player.print("Clipboard flipped.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/load" },
|
aliases = { "/load" },
|
||||||
usage = "<filename>",
|
usage = "<filename>",
|
||||||
desc = "Load a schematic into your clipboard",
|
desc = "Load a schematic into your clipboard",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@CommandPermissions("worldedit.clipboard.load")
|
@CommandPermissions("worldedit.clipboard.load")
|
||||||
public void load(CommandContext args, LocalSession session, LocalPlayer player,
|
public void load(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
player.printError("This command is no longer used. See //schematic load.");
|
player.printError("This command is no longer used. See //schematic load.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/save" },
|
aliases = { "/save" },
|
||||||
usage = "<filename>",
|
usage = "<filename>",
|
||||||
desc = "Save a schematic into your clipboard",
|
desc = "Save a schematic into your clipboard",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@CommandPermissions("worldedit.clipboard.save")
|
@CommandPermissions("worldedit.clipboard.save")
|
||||||
public void save(CommandContext args, LocalSession session, LocalPlayer player,
|
public void save(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
player.printError("This command is no longer used. See //schematic save.");
|
player.printError("This command is no longer used. See //schematic save.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/schematic", "/schem"},
|
aliases = { "/schematic", "/schem"},
|
||||||
desc = "Schematic-related commands"
|
desc = "Schematic-related commands"
|
||||||
)
|
)
|
||||||
@NestedCommand(SchematicCommands.class)
|
@NestedCommand(SchematicCommands.class)
|
||||||
public void schematic() {}
|
public void schematic() {}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "clearclipboard" },
|
aliases = { "clearclipboard" },
|
||||||
usage = "",
|
usage = "",
|
||||||
desc = "Clear your clipboard",
|
desc = "Clear your clipboard",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.clipboard.clear")
|
@CommandPermissions("worldedit.clipboard.clear")
|
||||||
public void clearClipboard(CommandContext args, LocalSession session, LocalPlayer player,
|
public void clearClipboard(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
session.setClipboard(null);
|
session.setClipboard(null);
|
||||||
player.print("Clipboard cleared.");
|
player.print("Clipboard cleared.");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,234 +1,234 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.minecraft.util.commands.Console;
|
import com.sk89q.minecraft.util.commands.Console;
|
||||||
import com.sk89q.minecraft.util.commands.NestedCommand;
|
import com.sk89q.minecraft.util.commands.NestedCommand;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.ItemType;
|
import com.sk89q.worldedit.blocks.ItemType;
|
||||||
import com.sk89q.worldedit.masks.Mask;
|
import com.sk89q.worldedit.masks.Mask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* General WorldEdit commands.
|
* General WorldEdit commands.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class GeneralCommands {
|
public class GeneralCommands {
|
||||||
private final WorldEdit we;
|
private final WorldEdit we;
|
||||||
|
|
||||||
public GeneralCommands(WorldEdit we) {
|
public GeneralCommands(WorldEdit we) {
|
||||||
this.we = we;
|
this.we = we;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/limit" },
|
aliases = { "/limit" },
|
||||||
usage = "<limit>",
|
usage = "<limit>",
|
||||||
desc = "Modify block change limit",
|
desc = "Modify block change limit",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.limit")
|
@CommandPermissions("worldedit.limit")
|
||||||
public void limit(CommandContext args, LocalSession session, LocalPlayer player,
|
public void limit(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
LocalConfiguration config = we.getConfiguration();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
|
|
||||||
int limit = Math.max(-1, args.getInteger(0));
|
int limit = Math.max(-1, args.getInteger(0));
|
||||||
if (!player.hasPermission("worldedit.limit.unrestricted")
|
if (!player.hasPermission("worldedit.limit.unrestricted")
|
||||||
&& config.maxChangeLimit > -1) {
|
&& config.maxChangeLimit > -1) {
|
||||||
if (limit > config.maxChangeLimit) {
|
if (limit > config.maxChangeLimit) {
|
||||||
player.printError("Your maximum allowable limit is "
|
player.printError("Your maximum allowable limit is "
|
||||||
+ config.maxChangeLimit + ".");
|
+ config.maxChangeLimit + ".");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
session.setBlockChangeLimit(limit);
|
session.setBlockChangeLimit(limit);
|
||||||
player.print("Block change limit set to " + limit + ".");
|
player.print("Block change limit set to " + limit + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/fast" },
|
aliases = { "/fast" },
|
||||||
usage = "[on|off]",
|
usage = "[on|off]",
|
||||||
desc = "Toggle fast mode",
|
desc = "Toggle fast mode",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.fast")
|
@CommandPermissions("worldedit.fast")
|
||||||
public void fast(CommandContext args, LocalSession session, LocalPlayer player,
|
public void fast(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
String newState = args.getString(0, null);
|
String newState = args.getString(0, null);
|
||||||
if (session.hasFastMode()) {
|
if (session.hasFastMode()) {
|
||||||
if ("on".equals(newState)) {
|
if ("on".equals(newState)) {
|
||||||
player.printError("Fast mode already enabled.");
|
player.printError("Fast mode already enabled.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.setFastMode(false);
|
session.setFastMode(false);
|
||||||
player.print("Fast mode disabled.");
|
player.print("Fast mode disabled.");
|
||||||
} else {
|
} else {
|
||||||
if ("off".equals(newState)) {
|
if ("off".equals(newState)) {
|
||||||
player.printError("Fast mode already disabled.");
|
player.printError("Fast mode already disabled.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.setFastMode(true);
|
session.setFastMode(true);
|
||||||
player.print("Fast mode enabled. Lighting in the affected chunks may be wrong and/or you may need to rejoin to see changes.");
|
player.print("Fast mode enabled. Lighting in the affected chunks may be wrong and/or you may need to rejoin to see changes.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/gmask", "gmask" },
|
aliases = { "/gmask", "gmask" },
|
||||||
usage = "[mask]",
|
usage = "[mask]",
|
||||||
desc = "Set the global mask",
|
desc = "Set the global mask",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = -1
|
max = -1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.global-mask")
|
@CommandPermissions("worldedit.global-mask")
|
||||||
public void gmask(CommandContext args, LocalSession session, LocalPlayer player,
|
public void gmask(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
if (args.argsLength() == 0) {
|
if (args.argsLength() == 0) {
|
||||||
session.setMask(null);
|
session.setMask(null);
|
||||||
player.print("Global mask disabled.");
|
player.print("Global mask disabled.");
|
||||||
} else {
|
} else {
|
||||||
Mask mask = we.getBlockMask(player, session, args.getJoinedStrings(0));
|
Mask mask = we.getBlockMask(player, session, args.getJoinedStrings(0));
|
||||||
session.setMask(mask);
|
session.setMask(mask);
|
||||||
player.print("Global mask set.");
|
player.print("Global mask set.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/toggleplace", "toggleplace" },
|
aliases = { "/toggleplace", "toggleplace" },
|
||||||
usage = "",
|
usage = "",
|
||||||
desc = "Switch between your position and pos1 for placement",
|
desc = "Switch between your position and pos1 for placement",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
public void togglePlace(CommandContext args, LocalSession session, LocalPlayer player,
|
public void togglePlace(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
if (session.togglePlacementPosition()) {
|
if (session.togglePlacementPosition()) {
|
||||||
player.print("Now placing at pos #1.");
|
player.print("Now placing at pos #1.");
|
||||||
} else {
|
} else {
|
||||||
player.print("Now placing at the block you stand in.");
|
player.print("Now placing at the block you stand in.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/searchitem", "/l", "/search", "searchitem" },
|
aliases = { "/searchitem", "/l", "/search", "searchitem" },
|
||||||
usage = "<query>",
|
usage = "<query>",
|
||||||
flags = "bi",
|
flags = "bi",
|
||||||
desc = "Search for an item",
|
desc = "Search for an item",
|
||||||
help =
|
help =
|
||||||
"Searches for an item.\n" +
|
"Searches for an item.\n" +
|
||||||
"Flags:\n" +
|
"Flags:\n" +
|
||||||
" -b only search for blocks\n" +
|
" -b only search for blocks\n" +
|
||||||
" -i only search for items",
|
" -i only search for items",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@Console
|
@Console
|
||||||
public void searchItem(CommandContext args, LocalSession session, LocalPlayer player,
|
public void searchItem(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
String query = args.getString(0).trim().toLowerCase();
|
String query = args.getString(0).trim().toLowerCase();
|
||||||
boolean blocksOnly = args.hasFlag('b');
|
boolean blocksOnly = args.hasFlag('b');
|
||||||
boolean itemsOnly = args.hasFlag('i');
|
boolean itemsOnly = args.hasFlag('i');
|
||||||
|
|
||||||
try {
|
try {
|
||||||
int id = Integer.parseInt(query);
|
int id = Integer.parseInt(query);
|
||||||
|
|
||||||
ItemType type = ItemType.fromID(id);
|
ItemType type = ItemType.fromID(id);
|
||||||
|
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
player.print("#" + type.getID() + " (" + type.getName() + ")");
|
player.print("#" + type.getID() + " (" + type.getName() + ")");
|
||||||
} else {
|
} else {
|
||||||
player.printError("No item found by ID " + id);
|
player.printError("No item found by ID " + id);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (query.length() <= 2) {
|
if (query.length() <= 2) {
|
||||||
player.printError("Enter a longer search string (len > 2).");
|
player.printError("Enter a longer search string (len > 2).");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!blocksOnly && !itemsOnly) {
|
if (!blocksOnly && !itemsOnly) {
|
||||||
player.print("Searching for: " + query);
|
player.print("Searching for: " + query);
|
||||||
} else if (blocksOnly && itemsOnly) {
|
} else if (blocksOnly && itemsOnly) {
|
||||||
player.printError("You cannot use both the 'b' and 'i' flags simultaneously.");
|
player.printError("You cannot use both the 'b' and 'i' flags simultaneously.");
|
||||||
return;
|
return;
|
||||||
} else if (blocksOnly) {
|
} else if (blocksOnly) {
|
||||||
player.print("Searching for blocks: " + query);
|
player.print("Searching for blocks: " + query);
|
||||||
} else {
|
} else {
|
||||||
player.print("Searching for items: " + query);
|
player.print("Searching for items: " + query);
|
||||||
}
|
}
|
||||||
|
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
|
||||||
for (ItemType type : ItemType.values()) {
|
for (ItemType type : ItemType.values()) {
|
||||||
if (found >= 15) {
|
if (found >= 15) {
|
||||||
player.print("Too many results!");
|
player.print("Too many results!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blocksOnly && type.getID() > 255) {
|
if (blocksOnly && type.getID() > 255) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemsOnly && type.getID() <= 255) {
|
if (itemsOnly && type.getID() <= 255) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String alias : type.getAliases()) {
|
for (String alias : type.getAliases()) {
|
||||||
if (alias.contains(query)) {
|
if (alias.contains(query)) {
|
||||||
player.print("#" + type.getID() + " (" + type.getName() + ")");
|
player.print("#" + type.getID() + " (" + type.getName() + ")");
|
||||||
++found;
|
++found;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found == 0) {
|
if (found == 0) {
|
||||||
player.printError("No items found.");
|
player.printError("No items found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "we", "worldedit" },
|
aliases = { "we", "worldedit" },
|
||||||
desc = "WorldEdit commands"
|
desc = "WorldEdit commands"
|
||||||
)
|
)
|
||||||
@NestedCommand(WorldEditCommands.class)
|
@NestedCommand(WorldEditCommands.class)
|
||||||
@Console
|
@Console
|
||||||
public void we(CommandContext args, LocalSession session, LocalPlayer player,
|
public void we(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,487 +1,486 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.ALL;
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.ALL;
|
||||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.PLACEMENT;
|
||||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.minecraft.util.commands.Logging;
|
import com.sk89q.minecraft.util.commands.Logging;
|
||||||
import com.sk89q.worldedit.BiomeType;
|
import com.sk89q.worldedit.BiomeType;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.Vector2D;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
import com.sk89q.worldedit.expression.ExpressionException;
|
import com.sk89q.worldedit.patterns.Pattern;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
|
||||||
|
/**
|
||||||
/**
|
* Generation commands.
|
||||||
* Generation commands.
|
*
|
||||||
*
|
* @author sk89q
|
||||||
* @author sk89q
|
*/
|
||||||
*/
|
public class GenerationCommands {
|
||||||
public class GenerationCommands {
|
private final WorldEdit we;
|
||||||
private final WorldEdit we;
|
|
||||||
|
public GenerationCommands(WorldEdit we) {
|
||||||
public GenerationCommands(WorldEdit we) {
|
this.we = we;
|
||||||
this.we = we;
|
}
|
||||||
}
|
|
||||||
|
@Command(
|
||||||
@Command(
|
aliases = { "/hcyl" },
|
||||||
aliases = { "/hcyl" },
|
usage = "<block> <radius>[,<radius>] [height]",
|
||||||
usage = "<block> <radius>[,<radius>] [height]",
|
desc = "Generates a hollow cylinder.",
|
||||||
desc = "Generates a hollow cylinder.",
|
help =
|
||||||
help =
|
"Generates a hollow cylinder.\n" +
|
||||||
"Generates a hollow cylinder.\n" +
|
"By specifying 2 radii, separated by a comma,\n" +
|
||||||
"By specifying 2 radii, separated by a comma,\n" +
|
"you can generate elliptical cylinders.\n" +
|
||||||
"you can generate elliptical cylinders.\n" +
|
"The 1st radius is north/south, the 2nd radius is east/west.",
|
||||||
"The 1st radius is north/south, the 2nd radius is east/west.",
|
min = 2,
|
||||||
min = 2,
|
max = 3
|
||||||
max = 3
|
)
|
||||||
)
|
@CommandPermissions("worldedit.generation.cylinder")
|
||||||
@CommandPermissions("worldedit.generation.cylinder")
|
@Logging(PLACEMENT)
|
||||||
@Logging(PLACEMENT)
|
public void hcyl(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
public void hcyl(CommandContext args, LocalSession session, LocalPlayer player,
|
EditSession editSession) throws WorldEditException {
|
||||||
EditSession editSession) throws WorldEditException {
|
|
||||||
|
Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||||
Pattern block = we.getBlockPattern(player, args.getString(0));
|
String[] radiuses = args.getString(1).split(",");
|
||||||
String[] radiuses = args.getString(1).split(",");
|
final double radiusX, radiusZ;
|
||||||
final double radiusX, radiusZ;
|
switch (radiuses.length) {
|
||||||
switch (radiuses.length) {
|
case 1:
|
||||||
case 1:
|
radiusX = radiusZ = Math.max(1, Double.parseDouble(radiuses[0]));
|
||||||
radiusX = radiusZ = Math.max(1, Double.parseDouble(radiuses[0]));
|
break;
|
||||||
break;
|
|
||||||
|
case 2:
|
||||||
case 2:
|
radiusX = Math.max(1, Double.parseDouble(radiuses[0]));
|
||||||
radiusX = Math.max(1, Double.parseDouble(radiuses[0]));
|
radiusZ = Math.max(1, Double.parseDouble(radiuses[1]));
|
||||||
radiusZ = Math.max(1, Double.parseDouble(radiuses[1]));
|
break;
|
||||||
break;
|
|
||||||
|
default:
|
||||||
default:
|
player.printError("You must either specify 1 or 2 radius values.");
|
||||||
player.printError("You must either specify 1 or 2 radius values.");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
int height = args.argsLength() > 2 ? args.getInteger(2) : 1;
|
||||||
int height = args.argsLength() > 2 ? args.getInteger(2) : 1;
|
|
||||||
|
we.checkMaxRadius(radiusX);
|
||||||
we.checkMaxRadius(radiusX);
|
we.checkMaxRadius(radiusZ);
|
||||||
we.checkMaxRadius(radiusZ);
|
we.checkMaxRadius(height);
|
||||||
we.checkMaxRadius(height);
|
|
||||||
|
Vector pos = session.getPlacementPosition(player);
|
||||||
Vector pos = session.getPlacementPosition(player);
|
int affected = editSession.makeCylinder(pos, block, radiusX, radiusZ, height, false);
|
||||||
int affected = editSession.makeCylinder(pos, block, radiusX, radiusZ, height, false);
|
player.print(affected + " block(s) have been created.");
|
||||||
player.print(affected + " block(s) have been created.");
|
}
|
||||||
}
|
|
||||||
|
@Command(
|
||||||
@Command(
|
aliases = { "/cyl" },
|
||||||
aliases = { "/cyl" },
|
usage = "<block> <radius>[,<radius>] [height]",
|
||||||
usage = "<block> <radius>[,<radius>] [height]",
|
desc = "Generates a cylinder.",
|
||||||
desc = "Generates a cylinder.",
|
help =
|
||||||
help =
|
"Generates a cylinder.\n" +
|
||||||
"Generates a cylinder.\n" +
|
"By specifying 2 radii, separated by a comma,\n" +
|
||||||
"By specifying 2 radii, separated by a comma,\n" +
|
"you can generate elliptical cylinders.\n" +
|
||||||
"you can generate elliptical cylinders.\n" +
|
"The 1st radius is north/south, the 2nd radius is east/west.",
|
||||||
"The 1st radius is north/south, the 2nd radius is east/west.",
|
min = 2,
|
||||||
min = 2,
|
max = 3
|
||||||
max = 3
|
)
|
||||||
)
|
@CommandPermissions("worldedit.generation.cylinder")
|
||||||
@CommandPermissions("worldedit.generation.cylinder")
|
@Logging(PLACEMENT)
|
||||||
@Logging(PLACEMENT)
|
public void cyl(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
public void cyl(CommandContext args, LocalSession session, LocalPlayer player,
|
EditSession editSession) throws WorldEditException {
|
||||||
EditSession editSession) throws WorldEditException {
|
|
||||||
|
Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||||
Pattern block = we.getBlockPattern(player, args.getString(0));
|
String[] radiuses = args.getString(1).split(",");
|
||||||
String[] radiuses = args.getString(1).split(",");
|
final double radiusX, radiusZ;
|
||||||
final double radiusX, radiusZ;
|
switch (radiuses.length) {
|
||||||
switch (radiuses.length) {
|
case 1:
|
||||||
case 1:
|
radiusX = radiusZ = Math.max(1, Double.parseDouble(radiuses[0]));
|
||||||
radiusX = radiusZ = Math.max(1, Double.parseDouble(radiuses[0]));
|
break;
|
||||||
break;
|
|
||||||
|
case 2:
|
||||||
case 2:
|
radiusX = Math.max(1, Double.parseDouble(radiuses[0]));
|
||||||
radiusX = Math.max(1, Double.parseDouble(radiuses[0]));
|
radiusZ = Math.max(1, Double.parseDouble(radiuses[1]));
|
||||||
radiusZ = Math.max(1, Double.parseDouble(radiuses[1]));
|
break;
|
||||||
break;
|
|
||||||
|
default:
|
||||||
default:
|
player.printError("You must either specify 1 or 2 radius values.");
|
||||||
player.printError("You must either specify 1 or 2 radius values.");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
int height = args.argsLength() > 2 ? args.getInteger(2) : 1;
|
||||||
int height = args.argsLength() > 2 ? args.getInteger(2) : 1;
|
|
||||||
|
we.checkMaxRadius(radiusX);
|
||||||
we.checkMaxRadius(radiusX);
|
we.checkMaxRadius(radiusZ);
|
||||||
we.checkMaxRadius(radiusZ);
|
we.checkMaxRadius(height);
|
||||||
we.checkMaxRadius(height);
|
|
||||||
|
Vector pos = session.getPlacementPosition(player);
|
||||||
Vector pos = session.getPlacementPosition(player);
|
int affected = editSession.makeCylinder(pos, block, radiusX, radiusZ, height, true);
|
||||||
int affected = editSession.makeCylinder(pos, block, radiusX, radiusZ, height, true);
|
player.print(affected + " block(s) have been created.");
|
||||||
player.print(affected + " block(s) have been created.");
|
}
|
||||||
}
|
|
||||||
|
@Command(
|
||||||
@Command(
|
aliases = { "/hsphere" },
|
||||||
aliases = { "/hsphere" },
|
usage = "<block> <radius>[,<radius>,<radius>] [raised?]",
|
||||||
usage = "<block> <radius>[,<radius>,<radius>] [raised?]",
|
desc = "Generates a hollow sphere.",
|
||||||
desc = "Generates a hollow sphere.",
|
help =
|
||||||
help =
|
"Generates a hollow sphere.\n" +
|
||||||
"Generates a hollow sphere.\n" +
|
"By specifying 3 radii, separated by commas,\n" +
|
||||||
"By specifying 3 radii, separated by commas,\n" +
|
"you can generate an ellipsoid. The order of the ellipsoid radii\n" +
|
||||||
"you can generate an ellipsoid. The order of the ellipsoid radii\n" +
|
"is north/south, up/down, east/west.",
|
||||||
"is north/south, up/down, east/west.",
|
min = 2,
|
||||||
min = 2,
|
max = 3
|
||||||
max = 3
|
)
|
||||||
)
|
@CommandPermissions("worldedit.generation.sphere")
|
||||||
@CommandPermissions("worldedit.generation.sphere")
|
@Logging(PLACEMENT)
|
||||||
@Logging(PLACEMENT)
|
public void hsphere(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
public void hsphere(CommandContext args, LocalSession session, LocalPlayer player,
|
EditSession editSession) throws WorldEditException {
|
||||||
EditSession editSession) throws WorldEditException {
|
|
||||||
|
final Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||||
final Pattern block = we.getBlockPattern(player, args.getString(0));
|
String[] radiuses = args.getString(1).split(",");
|
||||||
String[] radiuses = args.getString(1).split(",");
|
final double radiusX, radiusY, radiusZ;
|
||||||
final double radiusX, radiusY, radiusZ;
|
switch (radiuses.length) {
|
||||||
switch (radiuses.length) {
|
case 1:
|
||||||
case 1:
|
radiusX = radiusY = radiusZ = Math.max(1, Double.parseDouble(radiuses[0]));
|
||||||
radiusX = radiusY = radiusZ = Math.max(1, Double.parseDouble(radiuses[0]));
|
break;
|
||||||
break;
|
|
||||||
|
case 3:
|
||||||
case 3:
|
radiusX = Math.max(1, Double.parseDouble(radiuses[0]));
|
||||||
radiusX = Math.max(1, Double.parseDouble(radiuses[0]));
|
radiusY = Math.max(1, Double.parseDouble(radiuses[1]));
|
||||||
radiusY = Math.max(1, Double.parseDouble(radiuses[1]));
|
radiusZ = Math.max(1, Double.parseDouble(radiuses[2]));
|
||||||
radiusZ = Math.max(1, Double.parseDouble(radiuses[2]));
|
break;
|
||||||
break;
|
|
||||||
|
default:
|
||||||
default:
|
player.printError("You must either specify 1 or 3 radius values.");
|
||||||
player.printError("You must either specify 1 or 3 radius values.");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
we.checkMaxRadius(radiusX);
|
||||||
we.checkMaxRadius(radiusX);
|
we.checkMaxRadius(radiusY);
|
||||||
we.checkMaxRadius(radiusY);
|
we.checkMaxRadius(radiusZ);
|
||||||
we.checkMaxRadius(radiusZ);
|
|
||||||
|
final boolean raised;
|
||||||
final boolean raised;
|
if (args.argsLength() > 2) {
|
||||||
if (args.argsLength() > 2) {
|
raised = args.getString(2).equalsIgnoreCase("true") || args.getString(2).equalsIgnoreCase("yes");
|
||||||
raised = args.getString(2).equalsIgnoreCase("true") || args.getString(2).equalsIgnoreCase("yes");
|
} else {
|
||||||
} else {
|
raised = false;
|
||||||
raised = false;
|
}
|
||||||
}
|
|
||||||
|
Vector pos = session.getPlacementPosition(player);
|
||||||
Vector pos = session.getPlacementPosition(player);
|
if (raised) {
|
||||||
if (raised) {
|
pos = pos.add(0, radiusY, 0);
|
||||||
pos = pos.add(0, radiusY, 0);
|
}
|
||||||
}
|
|
||||||
|
int affected = editSession.makeSphere(pos, block, radiusX, radiusY, radiusZ, false);
|
||||||
int affected = editSession.makeSphere(pos, block, radiusX, radiusY, radiusZ, false);
|
player.findFreePosition();
|
||||||
player.findFreePosition();
|
player.print(affected + " block(s) have been created.");
|
||||||
player.print(affected + " block(s) have been created.");
|
}
|
||||||
}
|
|
||||||
|
@Command(
|
||||||
@Command(
|
aliases = { "/sphere" },
|
||||||
aliases = { "/sphere" },
|
usage = "<block> <radius>[,<radius>,<radius>] [raised?]",
|
||||||
usage = "<block> <radius>[,<radius>,<radius>] [raised?]",
|
desc = "Generates a filled sphere.",
|
||||||
desc = "Generates a filled sphere.",
|
help =
|
||||||
help =
|
"Generates a filled sphere.\n" +
|
||||||
"Generates a filled sphere.\n" +
|
"By specifying 3 radii, separated by commas,\n" +
|
||||||
"By specifying 3 radii, separated by commas,\n" +
|
"you can generate an ellipsoid. The order of the ellipsoid radii\n" +
|
||||||
"you can generate an ellipsoid. The order of the ellipsoid radii\n" +
|
"is north/south, up/down, east/west.",
|
||||||
"is north/south, up/down, east/west.",
|
min = 2,
|
||||||
min = 2,
|
max = 3
|
||||||
max = 3
|
)
|
||||||
)
|
@CommandPermissions("worldedit.generation.sphere")
|
||||||
@CommandPermissions("worldedit.generation.sphere")
|
@Logging(PLACEMENT)
|
||||||
@Logging(PLACEMENT)
|
public void sphere(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
public void sphere(CommandContext args, LocalSession session, LocalPlayer player,
|
EditSession editSession) throws WorldEditException {
|
||||||
EditSession editSession) throws WorldEditException {
|
|
||||||
|
Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||||
Pattern block = we.getBlockPattern(player, args.getString(0));
|
String[] radiuses = args.getString(1).split(",");
|
||||||
String[] radiuses = args.getString(1).split(",");
|
final double radiusX, radiusY, radiusZ;
|
||||||
final double radiusX, radiusY, radiusZ;
|
switch (radiuses.length) {
|
||||||
switch (radiuses.length) {
|
case 1:
|
||||||
case 1:
|
radiusX = radiusY = radiusZ = Math.max(1, Double.parseDouble(radiuses[0]));
|
||||||
radiusX = radiusY = radiusZ = Math.max(1, Double.parseDouble(radiuses[0]));
|
break;
|
||||||
break;
|
|
||||||
|
case 3:
|
||||||
case 3:
|
radiusX = Math.max(1, Double.parseDouble(radiuses[0]));
|
||||||
radiusX = Math.max(1, Double.parseDouble(radiuses[0]));
|
radiusY = Math.max(1, Double.parseDouble(radiuses[1]));
|
||||||
radiusY = Math.max(1, Double.parseDouble(radiuses[1]));
|
radiusZ = Math.max(1, Double.parseDouble(radiuses[2]));
|
||||||
radiusZ = Math.max(1, Double.parseDouble(radiuses[2]));
|
break;
|
||||||
break;
|
|
||||||
|
default:
|
||||||
default:
|
player.printError("You must either specify 1 or 3 radius values.");
|
||||||
player.printError("You must either specify 1 or 3 radius values.");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
we.checkMaxRadius(radiusX);
|
||||||
we.checkMaxRadius(radiusX);
|
we.checkMaxRadius(radiusY);
|
||||||
we.checkMaxRadius(radiusY);
|
we.checkMaxRadius(radiusZ);
|
||||||
we.checkMaxRadius(radiusZ);
|
|
||||||
|
final boolean raised;
|
||||||
final boolean raised;
|
if (args.argsLength() > 2) {
|
||||||
if (args.argsLength() > 2) {
|
raised = args.getString(2).equalsIgnoreCase("true") || args.getString(2).equalsIgnoreCase("yes");
|
||||||
raised = args.getString(2).equalsIgnoreCase("true") || args.getString(2).equalsIgnoreCase("yes");
|
} else {
|
||||||
} else {
|
raised = false;
|
||||||
raised = false;
|
}
|
||||||
}
|
|
||||||
|
Vector pos = session.getPlacementPosition(player);
|
||||||
Vector pos = session.getPlacementPosition(player);
|
if (raised) {
|
||||||
if (raised) {
|
pos = pos.add(0, radiusY, 0);
|
||||||
pos = pos.add(0, radiusY, 0);
|
}
|
||||||
}
|
|
||||||
|
int affected = editSession.makeSphere(pos, block, radiusX, radiusY, radiusZ, true);
|
||||||
int affected = editSession.makeSphere(pos, block, radiusX, radiusY, radiusZ, true);
|
player.findFreePosition();
|
||||||
player.findFreePosition();
|
player.print(affected + " block(s) have been created.");
|
||||||
player.print(affected + " block(s) have been created.");
|
}
|
||||||
}
|
|
||||||
|
@Command(
|
||||||
@Command(
|
aliases = { "forestgen" },
|
||||||
aliases = { "forestgen" },
|
usage = "[size] [type] [density]",
|
||||||
usage = "[size] [type] [density]",
|
desc = "Generate a forest",
|
||||||
desc = "Generate a forest",
|
min = 0,
|
||||||
min = 0,
|
max = 3
|
||||||
max = 3
|
)
|
||||||
)
|
@CommandPermissions("worldedit.generation.forest")
|
||||||
@CommandPermissions("worldedit.generation.forest")
|
@Logging(POSITION)
|
||||||
@Logging(POSITION)
|
@SuppressWarnings("deprecation")
|
||||||
@SuppressWarnings("deprecation")
|
public void forestGen(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
public void forestGen(CommandContext args, LocalSession session, LocalPlayer player,
|
EditSession editSession) throws WorldEditException {
|
||||||
EditSession editSession) throws WorldEditException {
|
|
||||||
|
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 10;
|
||||||
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 10;
|
TreeGenerator.TreeType type = args.argsLength() > 1 ?
|
||||||
TreeGenerator.TreeType type = args.argsLength() > 1 ?
|
TreeGenerator.lookup(args.getString(1))
|
||||||
TreeGenerator.lookup(args.getString(1))
|
: TreeGenerator.TreeType.TREE;
|
||||||
: TreeGenerator.TreeType.TREE;
|
double density = args.argsLength() > 2 ? args.getDouble(2) / 100 : 0.05;
|
||||||
double density = args.argsLength() > 2 ? args.getDouble(2) / 100 : 0.05;
|
|
||||||
|
if (type == null) {
|
||||||
if (type == null) {
|
player.printError("Tree type '" + args.getString(1) + "' is unknown.");
|
||||||
player.printError("Tree type '" + args.getString(1) + "' is unknown.");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
int affected = editSession.makeForest(session.getPlacementPosition(player),
|
||||||
int affected = editSession.makeForest(session.getPlacementPosition(player),
|
size, density, new TreeGenerator(type));
|
||||||
size, density, new TreeGenerator(type));
|
player.print(affected + " trees created.");
|
||||||
player.print(affected + " trees created.");
|
}
|
||||||
}
|
|
||||||
|
@Command(
|
||||||
@Command(
|
aliases = { "pumpkins" },
|
||||||
aliases = { "pumpkins" },
|
usage = "[size]",
|
||||||
usage = "[size]",
|
desc = "Generate pumpkin patches",
|
||||||
desc = "Generate pumpkin patches",
|
min = 0,
|
||||||
min = 0,
|
max = 1
|
||||||
max = 1
|
)
|
||||||
)
|
@CommandPermissions("worldedit.generation.pumpkins")
|
||||||
@CommandPermissions("worldedit.generation.pumpkins")
|
@Logging(POSITION)
|
||||||
@Logging(POSITION)
|
public void pumpkins(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
public void pumpkins(CommandContext args, LocalSession session, LocalPlayer player,
|
EditSession editSession) throws WorldEditException {
|
||||||
EditSession editSession) throws WorldEditException {
|
|
||||||
|
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 10;
|
||||||
int size = args.argsLength() > 0 ? Math.max(1, args.getInteger(0)) : 10;
|
|
||||||
|
int affected = editSession.makePumpkinPatches(session.getPlacementPosition(player), size);
|
||||||
int affected = editSession.makePumpkinPatches(session.getPlacementPosition(player), size);
|
player.print(affected + " pumpkin patches created.");
|
||||||
player.print(affected + " pumpkin patches created.");
|
}
|
||||||
}
|
|
||||||
|
@Command(
|
||||||
@Command(
|
aliases = { "/pyramid" },
|
||||||
aliases = { "/pyramid" },
|
usage = "<block> <size>",
|
||||||
usage = "<block> <size>",
|
desc = "Generate a filled pyramid",
|
||||||
desc = "Generate a filled pyramid",
|
min = 2,
|
||||||
min = 2,
|
max = 2
|
||||||
max = 2
|
)
|
||||||
)
|
@CommandPermissions("worldedit.generation.pyramid")
|
||||||
@CommandPermissions("worldedit.generation.pyramid")
|
@Logging(PLACEMENT)
|
||||||
@Logging(PLACEMENT)
|
public void pyramid(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
public void pyramid(CommandContext args, LocalSession session, LocalPlayer player,
|
EditSession editSession) throws WorldEditException {
|
||||||
EditSession editSession) throws WorldEditException {
|
|
||||||
|
Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||||
Pattern block = we.getBlockPattern(player, args.getString(0));
|
int size = Math.max(1, args.getInteger(1));
|
||||||
int size = Math.max(1, args.getInteger(1));
|
Vector pos = session.getPlacementPosition(player);
|
||||||
Vector pos = session.getPlacementPosition(player);
|
|
||||||
|
we.checkMaxRadius(size);
|
||||||
we.checkMaxRadius(size);
|
|
||||||
|
int affected = editSession.makePyramid(pos, block, size, true);
|
||||||
int affected = editSession.makePyramid(pos, block, size, true);
|
|
||||||
|
player.findFreePosition();
|
||||||
player.findFreePosition();
|
player.print(affected + " block(s) have been created.");
|
||||||
player.print(affected + " block(s) have been created.");
|
}
|
||||||
}
|
|
||||||
|
@Command(
|
||||||
@Command(
|
aliases = { "/hpyramid" },
|
||||||
aliases = { "/hpyramid" },
|
usage = "<block> <size>",
|
||||||
usage = "<block> <size>",
|
desc = "Generate a hollow pyramid",
|
||||||
desc = "Generate a hollow pyramid",
|
min = 2,
|
||||||
min = 2,
|
max = 2
|
||||||
max = 2
|
)
|
||||||
)
|
@CommandPermissions("worldedit.generation.pyramid")
|
||||||
@CommandPermissions("worldedit.generation.pyramid")
|
@Logging(PLACEMENT)
|
||||||
@Logging(PLACEMENT)
|
public void hpyramid(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
public void hpyramid(CommandContext args, LocalSession session, LocalPlayer player,
|
EditSession editSession) throws WorldEditException {
|
||||||
EditSession editSession) throws WorldEditException {
|
|
||||||
|
Pattern block = we.getBlockPattern(player, args.getString(0));
|
||||||
Pattern block = we.getBlockPattern(player, args.getString(0));
|
int size = Math.max(1, args.getInteger(1));
|
||||||
int size = Math.max(1, args.getInteger(1));
|
Vector pos = session.getPlacementPosition(player);
|
||||||
Vector pos = session.getPlacementPosition(player);
|
|
||||||
|
we.checkMaxRadius(size);
|
||||||
we.checkMaxRadius(size);
|
|
||||||
|
int affected = editSession.makePyramid(pos, block, size, false);
|
||||||
int affected = editSession.makePyramid(pos, block, size, false);
|
|
||||||
|
player.findFreePosition();
|
||||||
player.findFreePosition();
|
player.print(affected + " block(s) have been created.");
|
||||||
player.print(affected + " block(s) have been created.");
|
}
|
||||||
}
|
|
||||||
|
@Command(
|
||||||
@Command(
|
aliases = { "/generate", "/gen", "/g" },
|
||||||
aliases = { "/generate", "/gen", "/g" },
|
usage = "<block> <expression>",
|
||||||
usage = "<block> <expression>",
|
desc = "Generates a shape according to a formula.",
|
||||||
desc = "Generates a shape according to a formula.",
|
help =
|
||||||
help =
|
"Generates a shape according to a formula that is expected to\n" +
|
||||||
"Generates a shape according to a formula that is expected to\n" +
|
"return positive numbers (true) if the point is inside the shape\n" +
|
||||||
"return positive numbers (true) if the point is inside the shape\n" +
|
"Optionally set type/data to the desired block.\n" +
|
||||||
"Optionally set type/data to the desired block.\n" +
|
"Flags:\n" +
|
||||||
"Flags:\n" +
|
" -h to generate a hollow shape\n" +
|
||||||
" -h to generate a hollow shape\n" +
|
" -r to use raw minecraft coordinates\n" +
|
||||||
" -r to use raw minecraft coordinates\n" +
|
" -o is like -r, except offset from placement.\n" +
|
||||||
" -o is like -r, except offset from placement.\n" +
|
" -c is like -r, except offset selection center.\n" +
|
||||||
" -c is like -r, except offset selection center.\n" +
|
"If neither -r nor -o is given, the selection is mapped to -1..1\n" +
|
||||||
"If neither -r nor -o is given, the selection is mapped to -1..1\n" +
|
"See also tinyurl.com/wesyntax.",
|
||||||
"See also tinyurl.com/wesyntax.",
|
flags = "hroc",
|
||||||
flags = "hroc",
|
min = 2,
|
||||||
min = 2,
|
max = -1
|
||||||
max = -1
|
)
|
||||||
)
|
@CommandPermissions("worldedit.generation.shape")
|
||||||
@CommandPermissions("worldedit.generation.shape")
|
@Logging(ALL)
|
||||||
@Logging(ALL)
|
public void generate(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
public void generate(CommandContext args, LocalSession session, LocalPlayer player,
|
EditSession editSession) throws WorldEditException {
|
||||||
EditSession editSession) throws WorldEditException {
|
|
||||||
|
final Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
||||||
final Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
final Region region = session.getSelection(player.getWorld());
|
||||||
final Region region = session.getSelection(player.getWorld());
|
|
||||||
|
final boolean hollow = args.hasFlag('h');
|
||||||
final boolean hollow = args.hasFlag('h');
|
|
||||||
|
final String expression = args.getJoinedStrings(1);
|
||||||
final String expression = args.getJoinedStrings(1);
|
|
||||||
|
final Vector zero;
|
||||||
final Vector zero;
|
Vector unit;
|
||||||
Vector unit;
|
|
||||||
|
if (args.hasFlag('r')) {
|
||||||
if (args.hasFlag('r')) {
|
zero = Vector.ZERO;
|
||||||
zero = Vector.ZERO;
|
unit = Vector.ONE;
|
||||||
unit = Vector.ONE;
|
} else if (args.hasFlag('o')) {
|
||||||
} else if (args.hasFlag('o')) {
|
zero = session.getPlacementPosition(player);
|
||||||
zero = session.getPlacementPosition(player);
|
unit = Vector.ONE;
|
||||||
unit = Vector.ONE;
|
} else if (args.hasFlag('c')) {
|
||||||
} else if (args.hasFlag('c')) {
|
final Vector min = region.getMinimumPoint();
|
||||||
final Vector min = region.getMinimumPoint();
|
final Vector max = region.getMaximumPoint();
|
||||||
final Vector max = region.getMaximumPoint();
|
|
||||||
|
zero = max.add(min).multiply(0.5);
|
||||||
zero = max.add(min).multiply(0.5);
|
unit = Vector.ONE;
|
||||||
unit = Vector.ONE;
|
} else {
|
||||||
} else {
|
final Vector min = region.getMinimumPoint();
|
||||||
final Vector min = region.getMinimumPoint();
|
final Vector max = region.getMaximumPoint();
|
||||||
final Vector max = region.getMaximumPoint();
|
|
||||||
|
zero = max.add(min).multiply(0.5);
|
||||||
zero = max.add(min).multiply(0.5);
|
unit = max.subtract(zero);
|
||||||
unit = max.subtract(zero);
|
|
||||||
|
if (unit.getX() == 0) unit = unit.setX(1.0);
|
||||||
if (unit.getX() == 0) unit = unit.setX(1.0);
|
if (unit.getY() == 0) unit = unit.setY(1.0);
|
||||||
if (unit.getY() == 0) unit = unit.setY(1.0);
|
if (unit.getZ() == 0) unit = unit.setZ(1.0);
|
||||||
if (unit.getZ() == 0) unit = unit.setZ(1.0);
|
}
|
||||||
}
|
|
||||||
|
try {
|
||||||
try {
|
final int affected = editSession.makeShape(region, zero, unit, pattern, expression, hollow);
|
||||||
final int affected = editSession.makeShape(region, zero, unit, pattern, expression, hollow);
|
player.findFreePosition();
|
||||||
player.findFreePosition();
|
player.print(affected + " block(s) have been created.");
|
||||||
player.print(affected + " block(s) have been created.");
|
} catch (ExpressionException e) {
|
||||||
} catch (ExpressionException e) {
|
player.printError(e.getMessage());
|
||||||
player.printError(e.getMessage());
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@Command(
|
||||||
@Command(
|
aliases = { "/generatebiome", "/genbiome", "/gb" },
|
||||||
aliases = { "/generatebiome", "/genbiome", "/gb" },
|
usage = "<block> <expression>",
|
||||||
usage = "<block> <expression>",
|
desc = "Sets biome according to a formula.",
|
||||||
desc = "Sets biome according to a formula.",
|
help =
|
||||||
help =
|
"Generates a shape according to a formula that is expected to\n" +
|
||||||
"Generates a shape according to a formula that is expected to\n" +
|
"return positive numbers (true) if the point is inside the shape\n" +
|
||||||
"return positive numbers (true) if the point is inside the shape\n" +
|
"Optionally set type/data to the desired block.\n" +
|
||||||
"Optionally set type/data to the desired block.\n" +
|
"Flags:\n" +
|
||||||
"Flags:\n" +
|
" -h to generate a hollow shape\n" +
|
||||||
" -h to generate a hollow shape\n" +
|
" -r to use raw minecraft coordinates\n" +
|
||||||
" -r to use raw minecraft coordinates\n" +
|
" -o is like -r, except offset from placement.\n" +
|
||||||
" -o is like -r, except offset from placement.\n" +
|
" -c is like -r, except offset selection center.\n" +
|
||||||
" -c is like -r, except offset selection center.\n" +
|
"If neither -r nor -o is given, the selection is mapped to -1..1\n" +
|
||||||
"If neither -r nor -o is given, the selection is mapped to -1..1\n" +
|
"See also tinyurl.com/wesyntax.",
|
||||||
"See also tinyurl.com/wesyntax.",
|
flags = "hroc",
|
||||||
flags = "hroc",
|
min = 2,
|
||||||
min = 2,
|
max = -1
|
||||||
max = -1
|
)
|
||||||
)
|
@CommandPermissions({"worldedit.generation.shape", "worldedit.biome.set"})
|
||||||
@CommandPermissions({"worldedit.generation.shape", "worldedit.biome.set"})
|
@Logging(ALL)
|
||||||
@Logging(ALL)
|
public void generateBiome(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
public void generateBiome(CommandContext args, LocalSession session, LocalPlayer player,
|
EditSession editSession) throws WorldEditException {
|
||||||
EditSession editSession) throws WorldEditException {
|
|
||||||
|
final BiomeType target = we.getServer().getBiomes().get(args.getString(0));
|
||||||
final BiomeType target = we.getServer().getBiomes().get(args.getString(0));
|
final Region region = session.getSelection(player.getWorld());
|
||||||
final Region region = session.getSelection(player.getWorld());
|
|
||||||
|
final boolean hollow = args.hasFlag('h');
|
||||||
final boolean hollow = args.hasFlag('h');
|
|
||||||
|
final String expression = args.getJoinedStrings(1);
|
||||||
final String expression = args.getJoinedStrings(1);
|
|
||||||
|
final Vector zero;
|
||||||
final Vector zero;
|
Vector unit;
|
||||||
Vector unit;
|
|
||||||
|
if (args.hasFlag('r')) {
|
||||||
if (args.hasFlag('r')) {
|
zero = Vector.ZERO;
|
||||||
zero = Vector.ZERO;
|
unit = Vector.ONE;
|
||||||
unit = Vector.ONE;
|
} else if (args.hasFlag('o')) {
|
||||||
} else if (args.hasFlag('o')) {
|
zero = session.getPlacementPosition(player);
|
||||||
zero = session.getPlacementPosition(player);
|
unit = Vector.ONE;
|
||||||
unit = Vector.ONE;
|
} else if (args.hasFlag('c')) {
|
||||||
} else if (args.hasFlag('c')) {
|
final Vector min = region.getMinimumPoint();
|
||||||
final Vector min = region.getMinimumPoint();
|
final Vector max = region.getMaximumPoint();
|
||||||
final Vector max = region.getMaximumPoint();
|
|
||||||
|
zero = max.add(min).multiply(0.5);
|
||||||
zero = max.add(min).multiply(0.5);
|
unit = Vector.ONE;
|
||||||
unit = Vector.ONE;
|
} else {
|
||||||
} else {
|
final Vector min = region.getMinimumPoint();
|
||||||
final Vector min = region.getMinimumPoint();
|
final Vector max = region.getMaximumPoint();
|
||||||
final Vector max = region.getMaximumPoint();
|
|
||||||
|
zero = max.add(min).multiply(0.5);
|
||||||
zero = max.add(min).multiply(0.5);
|
unit = max.subtract(zero);
|
||||||
unit = max.subtract(zero);
|
|
||||||
|
if (unit.getX() == 0) unit = unit.setX(1.0);
|
||||||
if (unit.getX() == 0) unit = unit.setX(1.0);
|
if (unit.getY() == 0) unit = unit.setY(1.0);
|
||||||
if (unit.getY() == 0) unit = unit.setY(1.0);
|
if (unit.getZ() == 0) unit = unit.setZ(1.0);
|
||||||
if (unit.getZ() == 0) unit = unit.setZ(1.0);
|
}
|
||||||
}
|
|
||||||
|
try {
|
||||||
try {
|
final int affected = editSession.makeBiomeShape(region, zero, unit, target, expression, hollow);
|
||||||
final int affected = editSession.makeBiomeShape(region, zero, unit, target, expression, hollow);
|
player.findFreePosition();
|
||||||
player.findFreePosition();
|
player.print("Biome changed to " + target.getName() + ". " + affected + " columns affected.");
|
||||||
player.print("Biome changed to " + target.getName() + ". " + affected + " columns affected.");
|
} catch (ExpressionException e) {
|
||||||
} catch (ExpressionException e) {
|
player.printError(e.getMessage());
|
||||||
player.printError(e.getMessage());
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
@ -1,123 +1,123 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* History little commands.
|
* History little commands.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class HistoryCommands {
|
public class HistoryCommands {
|
||||||
private final WorldEdit we;
|
private final WorldEdit we;
|
||||||
|
|
||||||
public HistoryCommands(WorldEdit we) {
|
public HistoryCommands(WorldEdit we) {
|
||||||
this.we = we;
|
this.we = we;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/undo", "undo" },
|
aliases = { "/undo", "undo" },
|
||||||
usage = "[times] [player]",
|
usage = "[times] [player]",
|
||||||
desc = "Undoes the last action",
|
desc = "Undoes the last action",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 2
|
max = 2
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.history.undo")
|
@CommandPermissions("worldedit.history.undo")
|
||||||
public void undo(CommandContext args, LocalSession session, LocalPlayer player,
|
public void undo(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
int times = Math.max(1, args.getInteger(0, 1));
|
int times = Math.max(1, args.getInteger(0, 1));
|
||||||
for (int i = 0; i < times; ++i) {
|
for (int i = 0; i < times; ++i) {
|
||||||
EditSession undone;
|
EditSession undone;
|
||||||
if (args.argsLength() < 2) {
|
if (args.argsLength() < 2) {
|
||||||
undone = session.undo(session.getBlockBag(player), player);
|
undone = session.undo(session.getBlockBag(player), player);
|
||||||
} else {
|
} else {
|
||||||
player.checkPermission("worldedit.history.undo.other");
|
player.checkPermission("worldedit.history.undo.other");
|
||||||
LocalSession sess = we.getSession(args.getString(1));
|
LocalSession sess = we.getSession(args.getString(1));
|
||||||
if (sess == null) {
|
if (sess == null) {
|
||||||
player.printError("Unable to find session for " + args.getString(1));
|
player.printError("Unable to find session for " + args.getString(1));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
undone = sess.undo(session.getBlockBag(player), player);
|
undone = sess.undo(session.getBlockBag(player), player);
|
||||||
}
|
}
|
||||||
if (undone != null) {
|
if (undone != null) {
|
||||||
player.print("Undo successful.");
|
player.print("Undo successful.");
|
||||||
we.flushBlockBag(player, undone);
|
we.flushBlockBag(player, undone);
|
||||||
} else {
|
} else {
|
||||||
player.printError("Nothing left to undo.");
|
player.printError("Nothing left to undo.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/redo", "redo" },
|
aliases = { "/redo", "redo" },
|
||||||
usage = "[times] [player]",
|
usage = "[times] [player]",
|
||||||
desc = "Redoes the last action (from history)",
|
desc = "Redoes the last action (from history)",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 2
|
max = 2
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.history.redo")
|
@CommandPermissions("worldedit.history.redo")
|
||||||
public void redo(CommandContext args, LocalSession session, LocalPlayer player,
|
public void redo(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
int times = Math.max(1, args.getInteger(0, 1));
|
int times = Math.max(1, args.getInteger(0, 1));
|
||||||
|
|
||||||
for (int i = 0; i < times; ++i) {
|
for (int i = 0; i < times; ++i) {
|
||||||
EditSession redone;
|
EditSession redone;
|
||||||
if (args.argsLength() < 2) {
|
if (args.argsLength() < 2) {
|
||||||
redone = session.redo(session.getBlockBag(player), player);
|
redone = session.redo(session.getBlockBag(player), player);
|
||||||
} else {
|
} else {
|
||||||
player.checkPermission("worldedit.history.redo.other");
|
player.checkPermission("worldedit.history.redo.other");
|
||||||
LocalSession sess = we.getSession(args.getString(1));
|
LocalSession sess = we.getSession(args.getString(1));
|
||||||
if (sess == null) {
|
if (sess == null) {
|
||||||
player.printError("Unable to find session for " + args.getString(1));
|
player.printError("Unable to find session for " + args.getString(1));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
redone = sess.redo(session.getBlockBag(player), player);
|
redone = sess.redo(session.getBlockBag(player), player);
|
||||||
}
|
}
|
||||||
if (redone != null) {
|
if (redone != null) {
|
||||||
player.print("Redo successful.");
|
player.print("Redo successful.");
|
||||||
we.flushBlockBag(player, redone);
|
we.flushBlockBag(player, redone);
|
||||||
} else {
|
} else {
|
||||||
player.printError("Nothing left to redo.");
|
player.printError("Nothing left to redo.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/clearhistory", "clearhistory" },
|
aliases = { "/clearhistory", "clearhistory" },
|
||||||
usage = "",
|
usage = "",
|
||||||
desc = "Clear your history",
|
desc = "Clear your history",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.history.clear")
|
@CommandPermissions("worldedit.history.clear")
|
||||||
public void clearHistory(CommandContext args, LocalSession session, LocalPlayer player,
|
public void clearHistory(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
session.clearHistory();
|
session.clearHistory();
|
||||||
player.print("History cleared.");
|
player.print("History cleared.");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
|
@ -1,216 +1,216 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.POSITION;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.minecraft.util.commands.Logging;
|
import com.sk89q.minecraft.util.commands.Logging;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.WorldVector;
|
import com.sk89q.worldedit.WorldVector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Navigation commands.
|
* Navigation commands.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class NavigationCommands {
|
public class NavigationCommands {
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
private final WorldEdit we;
|
private final WorldEdit we;
|
||||||
|
|
||||||
public NavigationCommands(WorldEdit we) {
|
public NavigationCommands(WorldEdit we) {
|
||||||
this.we = we;
|
this.we = we;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "unstuck", "!" },
|
aliases = { "unstuck", "!" },
|
||||||
usage = "",
|
usage = "",
|
||||||
desc = "Escape from being stuck inside a block",
|
desc = "Escape from being stuck inside a block",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.navigation.unstuck")
|
@CommandPermissions("worldedit.navigation.unstuck")
|
||||||
public void unstuck(CommandContext args, LocalSession session, LocalPlayer player,
|
public void unstuck(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
player.print("There you go!");
|
player.print("There you go!");
|
||||||
player.findFreePosition();
|
player.findFreePosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "ascend", "asc" },
|
aliases = { "ascend", "asc" },
|
||||||
usage = "[# of levels]",
|
usage = "[# of levels]",
|
||||||
desc = "Go up a floor",
|
desc = "Go up a floor",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.navigation.ascend")
|
@CommandPermissions("worldedit.navigation.ascend")
|
||||||
public void ascend(CommandContext args, LocalSession session, LocalPlayer player,
|
public void ascend(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
int levelsToAscend = 0;
|
int levelsToAscend = 0;
|
||||||
if (args.argsLength() == 0) {
|
if (args.argsLength() == 0) {
|
||||||
levelsToAscend = 1;
|
levelsToAscend = 1;
|
||||||
} else {
|
} else {
|
||||||
levelsToAscend = args.getInteger(0);
|
levelsToAscend = args.getInteger(0);
|
||||||
}
|
}
|
||||||
int ascentLevels = 1;
|
int ascentLevels = 1;
|
||||||
while (player.ascendLevel() && levelsToAscend != ascentLevels) {
|
while (player.ascendLevel() && levelsToAscend != ascentLevels) {
|
||||||
++ascentLevels;
|
++ascentLevels;
|
||||||
}
|
}
|
||||||
if (ascentLevels == 0) {
|
if (ascentLevels == 0) {
|
||||||
player.printError("No free spot above you found.");
|
player.printError("No free spot above you found.");
|
||||||
} else {
|
} else {
|
||||||
player.print((ascentLevels != 1) ? "Ascended " + Integer.toString(ascentLevels) + " levels." : "Ascended a level.");
|
player.print((ascentLevels != 1) ? "Ascended " + Integer.toString(ascentLevels) + " levels." : "Ascended a level.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "descend", "desc" },
|
aliases = { "descend", "desc" },
|
||||||
usage = "[# of floors]",
|
usage = "[# of floors]",
|
||||||
desc = "Go down a floor",
|
desc = "Go down a floor",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.navigation.descend")
|
@CommandPermissions("worldedit.navigation.descend")
|
||||||
public void descend(CommandContext args, LocalSession session, LocalPlayer player,
|
public void descend(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
int levelsToDescend = 0;
|
int levelsToDescend = 0;
|
||||||
if (args.argsLength() == 0) {
|
if (args.argsLength() == 0) {
|
||||||
levelsToDescend = 1;
|
levelsToDescend = 1;
|
||||||
} else {
|
} else {
|
||||||
levelsToDescend = args.getInteger(0);
|
levelsToDescend = args.getInteger(0);
|
||||||
}
|
}
|
||||||
int descentLevels = 1;
|
int descentLevels = 1;
|
||||||
while (player.descendLevel() && levelsToDescend != descentLevels) {
|
while (player.descendLevel() && levelsToDescend != descentLevels) {
|
||||||
++descentLevels;
|
++descentLevels;
|
||||||
}
|
}
|
||||||
if (descentLevels == 0) {
|
if (descentLevels == 0) {
|
||||||
player.printError("No free spot above you found.");
|
player.printError("No free spot above you found.");
|
||||||
} else {
|
} else {
|
||||||
player.print((descentLevels != 1) ? "Descended " + Integer.toString(descentLevels) + " levels." : "Descended a level.");
|
player.print((descentLevels != 1) ? "Descended " + Integer.toString(descentLevels) + " levels." : "Descended a level.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "ceil" },
|
aliases = { "ceil" },
|
||||||
usage = "[clearance]",
|
usage = "[clearance]",
|
||||||
desc = "Go to the celing",
|
desc = "Go to the celing",
|
||||||
flags = "fg",
|
flags = "fg",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.navigation.ceiling")
|
@CommandPermissions("worldedit.navigation.ceiling")
|
||||||
@Logging(POSITION)
|
@Logging(POSITION)
|
||||||
public void ceiling(CommandContext args, LocalSession session, LocalPlayer player,
|
public void ceiling(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
final int clearance = args.argsLength() > 0 ?
|
final int clearance = args.argsLength() > 0 ?
|
||||||
Math.max(0, args.getInteger(0)) : 0;
|
Math.max(0, args.getInteger(0)) : 0;
|
||||||
|
|
||||||
final boolean alwaysGlass = getAlwaysGlass(args);
|
final boolean alwaysGlass = getAlwaysGlass(args);
|
||||||
if (player.ascendToCeiling(clearance, alwaysGlass)) {
|
if (player.ascendToCeiling(clearance, alwaysGlass)) {
|
||||||
player.print("Whoosh!");
|
player.print("Whoosh!");
|
||||||
} else {
|
} else {
|
||||||
player.printError("No free spot above you found.");
|
player.printError("No free spot above you found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "thru" },
|
aliases = { "thru" },
|
||||||
usage = "",
|
usage = "",
|
||||||
desc = "Passthrough walls",
|
desc = "Passthrough walls",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.navigation.thru.command")
|
@CommandPermissions("worldedit.navigation.thru.command")
|
||||||
public void thru(CommandContext args, LocalSession session, LocalPlayer player,
|
public void thru(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
if (player.passThroughForwardWall(6)) {
|
if (player.passThroughForwardWall(6)) {
|
||||||
player.print("Whoosh!");
|
player.print("Whoosh!");
|
||||||
} else {
|
} else {
|
||||||
player.printError("No free spot ahead of you found.");
|
player.printError("No free spot ahead of you found.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "jumpto", "j" },
|
aliases = { "jumpto", "j" },
|
||||||
usage = "",
|
usage = "",
|
||||||
desc = "Teleport to a location",
|
desc = "Teleport to a location",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.navigation.jumpto.command")
|
@CommandPermissions("worldedit.navigation.jumpto.command")
|
||||||
public void jumpTo(CommandContext args, LocalSession session, LocalPlayer player,
|
public void jumpTo(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
WorldVector pos = player.getSolidBlockTrace(300);
|
WorldVector pos = player.getSolidBlockTrace(300);
|
||||||
if (pos != null) {
|
if (pos != null) {
|
||||||
player.findFreePosition(pos);
|
player.findFreePosition(pos);
|
||||||
player.print("Poof!");
|
player.print("Poof!");
|
||||||
} else {
|
} else {
|
||||||
player.printError("No block in sight!");
|
player.printError("No block in sight!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "up" },
|
aliases = { "up" },
|
||||||
usage = "<block>",
|
usage = "<block>",
|
||||||
desc = "Go upwards some distance",
|
desc = "Go upwards some distance",
|
||||||
flags = "fg",
|
flags = "fg",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.navigation.up")
|
@CommandPermissions("worldedit.navigation.up")
|
||||||
@Logging(POSITION)
|
@Logging(POSITION)
|
||||||
public void up(CommandContext args, LocalSession session, LocalPlayer player,
|
public void up(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
final int distance = args.getInteger(0);
|
final int distance = args.getInteger(0);
|
||||||
|
|
||||||
final boolean alwaysGlass = getAlwaysGlass(args);
|
final boolean alwaysGlass = getAlwaysGlass(args);
|
||||||
if (player.ascendUpwards(distance, alwaysGlass)) {
|
if (player.ascendUpwards(distance, alwaysGlass)) {
|
||||||
player.print("Whoosh!");
|
player.print("Whoosh!");
|
||||||
} else {
|
} else {
|
||||||
player.printError("You would hit something above you.");
|
player.printError("You would hit something above you.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function for /up and /ceil.
|
* Helper function for /up and /ceil.
|
||||||
*
|
*
|
||||||
* @param args The {@link CommandContext} to extract the flags from.
|
* @param args The {@link CommandContext} to extract the flags from.
|
||||||
* @return true, if glass should always be put under the player
|
* @return true, if glass should always be put under the player
|
||||||
*/
|
*/
|
||||||
private boolean getAlwaysGlass(CommandContext args) {
|
private boolean getAlwaysGlass(CommandContext args) {
|
||||||
final LocalConfiguration config = we.getConfiguration();
|
final LocalConfiguration config = we.getConfiguration();
|
||||||
|
|
||||||
final boolean forceFlight = args.hasFlag('f');
|
final boolean forceFlight = args.hasFlag('f');
|
||||||
final boolean forceGlass = args.hasFlag('g');
|
final boolean forceGlass = args.hasFlag('g');
|
||||||
|
|
||||||
return forceGlass || (config.navigationUseGlass && !forceFlight);
|
return forceGlass || (config.navigationUseGlass && !forceFlight);
|
||||||
}
|
}
|
||||||
}
|
}
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -16,7 +16,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -35,13 +35,13 @@ import com.sk89q.worldedit.LocalPlayer;
|
|||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.data.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
import com.sk89q.worldedit.schematic.SchematicFormat;
|
import com.sk89q.worldedit.schematic.SchematicFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Commands related to schematics
|
* Commands related to schematics
|
||||||
*
|
*
|
||||||
* @see com.sk89q.worldedit.commands.ClipboardCommands#schematic()
|
* @see com.sk89q.worldedit.command.ClipboardCommands#schematic()
|
||||||
*/
|
*/
|
||||||
public class SchematicCommands {
|
public class SchematicCommands {
|
||||||
private final WorldEdit we;
|
private final WorldEdit we;
|
@ -1,101 +1,101 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.minecraft.util.commands.Logging;
|
import com.sk89q.minecraft.util.commands.Logging;
|
||||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.*;
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.*;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scripting commands.
|
* Scripting commands.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class ScriptingCommands {
|
public class ScriptingCommands {
|
||||||
private final WorldEdit we;
|
private final WorldEdit we;
|
||||||
|
|
||||||
public ScriptingCommands(WorldEdit we) {
|
public ScriptingCommands(WorldEdit we) {
|
||||||
this.we = we;
|
this.we = we;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "cs" },
|
aliases = { "cs" },
|
||||||
usage = "<filename> [args...]",
|
usage = "<filename> [args...]",
|
||||||
desc = "Execute a CraftScript",
|
desc = "Execute a CraftScript",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = -1
|
max = -1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.scripting.execute")
|
@CommandPermissions("worldedit.scripting.execute")
|
||||||
@Logging(ALL)
|
@Logging(ALL)
|
||||||
public void execute(CommandContext args, LocalSession session, LocalPlayer player,
|
public void execute(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
String[] scriptArgs = args.getSlice(1);
|
String[] scriptArgs = args.getSlice(1);
|
||||||
String name = args.getString(0);
|
String name = args.getString(0);
|
||||||
|
|
||||||
if (!player.hasPermission("worldedit.scripting.execute." + name)) {
|
if (!player.hasPermission("worldedit.scripting.execute." + name)) {
|
||||||
player.printError("You don't have permission to use that script.");
|
player.printError("You don't have permission to use that script.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.setLastScript(name);
|
session.setLastScript(name);
|
||||||
|
|
||||||
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
|
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
|
||||||
File f = we.getSafeOpenFile(player, dir, name, "js", "js");
|
File f = we.getSafeOpenFile(player, dir, name, "js", "js");
|
||||||
|
|
||||||
we.runScript(player, f, scriptArgs);
|
we.runScript(player, f, scriptArgs);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { ".s" },
|
aliases = { ".s" },
|
||||||
usage = "[args...]",
|
usage = "[args...]",
|
||||||
desc = "Execute last CraftScript",
|
desc = "Execute last CraftScript",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = -1
|
max = -1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.scripting.execute")
|
@CommandPermissions("worldedit.scripting.execute")
|
||||||
@Logging(ALL)
|
@Logging(ALL)
|
||||||
public void executeLast(CommandContext args, LocalSession session, LocalPlayer player,
|
public void executeLast(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
String lastScript = session.getLastScript();
|
String lastScript = session.getLastScript();
|
||||||
|
|
||||||
if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) {
|
if (!player.hasPermission("worldedit.scripting.execute." + lastScript)) {
|
||||||
player.printError("You don't have permission to use that script.");
|
player.printError("You don't have permission to use that script.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lastScript == null) {
|
if (lastScript == null) {
|
||||||
player.printError("Use /cs with a script name first.");
|
player.printError("Use /cs with a script name first.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] scriptArgs = args.getSlice(0);
|
String[] scriptArgs = args.getSlice(0);
|
||||||
|
|
||||||
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
|
File dir = we.getWorkingDirectoryFile(we.getConfiguration().scriptsDir);
|
||||||
File f = we.getSafeOpenFile(player, dir, lastScript, "js", "js");
|
File f = we.getSafeOpenFile(player, dir, lastScript, "js", "js");
|
||||||
|
|
||||||
we.runScript(player, f, scriptArgs);
|
we.runScript(player, f, scriptArgs);
|
||||||
}
|
}
|
||||||
}
|
}
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -1,272 +1,272 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.data.MissingWorldException;
|
import com.sk89q.worldedit.world.storage.MissingWorldException;
|
||||||
import com.sk89q.worldedit.snapshots.InvalidSnapshotException;
|
import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException;
|
||||||
import com.sk89q.worldedit.snapshots.Snapshot;
|
import com.sk89q.worldedit.world.snapshot.Snapshot;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Snapshot commands.
|
* Snapshot commands.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class SnapshotCommands {
|
public class SnapshotCommands {
|
||||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
||||||
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
|
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
|
||||||
|
|
||||||
private final WorldEdit we;
|
private final WorldEdit we;
|
||||||
|
|
||||||
public SnapshotCommands(WorldEdit we) {
|
public SnapshotCommands(WorldEdit we) {
|
||||||
this.we = we;
|
this.we = we;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "list" },
|
aliases = { "list" },
|
||||||
usage = "[num]",
|
usage = "[num]",
|
||||||
desc = "List snapshots",
|
desc = "List snapshots",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.snapshots.list")
|
@CommandPermissions("worldedit.snapshots.list")
|
||||||
public void list(CommandContext args, LocalSession session, LocalPlayer player,
|
public void list(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
LocalConfiguration config = we.getConfiguration();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
|
|
||||||
if (config.snapshotRepo == null) {
|
if (config.snapshotRepo == null) {
|
||||||
player.printError("Snapshot/backup restore is not configured.");
|
player.printError("Snapshot/backup restore is not configured.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName());
|
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName());
|
||||||
|
|
||||||
if (snapshots.size() > 0) {
|
if (snapshots.size() > 0) {
|
||||||
|
|
||||||
int num = args.argsLength() > 0 ? Math.min(40, Math.max(5, args.getInteger(0))) : 5;
|
int num = args.argsLength() > 0 ? Math.min(40, Math.max(5, args.getInteger(0))) : 5;
|
||||||
|
|
||||||
player.print("Snapshots for world: '" + player.getWorld().getName() + "'");
|
player.print("Snapshots for world: '" + player.getWorld().getName() + "'");
|
||||||
for (byte i = 0; i < Math.min(num, snapshots.size()); i++) {
|
for (byte i = 0; i < Math.min(num, snapshots.size()); i++) {
|
||||||
player.print((i + 1) + ". " + snapshots.get(i).getName());
|
player.print((i + 1) + ". " + snapshots.get(i).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
player.print("Use /snap use [snapshot] or /snap use latest.");
|
player.print("Use /snap use [snapshot] or /snap use latest.");
|
||||||
} else {
|
} else {
|
||||||
player.printError("No snapshots are available. See console for details.");
|
player.printError("No snapshots are available. See console for details.");
|
||||||
|
|
||||||
// Okay, let's toss some debugging information!
|
// Okay, let's toss some debugging information!
|
||||||
File dir = config.snapshotRepo.getDirectory();
|
File dir = config.snapshotRepo.getDirectory();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.info("WorldEdit found no snapshots: looked in: "
|
logger.info("WorldEdit found no snapshots: looked in: "
|
||||||
+ dir.getCanonicalPath());
|
+ dir.getCanonicalPath());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.info("WorldEdit found no snapshots: looked in "
|
logger.info("WorldEdit found no snapshots: looked in "
|
||||||
+ "(NON-RESOLVABLE PATH - does it exist?): "
|
+ "(NON-RESOLVABLE PATH - does it exist?): "
|
||||||
+ dir.getPath());
|
+ dir.getPath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (MissingWorldException ex) {
|
} catch (MissingWorldException ex) {
|
||||||
player.printError("No snapshots were found for this world.");
|
player.printError("No snapshots were found for this world.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "use" },
|
aliases = { "use" },
|
||||||
usage = "<snapshot>",
|
usage = "<snapshot>",
|
||||||
desc = "Choose a snapshot to use",
|
desc = "Choose a snapshot to use",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.snapshots.restore")
|
@CommandPermissions("worldedit.snapshots.restore")
|
||||||
public void use(CommandContext args, LocalSession session, LocalPlayer player,
|
public void use(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
LocalConfiguration config = we.getConfiguration();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
|
|
||||||
if (config.snapshotRepo == null) {
|
if (config.snapshotRepo == null) {
|
||||||
player.printError("Snapshot/backup restore is not configured.");
|
player.printError("Snapshot/backup restore is not configured.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = args.getString(0);
|
String name = args.getString(0);
|
||||||
|
|
||||||
// Want the latest snapshot?
|
// Want the latest snapshot?
|
||||||
if (name.equalsIgnoreCase("latest")) {
|
if (name.equalsIgnoreCase("latest")) {
|
||||||
try {
|
try {
|
||||||
Snapshot snapshot = config.snapshotRepo.getDefaultSnapshot(player.getWorld().getName());
|
Snapshot snapshot = config.snapshotRepo.getDefaultSnapshot(player.getWorld().getName());
|
||||||
|
|
||||||
if (snapshot != null) {
|
if (snapshot != null) {
|
||||||
session.setSnapshot(null);
|
session.setSnapshot(null);
|
||||||
player.print("Now using newest snapshot.");
|
player.print("Now using newest snapshot.");
|
||||||
} else {
|
} else {
|
||||||
player.printError("No snapshots were found.");
|
player.printError("No snapshots were found.");
|
||||||
}
|
}
|
||||||
} catch (MissingWorldException ex) {
|
} catch (MissingWorldException ex) {
|
||||||
player.printError("No snapshots were found for this world.");
|
player.printError("No snapshots were found for this world.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
session.setSnapshot(config.snapshotRepo.getSnapshot(name));
|
session.setSnapshot(config.snapshotRepo.getSnapshot(name));
|
||||||
player.print("Snapshot set to: " + name);
|
player.print("Snapshot set to: " + name);
|
||||||
} catch (InvalidSnapshotException e) {
|
} catch (InvalidSnapshotException e) {
|
||||||
player.printError("That snapshot does not exist or is not available.");
|
player.printError("That snapshot does not exist or is not available.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "sel" },
|
aliases = { "sel" },
|
||||||
usage = "<index>",
|
usage = "<index>",
|
||||||
desc = "Choose the snapshot based on the list id",
|
desc = "Choose the snapshot based on the list id",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.snapshots.restore")
|
@CommandPermissions("worldedit.snapshots.restore")
|
||||||
public void sel(CommandContext args, LocalSession session, LocalPlayer player,
|
public void sel(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
LocalConfiguration config = we.getConfiguration();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
|
|
||||||
if (config.snapshotRepo == null) {
|
if (config.snapshotRepo == null) {
|
||||||
player.printError("Snapshot/backup restore is not configured.");
|
player.printError("Snapshot/backup restore is not configured.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = -1;
|
int index = -1;
|
||||||
try {
|
try {
|
||||||
index = Integer.parseInt(args.getString(0));
|
index = Integer.parseInt(args.getString(0));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
player.printError("Invalid index, " + args.getString(0) + " is not a valid integer.");
|
player.printError("Invalid index, " + args.getString(0) + " is not a valid integer.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index < 1) {
|
if (index < 1) {
|
||||||
player.printError("Invalid index, must be equal or higher then 1.");
|
player.printError("Invalid index, must be equal or higher then 1.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName());
|
List<Snapshot> snapshots = config.snapshotRepo.getSnapshots(true, player.getWorld().getName());
|
||||||
if (snapshots.size() < index) {
|
if (snapshots.size() < index) {
|
||||||
player.printError("Invalid index, must be between 1 and " + snapshots.size() + ".");
|
player.printError("Invalid index, must be between 1 and " + snapshots.size() + ".");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Snapshot snapshot = snapshots.get(index - 1);
|
Snapshot snapshot = snapshots.get(index - 1);
|
||||||
if (snapshot == null) {
|
if (snapshot == null) {
|
||||||
player.printError("That snapshot does not exist or is not available.");
|
player.printError("That snapshot does not exist or is not available.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
session.setSnapshot(snapshot);
|
session.setSnapshot(snapshot);
|
||||||
player.print("Snapshot set to: " + snapshot.getName());
|
player.print("Snapshot set to: " + snapshot.getName());
|
||||||
} catch (MissingWorldException e) {
|
} catch (MissingWorldException e) {
|
||||||
player.printError("No snapshots were found for this world.");
|
player.printError("No snapshots were found for this world.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "before" },
|
aliases = { "before" },
|
||||||
usage = "<date>",
|
usage = "<date>",
|
||||||
desc = "Choose the nearest snapshot before a date",
|
desc = "Choose the nearest snapshot before a date",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = -1
|
max = -1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.snapshots.restore")
|
@CommandPermissions("worldedit.snapshots.restore")
|
||||||
public void before(CommandContext args, LocalSession session, LocalPlayer player,
|
public void before(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
LocalConfiguration config = we.getConfiguration();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
|
|
||||||
if (config.snapshotRepo == null) {
|
if (config.snapshotRepo == null) {
|
||||||
player.printError("Snapshot/backup restore is not configured.");
|
player.printError("Snapshot/backup restore is not configured.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Calendar date = session.detectDate(args.getJoinedStrings(0));
|
Calendar date = session.detectDate(args.getJoinedStrings(0));
|
||||||
|
|
||||||
if (date == null) {
|
if (date == null) {
|
||||||
player.printError("Could not detect the date inputted.");
|
player.printError("Could not detect the date inputted.");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
Snapshot snapshot = config.snapshotRepo.getSnapshotBefore(date, player.getWorld().getName());
|
Snapshot snapshot = config.snapshotRepo.getSnapshotBefore(date, player.getWorld().getName());
|
||||||
|
|
||||||
if (snapshot == null) {
|
if (snapshot == null) {
|
||||||
dateFormat.setTimeZone(session.getTimeZone());
|
dateFormat.setTimeZone(session.getTimeZone());
|
||||||
player.printError("Couldn't find a snapshot before "
|
player.printError("Couldn't find a snapshot before "
|
||||||
+ dateFormat.format(date.getTime()) + ".");
|
+ dateFormat.format(date.getTime()) + ".");
|
||||||
} else {
|
} else {
|
||||||
session.setSnapshot(snapshot);
|
session.setSnapshot(snapshot);
|
||||||
player.print("Snapshot set to: " + snapshot.getName());
|
player.print("Snapshot set to: " + snapshot.getName());
|
||||||
}
|
}
|
||||||
} catch (MissingWorldException ex) {
|
} catch (MissingWorldException ex) {
|
||||||
player.printError("No snapshots were found for this world.");
|
player.printError("No snapshots were found for this world.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "after" },
|
aliases = { "after" },
|
||||||
usage = "<date>",
|
usage = "<date>",
|
||||||
desc = "Choose the nearest snapshot after a date",
|
desc = "Choose the nearest snapshot after a date",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = -1
|
max = -1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.snapshots.restore")
|
@CommandPermissions("worldedit.snapshots.restore")
|
||||||
public void after(CommandContext args, LocalSession session, LocalPlayer player,
|
public void after(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
LocalConfiguration config = we.getConfiguration();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
|
|
||||||
if (config.snapshotRepo == null) {
|
if (config.snapshotRepo == null) {
|
||||||
player.printError("Snapshot/backup restore is not configured.");
|
player.printError("Snapshot/backup restore is not configured.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Calendar date = session.detectDate(args.getJoinedStrings(0));
|
Calendar date = session.detectDate(args.getJoinedStrings(0));
|
||||||
|
|
||||||
if (date == null) {
|
if (date == null) {
|
||||||
player.printError("Could not detect the date inputted.");
|
player.printError("Could not detect the date inputted.");
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
Snapshot snapshot = config.snapshotRepo.getSnapshotAfter(date, player.getWorld().getName());
|
Snapshot snapshot = config.snapshotRepo.getSnapshotAfter(date, player.getWorld().getName());
|
||||||
if (snapshot == null) {
|
if (snapshot == null) {
|
||||||
dateFormat.setTimeZone(session.getTimeZone());
|
dateFormat.setTimeZone(session.getTimeZone());
|
||||||
player.printError("Couldn't find a snapshot after "
|
player.printError("Couldn't find a snapshot after "
|
||||||
+ dateFormat.format(date.getTime()) + ".");
|
+ dateFormat.format(date.getTime()) + ".");
|
||||||
} else {
|
} else {
|
||||||
session.setSnapshot(snapshot);
|
session.setSnapshot(snapshot);
|
||||||
player.print("Snapshot set to: " + snapshot.getName());
|
player.print("Snapshot set to: " + snapshot.getName());
|
||||||
}
|
}
|
||||||
} catch (MissingWorldException ex) {
|
} catch (MissingWorldException ex) {
|
||||||
player.printError("No snapshots were found for this world.");
|
player.printError("No snapshots were found for this world.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,169 +1,169 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
import static com.sk89q.minecraft.util.commands.Logging.LogMode.REGION;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.minecraft.util.commands.Logging;
|
import com.sk89q.minecraft.util.commands.Logging;
|
||||||
import com.sk89q.minecraft.util.commands.NestedCommand;
|
import com.sk89q.minecraft.util.commands.NestedCommand;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.data.ChunkStore;
|
import com.sk89q.worldedit.world.storage.ChunkStore;
|
||||||
import com.sk89q.worldedit.data.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
import com.sk89q.worldedit.data.MissingWorldException;
|
import com.sk89q.worldedit.world.storage.MissingWorldException;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.snapshots.InvalidSnapshotException;
|
import com.sk89q.worldedit.world.snapshot.InvalidSnapshotException;
|
||||||
import com.sk89q.worldedit.snapshots.Snapshot;
|
import com.sk89q.worldedit.world.snapshot.Snapshot;
|
||||||
import com.sk89q.worldedit.snapshots.SnapshotRestore;
|
import com.sk89q.worldedit.world.snapshot.SnapshotRestore;
|
||||||
|
|
||||||
public class SnapshotUtilCommands {
|
public class SnapshotUtilCommands {
|
||||||
|
|
||||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
||||||
|
|
||||||
private final WorldEdit we;
|
private final WorldEdit we;
|
||||||
|
|
||||||
public SnapshotUtilCommands(WorldEdit we) {
|
public SnapshotUtilCommands(WorldEdit we) {
|
||||||
this.we = we;
|
this.we = we;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "snapshot", "snap" },
|
aliases = { "snapshot", "snap" },
|
||||||
desc = "Snapshot commands"
|
desc = "Snapshot commands"
|
||||||
)
|
)
|
||||||
@NestedCommand(SnapshotCommands.class)
|
@NestedCommand(SnapshotCommands.class)
|
||||||
public void snapshot(CommandContext args, LocalSession session, LocalPlayer player,
|
public void snapshot(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "restore", "/restore" },
|
aliases = { "restore", "/restore" },
|
||||||
usage = "[snapshot]",
|
usage = "[snapshot]",
|
||||||
desc = "Restore the selection from a snapshot",
|
desc = "Restore the selection from a snapshot",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@Logging(REGION)
|
@Logging(REGION)
|
||||||
@CommandPermissions("worldedit.snapshots.restore")
|
@CommandPermissions("worldedit.snapshots.restore")
|
||||||
public void restore(CommandContext args, LocalSession session, LocalPlayer player,
|
public void restore(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
LocalConfiguration config = we.getConfiguration();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
|
|
||||||
if (config.snapshotRepo == null) {
|
if (config.snapshotRepo == null) {
|
||||||
player.printError("Snapshot/backup restore is not configured.");
|
player.printError("Snapshot/backup restore is not configured.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Region region = session.getSelection(player.getWorld());
|
Region region = session.getSelection(player.getWorld());
|
||||||
Snapshot snapshot;
|
Snapshot snapshot;
|
||||||
|
|
||||||
if (args.argsLength() > 0) {
|
if (args.argsLength() > 0) {
|
||||||
try {
|
try {
|
||||||
snapshot = config.snapshotRepo.getSnapshot(args.getString(0));
|
snapshot = config.snapshotRepo.getSnapshot(args.getString(0));
|
||||||
} catch (InvalidSnapshotException e) {
|
} catch (InvalidSnapshotException e) {
|
||||||
player.printError("That snapshot does not exist or is not available.");
|
player.printError("That snapshot does not exist or is not available.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
snapshot = session.getSnapshot();
|
snapshot = session.getSnapshot();
|
||||||
}
|
}
|
||||||
|
|
||||||
// No snapshot set?
|
// No snapshot set?
|
||||||
if (snapshot == null) {
|
if (snapshot == null) {
|
||||||
try {
|
try {
|
||||||
snapshot = config.snapshotRepo.getDefaultSnapshot(player.getWorld().getName());
|
snapshot = config.snapshotRepo.getDefaultSnapshot(player.getWorld().getName());
|
||||||
|
|
||||||
if (snapshot == null) {
|
if (snapshot == null) {
|
||||||
player.printError("No snapshots were found. See console for details.");
|
player.printError("No snapshots were found. See console for details.");
|
||||||
|
|
||||||
// Okay, let's toss some debugging information!
|
// Okay, let's toss some debugging information!
|
||||||
File dir = config.snapshotRepo.getDirectory();
|
File dir = config.snapshotRepo.getDirectory();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
logger.info("WorldEdit found no snapshots: looked in: "
|
logger.info("WorldEdit found no snapshots: looked in: "
|
||||||
+ dir.getCanonicalPath());
|
+ dir.getCanonicalPath());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.info("WorldEdit found no snapshots: looked in "
|
logger.info("WorldEdit found no snapshots: looked in "
|
||||||
+ "(NON-RESOLVABLE PATH - does it exist?): "
|
+ "(NON-RESOLVABLE PATH - does it exist?): "
|
||||||
+ dir.getPath());
|
+ dir.getPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (MissingWorldException ex) {
|
} catch (MissingWorldException ex) {
|
||||||
player.printError("No snapshots were found for this world.");
|
player.printError("No snapshots were found for this world.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ChunkStore chunkStore = null;
|
ChunkStore chunkStore = null;
|
||||||
|
|
||||||
// Load chunk store
|
// Load chunk store
|
||||||
try {
|
try {
|
||||||
chunkStore = snapshot.getChunkStore();
|
chunkStore = snapshot.getChunkStore();
|
||||||
player.print("Snapshot '" + snapshot.getName() + "' loaded; now restoring...");
|
player.print("Snapshot '" + snapshot.getName() + "' loaded; now restoring...");
|
||||||
} catch (DataException e) {
|
} catch (DataException e) {
|
||||||
player.printError("Failed to load snapshot: " + e.getMessage());
|
player.printError("Failed to load snapshot: " + e.getMessage());
|
||||||
return;
|
return;
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
player.printError("Failed to load snapshot: " + e.getMessage());
|
player.printError("Failed to load snapshot: " + e.getMessage());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Restore snapshot
|
// Restore snapshot
|
||||||
SnapshotRestore restore = new SnapshotRestore(chunkStore, editSession, region);
|
SnapshotRestore restore = new SnapshotRestore(chunkStore, editSession, region);
|
||||||
//player.print(restore.getChunksAffected() + " chunk(s) will be loaded.");
|
//player.print(restore.getChunksAffected() + " chunk(s) will be loaded.");
|
||||||
|
|
||||||
restore.restore();
|
restore.restore();
|
||||||
|
|
||||||
if (restore.hadTotalFailure()) {
|
if (restore.hadTotalFailure()) {
|
||||||
String error = restore.getLastErrorMessage();
|
String error = restore.getLastErrorMessage();
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
player.printError("Errors prevented any blocks from being restored.");
|
player.printError("Errors prevented any blocks from being restored.");
|
||||||
player.printError("Last error: " + error);
|
player.printError("Last error: " + error);
|
||||||
} else {
|
} else {
|
||||||
player.printError("No chunks could be loaded. (Bad archive?)");
|
player.printError("No chunks could be loaded. (Bad archive?)");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.print(String.format("Restored; %d "
|
player.print(String.format("Restored; %d "
|
||||||
+ "missing chunks and %d other errors.",
|
+ "missing chunks and %d other errors.",
|
||||||
restore.getMissingChunks().size(),
|
restore.getMissingChunks().size(),
|
||||||
restore.getErrorChunks().size()));
|
restore.getErrorChunks().size()));
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
chunkStore.close();
|
chunkStore.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,105 +1,105 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.tools.AreaPickaxe;
|
import com.sk89q.worldedit.command.tool.AreaPickaxe;
|
||||||
import com.sk89q.worldedit.tools.RecursivePickaxe;
|
import com.sk89q.worldedit.command.tool.RecursivePickaxe;
|
||||||
import com.sk89q.worldedit.tools.SinglePickaxe;
|
import com.sk89q.worldedit.command.tool.SinglePickaxe;
|
||||||
|
|
||||||
public class SuperPickaxeCommands {
|
public class SuperPickaxeCommands {
|
||||||
private final WorldEdit we;
|
private final WorldEdit we;
|
||||||
|
|
||||||
public SuperPickaxeCommands(WorldEdit we) {
|
public SuperPickaxeCommands(WorldEdit we) {
|
||||||
this.we = we;
|
this.we = we;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "single" },
|
aliases = { "single" },
|
||||||
usage = "",
|
usage = "",
|
||||||
desc = "Enable the single block super pickaxe mode",
|
desc = "Enable the single block super pickaxe mode",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.superpickaxe")
|
@CommandPermissions("worldedit.superpickaxe")
|
||||||
public void single(CommandContext args, LocalSession session, LocalPlayer player,
|
public void single(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
session.setSuperPickaxe(new SinglePickaxe());
|
session.setSuperPickaxe(new SinglePickaxe());
|
||||||
session.enableSuperPickAxe();
|
session.enableSuperPickAxe();
|
||||||
player.print("Mode changed. Left click with a pickaxe. // to disable.");
|
player.print("Mode changed. Left click with a pickaxe. // to disable.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "area" },
|
aliases = { "area" },
|
||||||
usage = "<radius>",
|
usage = "<radius>",
|
||||||
desc = "Enable the area super pickaxe pickaxe mode",
|
desc = "Enable the area super pickaxe pickaxe mode",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.superpickaxe.area")
|
@CommandPermissions("worldedit.superpickaxe.area")
|
||||||
public void area(CommandContext args, LocalSession session, LocalPlayer player,
|
public void area(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
LocalConfiguration config = we.getConfiguration();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
int range = args.getInteger(0);
|
int range = args.getInteger(0);
|
||||||
|
|
||||||
if (range > config.maxSuperPickaxeSize) {
|
if (range > config.maxSuperPickaxeSize) {
|
||||||
player.printError("Maximum range: " + config.maxSuperPickaxeSize);
|
player.printError("Maximum range: " + config.maxSuperPickaxeSize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.setSuperPickaxe(new AreaPickaxe(range));
|
session.setSuperPickaxe(new AreaPickaxe(range));
|
||||||
session.enableSuperPickAxe();
|
session.enableSuperPickAxe();
|
||||||
player.print("Mode changed. Left click with a pickaxe. // to disable.");
|
player.print("Mode changed. Left click with a pickaxe. // to disable.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "recur", "recursive" },
|
aliases = { "recur", "recursive" },
|
||||||
usage = "<radius>",
|
usage = "<radius>",
|
||||||
desc = "Enable the recursive super pickaxe pickaxe mode",
|
desc = "Enable the recursive super pickaxe pickaxe mode",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.superpickaxe.recursive")
|
@CommandPermissions("worldedit.superpickaxe.recursive")
|
||||||
public void recursive(CommandContext args, LocalSession session, LocalPlayer player,
|
public void recursive(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
LocalConfiguration config = we.getConfiguration();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
double range = args.getDouble(0);
|
double range = args.getDouble(0);
|
||||||
|
|
||||||
if (range > config.maxSuperPickaxeSize) {
|
if (range > config.maxSuperPickaxeSize) {
|
||||||
player.printError("Maximum range: " + config.maxSuperPickaxeSize);
|
player.printError("Maximum range: " + config.maxSuperPickaxeSize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.setSuperPickaxe(new RecursivePickaxe(range));
|
session.setSuperPickaxe(new RecursivePickaxe(range));
|
||||||
session.enableSuperPickAxe();
|
session.enableSuperPickAxe();
|
||||||
player.print("Mode changed. Left click with a pickaxe. // to disable.");
|
player.print("Mode changed. Left click with a pickaxe. // to disable.");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,212 +1,212 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.minecraft.util.commands.NestedCommand;
|
import com.sk89q.minecraft.util.commands.NestedCommand;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.ItemType;
|
import com.sk89q.worldedit.blocks.ItemType;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.patterns.Pattern;
|
||||||
import com.sk89q.worldedit.tools.*;
|
import com.sk89q.worldedit.command.tool.*;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
|
|
||||||
public class ToolCommands {
|
public class ToolCommands {
|
||||||
private final WorldEdit we;
|
private final WorldEdit we;
|
||||||
|
|
||||||
public ToolCommands(WorldEdit we) {
|
public ToolCommands(WorldEdit we) {
|
||||||
this.we = we;
|
this.we = we;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "none" },
|
aliases = { "none" },
|
||||||
usage = "",
|
usage = "",
|
||||||
desc = "Unbind a bound tool from your current item",
|
desc = "Unbind a bound tool from your current item",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
public void none(CommandContext args, LocalSession session, LocalPlayer player,
|
public void none(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
session.setTool(player.getItemInHand(), null);
|
session.setTool(player.getItemInHand(), null);
|
||||||
player.print("Tool unbound from your current item.");
|
player.print("Tool unbound from your current item.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "info" },
|
aliases = { "info" },
|
||||||
usage = "",
|
usage = "",
|
||||||
desc = "Block information tool",
|
desc = "Block information tool",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.tool.info")
|
@CommandPermissions("worldedit.tool.info")
|
||||||
public void info(CommandContext args, LocalSession session, LocalPlayer player,
|
public void info(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
session.setTool(player.getItemInHand(), new QueryTool());
|
session.setTool(player.getItemInHand(), new QueryTool());
|
||||||
player.print("Info tool bound to "
|
player.print("Info tool bound to "
|
||||||
+ ItemType.toHeldName(player.getItemInHand()) + ".");
|
+ ItemType.toHeldName(player.getItemInHand()) + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "tree" },
|
aliases = { "tree" },
|
||||||
usage = "[type]",
|
usage = "[type]",
|
||||||
desc = "Tree generator tool",
|
desc = "Tree generator tool",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.tool.tree")
|
@CommandPermissions("worldedit.tool.tree")
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void tree(CommandContext args, LocalSession session, LocalPlayer player,
|
public void tree(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
TreeGenerator.TreeType type = args.argsLength() > 0 ?
|
TreeGenerator.TreeType type = args.argsLength() > 0 ?
|
||||||
type = TreeGenerator.lookup(args.getString(0))
|
type = TreeGenerator.lookup(args.getString(0))
|
||||||
: TreeGenerator.TreeType.TREE;
|
: TreeGenerator.TreeType.TREE;
|
||||||
|
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
player.printError("Tree type '" + args.getString(0) + "' is unknown.");
|
player.printError("Tree type '" + args.getString(0) + "' is unknown.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.setTool(player.getItemInHand(), new TreePlanter(new TreeGenerator(type)));
|
session.setTool(player.getItemInHand(), new TreePlanter(new TreeGenerator(type)));
|
||||||
player.print("Tree tool bound to "
|
player.print("Tree tool bound to "
|
||||||
+ ItemType.toHeldName(player.getItemInHand()) + ".");
|
+ ItemType.toHeldName(player.getItemInHand()) + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "repl" },
|
aliases = { "repl" },
|
||||||
usage = "<block>",
|
usage = "<block>",
|
||||||
desc = "Block replacer tool",
|
desc = "Block replacer tool",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.tool.replacer")
|
@CommandPermissions("worldedit.tool.replacer")
|
||||||
public void repl(CommandContext args, LocalSession session, LocalPlayer player,
|
public void repl(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
BaseBlock targetBlock = we.getBlock(player, args.getString(0));
|
BaseBlock targetBlock = we.getBlock(player, args.getString(0));
|
||||||
session.setTool(player.getItemInHand(), new BlockReplacer(targetBlock));
|
session.setTool(player.getItemInHand(), new BlockReplacer(targetBlock));
|
||||||
player.print("Block replacer tool bound to "
|
player.print("Block replacer tool bound to "
|
||||||
+ ItemType.toHeldName(player.getItemInHand()) + ".");
|
+ ItemType.toHeldName(player.getItemInHand()) + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "cycler" },
|
aliases = { "cycler" },
|
||||||
usage = "",
|
usage = "",
|
||||||
desc = "Block data cycler tool",
|
desc = "Block data cycler tool",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.tool.data-cycler")
|
@CommandPermissions("worldedit.tool.data-cycler")
|
||||||
public void cycler(CommandContext args, LocalSession session, LocalPlayer player,
|
public void cycler(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
session.setTool(player.getItemInHand(), new BlockDataCyler());
|
session.setTool(player.getItemInHand(), new BlockDataCyler());
|
||||||
player.print("Block data cycler tool bound to "
|
player.print("Block data cycler tool bound to "
|
||||||
+ ItemType.toHeldName(player.getItemInHand()) + ".");
|
+ ItemType.toHeldName(player.getItemInHand()) + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "floodfill", "flood" },
|
aliases = { "floodfill", "flood" },
|
||||||
usage = "<pattern> <range>",
|
usage = "<pattern> <range>",
|
||||||
desc = "Flood fill tool",
|
desc = "Flood fill tool",
|
||||||
min = 2,
|
min = 2,
|
||||||
max = 2
|
max = 2
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.tool.flood-fill")
|
@CommandPermissions("worldedit.tool.flood-fill")
|
||||||
public void floodFill(CommandContext args, LocalSession session, LocalPlayer player,
|
public void floodFill(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
LocalConfiguration config = we.getConfiguration();
|
LocalConfiguration config = we.getConfiguration();
|
||||||
int range = args.getInteger(1);
|
int range = args.getInteger(1);
|
||||||
|
|
||||||
if (range > config.maxSuperPickaxeSize) {
|
if (range > config.maxSuperPickaxeSize) {
|
||||||
player.printError("Maximum range: " + config.maxSuperPickaxeSize);
|
player.printError("Maximum range: " + config.maxSuperPickaxeSize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
||||||
session.setTool(player.getItemInHand(), new FloodFillTool(range, pattern));
|
session.setTool(player.getItemInHand(), new FloodFillTool(range, pattern));
|
||||||
player.print("Block flood fill tool bound to "
|
player.print("Block flood fill tool bound to "
|
||||||
+ ItemType.toHeldName(player.getItemInHand()) + ".");
|
+ ItemType.toHeldName(player.getItemInHand()) + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "brush", "br" },
|
aliases = { "brush", "br" },
|
||||||
desc = "Brush tool"
|
desc = "Brush tool"
|
||||||
)
|
)
|
||||||
@NestedCommand(BrushCommands.class)
|
@NestedCommand(BrushCommands.class)
|
||||||
public void brush(CommandContext args, LocalSession session, LocalPlayer player,
|
public void brush(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "deltree" },
|
aliases = { "deltree" },
|
||||||
usage = "",
|
usage = "",
|
||||||
desc = "Floating tree remover tool",
|
desc = "Floating tree remover tool",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.tool.deltree")
|
@CommandPermissions("worldedit.tool.deltree")
|
||||||
public void deltree(CommandContext args, LocalSession session, LocalPlayer player,
|
public void deltree(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
session.setTool(player.getItemInHand(), new FloatingTreeRemover());
|
session.setTool(player.getItemInHand(), new FloatingTreeRemover());
|
||||||
player.print("Floating tree remover tool bound to "
|
player.print("Floating tree remover tool bound to "
|
||||||
+ ItemType.toHeldName(player.getItemInHand()) + ".");
|
+ ItemType.toHeldName(player.getItemInHand()) + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "farwand" },
|
aliases = { "farwand" },
|
||||||
usage = "",
|
usage = "",
|
||||||
desc = "Wand at a distance tool",
|
desc = "Wand at a distance tool",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.tool.farwand")
|
@CommandPermissions("worldedit.tool.farwand")
|
||||||
public void farwand(CommandContext args, LocalSession session, LocalPlayer player,
|
public void farwand(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
session.setTool(player.getItemInHand(), new DistanceWand());
|
session.setTool(player.getItemInHand(), new DistanceWand());
|
||||||
player.print("Far wand tool bound to " + ItemType.toHeldName(player.getItemInHand()) + ".");
|
player.print("Far wand tool bound to " + ItemType.toHeldName(player.getItemInHand()) + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "lrbuild", "/lrbuild" },
|
aliases = { "lrbuild", "/lrbuild" },
|
||||||
usage = "<leftclick block> <rightclick block>",
|
usage = "<leftclick block> <rightclick block>",
|
||||||
desc = "Long-range building tool",
|
desc = "Long-range building tool",
|
||||||
min = 2,
|
min = 2,
|
||||||
max = 2
|
max = 2
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.tool.lrbuild")
|
@CommandPermissions("worldedit.tool.lrbuild")
|
||||||
public void longrangebuildtool(CommandContext args, LocalSession session, LocalPlayer player,
|
public void longrangebuildtool(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
BaseBlock secondary = we.getBlock(player, args.getString(0));
|
BaseBlock secondary = we.getBlock(player, args.getString(0));
|
||||||
BaseBlock primary = we.getBlock(player, args.getString(1));
|
BaseBlock primary = we.getBlock(player, args.getString(1));
|
||||||
session.setTool(player.getItemInHand(), new LongRangeBuildTool(primary, secondary));
|
session.setTool(player.getItemInHand(), new LongRangeBuildTool(primary, secondary));
|
||||||
player.print("Long-range building tool bound to " + ItemType.toHeldName(player.getItemInHand()) + ".");
|
player.print("Long-range building tool bound to " + ItemType.toHeldName(player.getItemInHand()) + ".");
|
||||||
player.print("Left-click set to " + ItemType.toName(secondary.getType()) + "; right-click set to "
|
player.print("Left-click set to " + ItemType.toName(secondary.getType()) + "; right-click set to "
|
||||||
+ ItemType.toName(primary.getType()) + ".");
|
+ ItemType.toName(primary.getType()) + ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,158 +1,158 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.minecraft.util.commands.NestedCommand;
|
import com.sk89q.minecraft.util.commands.NestedCommand;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.masks.Mask;
|
import com.sk89q.worldedit.masks.Mask;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.patterns.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tool commands.
|
* Tool commands.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class ToolUtilCommands {
|
public class ToolUtilCommands {
|
||||||
private final WorldEdit we;
|
private final WorldEdit we;
|
||||||
|
|
||||||
public ToolUtilCommands(WorldEdit we) {
|
public ToolUtilCommands(WorldEdit we) {
|
||||||
this.we = we;
|
this.we = we;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "/", "," },
|
aliases = { "/", "," },
|
||||||
usage = "[on|off]",
|
usage = "[on|off]",
|
||||||
desc = "Toggle the super pickaxe pickaxe function",
|
desc = "Toggle the super pickaxe pickaxe function",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.superpickaxe")
|
@CommandPermissions("worldedit.superpickaxe")
|
||||||
public void togglePickaxe(CommandContext args, LocalSession session, LocalPlayer player,
|
public void togglePickaxe(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
String newState = args.getString(0, null);
|
String newState = args.getString(0, null);
|
||||||
if (session.hasSuperPickAxe()) {
|
if (session.hasSuperPickAxe()) {
|
||||||
if ("on".equals(newState)) {
|
if ("on".equals(newState)) {
|
||||||
player.printError("Super pick axe already enabled.");
|
player.printError("Super pick axe already enabled.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
session.disableSuperPickAxe();
|
session.disableSuperPickAxe();
|
||||||
player.print("Super pick axe disabled.");
|
player.print("Super pick axe disabled.");
|
||||||
} else {
|
} else {
|
||||||
if ("off".equals(newState)) {
|
if ("off".equals(newState)) {
|
||||||
player.printError("Super pick axe already disabled.");
|
player.printError("Super pick axe already disabled.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
session.enableSuperPickAxe();
|
session.enableSuperPickAxe();
|
||||||
player.print("Super pick axe enabled.");
|
player.print("Super pick axe enabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "superpickaxe", "pickaxe", "sp" },
|
aliases = { "superpickaxe", "pickaxe", "sp" },
|
||||||
desc = "Select super pickaxe mode"
|
desc = "Select super pickaxe mode"
|
||||||
)
|
)
|
||||||
@NestedCommand(SuperPickaxeCommands.class)
|
@NestedCommand(SuperPickaxeCommands.class)
|
||||||
public void pickaxe(CommandContext args, LocalSession session, LocalPlayer player,
|
public void pickaxe(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = {"tool"},
|
aliases = {"tool"},
|
||||||
desc = "Select a tool to bind"
|
desc = "Select a tool to bind"
|
||||||
)
|
)
|
||||||
@NestedCommand(ToolCommands.class)
|
@NestedCommand(ToolCommands.class)
|
||||||
public void tool(CommandContext args, LocalSession session, LocalPlayer player,
|
public void tool(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "mask" },
|
aliases = { "mask" },
|
||||||
usage = "[mask]",
|
usage = "[mask]",
|
||||||
desc = "Set the brush mask",
|
desc = "Set the brush mask",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = -1
|
max = -1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.options.mask")
|
@CommandPermissions("worldedit.brush.options.mask")
|
||||||
public void mask(CommandContext args, LocalSession session, LocalPlayer player,
|
public void mask(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
if (args.argsLength() == 0) {
|
if (args.argsLength() == 0) {
|
||||||
session.getBrushTool(player.getItemInHand()).setMask(null);
|
session.getBrushTool(player.getItemInHand()).setMask(null);
|
||||||
player.print("Brush mask disabled.");
|
player.print("Brush mask disabled.");
|
||||||
} else {
|
} else {
|
||||||
Mask mask = we.getBlockMask(player, session, args.getJoinedStrings(0));
|
Mask mask = we.getBlockMask(player, session, args.getJoinedStrings(0));
|
||||||
session.getBrushTool(player.getItemInHand()).setMask(mask);
|
session.getBrushTool(player.getItemInHand()).setMask(mask);
|
||||||
player.print("Brush mask set.");
|
player.print("Brush mask set.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "mat", "material" },
|
aliases = { "mat", "material" },
|
||||||
usage = "[pattern]",
|
usage = "[pattern]",
|
||||||
desc = "Set the brush material",
|
desc = "Set the brush material",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.options.material")
|
@CommandPermissions("worldedit.brush.options.material")
|
||||||
public void material(CommandContext args, LocalSession session, LocalPlayer player,
|
public void material(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
Pattern pattern = we.getBlockPattern(player, args.getString(0));
|
||||||
session.getBrushTool(player.getItemInHand()).setFill(pattern);
|
session.getBrushTool(player.getItemInHand()).setFill(pattern);
|
||||||
player.print("Brush material set.");
|
player.print("Brush material set.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "range" },
|
aliases = { "range" },
|
||||||
usage = "[pattern]",
|
usage = "[pattern]",
|
||||||
desc = "Set the brush range",
|
desc = "Set the brush range",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.options.range")
|
@CommandPermissions("worldedit.brush.options.range")
|
||||||
public void range(CommandContext args, LocalSession session, LocalPlayer player,
|
public void range(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
int range = args.getInteger(0);
|
int range = args.getInteger(0);
|
||||||
session.getBrushTool(player.getItemInHand()).setRange(range);
|
session.getBrushTool(player.getItemInHand()).setRange(range);
|
||||||
player.print("Brush range set.");
|
player.print("Brush range set.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "size" },
|
aliases = { "size" },
|
||||||
usage = "[pattern]",
|
usage = "[pattern]",
|
||||||
desc = "Set the brush size",
|
desc = "Set the brush size",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.brush.options.size")
|
@CommandPermissions("worldedit.brush.options.size")
|
||||||
public void size(CommandContext args, LocalSession session, LocalPlayer player,
|
public void size(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
int radius = args.getInteger(0);
|
int radius = args.getInteger(0);
|
||||||
we.checkMaxBrushRadius(radius);
|
we.checkMaxBrushRadius(radius);
|
||||||
|
|
||||||
session.getBrushTool(player.getItemInHand()).setSize(radius);
|
session.getBrushTool(player.getItemInHand()).setSize(radius);
|
||||||
player.print("Brush size set.");
|
player.print("Brush size set.");
|
||||||
}
|
}
|
||||||
}
|
}
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -1,120 +1,120 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.commands;
|
package com.sk89q.worldedit.command;
|
||||||
|
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||||
import com.sk89q.minecraft.util.commands.Console;
|
import com.sk89q.minecraft.util.commands.Console;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
|
||||||
public class WorldEditCommands {
|
public class WorldEditCommands {
|
||||||
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
|
private static final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
|
||||||
|
|
||||||
private final WorldEdit we;
|
private final WorldEdit we;
|
||||||
|
|
||||||
public WorldEditCommands(WorldEdit we) {
|
public WorldEditCommands(WorldEdit we) {
|
||||||
this.we = we;
|
this.we = we;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "version", "ver" },
|
aliases = { "version", "ver" },
|
||||||
usage = "",
|
usage = "",
|
||||||
desc = "Get WorldEdit version",
|
desc = "Get WorldEdit version",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@Console
|
@Console
|
||||||
public void version(CommandContext args, LocalSession session, LocalPlayer player,
|
public void version(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
player.print("WorldEdit version " + WorldEdit.getVersion());
|
player.print("WorldEdit version " + WorldEdit.getVersion());
|
||||||
player.print("http://www.sk89q.com/projects/worldedit/");
|
player.print("http://www.sk89q.com/projects/worldedit/");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "reload" },
|
aliases = { "reload" },
|
||||||
usage = "",
|
usage = "",
|
||||||
desc = "Reload WorldEdit",
|
desc = "Reload WorldEdit",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.reload")
|
@CommandPermissions("worldedit.reload")
|
||||||
@Console
|
@Console
|
||||||
public void reload(CommandContext args, LocalSession session, LocalPlayer player,
|
public void reload(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
we.getServer().reload();
|
we.getServer().reload();
|
||||||
player.print("Configuration reloaded!");
|
player.print("Configuration reloaded!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "cui" },
|
aliases = { "cui" },
|
||||||
usage = "",
|
usage = "",
|
||||||
desc = "Complete CUI handshake",
|
desc = "Complete CUI handshake",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = 0
|
max = 0
|
||||||
)
|
)
|
||||||
public void cui(CommandContext args, LocalSession session, LocalPlayer player,
|
public void cui(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
session.setCUISupport(true);
|
session.setCUISupport(true);
|
||||||
session.dispatchCUISetup(player);
|
session.dispatchCUISetup(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "tz" },
|
aliases = { "tz" },
|
||||||
usage = "[timezone]",
|
usage = "[timezone]",
|
||||||
desc = "Set your timezone",
|
desc = "Set your timezone",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
@Console
|
@Console
|
||||||
public void tz(CommandContext args, LocalSession session, LocalPlayer player,
|
public void tz(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
TimeZone tz = TimeZone.getTimeZone(args.getString(0));
|
TimeZone tz = TimeZone.getTimeZone(args.getString(0));
|
||||||
session.setTimezone(tz);
|
session.setTimezone(tz);
|
||||||
player.print("Timezone set for this session to: " + tz.getDisplayName());
|
player.print("Timezone set for this session to: " + tz.getDisplayName());
|
||||||
player.print("The current time in that timezone is: "
|
player.print("The current time in that timezone is: "
|
||||||
+ dateFormat.format(Calendar.getInstance(tz).getTime()));
|
+ dateFormat.format(Calendar.getInstance(tz).getTime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
aliases = { "help" },
|
aliases = { "help" },
|
||||||
usage = "[<command>]",
|
usage = "[<command>]",
|
||||||
desc = "Displays help for the given command or lists all commands.",
|
desc = "Displays help for the given command or lists all commands.",
|
||||||
min = 0,
|
min = 0,
|
||||||
max = -1
|
max = -1
|
||||||
)
|
)
|
||||||
@CommandPermissions("worldedit.help")
|
@CommandPermissions("worldedit.help")
|
||||||
@Console
|
@Console
|
||||||
public void help(CommandContext args, LocalSession session, LocalPlayer player,
|
public void help(CommandContext args, LocalSession session, LocalPlayer player,
|
||||||
EditSession editSession) throws WorldEditException {
|
EditSession editSession) throws WorldEditException {
|
||||||
|
|
||||||
UtilityCommands.help(args, we, session, player, editSession);
|
UtilityCommands.help(args, we, session, player, editSession);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,87 +1,87 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A super pickaxe mode that will remove blocks in an area.
|
* A super pickaxe mode that will remove blocks in an area.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class AreaPickaxe implements BlockTool {
|
public class AreaPickaxe implements BlockTool {
|
||||||
private static final BaseBlock air = new BaseBlock(0);
|
private static final BaseBlock air = new BaseBlock(0);
|
||||||
private int range;
|
private int range;
|
||||||
|
|
||||||
public AreaPickaxe(int range) {
|
public AreaPickaxe(int range) {
|
||||||
this.range = range;
|
this.range = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUse(LocalPlayer player) {
|
public boolean canUse(LocalPlayer player) {
|
||||||
return player.hasPermission("worldedit.superpickaxe.area");
|
return player.hasPermission("worldedit.superpickaxe.area");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||||
LocalWorld world = clicked.getWorld();
|
LocalWorld world = clicked.getWorld();
|
||||||
int ox = clicked.getBlockX();
|
int ox = clicked.getBlockX();
|
||||||
int oy = clicked.getBlockY();
|
int oy = clicked.getBlockY();
|
||||||
int oz = clicked.getBlockZ();
|
int oz = clicked.getBlockZ();
|
||||||
int initialType = world.getBlockType(clicked);
|
int initialType = world.getBlockType(clicked);
|
||||||
|
|
||||||
if (initialType == 0) {
|
if (initialType == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) {
|
if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditSession editSession = session.createEditSession(player);
|
EditSession editSession = session.createEditSession(player);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (int x = ox - range; x <= ox + range; ++x) {
|
for (int x = ox - range; x <= ox + range; ++x) {
|
||||||
for (int y = oy - range; y <= oy + range; ++y) {
|
for (int y = oy - range; y <= oy + range; ++y) {
|
||||||
for (int z = oz - range; z <= oz + range; ++z) {
|
for (int z = oz - range; z <= oz + range; ++z) {
|
||||||
Vector pos = new Vector(x, y, z);
|
Vector pos = new Vector(x, y, z);
|
||||||
if (world.getBlockType(pos) != initialType) {
|
if (world.getBlockType(pos) != initialType) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (config.superPickaxeManyDrop) {
|
if (config.superPickaxeManyDrop) {
|
||||||
world.simulateBlockMine(pos);
|
world.simulateBlockMine(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
world.queueBlockBreakEffect(server, pos, initialType, clicked.distanceSq(pos));
|
world.queueBlockBreakEffect(server, pos, initialType, clicked.distanceSq(pos));
|
||||||
|
|
||||||
editSession.setBlock(pos, air);
|
editSession.setBlock(pos, air);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
player.printError("Max blocks change limit reached.");
|
player.printError("Max blocks change limit reached.");
|
||||||
} finally {
|
} finally {
|
||||||
session.remember(editSession);
|
session.remember(editSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,74 +1,74 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mode that cycles the data values of supported blocks.
|
* A mode that cycles the data values of supported blocks.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class BlockDataCyler implements DoubleActionBlockTool {
|
public class BlockDataCyler implements DoubleActionBlockTool {
|
||||||
|
|
||||||
public boolean canUse(LocalPlayer player) {
|
public boolean canUse(LocalPlayer player) {
|
||||||
return player.hasPermission("worldedit.tool.data-cycler");
|
return player.hasPermission("worldedit.tool.data-cycler");
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean handleCycle(ServerInterface server, LocalConfiguration config,
|
private boolean handleCycle(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked, boolean forward) {
|
LocalPlayer player, LocalSession session, WorldVector clicked, boolean forward) {
|
||||||
|
|
||||||
LocalWorld world = clicked.getWorld();
|
LocalWorld world = clicked.getWorld();
|
||||||
|
|
||||||
int type = world.getBlockType(clicked);
|
int type = world.getBlockType(clicked);
|
||||||
int data = world.getBlockData(clicked);
|
int data = world.getBlockData(clicked);
|
||||||
|
|
||||||
if (config.allowedDataCycleBlocks.size() > 0
|
if (config.allowedDataCycleBlocks.size() > 0
|
||||||
&& !player.hasPermission("worldedit.override.data-cycler")
|
&& !player.hasPermission("worldedit.override.data-cycler")
|
||||||
&& !config.allowedDataCycleBlocks.contains(type)) {
|
&& !config.allowedDataCycleBlocks.contains(type)) {
|
||||||
player.printError("You are not permitted to cycle the data value of that block.");
|
player.printError("You are not permitted to cycle the data value of that block.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int increment = forward ? 1 : -1;
|
int increment = forward ? 1 : -1;
|
||||||
data = (new BaseBlock(type, data)).cycleData(increment);
|
data = (new BaseBlock(type, data)).cycleData(increment);
|
||||||
|
|
||||||
if (data < 0) {
|
if (data < 0) {
|
||||||
player.printError("That block's data cannot be cycled!");
|
player.printError("That block's data cannot be cycled!");
|
||||||
} else {
|
} else {
|
||||||
world.setBlockData(clicked, data);
|
world.setBlockData(clicked, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||||
return handleCycle(server, config, player, session, clicked, true);
|
return handleCycle(server, config, player, session, clicked, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actSecondary(ServerInterface server,
|
public boolean actSecondary(ServerInterface server,
|
||||||
LocalConfiguration config, LocalPlayer player,
|
LocalConfiguration config, LocalPlayer player,
|
||||||
LocalSession session, WorldVector clicked) {
|
LocalSession session, WorldVector clicked) {
|
||||||
return handleCycle(server, config, player, session, clicked, false);
|
return handleCycle(server, config, player, session, clicked, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,80 +1,80 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.bags.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockType;
|
import com.sk89q.worldedit.blocks.BlockType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mode that replaces one block.
|
* A mode that replaces one block.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class BlockReplacer implements DoubleActionBlockTool {
|
public class BlockReplacer implements DoubleActionBlockTool {
|
||||||
private BaseBlock targetBlock;
|
private BaseBlock targetBlock;
|
||||||
|
|
||||||
public BlockReplacer(BaseBlock targetBlock) {
|
public BlockReplacer(BaseBlock targetBlock) {
|
||||||
this.targetBlock = targetBlock;
|
this.targetBlock = targetBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUse(LocalPlayer player) {
|
public boolean canUse(LocalPlayer player) {
|
||||||
return player.hasPermission("worldedit.tool.replacer");
|
return player.hasPermission("worldedit.tool.replacer");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||||
|
|
||||||
BlockBag bag = session.getBlockBag(player);
|
BlockBag bag = session.getBlockBag(player);
|
||||||
|
|
||||||
LocalWorld world = clicked.getWorld();
|
LocalWorld world = clicked.getWorld();
|
||||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, bag, player);
|
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, bag, player);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
editSession.setBlock(clicked, targetBlock);
|
editSession.setBlock(clicked, targetBlock);
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
} finally {
|
} finally {
|
||||||
if (bag != null) {
|
if (bag != null) {
|
||||||
bag.flushChanges();
|
bag.flushChanges();
|
||||||
}
|
}
|
||||||
session.remember(editSession);
|
session.remember(editSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actSecondary(ServerInterface server,
|
public boolean actSecondary(ServerInterface server,
|
||||||
LocalConfiguration config, LocalPlayer player,
|
LocalConfiguration config, LocalPlayer player,
|
||||||
LocalSession session, WorldVector clicked) {
|
LocalSession session, WorldVector clicked) {
|
||||||
|
|
||||||
LocalWorld world = clicked.getWorld();
|
LocalWorld world = clicked.getWorld();
|
||||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, player);
|
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, -1, player);
|
||||||
targetBlock = (editSession).getBlock(clicked);
|
targetBlock = (editSession).getBlock(clicked);
|
||||||
BlockType type = BlockType.fromID(targetBlock.getType());
|
BlockType type = BlockType.fromID(targetBlock.getType());
|
||||||
|
|
||||||
if (type != null) {
|
if (type != null) {
|
||||||
player.print("Replacer tool switched to: " + type.getName());
|
player.print("Replacer tool switched to: " + type.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,43 +1,43 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a tool that uses a block..
|
* Represents a tool that uses a block..
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public interface BlockTool extends Tool {
|
public interface BlockTool extends Tool {
|
||||||
/**
|
/**
|
||||||
* Perform the action. Should return true to deny the default
|
* Perform the action. Should return true to deny the default
|
||||||
* action.
|
* action.
|
||||||
*
|
*
|
||||||
* @param server
|
* @param server
|
||||||
* @param config
|
* @param config
|
||||||
* @param player
|
* @param player
|
||||||
* @param session
|
* @param session
|
||||||
* @param clicked
|
* @param clicked
|
||||||
* @return true to deny
|
* @return true to deny
|
||||||
*/
|
*/
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked);
|
LocalPlayer player, LocalSession session, WorldVector clicked);
|
||||||
}
|
}
|
@ -1,208 +1,208 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.bags.BlockBag;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
import com.sk89q.worldedit.masks.CombinedMask;
|
import com.sk89q.worldedit.masks.CombinedMask;
|
||||||
import com.sk89q.worldedit.masks.Mask;
|
import com.sk89q.worldedit.masks.Mask;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.patterns.Pattern;
|
||||||
import com.sk89q.worldedit.patterns.SingleBlockPattern;
|
import com.sk89q.worldedit.patterns.SingleBlockPattern;
|
||||||
import com.sk89q.worldedit.tools.brushes.Brush;
|
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||||
import com.sk89q.worldedit.tools.brushes.SphereBrush;
|
import com.sk89q.worldedit.command.tool.brush.SphereBrush;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a shape at the place being looked at.
|
* Builds a shape at the place being looked at.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class BrushTool implements TraceTool {
|
public class BrushTool implements TraceTool {
|
||||||
protected static int MAX_RANGE = 500;
|
protected static int MAX_RANGE = 500;
|
||||||
protected int range = -1;
|
protected int range = -1;
|
||||||
private Mask mask = null;
|
private Mask mask = null;
|
||||||
private Brush brush = new SphereBrush();
|
private Brush brush = new SphereBrush();
|
||||||
private Pattern material = new SingleBlockPattern(new BaseBlock(BlockID.COBBLESTONE));
|
private Pattern material = new SingleBlockPattern(new BaseBlock(BlockID.COBBLESTONE));
|
||||||
private double size = 1;
|
private double size = 1;
|
||||||
private String permission;
|
private String permission;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the tool.
|
* Construct the tool.
|
||||||
*
|
*
|
||||||
* @param permission
|
* @param permission
|
||||||
*/
|
*/
|
||||||
public BrushTool(String permission) {
|
public BrushTool(String permission) {
|
||||||
this.permission = permission;
|
this.permission = permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if the player can still be using this tool (considering
|
* Checks to see if the player can still be using this tool (considering
|
||||||
* permissions and such).
|
* permissions and such).
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean canUse(LocalPlayer player) {
|
public boolean canUse(LocalPlayer player) {
|
||||||
return player.hasPermission(permission);
|
return player.hasPermission(permission);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the filter.
|
* Get the filter.
|
||||||
*
|
*
|
||||||
* @return the filter
|
* @return the filter
|
||||||
*/
|
*/
|
||||||
public Mask getMask() {
|
public Mask getMask() {
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the block filter used for identifying blocks to replace.
|
* Set the block filter used for identifying blocks to replace.
|
||||||
*
|
*
|
||||||
* @param filter the filter to set
|
* @param filter the filter to set
|
||||||
*/
|
*/
|
||||||
public void setMask(Mask filter) {
|
public void setMask(Mask filter) {
|
||||||
this.mask = filter;
|
this.mask = filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the brush.
|
* Set the brush.
|
||||||
*
|
*
|
||||||
* @param brush
|
* @param brush
|
||||||
* @param perm
|
* @param perm
|
||||||
*/
|
*/
|
||||||
public void setBrush(Brush brush, String perm) {
|
public void setBrush(Brush brush, String perm) {
|
||||||
this.brush = brush;
|
this.brush = brush;
|
||||||
this.permission = perm;
|
this.permission = perm;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current brush.
|
* Get the current brush.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Brush getBrush() {
|
public Brush getBrush() {
|
||||||
return brush;
|
return brush;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the material.
|
* Set the material.
|
||||||
*
|
*
|
||||||
* @param material
|
* @param material
|
||||||
*/
|
*/
|
||||||
public void setFill(Pattern material) {
|
public void setFill(Pattern material) {
|
||||||
this.material = material;
|
this.material = material;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the material.
|
* Get the material.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Pattern getMaterial() {
|
public Pattern getMaterial() {
|
||||||
return material;
|
return material;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the set brush size.
|
* Get the set brush size.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public double getSize() {
|
public double getSize() {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the set brush size.
|
* Set the set brush size.
|
||||||
*
|
*
|
||||||
* @param radius
|
* @param radius
|
||||||
*/
|
*/
|
||||||
public void setSize(double radius) {
|
public void setSize(double radius) {
|
||||||
this.size = radius;
|
this.size = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the set brush range.
|
* Get the set brush range.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getRange() {
|
public int getRange() {
|
||||||
return (range < 0) ? MAX_RANGE : Math.min(range, MAX_RANGE);
|
return (range < 0) ? MAX_RANGE : Math.min(range, MAX_RANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the set brush range.
|
* Set the set brush range.
|
||||||
*
|
*
|
||||||
* @param size
|
* @param size
|
||||||
*/
|
*/
|
||||||
public void setRange(int range) {
|
public void setRange(int range) {
|
||||||
this.range = range;
|
this.range = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform the action. Should return true to deny the default
|
* Perform the action. Should return true to deny the default
|
||||||
* action.
|
* action.
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @param session
|
* @param session
|
||||||
* @return true to deny
|
* @return true to deny
|
||||||
*/
|
*/
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session) {
|
LocalPlayer player, LocalSession session) {
|
||||||
WorldVector target = null;
|
WorldVector target = null;
|
||||||
target = player.getBlockTrace(getRange(), true);
|
target = player.getBlockTrace(getRange(), true);
|
||||||
|
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
player.printError("No block in sight!");
|
player.printError("No block in sight!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockBag bag = session.getBlockBag(player);
|
BlockBag bag = session.getBlockBag(player);
|
||||||
|
|
||||||
EditSession editSession = session.createEditSession(player);
|
EditSession editSession = session.createEditSession(player);
|
||||||
if (mask != null) {
|
if (mask != null) {
|
||||||
mask.prepare(session, player, target);
|
mask.prepare(session, player, target);
|
||||||
Mask existingMask = editSession.getMask();
|
Mask existingMask = editSession.getMask();
|
||||||
if (existingMask == null) {
|
if (existingMask == null) {
|
||||||
editSession.setMask(mask);
|
editSession.setMask(mask);
|
||||||
} else if (existingMask instanceof CombinedMask) {
|
} else if (existingMask instanceof CombinedMask) {
|
||||||
((CombinedMask) existingMask).add(mask);
|
((CombinedMask) existingMask).add(mask);
|
||||||
} else {
|
} else {
|
||||||
CombinedMask newMask = new CombinedMask(existingMask);
|
CombinedMask newMask = new CombinedMask(existingMask);
|
||||||
newMask.add(mask);
|
newMask.add(mask);
|
||||||
editSession.setMask(newMask);
|
editSession.setMask(newMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
brush.build(editSession, target, material, size);
|
brush.build(editSession, target, material, size);
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
player.printError("Max blocks change limit reached.");
|
player.printError("Max blocks change limit reached.");
|
||||||
} finally {
|
} finally {
|
||||||
if (bag != null) {
|
if (bag != null) {
|
||||||
bag.flushChanges();
|
bag.flushChanges();
|
||||||
}
|
}
|
||||||
session.remember(editSession);
|
session.remember(editSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,90 +1,90 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.regions.RegionSelector;
|
import com.sk89q.worldedit.regions.RegionSelector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A wand that can be used at a distance.
|
* A wand that can be used at a distance.
|
||||||
*
|
*
|
||||||
* @author wizjany
|
* @author wizjany
|
||||||
*/
|
*/
|
||||||
public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
|
public class DistanceWand extends BrushTool implements DoubleActionTraceTool {
|
||||||
|
|
||||||
public DistanceWand() {
|
public DistanceWand() {
|
||||||
super("worldedit.wand");
|
super("worldedit.wand");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canUse(LocalPlayer player) {
|
public boolean canUse(LocalPlayer player) {
|
||||||
return player.hasPermission("worldedit.wand");
|
return player.hasPermission("worldedit.wand");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actSecondary(ServerInterface server, LocalConfiguration config,
|
public boolean actSecondary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session) {
|
LocalPlayer player, LocalSession session) {
|
||||||
if (session.isToolControlEnabled() && player.hasPermission("worldedit.selection.pos")) {
|
if (session.isToolControlEnabled() && player.hasPermission("worldedit.selection.pos")) {
|
||||||
WorldVector target = getTarget(player);
|
WorldVector target = getTarget(player);
|
||||||
if (target == null) return true;
|
if (target == null) return true;
|
||||||
|
|
||||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||||
if (selector.selectPrimary(target)) {
|
if (selector.selectPrimary(target)) {
|
||||||
selector.explainPrimarySelection(player, session, target);
|
selector.explainPrimarySelection(player, session, target);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session) {
|
LocalPlayer player, LocalSession session) {
|
||||||
if (session.isToolControlEnabled() && player.hasPermission("worldedit.selection.pos")) {
|
if (session.isToolControlEnabled() && player.hasPermission("worldedit.selection.pos")) {
|
||||||
WorldVector target = getTarget(player);
|
WorldVector target = getTarget(player);
|
||||||
if (target == null) return true;
|
if (target == null) return true;
|
||||||
|
|
||||||
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
RegionSelector selector = session.getRegionSelector(player.getWorld());
|
||||||
if (selector.selectSecondary(target)) {
|
if (selector.selectSecondary(target)) {
|
||||||
selector.explainSecondarySelection(player, session, target);
|
selector.explainSecondarySelection(player, session, target);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldVector getTarget(LocalPlayer player) {
|
public WorldVector getTarget(LocalPlayer player) {
|
||||||
WorldVector target = null;
|
WorldVector target = null;
|
||||||
if (this.range > -1) {
|
if (this.range > -1) {
|
||||||
target = player.getBlockTrace(getRange(), true);
|
target = player.getBlockTrace(getRange(), true);
|
||||||
} else {
|
} else {
|
||||||
target = player.getBlockTrace(MAX_RANGE);
|
target = player.getBlockTrace(MAX_RANGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
player.printError("No block in sight!");
|
player.printError("No block in sight!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,47 +1,47 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.ServerInterface;
|
import com.sk89q.worldedit.ServerInterface;
|
||||||
import com.sk89q.worldedit.WorldVector;
|
import com.sk89q.worldedit.WorldVector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a block tool that also has a secondary/primary function.
|
* Represents a block tool that also has a secondary/primary function.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public interface DoubleActionBlockTool extends BlockTool {
|
public interface DoubleActionBlockTool extends BlockTool {
|
||||||
/**
|
/**
|
||||||
* Perform the secondary action. Should return true to deny the default
|
* Perform the secondary action. Should return true to deny the default
|
||||||
* action.
|
* action.
|
||||||
*
|
*
|
||||||
* @param server
|
* @param server
|
||||||
* @param config
|
* @param config
|
||||||
* @param player
|
* @param player
|
||||||
* @param session
|
* @param session
|
||||||
* @param clicked
|
* @param clicked
|
||||||
* @return true to deny
|
* @return true to deny
|
||||||
*/
|
*/
|
||||||
public boolean actSecondary(ServerInterface server, LocalConfiguration config,
|
public boolean actSecondary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked);
|
LocalPlayer player, LocalSession session, WorldVector clicked);
|
||||||
}
|
}
|
@ -1,43 +1,43 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.ServerInterface;
|
import com.sk89q.worldedit.ServerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a trace tool that also has a secondary/primary function.
|
* Represents a trace tool that also has a secondary/primary function.
|
||||||
*/
|
*/
|
||||||
public interface DoubleActionTraceTool extends TraceTool {
|
public interface DoubleActionTraceTool extends TraceTool {
|
||||||
/**
|
/**
|
||||||
* Perform the secondary action. Should return true to deny the default
|
* Perform the secondary action. Should return true to deny the default
|
||||||
* action.
|
* action.
|
||||||
*
|
*
|
||||||
* @param server
|
* @param server
|
||||||
* @param config
|
* @param config
|
||||||
* @param player
|
* @param player
|
||||||
* @param session
|
* @param session
|
||||||
* @return true to deny
|
* @return true to deny
|
||||||
*/
|
*/
|
||||||
public boolean actSecondary(ServerInterface server, LocalConfiguration config,
|
public boolean actSecondary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session);
|
LocalPlayer player, LocalSession session);
|
||||||
}
|
}
|
332
src/main/java/com/sk89q/worldedit/tools/FloatingTreeRemover.java → src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java
Ausführbare Datei → Normale Datei
332
src/main/java/com/sk89q/worldedit/tools/FloatingTreeRemover.java → src/main/java/com/sk89q/worldedit/command/tool/FloatingTreeRemover.java
Ausführbare Datei → Normale Datei
@ -1,166 +1,166 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A pickaxe mode that removes floating treetops (logs and leaves not connected
|
* A pickaxe mode that removes floating treetops (logs and leaves not connected
|
||||||
* to anything else)
|
* to anything else)
|
||||||
*
|
*
|
||||||
* @author Moo0
|
* @author Moo0
|
||||||
*/
|
*/
|
||||||
public class FloatingTreeRemover implements BlockTool {
|
public class FloatingTreeRemover implements BlockTool {
|
||||||
private static final BaseBlock AIR = new BaseBlock(BlockID.AIR);
|
private static final BaseBlock AIR = new BaseBlock(BlockID.AIR);
|
||||||
private int rangeSq;
|
private int rangeSq;
|
||||||
|
|
||||||
public FloatingTreeRemover() {
|
public FloatingTreeRemover() {
|
||||||
rangeSq = 100*100;
|
rangeSq = 100*100;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUse(LocalPlayer player) {
|
public boolean canUse(LocalPlayer player) {
|
||||||
return player.hasPermission("worldedit.tool.deltree");
|
return player.hasPermission("worldedit.tool.deltree");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||||
|
|
||||||
final LocalWorld world = clicked.getWorld();
|
final LocalWorld world = clicked.getWorld();
|
||||||
|
|
||||||
switch (world.getBlockType(clicked)) {
|
switch (world.getBlockType(clicked)) {
|
||||||
case BlockID.LOG:
|
case BlockID.LOG:
|
||||||
case BlockID.LOG2:
|
case BlockID.LOG2:
|
||||||
case BlockID.LEAVES:
|
case BlockID.LEAVES:
|
||||||
case BlockID.LEAVES2:
|
case BlockID.LEAVES2:
|
||||||
case BlockID.BROWN_MUSHROOM_CAP:
|
case BlockID.BROWN_MUSHROOM_CAP:
|
||||||
case BlockID.RED_MUSHROOM_CAP:
|
case BlockID.RED_MUSHROOM_CAP:
|
||||||
case BlockID.VINE:
|
case BlockID.VINE:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
player.printError("That's not a tree.");
|
player.printError("That's not a tree.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final EditSession editSession = session.createEditSession(player);
|
final EditSession editSession = session.createEditSession(player);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final Set<Vector> blockSet = bfs(world, clicked);
|
final Set<Vector> blockSet = bfs(world, clicked);
|
||||||
if (blockSet == null) {
|
if (blockSet == null) {
|
||||||
player.printError("That's not a floating tree.");
|
player.printError("That's not a floating tree.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Vector blockVector : blockSet) {
|
for (Vector blockVector : blockSet) {
|
||||||
final int typeId = editSession.getBlock(blockVector).getType();
|
final int typeId = editSession.getBlock(blockVector).getType();
|
||||||
switch (typeId) {
|
switch (typeId) {
|
||||||
case BlockID.LOG:
|
case BlockID.LOG:
|
||||||
case BlockID.LOG2:
|
case BlockID.LOG2:
|
||||||
case BlockID.LEAVES:
|
case BlockID.LEAVES:
|
||||||
case BlockID.LEAVES2:
|
case BlockID.LEAVES2:
|
||||||
case BlockID.BROWN_MUSHROOM_CAP:
|
case BlockID.BROWN_MUSHROOM_CAP:
|
||||||
case BlockID.RED_MUSHROOM_CAP:
|
case BlockID.RED_MUSHROOM_CAP:
|
||||||
case BlockID.VINE:
|
case BlockID.VINE:
|
||||||
editSession.setBlock(blockVector, AIR);
|
editSession.setBlock(blockVector, AIR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
player.printError("Max blocks change limit reached.");
|
player.printError("Max blocks change limit reached.");
|
||||||
} finally {
|
} finally {
|
||||||
session.remember(editSession);
|
session.remember(editSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector[] recurseDirections = {
|
Vector[] recurseDirections = {
|
||||||
PlayerDirection.NORTH.vector(),
|
PlayerDirection.NORTH.vector(),
|
||||||
PlayerDirection.EAST.vector(),
|
PlayerDirection.EAST.vector(),
|
||||||
PlayerDirection.SOUTH.vector(),
|
PlayerDirection.SOUTH.vector(),
|
||||||
PlayerDirection.WEST.vector(),
|
PlayerDirection.WEST.vector(),
|
||||||
PlayerDirection.UP.vector(),
|
PlayerDirection.UP.vector(),
|
||||||
PlayerDirection.DOWN.vector(),
|
PlayerDirection.DOWN.vector(),
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method.
|
* Helper method.
|
||||||
*
|
*
|
||||||
* @param world the world that contains the tree
|
* @param world the world that contains the tree
|
||||||
* @param origin any point contained in the floating tree
|
* @param origin any point contained in the floating tree
|
||||||
* @return a set containing all blocks in the tree/shroom or null if this is not a floating tree/shroom.
|
* @return a set containing all blocks in the tree/shroom or null if this is not a floating tree/shroom.
|
||||||
*/
|
*/
|
||||||
private Set<Vector> bfs(LocalWorld world, Vector origin) throws MaxChangedBlocksException {
|
private Set<Vector> bfs(LocalWorld world, Vector origin) throws MaxChangedBlocksException {
|
||||||
final Set<Vector> visited = new HashSet<Vector>();
|
final Set<Vector> visited = new HashSet<Vector>();
|
||||||
final LinkedList<Vector> queue = new LinkedList<Vector>();
|
final LinkedList<Vector> queue = new LinkedList<Vector>();
|
||||||
|
|
||||||
queue.addLast(origin);
|
queue.addLast(origin);
|
||||||
visited.add(origin);
|
visited.add(origin);
|
||||||
|
|
||||||
while (!queue.isEmpty()) {
|
while (!queue.isEmpty()) {
|
||||||
final Vector current = queue.removeFirst();
|
final Vector current = queue.removeFirst();
|
||||||
for (Vector recurseDirection : recurseDirections) {
|
for (Vector recurseDirection : recurseDirections) {
|
||||||
final Vector next = current.add(recurseDirection);
|
final Vector next = current.add(recurseDirection);
|
||||||
if (origin.distanceSq(next) > rangeSq) {
|
if (origin.distanceSq(next) > rangeSq) {
|
||||||
// Maximum range exceeded => stop walking
|
// Maximum range exceeded => stop walking
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (visited.add(next)) {
|
if (visited.add(next)) {
|
||||||
switch (world.getBlockType(next)) {
|
switch (world.getBlockType(next)) {
|
||||||
case BlockID.AIR:
|
case BlockID.AIR:
|
||||||
case BlockID.SNOW:
|
case BlockID.SNOW:
|
||||||
// we hit air or snow => stop walking this route
|
// we hit air or snow => stop walking this route
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case BlockID.LOG:
|
case BlockID.LOG:
|
||||||
case BlockID.LOG2:
|
case BlockID.LOG2:
|
||||||
case BlockID.LEAVES:
|
case BlockID.LEAVES:
|
||||||
case BlockID.LEAVES2:
|
case BlockID.LEAVES2:
|
||||||
case BlockID.BROWN_MUSHROOM_CAP:
|
case BlockID.BROWN_MUSHROOM_CAP:
|
||||||
case BlockID.RED_MUSHROOM_CAP:
|
case BlockID.RED_MUSHROOM_CAP:
|
||||||
case BlockID.VINE:
|
case BlockID.VINE:
|
||||||
// queue next point
|
// queue next point
|
||||||
queue.addLast(next);
|
queue.addLast(next);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// we hit something solid - evaluate where we came from
|
// we hit something solid - evaluate where we came from
|
||||||
final int curId = world.getBlockType(current);
|
final int curId = world.getBlockType(current);
|
||||||
if (curId == BlockID.LEAVES || curId == BlockID.LEAVES2
|
if (curId == BlockID.LEAVES || curId == BlockID.LEAVES2
|
||||||
|| curId == BlockID.VINE) {
|
|| curId == BlockID.VINE) {
|
||||||
// leaves touching a wall/the ground => stop walking this route
|
// leaves touching a wall/the ground => stop walking this route
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
// log/shroom touching a wall/the ground => this is not a floating tree, bail out
|
// log/shroom touching a wall/the ground => this is not a floating tree, bail out
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
} // switch
|
} // switch
|
||||||
} // if
|
} // if
|
||||||
} // for
|
} // for
|
||||||
} // while
|
} // while
|
||||||
|
|
||||||
return visited;
|
return visited;
|
||||||
} // bfs
|
} // bfs
|
||||||
}
|
}
|
@ -1,118 +1,118 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.patterns.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A tool that flood fills blocks.
|
* A tool that flood fills blocks.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class FloodFillTool implements BlockTool {
|
public class FloodFillTool implements BlockTool {
|
||||||
private int range;
|
private int range;
|
||||||
private Pattern pattern;
|
private Pattern pattern;
|
||||||
|
|
||||||
public FloodFillTool(int range, Pattern pattern) {
|
public FloodFillTool(int range, Pattern pattern) {
|
||||||
this.range = range;
|
this.range = range;
|
||||||
this.pattern = pattern;
|
this.pattern = pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUse(LocalPlayer player) {
|
public boolean canUse(LocalPlayer player) {
|
||||||
return player.hasPermission("worldedit.tool.flood-fill");
|
return player.hasPermission("worldedit.tool.flood-fill");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||||
LocalWorld world = clicked.getWorld();
|
LocalWorld world = clicked.getWorld();
|
||||||
|
|
||||||
int initialType = world.getBlockType(clicked);
|
int initialType = world.getBlockType(clicked);
|
||||||
|
|
||||||
if (initialType == BlockID.AIR) {
|
if (initialType == BlockID.AIR) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) {
|
if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditSession editSession = session.createEditSession(player);
|
EditSession editSession = session.createEditSession(player);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
recurse(server, editSession, world, clicked.toBlockVector(),
|
recurse(server, editSession, world, clicked.toBlockVector(),
|
||||||
clicked, range, initialType, new HashSet<BlockVector>());
|
clicked, range, initialType, new HashSet<BlockVector>());
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
player.printError("Max blocks change limit reached.");
|
player.printError("Max blocks change limit reached.");
|
||||||
} finally {
|
} finally {
|
||||||
session.remember(editSession);
|
session.remember(editSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method.
|
* Helper method.
|
||||||
*
|
*
|
||||||
* @param server
|
* @param server
|
||||||
* @param superPickaxeManyDrop
|
* @param superPickaxeManyDrop
|
||||||
* @param world
|
* @param world
|
||||||
* @param pos
|
* @param pos
|
||||||
* @param origin
|
* @param origin
|
||||||
* @param size
|
* @param size
|
||||||
* @param initialType
|
* @param initialType
|
||||||
* @param visited
|
* @param visited
|
||||||
*/
|
*/
|
||||||
private void recurse(ServerInterface server, EditSession editSession,
|
private void recurse(ServerInterface server, EditSession editSession,
|
||||||
LocalWorld world, BlockVector pos,
|
LocalWorld world, BlockVector pos,
|
||||||
Vector origin, int size, int initialType,
|
Vector origin, int size, int initialType,
|
||||||
Set<BlockVector> visited)
|
Set<BlockVector> visited)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
|
|
||||||
if (origin.distance(pos) > size || visited.contains(pos)) {
|
if (origin.distance(pos) > size || visited.contains(pos)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
visited.add(pos);
|
visited.add(pos);
|
||||||
|
|
||||||
if (editSession.getBlock(pos).getType() == initialType) {
|
if (editSession.getBlock(pos).getType() == initialType) {
|
||||||
editSession.setBlock(pos, pattern.next(pos));
|
editSession.setBlock(pos, pattern.next(pos));
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
recurse(server, editSession, world, pos.add(1, 0, 0).toBlockVector(),
|
recurse(server, editSession, world, pos.add(1, 0, 0).toBlockVector(),
|
||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
recurse(server, editSession, world, pos.add(-1, 0, 0).toBlockVector(),
|
recurse(server, editSession, world, pos.add(-1, 0, 0).toBlockVector(),
|
||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
recurse(server, editSession, world, pos.add(0, 0, 1).toBlockVector(),
|
recurse(server, editSession, world, pos.add(0, 0, 1).toBlockVector(),
|
||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
recurse(server, editSession, world, pos.add(0, 0, -1).toBlockVector(),
|
recurse(server, editSession, world, pos.add(0, 0, -1).toBlockVector(),
|
||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
recurse(server, editSession, world, pos.add(0, 1, 0).toBlockVector(),
|
recurse(server, editSession, world, pos.add(0, 1, 0).toBlockVector(),
|
||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
recurse(server, editSession, world, pos.add(0, -1, 0).toBlockVector(),
|
recurse(server, editSession, world, pos.add(0, -1, 0).toBlockVector(),
|
||||||
origin, size, initialType, visited);
|
origin, size, initialType, visited);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,98 +1,98 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A tool that can place (or remove) blocks at a distance.
|
* A tool that can place (or remove) blocks at a distance.
|
||||||
*
|
*
|
||||||
* @author wizjany
|
* @author wizjany
|
||||||
*/
|
*/
|
||||||
public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTool {
|
public class LongRangeBuildTool extends BrushTool implements DoubleActionTraceTool {
|
||||||
|
|
||||||
BaseBlock primary;
|
BaseBlock primary;
|
||||||
BaseBlock secondary;
|
BaseBlock secondary;
|
||||||
|
|
||||||
public LongRangeBuildTool(BaseBlock primary, BaseBlock secondary) {
|
public LongRangeBuildTool(BaseBlock primary, BaseBlock secondary) {
|
||||||
super("worldedit.tool.lrbuild");
|
super("worldedit.tool.lrbuild");
|
||||||
this.primary = primary;
|
this.primary = primary;
|
||||||
this.secondary = secondary;
|
this.secondary = secondary;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canUse(LocalPlayer player) {
|
public boolean canUse(LocalPlayer player) {
|
||||||
return player.hasPermission("worldedit.tool.lrbuild");
|
return player.hasPermission("worldedit.tool.lrbuild");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actSecondary(ServerInterface server, LocalConfiguration config,
|
public boolean actSecondary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session) {
|
LocalPlayer player, LocalSession session) {
|
||||||
|
|
||||||
WorldVectorFace pos = getTargetFace(player);
|
WorldVectorFace pos = getTargetFace(player);
|
||||||
if (pos == null) return false;
|
if (pos == null) return false;
|
||||||
EditSession eS = session.createEditSession(player);
|
EditSession eS = session.createEditSession(player);
|
||||||
try {
|
try {
|
||||||
if (secondary.getType() == BlockID.AIR) {
|
if (secondary.getType() == BlockID.AIR) {
|
||||||
eS.setBlock(pos, secondary);
|
eS.setBlock(pos, secondary);
|
||||||
} else {
|
} else {
|
||||||
eS.setBlock(pos.getFaceVector(), secondary);
|
eS.setBlock(pos.getFaceVector(), secondary);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
// one block? eat it
|
// one block? eat it
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session) {
|
LocalPlayer player, LocalSession session) {
|
||||||
|
|
||||||
WorldVectorFace pos = getTargetFace(player);
|
WorldVectorFace pos = getTargetFace(player);
|
||||||
if (pos == null) return false;
|
if (pos == null) return false;
|
||||||
EditSession eS = session.createEditSession(player);
|
EditSession eS = session.createEditSession(player);
|
||||||
try {
|
try {
|
||||||
if (primary.getType() == BlockID.AIR) {
|
if (primary.getType() == BlockID.AIR) {
|
||||||
eS.setBlock(pos, primary);
|
eS.setBlock(pos, primary);
|
||||||
} else {
|
} else {
|
||||||
eS.setBlock(pos.getFaceVector(), primary);
|
eS.setBlock(pos.getFaceVector(), primary);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
// one block? eat it
|
// one block? eat it
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public WorldVectorFace getTargetFace(LocalPlayer player) {
|
public WorldVectorFace getTargetFace(LocalPlayer player) {
|
||||||
WorldVectorFace target = null;
|
WorldVectorFace target = null;
|
||||||
target = player.getBlockTraceFace(getRange(), true);
|
target = player.getBlockTraceFace(getRange(), true);
|
||||||
|
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
player.printError("No block in sight!");
|
player.printError("No block in sight!");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,65 +1,65 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.*;
|
import com.sk89q.worldedit.blocks.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plants a tree.
|
* Plants a tree.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class QueryTool implements BlockTool {
|
public class QueryTool implements BlockTool {
|
||||||
|
|
||||||
public boolean canUse(LocalPlayer player) {
|
public boolean canUse(LocalPlayer player) {
|
||||||
return player.hasPermission("worldedit.tool.info");
|
return player.hasPermission("worldedit.tool.info");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||||
|
|
||||||
LocalWorld world = clicked.getWorld();
|
LocalWorld world = clicked.getWorld();
|
||||||
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, 0, player);
|
EditSession editSession = WorldEdit.getInstance().getEditSessionFactory().getEditSession(world, 0, player);
|
||||||
BaseBlock block = (editSession).rawGetBlock(clicked);
|
BaseBlock block = (editSession).rawGetBlock(clicked);
|
||||||
BlockType type = BlockType.fromID(block.getType());
|
BlockType type = BlockType.fromID(block.getType());
|
||||||
|
|
||||||
player.print("\u00A79@" + clicked + ": " + "\u00A7e"
|
player.print("\u00A79@" + clicked + ": " + "\u00A7e"
|
||||||
+ "#" + block.getType() + "\u00A77" + " ("
|
+ "#" + block.getType() + "\u00A77" + " ("
|
||||||
+ (type == null ? "Unknown" : type.getName()) + ") "
|
+ (type == null ? "Unknown" : type.getName()) + ") "
|
||||||
+ "\u00A7f"
|
+ "\u00A7f"
|
||||||
+ "[" + block.getData() + "]" + " (" + world.getBlockLightLevel(clicked) + "/" + world.getBlockLightLevel(clicked.add(0, 1, 0)) + ")");
|
+ "[" + block.getData() + "]" + " (" + world.getBlockLightLevel(clicked) + "/" + world.getBlockLightLevel(clicked.add(0, 1, 0)) + ")");
|
||||||
|
|
||||||
if (block instanceof MobSpawnerBlock) {
|
if (block instanceof MobSpawnerBlock) {
|
||||||
player.printRaw("\u00A7e" + "Mob Type: "
|
player.printRaw("\u00A7e" + "Mob Type: "
|
||||||
+ ((MobSpawnerBlock) block).getMobType());
|
+ ((MobSpawnerBlock) block).getMobType());
|
||||||
} else if (block instanceof NoteBlock) {
|
} else if (block instanceof NoteBlock) {
|
||||||
player.printRaw("\u00A7e" + "Note block: "
|
player.printRaw("\u00A7e" + "Note block: "
|
||||||
+ ((NoteBlock) block).getNote());
|
+ ((NoteBlock) block).getNote());
|
||||||
} else if (block.getType() == BlockID.CLOTH) {
|
} else if (block.getType() == BlockID.CLOTH) {
|
||||||
// Should never be null
|
// Should never be null
|
||||||
player.printRaw("\u00A7e" + "Color: "
|
player.printRaw("\u00A7e" + "Color: "
|
||||||
+ ClothColor.fromID(block.getData()).getName());
|
+ ClothColor.fromID(block.getData()).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,127 +1,127 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A pickaxe mode that recursively finds adjacent blocks within range of
|
* A pickaxe mode that recursively finds adjacent blocks within range of
|
||||||
* an initial block and of the same type.
|
* an initial block and of the same type.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class RecursivePickaxe implements BlockTool {
|
public class RecursivePickaxe implements BlockTool {
|
||||||
private static final BaseBlock air = new BaseBlock(0);
|
private static final BaseBlock air = new BaseBlock(0);
|
||||||
private double range;
|
private double range;
|
||||||
|
|
||||||
public RecursivePickaxe(double range) {
|
public RecursivePickaxe(double range) {
|
||||||
this.range = range;
|
this.range = range;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUse(LocalPlayer player) {
|
public boolean canUse(LocalPlayer player) {
|
||||||
return player.hasPermission("worldedit.superpickaxe.recursive");
|
return player.hasPermission("worldedit.superpickaxe.recursive");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||||
LocalWorld world = clicked.getWorld();
|
LocalWorld world = clicked.getWorld();
|
||||||
|
|
||||||
int initialType = world.getBlockType(clicked);
|
int initialType = world.getBlockType(clicked);
|
||||||
|
|
||||||
if (initialType == BlockID.AIR) {
|
if (initialType == BlockID.AIR) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) {
|
if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
EditSession editSession = session.createEditSession(player);
|
EditSession editSession = session.createEditSession(player);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
recurse(server, editSession, world, clicked.toBlockVector(),
|
recurse(server, editSession, world, clicked.toBlockVector(),
|
||||||
clicked, range, initialType, new HashSet<BlockVector>(),
|
clicked, range, initialType, new HashSet<BlockVector>(),
|
||||||
config.superPickaxeManyDrop);
|
config.superPickaxeManyDrop);
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
player.printError("Max blocks change limit reached.");
|
player.printError("Max blocks change limit reached.");
|
||||||
} finally {
|
} finally {
|
||||||
session.remember(editSession);
|
session.remember(editSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method.
|
* Helper method.
|
||||||
*
|
*
|
||||||
* @param server
|
* @param server
|
||||||
* @param superPickaxeManyDrop
|
* @param superPickaxeManyDrop
|
||||||
* @param world
|
* @param world
|
||||||
* @param pos
|
* @param pos
|
||||||
* @param origin
|
* @param origin
|
||||||
* @param size
|
* @param size
|
||||||
* @param initialType
|
* @param initialType
|
||||||
* @param visited
|
* @param visited
|
||||||
*/
|
*/
|
||||||
private static void recurse(ServerInterface server, EditSession editSession,
|
private static void recurse(ServerInterface server, EditSession editSession,
|
||||||
LocalWorld world, BlockVector pos,
|
LocalWorld world, BlockVector pos,
|
||||||
Vector origin, double size, int initialType,
|
Vector origin, double size, int initialType,
|
||||||
Set<BlockVector> visited, boolean drop)
|
Set<BlockVector> visited, boolean drop)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
|
|
||||||
final double distanceSq = origin.distanceSq(pos);
|
final double distanceSq = origin.distanceSq(pos);
|
||||||
if (distanceSq > size*size || visited.contains(pos)) {
|
if (distanceSq > size*size || visited.contains(pos)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
visited.add(pos);
|
visited.add(pos);
|
||||||
|
|
||||||
if (editSession.getBlock(pos).getType() != initialType) {
|
if (editSession.getBlock(pos).getType() != initialType) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (drop) {
|
if (drop) {
|
||||||
world.simulateBlockMine(pos);
|
world.simulateBlockMine(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
world.queueBlockBreakEffect(server, pos, initialType, distanceSq);
|
world.queueBlockBreakEffect(server, pos, initialType, distanceSq);
|
||||||
|
|
||||||
editSession.setBlock(pos, air);
|
editSession.setBlock(pos, air);
|
||||||
|
|
||||||
recurse(server, editSession, world, pos.add(1, 0, 0).toBlockVector(),
|
recurse(server, editSession, world, pos.add(1, 0, 0).toBlockVector(),
|
||||||
origin, size, initialType, visited, drop);
|
origin, size, initialType, visited, drop);
|
||||||
recurse(server, editSession, world, pos.add(-1, 0, 0).toBlockVector(),
|
recurse(server, editSession, world, pos.add(-1, 0, 0).toBlockVector(),
|
||||||
origin, size, initialType, visited, drop);
|
origin, size, initialType, visited, drop);
|
||||||
recurse(server, editSession, world, pos.add(0, 0, 1).toBlockVector(),
|
recurse(server, editSession, world, pos.add(0, 0, 1).toBlockVector(),
|
||||||
origin, size, initialType, visited, drop);
|
origin, size, initialType, visited, drop);
|
||||||
recurse(server, editSession, world, pos.add(0, 0, -1).toBlockVector(),
|
recurse(server, editSession, world, pos.add(0, 0, -1).toBlockVector(),
|
||||||
origin, size, initialType, visited, drop);
|
origin, size, initialType, visited, drop);
|
||||||
recurse(server, editSession, world, pos.add(0, 1, 0).toBlockVector(),
|
recurse(server, editSession, world, pos.add(0, 1, 0).toBlockVector(),
|
||||||
origin, size, initialType, visited, drop);
|
origin, size, initialType, visited, drop);
|
||||||
recurse(server, editSession, world, pos.add(0, -1, 0).toBlockVector(),
|
recurse(server, editSession, world, pos.add(0, -1, 0).toBlockVector(),
|
||||||
origin, size, initialType, visited, drop);
|
origin, size, initialType, visited, drop);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,57 +1,57 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A super pickaxe mode that removes one block.
|
* A super pickaxe mode that removes one block.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class SinglePickaxe implements BlockTool {
|
public class SinglePickaxe implements BlockTool {
|
||||||
|
|
||||||
public boolean canUse(LocalPlayer player) {
|
public boolean canUse(LocalPlayer player) {
|
||||||
return player.hasPermission("worldedit.superpickaxe");
|
return player.hasPermission("worldedit.superpickaxe");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||||
LocalWorld world = clicked.getWorld();
|
LocalWorld world = clicked.getWorld();
|
||||||
|
|
||||||
final int blockType = world.getBlockType(clicked);
|
final int blockType = world.getBlockType(clicked);
|
||||||
if (blockType == BlockID.BEDROCK
|
if (blockType == BlockID.BEDROCK
|
||||||
&& !player.canDestroyBedrock()) {
|
&& !player.canDestroyBedrock()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.superPickaxeDrop) {
|
if (config.superPickaxeDrop) {
|
||||||
world.simulateBlockMine(clicked);
|
world.simulateBlockMine(clicked);
|
||||||
}
|
}
|
||||||
|
|
||||||
world.setBlockType(clicked, BlockID.AIR);
|
world.setBlockType(clicked, BlockID.AIR);
|
||||||
|
|
||||||
world.playEffect(clicked, 2001, blockType);
|
world.playEffect(clicked, 2001, blockType);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,41 +1,41 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a tool. This interface alone defines nothing. A tool also
|
* Represents a tool. This interface alone defines nothing. A tool also
|
||||||
* has to implement <code>BlockTool</code> or <code>TraceTool</code>.
|
* has to implement <code>BlockTool</code> or <code>TraceTool</code>.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public abstract interface Tool {
|
public abstract interface Tool {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if the player can still be using this tool (considering
|
* Checks to see if the player can still be using this tool (considering
|
||||||
* permissions and such).
|
* permissions and such).
|
||||||
*
|
*
|
||||||
* @param player
|
* @param player
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean canUse(LocalPlayer player);
|
public boolean canUse(LocalPlayer player);
|
||||||
|
|
||||||
}
|
}
|
@ -1,45 +1,45 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.LocalConfiguration;
|
import com.sk89q.worldedit.LocalConfiguration;
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.ServerInterface;
|
import com.sk89q.worldedit.ServerInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a tool that does not require a block.
|
* Represents a tool that does not require a block.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public interface TraceTool extends Tool {
|
public interface TraceTool extends Tool {
|
||||||
/**
|
/**
|
||||||
* Perform the action. Should return true to deny the default
|
* Perform the action. Should return true to deny the default
|
||||||
* action.
|
* action.
|
||||||
*
|
*
|
||||||
* @param server
|
* @param server
|
||||||
* @param config
|
* @param config
|
||||||
* @param player
|
* @param player
|
||||||
* @param session
|
* @param session
|
||||||
* @return true to deny
|
* @return true to deny
|
||||||
*/
|
*/
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session);
|
LocalPlayer player, LocalSession session);
|
||||||
}
|
}
|
@ -1,68 +1,68 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools;
|
package com.sk89q.worldedit.command.tool;
|
||||||
|
|
||||||
import com.sk89q.worldedit.*;
|
import com.sk89q.worldedit.*;
|
||||||
import com.sk89q.worldedit.util.TreeGenerator;
|
import com.sk89q.worldedit.util.TreeGenerator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plants a tree.
|
* Plants a tree.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class TreePlanter implements BlockTool {
|
public class TreePlanter implements BlockTool {
|
||||||
private TreeGenerator gen;
|
private TreeGenerator gen;
|
||||||
|
|
||||||
public TreePlanter(TreeGenerator gen) {
|
public TreePlanter(TreeGenerator gen) {
|
||||||
this.gen = gen;
|
this.gen = gen;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canUse(LocalPlayer player) {
|
public boolean canUse(LocalPlayer player) {
|
||||||
return player.hasPermission("worldedit.tool.tree");
|
return player.hasPermission("worldedit.tool.tree");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
public boolean actPrimary(ServerInterface server, LocalConfiguration config,
|
||||||
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
LocalPlayer player, LocalSession session, WorldVector clicked) {
|
||||||
|
|
||||||
EditSession editSession = session.createEditSession(player);
|
EditSession editSession = session.createEditSession(player);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
boolean successful = false;
|
boolean successful = false;
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
if (gen.generate(editSession, clicked.add(0, 1, 0))) {
|
if (gen.generate(editSession, clicked.add(0, 1, 0))) {
|
||||||
successful = true;
|
successful = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!successful) {
|
if (!successful) {
|
||||||
player.printError("A tree can't go there.");
|
player.printError("A tree can't go there.");
|
||||||
}
|
}
|
||||||
} catch (MaxChangedBlocksException e) {
|
} catch (MaxChangedBlocksException e) {
|
||||||
player.printError("Max. blocks changed reached.");
|
player.printError("Max. blocks changed reached.");
|
||||||
} finally {
|
} finally {
|
||||||
session.remember(editSession);
|
session.remember(editSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,44 +1,44 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools.brushes;
|
package com.sk89q.worldedit.command.tool.brush;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.patterns.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a brush.
|
* Represents a brush.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public interface Brush {
|
public interface Brush {
|
||||||
/**
|
/**
|
||||||
* Build the object.
|
* Build the object.
|
||||||
*
|
*
|
||||||
* @param editSession
|
* @param editSession
|
||||||
* @param pos
|
* @param pos
|
||||||
* @param mat
|
* @param mat
|
||||||
* @param size
|
* @param size
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException
|
||||||
*/
|
*/
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
||||||
throws MaxChangedBlocksException;
|
throws MaxChangedBlocksException;
|
||||||
}
|
}
|
@ -17,7 +17,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools.brushes;
|
package com.sk89q.worldedit.command.tool.brush;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
@ -1,41 +1,41 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools.brushes;
|
package com.sk89q.worldedit.command.tool.brush;
|
||||||
|
|
||||||
import com.sk89q.worldedit.CuboidClipboard;
|
import com.sk89q.worldedit.CuboidClipboard;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.patterns.Pattern;
|
||||||
|
|
||||||
public class ClipboardBrush implements Brush {
|
public class ClipboardBrush implements Brush {
|
||||||
private CuboidClipboard clipboard;
|
private CuboidClipboard clipboard;
|
||||||
private boolean noAir;
|
private boolean noAir;
|
||||||
|
|
||||||
public ClipboardBrush(CuboidClipboard clipboard, boolean noAir) {
|
public ClipboardBrush(CuboidClipboard clipboard, boolean noAir) {
|
||||||
this.clipboard = clipboard;
|
this.clipboard = clipboard;
|
||||||
this.noAir = noAir;
|
this.noAir = noAir;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
clipboard.place(editSession, pos.subtract(clipboard.getSize().divide(2)), noAir);
|
clipboard.place(editSession, pos.subtract(clipboard.getSize().divide(2)), noAir);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,38 +1,38 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools.brushes;
|
package com.sk89q.worldedit.command.tool.brush;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.patterns.Pattern;
|
||||||
|
|
||||||
public class CylinderBrush implements Brush {
|
public class CylinderBrush implements Brush {
|
||||||
private int height;
|
private int height;
|
||||||
|
|
||||||
public CylinderBrush(int height) {
|
public CylinderBrush(int height) {
|
||||||
this.height = height;
|
this.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
editSession.makeCylinder(pos, mat, size, size, height, true);
|
editSession.makeCylinder(pos, mat, size, size, height, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,7 +17,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools.brushes;
|
package com.sk89q.worldedit.command.tool.brush;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
@ -1,38 +1,38 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools.brushes;
|
package com.sk89q.worldedit.command.tool.brush;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.patterns.Pattern;
|
||||||
|
|
||||||
public class HollowCylinderBrush implements Brush {
|
public class HollowCylinderBrush implements Brush {
|
||||||
private int height;
|
private int height;
|
||||||
|
|
||||||
public HollowCylinderBrush(int height) {
|
public HollowCylinderBrush(int height) {
|
||||||
this.height = height;
|
this.height = height;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
editSession.makeCylinder(pos, mat, size, size, height, false);
|
editSession.makeCylinder(pos, mat, size, size, height, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,35 +1,35 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools.brushes;
|
package com.sk89q.worldedit.command.tool.brush;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.patterns.Pattern;
|
||||||
|
|
||||||
public class HollowSphereBrush implements Brush {
|
public class HollowSphereBrush implements Brush {
|
||||||
public HollowSphereBrush() {
|
public HollowSphereBrush() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
editSession.makeSphere(pos, mat, size, size, size, false);
|
editSession.makeSphere(pos, mat, size, size, size, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,56 +1,56 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools.brushes;
|
package com.sk89q.worldedit.command.tool.brush;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.math.convolution.HeightMap;
|
import com.sk89q.worldedit.math.convolution.HeightMap;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldVector;
|
import com.sk89q.worldedit.WorldVector;
|
||||||
import com.sk89q.worldedit.math.convolution.GaussianKernel;
|
import com.sk89q.worldedit.math.convolution.GaussianKernel;
|
||||||
import com.sk89q.worldedit.math.convolution.HeightMapFilter;
|
import com.sk89q.worldedit.math.convolution.HeightMapFilter;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.patterns.Pattern;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
public class SmoothBrush implements Brush {
|
public class SmoothBrush implements Brush {
|
||||||
private int iterations;
|
private int iterations;
|
||||||
private boolean naturalOnly;
|
private boolean naturalOnly;
|
||||||
|
|
||||||
public SmoothBrush(int iterations) {
|
public SmoothBrush(int iterations) {
|
||||||
this(iterations, false);
|
this(iterations, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SmoothBrush(int iterations, boolean naturalOnly) {
|
public SmoothBrush(int iterations, boolean naturalOnly) {
|
||||||
this.iterations = iterations;
|
this.iterations = iterations;
|
||||||
this.naturalOnly = naturalOnly;
|
this.naturalOnly = naturalOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
double rad = size;
|
double rad = size;
|
||||||
WorldVector min = new WorldVector(editSession.getWorld(), pos.subtract(rad, rad, rad));
|
WorldVector min = new WorldVector(editSession.getWorld(), pos.subtract(rad, rad, rad));
|
||||||
Vector max = pos.add(rad, rad + 10, rad);
|
Vector max = pos.add(rad, rad + 10, rad);
|
||||||
Region region = new CuboidRegion(editSession.getWorld(), min, max);
|
Region region = new CuboidRegion(editSession.getWorld(), min, max);
|
||||||
HeightMap heightMap = new HeightMap(editSession, region, naturalOnly);
|
HeightMap heightMap = new HeightMap(editSession, region, naturalOnly);
|
||||||
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
HeightMapFilter filter = new HeightMapFilter(new GaussianKernel(5, 1.0));
|
||||||
heightMap.applyFilter(filter, iterations);
|
heightMap.applyFilter(filter, iterations);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,35 +1,35 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.tools.brushes;
|
package com.sk89q.worldedit.command.tool.brush;
|
||||||
|
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.patterns.Pattern;
|
import com.sk89q.worldedit.patterns.Pattern;
|
||||||
|
|
||||||
public class SphereBrush implements Brush {
|
public class SphereBrush implements Brush {
|
||||||
public SphereBrush() {
|
public SphereBrush() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
public void build(EditSession editSession, Vector pos, Pattern mat, double size)
|
||||||
throws MaxChangedBlocksException {
|
throws MaxChangedBlocksException {
|
||||||
editSession.makeSphere(pos, mat, size, size, size, true);
|
editSession.makeSphere(pos, mat, size, size, size, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -17,13 +17,15 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent.buffer;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.extent.ExtentDelegate;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.mask.Masks;
|
import com.sk89q.worldedit.function.mask.Masks;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
@ -17,11 +17,13 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent.cache;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.extent.ExtentDelegate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the same cached {@link BaseBlock} for repeated calls to
|
* Returns the same cached {@link BaseBlock} for repeated calls to
|
@ -1,199 +1,199 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.bags;
|
package com.sk89q.worldedit.extent.inventory;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldVector;
|
import com.sk89q.worldedit.WorldVector;
|
||||||
import com.sk89q.worldedit.blocks.*;
|
import com.sk89q.worldedit.blocks.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a source to get blocks from and store removed ones.
|
* Represents a source to get blocks from and store removed ones.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public abstract class BlockBag {
|
public abstract class BlockBag {
|
||||||
/**
|
/**
|
||||||
* Stores a block as if it was mined.
|
* Stores a block as if it was mined.
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @throws BlockBagException
|
* @throws BlockBagException
|
||||||
* @deprecated Use {@link BlockBag#storeDroppedBlock(int, int)} instead
|
* @deprecated Use {@link BlockBag#storeDroppedBlock(int, int)} instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void storeDroppedBlock(int id) throws BlockBagException {
|
public void storeDroppedBlock(int id) throws BlockBagException {
|
||||||
storeDroppedBlock(id, 0);
|
storeDroppedBlock(id, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores a block as if it was mined.
|
* Stores a block as if it was mined.
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @param data
|
* @param data
|
||||||
* @throws BlockBagException
|
* @throws BlockBagException
|
||||||
*/
|
*/
|
||||||
public void storeDroppedBlock(int id, int data) throws BlockBagException {
|
public void storeDroppedBlock(int id, int data) throws BlockBagException {
|
||||||
BaseItem dropped = BlockType.getBlockBagItem(id, data);
|
BaseItem dropped = BlockType.getBlockBagItem(id, data);
|
||||||
if (dropped == null) return;
|
if (dropped == null) return;
|
||||||
if (dropped.getType() == BlockID.AIR) return;
|
if (dropped.getType() == BlockID.AIR) return;
|
||||||
|
|
||||||
storeItem(dropped);
|
storeItem(dropped);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a block as if it was placed by hand.
|
* Sets a block as if it was placed by hand.
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @throws BlockBagException
|
* @throws BlockBagException
|
||||||
* @deprecated Use {@link #fetchPlacedBlock(int,int)} instead
|
* @deprecated Use {@link #fetchPlacedBlock(int,int)} instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void fetchPlacedBlock(int id) throws BlockBagException {
|
public void fetchPlacedBlock(int id) throws BlockBagException {
|
||||||
fetchPlacedBlock(id, 0);
|
fetchPlacedBlock(id, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a block as if it was placed by hand.
|
* Sets a block as if it was placed by hand.
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @param data TODO
|
* @param data TODO
|
||||||
* @throws BlockBagException
|
* @throws BlockBagException
|
||||||
*/
|
*/
|
||||||
public void fetchPlacedBlock(int id, int data) throws BlockBagException {
|
public void fetchPlacedBlock(int id, int data) throws BlockBagException {
|
||||||
try {
|
try {
|
||||||
// Blocks that can't be fetched...
|
// Blocks that can't be fetched...
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case BlockID.BEDROCK:
|
case BlockID.BEDROCK:
|
||||||
case BlockID.GOLD_ORE:
|
case BlockID.GOLD_ORE:
|
||||||
case BlockID.IRON_ORE:
|
case BlockID.IRON_ORE:
|
||||||
case BlockID.COAL_ORE:
|
case BlockID.COAL_ORE:
|
||||||
case BlockID.DIAMOND_ORE:
|
case BlockID.DIAMOND_ORE:
|
||||||
case BlockID.TNT:
|
case BlockID.TNT:
|
||||||
case BlockID.MOB_SPAWNER:
|
case BlockID.MOB_SPAWNER:
|
||||||
case BlockID.CROPS:
|
case BlockID.CROPS:
|
||||||
case BlockID.REDSTONE_ORE:
|
case BlockID.REDSTONE_ORE:
|
||||||
case BlockID.GLOWING_REDSTONE_ORE:
|
case BlockID.GLOWING_REDSTONE_ORE:
|
||||||
case BlockID.SNOW:
|
case BlockID.SNOW:
|
||||||
case BlockID.LIGHTSTONE:
|
case BlockID.LIGHTSTONE:
|
||||||
case BlockID.PORTAL:
|
case BlockID.PORTAL:
|
||||||
throw new UnplaceableBlockException();
|
throw new UnplaceableBlockException();
|
||||||
|
|
||||||
case BlockID.WATER:
|
case BlockID.WATER:
|
||||||
case BlockID.STATIONARY_WATER:
|
case BlockID.STATIONARY_WATER:
|
||||||
case BlockID.LAVA:
|
case BlockID.LAVA:
|
||||||
case BlockID.STATIONARY_LAVA:
|
case BlockID.STATIONARY_LAVA:
|
||||||
// Override liquids
|
// Override liquids
|
||||||
return;
|
return;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
fetchBlock(id);
|
fetchBlock(id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (OutOfBlocksException e) {
|
} catch (OutOfBlocksException e) {
|
||||||
BaseItem placed = BlockType.getBlockBagItem(id, data);
|
BaseItem placed = BlockType.getBlockBagItem(id, data);
|
||||||
if (placed == null) throw e; // TODO: check
|
if (placed == null) throw e; // TODO: check
|
||||||
if (placed.getType() == BlockID.AIR) throw e; // TODO: check
|
if (placed.getType() == BlockID.AIR) throw e; // TODO: check
|
||||||
|
|
||||||
fetchItem(placed);
|
fetchItem(placed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a block.
|
* Get a block.
|
||||||
*
|
*
|
||||||
* Either this method or fetchItem needs to be overridden
|
* Either this method or fetchItem needs to be overridden
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @throws BlockBagException
|
* @throws BlockBagException
|
||||||
*/
|
*/
|
||||||
public void fetchBlock(int id) throws BlockBagException {
|
public void fetchBlock(int id) throws BlockBagException {
|
||||||
fetchItem(new BaseItem(id));
|
fetchItem(new BaseItem(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a block.
|
* Get a block.
|
||||||
*
|
*
|
||||||
* Either this method or fetchBlock needs to be overridden
|
* Either this method or fetchBlock needs to be overridden
|
||||||
*
|
*
|
||||||
* @param item
|
* @param item
|
||||||
* @throws BlockBagException
|
* @throws BlockBagException
|
||||||
*/
|
*/
|
||||||
public void fetchItem(BaseItem item) throws BlockBagException {
|
public void fetchItem(BaseItem item) throws BlockBagException {
|
||||||
fetchBlock(item.getType());
|
fetchBlock(item.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store a block.
|
* Store a block.
|
||||||
*
|
*
|
||||||
* Either this method or storeItem needs to be overridden
|
* Either this method or storeItem needs to be overridden
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @throws BlockBagException
|
* @throws BlockBagException
|
||||||
*/
|
*/
|
||||||
public void storeBlock(int id) throws BlockBagException {
|
public void storeBlock(int id) throws BlockBagException {
|
||||||
storeItem(new BaseItem(id));
|
storeItem(new BaseItem(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Store a block.
|
* Store a block.
|
||||||
*
|
*
|
||||||
* Either this method or storeBlock needs to be overridden
|
* Either this method or storeBlock needs to be overridden
|
||||||
*
|
*
|
||||||
* @param item
|
* @param item
|
||||||
* @throws BlockBagException
|
* @throws BlockBagException
|
||||||
*/
|
*/
|
||||||
public void storeItem(BaseItem item) throws BlockBagException {
|
public void storeItem(BaseItem item) throws BlockBagException {
|
||||||
storeBlock(item.getType());
|
storeBlock(item.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks to see if a block exists without removing it.
|
* Checks to see if a block exists without removing it.
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @return whether the block exists
|
* @return whether the block exists
|
||||||
*/
|
*/
|
||||||
public boolean peekBlock(int id) {
|
public boolean peekBlock(int id) {
|
||||||
try {
|
try {
|
||||||
fetchBlock(id);
|
fetchBlock(id);
|
||||||
storeBlock(id);
|
storeBlock(id);
|
||||||
return true;
|
return true;
|
||||||
} catch (BlockBagException e) {
|
} catch (BlockBagException e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Flush any changes. This is called at the end.
|
* Flush any changes. This is called at the end.
|
||||||
*/
|
*/
|
||||||
public abstract void flushChanges();
|
public abstract void flushChanges();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a position to be used a source.
|
* Adds a position to be used a source.
|
||||||
*
|
*
|
||||||
* @param pos
|
* @param pos
|
||||||
*/
|
*/
|
||||||
public abstract void addSourcePosition(WorldVector pos);
|
public abstract void addSourcePosition(WorldVector pos);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds a position to be used a source.
|
* Adds a position to be used a source.
|
||||||
*
|
*
|
||||||
* @param pos
|
* @param pos
|
||||||
*/
|
*/
|
||||||
public abstract void addSingleSourcePosition(WorldVector pos);
|
public abstract void addSingleSourcePosition(WorldVector pos);
|
||||||
}
|
}
|
@ -1,28 +1,28 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.bags;
|
package com.sk89q.worldedit.extent.inventory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class BlockBagException extends Exception {
|
public class BlockBagException extends Exception {
|
||||||
private static final long serialVersionUID = 4672190086028430655L;
|
private static final long serialVersionUID = 4672190086028430655L;
|
||||||
}
|
}
|
@ -17,14 +17,16 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent.inventory;
|
||||||
|
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
import com.sk89q.worldedit.LocalWorld;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.bags.BlockBag;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.bags.BlockBagException;
|
import com.sk89q.worldedit.extent.ExtentDelegate;
|
||||||
import com.sk89q.worldedit.bags.UnplaceableBlockException;
|
import com.sk89q.worldedit.extent.inventory.BlockBag;
|
||||||
|
import com.sk89q.worldedit.extent.inventory.BlockBagException;
|
||||||
|
import com.sk89q.worldedit.extent.inventory.UnplaceableBlockException;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
@ -1,28 +1,28 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.bags;
|
package com.sk89q.worldedit.extent.inventory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class OutOfBlocksException extends BlockBagException {
|
public class OutOfBlocksException extends BlockBagException {
|
||||||
private static final long serialVersionUID = 7495899825677689509L;
|
private static final long serialVersionUID = 7495899825677689509L;
|
||||||
}
|
}
|
@ -1,48 +1,48 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.bags;
|
package com.sk89q.worldedit.extent.inventory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class OutOfSpaceException extends BlockBagException {
|
public class OutOfSpaceException extends BlockBagException {
|
||||||
private static final long serialVersionUID = -2962840237632916821L;
|
private static final long serialVersionUID = -2962840237632916821L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stores the block ID.
|
* Stores the block ID.
|
||||||
*/
|
*/
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the object.
|
* Construct the object.
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
public OutOfSpaceException(int id) {
|
public OutOfSpaceException(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the id
|
* @return the id
|
||||||
*/
|
*/
|
||||||
public int getID() {
|
public int getID() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,29 +1,29 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.bags;
|
package com.sk89q.worldedit.extent.inventory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class UnplaceableBlockException extends BlockBagException {
|
public class UnplaceableBlockException extends BlockBagException {
|
||||||
private static final long serialVersionUID = 7227883966999843526L;
|
private static final long serialVersionUID = 7227883966999843526L;
|
||||||
|
|
||||||
}
|
}
|
@ -17,11 +17,13 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent.logging;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.extent.ExtentDelegate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An abstract class to implement block loggers and so on with.
|
* An abstract class to implement block loggers and so on with.
|
@ -17,12 +17,14 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent.validation;
|
||||||
|
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.extent.ExtentDelegate;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
@ -17,12 +17,14 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent.validation;
|
||||||
|
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
import com.sk89q.worldedit.LocalWorld;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.extent.ExtentDelegate;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
@ -17,7 +17,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent.world;
|
||||||
|
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
import com.sk89q.worldedit.LocalWorld;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
@ -25,6 +25,8 @@ import com.sk89q.worldedit.WorldEditException;
|
|||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
import com.sk89q.worldedit.blocks.BlockType;
|
import com.sk89q.worldedit.blocks.BlockType;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.extent.ExtentDelegate;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
@ -17,12 +17,14 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent.world;
|
||||||
|
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
import com.sk89q.worldedit.LocalWorld;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.extent.ExtentDelegate;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
@ -17,13 +17,14 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.extent;
|
package com.sk89q.worldedit.extent.world;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector2D;
|
import com.sk89q.worldedit.BlockVector2D;
|
||||||
import com.sk89q.worldedit.LocalWorld;
|
import com.sk89q.worldedit.LocalWorld;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.extent.ExtentDelegate;
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.function.operation.RunContext;
|
import com.sk89q.worldedit.function.operation.RunContext;
|
||||||
|
|
@ -23,7 +23,7 @@ import com.sk89q.jnbt.StringTag;
|
|||||||
import com.sk89q.jnbt.Tag;
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.blocks.BaseBlock;
|
import com.sk89q.worldedit.blocks.BaseBlock;
|
||||||
import com.sk89q.worldedit.blocks.TileEntityBlock;
|
import com.sk89q.worldedit.blocks.TileEntityBlock;
|
||||||
import com.sk89q.worldedit.data.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a mutable copy of a block that is not tied to any 'real' block in a world.
|
* Represents a mutable copy of a block that is not tied to any 'real' block in a world.
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
package com.sk89q.worldedit.foundation;
|
package com.sk89q.worldedit.foundation;
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.data.DataException;
|
import com.sk89q.worldedit.world.DataException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates an object that contains extra data identified as an NBT structure. This
|
* Indicates an object that contains extra data identified as an NBT structure. This
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.cui;
|
package com.sk89q.worldedit.internal.cui;
|
||||||
|
|
||||||
public interface CUIEvent {
|
public interface CUIEvent {
|
||||||
|
|
||||||
public String getTypeId();
|
public String getTypeId();
|
||||||
|
|
||||||
public String[] getParameters();
|
public String[] getParameters();
|
||||||
}
|
}
|
@ -1,65 +1,65 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.cui;
|
package com.sk89q.worldedit.internal.cui;
|
||||||
|
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
import com.sk89q.worldedit.LocalPlayer;
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
|
||||||
public interface CUIRegion {
|
public interface CUIRegion {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends CUI events describing the region for
|
* Sends CUI events describing the region for
|
||||||
* versions of CUI equal to or greater than the
|
* versions of CUI equal to or greater than the
|
||||||
* value supplied by getProtocolVersion().
|
* value supplied by getProtocolVersion().
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void describeCUI(LocalSession session, LocalPlayer player);
|
public void describeCUI(LocalSession session, LocalPlayer player);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends CUI events describing the region for
|
* Sends CUI events describing the region for
|
||||||
* versions of CUI smaller than the value
|
* versions of CUI smaller than the value
|
||||||
* supplied by getProtocolVersion().
|
* supplied by getProtocolVersion().
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void describeLegacyCUI(LocalSession session, LocalPlayer player);
|
public void describeLegacyCUI(LocalSession session, LocalPlayer player);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the CUI version that is required to send
|
* Returns the CUI version that is required to send
|
||||||
* up-to-date data. If the CUI version is smaller than
|
* up-to-date data. If the CUI version is smaller than
|
||||||
* this value, the legacy methods will be called.
|
* this value, the legacy methods will be called.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getProtocolVersion();
|
public int getProtocolVersion();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type ID to send to CUI in the selection event.
|
* Returns the type ID to send to CUI in the selection event.
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getTypeID();
|
public String getTypeID();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the type ID to send to CUI in the selection
|
* Returns the type ID to send to CUI in the selection
|
||||||
* event if the CUI is in legacy mode.
|
* event if the CUI is in legacy mode.
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String getLegacyTypeID();
|
public String getLegacyTypeID();
|
||||||
}
|
}
|
@ -1,47 +1,47 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.sk89q.worldedit.cui;
|
package com.sk89q.worldedit.internal.cui;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.Vector2D;
|
import com.sk89q.worldedit.Vector2D;
|
||||||
|
|
||||||
public class SelectionCylinderEvent implements CUIEvent {
|
public class SelectionCylinderEvent implements CUIEvent {
|
||||||
|
|
||||||
protected final Vector pos;
|
protected final Vector pos;
|
||||||
protected final Vector2D radius;
|
protected final Vector2D radius;
|
||||||
|
|
||||||
public SelectionCylinderEvent(Vector pos, Vector2D radius) {
|
public SelectionCylinderEvent(Vector pos, Vector2D radius) {
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypeId() {
|
public String getTypeId() {
|
||||||
return "cyl";
|
return "cyl";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getParameters() {
|
public String[] getParameters() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
String.valueOf(pos.getBlockX()),
|
String.valueOf(pos.getBlockX()),
|
||||||
String.valueOf(pos.getBlockY()),
|
String.valueOf(pos.getBlockY()),
|
||||||
String.valueOf(pos.getBlockZ()),
|
String.valueOf(pos.getBlockZ()),
|
||||||
String.valueOf(radius.getX()),
|
String.valueOf(radius.getX()),
|
||||||
String.valueOf(radius.getZ())
|
String.valueOf(radius.getZ())
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,45 +1,45 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.cui;
|
package com.sk89q.worldedit.internal.cui;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
|
|
||||||
public class SelectionEllipsoidPointEvent implements CUIEvent {
|
public class SelectionEllipsoidPointEvent implements CUIEvent {
|
||||||
protected final int id;
|
protected final int id;
|
||||||
protected final Vector pos;
|
protected final Vector pos;
|
||||||
|
|
||||||
public SelectionEllipsoidPointEvent(int id, Vector pos) {
|
public SelectionEllipsoidPointEvent(int id, Vector pos) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypeId() {
|
public String getTypeId() {
|
||||||
return "e";
|
return "e";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getParameters() {
|
public String[] getParameters() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
String.valueOf(id),
|
String.valueOf(id),
|
||||||
String.valueOf(pos.getBlockX()),
|
String.valueOf(pos.getBlockX()),
|
||||||
String.valueOf(pos.getBlockY()),
|
String.valueOf(pos.getBlockY()),
|
||||||
String.valueOf(pos.getBlockZ())
|
String.valueOf(pos.getBlockZ())
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,43 +1,43 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.cui;
|
package com.sk89q.worldedit.internal.cui;
|
||||||
|
|
||||||
public class SelectionMinMaxEvent implements CUIEvent {
|
public class SelectionMinMaxEvent implements CUIEvent {
|
||||||
|
|
||||||
protected final int min;
|
protected final int min;
|
||||||
protected final int max;
|
protected final int max;
|
||||||
|
|
||||||
public SelectionMinMaxEvent(int min, int max) {
|
public SelectionMinMaxEvent(int min, int max) {
|
||||||
this.min = min;
|
this.min = min;
|
||||||
this.max = max;
|
this.max = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypeId() {
|
public String getTypeId() {
|
||||||
return "mm";
|
return "mm";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getParameters() {
|
public String[] getParameters() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
String.valueOf(min),
|
String.valueOf(min),
|
||||||
String.valueOf(max),
|
String.valueOf(max),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,59 +1,59 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.cui;
|
package com.sk89q.worldedit.internal.cui;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
import com.sk89q.worldedit.Vector2D;
|
import com.sk89q.worldedit.Vector2D;
|
||||||
|
|
||||||
public class SelectionPoint2DEvent implements CUIEvent {
|
public class SelectionPoint2DEvent implements CUIEvent {
|
||||||
|
|
||||||
protected final int id;
|
protected final int id;
|
||||||
protected final int blockx;
|
protected final int blockx;
|
||||||
protected final int blockz;
|
protected final int blockz;
|
||||||
protected final int area;
|
protected final int area;
|
||||||
|
|
||||||
public SelectionPoint2DEvent(int id, Vector2D pos, int area) {
|
public SelectionPoint2DEvent(int id, Vector2D pos, int area) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.blockx = pos.getBlockX();
|
this.blockx = pos.getBlockX();
|
||||||
this.blockz = pos.getBlockZ();
|
this.blockz = pos.getBlockZ();
|
||||||
this.area = area;
|
this.area = area;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SelectionPoint2DEvent(int id, Vector pos, int area) {
|
public SelectionPoint2DEvent(int id, Vector pos, int area) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.blockx = pos.getBlockX();
|
this.blockx = pos.getBlockX();
|
||||||
this.blockz = pos.getBlockZ();
|
this.blockz = pos.getBlockZ();
|
||||||
this.area = area;
|
this.area = area;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypeId() {
|
public String getTypeId() {
|
||||||
return "p2";
|
return "p2";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getParameters() {
|
public String[] getParameters() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
String.valueOf(id),
|
String.valueOf(id),
|
||||||
String.valueOf(blockx),
|
String.valueOf(blockx),
|
||||||
String.valueOf(blockz),
|
String.valueOf(blockz),
|
||||||
String.valueOf(area)
|
String.valueOf(area)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,50 +1,50 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.cui;
|
package com.sk89q.worldedit.internal.cui;
|
||||||
|
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
|
|
||||||
public class SelectionPointEvent implements CUIEvent {
|
public class SelectionPointEvent implements CUIEvent {
|
||||||
|
|
||||||
protected final int id;
|
protected final int id;
|
||||||
protected final Vector pos;
|
protected final Vector pos;
|
||||||
protected final int area;
|
protected final int area;
|
||||||
|
|
||||||
public SelectionPointEvent(int id, Vector pos, int area) {
|
public SelectionPointEvent(int id, Vector pos, int area) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
this.area = area;
|
this.area = area;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypeId() {
|
public String getTypeId() {
|
||||||
return "p";
|
return "p";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getParameters() {
|
public String[] getParameters() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
String.valueOf(id),
|
String.valueOf(id),
|
||||||
String.valueOf(pos.getBlockX()),
|
String.valueOf(pos.getBlockX()),
|
||||||
String.valueOf(pos.getBlockY()),
|
String.valueOf(pos.getBlockY()),
|
||||||
String.valueOf(pos.getBlockZ()),
|
String.valueOf(pos.getBlockZ()),
|
||||||
String.valueOf(area)
|
String.valueOf(area)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,42 +1,42 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.sk89q.worldedit.cui;
|
package com.sk89q.worldedit.internal.cui;
|
||||||
|
|
||||||
public class SelectionPolygonEvent implements CUIEvent {
|
public class SelectionPolygonEvent implements CUIEvent {
|
||||||
protected final int[] vertices;
|
protected final int[] vertices;
|
||||||
|
|
||||||
public SelectionPolygonEvent(int... vertices) {
|
public SelectionPolygonEvent(int... vertices) {
|
||||||
this.vertices = vertices;
|
this.vertices = vertices;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypeId() {
|
public String getTypeId() {
|
||||||
return "poly";
|
return "poly";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getParameters() {
|
public String[] getParameters() {
|
||||||
final String[] ret = new String[vertices.length];
|
final String[] ret = new String[vertices.length];
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (int vertex : vertices) {
|
for (int vertex : vertices) {
|
||||||
ret[i++] = String.valueOf(vertex);
|
ret[i++] = String.valueOf(vertex);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,38 +1,38 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.cui;
|
package com.sk89q.worldedit.internal.cui;
|
||||||
|
|
||||||
public class SelectionShapeEvent implements CUIEvent {
|
public class SelectionShapeEvent implements CUIEvent {
|
||||||
|
|
||||||
protected final String shapeName;
|
protected final String shapeName;
|
||||||
|
|
||||||
public SelectionShapeEvent(String shapeName) {
|
public SelectionShapeEvent(String shapeName) {
|
||||||
this.shapeName = shapeName;
|
this.shapeName = shapeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getTypeId() {
|
public String getTypeId() {
|
||||||
return "s";
|
return "s";
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getParameters() {
|
public String[] getParameters() {
|
||||||
return new String[] { shapeName };
|
return new String[] { shapeName };
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1,172 +1,170 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.expression;
|
package com.sk89q.worldedit.internal.expression;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.internal.expression.lexer.Lexer;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.internal.expression.lexer.tokens.Token;
|
||||||
import com.sk89q.worldedit.expression.lexer.Lexer;
|
import com.sk89q.worldedit.internal.expression.parser.Parser;
|
||||||
import com.sk89q.worldedit.expression.lexer.tokens.Token;
|
import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment;
|
||||||
import com.sk89q.worldedit.expression.parser.Parser;
|
import com.sk89q.worldedit.internal.expression.runtime.Constant;
|
||||||
import com.sk89q.worldedit.expression.runtime.ExpressionEnvironment;
|
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
||||||
import com.sk89q.worldedit.expression.runtime.Constant;
|
import com.sk89q.worldedit.internal.expression.runtime.Functions;
|
||||||
import com.sk89q.worldedit.expression.runtime.EvaluationException;
|
import com.sk89q.worldedit.internal.expression.runtime.RValue;
|
||||||
import com.sk89q.worldedit.expression.runtime.Functions;
|
import com.sk89q.worldedit.internal.expression.runtime.ReturnException;
|
||||||
import com.sk89q.worldedit.expression.runtime.RValue;
|
import com.sk89q.worldedit.internal.expression.runtime.Variable;
|
||||||
import com.sk89q.worldedit.expression.runtime.ReturnException;
|
|
||||||
import com.sk89q.worldedit.expression.runtime.Variable;
|
/**
|
||||||
|
* Compiles and evaluates expressions.
|
||||||
/**
|
*
|
||||||
* Compiles and evaluates expressions.
|
* Supported operators:
|
||||||
*
|
* Logical: &&, ||, ! (unary)
|
||||||
* Supported operators:
|
* Bitwise: ~ (unary), >>, <<
|
||||||
* Logical: &&, ||, ! (unary)
|
* Arithmetic: +, -, *, /, % (modulo), ^ (power), - (unary), --, ++ (prefix only)
|
||||||
* Bitwise: ~ (unary), >>, <<
|
* Comparison: <=, >=, >, <, ==, !=, ~= (near)
|
||||||
* Arithmetic: +, -, *, /, % (modulo), ^ (power), - (unary), --, ++ (prefix only)
|
*
|
||||||
* Comparison: <=, >=, >, <, ==, !=, ~= (near)
|
* Supported functions: abs, acos, asin, atan, atan2, cbrt, ceil, cos, cosh, exp, floor, ln, log, log10, max, max, min, min, rint, round, sin, sinh, sqrt, tan, tanh and more. (See the Functions class or the wiki)
|
||||||
*
|
*
|
||||||
* Supported functions: abs, acos, asin, atan, atan2, cbrt, ceil, cos, cosh, exp, floor, ln, log, log10, max, max, min, min, rint, round, sin, sinh, sqrt, tan, tanh and more. (See the Functions class or the wiki)
|
* Constants: e, pi
|
||||||
*
|
*
|
||||||
* Constants: e, pi
|
* To compile an equation, run <code>Expression.compile("expression here", "var1", "var2"...)</code>
|
||||||
*
|
* If you wish to run the equation multiple times, you can then optimize it, by calling myExpression.optimize();
|
||||||
* To compile an equation, run <code>Expression.compile("expression here", "var1", "var2"...)</code>
|
* You can then run the equation as many times as you want by calling myExpression.evaluate(var1, var2...)
|
||||||
* If you wish to run the equation multiple times, you can then optimize it, by calling myExpression.optimize();
|
* You do not need to pass values for all variables specified while compiling.
|
||||||
* You can then run the equation as many times as you want by calling myExpression.evaluate(var1, var2...)
|
* To query variables after evaluation, you can use myExpression.getVariable("variable name").
|
||||||
* You do not need to pass values for all variables specified while compiling.
|
* To get a value out of these, use myVariable.getValue()
|
||||||
* To query variables after evaluation, you can use myExpression.getVariable("variable name").
|
*
|
||||||
* To get a value out of these, use myVariable.getValue()
|
* Variables are also supported and can be set either by passing values to <code>evaluate</code>
|
||||||
*
|
*
|
||||||
* Variables are also supported and can be set either by passing values to <code>evaluate</code>
|
* @author TomyLobo
|
||||||
*
|
*/
|
||||||
* @author TomyLobo
|
public class Expression {
|
||||||
*/
|
private static final ThreadLocal<Stack<Expression>> instance = new ThreadLocal<Stack<Expression>>();
|
||||||
public class Expression {
|
|
||||||
private static final ThreadLocal<Stack<Expression>> instance = new ThreadLocal<Stack<Expression>>();
|
private final Map<String, RValue> variables = new HashMap<String, RValue>();
|
||||||
|
private final String[] variableNames;
|
||||||
private final Map<String, RValue> variables = new HashMap<String, RValue>();
|
private RValue root;
|
||||||
private final String[] variableNames;
|
private final Functions functions = new Functions();
|
||||||
private RValue root;
|
private ExpressionEnvironment environment;
|
||||||
private final Functions functions = new Functions();
|
|
||||||
private ExpressionEnvironment environment;
|
public static Expression compile(String expression, String... variableNames) throws ExpressionException {
|
||||||
|
return new Expression(expression, variableNames);
|
||||||
public static Expression compile(String expression, String... variableNames) throws ExpressionException {
|
}
|
||||||
return new Expression(expression, variableNames);
|
|
||||||
}
|
private Expression(String expression, String... variableNames) throws ExpressionException {
|
||||||
|
this(Lexer.tokenize(expression), variableNames);
|
||||||
private Expression(String expression, String... variableNames) throws ExpressionException {
|
}
|
||||||
this(Lexer.tokenize(expression), variableNames);
|
|
||||||
}
|
private Expression(List<Token> tokens, String... variableNames) throws ExpressionException {
|
||||||
|
this.variableNames = variableNames;
|
||||||
private Expression(List<Token> tokens, String... variableNames) throws ExpressionException {
|
|
||||||
this.variableNames = variableNames;
|
variables.put("e", new Constant(-1, Math.E));
|
||||||
|
variables.put("pi", new Constant(-1, Math.PI));
|
||||||
variables.put("e", new Constant(-1, Math.E));
|
variables.put("true", new Constant(-1, 1));
|
||||||
variables.put("pi", new Constant(-1, Math.PI));
|
variables.put("false", new Constant(-1, 0));
|
||||||
variables.put("true", new Constant(-1, 1));
|
|
||||||
variables.put("false", new Constant(-1, 0));
|
for (String variableName : variableNames) {
|
||||||
|
if (variables.containsKey(variableName)) {
|
||||||
for (String variableName : variableNames) {
|
throw new ExpressionException(-1, "Tried to overwrite identifier '" + variableName + "'");
|
||||||
if (variables.containsKey(variableName)) {
|
}
|
||||||
throw new ExpressionException(-1, "Tried to overwrite identifier '" + variableName + "'");
|
variables.put(variableName, new Variable(0));
|
||||||
}
|
}
|
||||||
variables.put(variableName, new Variable(0));
|
|
||||||
}
|
root = Parser.parse(tokens, this);
|
||||||
|
}
|
||||||
root = Parser.parse(tokens, this);
|
|
||||||
}
|
public double evaluate(double... values) throws EvaluationException {
|
||||||
|
for (int i = 0; i < values.length; ++i) {
|
||||||
public double evaluate(double... values) throws EvaluationException {
|
final String variableName = variableNames[i];
|
||||||
for (int i = 0; i < values.length; ++i) {
|
final RValue invokable = variables.get(variableName);
|
||||||
final String variableName = variableNames[i];
|
if (!(invokable instanceof Variable)) {
|
||||||
final RValue invokable = variables.get(variableName);
|
throw new EvaluationException(invokable.getPosition(), "Tried to assign constant " + variableName + ".");
|
||||||
if (!(invokable instanceof Variable)) {
|
}
|
||||||
throw new EvaluationException(invokable.getPosition(), "Tried to assign constant " + variableName + ".");
|
|
||||||
}
|
((Variable) invokable).value = values[i];
|
||||||
|
}
|
||||||
((Variable) invokable).value = values[i];
|
|
||||||
}
|
pushInstance();
|
||||||
|
try {
|
||||||
pushInstance();
|
return root.getValue();
|
||||||
try {
|
} catch (ReturnException e) {
|
||||||
return root.getValue();
|
return e.getValue();
|
||||||
} catch (ReturnException e) {
|
} finally {
|
||||||
return e.getValue();
|
popInstance();
|
||||||
} finally {
|
}
|
||||||
popInstance();
|
}
|
||||||
}
|
|
||||||
}
|
public void optimize() throws EvaluationException {
|
||||||
|
root = root.optimize();
|
||||||
public void optimize() throws EvaluationException {
|
}
|
||||||
root = root.optimize();
|
|
||||||
}
|
@Override
|
||||||
|
public String toString() {
|
||||||
@Override
|
return root.toString();
|
||||||
public String toString() {
|
}
|
||||||
return root.toString();
|
|
||||||
}
|
public RValue getVariable(String name, boolean create) {
|
||||||
|
RValue variable = variables.get(name);
|
||||||
public RValue getVariable(String name, boolean create) {
|
if (variable == null && create) {
|
||||||
RValue variable = variables.get(name);
|
variables.put(name, variable = new Variable(0));
|
||||||
if (variable == null && create) {
|
}
|
||||||
variables.put(name, variable = new Variable(0));
|
|
||||||
}
|
return variable;
|
||||||
|
}
|
||||||
return variable;
|
|
||||||
}
|
public static Expression getInstance() {
|
||||||
|
return instance.get().peek();
|
||||||
public static Expression getInstance() {
|
}
|
||||||
return instance.get().peek();
|
|
||||||
}
|
private void pushInstance() {
|
||||||
|
Stack<Expression> foo = instance.get();
|
||||||
private void pushInstance() {
|
if (foo == null) {
|
||||||
Stack<Expression> foo = instance.get();
|
instance.set(foo = new Stack<Expression>());
|
||||||
if (foo == null) {
|
}
|
||||||
instance.set(foo = new Stack<Expression>());
|
|
||||||
}
|
foo.push(this);
|
||||||
|
}
|
||||||
foo.push(this);
|
|
||||||
}
|
private void popInstance() {
|
||||||
|
Stack<Expression> foo = instance.get();
|
||||||
private void popInstance() {
|
|
||||||
Stack<Expression> foo = instance.get();
|
foo.pop();
|
||||||
|
|
||||||
foo.pop();
|
if (foo.isEmpty()) {
|
||||||
|
instance.set(null);
|
||||||
if (foo.isEmpty()) {
|
}
|
||||||
instance.set(null);
|
}
|
||||||
}
|
|
||||||
}
|
public Functions getFunctions() {
|
||||||
|
return functions;
|
||||||
public Functions getFunctions() {
|
}
|
||||||
return functions;
|
|
||||||
}
|
public ExpressionEnvironment getEnvironment() {
|
||||||
|
return environment;
|
||||||
public ExpressionEnvironment getEnvironment() {
|
}
|
||||||
return environment;
|
|
||||||
}
|
public void setEnvironment(ExpressionEnvironment environment) {
|
||||||
|
this.environment = environment;
|
||||||
public void setEnvironment(ExpressionEnvironment environment) {
|
}
|
||||||
this.environment = environment;
|
}
|
||||||
}
|
|
||||||
}
|
|
@ -1,54 +1,54 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.expression;
|
package com.sk89q.worldedit.internal.expression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thrown when there's a problem during any stage of the expression compilation or evaluation.
|
* Thrown when there's a problem during any stage of the expression compilation or evaluation.
|
||||||
*
|
*
|
||||||
* @author TomyLobo
|
* @author TomyLobo
|
||||||
*/
|
*/
|
||||||
public class ExpressionException extends Exception {
|
public class ExpressionException extends Exception {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private final int position;
|
private final int position;
|
||||||
|
|
||||||
public ExpressionException(int position) {
|
public ExpressionException(int position) {
|
||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExpressionException(int position, String message, Throwable cause) {
|
public ExpressionException(int position, String message, Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExpressionException(int position, String message) {
|
public ExpressionException(int position, String message) {
|
||||||
super(message);
|
super(message);
|
||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExpressionException(int position, Throwable cause) {
|
public ExpressionException(int position, Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPosition() {
|
public int getPosition() {
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,61 +1,61 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.expression;
|
package com.sk89q.worldedit.internal.expression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A common superinterface for everything passed to parser processors.
|
* A common superinterface for everything passed to parser processors.
|
||||||
*
|
*
|
||||||
* @author TomyLobo
|
* @author TomyLobo
|
||||||
*/
|
*/
|
||||||
public interface Identifiable {
|
public interface Identifiable {
|
||||||
/**
|
/**
|
||||||
* Returns a character that helps identify the token, pseudo-token or invokable in question.
|
* Returns a character that helps identify the token, pseudo-token or invokable in question.
|
||||||
*
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* Tokens:
|
* Tokens:
|
||||||
* i - IdentifierToken
|
* i - IdentifierToken
|
||||||
* 0 - NumberToken
|
* 0 - NumberToken
|
||||||
* o - OperatorToken
|
* o - OperatorToken
|
||||||
* \0 - NullToken
|
* \0 - NullToken
|
||||||
* CharacterTokens are returned literally
|
* CharacterTokens are returned literally
|
||||||
*
|
*
|
||||||
* PseudoTokens:
|
* PseudoTokens:
|
||||||
* p - UnaryOperator
|
* p - UnaryOperator
|
||||||
* V - UnboundVariable
|
* V - UnboundVariable
|
||||||
*
|
*
|
||||||
* Nodes:
|
* Nodes:
|
||||||
* c - Constant
|
* c - Constant
|
||||||
* v - Variable
|
* v - Variable
|
||||||
* f - Function
|
* f - Function
|
||||||
* l - LValueFunction
|
* l - LValueFunction
|
||||||
* s - Sequence
|
* s - Sequence
|
||||||
* I - Conditional
|
* I - Conditional
|
||||||
* w - While
|
* w - While
|
||||||
* F - For
|
* F - For
|
||||||
* r - Return
|
* r - Return
|
||||||
* b - Break (includes continue)
|
* b - Break (includes continue)
|
||||||
* S - SimpleFor
|
* S - SimpleFor
|
||||||
* C - Switch
|
* C - Switch
|
||||||
* </pre>
|
* </pre>
|
||||||
*/
|
*/
|
||||||
public abstract char id();
|
public abstract char id();
|
||||||
|
|
||||||
public int getPosition();
|
public int getPosition();
|
||||||
}
|
}
|
@ -1,233 +1,233 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.expression.lexer;
|
package com.sk89q.worldedit.internal.expression.lexer;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import com.sk89q.worldedit.expression.lexer.tokens.*;
|
import com.sk89q.worldedit.internal.expression.lexer.tokens.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes a string into a list of tokens.
|
* Processes a string into a list of tokens.
|
||||||
*
|
*
|
||||||
* Tokens can be numbers, identifiers, operators and assorted other characters.
|
* Tokens can be numbers, identifiers, operators and assorted other characters.
|
||||||
*
|
*
|
||||||
* @author TomyLobo
|
* @author TomyLobo
|
||||||
*/
|
*/
|
||||||
public class Lexer {
|
public class Lexer {
|
||||||
private final String expression;
|
private final String expression;
|
||||||
private int position = 0;
|
private int position = 0;
|
||||||
|
|
||||||
private Lexer(String expression) {
|
private Lexer(String expression) {
|
||||||
this.expression = expression;
|
this.expression = expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final List<Token> tokenize(String expression) throws LexerException {
|
public static final List<Token> tokenize(String expression) throws LexerException {
|
||||||
return new Lexer(expression).tokenize();
|
return new Lexer(expression).tokenize();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final DecisionTree operatorTree = new DecisionTree(null,
|
private final DecisionTree operatorTree = new DecisionTree(null,
|
||||||
'+', new DecisionTree("+",
|
'+', new DecisionTree("+",
|
||||||
'=', new DecisionTree("+="),
|
'=', new DecisionTree("+="),
|
||||||
'+', new DecisionTree("++")
|
'+', new DecisionTree("++")
|
||||||
),
|
),
|
||||||
'-', new DecisionTree("-",
|
'-', new DecisionTree("-",
|
||||||
'=', new DecisionTree("-="),
|
'=', new DecisionTree("-="),
|
||||||
'-', new DecisionTree("--")
|
'-', new DecisionTree("--")
|
||||||
),
|
),
|
||||||
'*', new DecisionTree("*",
|
'*', new DecisionTree("*",
|
||||||
'=', new DecisionTree("*="),
|
'=', new DecisionTree("*="),
|
||||||
'*', new DecisionTree("**")
|
'*', new DecisionTree("**")
|
||||||
),
|
),
|
||||||
'/', new DecisionTree("/",
|
'/', new DecisionTree("/",
|
||||||
'=', new DecisionTree("/=")
|
'=', new DecisionTree("/=")
|
||||||
),
|
),
|
||||||
'%', new DecisionTree("%",
|
'%', new DecisionTree("%",
|
||||||
'=', new DecisionTree("%=")
|
'=', new DecisionTree("%=")
|
||||||
),
|
),
|
||||||
'^', new DecisionTree("^",
|
'^', new DecisionTree("^",
|
||||||
'=', new DecisionTree("^=")
|
'=', new DecisionTree("^=")
|
||||||
),
|
),
|
||||||
'=', new DecisionTree("=",
|
'=', new DecisionTree("=",
|
||||||
'=', new DecisionTree("==")
|
'=', new DecisionTree("==")
|
||||||
),
|
),
|
||||||
'!', new DecisionTree("!",
|
'!', new DecisionTree("!",
|
||||||
'=', new DecisionTree("!=")
|
'=', new DecisionTree("!=")
|
||||||
),
|
),
|
||||||
'<', new DecisionTree("<",
|
'<', new DecisionTree("<",
|
||||||
'<', new DecisionTree("<<"),
|
'<', new DecisionTree("<<"),
|
||||||
'=', new DecisionTree("<=")
|
'=', new DecisionTree("<=")
|
||||||
),
|
),
|
||||||
'>', new DecisionTree(">",
|
'>', new DecisionTree(">",
|
||||||
'>', new DecisionTree(">>"),
|
'>', new DecisionTree(">>"),
|
||||||
'=', new DecisionTree(">=")
|
'=', new DecisionTree(">=")
|
||||||
),
|
),
|
||||||
'&', new DecisionTree(null, // not implemented
|
'&', new DecisionTree(null, // not implemented
|
||||||
'&', new DecisionTree("&&")
|
'&', new DecisionTree("&&")
|
||||||
),
|
),
|
||||||
'|', new DecisionTree(null, // not implemented
|
'|', new DecisionTree(null, // not implemented
|
||||||
'|', new DecisionTree("||")
|
'|', new DecisionTree("||")
|
||||||
),
|
),
|
||||||
'~', new DecisionTree("~",
|
'~', new DecisionTree("~",
|
||||||
'=', new DecisionTree("~=")
|
'=', new DecisionTree("~=")
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
private static final Set<Character> characterTokens = new HashSet<Character>();
|
private static final Set<Character> characterTokens = new HashSet<Character>();
|
||||||
static {
|
static {
|
||||||
characterTokens.add(',');
|
characterTokens.add(',');
|
||||||
characterTokens.add('(');
|
characterTokens.add('(');
|
||||||
characterTokens.add(')');
|
characterTokens.add(')');
|
||||||
characterTokens.add('{');
|
characterTokens.add('{');
|
||||||
characterTokens.add('}');
|
characterTokens.add('}');
|
||||||
characterTokens.add(';');
|
characterTokens.add(';');
|
||||||
characterTokens.add('?');
|
characterTokens.add('?');
|
||||||
characterTokens.add(':');
|
characterTokens.add(':');
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Set<String> keywords = new HashSet<String>(Arrays.asList("if", "else", "while", "do", "for", "break", "continue", "return", "switch", "case", "default"));
|
private static final Set<String> keywords = new HashSet<String>(Arrays.asList("if", "else", "while", "do", "for", "break", "continue", "return", "switch", "case", "default"));
|
||||||
|
|
||||||
private static final Pattern numberPattern = Pattern.compile("^([0-9]*(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?)");
|
private static final Pattern numberPattern = Pattern.compile("^([0-9]*(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?)");
|
||||||
private static final Pattern identifierPattern = Pattern.compile("^([A-Za-z][0-9A-Za-z_]*)");
|
private static final Pattern identifierPattern = Pattern.compile("^([A-Za-z][0-9A-Za-z_]*)");
|
||||||
|
|
||||||
private final List<Token> tokenize() throws LexerException {
|
private final List<Token> tokenize() throws LexerException {
|
||||||
List<Token> tokens = new ArrayList<Token>();
|
List<Token> tokens = new ArrayList<Token>();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
skipWhitespace();
|
skipWhitespace();
|
||||||
if (position >= expression.length()) {
|
if (position >= expression.length()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Token token = operatorTree.evaluate(position);
|
Token token = operatorTree.evaluate(position);
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
tokens.add(token);
|
tokens.add(token);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final char ch = peek();
|
final char ch = peek();
|
||||||
|
|
||||||
if (characterTokens.contains(ch)) {
|
if (characterTokens.contains(ch)) {
|
||||||
tokens.add(new CharacterToken(position++, ch));
|
tokens.add(new CharacterToken(position++, ch));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Matcher numberMatcher = numberPattern.matcher(expression.substring(position));
|
final Matcher numberMatcher = numberPattern.matcher(expression.substring(position));
|
||||||
if (numberMatcher.lookingAt()) {
|
if (numberMatcher.lookingAt()) {
|
||||||
String numberPart = numberMatcher.group(1);
|
String numberPart = numberMatcher.group(1);
|
||||||
if (numberPart.length() > 0) {
|
if (numberPart.length() > 0) {
|
||||||
try {
|
try {
|
||||||
tokens.add(new NumberToken(position, Double.parseDouble(numberPart)));
|
tokens.add(new NumberToken(position, Double.parseDouble(numberPart)));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
throw new LexerException(position, "Number parsing failed", e);
|
throw new LexerException(position, "Number parsing failed", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
position += numberPart.length();
|
position += numberPart.length();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final Matcher identifierMatcher = identifierPattern.matcher(expression.substring(position));
|
final Matcher identifierMatcher = identifierPattern.matcher(expression.substring(position));
|
||||||
if (identifierMatcher.lookingAt()) {
|
if (identifierMatcher.lookingAt()) {
|
||||||
String identifierPart = identifierMatcher.group(1);
|
String identifierPart = identifierMatcher.group(1);
|
||||||
if (identifierPart.length() > 0) {
|
if (identifierPart.length() > 0) {
|
||||||
if (keywords.contains(identifierPart)) {
|
if (keywords.contains(identifierPart)) {
|
||||||
tokens.add(new KeywordToken(position, identifierPart));
|
tokens.add(new KeywordToken(position, identifierPart));
|
||||||
} else {
|
} else {
|
||||||
tokens.add(new IdentifierToken(position, identifierPart));
|
tokens.add(new IdentifierToken(position, identifierPart));
|
||||||
}
|
}
|
||||||
|
|
||||||
position += identifierPart.length();
|
position += identifierPart.length();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new LexerException(position, "Unknown character '" + ch + "'");
|
throw new LexerException(position, "Unknown character '" + ch + "'");
|
||||||
} while (position < expression.length());
|
} while (position < expression.length());
|
||||||
|
|
||||||
return tokens;
|
return tokens;
|
||||||
}
|
}
|
||||||
|
|
||||||
private char peek() {
|
private char peek() {
|
||||||
return expression.charAt(position);
|
return expression.charAt(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void skipWhitespace() {
|
private final void skipWhitespace() {
|
||||||
while (position < expression.length() && Character.isWhitespace(peek())) {
|
while (position < expression.length() && Character.isWhitespace(peek())) {
|
||||||
++position;
|
++position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DecisionTree {
|
public class DecisionTree {
|
||||||
private final String tokenName;
|
private final String tokenName;
|
||||||
private final Map<Character, DecisionTree> subTrees = new HashMap<Character, Lexer.DecisionTree>();
|
private final Map<Character, DecisionTree> subTrees = new HashMap<Character, Lexer.DecisionTree>();
|
||||||
|
|
||||||
private DecisionTree(String tokenName, Object... args) {
|
private DecisionTree(String tokenName, Object... args) {
|
||||||
this.tokenName = tokenName;
|
this.tokenName = tokenName;
|
||||||
|
|
||||||
if (args.length % 2 != 0) {
|
if (args.length % 2 != 0) {
|
||||||
throw new UnsupportedOperationException("You need to pass an even number of arguments.");
|
throw new UnsupportedOperationException("You need to pass an even number of arguments.");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < args.length; i += 2) {
|
for (int i = 0; i < args.length; i += 2) {
|
||||||
if (!(args[i] instanceof Character)) {
|
if (!(args[i] instanceof Character)) {
|
||||||
throw new UnsupportedOperationException("Argument #" + i + " expected to be 'Character', not '" + args[i].getClass().getName() + "'.");
|
throw new UnsupportedOperationException("Argument #" + i + " expected to be 'Character', not '" + args[i].getClass().getName() + "'.");
|
||||||
}
|
}
|
||||||
if (!(args[i + 1] instanceof DecisionTree)) {
|
if (!(args[i + 1] instanceof DecisionTree)) {
|
||||||
throw new UnsupportedOperationException("Argument #" + (i + 1) + " expected to be 'DecisionTree', not '" + args[i + 1].getClass().getName() + "'.");
|
throw new UnsupportedOperationException("Argument #" + (i + 1) + " expected to be 'DecisionTree', not '" + args[i + 1].getClass().getName() + "'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
Character next = (Character) args[i];
|
Character next = (Character) args[i];
|
||||||
DecisionTree subTree = (DecisionTree) args[i + 1];
|
DecisionTree subTree = (DecisionTree) args[i + 1];
|
||||||
|
|
||||||
subTrees.put(next, subTree);
|
subTrees.put(next, subTree);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Token evaluate(int startPosition) throws LexerException {
|
private Token evaluate(int startPosition) throws LexerException {
|
||||||
if (position < expression.length()) {
|
if (position < expression.length()) {
|
||||||
final char next = peek();
|
final char next = peek();
|
||||||
|
|
||||||
final DecisionTree subTree = subTrees.get(next);
|
final DecisionTree subTree = subTrees.get(next);
|
||||||
if (subTree != null) {
|
if (subTree != null) {
|
||||||
++position;
|
++position;
|
||||||
final Token subTreeResult = subTree.evaluate(startPosition);
|
final Token subTreeResult = subTree.evaluate(startPosition);
|
||||||
if (subTreeResult != null) {
|
if (subTreeResult != null) {
|
||||||
return subTreeResult;
|
return subTreeResult;
|
||||||
}
|
}
|
||||||
--position;
|
--position;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tokenName == null) {
|
if (tokenName == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new OperatorToken(startPosition, tokenName);
|
return new OperatorToken(startPosition, tokenName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,51 +1,51 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.expression.lexer;
|
package com.sk89q.worldedit.internal.expression.lexer;
|
||||||
|
|
||||||
import com.sk89q.worldedit.expression.ExpressionException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Thrown when the lexer encounters a problem.
|
* Thrown when the lexer encounters a problem.
|
||||||
*
|
*
|
||||||
* @author TomyLobo
|
* @author TomyLobo
|
||||||
*/
|
*/
|
||||||
public class LexerException extends ExpressionException {
|
public class LexerException extends ExpressionException {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public LexerException(int position) {
|
public LexerException(int position) {
|
||||||
super(position, getPrefix(position));
|
super(position, getPrefix(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
public LexerException(int position, String message, Throwable cause) {
|
public LexerException(int position, String message, Throwable cause) {
|
||||||
super(position, getPrefix(position) + ": " + message, cause);
|
super(position, getPrefix(position) + ": " + message, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LexerException(int position, String message) {
|
public LexerException(int position, String message) {
|
||||||
super(position, getPrefix(position) + ": " + message);
|
super(position, getPrefix(position) + ": " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LexerException(int position, Throwable cause) {
|
public LexerException(int position, Throwable cause) {
|
||||||
super(position, getPrefix(position), cause);
|
super(position, getPrefix(position), cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getPrefix(int position) {
|
private static String getPrefix(int position) {
|
||||||
return position < 0 ? "Lexer error" : ("Lexer error at " + (position + 1));
|
return position < 0 ? "Lexer error" : ("Lexer error at " + (position + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,44 +1,44 @@
|
|||||||
// $Id$
|
// $Id$
|
||||||
/*
|
/*
|
||||||
* WorldEdit
|
* WorldEdit
|
||||||
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
* Copyright (C) 2010, 2011 sk89q <http://www.sk89q.com> and contributors
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldedit.expression.lexer.tokens;
|
package com.sk89q.worldedit.internal.expression.lexer.tokens;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single character that doesn't fit any of the other token categories.
|
* A single character that doesn't fit any of the other token categories.
|
||||||
*
|
*
|
||||||
* @author TomyLobo
|
* @author TomyLobo
|
||||||
*/
|
*/
|
||||||
public class CharacterToken extends Token {
|
public class CharacterToken extends Token {
|
||||||
public final char character;
|
public final char character;
|
||||||
|
|
||||||
public CharacterToken(int position, char character) {
|
public CharacterToken(int position, char character) {
|
||||||
super(position);
|
super(position);
|
||||||
this.character = character;
|
this.character = character;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char id() {
|
public char id() {
|
||||||
return character;
|
return character;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "CharacterToken(" + character + ")";
|
return "CharacterToken(" + character + ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren