Overhauled the tool system. All tools can now be bound to any held item so you can have multiple tools out a time. New masks framework allows making a filter of blocks to change. Brushes are now powerful as well.
This commit is contained in:
@@ -19,20 +19,29 @@
|
||||
|
||||
package com.sk89q.worldedit;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Map;
|
||||
import com.sk89q.worldedit.snapshots.Snapshot;
|
||||
import com.sk89q.worldedit.superpickaxe.SinglePickaxe;
|
||||
import com.sk89q.worldedit.superpickaxe.SuperPickaxeMode;
|
||||
import com.sk89q.worldedit.superpickaxe.brushes.BrushShape;
|
||||
import com.sk89q.worldedit.tools.Brush;
|
||||
import com.sk89q.worldedit.tools.SinglePickaxe;
|
||||
import com.sk89q.worldedit.tools.BlockTool;
|
||||
import com.sk89q.worldedit.tools.Tool;
|
||||
import com.sk89q.worldedit.bags.BlockBag;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
|
||||
/**
|
||||
* An instance of this represents the WorldEdit session of a user. A session
|
||||
* stores history and settings. Sessions are not tied particularly to any
|
||||
* player and can be shuffled between players, saved, and loaded.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class LocalSession {
|
||||
/**
|
||||
* List of compass modes.
|
||||
*/
|
||||
public enum CompassMode {
|
||||
JUMPTO,
|
||||
THRU
|
||||
@@ -50,15 +59,14 @@ public class LocalSession {
|
||||
private CuboidClipboard clipboard;
|
||||
private boolean toolControl = true;
|
||||
private boolean superPickaxe = false;
|
||||
private SuperPickaxeMode leftClickMode = new SinglePickaxe();
|
||||
private SuperPickaxeMode armSwingMode;
|
||||
private SuperPickaxeMode rightClickMode;
|
||||
private BlockTool pickaxeMode = new SinglePickaxe();
|
||||
private Map<Integer, Tool> tools
|
||||
= new HashMap<Integer, Tool>();
|
||||
private int maxBlocksChanged = -1;
|
||||
private boolean useInventory;
|
||||
private Snapshot snapshot;
|
||||
private String lastScript;
|
||||
private CompassMode compassMode = CompassMode.JUMPTO;
|
||||
private BrushShape brushShape = null;
|
||||
private boolean beenToldVersion = false;
|
||||
|
||||
/**
|
||||
@@ -79,7 +87,10 @@ public class LocalSession {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the edit session.
|
||||
* Remember an edit session for the undo history. If the history maximum
|
||||
* size is reached, old edit sessions will be discarded.
|
||||
*
|
||||
* @param editSession
|
||||
*/
|
||||
public void remember(EditSession editSession) {
|
||||
// Don't store anything if no changes were made
|
||||
@@ -97,16 +108,18 @@ public class LocalSession {
|
||||
}
|
||||
|
||||
/**
|
||||
* Undo.
|
||||
* Performs an undo.
|
||||
*
|
||||
* @param newBlockBag
|
||||
* @return whether anything was undone
|
||||
*/
|
||||
public EditSession undo(BlockBag newBlockBag) {
|
||||
historyPointer--;
|
||||
if (historyPointer >= 0) {
|
||||
EditSession editSession = history.get(historyPointer);
|
||||
editSession.setBlockBag(newBlockBag);
|
||||
editSession.undo();
|
||||
EditSession newEditSession =
|
||||
new EditSession(editSession.getWorld(), -1, newBlockBag);
|
||||
editSession.undo(newEditSession);
|
||||
return editSession;
|
||||
} else {
|
||||
historyPointer = 0;
|
||||
@@ -115,15 +128,17 @@ public class LocalSession {
|
||||
}
|
||||
|
||||
/**
|
||||
* Redo.
|
||||
* Performs a redo
|
||||
*
|
||||
* @param newBlockBag
|
||||
* @return whether anything was redone
|
||||
*/
|
||||
public EditSession redo(BlockBag newBlockBag) {
|
||||
if (historyPointer < history.size()) {
|
||||
EditSession editSession = history.get(historyPointer);
|
||||
editSession.setBlockBag(newBlockBag);
|
||||
editSession.redo();
|
||||
EditSession newEditSession =
|
||||
new EditSession(editSession.getWorld(), -1, newBlockBag);
|
||||
editSession.redo(newEditSession);
|
||||
historyPointer++;
|
||||
return editSession;
|
||||
}
|
||||
@@ -155,8 +170,8 @@ public class LocalSession {
|
||||
|
||||
/**
|
||||
* Returns true if the region is fully defined.
|
||||
*
|
||||
* @throws IncompleteRegionException
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isRegionDefined() {
|
||||
return pos1 != null && pos2 != null;
|
||||
@@ -303,8 +318,6 @@ public class LocalSession {
|
||||
|
||||
/**
|
||||
* Enable super pick axe.
|
||||
*
|
||||
* @param superPickaxe
|
||||
*/
|
||||
public void enableSuperPickAxe() {
|
||||
superPickaxe = true;
|
||||
@@ -312,8 +325,6 @@ public class LocalSession {
|
||||
|
||||
/**
|
||||
* Disable super pick axe.
|
||||
*
|
||||
* @param superPickaxe
|
||||
*/
|
||||
public void disableSuperPickAxe() {
|
||||
superPickaxe = false;
|
||||
@@ -330,6 +341,9 @@ public class LocalSession {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the placement position.
|
||||
*
|
||||
* @param player
|
||||
* @return position
|
||||
* @throws IncompleteRegionException
|
||||
*/
|
||||
@@ -344,7 +358,9 @@ public class LocalSession {
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle placement position;
|
||||
* Toggle placement position.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean togglePlacementPosition() {
|
||||
placeAtPos1 = !placeAtPos1;
|
||||
@@ -365,13 +381,17 @@ public class LocalSession {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the snapshotName
|
||||
* Get the snapshot that has been selected.
|
||||
*
|
||||
* @return the snapshot
|
||||
*/
|
||||
public Snapshot getSnapshot() {
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select a snapshot.
|
||||
*
|
||||
* @param snapshot
|
||||
*/
|
||||
public void setSnapshot(Snapshot snapshot) {
|
||||
@@ -381,46 +401,61 @@ public class LocalSession {
|
||||
/**
|
||||
* @return the superPickaxeMode
|
||||
*/
|
||||
public SuperPickaxeMode getLeftClickMode() {
|
||||
return leftClickMode;
|
||||
public BlockTool getSuperPickaxe() {
|
||||
return pickaxeMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param superPickaxeMode the superPickaxeMode to set
|
||||
* Set the super pickaxe tool.
|
||||
*
|
||||
* @param tool
|
||||
*/
|
||||
public void setLeftClickMode(SuperPickaxeMode leftClickMode) {
|
||||
this.leftClickMode = leftClickMode;
|
||||
public void setSuperPickaxe(BlockTool tool) {
|
||||
this.pickaxeMode = tool;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tool assigned to the item.
|
||||
*
|
||||
* @param item
|
||||
* @return the tool
|
||||
*/
|
||||
public SuperPickaxeMode getRightClickMode() {
|
||||
return rightClickMode;
|
||||
public Tool getTool(int item) {
|
||||
return tools.get(item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the brush tool assigned to the item. If there is no tool assigned
|
||||
* or the tool is not assigned, the slot will be replaced with the
|
||||
* brush tool.
|
||||
*
|
||||
* @param item
|
||||
* @return the tool
|
||||
*/
|
||||
public Brush getBrushTool(int item) {
|
||||
Tool tool = getTool(item);
|
||||
|
||||
if (tool == null || !(tool instanceof Brush)) {
|
||||
tool = new Brush();
|
||||
setTool(item, tool);
|
||||
}
|
||||
|
||||
return (Brush)tool;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the tool.
|
||||
*
|
||||
* @param item
|
||||
* @param tool the tool to set
|
||||
*/
|
||||
public void setRightClickMode(SuperPickaxeMode rightClickMode) {
|
||||
this.rightClickMode = rightClickMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the arm swing mode
|
||||
*/
|
||||
public SuperPickaxeMode getArmSwingMode() {
|
||||
return armSwingMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param rightClickMode the tool to set
|
||||
*/
|
||||
public void setArmSwingMode(SuperPickaxeMode armSwingMode) {
|
||||
this.armSwingMode = armSwingMode;
|
||||
public void setTool(int item, Tool tool) {
|
||||
this.tools.put(item, tool);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether inventory usage is enabled for this session.
|
||||
*
|
||||
* @return the useInventory
|
||||
*/
|
||||
public boolean isUsingInventory() {
|
||||
@@ -428,6 +463,8 @@ public class LocalSession {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the state of inventory usage.
|
||||
*
|
||||
* @param useInventory the useInventory to set
|
||||
*/
|
||||
public void setUseInventory(boolean useInventory) {
|
||||
@@ -435,6 +472,8 @@ public class LocalSession {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the last script used.
|
||||
*
|
||||
* @return the lastScript
|
||||
*/
|
||||
public String getLastScript() {
|
||||
@@ -442,6 +481,8 @@ public class LocalSession {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the last script used.
|
||||
*
|
||||
* @param lastScript the lastScript to set
|
||||
*/
|
||||
public void setLastScript(String lastScript) {
|
||||
@@ -449,6 +490,8 @@ public class LocalSession {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the compass mode.
|
||||
*
|
||||
* @return the compassMode
|
||||
*/
|
||||
public CompassMode getCompassMode() {
|
||||
@@ -456,28 +499,18 @@ public class LocalSession {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the compass mode.
|
||||
*
|
||||
* @param compassMode the compassMode to set
|
||||
*/
|
||||
public void setCompassMode(CompassMode compassMode) {
|
||||
this.compassMode = compassMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the brushShape
|
||||
*/
|
||||
public BrushShape getBrushShape() {
|
||||
return brushShape;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param brushShape the brushShape to set
|
||||
*/
|
||||
public void setBrushShape(BrushShape brushShape) {
|
||||
this.brushShape = brushShape;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tell the player the WorldEdit version.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public void tellVersion(LocalPlayer player) {
|
||||
if (config.showFirstUseVersion) {
|
||||
|
||||
Reference in New Issue
Block a user