geforkt von Mirrors/FastAsyncWorldEdit
Code clean up, add preconditions, and correct Javadocs.
Dieser Commit ist enthalten in:
Ursprung
70bca47be7
Commit
e95eeefa2b
@ -53,6 +53,7 @@ import java.util.Collection;
|
|||||||
* as a "wildcard" block value, even though a {@link Mask} would be
|
* as a "wildcard" block value, even though a {@link Mask} would be
|
||||||
* more appropriate.</p>
|
* more appropriate.</p>
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public class BaseBlock extends Block implements TileEntityBlock {
|
public class BaseBlock extends Block implements TileEntityBlock {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -251,9 +252,8 @@ public class BaseBlock extends Block implements TileEntityBlock {
|
|||||||
return nbtData;
|
return nbtData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
@Override
|
||||||
public void setNbtData(CompoundTag nbtData) {
|
public void setNbtData(@Nullable CompoundTag nbtData) {
|
||||||
this.nbtData = nbtData;
|
this.nbtData = nbtData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,11 +359,9 @@ public class BaseBlock extends Block implements TileEntityBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final BaseBlock otherBlock = (BaseBlock) o;
|
final BaseBlock otherBlock = (BaseBlock) o;
|
||||||
if (getType() != otherBlock.getType()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return getData() == otherBlock.getData();
|
return getType() == otherBlock.getType() && getData() == otherBlock.getData();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -21,8 +21,6 @@ package com.sk89q.worldedit.blocks;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* List of block IDs.
|
* List of block IDs.
|
||||||
*
|
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public final class BlockID {
|
public final class BlockID {
|
||||||
public static final int AIR = 0;
|
public static final int AIR = 0;
|
||||||
|
@ -24,48 +24,160 @@ package com.sk89q.worldedit.blocks;
|
|||||||
*/
|
*/
|
||||||
public interface BlockMaterial {
|
public interface BlockMaterial {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether this block is rendered like a normal block.
|
||||||
|
*
|
||||||
|
* @return the value of the test
|
||||||
|
*/
|
||||||
boolean isRenderedAsNormalBlock();
|
boolean isRenderedAsNormalBlock();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether this block is a full sized cube.
|
||||||
|
*
|
||||||
|
* @return the value of the test
|
||||||
|
*/
|
||||||
boolean isFullCube();
|
boolean isFullCube();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether this block is opaque.
|
||||||
|
*
|
||||||
|
* @return the value of the test
|
||||||
|
*/
|
||||||
boolean isOpaque();
|
boolean isOpaque();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether this block emits a Redstone signal.
|
||||||
|
*
|
||||||
|
* @return the value of the test
|
||||||
|
*/
|
||||||
boolean isPowerSource();
|
boolean isPowerSource();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether this block is a liquid.
|
||||||
|
*
|
||||||
|
* @return the value of the test
|
||||||
|
*/
|
||||||
boolean isLiquid();
|
boolean isLiquid();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether this block is a solid.
|
||||||
|
*
|
||||||
|
* @return the value of the test
|
||||||
|
*/
|
||||||
boolean isSolid();
|
boolean isSolid();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the hardness factor for this block.
|
||||||
|
*
|
||||||
|
* @return the hardness factor
|
||||||
|
*/
|
||||||
float getHardness();
|
float getHardness();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the resistance factor for this block.
|
||||||
|
*
|
||||||
|
* @return the resistance factor
|
||||||
|
*/
|
||||||
float getResistance();
|
float getResistance();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the slipperiness factor for this block.
|
||||||
|
*
|
||||||
|
* @return the slipperiness factor
|
||||||
|
*/
|
||||||
float getSlipperiness();
|
float getSlipperiness();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether this block blocks grass from growing.
|
||||||
|
*
|
||||||
|
* @return whether this block blocks grass
|
||||||
|
*/
|
||||||
boolean isGrassBlocking();
|
boolean isGrassBlocking();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the ambient occlusion light value.
|
||||||
|
*
|
||||||
|
* @return the ambient occlusion light value
|
||||||
|
*/
|
||||||
float getAmbientOcclusionLightValue();
|
float getAmbientOcclusionLightValue();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the opacity of this block for light to pass through.
|
||||||
|
*
|
||||||
|
* @return the opacity
|
||||||
|
*/
|
||||||
int getLightOpacity();
|
int getLightOpacity();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the light value for this block.
|
||||||
|
*
|
||||||
|
* @return the light value
|
||||||
|
*/
|
||||||
int getLightValue();
|
int getLightValue();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether this block breaks when it is pushed by a piston.
|
||||||
|
*
|
||||||
|
* @return true if the block breaks
|
||||||
|
*/
|
||||||
boolean isFragileWhenPushed();
|
boolean isFragileWhenPushed();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether this block can be pushed by a piston.
|
||||||
|
*
|
||||||
|
* @return true if the block cannot be pushed
|
||||||
|
*/
|
||||||
boolean isUnpushable();
|
boolean isUnpushable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether this block can be used in adventure mode.
|
||||||
|
*
|
||||||
|
* @return true if the block can be used in adventure mode
|
||||||
|
*/
|
||||||
boolean isAdventureModeExempt();
|
boolean isAdventureModeExempt();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether this block is ticked randomly.
|
||||||
|
*
|
||||||
|
* @return true if this block is ticked randomly
|
||||||
|
*/
|
||||||
boolean isTicksRandomly();
|
boolean isTicksRandomly();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether this block uses a neighbor's light value.
|
||||||
|
*
|
||||||
|
* @return true if this block does
|
||||||
|
*/
|
||||||
boolean isUsingNeighborLight();
|
boolean isUsingNeighborLight();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether this block prevents movement.
|
||||||
|
*
|
||||||
|
* @return true if this block blocks movement
|
||||||
|
*/
|
||||||
boolean isMovementBlocker();
|
boolean isMovementBlocker();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether this block will burn.
|
||||||
|
*
|
||||||
|
* @return true if this block will burn
|
||||||
|
*/
|
||||||
boolean isBurnable();
|
boolean isBurnable();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether this block needs to be broken by a tool for maximum
|
||||||
|
* speed.
|
||||||
|
*
|
||||||
|
* @return true if a tool is required
|
||||||
|
*/
|
||||||
boolean isToolRequired();
|
boolean isToolRequired();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get whether this block is replaced when a block is placed over it
|
||||||
|
* (for example, tall grass).
|
||||||
|
*
|
||||||
|
* @return true if the block is replaced
|
||||||
|
*/
|
||||||
boolean isReplacedDuringPlacement();
|
boolean isReplacedDuringPlacement();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,22 @@ package com.sk89q.worldedit.entity;
|
|||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.world.NbtValued;
|
import com.sk89q.worldedit.world.NbtValued;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A snapshot of an entity that can be reused and passed around.
|
* Represents a mutable "snapshot" of an entity.
|
||||||
|
*
|
||||||
|
* <p>An instance of this class contains all the information needed to
|
||||||
|
* accurately reproduce the entity, provided that the instance was
|
||||||
|
* made correctly. In some implementations, it may not be possible to get a
|
||||||
|
* snapshot of entities correctly, so, for example, the NBT data for an entity
|
||||||
|
* may be missing.</p>
|
||||||
|
*
|
||||||
|
* <p>This class identifies entities using its entity type string, although
|
||||||
|
* this is not very efficient as the types are currently not interned. This
|
||||||
|
* may be changed in the future.</p>
|
||||||
*/
|
*/
|
||||||
public class BaseEntity implements NbtValued {
|
public class BaseEntity implements NbtValued {
|
||||||
|
|
||||||
@ -68,14 +80,14 @@ public class BaseEntity implements NbtValued {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getNbtData() {
|
public CompoundTag getNbtData() {
|
||||||
return nbtData;
|
return nbtData;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setNbtData(CompoundTag nbtData) {
|
public void setNbtData(@Nullable CompoundTag nbtData) {
|
||||||
checkNotNull(nbtData);
|
|
||||||
this.nbtData = nbtData;
|
this.nbtData = nbtData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,19 +28,21 @@ import javax.annotation.Nullable;
|
|||||||
/**
|
/**
|
||||||
* A reference to an instance of an entity that exists in an {@link Extent}
|
* A reference to an instance of an entity that exists in an {@link Extent}
|
||||||
* and thus would have position and similar details.
|
* and thus would have position and similar details.
|
||||||
* </p>
|
*
|
||||||
* This object cannot be directly cloned because it represents a particular
|
* <p>This object cannot be directly cloned because it represents a particular
|
||||||
* instance of an entity, but a {@link BaseEntity} can be created from
|
* instance of an entity, but a {@link BaseEntity} can be created from
|
||||||
* this entity (or at least, it will be possible in the future), which
|
* this entity by calling {@link #getState()}.</p>
|
||||||
* can then be used to spawn new instances of that particular entity
|
|
||||||
* description.
|
|
||||||
*/
|
*/
|
||||||
public interface Entity extends Faceted {
|
public interface Entity extends Faceted {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a copy of the entity's state.
|
* Get a copy of the entity's state.
|
||||||
*
|
*
|
||||||
* @return the entity's state or null if one cannot be gotten
|
* <p>In some cases, this method may return {@code null} if a snapshot
|
||||||
|
* of the entity can't be created. It may not be possible, for example,
|
||||||
|
* to get a snapshot of a player.</p>
|
||||||
|
*
|
||||||
|
* @return the entity's state or null if one cannot be created
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
BaseEntity getState();
|
BaseEntity getState();
|
||||||
|
@ -30,7 +30,7 @@ import com.sk89q.worldedit.extent.inventory.BlockBag;
|
|||||||
import com.sk89q.worldedit.world.World;
|
import com.sk89q.worldedit.world.World;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A player.
|
* Represents a player
|
||||||
*/
|
*/
|
||||||
public interface Player extends Entity, Actor {
|
public interface Player extends Entity, Actor {
|
||||||
|
|
||||||
@ -192,12 +192,19 @@ public interface Player extends Entity, Actor {
|
|||||||
* Get the point of the block being looked at. May return null.
|
* Get the point of the block being looked at. May return null.
|
||||||
* Will return the farthest away air block if useLastBlock is true and no other block is found.
|
* Will return the farthest away air block if useLastBlock is true and no other block is found.
|
||||||
*
|
*
|
||||||
* @param range How far to checks for blocks
|
* @param range how far to checks for blocks
|
||||||
* @param useLastBlock Try to return the last valid air block found.
|
* @param useLastBlock try to return the last valid air block found
|
||||||
* @return point
|
* @return point
|
||||||
*/
|
*/
|
||||||
WorldVector getBlockTrace(int range, boolean useLastBlock);
|
WorldVector getBlockTrace(int range, boolean useLastBlock);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the face that the player is looking at.
|
||||||
|
*
|
||||||
|
* @param range the range
|
||||||
|
* @param useLastBlock try to return the last valid air block found
|
||||||
|
* @return a face
|
||||||
|
*/
|
||||||
WorldVectorFace getBlockTraceFace(int range, boolean useLastBlock);
|
WorldVectorFace getBlockTraceFace(int range, boolean useLastBlock);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -225,25 +232,31 @@ public interface Player extends Entity, Actor {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the actor's position.
|
* Get the actor's position.
|
||||||
* </p>
|
*
|
||||||
* If the actor has no permission, then return a dummy location.
|
* <p>If the actor has no permission, then a dummy location is returned.</p>
|
||||||
*
|
*
|
||||||
* @return the actor's position
|
* @return the actor's position
|
||||||
|
* @deprecated use {@link #getLocation()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
WorldVector getPosition();
|
WorldVector getPosition();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the player's view pitch.
|
* Get the player's view pitch in degrees.
|
||||||
*
|
*
|
||||||
* @return pitch
|
* @return pitch
|
||||||
|
* @deprecated use {@link #getLocation()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
double getPitch();
|
double getPitch();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the player's view yaw.
|
* Get the player's view yaw in degrees.
|
||||||
*
|
*
|
||||||
* @return yaw
|
* @return yaw
|
||||||
|
* @deprecated use {@link #getLocation()}
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
double getYaw();
|
double getYaw();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -257,16 +270,16 @@ public interface Player extends Entity, Actor {
|
|||||||
/**
|
/**
|
||||||
* Move the player.
|
* Move the player.
|
||||||
*
|
*
|
||||||
* @param pos Where to move them
|
* @param pos where to move them
|
||||||
* @param pitch The pitch (up/down) of the player's view
|
* @param pitch the pitch (up/down) of the player's view in degrees
|
||||||
* @param yaw The yaw (left/right) of the player's view
|
* @param yaw the yaw (left/right) of the player's view in degrees
|
||||||
*/
|
*/
|
||||||
void setPosition(Vector pos, float pitch, float yaw);
|
void setPosition(Vector pos, float pitch, float yaw);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move the player.
|
* Move the player.
|
||||||
*
|
*
|
||||||
* @param pos Where to move them
|
* @param pos where to move them
|
||||||
*/
|
*/
|
||||||
void setPosition(Vector pos);
|
void setPosition(Vector pos);
|
||||||
|
|
||||||
|
@ -34,17 +34,19 @@ import static com.sk89q.worldedit.EditSession.Stage;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Raised (several times) when a new {@link EditSession} is being instantiated.
|
* Raised (several times) when a new {@link EditSession} is being instantiated.
|
||||||
* </p>
|
*
|
||||||
* Block loggers, as well as block set interceptors, can use this event to wrap
|
* <p></p>Block loggers, as well as block set interceptors, can use this event to wrap
|
||||||
* the given {@link Extent} with their own, which would allow them to intercept
|
* the given {@link Extent} with their own, which would allow them to intercept
|
||||||
* all changes made to the world. For example, the code below would wrap the
|
* all changes made to the world. For example, the code below would wrap the
|
||||||
* existing extent with a custom one, and the custom extent would receive
|
* existing extent with a custom one, and the custom extent would receive
|
||||||
* all method calls <strong>before</strong> the extent fetched from
|
* all method calls <strong>before</strong> the extent fetched from
|
||||||
* {@link #getExtent()} would.
|
* {@link #getExtent()} would.</p>
|
||||||
|
*
|
||||||
* <pre>
|
* <pre>
|
||||||
* event.setExtent(new MyExtent(event.getExtent())
|
* event.setExtent(new MyExtent(event.getExtent())
|
||||||
* </pre>
|
* </pre>
|
||||||
* This event is fired several times during the creation of a single
|
*
|
||||||
|
* <p></p>This event is fired several times during the creation of a single
|
||||||
* {@link EditSession}, but {@link #getStage()} will differ each time.
|
* {@link EditSession}, but {@link #getStage()} will differ each time.
|
||||||
* The stage determines at which point {@link Extent}s added to this event
|
* The stage determines at which point {@link Extent}s added to this event
|
||||||
* will be called. For example, if you inject an extent when the stage
|
* will be called. For example, if you inject an extent when the stage
|
||||||
@ -55,7 +57,7 @@ import static com.sk89q.worldedit.EditSession.Stage;
|
|||||||
* custom {@link Extent} because that method bypasses history (and reorder).
|
* custom {@link Extent} because that method bypasses history (and reorder).
|
||||||
* It is thus recommended that loggers intercept at {@link Stage#BEFORE_CHANGE}
|
* It is thus recommended that loggers intercept at {@link Stage#BEFORE_CHANGE}
|
||||||
* and block interceptors intercept at BOTH {@link Stage#BEFORE_CHANGE} and
|
* and block interceptors intercept at BOTH {@link Stage#BEFORE_CHANGE} and
|
||||||
* {@link Stage#BEFORE_HISTORY}.
|
* {@link Stage#BEFORE_HISTORY}.</p>
|
||||||
*/
|
*/
|
||||||
public class EditSessionEvent extends Event {
|
public class EditSessionEvent extends Event {
|
||||||
|
|
||||||
|
@ -31,9 +31,9 @@ import java.util.Set;
|
|||||||
/**
|
/**
|
||||||
* A registry of known {@link BaseBlock}s. Provides methods to instantiate
|
* A registry of known {@link BaseBlock}s. Provides methods to instantiate
|
||||||
* new blocks from input.
|
* new blocks from input.
|
||||||
* </p>
|
*
|
||||||
* Instances of this class can be taken from
|
* <p>Instances of this class can be taken from
|
||||||
* {@link WorldEdit#getBlockFactory()}.
|
* {@link WorldEdit#getBlockFactory()}.</p>
|
||||||
*/
|
*/
|
||||||
public class BlockFactory extends AbstractFactory<BaseBlock> {
|
public class BlockFactory extends AbstractFactory<BaseBlock> {
|
||||||
|
|
||||||
|
@ -144,7 +144,7 @@ class DefaultBlockParser extends InputParser<BaseBlock> {
|
|||||||
if (parseDataValue) { // Block data not yet detected
|
if (parseDataValue) { // Block data not yet detected
|
||||||
// Parse the block data (optional)
|
// Parse the block data (optional)
|
||||||
try {
|
try {
|
||||||
if (typeAndData.length > 1 && typeAndData[1].length() > 0) {
|
if (typeAndData.length > 1 && !typeAndData[1].isEmpty()) {
|
||||||
data = Integer.parseInt(typeAndData[1]);
|
data = Integer.parseInt(typeAndData[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ class DefaultMaskParser extends InputParser<Mask> {
|
|||||||
List<Mask> masks = new ArrayList<Mask>();
|
List<Mask> masks = new ArrayList<Mask>();
|
||||||
|
|
||||||
for (String component : input.split(" ")) {
|
for (String component : input.split(" ")) {
|
||||||
if (component.length() == 0) {
|
if (component.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,9 +26,9 @@ import com.sk89q.worldedit.internal.registry.AbstractFactory;
|
|||||||
/**
|
/**
|
||||||
* A registry of known {@link Mask}s. Provides methods to instantiate
|
* A registry of known {@link Mask}s. Provides methods to instantiate
|
||||||
* new masks from input.
|
* new masks from input.
|
||||||
* </p>
|
*
|
||||||
* Instances of this class can be taken from
|
* <p>Instances of this class can be taken from
|
||||||
* {@link WorldEdit#getMaskFactory()}.
|
* {@link WorldEdit#getMaskFactory()}.</p>
|
||||||
*/
|
*/
|
||||||
public final class MaskFactory extends AbstractFactory<Mask> {
|
public final class MaskFactory extends AbstractFactory<Mask> {
|
||||||
|
|
||||||
|
@ -26,9 +26,9 @@ import com.sk89q.worldedit.internal.registry.AbstractFactory;
|
|||||||
/**
|
/**
|
||||||
* A registry of known {@link Pattern}s. Provides methods to instantiate
|
* A registry of known {@link Pattern}s. Provides methods to instantiate
|
||||||
* new patterns from input.
|
* new patterns from input.
|
||||||
* </p>
|
*
|
||||||
* Instances of this class can be taken from
|
* <p>Instances of this class can be taken from
|
||||||
* {@link WorldEdit#getPatternFactory()}.
|
* {@link WorldEdit#getPatternFactory()}.</p>
|
||||||
*/
|
*/
|
||||||
public final class PatternFactory extends AbstractFactory<Pattern> {
|
public final class PatternFactory extends AbstractFactory<Pattern> {
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ import javax.annotation.Nullable;
|
|||||||
/**
|
/**
|
||||||
* Contains contextual information that may be useful when constructing
|
* Contains contextual information that may be useful when constructing
|
||||||
* objects from a registry (such as {@link MaskFactory}).
|
* objects from a registry (such as {@link MaskFactory}).
|
||||||
* </p>
|
*
|
||||||
* By default, {@link #isRestricted()} will return true.
|
* <p>By default, {@link #isRestricted()} will return true.</p>
|
||||||
*/
|
*/
|
||||||
public class ParserContext {
|
public class ParserContext {
|
||||||
|
|
||||||
|
@ -59,8 +59,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles the registration and invocation of commands.
|
* Handles the registration and invocation of commands.
|
||||||
* </p>
|
*
|
||||||
* This class is primarily for internal usage.
|
* <p>This class is primarily for internal usage.</p>
|
||||||
*/
|
*/
|
||||||
public final class CommandManager {
|
public final class CommandManager {
|
||||||
|
|
||||||
@ -206,7 +206,7 @@ public final class CommandManager {
|
|||||||
Request.reset();
|
Request.reset();
|
||||||
|
|
||||||
Actor actor = platformManager.createProxyActor(event.getActor());
|
Actor actor = platformManager.createProxyActor(event.getActor());
|
||||||
String split[] = commandDetection(event.getArguments().split(" "));
|
String[] split = commandDetection(event.getArguments().split(" "));
|
||||||
|
|
||||||
// No command found!
|
// No command found!
|
||||||
if (!dispatcher.contains(split[0])) {
|
if (!dispatcher.contains(split[0])) {
|
||||||
|
@ -44,8 +44,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
/**
|
/**
|
||||||
* Manages registered {@link Platform}s for WorldEdit. Platforms are
|
* Manages registered {@link Platform}s for WorldEdit. Platforms are
|
||||||
* implementations of WorldEdit.
|
* implementations of WorldEdit.
|
||||||
* </p>
|
*
|
||||||
* This class is thread-safe.
|
* <p>This class is thread-safe.</p>
|
||||||
*/
|
*/
|
||||||
public class PlatformManager {
|
public class PlatformManager {
|
||||||
|
|
||||||
@ -99,9 +99,9 @@ public class PlatformManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregister a platform from WorldEdit.
|
* Unregister a platform from WorldEdit.
|
||||||
* </p>
|
*
|
||||||
* If the platform has been chosen for any capabilities, then a new
|
* <p>If the platform has been chosen for any capabilities, then a new
|
||||||
* platform will be found.
|
* platform will be found.</p>
|
||||||
*
|
*
|
||||||
* @param platform the platform
|
* @param platform the platform
|
||||||
*/
|
*/
|
||||||
@ -189,8 +189,8 @@ public class PlatformManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of loaded platforms.
|
* Get a list of loaded platforms.
|
||||||
* </p>
|
*
|
||||||
* The returned list is a copy of the original and is mutable.
|
* <p>The returned list is a copy of the original and is mutable.</p>
|
||||||
*
|
*
|
||||||
* @return a list of platforms
|
* @return a list of platforms
|
||||||
*/
|
*/
|
||||||
@ -252,9 +252,9 @@ public class PlatformManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current configuration.
|
* Get the current configuration.
|
||||||
* </p>
|
*
|
||||||
* If no platform has been registered yet, then a default configuration
|
* <p>If no platform has been registered yet, then a default configuration
|
||||||
* will be returned.
|
* will be returned.</p>
|
||||||
*
|
*
|
||||||
* @return the configuration
|
* @return the configuration
|
||||||
*/
|
*/
|
||||||
@ -365,7 +365,6 @@ public class PlatformManager {
|
|||||||
// Create a proxy actor with a potentially different world for
|
// Create a proxy actor with a potentially different world for
|
||||||
// making changes to the world
|
// making changes to the world
|
||||||
Player player = createProxyActor(event.getPlayer());
|
Player player = createProxyActor(event.getPlayer());
|
||||||
World world = player.getWorld();
|
|
||||||
|
|
||||||
switch (event.getInputType()) {
|
switch (event.getInputType()) {
|
||||||
case PRIMARY: {
|
case PRIMARY: {
|
||||||
|
@ -39,9 +39,9 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the minimum point in the extent.
|
* Get the minimum point in the extent.
|
||||||
* </p>
|
*
|
||||||
* If the extent is unbounded, then a large (negative) value may
|
* <p>If the extent is unbounded, then a large (negative) value may
|
||||||
* be returned.
|
* be returned.</p>
|
||||||
*
|
*
|
||||||
* @return the minimum point
|
* @return the minimum point
|
||||||
*/
|
*/
|
||||||
@ -49,9 +49,9 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the maximum point in the extent.
|
* Get the maximum point in the extent.
|
||||||
* </p>
|
*
|
||||||
* If the extent is unbounded, then a large (positive) value may
|
* <p>If the extent is unbounded, then a large (positive) value may
|
||||||
* be returned.
|
* be returned.</p>
|
||||||
*
|
*
|
||||||
* @return the maximum point
|
* @return the maximum point
|
||||||
*/
|
*/
|
||||||
@ -59,10 +59,10 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of all entities within the given region.
|
* Get a list of all entities within the given region.
|
||||||
* </p>
|
*
|
||||||
* If the extent is not wholly loaded (i.e. a world being simulated in the
|
* <p>If the extent is not wholly loaded (i.e. a world being simulated in the
|
||||||
* game will not have every chunk loaded), then this list may not be
|
* game will not have every chunk loaded), then this list may not be
|
||||||
* incomplete.
|
* incomplete.</p>
|
||||||
*
|
*
|
||||||
* @return a list of entities
|
* @return a list of entities
|
||||||
*/
|
*/
|
||||||
@ -70,10 +70,10 @@ public interface Extent extends InputExtent, OutputExtent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list of all entities.
|
* Get a list of all entities.
|
||||||
* </p>
|
*
|
||||||
* If the extent is not wholly loaded (i.e. a world being simulated in the
|
* <p>If the extent is not wholly loaded (i.e. a world being simulated in the
|
||||||
* game will not have every chunk loaded), then this list may not be
|
* game will not have every chunk loaded), then this list may not be
|
||||||
* incomplete.
|
* incomplete.</p>
|
||||||
*
|
*
|
||||||
* @return a list of entities
|
* @return a list of entities
|
||||||
*/
|
*/
|
||||||
|
@ -32,20 +32,20 @@ public interface InputExtent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a snapshot of the block at the given location.
|
* Get a snapshot of the block at the given location.
|
||||||
* </p>
|
*
|
||||||
* If the given position is out of the bounds of the extent, then the behavior
|
* <p>If the given position is out of the bounds of the extent, then the behavior
|
||||||
* is undefined (an air block could be returned). However, <code>null</code>
|
* is undefined (an air block could be returned). However, {@code null}
|
||||||
* should <strong>not</strong> be returned.
|
* should <strong>not</strong> be returned.</p>
|
||||||
* </p>
|
*
|
||||||
* The returned block is mutable and is a snapshot of the block at the time
|
* <p>The returned block is mutable and is a snapshot of the block at the time
|
||||||
* of call. It has no position attached to it, so it could be reused in
|
* of call. It has no position attached to it, so it could be reused in
|
||||||
* {@link Pattern}s and so on.
|
* {@link Pattern}s and so on.</p>
|
||||||
* </p>
|
*
|
||||||
* Calls to this method can actually be quite expensive, so cache results
|
* <p>Calls to this method can actually be quite expensive, so cache results
|
||||||
* whenever it is possible, while being aware of the mutability aspect.
|
* whenever it is possible, while being aware of the mutability aspect.
|
||||||
* The cost, however, depends on the implementation and particular extent.
|
* The cost, however, depends on the implementation and particular extent.
|
||||||
* If only basic information about the block is required, then use of
|
* If only basic information about the block is required, then use of
|
||||||
* {@link #getLazyBlock(Vector)} is recommended.
|
* {@link #getLazyBlock(Vector)} is recommended.</p>
|
||||||
*
|
*
|
||||||
* @param position position of the block
|
* @param position position of the block
|
||||||
* @return the block
|
* @return the block
|
||||||
@ -55,20 +55,20 @@ public interface InputExtent {
|
|||||||
/**
|
/**
|
||||||
* Get a lazy, immutable snapshot of the block at the given location that only
|
* Get a lazy, immutable snapshot of the block at the given location that only
|
||||||
* immediately contains information about the block's type (and metadata).
|
* immediately contains information about the block's type (and metadata).
|
||||||
* </p>
|
*
|
||||||
* Further information (such as NBT data) will be available <strong>by the
|
* <p>Further information (such as NBT data) will be available <strong>by the
|
||||||
* time of access</strong>. Therefore, it is not recommended that
|
* time of access</strong>. Therefore, it is not recommended that
|
||||||
* this method is used if the world is being simulated at the time of
|
* this method is used if the world is being simulated at the time of
|
||||||
* call. If the block needs to be stored for future use, then this method should
|
* call. If the block needs to be stored for future use, then this method should
|
||||||
* definitely not be used. Moreover, the block that is returned is immutable (or
|
* definitely not be used. Moreover, the block that is returned is immutable (or
|
||||||
* should be), and therefore modifications should not be attempted on it. If a
|
* should be), and therefore modifications should not be attempted on it. If a
|
||||||
* modifiable copy is required, then the block should be cloned.
|
* modifiable copy is required, then the block should be cloned.</p>
|
||||||
* </p>
|
*
|
||||||
* This method exists because it is sometimes important to inspect the block
|
* <p>This method exists because it is sometimes important to inspect the block
|
||||||
* at a given location, but {@link #getBlock(Vector)} may be too expensive in
|
* at a given location, but {@link #getBlock(Vector)} may be too expensive in
|
||||||
* the underlying implementation. It is also not possible to implement
|
* the underlying implementation. It is also not possible to implement
|
||||||
* caching if the returned object is mutable, so this methods allows caching
|
* caching if the returned object is mutable, so this methods allows caching
|
||||||
* implementations to be used.
|
* implementations to be used.</p>
|
||||||
*
|
*
|
||||||
* @param position position of the block
|
* @param position position of the block
|
||||||
* @return the block
|
* @return the block
|
||||||
|
@ -37,13 +37,13 @@ public interface OutputExtent {
|
|||||||
* Change the block at the given location to the given block. The operation may
|
* Change the block at the given location to the given block. The operation may
|
||||||
* not tie the given {@link BaseBlock} to the world, so future changes to the
|
* not tie the given {@link BaseBlock} to the world, so future changes to the
|
||||||
* {@link BaseBlock} do not affect the world until this method is called again.
|
* {@link BaseBlock} do not affect the world until this method is called again.
|
||||||
* </p>
|
*
|
||||||
* The return value of this method indicates whether the change was probably
|
* <p>The return value of this method indicates whether the change was probably
|
||||||
* successful. It may not be successful if, for example, the location is out
|
* successful. It may not be successful if, for example, the location is out
|
||||||
* of the bounds of the extent. It may be unsuccessful if the block passed
|
* of the bounds of the extent. It may be unsuccessful if the block passed
|
||||||
* is the same as the one in the world. However, the return value is only an
|
* is the same as the one in the world. However, the return value is only an
|
||||||
* estimation and it may be incorrect, but it could be used to count, for
|
* estimation and it may be incorrect, but it could be used to count, for
|
||||||
* example, the approximate number of changes.
|
* example, the approximate number of changes.</p>
|
||||||
*
|
*
|
||||||
* @param position position of the block
|
* @param position position of the block
|
||||||
* @param block block to set
|
* @param block block to set
|
||||||
|
@ -42,9 +42,9 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
/**
|
/**
|
||||||
* Buffers changes to an {@link Extent} and allows later retrieval for
|
* Buffers changes to an {@link Extent} and allows later retrieval for
|
||||||
* actual application of the changes.
|
* actual application of the changes.
|
||||||
* </p>
|
*
|
||||||
* This buffer will not attempt to return results from the buffer when
|
* <p>This buffer will not attempt to return results from the buffer when
|
||||||
* accessor methods (such as {@link #getBlock(Vector)}) are called.
|
* accessor methods (such as {@link #getBlock(Vector)}) are called.</p>
|
||||||
*/
|
*/
|
||||||
public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pattern {
|
public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pattern {
|
||||||
|
|
||||||
|
@ -51,8 +51,8 @@ public class BlockArrayClipboard implements Clipboard {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
* <p>
|
*
|
||||||
* The origin will be placed at the region's lowest minimum point.
|
* <p>The origin will be placed at the region's lowest minimum point.</p>
|
||||||
*
|
*
|
||||||
* @param region the bounding region
|
* @param region the bounding region
|
||||||
*/
|
*/
|
||||||
|
@ -28,8 +28,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of {@link Entity} that stores a {@link BaseEntity} with it.
|
* An implementation of {@link Entity} that stores a {@link BaseEntity} with it.
|
||||||
* </p>
|
*
|
||||||
* Calls to {@link #getState()} return a clone.
|
* <p>Calls to {@link #getState()} return a clone.</p>
|
||||||
*/
|
*/
|
||||||
abstract class StoredEntity implements Entity {
|
abstract class StoredEntity implements Entity {
|
||||||
|
|
||||||
|
@ -24,15 +24,14 @@ 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
|
|
||||||
*/
|
*/
|
||||||
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 the type ID
|
||||||
* @throws BlockBagException
|
* @throws BlockBagException on error
|
||||||
* @deprecated Use {@link BlockBag#storeDroppedBlock(int, int)} instead
|
* @deprecated Use {@link BlockBag#storeDroppedBlock(int, int)} instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -43,9 +42,9 @@ public abstract class BlockBag {
|
|||||||
/**
|
/**
|
||||||
* Stores a block as if it was mined.
|
* Stores a block as if it was mined.
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id the type ID
|
||||||
* @param data
|
* @param data the data value
|
||||||
* @throws BlockBagException
|
* @throws BlockBagException on error
|
||||||
*/
|
*/
|
||||||
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);
|
||||||
@ -58,8 +57,8 @@ public abstract class BlockBag {
|
|||||||
/**
|
/**
|
||||||
* Sets a block as if it was placed by hand.
|
* Sets a block as if it was placed by hand.
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id the type ID
|
||||||
* @throws BlockBagException
|
* @throws BlockBagException on error
|
||||||
* @deprecated Use {@link #fetchPlacedBlock(int,int)} instead
|
* @deprecated Use {@link #fetchPlacedBlock(int,int)} instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -70,9 +69,9 @@ public abstract class BlockBag {
|
|||||||
/**
|
/**
|
||||||
* Sets a block as if it was placed by hand.
|
* Sets a block as if it was placed by hand.
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id the type ID
|
||||||
* @param data TODO
|
* @param data the data value
|
||||||
* @throws BlockBagException
|
* @throws BlockBagException on error
|
||||||
*/
|
*/
|
||||||
public void fetchPlacedBlock(int id, int data) throws BlockBagException {
|
public void fetchPlacedBlock(int id, int data) throws BlockBagException {
|
||||||
try {
|
try {
|
||||||
@ -117,10 +116,10 @@ public abstract class BlockBag {
|
|||||||
/**
|
/**
|
||||||
* Get a block.
|
* Get a block.
|
||||||
*
|
*
|
||||||
* Either this method or fetchItem needs to be overridden
|
* <p>Either this method or fetchItem needs to be overridden.</p>
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id the type ID
|
||||||
* @throws BlockBagException
|
* @throws BlockBagException on error
|
||||||
*/
|
*/
|
||||||
public void fetchBlock(int id) throws BlockBagException {
|
public void fetchBlock(int id) throws BlockBagException {
|
||||||
fetchItem(new BaseItem(id));
|
fetchItem(new BaseItem(id));
|
||||||
@ -129,10 +128,10 @@ public abstract class BlockBag {
|
|||||||
/**
|
/**
|
||||||
* Get a block.
|
* Get a block.
|
||||||
*
|
*
|
||||||
* Either this method or fetchBlock needs to be overridden
|
* <p>Either this method or fetchItem needs to be overridden.</p>
|
||||||
*
|
*
|
||||||
* @param item
|
* @param item the item
|
||||||
* @throws BlockBagException
|
* @throws BlockBagException on error
|
||||||
*/
|
*/
|
||||||
public void fetchItem(BaseItem item) throws BlockBagException {
|
public void fetchItem(BaseItem item) throws BlockBagException {
|
||||||
fetchBlock(item.getType());
|
fetchBlock(item.getType());
|
||||||
@ -141,10 +140,10 @@ public abstract class BlockBag {
|
|||||||
/**
|
/**
|
||||||
* Store a block.
|
* Store a block.
|
||||||
*
|
*
|
||||||
* Either this method or storeItem needs to be overridden
|
* <p>Either this method or fetchItem needs to be overridden.</p>
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id the type ID
|
||||||
* @throws BlockBagException
|
* @throws BlockBagException on error
|
||||||
*/
|
*/
|
||||||
public void storeBlock(int id) throws BlockBagException {
|
public void storeBlock(int id) throws BlockBagException {
|
||||||
storeItem(new BaseItem(id));
|
storeItem(new BaseItem(id));
|
||||||
@ -153,10 +152,10 @@ public abstract class BlockBag {
|
|||||||
/**
|
/**
|
||||||
* Store a block.
|
* Store a block.
|
||||||
*
|
*
|
||||||
* Either this method or storeBlock needs to be overridden
|
* <p>Either this method or fetchItem needs to be overridden.</p>
|
||||||
*
|
*
|
||||||
* @param item
|
* @param item the item
|
||||||
* @throws BlockBagException
|
* @throws BlockBagException on error
|
||||||
*/
|
*/
|
||||||
public void storeItem(BaseItem item) throws BlockBagException {
|
public void storeItem(BaseItem item) throws BlockBagException {
|
||||||
storeBlock(item.getType());
|
storeBlock(item.getType());
|
||||||
@ -165,7 +164,7 @@ public abstract class BlockBag {
|
|||||||
/**
|
/**
|
||||||
* Checks to see if a block exists without removing it.
|
* Checks to see if a block exists without removing it.
|
||||||
*
|
*
|
||||||
* @param id
|
* @param id the type ID
|
||||||
* @return whether the block exists
|
* @return whether the block exists
|
||||||
*/
|
*/
|
||||||
public boolean peekBlock(int id) {
|
public boolean peekBlock(int id) {
|
||||||
@ -186,14 +185,14 @@ public abstract class BlockBag {
|
|||||||
/**
|
/**
|
||||||
* Adds a position to be used a source.
|
* Adds a position to be used a source.
|
||||||
*
|
*
|
||||||
* @param pos
|
* @param pos the position
|
||||||
*/
|
*/
|
||||||
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 the position
|
||||||
*/
|
*/
|
||||||
public abstract void addSingleSourcePosition(WorldVector pos);
|
public abstract void addSingleSourcePosition(WorldVector pos);
|
||||||
}
|
}
|
||||||
|
@ -20,9 +20,7 @@
|
|||||||
package com.sk89q.worldedit.extent.inventory;
|
package com.sk89q.worldedit.extent.inventory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Thrown when a block bag detects a problem.
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class BlockBagException extends Exception {
|
public class BlockBagException extends Exception {
|
||||||
private static final long serialVersionUID = 4672190086028430655L;
|
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,6 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
|||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*
|
*
|
||||||
* @param extent the extent
|
* @param extent the extent
|
||||||
* @param world the world
|
|
||||||
* @param blockBag the block bag
|
* @param blockBag the block bag
|
||||||
*/
|
*/
|
||||||
public BlockBagExtent(Extent extent, @Nullable BlockBag blockBag) {
|
public BlockBagExtent(Extent extent, @Nullable BlockBag blockBag) {
|
||||||
|
@ -20,9 +20,7 @@
|
|||||||
package com.sk89q.worldedit.extent.inventory;
|
package com.sk89q.worldedit.extent.inventory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Thrown when there are no more blocks left.
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class OutOfBlocksException extends BlockBagException {
|
public class OutOfBlocksException extends BlockBagException {
|
||||||
private static final long serialVersionUID = 7495899825677689509L;
|
|
||||||
}
|
}
|
||||||
|
@ -20,26 +20,24 @@
|
|||||||
package com.sk89q.worldedit.extent.inventory;
|
package com.sk89q.worldedit.extent.inventory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Thrown when the target inventory of a block bag is full.
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class OutOfSpaceException extends BlockBagException {
|
public class OutOfSpaceException extends BlockBagException {
|
||||||
private static final long serialVersionUID = -2962840237632916821L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Stores the block ID.
|
|
||||||
*/
|
|
||||||
private int id;
|
private int id;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the object.
|
* Construct the object.
|
||||||
* @param id
|
*
|
||||||
|
* @param id the ID of the block
|
||||||
*/
|
*/
|
||||||
public OutOfSpaceException(int id) {
|
public OutOfSpaceException(int id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Get the ID of the block
|
||||||
|
*
|
||||||
* @return the id
|
* @return the id
|
||||||
*/
|
*/
|
||||||
public int getID() {
|
public int getID() {
|
||||||
|
@ -20,10 +20,7 @@
|
|||||||
package com.sk89q.worldedit.extent.inventory;
|
package com.sk89q.worldedit.extent.inventory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Thrown when a block that can't be placed is used.
|
||||||
* @author sk89q
|
|
||||||
*/
|
*/
|
||||||
public class UnplaceableBlockException extends BlockBagException {
|
public class UnplaceableBlockException extends BlockBagException {
|
||||||
private static final long serialVersionUID = 7227883966999843526L;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -186,7 +186,7 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder
|
|||||||
current = current.add(attachment.vector()).toBlockVector();
|
current = current.add(attachment.vector()).toBlockVector();
|
||||||
|
|
||||||
if (!blocks.contains(current)) {
|
if (!blocks.contains(current)) {
|
||||||
// We ran outside the remaing set => assume we can place blocks on this
|
// We ran outside the remaining set => assume we can place blocks on this
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,10 +24,10 @@ import com.sk89q.worldedit.extent.Extent;
|
|||||||
/**
|
/**
|
||||||
* An interface for {@link Extent}s that are meant to reorder changes so
|
* An interface for {@link Extent}s that are meant to reorder changes so
|
||||||
* that they are more successful.
|
* that they are more successful.
|
||||||
* </p>
|
*
|
||||||
* For example, torches in Minecraft need to be placed on a block. A smart
|
* <p>For example, torches in Minecraft need to be placed on a block. A smart
|
||||||
* reordering implementation might place the torch after the block has
|
* reordering implementation might place the torch after the block has
|
||||||
* been placed.
|
* been placed.</p>
|
||||||
*/
|
*/
|
||||||
public interface ReorderingExtent extends Extent {
|
public interface ReorderingExtent extends Extent {
|
||||||
|
|
||||||
|
@ -31,11 +31,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes changes to the world as if a player had done so during survival mode.
|
* Makes changes to the world as if a player had done so during survival mode.
|
||||||
* </p>
|
*
|
||||||
* Note that this extent may choose to not call the underlying
|
* <p>Note that this extent may choose to not call the underlying
|
||||||
* extent and may instead call methods on the {@link World} that is passed
|
* extent and may instead call methods on the {@link World} that is passed
|
||||||
* in the constructor. For that reason, if you wish to "catch" changes, you
|
* in the constructor. For that reason, if you wish to "catch" changes, you
|
||||||
* should catch them before the changes reach this extent.
|
* should catch them before the changes reach this extent.</p>
|
||||||
*/
|
*/
|
||||||
public class SurvivalModeExtent extends AbstractDelegateExtent {
|
public class SurvivalModeExtent extends AbstractDelegateExtent {
|
||||||
|
|
||||||
@ -57,10 +57,10 @@ public class SurvivalModeExtent extends AbstractDelegateExtent {
|
|||||||
/**
|
/**
|
||||||
* Return whether changes to the world should be simulated with the
|
* Return whether changes to the world should be simulated with the
|
||||||
* use of game tools (such as pickaxes) whenever possible and reasonable.
|
* use of game tools (such as pickaxes) whenever possible and reasonable.
|
||||||
* </p>
|
*
|
||||||
* For example, we could pretend that the act of setting a coal ore block
|
* <p>For example, we could pretend that the act of setting a coal ore block
|
||||||
* to air (nothing) was the act of a player mining that coal ore block
|
* to air (nothing) was the act of a player mining that coal ore block
|
||||||
* with a pickaxe, which would mean that a coal item would be dropped.
|
* with a pickaxe, which would mean that a coal item would be dropped.</p>
|
||||||
*
|
*
|
||||||
* @return true if tool use is to be simulated
|
* @return true if tool use is to be simulated
|
||||||
*/
|
*/
|
||||||
|
@ -39,9 +39,9 @@ public interface LayerFunction {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply the function to the given position.
|
* Apply the function to the given position.
|
||||||
* </p>
|
*
|
||||||
* The depth would be the number of blocks from the surface if
|
* <p>The depth would be the number of blocks from the surface if
|
||||||
* a {@link LayerVisitor} was used.
|
* a {@link LayerVisitor} was used.</p>
|
||||||
*
|
*
|
||||||
* @param position the position
|
* @param position the position
|
||||||
* @param depth the depth as a number starting from 0
|
* @param depth the depth as a number starting from 0
|
||||||
|
@ -31,9 +31,9 @@ import com.sk89q.worldedit.function.pattern.RandomPattern;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates flora (which may include tall grass, flowers, etc.).
|
* Generates flora (which may include tall grass, flowers, etc.).
|
||||||
* <p>
|
*
|
||||||
* The current implementation is not biome-aware, but it may become so in
|
* <p>The current implementation is not biome-aware, but it may become so in
|
||||||
* the future.
|
* the future.</p>
|
||||||
*/
|
*/
|
||||||
public class FloraGenerator implements RegionFunction {
|
public class FloraGenerator implements RegionFunction {
|
||||||
|
|
||||||
@ -53,8 +53,9 @@ public class FloraGenerator implements RegionFunction {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether the flora generator is set to be biome-aware.
|
* Return whether the flora generator is set to be biome-aware.
|
||||||
* <p>
|
*
|
||||||
* By default, it is currently disabled by default, but this may change.
|
* <p>By default, it is currently disabled by default, but
|
||||||
|
* this may change.</p>
|
||||||
*
|
*
|
||||||
* @return true if biome aware
|
* @return true if biome aware
|
||||||
*/
|
*/
|
||||||
@ -64,8 +65,8 @@ public class FloraGenerator implements RegionFunction {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set whether the generator is biome aware.
|
* Set whether the generator is biome aware.
|
||||||
* <p>
|
*
|
||||||
* It is currently not possible to make the generator biome-aware.
|
* <p>It is currently not possible to make the generator biome-aware.</p>
|
||||||
*
|
*
|
||||||
* @param biomeAware must always be false
|
* @param biomeAware must always be false
|
||||||
*/
|
*/
|
||||||
@ -73,7 +74,6 @@ public class FloraGenerator implements RegionFunction {
|
|||||||
if (biomeAware) {
|
if (biomeAware) {
|
||||||
throw new IllegalArgumentException("Cannot enable biome-aware mode; not yet implemented");
|
throw new IllegalArgumentException("Cannot enable biome-aware mode; not yet implemented");
|
||||||
}
|
}
|
||||||
this.biomeAware = biomeAware;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -133,10 +133,10 @@ public final class Masks {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap an old-style mask and convert it to a new mask.
|
* Wrap an old-style mask and convert it to a new mask.
|
||||||
* </p>
|
*
|
||||||
* Note, however, that this is strongly not recommended because
|
* <p>Note, however, that this is strongly not recommended because
|
||||||
* {@link com.sk89q.worldedit.masks.Mask#prepare(LocalSession, LocalPlayer, Vector)}
|
* {@link com.sk89q.worldedit.masks.Mask#prepare(LocalSession, LocalPlayer, Vector)}
|
||||||
* is not called.
|
* is not called.</p>
|
||||||
*
|
*
|
||||||
* @param mask the old-style mask
|
* @param mask the old-style mask
|
||||||
* @param editSession the edit session to bind to
|
* @param editSession the edit session to bind to
|
||||||
@ -163,10 +163,10 @@ public final class Masks {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrap an old-style mask and convert it to a new mask.
|
* Wrap an old-style mask and convert it to a new mask.
|
||||||
* </p>
|
*
|
||||||
* As an {@link EditSession} is not provided in this case, one will be
|
* <p>As an {@link EditSession} is not provided in this case, one will be
|
||||||
* taken from the {@link Request}, if possible. If not possible, then the
|
* taken from the {@link Request}, if possible. If not possible, then the
|
||||||
* mask will return false.
|
* mask will return false.</p>
|
||||||
*
|
*
|
||||||
* @param mask the old-style mask
|
* @param mask the old-style mask
|
||||||
* @return a new-style mask
|
* @return a new-style mask
|
||||||
|
@ -77,8 +77,6 @@ public class NoiseFilter extends AbstractMask {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the probability of passing as a number between 0 and 1 (inclusive).
|
* Set the probability of passing as a number between 0 and 1 (inclusive).
|
||||||
*
|
|
||||||
* @return the density
|
|
||||||
*/
|
*/
|
||||||
public void setDensity(double density) {
|
public void setDensity(double density) {
|
||||||
checkArgument(density >= 0, "density must be >= 0");
|
checkArgument(density >= 0, "density must be >= 0");
|
||||||
|
@ -75,8 +75,6 @@ public class NoiseFilter2D extends AbstractMask2D {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the probability of passing as a number between 0 and 1 (inclusive).
|
* Set the probability of passing as a number between 0 and 1 (inclusive).
|
||||||
*
|
|
||||||
* @return the density
|
|
||||||
*/
|
*/
|
||||||
public void setDensity(double density) {
|
public void setDensity(double density) {
|
||||||
checkArgument(density >= 0, "density must be >= 0");
|
checkArgument(density >= 0, "density must be >= 0");
|
||||||
|
@ -43,10 +43,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes a copy of a portion of one extent to another extent or another point.
|
* Makes a copy of a portion of one extent to another extent or another point.
|
||||||
* </p>
|
*
|
||||||
* This is a forward extent copy, meaning that it iterates over the blocks in the
|
* <p>This is a forward extent copy, meaning that it iterates over the blocks
|
||||||
* source extent, and will copy as many blocks as there are in the source.
|
* in the source extent, and will copy as many blocks as there are in the
|
||||||
* Therefore, interpolation will not occur to fill in the gaps.
|
* source. Therefore, interpolation will not occur to fill in the gaps.</p>
|
||||||
*/
|
*/
|
||||||
public class ForwardExtentCopy implements Operation {
|
public class ForwardExtentCopy implements Operation {
|
||||||
|
|
||||||
@ -102,8 +102,8 @@ public class ForwardExtentCopy implements Operation {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the transformation that will occur on every point.
|
* Get the transformation that will occur on every point.
|
||||||
* </p>
|
*
|
||||||
* The transformation will stack with each repetition.
|
* <p>The transformation will stack with each repetition.</p>
|
||||||
*
|
*
|
||||||
* @return a transformation
|
* @return a transformation
|
||||||
*/
|
*/
|
||||||
@ -124,8 +124,8 @@ public class ForwardExtentCopy implements Operation {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the mask that gets applied to the source extent.
|
* Get the mask that gets applied to the source extent.
|
||||||
* </p>
|
*
|
||||||
* This mask can be used to filter what will be copied from the source.
|
* <p>This mask can be used to filter what will be copied from the source.</p>
|
||||||
*
|
*
|
||||||
* @return a source mask
|
* @return a source mask
|
||||||
*/
|
*/
|
||||||
@ -195,7 +195,7 @@ public class ForwardExtentCopy implements Operation {
|
|||||||
/**
|
/**
|
||||||
* Set whether entities that are copied should be removed.
|
* Set whether entities that are copied should be removed.
|
||||||
*
|
*
|
||||||
* @param removing true if removing
|
* @param removingEntities true if removing
|
||||||
*/
|
*/
|
||||||
public void setRemovingEntities(boolean removingEntities) {
|
public void setRemovingEntities(boolean removingEntities) {
|
||||||
this.removingEntities = removingEntities;
|
this.removingEntities = removingEntities;
|
||||||
|
@ -77,7 +77,7 @@ public class OperationQueue implements Operation {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Operation resume(RunContext run) throws WorldEditException {
|
public Operation resume(RunContext run) throws WorldEditException {
|
||||||
if (current == null && queue.size() > 0) {
|
if (current == null && !queue.isEmpty()) {
|
||||||
current = queue.poll();
|
current = queue.poll();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,8 +26,8 @@ public class RunContext {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Return whether the current operation should still continue running.
|
* Return whether the current operation should still continue running.
|
||||||
* </p>
|
*
|
||||||
* This method can be called frequently.
|
* <p>This method can be called frequently.</p>
|
||||||
*
|
*
|
||||||
* @return true if the operation should continue running
|
* @return true if the operation should continue running
|
||||||
*/
|
*/
|
||||||
|
@ -39,9 +39,9 @@ public class RandomPattern extends AbstractPattern {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a pattern to the weight list of patterns.
|
* Add a pattern to the weight list of patterns.
|
||||||
* </p>
|
*
|
||||||
* The probability for the pattern added is chance / max where max is the sum
|
* <p>The probability for the pattern added is chance / max where max is
|
||||||
* of the probabilities of all added patterns.
|
* the sum of the probabilities of all added patterns.</p>
|
||||||
*
|
*
|
||||||
* @param pattern the pattern
|
* @param pattern the pattern
|
||||||
* @param chance the chance, which can be any positive number
|
* @param chance the chance, which can be any positive number
|
||||||
|
@ -36,10 +36,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
* to a certain adjacent point provided that the method
|
* to a certain adjacent point provided that the method
|
||||||
* {@link #isVisitable(com.sk89q.worldedit.Vector, com.sk89q.worldedit.Vector)}
|
* {@link #isVisitable(com.sk89q.worldedit.Vector, com.sk89q.worldedit.Vector)}
|
||||||
* returns true for that point.
|
* returns true for that point.
|
||||||
* </p>
|
*
|
||||||
* As an abstract implementation, this class can be used to implement
|
* <p>As an abstract implementation, this class can be used to implement
|
||||||
* functionality that starts at certain points and extends outward from
|
* functionality that starts at certain points and extends outward from
|
||||||
* those points.
|
* those points.</p>
|
||||||
*/
|
*/
|
||||||
public abstract class BreadthFirstSearch implements Operation {
|
public abstract class BreadthFirstSearch implements Operation {
|
||||||
|
|
||||||
@ -62,12 +62,13 @@ public abstract class BreadthFirstSearch implements Operation {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of directions will be visited.
|
* Get the list of directions will be visited.
|
||||||
* </p>
|
*
|
||||||
* Directions are {@link com.sk89q.worldedit.Vector}s that determine
|
* <p>Directions are {@link com.sk89q.worldedit.Vector}s that determine
|
||||||
* what adjacent points area available. Vectors should not be
|
* what adjacent points area available. Vectors should not be
|
||||||
* unit vectors. An example of a valid direction is {@code new Vector(1, 0, 1)}.
|
* unit vectors. An example of a valid direction is
|
||||||
* </p>
|
* {@code new Vector(1, 0, 1)}.</p>
|
||||||
* The list of directions can be cleared.
|
*
|
||||||
|
* <p>The list of directions can be cleared.</p>
|
||||||
*
|
*
|
||||||
* @return the list of directions
|
* @return the list of directions
|
||||||
*/
|
*/
|
||||||
|
@ -31,8 +31,8 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
* Visits adjacent points on the same X-Z plane as long as the points
|
* Visits adjacent points on the same X-Z plane as long as the points
|
||||||
* pass the given mask, and then executes the provided region
|
* pass the given mask, and then executes the provided region
|
||||||
* function on the entire column.
|
* function on the entire column.
|
||||||
* </p>
|
*
|
||||||
* This is used by <code>//fill</code>.
|
* <p>This is used by {@code //fill}.</p>
|
||||||
*/
|
*/
|
||||||
public class DownwardVisitor extends RecursiveVisitor {
|
public class DownwardVisitor extends RecursiveVisitor {
|
||||||
|
|
||||||
|
@ -34,11 +34,11 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Visits the layers within a region.
|
* Visits the layers within a region.
|
||||||
* </p>
|
*
|
||||||
* This class works by iterating over all the columns in a {@link FlatRegion},
|
* <p>This class works by iterating over all the columns in a {@link FlatRegion},
|
||||||
* finding the first ground block in each column (searching from a given
|
* finding the first ground block in each column (searching from a given
|
||||||
* maximum Y down to a minimum Y), and then applies a {@link LayerFunction} to
|
* maximum Y down to a minimum Y), and then applies a {@link LayerFunction} to
|
||||||
* each layer.
|
* each layer.</p>
|
||||||
*/
|
*/
|
||||||
public class LayerVisitor implements Operation {
|
public class LayerVisitor implements Operation {
|
||||||
|
|
||||||
|
@ -26,9 +26,9 @@ import javax.annotation.Nullable;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides context for undo and redo operations.
|
* Provides context for undo and redo operations.
|
||||||
* </p>
|
*
|
||||||
* For example, {@link BlockChange}s take the {@link Extent} from the
|
* <p>For example, {@link BlockChange}s take the {@link Extent} from the
|
||||||
* context rather than store a reference to one.
|
* context rather than store a reference to one.</p>
|
||||||
*/
|
*/
|
||||||
public class UndoContext {
|
public class UndoContext {
|
||||||
|
|
||||||
|
@ -29,10 +29,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a block change that may be undone or replayed.
|
* Represents a block change that may be undone or replayed.
|
||||||
* </p>
|
*
|
||||||
* This block change does not have an {@link Extent} assigned to it because
|
* <p>This block change does not have an {@link Extent} assigned to it because
|
||||||
* one will be taken from the passed {@link UndoContext}. If the context
|
* one will be taken from the passed {@link UndoContext}. If the context
|
||||||
* does not have an extent (it is null), cryptic errors may occur.
|
* does not have an extent (it is null), cryptic errors may occur.</p>
|
||||||
*/
|
*/
|
||||||
public class BlockChange implements Change {
|
public class BlockChange implements Change {
|
||||||
|
|
||||||
|
@ -36,10 +36,10 @@ import static java.util.Map.Entry;
|
|||||||
/**
|
/**
|
||||||
* An extension of {@link ArrayListHistory} that stores {@link BlockChange}s
|
* An extension of {@link ArrayListHistory} that stores {@link BlockChange}s
|
||||||
* separately in two {@link ArrayList}s.
|
* separately in two {@link ArrayList}s.
|
||||||
* </p>
|
*
|
||||||
* Whether this is a good idea or not is highly questionable, but this class
|
* <p>Whether this is a good idea or not is highly questionable, but this class
|
||||||
* exists because this is how history was implemented in WorldEdit for
|
* exists because this is how history was implemented in WorldEdit for
|
||||||
* many years.
|
* many years.</p>
|
||||||
*/
|
*/
|
||||||
public class BlockOptimizedHistory extends ArrayListHistory {
|
public class BlockOptimizedHistory extends ArrayListHistory {
|
||||||
|
|
||||||
|
@ -38,9 +38,9 @@ public interface ChangeSet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a backward directed iterator that can be used for undo.
|
* Get a backward directed iterator that can be used for undo.
|
||||||
* </p>
|
*
|
||||||
* The iterator may return the changes out of order, as long as the final
|
* <p>The iterator may return the changes out of order, as long as the final
|
||||||
* result after all changes have been applied is correct.
|
* result after all changes have been applied is correct.</p>
|
||||||
*
|
*
|
||||||
* @return a undo directed iterator
|
* @return a undo directed iterator
|
||||||
*/
|
*/
|
||||||
@ -48,9 +48,9 @@ public interface ChangeSet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a forward directed iterator that can be used for redo.
|
* Get a forward directed iterator that can be used for redo.
|
||||||
* </p>
|
*
|
||||||
* The iterator may return the changes out of order, as long as the final
|
* <p>The iterator may return the changes out of order, as long as the final
|
||||||
* result after all changes have been applied is correct.
|
* result after all changes have been applied is correct.</p>
|
||||||
*
|
*
|
||||||
* @return a forward directed iterator
|
* @return a forward directed iterator
|
||||||
*/
|
*/
|
||||||
|
@ -47,6 +47,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
/**
|
/**
|
||||||
* Wraps {@link World}s into {@link LocalWorld}.
|
* Wraps {@link World}s into {@link LocalWorld}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public class LocalWorldAdapter extends LocalWorld {
|
public class LocalWorldAdapter extends LocalWorld {
|
||||||
|
|
||||||
private final World world;
|
private final World world;
|
||||||
@ -203,6 +204,7 @@ public class LocalWorldAdapter extends LocalWorld {
|
|||||||
return world.getWorldData();
|
return world.getWorldData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("EqualsWhichDoesntCheckParameterClass")
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
return world.equals(other);
|
return world.equals(other);
|
||||||
|
@ -37,6 +37,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
/**
|
/**
|
||||||
* Adapts {@link Platform}s into the legacy {@link ServerInterface}.
|
* Adapts {@link Platform}s into the legacy {@link ServerInterface}.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("ALL")
|
||||||
public class ServerInterfaceAdapter extends ServerInterface {
|
public class ServerInterfaceAdapter extends ServerInterface {
|
||||||
|
|
||||||
private final Platform platform;
|
private final Platform platform;
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.internal.cui;
|
package com.sk89q.worldedit.internal.cui;
|
||||||
|
|
||||||
import com.sk89q.worldedit.LocalPlayer;
|
|
||||||
import com.sk89q.worldedit.LocalSession;
|
import com.sk89q.worldedit.LocalSession;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
|
||||||
@ -46,13 +45,14 @@ public interface CUIRegion {
|
|||||||
* 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 the protocol version
|
||||||
*/
|
*/
|
||||||
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 the type ID
|
||||||
*/
|
*/
|
||||||
public String getTypeID();
|
public String getTypeID();
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ public interface CUIRegion {
|
|||||||
* 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 the legacy type ID
|
||||||
*/
|
*/
|
||||||
public String getLegacyTypeID();
|
public String getLegacyTypeID();
|
||||||
}
|
}
|
||||||
|
@ -34,10 +34,12 @@ public class SelectionCylinderEvent implements CUIEvent {
|
|||||||
this.radius = radius;
|
this.radius = radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getTypeId() {
|
public String getTypeId() {
|
||||||
return "cyl";
|
return "cyl";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getParameters() {
|
public String[] getParameters() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
String.valueOf(pos.getBlockX()),
|
String.valueOf(pos.getBlockX()),
|
||||||
|
@ -22,6 +22,7 @@ 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;
|
||||||
|
|
||||||
@ -30,10 +31,12 @@ public class SelectionEllipsoidPointEvent implements CUIEvent {
|
|||||||
this.pos = pos;
|
this.pos = pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getTypeId() {
|
public String getTypeId() {
|
||||||
return "e";
|
return "e";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getParameters() {
|
public String[] getParameters() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
String.valueOf(id),
|
String.valueOf(id),
|
||||||
@ -42,4 +45,5 @@ public class SelectionEllipsoidPointEvent implements CUIEvent {
|
|||||||
String.valueOf(pos.getBlockZ())
|
String.valueOf(pos.getBlockZ())
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -29,10 +29,12 @@ public class SelectionMinMaxEvent implements CUIEvent {
|
|||||||
this.max = max;
|
this.max = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getTypeId() {
|
public String getTypeId() {
|
||||||
return "mm";
|
return "mm";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getParameters() {
|
public String[] getParameters() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
String.valueOf(min),
|
String.valueOf(min),
|
||||||
|
@ -43,10 +43,12 @@ public class SelectionPoint2DEvent implements CUIEvent {
|
|||||||
this.area = area;
|
this.area = area;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getTypeId() {
|
public String getTypeId() {
|
||||||
return "p2";
|
return "p2";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getParameters() {
|
public String[] getParameters() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
String.valueOf(id),
|
String.valueOf(id),
|
||||||
|
@ -33,10 +33,12 @@ public class SelectionPointEvent implements CUIEvent {
|
|||||||
this.area = area;
|
this.area = area;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getTypeId() {
|
public String getTypeId() {
|
||||||
return "p";
|
return "p";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getParameters() {
|
public String[] getParameters() {
|
||||||
return new String[] {
|
return new String[] {
|
||||||
String.valueOf(id),
|
String.valueOf(id),
|
||||||
|
@ -22,16 +22,19 @@
|
|||||||
package com.sk89q.worldedit.internal.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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getTypeId() {
|
public String getTypeId() {
|
||||||
return "poly";
|
return "poly";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getParameters() {
|
public String[] getParameters() {
|
||||||
final String[] ret = new String[vertices.length];
|
final String[] ret = new String[vertices.length];
|
||||||
|
|
||||||
@ -42,4 +45,5 @@ public class SelectionPolygonEvent implements CUIEvent {
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,10 +27,12 @@ public class SelectionShapeEvent implements CUIEvent {
|
|||||||
this.shapeName = shapeName;
|
this.shapeName = shapeName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String getTypeId() {
|
public String getTypeId() {
|
||||||
return "s";
|
return "s";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public String[] getParameters() {
|
public String[] getParameters() {
|
||||||
return new String[] { shapeName };
|
return new String[] { shapeName };
|
||||||
}
|
}
|
||||||
|
@ -19,47 +19,57 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.internal.expression;
|
package com.sk89q.worldedit.internal.expression;
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Stack;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.internal.expression.lexer.Lexer;
|
import com.sk89q.worldedit.internal.expression.lexer.Lexer;
|
||||||
import com.sk89q.worldedit.internal.expression.lexer.tokens.Token;
|
import com.sk89q.worldedit.internal.expression.lexer.tokens.Token;
|
||||||
import com.sk89q.worldedit.internal.expression.parser.Parser;
|
import com.sk89q.worldedit.internal.expression.parser.Parser;
|
||||||
import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment;
|
|
||||||
import com.sk89q.worldedit.internal.expression.runtime.Constant;
|
import com.sk89q.worldedit.internal.expression.runtime.Constant;
|
||||||
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
|
||||||
|
import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment;
|
||||||
import com.sk89q.worldedit.internal.expression.runtime.Functions;
|
import com.sk89q.worldedit.internal.expression.runtime.Functions;
|
||||||
import com.sk89q.worldedit.internal.expression.runtime.RValue;
|
import com.sk89q.worldedit.internal.expression.runtime.RValue;
|
||||||
import com.sk89q.worldedit.internal.expression.runtime.ReturnException;
|
import com.sk89q.worldedit.internal.expression.runtime.ReturnException;
|
||||||
import com.sk89q.worldedit.internal.expression.runtime.Variable;
|
import com.sk89q.worldedit.internal.expression.runtime.Variable;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Stack;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles and evaluates expressions.
|
* Compiles and evaluates expressions.
|
||||||
*
|
*
|
||||||
* Supported operators:
|
* <p>Supported operators:</p>
|
||||||
* Logical: &&, ||, ! (unary)
|
|
||||||
* Bitwise: ~ (unary), >>, <<
|
|
||||||
* 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)
|
* <ul>
|
||||||
|
* <li>Logical: &&, ||, ! (unary)</li>
|
||||||
|
* <li>Bitwise: ~ (unary), >>, <<</li>
|
||||||
|
* <li>Arithmetic: +, -, *, /, % (modulo), ^ (power), - (unary), --, ++ (prefix only)</li>
|
||||||
|
* <li>Comparison: <=, >=, >, <, ==, !=, ~= (near)</li>
|
||||||
|
* </ul>
|
||||||
*
|
*
|
||||||
* Constants: e, pi
|
* <p>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)</p>
|
||||||
*
|
*
|
||||||
* To compile an equation, run <code>Expression.compile("expression here", "var1", "var2"...)</code>
|
* <p>Constants: e, pi</p>
|
||||||
* If you wish to run the equation multiple times, you can then optimize it, by calling myExpression.optimize();
|
|
||||||
* You can then run the equation as many times as you want by calling myExpression.evaluate(var1, var2...)
|
|
||||||
* You do not need to pass values for all variables specified while compiling.
|
|
||||||
* 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>
|
* <p>To compile an equation, run
|
||||||
|
* {@code Expression.compile("expression here", "var1", "var2"...)}.
|
||||||
|
* If you wish to run the equation multiple times, you can then optimize it,
|
||||||
|
* by calling {@link #optimize()}. You can then run the equation as many times
|
||||||
|
* as you want by calling {@link #evaluate(double...)}. You do not need to
|
||||||
|
* pass values for all variables specified while compiling.
|
||||||
|
* To query variables after evaluation, you can use
|
||||||
|
* {@link #getVariable(String, boolean)}. To get a value out of these, use
|
||||||
|
* {@link Variable#getValue()}.</p>
|
||||||
|
*
|
||||||
|
* <p>Variables are also supported and can be set either by passing values
|
||||||
|
* to {@link #evaluate(double...)}.</p>
|
||||||
*
|
*
|
||||||
* @author TomyLobo
|
* @author TomyLobo
|
||||||
*/
|
*/
|
||||||
public class Expression {
|
public class Expression {
|
||||||
|
|
||||||
private static final ThreadLocal<Stack<Expression>> instance = new ThreadLocal<Stack<Expression>>();
|
private static final ThreadLocal<Stack<Expression>> instance = new ThreadLocal<Stack<Expression>>();
|
||||||
|
|
||||||
private final Map<String, RValue> variables = new HashMap<String, RValue>();
|
private final Map<String, RValue> variables = new HashMap<String, RValue>();
|
||||||
@ -167,4 +177,5 @@ public class Expression {
|
|||||||
public void setEnvironment(ExpressionEnvironment environment) {
|
public void setEnvironment(ExpressionEnvironment environment) {
|
||||||
this.environment = environment;
|
this.environment = environment;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,12 +20,10 @@
|
|||||||
package com.sk89q.worldedit.internal.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
|
|
||||||
*/
|
*/
|
||||||
public class ExpressionException extends Exception {
|
public class ExpressionException extends Exception {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
private final int position;
|
private final int position;
|
||||||
|
|
||||||
@ -51,4 +49,5 @@ public class ExpressionException extends Exception {
|
|||||||
public int getPosition() {
|
public int getPosition() {
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,9 @@ 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
|
|
||||||
*/
|
*/
|
||||||
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.
|
||||||
*
|
*
|
||||||
@ -58,4 +57,5 @@ public interface Identifiable {
|
|||||||
public abstract char id();
|
public abstract char id();
|
||||||
|
|
||||||
public int getPosition();
|
public int getPosition();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,13 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.internal.expression.lexer;
|
package com.sk89q.worldedit.internal.expression.lexer;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.internal.expression.lexer.tokens.CharacterToken;
|
||||||
|
import com.sk89q.worldedit.internal.expression.lexer.tokens.IdentifierToken;
|
||||||
|
import com.sk89q.worldedit.internal.expression.lexer.tokens.KeywordToken;
|
||||||
|
import com.sk89q.worldedit.internal.expression.lexer.tokens.NumberToken;
|
||||||
|
import com.sk89q.worldedit.internal.expression.lexer.tokens.OperatorToken;
|
||||||
|
import com.sk89q.worldedit.internal.expression.lexer.tokens.Token;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -29,16 +36,14 @@ 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.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.
|
* <p>Tokens can be numbers, identifiers, operators and assorted other
|
||||||
*
|
* characters.</p>
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class Lexer {
|
public class Lexer {
|
||||||
|
|
||||||
private final String expression;
|
private final String expression;
|
||||||
private int position = 0;
|
private int position = 0;
|
||||||
|
|
||||||
@ -46,7 +51,7 @@ public class Lexer {
|
|||||||
this.expression = expression;
|
this.expression = expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final List<Token> tokenize(String expression) throws LexerException {
|
public static List<Token> tokenize(String expression) throws LexerException {
|
||||||
return new Lexer(expression).tokenize();
|
return new Lexer(expression).tokenize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,7 +119,7 @@ public class Lexer {
|
|||||||
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 List<Token> tokenize() throws LexerException {
|
||||||
List<Token> tokens = new ArrayList<Token>();
|
List<Token> tokens = new ArrayList<Token>();
|
||||||
|
|
||||||
do {
|
do {
|
||||||
@ -139,7 +144,7 @@ public class Lexer {
|
|||||||
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.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
tokens.add(new NumberToken(position, Double.parseDouble(numberPart)));
|
tokens.add(new NumberToken(position, Double.parseDouble(numberPart)));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
@ -154,7 +159,7 @@ public class Lexer {
|
|||||||
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.isEmpty()) {
|
||||||
if (keywords.contains(identifierPart)) {
|
if (keywords.contains(identifierPart)) {
|
||||||
tokens.add(new KeywordToken(position, identifierPart));
|
tokens.add(new KeywordToken(position, identifierPart));
|
||||||
} else {
|
} else {
|
||||||
@ -176,7 +181,7 @@ public class Lexer {
|
|||||||
return expression.charAt(position);
|
return expression.charAt(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void skipWhitespace() {
|
private void skipWhitespace() {
|
||||||
while (position < expression.length() && Character.isWhitespace(peek())) {
|
while (position < expression.length() && Character.isWhitespace(peek())) {
|
||||||
++position;
|
++position;
|
||||||
}
|
}
|
||||||
@ -230,4 +235,5 @@ public class Lexer {
|
|||||||
return new OperatorToken(startPosition, tokenName);
|
return new OperatorToken(startPosition, tokenName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,8 @@ import com.sk89q.worldedit.internal.expression.ExpressionException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Thrown when the lexer encounters a problem.
|
* Thrown when the lexer encounters a problem.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class LexerException extends ExpressionException {
|
public class LexerException extends ExpressionException {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public LexerException(int position) {
|
public LexerException(int position) {
|
||||||
super(position, getPrefix(position));
|
super(position, getPrefix(position));
|
||||||
@ -48,4 +45,5 @@ public class LexerException extends ExpressionException {
|
|||||||
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));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,9 @@ 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
|
|
||||||
*/
|
*/
|
||||||
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) {
|
||||||
@ -41,4 +40,5 @@ public class CharacterToken extends Token {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "CharacterToken(" + character + ")";
|
return "CharacterToken(" + character + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,10 @@
|
|||||||
package com.sk89q.worldedit.internal.expression.lexer.tokens;
|
package com.sk89q.worldedit.internal.expression.lexer.tokens;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An identifier
|
* An identifier.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class IdentifierToken extends Token {
|
public class IdentifierToken extends Token {
|
||||||
|
|
||||||
public final String value;
|
public final String value;
|
||||||
|
|
||||||
public IdentifierToken(int position, String value) {
|
public IdentifierToken(int position, String value) {
|
||||||
@ -41,4 +40,5 @@ public class IdentifierToken extends Token {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "IdentifierToken(" + value + ")";
|
return "IdentifierToken(" + value + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,10 @@
|
|||||||
package com.sk89q.worldedit.internal.expression.lexer.tokens;
|
package com.sk89q.worldedit.internal.expression.lexer.tokens;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A keyword
|
* A keyword.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class KeywordToken extends Token {
|
public class KeywordToken extends Token {
|
||||||
|
|
||||||
public final String value;
|
public final String value;
|
||||||
|
|
||||||
public KeywordToken(int position, String value) {
|
public KeywordToken(int position, String value) {
|
||||||
@ -41,4 +40,5 @@ public class KeywordToken extends Token {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "KeywordToken(" + value + ")";
|
return "KeywordToken(" + value + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,10 @@
|
|||||||
package com.sk89q.worldedit.internal.expression.lexer.tokens;
|
package com.sk89q.worldedit.internal.expression.lexer.tokens;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A number
|
* A number.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class NumberToken extends Token {
|
public class NumberToken extends Token {
|
||||||
|
|
||||||
public final double value;
|
public final double value;
|
||||||
|
|
||||||
public NumberToken(int position, double value) {
|
public NumberToken(int position, double value) {
|
||||||
@ -41,4 +40,5 @@ public class NumberToken extends Token {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "NumberToken(" + value + ")";
|
return "NumberToken(" + value + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,9 @@ package com.sk89q.worldedit.internal.expression.lexer.tokens;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A unary or binary operator.
|
* A unary or binary operator.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class OperatorToken extends Token {
|
public class OperatorToken extends Token {
|
||||||
|
|
||||||
public final String operator;
|
public final String operator;
|
||||||
|
|
||||||
public OperatorToken(int position, String operator) {
|
public OperatorToken(int position, String operator) {
|
||||||
@ -41,4 +40,5 @@ public class OperatorToken extends Token {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "OperatorToken(" + operator + ")";
|
return "OperatorToken(" + operator + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,9 @@ import com.sk89q.worldedit.internal.expression.Identifiable;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A token. The lexer generates these to make the parser's job easier.
|
* A token. The lexer generates these to make the parser's job easier.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public abstract class Token implements Identifiable {
|
public abstract class Token implements Identifiable {
|
||||||
|
|
||||||
private final int position;
|
private final int position;
|
||||||
|
|
||||||
public Token(int position) {
|
public Token(int position) {
|
||||||
@ -37,4 +36,5 @@ public abstract class Token implements Identifiable {
|
|||||||
public int getPosition() {
|
public int getPosition() {
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,6 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.internal.expression.parser;
|
package com.sk89q.worldedit.internal.expression.parser;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.Identifiable;
|
import com.sk89q.worldedit.internal.expression.Identifiable;
|
||||||
import com.sk89q.worldedit.internal.expression.lexer.tokens.IdentifierToken;
|
import com.sk89q.worldedit.internal.expression.lexer.tokens.IdentifierToken;
|
||||||
@ -43,12 +40,14 @@ import com.sk89q.worldedit.internal.expression.runtime.SimpleFor;
|
|||||||
import com.sk89q.worldedit.internal.expression.runtime.Switch;
|
import com.sk89q.worldedit.internal.expression.runtime.Switch;
|
||||||
import com.sk89q.worldedit.internal.expression.runtime.While;
|
import com.sk89q.worldedit.internal.expression.runtime.While;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Processes a list of tokens into an executable tree.
|
* Processes a list of tokens into an executable tree.
|
||||||
*
|
*
|
||||||
* Tokens can be numbers, identifiers, operators and assorted other characters.
|
* <p>Tokens can be numbers, identifiers, operators and assorted other characters.</p>
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class Parser {
|
public class Parser {
|
||||||
private final class NullToken extends Token {
|
private final class NullToken extends Token {
|
||||||
@ -56,6 +55,7 @@ public class Parser {
|
|||||||
super(position);
|
super(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public char id() {
|
public char id() {
|
||||||
return '\0';
|
return '\0';
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ public class Parser {
|
|||||||
this.expression = expression;
|
this.expression = expression;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final RValue parse(List<Token> tokens, Expression expression) throws ParserException {
|
public static RValue parse(List<Token> tokens, Expression expression) throws ParserException {
|
||||||
return new Parser(tokens, expression).parse();
|
return new Parser(tokens, expression).parse();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,7 +309,7 @@ public class Parser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final RValue parseExpression(boolean canBeEmpty) throws ParserException {
|
private RValue parseExpression(boolean canBeEmpty) throws ParserException {
|
||||||
LinkedList<Identifiable> halfProcessed = new LinkedList<Identifiable>();
|
LinkedList<Identifiable> halfProcessed = new LinkedList<Identifiable>();
|
||||||
|
|
||||||
// process brackets, numbers, functions, variables and detect prefix operators
|
// process brackets, numbers, functions, variables and detect prefix operators
|
||||||
@ -423,7 +423,7 @@ public class Parser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final RValue parseBracket() throws ParserException {
|
private RValue parseBracket() throws ParserException {
|
||||||
consumeCharacter('(');
|
consumeCharacter('(');
|
||||||
|
|
||||||
final RValue ret = parseExpression(false);
|
final RValue ret = parseExpression(false);
|
||||||
@ -435,10 +435,8 @@ public class Parser {
|
|||||||
|
|
||||||
private boolean hasKeyword(String keyword) {
|
private boolean hasKeyword(String keyword) {
|
||||||
final Token next = peek();
|
final Token next = peek();
|
||||||
if (!(next instanceof KeywordToken)) {
|
|
||||||
return false;
|
return next instanceof KeywordToken && ((KeywordToken) next).value.equals(keyword);
|
||||||
}
|
|
||||||
return ((KeywordToken) next).value.equals(keyword);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertCharacter(char character) throws ParserException {
|
private void assertCharacter(char character) throws ParserException {
|
||||||
|
@ -23,11 +23,8 @@ import com.sk89q.worldedit.internal.expression.ExpressionException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Thrown when the parser encounters a problem.
|
* Thrown when the parser encounters a problem.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class ParserException extends ExpressionException {
|
public class ParserException extends ExpressionException {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public ParserException(int position) {
|
public ParserException(int position) {
|
||||||
super(position, getPrefix(position));
|
super(position, getPrefix(position));
|
||||||
@ -48,4 +45,5 @@ public class ParserException extends ExpressionException {
|
|||||||
private static String getPrefix(int position) {
|
private static String getPrefix(int position) {
|
||||||
return position < 0 ? "Parser error" : ("Parser error at " + (position + 1));
|
return position < 0 ? "Parser error" : ("Parser error at " + (position + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,10 +30,9 @@ import java.util.*;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper classfor Parser. Contains processors for statements and operators.
|
* Helper classfor Parser. Contains processors for statements and operators.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public final class ParserProcessors {
|
public final class ParserProcessors {
|
||||||
|
|
||||||
private static final Map<String, String> unaryOpMap = new HashMap<String, String>();
|
private static final Map<String, String> unaryOpMap = new HashMap<String, String>();
|
||||||
|
|
||||||
private static final Map<String, String>[] binaryOpMapsLA;
|
private static final Map<String, String>[] binaryOpMapsLA;
|
||||||
@ -347,4 +346,5 @@ public final class ParserProcessors {
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,9 @@ import com.sk89q.worldedit.internal.expression.Identifiable;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A pseudo-token, inserted by the parser instead of the lexer.
|
* A pseudo-token, inserted by the parser instead of the lexer.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public abstract class PseudoToken implements Identifiable {
|
public abstract class PseudoToken implements Identifiable {
|
||||||
|
|
||||||
private final int position;
|
private final int position;
|
||||||
|
|
||||||
public PseudoToken(int position) {
|
public PseudoToken(int position) {
|
||||||
@ -40,4 +39,5 @@ public abstract class PseudoToken implements Identifiable {
|
|||||||
public int getPosition() {
|
public int getPosition() {
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,9 @@ import com.sk89q.worldedit.internal.expression.lexer.tokens.OperatorToken;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The parser uses this pseudo-token to mark operators as unary operators.
|
* The parser uses this pseudo-token to mark operators as unary operators.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class UnaryOperator extends PseudoToken {
|
public class UnaryOperator extends PseudoToken {
|
||||||
|
|
||||||
final String operator;
|
final String operator;
|
||||||
|
|
||||||
public UnaryOperator(OperatorToken operatorToken) {
|
public UnaryOperator(OperatorToken operatorToken) {
|
||||||
@ -47,4 +46,5 @@ public class UnaryOperator extends PseudoToken {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "UnaryOperator(" + operator + ")";
|
return "UnaryOperator(" + operator + ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,17 +25,16 @@ import com.sk89q.worldedit.internal.expression.runtime.LValue;
|
|||||||
import com.sk89q.worldedit.internal.expression.runtime.RValue;
|
import com.sk89q.worldedit.internal.expression.runtime.RValue;
|
||||||
|
|
||||||
public class UnboundVariable extends PseudoToken implements LValue {
|
public class UnboundVariable extends PseudoToken implements LValue {
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
|
|
||||||
public UnboundVariable(int position, String name) {
|
public UnboundVariable(int position, String name) {
|
||||||
super(position);
|
super(position);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public char id() {
|
public char id() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return 'V';
|
return 'V';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,4 +76,5 @@ public class UnboundVariable extends PseudoToken implements LValue {
|
|||||||
|
|
||||||
return (LValue) variable;
|
return (LValue) variable;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,9 @@ package com.sk89q.worldedit.internal.expression.runtime;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A break or continue statement.
|
* A break or continue statement.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class Break extends Node {
|
public class Break extends Node {
|
||||||
|
|
||||||
boolean doContinue;
|
boolean doContinue;
|
||||||
|
|
||||||
public Break(int position, boolean doContinue) {
|
public Break(int position, boolean doContinue) {
|
||||||
@ -47,4 +46,5 @@ public class Break extends Node {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return doContinue ? "continue" : "break";
|
return doContinue ? "continue" : "break";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -22,11 +22,8 @@ package com.sk89q.worldedit.internal.expression.runtime;
|
|||||||
/**
|
/**
|
||||||
* Thrown when a break or continue is encountered.
|
* Thrown when a break or continue is encountered.
|
||||||
* Loop constructs catch this exception.
|
* Loop constructs catch this exception.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class BreakException extends EvaluationException {
|
public class BreakException extends EvaluationException {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
final boolean doContinue;
|
final boolean doContinue;
|
||||||
|
|
||||||
@ -35,4 +32,5 @@ public class BreakException extends EvaluationException {
|
|||||||
|
|
||||||
this.doContinue = doContinue;
|
this.doContinue = doContinue;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,9 @@ import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* An if/else statement or a ternary operator.
|
* An if/else statement or a ternary operator.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class Conditional extends Node {
|
public class Conditional extends Node {
|
||||||
|
|
||||||
private RValue condition;
|
private RValue condition;
|
||||||
private RValue truePart;
|
private RValue truePart;
|
||||||
private RValue falsePart;
|
private RValue falsePart;
|
||||||
@ -90,4 +89,5 @@ public class Conditional extends Node {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,9 @@ package com.sk89q.worldedit.internal.expression.runtime;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A constant.
|
* A constant.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public final class Constant extends Node {
|
public final class Constant extends Node {
|
||||||
|
|
||||||
private final double value;
|
private final double value;
|
||||||
|
|
||||||
public Constant(int position, double value) {
|
public Constant(int position, double value) {
|
||||||
@ -46,4 +45,5 @@ public final class Constant extends Node {
|
|||||||
public char id() {
|
public char id() {
|
||||||
return 'c';
|
return 'c';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,11 +23,8 @@ import com.sk89q.worldedit.internal.expression.ExpressionException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Thrown when there's a problem during expression evaluation.
|
* Thrown when there's a problem during expression evaluation.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class EvaluationException extends ExpressionException {
|
public class EvaluationException extends ExpressionException {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
public EvaluationException(int position) {
|
public EvaluationException(int position) {
|
||||||
super(position, getPrefix(position));
|
super(position, getPrefix(position));
|
||||||
@ -48,4 +45,5 @@ public class EvaluationException extends ExpressionException {
|
|||||||
private static String getPrefix(int position) {
|
private static String getPrefix(int position) {
|
||||||
return position < 0 ? "Evaluation error" : ("Evaluation error at " + (position + 1));
|
return position < 0 ? "Evaluation error" : ("Evaluation error at " + (position + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,12 @@ package com.sk89q.worldedit.internal.expression.runtime;
|
|||||||
* Represents a way to access blocks in a world. Has to accept non-rounded coordinates.
|
* Represents a way to access blocks in a world. Has to accept non-rounded coordinates.
|
||||||
*/
|
*/
|
||||||
public interface ExpressionEnvironment {
|
public interface ExpressionEnvironment {
|
||||||
|
|
||||||
int getBlockType(double x, double y, double z);
|
int getBlockType(double x, double y, double z);
|
||||||
int getBlockData(double x, double y, double z);
|
int getBlockData(double x, double y, double z);
|
||||||
int getBlockTypeAbs(double x, double y, double z);
|
int getBlockTypeAbs(double x, double y, double z);
|
||||||
int getBlockDataAbs(double x, double y, double z);
|
int getBlockDataAbs(double x, double y, double z);
|
||||||
int getBlockTypeRel(double x, double y, double z);
|
int getBlockTypeRel(double x, double y, double z);
|
||||||
int getBlockDataRel(double x, double y, double z);
|
int getBlockDataRel(double x, double y, double z);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,9 @@ import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A Java/C-style for loop.
|
* A Java/C-style for loop.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class For extends Node {
|
public class For extends Node {
|
||||||
|
|
||||||
RValue init;
|
RValue init;
|
||||||
RValue condition;
|
RValue condition;
|
||||||
RValue increment;
|
RValue increment;
|
||||||
@ -101,4 +100,5 @@ public class For extends Node {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,20 +19,19 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.internal.expression.runtime;
|
package com.sk89q.worldedit.internal.expression.runtime;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
|
import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
|
||||||
import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for a Java method and its arguments (other Nodes)
|
* Wrapper for a Java method and its arguments (other Nodes).
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class Function extends Node {
|
public class Function extends Node {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add this annotation on functions that don't always return the same value
|
* Add this annotation on functions that don't always return the same value
|
||||||
* for the same inputs and on functions with side-effects.
|
* for the same inputs and on functions with side-effects.
|
||||||
@ -120,4 +119,5 @@ public class Function extends Node {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,17 +27,16 @@ import java.util.*;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains all functions that can be used in expressions.
|
* Contains all functions that can be used in expressions.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("UnusedDeclaration")
|
@SuppressWarnings("UnusedDeclaration")
|
||||||
public final class Functions {
|
public final class Functions {
|
||||||
|
|
||||||
private static class Overload {
|
private static class Overload {
|
||||||
private final Method method;
|
private final Method method;
|
||||||
private final int mask;
|
private final int mask;
|
||||||
private final boolean isSetter;
|
private final boolean isSetter;
|
||||||
|
|
||||||
public Overload(Method method) throws IllegalArgumentException {
|
private Overload(Method method) throws IllegalArgumentException {
|
||||||
this.method = method;
|
this.method = method;
|
||||||
|
|
||||||
boolean isSetter = false;
|
boolean isSetter = false;
|
||||||
@ -436,4 +435,5 @@ public final class Functions {
|
|||||||
|
|
||||||
return queryInternal(type, data, typeId, dataValue);
|
return queryInternal(type, data, typeId, dataValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,13 +24,15 @@ import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A value that can be used on the left side of an assignment.
|
* A value that can be used on the left side of an assignment.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public interface LValue extends RValue {
|
public interface LValue extends RValue {
|
||||||
|
|
||||||
public double assign(double value) throws EvaluationException;
|
public double assign(double value) throws EvaluationException;
|
||||||
|
|
||||||
|
@Override
|
||||||
public LValue optimize() throws EvaluationException;
|
public LValue optimize() throws EvaluationException;
|
||||||
|
|
||||||
|
@Override
|
||||||
public LValue bindVariables(Expression expression, boolean preferLValue) throws ParserException;
|
public LValue bindVariables(Expression expression, boolean preferLValue) throws ParserException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,17 +19,17 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.internal.expression.runtime;
|
package com.sk89q.worldedit.internal.expression.runtime;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for a pair of Java methods and their arguments (other Nodes), forming an LValue
|
* Wrapper for a pair of Java methods and their arguments (other Nodes),
|
||||||
*
|
* forming an LValue.
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class LValueFunction extends Function implements LValue {
|
public class LValueFunction extends Function implements LValue {
|
||||||
|
|
||||||
private final Object[] setterArgs;
|
private final Object[] setterArgs;
|
||||||
private final Method setter;
|
private final Method setter;
|
||||||
|
|
||||||
@ -73,4 +73,5 @@ public class LValueFunction extends Function implements LValue {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,9 @@ import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A node in the execution tree of an expression.
|
* A node in the execution tree of an expression.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public abstract class Node implements RValue {
|
public abstract class Node implements RValue {
|
||||||
|
|
||||||
private final int position;
|
private final int position;
|
||||||
|
|
||||||
public Node(int position) {
|
public Node(int position) {
|
||||||
@ -37,6 +36,7 @@ public abstract class Node implements RValue {
|
|||||||
@Override
|
@Override
|
||||||
public abstract String toString();
|
public abstract String toString();
|
||||||
|
|
||||||
|
@Override
|
||||||
public RValue optimize() throws EvaluationException {
|
public RValue optimize() throws EvaluationException {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -50,4 +50,5 @@ public abstract class Node implements RValue {
|
|||||||
public RValue bindVariables(Expression expression, boolean preferLValue) throws ParserException {
|
public RValue bindVariables(Expression expression, boolean preferLValue) throws ParserException {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,11 +21,10 @@ package com.sk89q.worldedit.internal.expression.runtime;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains all unary and binary operators.
|
* Contains all unary and binary operators.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("UnusedDeclaration")
|
@SuppressWarnings("UnusedDeclaration")
|
||||||
public final class Operators {
|
public final class Operators {
|
||||||
|
|
||||||
private Operators() {
|
private Operators() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,4 +224,5 @@ public final class Operators {
|
|||||||
final long longDiff = Math.abs(aLong - bLong);
|
final long longDiff = Math.abs(aLong - bLong);
|
||||||
return longDiff <= maxUlps;
|
return longDiff <= maxUlps;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,13 +25,13 @@ import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A value that can be used on the right side of an assignment.
|
* A value that can be used on the right side of an assignment.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public interface RValue extends Identifiable {
|
public interface RValue extends Identifiable {
|
||||||
|
|
||||||
public double getValue() throws EvaluationException;
|
public double getValue() throws EvaluationException;
|
||||||
|
|
||||||
public RValue optimize() throws EvaluationException;
|
public RValue optimize() throws EvaluationException;
|
||||||
|
|
||||||
public RValue bindVariables(Expression expression, boolean preferLValue) throws ParserException;
|
public RValue bindVariables(Expression expression, boolean preferLValue) throws ParserException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,9 @@ import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A return statement.
|
* A return statement.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class Return extends Node {
|
public class Return extends Node {
|
||||||
|
|
||||||
RValue value;
|
RValue value;
|
||||||
|
|
||||||
public Return(int position, RValue value) {
|
public Return(int position, RValue value) {
|
||||||
@ -57,4 +56,5 @@ public class Return extends Node {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,12 +21,10 @@ package com.sk89q.worldedit.internal.expression.runtime;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Thrown when a return statement is encountered.
|
* Thrown when a return statement is encountered.
|
||||||
* {@link com.sk89q.worldedit.internal.expression.Expression#evaluate} catches this exception and returns the enclosed value.
|
* {@link com.sk89q.worldedit.internal.expression.Expression#evaluate}
|
||||||
*
|
* catches this exception and returns the enclosed value.
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class ReturnException extends EvaluationException {
|
public class ReturnException extends EvaluationException {
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
final double value;
|
final double value;
|
||||||
|
|
||||||
@ -39,4 +37,5 @@ public class ReturnException extends EvaluationException {
|
|||||||
public double getValue() {
|
public double getValue() {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,18 +19,19 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.internal.expression.runtime;
|
package com.sk89q.worldedit.internal.expression.runtime;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A sequence of operations, usually separated by semicolons in the input stream.
|
* A sequence of operations, usually separated by semicolons in the
|
||||||
*
|
* input stream.
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class Sequence extends Node {
|
public class Sequence extends Node {
|
||||||
|
|
||||||
final RValue[] sequence;
|
final RValue[] sequence;
|
||||||
|
|
||||||
public Sequence(int position, RValue... sequence) {
|
public Sequence(int position, RValue... sequence) {
|
||||||
@ -77,9 +78,7 @@ public class Sequence extends Node {
|
|||||||
droppedLast = null;
|
droppedLast = null;
|
||||||
invokable = invokable.optimize();
|
invokable = invokable.optimize();
|
||||||
if (invokable instanceof Sequence) {
|
if (invokable instanceof Sequence) {
|
||||||
for (RValue subInvokable : ((Sequence) invokable).sequence) {
|
Collections.addAll(newSequence, ((Sequence) invokable).sequence);
|
||||||
newSequence.add(subInvokable);
|
|
||||||
}
|
|
||||||
} else if (invokable instanceof Constant) {
|
} else if (invokable instanceof Constant) {
|
||||||
droppedLast = invokable;
|
droppedLast = invokable;
|
||||||
} else {
|
} else {
|
||||||
@ -106,4 +105,5 @@ public class Sequence extends Node {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,9 @@ import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple-style for loop.
|
* A simple-style for loop.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class SimpleFor extends Node {
|
public class SimpleFor extends Node {
|
||||||
|
|
||||||
LValue counter;
|
LValue counter;
|
||||||
RValue first;
|
RValue first;
|
||||||
RValue last;
|
RValue last;
|
||||||
@ -98,4 +97,5 @@ public class SimpleFor extends Node {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.internal.expression.runtime;
|
package com.sk89q.worldedit.internal.expression.runtime;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
|
import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -26,15 +29,11 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
|
||||||
import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A switch/case construct.
|
* A switch/case construct.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class Switch extends Node implements RValue {
|
public class Switch extends Node implements RValue {
|
||||||
|
|
||||||
private RValue parameter;
|
private RValue parameter;
|
||||||
private final Map<Double, Integer> valueMap;
|
private final Map<Double, Integer> valueMap;
|
||||||
private final RValue[] caseStatements;
|
private final RValue[] caseStatements;
|
||||||
@ -205,4 +204,5 @@ public class Switch extends Node implements RValue {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,9 @@ import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A variable.
|
* A variable.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public final class Variable extends Node implements LValue {
|
public final class Variable extends Node implements LValue {
|
||||||
|
|
||||||
public double value;
|
public double value;
|
||||||
|
|
||||||
public Variable(double value) {
|
public Variable(double value) {
|
||||||
@ -64,4 +63,5 @@ public final class Variable extends Node implements LValue {
|
|||||||
public LValue bindVariables(Expression expression, boolean preferLValue) throws ParserException {
|
public LValue bindVariables(Expression expression, boolean preferLValue) throws ParserException {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,9 @@ import com.sk89q.worldedit.internal.expression.parser.ParserException;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A while loop.
|
* A while loop.
|
||||||
*
|
|
||||||
* @author TomyLobo
|
|
||||||
*/
|
*/
|
||||||
public class While extends Node {
|
public class While extends Node {
|
||||||
|
|
||||||
RValue condition;
|
RValue condition;
|
||||||
RValue body;
|
RValue body;
|
||||||
boolean footChecked;
|
boolean footChecked;
|
||||||
@ -124,4 +123,5 @@ public class While extends Node {
|
|||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,9 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@SuppressWarnings("UseOfSystemOutOrSystemErr")
|
||||||
public final class DocumentationPrinter {
|
public final class DocumentationPrinter {
|
||||||
|
|
||||||
private DocumentationPrinter() {
|
private DocumentationPrinter() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,7 +193,6 @@ public final class DocumentationPrinter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void writeBukkitYAML(PrintStream stream) {
|
private static void writeBukkitYAML(PrintStream stream) {
|
||||||
|
|
||||||
stream.println("name: WorldEdit");
|
stream.println("name: WorldEdit");
|
||||||
stream.println("main: com.sk89q.worldedit.bukkit.WorldEditPlugin");
|
stream.println("main: com.sk89q.worldedit.bukkit.WorldEditPlugin");
|
||||||
stream.println("version: ${project.version}");
|
stream.println("version: ${project.version}");
|
||||||
@ -202,4 +203,5 @@ public final class DocumentationPrinter {
|
|||||||
stream.println("# Permissions aren't here. Read http://wiki.sk89q.com/wiki/WEPIF/DinnerPerms");
|
stream.println("# Permissions aren't here. Read http://wiki.sk89q.com/wiki/WEPIF/DinnerPerms");
|
||||||
stream.println("# for how WorldEdit permissions actually work.");
|
stream.println("# for how WorldEdit permissions actually work.");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,10 @@ public final class MathUtils {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Safe minimum, such that 1 / SAFE_MIN does not overflow.
|
* Safe minimum, such that 1 / SAFE_MIN does not overflow.
|
||||||
* <p>
|
*
|
||||||
* In IEEE 754 arithmetic, this is also the smallest normalized number
|
* <p>In IEEE 754 arithmetic, this is also the smallest normalized number
|
||||||
* 2<sup>-1022</sup>. The value of this constant is from Apache Commons
|
* 2<sup>-1022</sup>. The value of this constant is from Apache Commons
|
||||||
* Math 2.2.
|
* Math 2.2.</p>
|
||||||
*/
|
*/
|
||||||
public static final double SAFE_MIN = 0x1.0p-1022;
|
public static final double SAFE_MIN = 0x1.0p-1022;
|
||||||
|
|
||||||
|
@ -22,11 +22,8 @@ package com.sk89q.worldedit.math.convolution;
|
|||||||
import java.awt.image.Kernel;
|
import java.awt.image.Kernel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Gaussian Kernel generator (2D bellcurve)
|
* A Gaussian Kernel generator (2D bellcurve).
|
||||||
*
|
|
||||||
* @author Grum
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class GaussianKernel extends Kernel {
|
public class GaussianKernel extends Kernel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -35,7 +32,6 @@ public class GaussianKernel extends Kernel {
|
|||||||
* @param radius the resulting diameter will be radius * 2 + 1
|
* @param radius the resulting diameter will be radius * 2 + 1
|
||||||
* @param sigma controls 'flatness'
|
* @param sigma controls 'flatness'
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public GaussianKernel(int radius, double sigma) {
|
public GaussianKernel(int radius, double sigma) {
|
||||||
super(radius * 2 + 1, radius * 2 + 1, createKernel(radius, sigma));
|
super(radius * 2 + 1, radius * 2 + 1, createKernel(radius, sigma));
|
||||||
}
|
}
|
||||||
@ -54,4 +50,5 @@ public class GaussianKernel extends Kernel {
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,15 @@ import com.sk89q.worldedit.blocks.BaseBlock;
|
|||||||
import com.sk89q.worldedit.blocks.BlockID;
|
import com.sk89q.worldedit.blocks.BlockID;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows applications of Kernels onto the region's height map.
|
* Allows applications of Kernels onto the region's height map.
|
||||||
* Currently only used for smoothing (with a GaussianKernel).
|
|
||||||
*
|
*
|
||||||
* @author Grum
|
* <p>Currently only used for smoothing (with a GaussianKernel)</p>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class HeightMap {
|
public class HeightMap {
|
||||||
|
|
||||||
private int[] data;
|
private int[] data;
|
||||||
private int width;
|
private int width;
|
||||||
private int height;
|
private int height;
|
||||||
@ -44,8 +45,8 @@ public class HeightMap {
|
|||||||
/**
|
/**
|
||||||
* Constructs the HeightMap
|
* Constructs the HeightMap
|
||||||
*
|
*
|
||||||
* @param session
|
* @param session an edit session
|
||||||
* @param region
|
* @param region the region
|
||||||
*/
|
*/
|
||||||
public HeightMap(EditSession session, Region region) {
|
public HeightMap(EditSession session, Region region) {
|
||||||
this(session, region, false);
|
this(session, region, false);
|
||||||
@ -54,11 +55,14 @@ public class HeightMap {
|
|||||||
/**
|
/**
|
||||||
* Constructs the HeightMap
|
* Constructs the HeightMap
|
||||||
*
|
*
|
||||||
* @param session
|
* @param session an edit session
|
||||||
* @param region
|
* @param region the region
|
||||||
* @param naturalOnly ignore non-natural blocks
|
* @param naturalOnly ignore non-natural blocks
|
||||||
*/
|
*/
|
||||||
public HeightMap(EditSession session, Region region, boolean naturalOnly) {
|
public HeightMap(EditSession session, Region region, boolean naturalOnly) {
|
||||||
|
checkNotNull(session);
|
||||||
|
checkNotNull(region);
|
||||||
|
|
||||||
this.session = session;
|
this.session = session;
|
||||||
this.region = region;
|
this.region = region;
|
||||||
|
|
||||||
@ -82,13 +86,15 @@ public class HeightMap {
|
|||||||
/**
|
/**
|
||||||
* Apply the filter 'iterations' amount times.
|
* Apply the filter 'iterations' amount times.
|
||||||
*
|
*
|
||||||
* @param filter
|
* @param filter the filter
|
||||||
* @param iterations
|
* @param iterations the number of iterations
|
||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public int applyFilter(HeightMapFilter filter, int iterations) throws MaxChangedBlocksException {
|
public int applyFilter(HeightMapFilter filter, int iterations) throws MaxChangedBlocksException {
|
||||||
|
checkNotNull(filter);
|
||||||
|
|
||||||
int[] newData = new int[data.length];
|
int[] newData = new int[data.length];
|
||||||
System.arraycopy(data, 0, newData, 0, data.length);
|
System.arraycopy(data, 0, newData, 0, data.length);
|
||||||
|
|
||||||
@ -102,12 +108,14 @@ public class HeightMap {
|
|||||||
/**
|
/**
|
||||||
* Apply a raw heightmap to the region
|
* Apply a raw heightmap to the region
|
||||||
*
|
*
|
||||||
* @param data
|
* @param data the data
|
||||||
* @return number of blocks affected
|
* @return number of blocks affected
|
||||||
* @throws MaxChangedBlocksException
|
* @throws MaxChangedBlocksException
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public int apply(int[] data) throws MaxChangedBlocksException {
|
public int apply(int[] data) throws MaxChangedBlocksException {
|
||||||
|
checkNotNull(data);
|
||||||
|
|
||||||
Vector minY = region.getMinimumPoint();
|
Vector minY = region.getMinimumPoint();
|
||||||
int originX = minY.getBlockX();
|
int originX = minY.getBlockX();
|
||||||
int originY = minY.getBlockY();
|
int originY = minY.getBlockY();
|
||||||
@ -178,4 +186,5 @@ public class HeightMap {
|
|||||||
|
|
||||||
return blocksChanged;
|
return blocksChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -21,33 +21,36 @@ package com.sk89q.worldedit.math.convolution;
|
|||||||
|
|
||||||
import java.awt.image.Kernel;
|
import java.awt.image.Kernel;
|
||||||
|
|
||||||
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows applications of Kernels onto the region's height map.
|
* Allows applications of Kernels onto the region's height map.
|
||||||
* Only used for smoothing (with a GaussianKernel).
|
|
||||||
*
|
*
|
||||||
* @author Grum
|
* <p>Only used for smoothing (with a GaussianKernel).</p>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class HeightMapFilter {
|
public class HeightMapFilter {
|
||||||
|
|
||||||
private Kernel kernel;
|
private Kernel kernel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the HeightMapFilter object.
|
* Construct the HeightMapFilter object.
|
||||||
*
|
*
|
||||||
* @param kernel
|
* @param kernel the kernel
|
||||||
*/
|
*/
|
||||||
public HeightMapFilter(Kernel kernel) {
|
public HeightMapFilter(Kernel kernel) {
|
||||||
|
checkNotNull(kernel);
|
||||||
this.kernel = kernel;
|
this.kernel = kernel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Construct the HeightMapFilter object.
|
* Construct the HeightMapFilter object.
|
||||||
*
|
*
|
||||||
* @param kernelWidth
|
* @param kernelWidth the width
|
||||||
* @param kernelHeight
|
* @param kernelHeight the height
|
||||||
* @param kernelData
|
* @param kernelData the data
|
||||||
*/
|
*/
|
||||||
public HeightMapFilter(int kernelWidth, int kernelHeight, float[] kernelData) {
|
public HeightMapFilter(int kernelWidth, int kernelHeight, float[] kernelData) {
|
||||||
|
checkNotNull(kernelData);
|
||||||
this.kernel = new Kernel(kernelWidth, kernelHeight, kernelData);
|
this.kernel = new Kernel(kernelWidth, kernelHeight, kernelData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,21 +64,26 @@ public class HeightMapFilter {
|
|||||||
/**
|
/**
|
||||||
* Set Kernel
|
* Set Kernel
|
||||||
*
|
*
|
||||||
* @param kernel
|
* @param kernel the kernel
|
||||||
*/
|
*/
|
||||||
public void setKernel(Kernel kernel) {
|
public void setKernel(Kernel kernel) {
|
||||||
|
checkNotNull(kernel);
|
||||||
|
|
||||||
this.kernel = kernel;
|
this.kernel = kernel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter with a 2D kernel
|
* Filter with a 2D kernel
|
||||||
*
|
*
|
||||||
* @param inData
|
* @param inData the data
|
||||||
* @param width
|
* @param width the width
|
||||||
* @param height
|
* @param height the height
|
||||||
|
*
|
||||||
* @return the modified height map
|
* @return the modified height map
|
||||||
*/
|
*/
|
||||||
public int[] filter(int[] inData, int width, int height) {
|
public int[] filter(int[] inData, int width, int height) {
|
||||||
|
checkNotNull(inData);
|
||||||
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
float[] matrix = kernel.getKernelData(null);
|
float[] matrix = kernel.getKernelData(null);
|
||||||
int[] outData = new int[inData.length];
|
int[] outData = new int[inData.length];
|
||||||
@ -117,4 +125,5 @@ public class HeightMapFilter {
|
|||||||
}
|
}
|
||||||
return outData;
|
return outData;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,7 @@ import java.awt.image.Kernel;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A linear Kernel generator (all cells weight the same)
|
* A linear Kernel generator (all cells weight the same)
|
||||||
*
|
|
||||||
* @author Grum
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class LinearKernel extends Kernel {
|
public class LinearKernel extends Kernel {
|
||||||
|
|
||||||
public LinearKernel(int radius) {
|
public LinearKernel(int radius) {
|
||||||
@ -41,4 +38,5 @@ public class LinearKernel extends Kernel {
|
|||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
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