diff --git a/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java b/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java index e909296d2..cc8bcf05c 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java +++ b/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java @@ -53,6 +53,7 @@ import java.util.Collection; * as a "wildcard" block value, even though a {@link Mask} would be * more appropriate.

*/ +@SuppressWarnings("deprecation") public class BaseBlock extends Block implements TileEntityBlock { /** @@ -251,9 +252,8 @@ public class BaseBlock extends Block implements TileEntityBlock { return nbtData; } - @Nullable @Override - public void setNbtData(CompoundTag nbtData) { + public void setNbtData(@Nullable CompoundTag nbtData) { this.nbtData = nbtData; } @@ -359,11 +359,9 @@ public class BaseBlock extends Block implements TileEntityBlock { } final BaseBlock otherBlock = (BaseBlock) o; - if (getType() != otherBlock.getType()) { - return false; - } - return getData() == otherBlock.getData(); + return getType() == otherBlock.getType() && getData() == otherBlock.getData(); + } /** diff --git a/src/main/java/com/sk89q/worldedit/blocks/BlockID.java b/src/main/java/com/sk89q/worldedit/blocks/BlockID.java index 44765e329..b73dd1f6b 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/BlockID.java +++ b/src/main/java/com/sk89q/worldedit/blocks/BlockID.java @@ -21,8 +21,6 @@ package com.sk89q.worldedit.blocks; /** * List of block IDs. - * - * @author sk89q */ public final class BlockID { public static final int AIR = 0; diff --git a/src/main/java/com/sk89q/worldedit/blocks/BlockMaterial.java b/src/main/java/com/sk89q/worldedit/blocks/BlockMaterial.java index 09c9f8716..bf9e3abb0 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/BlockMaterial.java +++ b/src/main/java/com/sk89q/worldedit/blocks/BlockMaterial.java @@ -24,48 +24,160 @@ package com.sk89q.worldedit.blocks; */ public interface BlockMaterial { + /** + * Get whether this block is rendered like a normal block. + * + * @return the value of the test + */ boolean isRenderedAsNormalBlock(); + /** + * Get whether this block is a full sized cube. + * + * @return the value of the test + */ boolean isFullCube(); + /** + * Get whether this block is opaque. + * + * @return the value of the test + */ boolean isOpaque(); + /** + * Get whether this block emits a Redstone signal. + * + * @return the value of the test + */ boolean isPowerSource(); + /** + * Get whether this block is a liquid. + * + * @return the value of the test + */ boolean isLiquid(); + /** + * Get whether this block is a solid. + * + * @return the value of the test + */ boolean isSolid(); + /** + * Get the hardness factor for this block. + * + * @return the hardness factor + */ float getHardness(); + /** + * Get the resistance factor for this block. + * + * @return the resistance factor + */ float getResistance(); + /** + * Get the slipperiness factor for this block. + * + * @return the slipperiness factor + */ float getSlipperiness(); + /** + * Get whether this block blocks grass from growing. + * + * @return whether this block blocks grass + */ boolean isGrassBlocking(); + /** + * Get the ambient occlusion light value. + * + * @return the ambient occlusion light value + */ float getAmbientOcclusionLightValue(); + /** + * Get the opacity of this block for light to pass through. + * + * @return the opacity + */ int getLightOpacity(); + /** + * Get the light value for this block. + * + * @return the light value + */ int getLightValue(); + /** + * Get whether this block breaks when it is pushed by a piston. + * + * @return true if the block breaks + */ boolean isFragileWhenPushed(); + /** + * Get whether this block can be pushed by a piston. + * + * @return true if the block cannot be pushed + */ 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(); + /** + * Get whether this block is ticked randomly. + * + * @return true if this block is ticked randomly + */ boolean isTicksRandomly(); + /** + * Gets whether this block uses a neighbor's light value. + * + * @return true if this block does + */ boolean isUsingNeighborLight(); + /** + * Get whether this block prevents movement. + * + * @return true if this block blocks movement + */ boolean isMovementBlocker(); + /** + * Get whether this block will burn. + * + * @return true if this block will burn + */ 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(); + /** + * 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(); } diff --git a/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java b/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java index 4f6c40731..4b8237400 100644 --- a/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java +++ b/src/main/java/com/sk89q/worldedit/entity/BaseEntity.java @@ -22,10 +22,22 @@ package com.sk89q.worldedit.entity; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.world.NbtValued; +import javax.annotation.Nullable; + 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. + * + *

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.

+ * + *

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.

*/ public class BaseEntity implements NbtValued { @@ -68,14 +80,14 @@ public class BaseEntity implements NbtValued { return true; } + @Nullable @Override public CompoundTag getNbtData() { return nbtData; } @Override - public void setNbtData(CompoundTag nbtData) { - checkNotNull(nbtData); + public void setNbtData(@Nullable CompoundTag nbtData) { this.nbtData = nbtData; } diff --git a/src/main/java/com/sk89q/worldedit/entity/Entity.java b/src/main/java/com/sk89q/worldedit/entity/Entity.java index 4224e5de7..ef806ce7c 100644 --- a/src/main/java/com/sk89q/worldedit/entity/Entity.java +++ b/src/main/java/com/sk89q/worldedit/entity/Entity.java @@ -28,19 +28,21 @@ import javax.annotation.Nullable; /** * A reference to an instance of an entity that exists in an {@link Extent} * and thus would have position and similar details. - *

- * This object cannot be directly cloned because it represents a particular + * + *

This object cannot be directly cloned because it represents a particular * 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 - * can then be used to spawn new instances of that particular entity - * description. + * this entity by calling {@link #getState()}.

*/ public interface Entity extends Faceted { /** * Get a copy of the entity's state. * - * @return the entity's state or null if one cannot be gotten + *

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.

+ * + * @return the entity's state or null if one cannot be created */ @Nullable BaseEntity getState(); diff --git a/src/main/java/com/sk89q/worldedit/entity/Player.java b/src/main/java/com/sk89q/worldedit/entity/Player.java index c5e2e333e..ebb2e24f8 100644 --- a/src/main/java/com/sk89q/worldedit/entity/Player.java +++ b/src/main/java/com/sk89q/worldedit/entity/Player.java @@ -30,7 +30,7 @@ import com.sk89q.worldedit.extent.inventory.BlockBag; import com.sk89q.worldedit.world.World; /** - * A player. + * Represents a player */ 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. * 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 useLastBlock Try to return the last valid air block found. + * @param range how far to checks for blocks + * @param useLastBlock try to return the last valid air block found * @return point */ 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); /** @@ -225,25 +232,31 @@ public interface Player extends Entity, Actor { /** * Get the actor's position. - *

- * If the actor has no permission, then return a dummy location. + * + *

If the actor has no permission, then a dummy location is returned.

* * @return the actor's position + * @deprecated use {@link #getLocation()} */ + @Deprecated WorldVector getPosition(); /** - * Get the player's view pitch. + * Get the player's view pitch in degrees. * * @return pitch + * @deprecated use {@link #getLocation()} */ + @Deprecated double getPitch(); /** - * Get the player's view yaw. + * Get the player's view yaw in degrees. * * @return yaw + * @deprecated use {@link #getLocation()} */ + @Deprecated double getYaw(); /** @@ -257,16 +270,16 @@ public interface Player extends Entity, Actor { /** * Move the player. * - * @param pos Where to move them - * @param pitch The pitch (up/down) of the player's view - * @param yaw The yaw (left/right) of the player's view + * @param pos where to move them + * @param pitch the pitch (up/down) of the player's view in degrees + * @param yaw the yaw (left/right) of the player's view in degrees */ void setPosition(Vector pos, float pitch, float yaw); /** * Move the player. * - * @param pos Where to move them + * @param pos where to move them */ void setPosition(Vector pos); diff --git a/src/main/java/com/sk89q/worldedit/event/extent/EditSessionEvent.java b/src/main/java/com/sk89q/worldedit/event/extent/EditSessionEvent.java index 38124defe..f90642d07 100644 --- a/src/main/java/com/sk89q/worldedit/event/extent/EditSessionEvent.java +++ b/src/main/java/com/sk89q/worldedit/event/extent/EditSessionEvent.java @@ -34,17 +34,19 @@ import static com.sk89q.worldedit.EditSession.Stage; /** * Raised (several times) when a new {@link EditSession} is being instantiated. - *

- * Block loggers, as well as block set interceptors, can use this event to wrap + * + *

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 * 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 * all method calls before the extent fetched from - * {@link #getExtent()} would. + * {@link #getExtent()} would.

+ * *
  * event.setExtent(new MyExtent(event.getExtent())
  * 
- * This event is fired several times during the creation of a single + * + *

This event is fired several times during the creation of a single * {@link EditSession}, but {@link #getStage()} will differ each time. * 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 @@ -55,7 +57,7 @@ import static com.sk89q.worldedit.EditSession.Stage; * custom {@link Extent} because that method bypasses history (and reorder). * It is thus recommended that loggers intercept at {@link Stage#BEFORE_CHANGE} * and block interceptors intercept at BOTH {@link Stage#BEFORE_CHANGE} and - * {@link Stage#BEFORE_HISTORY}. + * {@link Stage#BEFORE_HISTORY}.

*/ public class EditSessionEvent extends Event { diff --git a/src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java b/src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java index 2cb5c9d1d..43037ccf5 100644 --- a/src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java +++ b/src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java @@ -31,9 +31,9 @@ import java.util.Set; /** * A registry of known {@link BaseBlock}s. Provides methods to instantiate * new blocks from input. - *

- * Instances of this class can be taken from - * {@link WorldEdit#getBlockFactory()}. + * + *

Instances of this class can be taken from + * {@link WorldEdit#getBlockFactory()}.

*/ public class BlockFactory extends AbstractFactory { diff --git a/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java b/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java index 3ecbc15fb..5b21294b0 100644 --- a/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java +++ b/src/main/java/com/sk89q/worldedit/extension/factory/DefaultBlockParser.java @@ -144,7 +144,7 @@ class DefaultBlockParser extends InputParser { if (parseDataValue) { // Block data not yet detected // Parse the block data (optional) try { - if (typeAndData.length > 1 && typeAndData[1].length() > 0) { + if (typeAndData.length > 1 && !typeAndData[1].isEmpty()) { data = Integer.parseInt(typeAndData[1]); } diff --git a/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java b/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java index 2d697fbbb..e611f93b7 100644 --- a/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java +++ b/src/main/java/com/sk89q/worldedit/extension/factory/DefaultMaskParser.java @@ -63,7 +63,7 @@ class DefaultMaskParser extends InputParser { List masks = new ArrayList(); for (String component : input.split(" ")) { - if (component.length() == 0) { + if (component.isEmpty()) { continue; } diff --git a/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java b/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java index 309992bcb..01fef9803 100644 --- a/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java +++ b/src/main/java/com/sk89q/worldedit/extension/factory/MaskFactory.java @@ -26,9 +26,9 @@ import com.sk89q.worldedit.internal.registry.AbstractFactory; /** * A registry of known {@link Mask}s. Provides methods to instantiate * new masks from input. - *

- * Instances of this class can be taken from - * {@link WorldEdit#getMaskFactory()}. + * + *

Instances of this class can be taken from + * {@link WorldEdit#getMaskFactory()}.

*/ public final class MaskFactory extends AbstractFactory { diff --git a/src/main/java/com/sk89q/worldedit/extension/factory/PatternFactory.java b/src/main/java/com/sk89q/worldedit/extension/factory/PatternFactory.java index e19891148..71225e7d1 100644 --- a/src/main/java/com/sk89q/worldedit/extension/factory/PatternFactory.java +++ b/src/main/java/com/sk89q/worldedit/extension/factory/PatternFactory.java @@ -26,9 +26,9 @@ import com.sk89q.worldedit.internal.registry.AbstractFactory; /** * A registry of known {@link Pattern}s. Provides methods to instantiate * new patterns from input. - *

- * Instances of this class can be taken from - * {@link WorldEdit#getPatternFactory()}. + * + *

Instances of this class can be taken from + * {@link WorldEdit#getPatternFactory()}.

*/ public final class PatternFactory extends AbstractFactory { diff --git a/src/main/java/com/sk89q/worldedit/extension/input/ParserContext.java b/src/main/java/com/sk89q/worldedit/extension/input/ParserContext.java index dd3a487af..b2f61e880 100644 --- a/src/main/java/com/sk89q/worldedit/extension/input/ParserContext.java +++ b/src/main/java/com/sk89q/worldedit/extension/input/ParserContext.java @@ -30,8 +30,8 @@ import javax.annotation.Nullable; /** * Contains contextual information that may be useful when constructing * objects from a registry (such as {@link MaskFactory}). - *

- * By default, {@link #isRestricted()} will return true. + * + *

By default, {@link #isRestricted()} will return true.

*/ public class ParserContext { diff --git a/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java b/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java index 85cb40134..8fb39631c 100644 --- a/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java +++ b/src/main/java/com/sk89q/worldedit/extension/platform/CommandManager.java @@ -59,8 +59,8 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Handles the registration and invocation of commands. - *

- * This class is primarily for internal usage. + * + *

This class is primarily for internal usage.

*/ public final class CommandManager { @@ -206,7 +206,7 @@ public final class CommandManager { Request.reset(); Actor actor = platformManager.createProxyActor(event.getActor()); - String split[] = commandDetection(event.getArguments().split(" ")); + String[] split = commandDetection(event.getArguments().split(" ")); // No command found! if (!dispatcher.contains(split[0])) { diff --git a/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java b/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java index 0c450689e..e8eb0b227 100644 --- a/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java +++ b/src/main/java/com/sk89q/worldedit/extension/platform/PlatformManager.java @@ -44,8 +44,8 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Manages registered {@link Platform}s for WorldEdit. Platforms are * implementations of WorldEdit. - *

- * This class is thread-safe. + * + *

This class is thread-safe.

*/ public class PlatformManager { @@ -99,9 +99,9 @@ public class PlatformManager { /** * Unregister a platform from WorldEdit. - *

- * If the platform has been chosen for any capabilities, then a new - * platform will be found. + * + *

If the platform has been chosen for any capabilities, then a new + * platform will be found.

* * @param platform the platform */ @@ -189,8 +189,8 @@ public class PlatformManager { /** * Get a list of loaded platforms. - *

- * The returned list is a copy of the original and is mutable. + * + *

The returned list is a copy of the original and is mutable.

* * @return a list of platforms */ @@ -252,9 +252,9 @@ public class PlatformManager { /** * Get the current configuration. - *

- * If no platform has been registered yet, then a default configuration - * will be returned. + * + *

If no platform has been registered yet, then a default configuration + * will be returned.

* * @return the configuration */ @@ -365,7 +365,6 @@ public class PlatformManager { // Create a proxy actor with a potentially different world for // making changes to the world Player player = createProxyActor(event.getPlayer()); - World world = player.getWorld(); switch (event.getInputType()) { case PRIMARY: { diff --git a/src/main/java/com/sk89q/worldedit/extent/Extent.java b/src/main/java/com/sk89q/worldedit/extent/Extent.java index 51ae4fc84..436c59ea8 100644 --- a/src/main/java/com/sk89q/worldedit/extent/Extent.java +++ b/src/main/java/com/sk89q/worldedit/extent/Extent.java @@ -39,9 +39,9 @@ public interface Extent extends InputExtent, OutputExtent { /** * Get the minimum point in the extent. - *

- * If the extent is unbounded, then a large (negative) value may - * be returned. + * + *

If the extent is unbounded, then a large (negative) value may + * be returned.

* * @return the minimum point */ @@ -49,9 +49,9 @@ public interface Extent extends InputExtent, OutputExtent { /** * Get the maximum point in the extent. - *

- * If the extent is unbounded, then a large (positive) value may - * be returned. + * + *

If the extent is unbounded, then a large (positive) value may + * be returned.

* * @return the maximum point */ @@ -59,10 +59,10 @@ public interface Extent extends InputExtent, OutputExtent { /** * Get a list of all entities within the given region. - *

- * If the extent is not wholly loaded (i.e. a world being simulated in the + * + *

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 - * incomplete. + * incomplete.

* * @return a list of entities */ @@ -70,10 +70,10 @@ public interface Extent extends InputExtent, OutputExtent { /** * Get a list of all entities. - *

- * If the extent is not wholly loaded (i.e. a world being simulated in the + * + *

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 - * incomplete. + * incomplete.

* * @return a list of entities */ diff --git a/src/main/java/com/sk89q/worldedit/extent/InputExtent.java b/src/main/java/com/sk89q/worldedit/extent/InputExtent.java index 81fcce5c9..f8e3a7a8f 100644 --- a/src/main/java/com/sk89q/worldedit/extent/InputExtent.java +++ b/src/main/java/com/sk89q/worldedit/extent/InputExtent.java @@ -32,20 +32,20 @@ public interface InputExtent { /** * Get a snapshot of the block at the given location. - *

- * If the given position is out of the bounds of the extent, then the behavior - * is undefined (an air block could be returned). However, null - * should not be returned. - *

- * The returned block is mutable and is a snapshot of the block at the time + * + *

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} + * should not be returned.

+ * + *

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 - * {@link Pattern}s and so on. - *

- * Calls to this method can actually be quite expensive, so cache results + * {@link Pattern}s and so on.

+ * + *

Calls to this method can actually be quite expensive, so cache results * whenever it is possible, while being aware of the mutability aspect. * The cost, however, depends on the implementation and particular extent. * If only basic information about the block is required, then use of - * {@link #getLazyBlock(Vector)} is recommended. + * {@link #getLazyBlock(Vector)} is recommended.

* * @param position position of 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 * immediately contains information about the block's type (and metadata). - *

- * Further information (such as NBT data) will be available by the + * + *

Further information (such as NBT data) will be available by the * time of access. Therefore, it is not recommended that * 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 * 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 - * modifiable copy is required, then the block should be cloned. - *

- * This method exists because it is sometimes important to inspect the block + * modifiable copy is required, then the block should be cloned.

+ * + *

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 * the underlying implementation. It is also not possible to implement * caching if the returned object is mutable, so this methods allows caching - * implementations to be used. + * implementations to be used.

* * @param position position of the block * @return the block diff --git a/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java b/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java index e0268495d..e7218e719 100644 --- a/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java +++ b/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java @@ -37,13 +37,13 @@ public interface OutputExtent { * 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 * {@link BaseBlock} do not affect the world until this method is called again. - *

- * The return value of this method indicates whether the change was probably + * + *

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 * 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 * 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.

* * @param position position of the block * @param block block to set diff --git a/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java b/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java index 7070da6e6..297df8b1a 100644 --- a/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java +++ b/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java @@ -42,9 +42,9 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Buffers changes to an {@link Extent} and allows later retrieval for * actual application of the changes. - *

- * This buffer will not attempt to return results from the buffer when - * accessor methods (such as {@link #getBlock(Vector)}) are called. + * + *

This buffer will not attempt to return results from the buffer when + * accessor methods (such as {@link #getBlock(Vector)}) are called.

*/ public class ForgetfulExtentBuffer extends AbstractDelegateExtent implements Pattern { diff --git a/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java b/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java index 1b819e036..15c9b7345 100644 --- a/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java +++ b/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java @@ -51,8 +51,8 @@ public class BlockArrayClipboard implements Clipboard { /** * Create a new instance. - *

- * The origin will be placed at the region's lowest minimum point. + * + *

The origin will be placed at the region's lowest minimum point.

* * @param region the bounding region */ diff --git a/src/main/java/com/sk89q/worldedit/extent/clipboard/StoredEntity.java b/src/main/java/com/sk89q/worldedit/extent/clipboard/StoredEntity.java index a38d2d412..4311ada18 100644 --- a/src/main/java/com/sk89q/worldedit/extent/clipboard/StoredEntity.java +++ b/src/main/java/com/sk89q/worldedit/extent/clipboard/StoredEntity.java @@ -28,8 +28,8 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * An implementation of {@link Entity} that stores a {@link BaseEntity} with it. - *

- * Calls to {@link #getState()} return a clone. + * + *

Calls to {@link #getState()} return a clone.

*/ abstract class StoredEntity implements Entity { diff --git a/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBag.java b/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBag.java index bc8ad8d86..969ecbd84 100644 --- a/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBag.java +++ b/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBag.java @@ -24,15 +24,14 @@ import com.sk89q.worldedit.blocks.*; /** * Represents a source to get blocks from and store removed ones. - * - * @author sk89q */ public abstract class BlockBag { + /** * Stores a block as if it was mined. * - * @param id - * @throws BlockBagException + * @param id the type ID + * @throws BlockBagException on error * @deprecated Use {@link BlockBag#storeDroppedBlock(int, int)} instead */ @Deprecated @@ -43,9 +42,9 @@ public abstract class BlockBag { /** * Stores a block as if it was mined. * - * @param id - * @param data - * @throws BlockBagException + * @param id the type ID + * @param data the data value + * @throws BlockBagException on error */ public void storeDroppedBlock(int id, int data) throws BlockBagException { BaseItem dropped = BlockType.getBlockBagItem(id, data); @@ -58,8 +57,8 @@ public abstract class BlockBag { /** * Sets a block as if it was placed by hand. * - * @param id - * @throws BlockBagException + * @param id the type ID + * @throws BlockBagException on error * @deprecated Use {@link #fetchPlacedBlock(int,int)} instead */ @Deprecated @@ -70,9 +69,9 @@ public abstract class BlockBag { /** * Sets a block as if it was placed by hand. * - * @param id - * @param data TODO - * @throws BlockBagException + * @param id the type ID + * @param data the data value + * @throws BlockBagException on error */ public void fetchPlacedBlock(int id, int data) throws BlockBagException { try { @@ -117,10 +116,10 @@ public abstract class BlockBag { /** * Get a block. * - * Either this method or fetchItem needs to be overridden + *

Either this method or fetchItem needs to be overridden.

* - * @param id - * @throws BlockBagException + * @param id the type ID + * @throws BlockBagException on error */ public void fetchBlock(int id) throws BlockBagException { fetchItem(new BaseItem(id)); @@ -129,10 +128,10 @@ public abstract class BlockBag { /** * Get a block. * - * Either this method or fetchBlock needs to be overridden + *

Either this method or fetchItem needs to be overridden.

* - * @param item - * @throws BlockBagException + * @param item the item + * @throws BlockBagException on error */ public void fetchItem(BaseItem item) throws BlockBagException { fetchBlock(item.getType()); @@ -140,11 +139,11 @@ public abstract class BlockBag { /** * Store a block. + * + *

Either this method or fetchItem needs to be overridden.

* - * Either this method or storeItem needs to be overridden - * - * @param id - * @throws BlockBagException + * @param id the type ID + * @throws BlockBagException on error */ public void storeBlock(int id) throws BlockBagException { storeItem(new BaseItem(id)); @@ -152,11 +151,11 @@ public abstract class BlockBag { /** * Store a block. + * + *

Either this method or fetchItem needs to be overridden.

* - * Either this method or storeBlock needs to be overridden - * - * @param item - * @throws BlockBagException + * @param item the item + * @throws BlockBagException on error */ public void storeItem(BaseItem item) throws BlockBagException { storeBlock(item.getType()); @@ -165,7 +164,7 @@ public abstract class BlockBag { /** * Checks to see if a block exists without removing it. * - * @param id + * @param id the type ID * @return whether the block exists */ public boolean peekBlock(int id) { @@ -186,14 +185,14 @@ public abstract class BlockBag { /** * Adds a position to be used a source. * - * @param pos + * @param pos the position */ public abstract void addSourcePosition(WorldVector pos); /** * Adds a position to be used a source. * - * @param pos + * @param pos the position */ public abstract void addSingleSourcePosition(WorldVector pos); } diff --git a/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagException.java b/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagException.java index 9cce8a5ac..07a450887 100644 --- a/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagException.java +++ b/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagException.java @@ -20,9 +20,7 @@ package com.sk89q.worldedit.extent.inventory; /** - * - * @author sk89q + * Thrown when a block bag detects a problem. */ public class BlockBagException extends Exception { - private static final long serialVersionUID = 4672190086028430655L; } diff --git a/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java b/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java index 0d29fea34..7eca18d20 100644 --- a/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java +++ b/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java @@ -44,7 +44,6 @@ public class BlockBagExtent extends AbstractDelegateExtent { * Create a new instance. * * @param extent the extent - * @param world the world * @param blockBag the block bag */ public BlockBagExtent(Extent extent, @Nullable BlockBag blockBag) { diff --git a/src/main/java/com/sk89q/worldedit/extent/inventory/OutOfBlocksException.java b/src/main/java/com/sk89q/worldedit/extent/inventory/OutOfBlocksException.java index be85ce4c7..7c632c664 100644 --- a/src/main/java/com/sk89q/worldedit/extent/inventory/OutOfBlocksException.java +++ b/src/main/java/com/sk89q/worldedit/extent/inventory/OutOfBlocksException.java @@ -20,9 +20,7 @@ package com.sk89q.worldedit.extent.inventory; /** - * - * @author sk89q + * Thrown when there are no more blocks left. */ public class OutOfBlocksException extends BlockBagException { - private static final long serialVersionUID = 7495899825677689509L; } diff --git a/src/main/java/com/sk89q/worldedit/extent/inventory/OutOfSpaceException.java b/src/main/java/com/sk89q/worldedit/extent/inventory/OutOfSpaceException.java index 0d06d6d80..27eb6d1f4 100644 --- a/src/main/java/com/sk89q/worldedit/extent/inventory/OutOfSpaceException.java +++ b/src/main/java/com/sk89q/worldedit/extent/inventory/OutOfSpaceException.java @@ -20,26 +20,24 @@ package com.sk89q.worldedit.extent.inventory; /** - * - * @author sk89q + * Thrown when the target inventory of a block bag is full. */ public class OutOfSpaceException extends BlockBagException { - private static final long serialVersionUID = -2962840237632916821L; - /** - * Stores the block ID. - */ private int id; /** * Construct the object. - * @param id + * + * @param id the ID of the block */ public OutOfSpaceException(int id) { this.id = id; } /** + * Get the ID of the block + * * @return the id */ public int getID() { diff --git a/src/main/java/com/sk89q/worldedit/extent/inventory/UnplaceableBlockException.java b/src/main/java/com/sk89q/worldedit/extent/inventory/UnplaceableBlockException.java index fecb02bba..2749a5688 100644 --- a/src/main/java/com/sk89q/worldedit/extent/inventory/UnplaceableBlockException.java +++ b/src/main/java/com/sk89q/worldedit/extent/inventory/UnplaceableBlockException.java @@ -20,10 +20,7 @@ package com.sk89q.worldedit.extent.inventory; /** - * - * @author sk89q + * Thrown when a block that can't be placed is used. */ public class UnplaceableBlockException extends BlockBagException { - private static final long serialVersionUID = 7227883966999843526L; - } diff --git a/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java b/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java index 578639019..0f1b3fda0 100644 --- a/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java +++ b/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java @@ -186,7 +186,7 @@ public class MultiStageReorder extends AbstractDelegateExtent implements Reorder current = current.add(attachment.vector()).toBlockVector(); 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; } diff --git a/src/main/java/com/sk89q/worldedit/extent/reorder/ReorderingExtent.java b/src/main/java/com/sk89q/worldedit/extent/reorder/ReorderingExtent.java index 66c9c7015..84e5626f0 100644 --- a/src/main/java/com/sk89q/worldedit/extent/reorder/ReorderingExtent.java +++ b/src/main/java/com/sk89q/worldedit/extent/reorder/ReorderingExtent.java @@ -24,10 +24,10 @@ import com.sk89q.worldedit.extent.Extent; /** * An interface for {@link Extent}s that are meant to reorder changes so * that they are more successful. - *

- * For example, torches in Minecraft need to be placed on a block. A smart + * + *

For example, torches in Minecraft need to be placed on a block. A smart * reordering implementation might place the torch after the block has - * been placed. + * been placed.

*/ public interface ReorderingExtent extends Extent { diff --git a/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java b/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java index bbf5b4699..de7c21b2c 100644 --- a/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java +++ b/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java @@ -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. - *

- * Note that this extent may choose to not call the underlying + * + *

Note that this extent may choose to not call the underlying * 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 - * should catch them before the changes reach this extent. + * should catch them before the changes reach this extent.

*/ 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 * use of game tools (such as pickaxes) whenever possible and reasonable. - *

- * For example, we could pretend that the act of setting a coal ore block + * + *

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 - * 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.

* * @return true if tool use is to be simulated */ diff --git a/src/main/java/com/sk89q/worldedit/function/LayerFunction.java b/src/main/java/com/sk89q/worldedit/function/LayerFunction.java index e54049725..bd9acb7cb 100644 --- a/src/main/java/com/sk89q/worldedit/function/LayerFunction.java +++ b/src/main/java/com/sk89q/worldedit/function/LayerFunction.java @@ -39,9 +39,9 @@ public interface LayerFunction { /** * Apply the function to the given position. - *

- * The depth would be the number of blocks from the surface if - * a {@link LayerVisitor} was used. + * + *

The depth would be the number of blocks from the surface if + * a {@link LayerVisitor} was used.

* * @param position the position * @param depth the depth as a number starting from 0 diff --git a/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java b/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java index 25d64a135..17d2547d6 100644 --- a/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java +++ b/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java @@ -31,9 +31,9 @@ import com.sk89q.worldedit.function.pattern.RandomPattern; /** * Generates flora (which may include tall grass, flowers, etc.). - *

- * The current implementation is not biome-aware, but it may become so in - * the future. + * + *

The current implementation is not biome-aware, but it may become so in + * the future.

*/ 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. - *

- * By default, it is currently disabled by default, but this may change. + * + *

By default, it is currently disabled by default, but + * this may change.

* * @return true if biome aware */ @@ -64,8 +65,8 @@ public class FloraGenerator implements RegionFunction { /** * Set whether the generator is biome aware. - *

- * It is currently not possible to make the generator biome-aware. + * + *

It is currently not possible to make the generator biome-aware.

* * @param biomeAware must always be false */ @@ -73,7 +74,6 @@ public class FloraGenerator implements RegionFunction { if (biomeAware) { throw new IllegalArgumentException("Cannot enable biome-aware mode; not yet implemented"); } - this.biomeAware = biomeAware; } /** diff --git a/src/main/java/com/sk89q/worldedit/function/mask/Masks.java b/src/main/java/com/sk89q/worldedit/function/mask/Masks.java index 837bcd2ae..86280cb08 100644 --- a/src/main/java/com/sk89q/worldedit/function/mask/Masks.java +++ b/src/main/java/com/sk89q/worldedit/function/mask/Masks.java @@ -133,10 +133,10 @@ public final class Masks { /** * Wrap an old-style mask and convert it to a new mask. - *

- * Note, however, that this is strongly not recommended because + * + *

Note, however, that this is strongly not recommended because * {@link com.sk89q.worldedit.masks.Mask#prepare(LocalSession, LocalPlayer, Vector)} - * is not called. + * is not called.

* * @param mask the old-style mask * @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. - *

- * As an {@link EditSession} is not provided in this case, one will be + * + *

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 - * mask will return false. + * mask will return false.

* * @param mask the old-style mask * @return a new-style mask diff --git a/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java b/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java index 7c5b658d4..61dd7b73a 100644 --- a/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java +++ b/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter.java @@ -77,8 +77,6 @@ public class NoiseFilter extends AbstractMask { /** * Set the probability of passing as a number between 0 and 1 (inclusive). - * - * @return the density */ public void setDensity(double density) { checkArgument(density >= 0, "density must be >= 0"); diff --git a/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter2D.java b/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter2D.java index f0dbe6240..6a2146c58 100644 --- a/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter2D.java +++ b/src/main/java/com/sk89q/worldedit/function/mask/NoiseFilter2D.java @@ -75,8 +75,6 @@ public class NoiseFilter2D extends AbstractMask2D { /** * Set the probability of passing as a number between 0 and 1 (inclusive). - * - * @return the density */ public void setDensity(double density) { checkArgument(density >= 0, "density must be >= 0"); diff --git a/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java b/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java index 3f9887b28..06da47e6b 100644 --- a/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java +++ b/src/main/java/com/sk89q/worldedit/function/operation/ForwardExtentCopy.java @@ -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. - *

- * This is a forward extent copy, meaning that it iterates over the blocks in the - * source extent, and will copy as many blocks as there are in the source. - * Therefore, interpolation will not occur to fill in the gaps. + * + *

This is a forward extent copy, meaning that it iterates over the blocks + * in the source extent, and will copy as many blocks as there are in the + * source. Therefore, interpolation will not occur to fill in the gaps.

*/ public class ForwardExtentCopy implements Operation { @@ -102,8 +102,8 @@ public class ForwardExtentCopy implements Operation { /** * Get the transformation that will occur on every point. - *

- * The transformation will stack with each repetition. + * + *

The transformation will stack with each repetition.

* * @return a transformation */ @@ -124,8 +124,8 @@ public class ForwardExtentCopy implements Operation { /** * Get the mask that gets applied to the source extent. - *

- * This mask can be used to filter what will be copied from the source. + * + *

This mask can be used to filter what will be copied from the source.

* * @return a source mask */ @@ -195,7 +195,7 @@ public class ForwardExtentCopy implements Operation { /** * Set whether entities that are copied should be removed. * - * @param removing true if removing + * @param removingEntities true if removing */ public void setRemovingEntities(boolean removingEntities) { this.removingEntities = removingEntities; diff --git a/src/main/java/com/sk89q/worldedit/function/operation/OperationQueue.java b/src/main/java/com/sk89q/worldedit/function/operation/OperationQueue.java index fd25f7c8c..895195c2f 100644 --- a/src/main/java/com/sk89q/worldedit/function/operation/OperationQueue.java +++ b/src/main/java/com/sk89q/worldedit/function/operation/OperationQueue.java @@ -77,7 +77,7 @@ public class OperationQueue implements Operation { @Override public Operation resume(RunContext run) throws WorldEditException { - if (current == null && queue.size() > 0) { + if (current == null && !queue.isEmpty()) { current = queue.poll(); } diff --git a/src/main/java/com/sk89q/worldedit/function/operation/RunContext.java b/src/main/java/com/sk89q/worldedit/function/operation/RunContext.java index c8c7b15c7..1af0412cf 100644 --- a/src/main/java/com/sk89q/worldedit/function/operation/RunContext.java +++ b/src/main/java/com/sk89q/worldedit/function/operation/RunContext.java @@ -26,8 +26,8 @@ public class RunContext { /** * Return whether the current operation should still continue running. - *

- * This method can be called frequently. + * + *

This method can be called frequently.

* * @return true if the operation should continue running */ diff --git a/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java b/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java index 00a0f8661..992eda5c5 100644 --- a/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java +++ b/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java @@ -39,9 +39,9 @@ public class RandomPattern extends AbstractPattern { /** * Add a pattern to the weight list of patterns. - *

- * The probability for the pattern added is chance / max where max is the sum - * of the probabilities of all added patterns. + * + *

The probability for the pattern added is chance / max where max is + * the sum of the probabilities of all added patterns.

* * @param pattern the pattern * @param chance the chance, which can be any positive number diff --git a/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java b/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java index 368e8d906..5356f568d 100644 --- a/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java +++ b/src/main/java/com/sk89q/worldedit/function/visitor/BreadthFirstSearch.java @@ -36,10 +36,10 @@ import static com.google.common.base.Preconditions.checkNotNull; * to a certain adjacent point provided that the method * {@link #isVisitable(com.sk89q.worldedit.Vector, com.sk89q.worldedit.Vector)} * returns true for that point. - *

- * As an abstract implementation, this class can be used to implement + * + *

As an abstract implementation, this class can be used to implement * functionality that starts at certain points and extends outward from - * those points. + * those points.

*/ public abstract class BreadthFirstSearch implements Operation { @@ -62,12 +62,13 @@ public abstract class BreadthFirstSearch implements Operation { /** * Get the list of directions will be visited. - *

- * Directions are {@link com.sk89q.worldedit.Vector}s that determine + * + *

Directions are {@link com.sk89q.worldedit.Vector}s that determine * what adjacent points area available. Vectors should not be - * unit vectors. An example of a valid direction is {@code new Vector(1, 0, 1)}. - *

- * The list of directions can be cleared. + * unit vectors. An example of a valid direction is + * {@code new Vector(1, 0, 1)}.

+ * + *

The list of directions can be cleared.

* * @return the list of directions */ diff --git a/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java b/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java index 1fe358da5..ae57a4418 100644 --- a/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java +++ b/src/main/java/com/sk89q/worldedit/function/visitor/DownwardVisitor.java @@ -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 * pass the given mask, and then executes the provided region * function on the entire column. - *

- * This is used by //fill. + * + *

This is used by {@code //fill}.

*/ public class DownwardVisitor extends RecursiveVisitor { diff --git a/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java b/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java index e368a8606..93b03c60e 100644 --- a/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java +++ b/src/main/java/com/sk89q/worldedit/function/visitor/LayerVisitor.java @@ -34,11 +34,11 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Visits the layers within a region. - *

- * This class works by iterating over all the columns in a {@link FlatRegion}, + * + *

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 * maximum Y down to a minimum Y), and then applies a {@link LayerFunction} to - * each layer. + * each layer.

*/ public class LayerVisitor implements Operation { diff --git a/src/main/java/com/sk89q/worldedit/history/UndoContext.java b/src/main/java/com/sk89q/worldedit/history/UndoContext.java index 31ec39c41..647844acb 100644 --- a/src/main/java/com/sk89q/worldedit/history/UndoContext.java +++ b/src/main/java/com/sk89q/worldedit/history/UndoContext.java @@ -26,9 +26,9 @@ import javax.annotation.Nullable; /** * Provides context for undo and redo operations. - *

- * For example, {@link BlockChange}s take the {@link Extent} from the - * context rather than store a reference to one. + * + *

For example, {@link BlockChange}s take the {@link Extent} from the + * context rather than store a reference to one.

*/ public class UndoContext { diff --git a/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java b/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java index 142c29e42..0b1e91e05 100644 --- a/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java +++ b/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java @@ -29,10 +29,10 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Represents a block change that may be undone or replayed. - *

- * This block change does not have an {@link Extent} assigned to it because + * + *

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 - * does not have an extent (it is null), cryptic errors may occur. + * does not have an extent (it is null), cryptic errors may occur.

*/ public class BlockChange implements Change { diff --git a/src/main/java/com/sk89q/worldedit/history/changeset/BlockOptimizedHistory.java b/src/main/java/com/sk89q/worldedit/history/changeset/BlockOptimizedHistory.java index 4750ecd36..d8286ffb5 100644 --- a/src/main/java/com/sk89q/worldedit/history/changeset/BlockOptimizedHistory.java +++ b/src/main/java/com/sk89q/worldedit/history/changeset/BlockOptimizedHistory.java @@ -36,10 +36,10 @@ import static java.util.Map.Entry; /** * An extension of {@link ArrayListHistory} that stores {@link BlockChange}s * separately in two {@link ArrayList}s. - *

- * Whether this is a good idea or not is highly questionable, but this class + * + *

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 - * many years. + * many years.

*/ public class BlockOptimizedHistory extends ArrayListHistory { diff --git a/src/main/java/com/sk89q/worldedit/history/changeset/ChangeSet.java b/src/main/java/com/sk89q/worldedit/history/changeset/ChangeSet.java index eab0d0e87..0b018bcb9 100644 --- a/src/main/java/com/sk89q/worldedit/history/changeset/ChangeSet.java +++ b/src/main/java/com/sk89q/worldedit/history/changeset/ChangeSet.java @@ -38,9 +38,9 @@ public interface ChangeSet { /** * Get a backward directed iterator that can be used for undo. - *

- * The iterator may return the changes out of order, as long as the final - * result after all changes have been applied is correct. + * + *

The iterator may return the changes out of order, as long as the final + * result after all changes have been applied is correct.

* * @return a undo directed iterator */ @@ -48,9 +48,9 @@ public interface ChangeSet { /** * Get a forward directed iterator that can be used for redo. - *

- * The iterator may return the changes out of order, as long as the final - * result after all changes have been applied is correct. + * + *

The iterator may return the changes out of order, as long as the final + * result after all changes have been applied is correct.

* * @return a forward directed iterator */ diff --git a/src/main/java/com/sk89q/worldedit/internal/LocalWorldAdapter.java b/src/main/java/com/sk89q/worldedit/internal/LocalWorldAdapter.java index d800de00a..2ded7c439 100644 --- a/src/main/java/com/sk89q/worldedit/internal/LocalWorldAdapter.java +++ b/src/main/java/com/sk89q/worldedit/internal/LocalWorldAdapter.java @@ -47,6 +47,7 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Wraps {@link World}s into {@link LocalWorld}. */ +@SuppressWarnings("deprecation") public class LocalWorldAdapter extends LocalWorld { private final World world; @@ -203,6 +204,7 @@ public class LocalWorldAdapter extends LocalWorld { return world.getWorldData(); } + @SuppressWarnings("EqualsWhichDoesntCheckParameterClass") @Override public boolean equals(Object other) { return world.equals(other); diff --git a/src/main/java/com/sk89q/worldedit/internal/ServerInterfaceAdapter.java b/src/main/java/com/sk89q/worldedit/internal/ServerInterfaceAdapter.java index 32d0922cc..af49c16f4 100644 --- a/src/main/java/com/sk89q/worldedit/internal/ServerInterfaceAdapter.java +++ b/src/main/java/com/sk89q/worldedit/internal/ServerInterfaceAdapter.java @@ -37,6 +37,7 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Adapts {@link Platform}s into the legacy {@link ServerInterface}. */ +@SuppressWarnings("ALL") public class ServerInterfaceAdapter extends ServerInterface { private final Platform platform; diff --git a/src/main/java/com/sk89q/worldedit/internal/cui/CUIRegion.java b/src/main/java/com/sk89q/worldedit/internal/cui/CUIRegion.java index f4bfd934c..84b740e39 100644 --- a/src/main/java/com/sk89q/worldedit/internal/cui/CUIRegion.java +++ b/src/main/java/com/sk89q/worldedit/internal/cui/CUIRegion.java @@ -19,7 +19,6 @@ package com.sk89q.worldedit.internal.cui; -import com.sk89q.worldedit.LocalPlayer; import com.sk89q.worldedit.LocalSession; 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 * this value, the legacy methods will be called. * - * @return + * @return the protocol version */ public int getProtocolVersion(); /** - * Returns the type ID to send to CUI in the selection event. - * @return + * Returns the type ID to send to CUI in the selection event. + * + * @return the type ID */ public String getTypeID(); @@ -60,7 +60,7 @@ public interface CUIRegion { * Returns the type ID to send to CUI in the selection * event if the CUI is in legacy mode. * - * @return + * @return the legacy type ID */ public String getLegacyTypeID(); } diff --git a/src/main/java/com/sk89q/worldedit/internal/cui/SelectionCylinderEvent.java b/src/main/java/com/sk89q/worldedit/internal/cui/SelectionCylinderEvent.java index 70dc22601..d23fd9a74 100644 --- a/src/main/java/com/sk89q/worldedit/internal/cui/SelectionCylinderEvent.java +++ b/src/main/java/com/sk89q/worldedit/internal/cui/SelectionCylinderEvent.java @@ -34,10 +34,12 @@ public class SelectionCylinderEvent implements CUIEvent { this.radius = radius; } + @Override public String getTypeId() { return "cyl"; } + @Override public String[] getParameters() { return new String[] { String.valueOf(pos.getBlockX()), diff --git a/src/main/java/com/sk89q/worldedit/internal/cui/SelectionEllipsoidPointEvent.java b/src/main/java/com/sk89q/worldedit/internal/cui/SelectionEllipsoidPointEvent.java index a4254cbd9..3e371b105 100644 --- a/src/main/java/com/sk89q/worldedit/internal/cui/SelectionEllipsoidPointEvent.java +++ b/src/main/java/com/sk89q/worldedit/internal/cui/SelectionEllipsoidPointEvent.java @@ -22,6 +22,7 @@ package com.sk89q.worldedit.internal.cui; import com.sk89q.worldedit.Vector; public class SelectionEllipsoidPointEvent implements CUIEvent { + protected final int id; protected final Vector pos; @@ -30,10 +31,12 @@ public class SelectionEllipsoidPointEvent implements CUIEvent { this.pos = pos; } + @Override public String getTypeId() { return "e"; } + @Override public String[] getParameters() { return new String[] { String.valueOf(id), @@ -42,4 +45,5 @@ public class SelectionEllipsoidPointEvent implements CUIEvent { String.valueOf(pos.getBlockZ()) }; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/cui/SelectionMinMaxEvent.java b/src/main/java/com/sk89q/worldedit/internal/cui/SelectionMinMaxEvent.java index 515b8970c..3eeaabb72 100644 --- a/src/main/java/com/sk89q/worldedit/internal/cui/SelectionMinMaxEvent.java +++ b/src/main/java/com/sk89q/worldedit/internal/cui/SelectionMinMaxEvent.java @@ -29,10 +29,12 @@ public class SelectionMinMaxEvent implements CUIEvent { this.max = max; } + @Override public String getTypeId() { return "mm"; } + @Override public String[] getParameters() { return new String[] { String.valueOf(min), diff --git a/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPoint2DEvent.java b/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPoint2DEvent.java index c5cd62307..dc4d0adaa 100644 --- a/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPoint2DEvent.java +++ b/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPoint2DEvent.java @@ -43,10 +43,12 @@ public class SelectionPoint2DEvent implements CUIEvent { this.area = area; } + @Override public String getTypeId() { return "p2"; } + @Override public String[] getParameters() { return new String[] { String.valueOf(id), diff --git a/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPointEvent.java b/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPointEvent.java index 0e2f80329..e719b1855 100644 --- a/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPointEvent.java +++ b/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPointEvent.java @@ -33,10 +33,12 @@ public class SelectionPointEvent implements CUIEvent { this.area = area; } + @Override public String getTypeId() { return "p"; } + @Override public String[] getParameters() { return new String[] { String.valueOf(id), diff --git a/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPolygonEvent.java b/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPolygonEvent.java index 6ff38bf5a..e6a0de312 100644 --- a/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPolygonEvent.java +++ b/src/main/java/com/sk89q/worldedit/internal/cui/SelectionPolygonEvent.java @@ -22,16 +22,19 @@ package com.sk89q.worldedit.internal.cui; public class SelectionPolygonEvent implements CUIEvent { + protected final int[] vertices; public SelectionPolygonEvent(int... vertices) { this.vertices = vertices; } + @Override public String getTypeId() { return "poly"; } + @Override public String[] getParameters() { final String[] ret = new String[vertices.length]; @@ -42,4 +45,5 @@ public class SelectionPolygonEvent implements CUIEvent { return ret; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/cui/SelectionShapeEvent.java b/src/main/java/com/sk89q/worldedit/internal/cui/SelectionShapeEvent.java index 478ab8483..c4bad96b4 100644 --- a/src/main/java/com/sk89q/worldedit/internal/cui/SelectionShapeEvent.java +++ b/src/main/java/com/sk89q/worldedit/internal/cui/SelectionShapeEvent.java @@ -27,10 +27,12 @@ public class SelectionShapeEvent implements CUIEvent { this.shapeName = shapeName; } + @Override public String getTypeId() { return "s"; } + @Override public String[] getParameters() { return new String[] { shapeName }; } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java b/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java index bb73a6b19..09583d5bb 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/Expression.java @@ -19,47 +19,57 @@ 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.tokens.Token; 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.EvaluationException; +import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment; import com.sk89q.worldedit.internal.expression.runtime.Functions; import com.sk89q.worldedit.internal.expression.runtime.RValue; import com.sk89q.worldedit.internal.expression.runtime.ReturnException; 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. * - * Supported operators: - * Logical: &&, ||, ! (unary) - * Bitwise: ~ (unary), >>, << - * Arithmetic: +, -, *, /, % (modulo), ^ (power), - (unary), --, ++ (prefix only) - * Comparison: <=, >=, >, <, ==, !=, ~= (near) + *

Supported operators:

* - * 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) + *
    + *
  • Logical: &&, ||, ! (unary)
  • + *
  • Bitwise: ~ (unary), >>, <<
  • + *
  • Arithmetic: +, -, *, /, % (modulo), ^ (power), - (unary), --, ++ (prefix only)
  • + *
  • Comparison: <=, >=, >, <, ==, !=, ~= (near)
  • + *
* - * Constants: e, pi + *

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)

* - * To compile an equation, run Expression.compile("expression here", "var1", "var2"...) - * 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() + *

Constants: e, pi

* - * Variables are also supported and can be set either by passing values to evaluate + *

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()}.

+ * + *

Variables are also supported and can be set either by passing values + * to {@link #evaluate(double...)}.

* * @author TomyLobo */ public class Expression { + private static final ThreadLocal> instance = new ThreadLocal>(); private final Map variables = new HashMap(); @@ -167,4 +177,5 @@ public class Expression { public void setEnvironment(ExpressionEnvironment environment) { this.environment = environment; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/ExpressionException.java b/src/main/java/com/sk89q/worldedit/internal/expression/ExpressionException.java index 2d2e8e0e8..2320ad99c 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/ExpressionException.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/ExpressionException.java @@ -20,12 +20,10 @@ package com.sk89q.worldedit.internal.expression; /** - * Thrown when there's a problem during any stage of the expression compilation or evaluation. - * - * @author TomyLobo + * Thrown when there's a problem during any stage of the expression + * compilation or evaluation. */ public class ExpressionException extends Exception { - private static final long serialVersionUID = 1L; private final int position; @@ -51,4 +49,5 @@ public class ExpressionException extends Exception { public int getPosition() { return position; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/Identifiable.java b/src/main/java/com/sk89q/worldedit/internal/expression/Identifiable.java index 0059b93a4..b23ba38c4 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/Identifiable.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/Identifiable.java @@ -21,10 +21,9 @@ package com.sk89q.worldedit.internal.expression; /** * A common superinterface for everything passed to parser processors. - * - * @author TomyLobo */ public interface Identifiable { + /** * 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 int getPosition(); + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/lexer/Lexer.java b/src/main/java/com/sk89q/worldedit/internal/expression/lexer/Lexer.java index a3edb02c6..8a3aa4d05 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/lexer/Lexer.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/lexer/Lexer.java @@ -19,6 +19,13 @@ 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.Arrays; import java.util.HashMap; @@ -29,16 +36,14 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import com.sk89q.worldedit.internal.expression.lexer.tokens.*; - /** * Processes a string into a list of tokens. * - * Tokens can be numbers, identifiers, operators and assorted other characters. - * - * @author TomyLobo + *

Tokens can be numbers, identifiers, operators and assorted other + * characters.

*/ public class Lexer { + private final String expression; private int position = 0; @@ -46,7 +51,7 @@ public class Lexer { this.expression = expression; } - public static final List tokenize(String expression) throws LexerException { + public static List tokenize(String expression) throws LexerException { 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 identifierPattern = Pattern.compile("^([A-Za-z][0-9A-Za-z_]*)"); - private final List tokenize() throws LexerException { + private List tokenize() throws LexerException { List tokens = new ArrayList(); do { @@ -139,7 +144,7 @@ public class Lexer { final Matcher numberMatcher = numberPattern.matcher(expression.substring(position)); if (numberMatcher.lookingAt()) { String numberPart = numberMatcher.group(1); - if (numberPart.length() > 0) { + if (!numberPart.isEmpty()) { try { tokens.add(new NumberToken(position, Double.parseDouble(numberPart))); } catch (NumberFormatException e) { @@ -154,7 +159,7 @@ public class Lexer { final Matcher identifierMatcher = identifierPattern.matcher(expression.substring(position)); if (identifierMatcher.lookingAt()) { String identifierPart = identifierMatcher.group(1); - if (identifierPart.length() > 0) { + if (!identifierPart.isEmpty()) { if (keywords.contains(identifierPart)) { tokens.add(new KeywordToken(position, identifierPart)); } else { @@ -176,7 +181,7 @@ public class Lexer { return expression.charAt(position); } - private final void skipWhitespace() { + private void skipWhitespace() { while (position < expression.length() && Character.isWhitespace(peek())) { ++position; } @@ -230,4 +235,5 @@ public class Lexer { return new OperatorToken(startPosition, tokenName); } } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/lexer/LexerException.java b/src/main/java/com/sk89q/worldedit/internal/expression/lexer/LexerException.java index ff854a368..3e08b2732 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/lexer/LexerException.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/lexer/LexerException.java @@ -23,11 +23,8 @@ import com.sk89q.worldedit.internal.expression.ExpressionException; /** * Thrown when the lexer encounters a problem. - * - * @author TomyLobo */ public class LexerException extends ExpressionException { - private static final long serialVersionUID = 1L; public LexerException(int position) { super(position, getPrefix(position)); @@ -48,4 +45,5 @@ public class LexerException extends ExpressionException { private static String getPrefix(int position) { return position < 0 ? "Lexer error" : ("Lexer error at " + (position + 1)); } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/CharacterToken.java b/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/CharacterToken.java index bc565e50b..51bf757da 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/CharacterToken.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/CharacterToken.java @@ -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. - * - * @author TomyLobo */ public class CharacterToken extends Token { + public final char character; public CharacterToken(int position, char character) { @@ -41,4 +40,5 @@ public class CharacterToken extends Token { public String toString() { return "CharacterToken(" + character + ")"; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/IdentifierToken.java b/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/IdentifierToken.java index 346c1b619..4a840f754 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/IdentifierToken.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/IdentifierToken.java @@ -20,11 +20,10 @@ package com.sk89q.worldedit.internal.expression.lexer.tokens; /** - * An identifier - * - * @author TomyLobo + * An identifier. */ public class IdentifierToken extends Token { + public final String value; public IdentifierToken(int position, String value) { @@ -41,4 +40,5 @@ public class IdentifierToken extends Token { public String toString() { return "IdentifierToken(" + value + ")"; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/KeywordToken.java b/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/KeywordToken.java index 841c3e99a..208e7280c 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/KeywordToken.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/KeywordToken.java @@ -20,11 +20,10 @@ package com.sk89q.worldedit.internal.expression.lexer.tokens; /** - * A keyword - * - * @author TomyLobo + * A keyword. */ public class KeywordToken extends Token { + public final String value; public KeywordToken(int position, String value) { @@ -41,4 +40,5 @@ public class KeywordToken extends Token { public String toString() { return "KeywordToken(" + value + ")"; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/NumberToken.java b/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/NumberToken.java index 5d823d6d8..44cc70665 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/NumberToken.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/NumberToken.java @@ -20,11 +20,10 @@ package com.sk89q.worldedit.internal.expression.lexer.tokens; /** - * A number - * - * @author TomyLobo + * A number. */ public class NumberToken extends Token { + public final double value; public NumberToken(int position, double value) { @@ -41,4 +40,5 @@ public class NumberToken extends Token { public String toString() { return "NumberToken(" + value + ")"; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/OperatorToken.java b/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/OperatorToken.java index fe49e4542..c4b70e475 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/OperatorToken.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/OperatorToken.java @@ -21,10 +21,9 @@ package com.sk89q.worldedit.internal.expression.lexer.tokens; /** * A unary or binary operator. - * - * @author TomyLobo */ public class OperatorToken extends Token { + public final String operator; public OperatorToken(int position, String operator) { @@ -41,4 +40,5 @@ public class OperatorToken extends Token { public String toString() { return "OperatorToken(" + operator + ")"; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/Token.java b/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/Token.java index a3dddc6d4..c6427f0c5 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/Token.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/lexer/tokens/Token.java @@ -23,10 +23,9 @@ import com.sk89q.worldedit.internal.expression.Identifiable; /** * A token. The lexer generates these to make the parser's job easier. - * - * @author TomyLobo */ public abstract class Token implements Identifiable { + private final int position; public Token(int position) { @@ -37,4 +36,5 @@ public abstract class Token implements Identifiable { public int getPosition() { return position; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/parser/Parser.java b/src/main/java/com/sk89q/worldedit/internal/expression/parser/Parser.java index a234a3aa4..3d6b7c30f 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/parser/Parser.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/parser/Parser.java @@ -19,9 +19,6 @@ 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.Identifiable; 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.While; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; + /** * Processes a list of tokens into an executable tree. * - * Tokens can be numbers, identifiers, operators and assorted other characters. - * - * @author TomyLobo + *

Tokens can be numbers, identifiers, operators and assorted other characters.

*/ public class Parser { private final class NullToken extends Token { @@ -56,6 +55,7 @@ public class Parser { super(position); } + @Override public char id() { return '\0'; } @@ -75,7 +75,7 @@ public class Parser { this.expression = expression; } - public static final RValue parse(List tokens, Expression expression) throws ParserException { + public static RValue parse(List tokens, Expression expression) throws ParserException { 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 halfProcessed = new LinkedList(); // 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('('); final RValue ret = parseExpression(false); @@ -435,10 +435,8 @@ public class Parser { private boolean hasKeyword(String keyword) { final Token next = peek(); - if (!(next instanceof KeywordToken)) { - return false; - } - return ((KeywordToken) next).value.equals(keyword); + + return next instanceof KeywordToken && ((KeywordToken) next).value.equals(keyword); } private void assertCharacter(char character) throws ParserException { diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserException.java b/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserException.java index 3d9d18bea..9a04fc914 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserException.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserException.java @@ -23,11 +23,8 @@ import com.sk89q.worldedit.internal.expression.ExpressionException; /** * Thrown when the parser encounters a problem. - * - * @author TomyLobo */ public class ParserException extends ExpressionException { - private static final long serialVersionUID = 1L; public ParserException(int position) { super(position, getPrefix(position)); @@ -48,4 +45,5 @@ public class ParserException extends ExpressionException { private static String getPrefix(int position) { return position < 0 ? "Parser error" : ("Parser error at " + (position + 1)); } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserProcessors.java b/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserProcessors.java index a909e0ee0..0989701b1 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserProcessors.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserProcessors.java @@ -30,10 +30,9 @@ import java.util.*; /** * Helper classfor Parser. Contains processors for statements and operators. - * - * @author TomyLobo */ public final class ParserProcessors { + private static final Map unaryOpMap = new HashMap(); private static final Map[] binaryOpMapsLA; @@ -347,4 +346,5 @@ public final class ParserProcessors { } return ret; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/parser/PseudoToken.java b/src/main/java/com/sk89q/worldedit/internal/expression/parser/PseudoToken.java index 03275dde3..cee19e8b3 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/parser/PseudoToken.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/parser/PseudoToken.java @@ -23,10 +23,9 @@ import com.sk89q.worldedit.internal.expression.Identifiable; /** * A pseudo-token, inserted by the parser instead of the lexer. - * - * @author TomyLobo */ public abstract class PseudoToken implements Identifiable { + private final int position; public PseudoToken(int position) { @@ -40,4 +39,5 @@ public abstract class PseudoToken implements Identifiable { public int getPosition() { return position; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/parser/UnaryOperator.java b/src/main/java/com/sk89q/worldedit/internal/expression/parser/UnaryOperator.java index 88d009ab1..d6a54b321 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/parser/UnaryOperator.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/parser/UnaryOperator.java @@ -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. - * - * @author TomyLobo */ public class UnaryOperator extends PseudoToken { + final String operator; public UnaryOperator(OperatorToken operatorToken) { @@ -47,4 +46,5 @@ public class UnaryOperator extends PseudoToken { public String toString() { return "UnaryOperator(" + operator + ")"; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/parser/UnboundVariable.java b/src/main/java/com/sk89q/worldedit/internal/expression/parser/UnboundVariable.java index 32a25e14e..a128bc866 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/parser/UnboundVariable.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/parser/UnboundVariable.java @@ -25,17 +25,16 @@ import com.sk89q.worldedit.internal.expression.runtime.LValue; import com.sk89q.worldedit.internal.expression.runtime.RValue; public class UnboundVariable extends PseudoToken implements LValue { + public final String name; public UnboundVariable(int position, String name) { super(position); this.name = name; - // TODO Auto-generated constructor stub } @Override public char id() { - // TODO Auto-generated method stub return 'V'; } @@ -77,4 +76,5 @@ public class UnboundVariable extends PseudoToken implements LValue { return (LValue) variable; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Break.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Break.java index e53f6f0b2..00bcf9936 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Break.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Break.java @@ -21,10 +21,9 @@ package com.sk89q.worldedit.internal.expression.runtime; /** * A break or continue statement. - * - * @author TomyLobo */ public class Break extends Node { + boolean doContinue; public Break(int position, boolean doContinue) { @@ -47,4 +46,5 @@ public class Break extends Node { public String toString() { return doContinue ? "continue" : "break"; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/BreakException.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/BreakException.java index 311be4120..a3d384117 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/BreakException.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/BreakException.java @@ -22,11 +22,8 @@ package com.sk89q.worldedit.internal.expression.runtime; /** * Thrown when a break or continue is encountered. * Loop constructs catch this exception. - * - * @author TomyLobo */ public class BreakException extends EvaluationException { - private static final long serialVersionUID = 1L; final boolean doContinue; @@ -35,4 +32,5 @@ public class BreakException extends EvaluationException { this.doContinue = doContinue; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Conditional.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Conditional.java index 361eb5f2c..4579004af 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Conditional.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Conditional.java @@ -24,10 +24,9 @@ import com.sk89q.worldedit.internal.expression.parser.ParserException; /** * An if/else statement or a ternary operator. - * - * @author TomyLobo */ public class Conditional extends Node { + private RValue condition; private RValue truePart; private RValue falsePart; @@ -90,4 +89,5 @@ public class Conditional extends Node { return this; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Constant.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Constant.java index aedb47263..5bdab9e1c 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Constant.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Constant.java @@ -21,10 +21,9 @@ package com.sk89q.worldedit.internal.expression.runtime; /** * A constant. - * - * @author TomyLobo */ public final class Constant extends Node { + private final double value; public Constant(int position, double value) { @@ -46,4 +45,5 @@ public final class Constant extends Node { public char id() { return 'c'; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/EvaluationException.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/EvaluationException.java index 356729d89..fc34a0ffa 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/EvaluationException.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/EvaluationException.java @@ -23,11 +23,8 @@ import com.sk89q.worldedit.internal.expression.ExpressionException; /** * Thrown when there's a problem during expression evaluation. - * - * @author TomyLobo */ public class EvaluationException extends ExpressionException { - private static final long serialVersionUID = 1L; public EvaluationException(int position) { super(position, getPrefix(position)); @@ -48,4 +45,5 @@ public class EvaluationException extends ExpressionException { private static String getPrefix(int position) { return position < 0 ? "Evaluation error" : ("Evaluation error at " + (position + 1)); } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/ExpressionEnvironment.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/ExpressionEnvironment.java index 65689d5c2..1a9a57d4a 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/ExpressionEnvironment.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/ExpressionEnvironment.java @@ -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. */ public interface ExpressionEnvironment { + int getBlockType(double x, double y, double z); int getBlockData(double x, double y, double z); int getBlockTypeAbs(double x, double y, double z); int getBlockDataAbs(double x, double y, double z); int getBlockTypeRel(double x, double y, double z); int getBlockDataRel(double x, double y, double z); + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/For.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/For.java index 0fd388975..868c83f96 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/For.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/For.java @@ -24,10 +24,9 @@ import com.sk89q.worldedit.internal.expression.parser.ParserException; /** * A Java/C-style for loop. - * - * @author TomyLobo */ public class For extends Node { + RValue init; RValue condition; RValue increment; @@ -101,4 +100,5 @@ public class For extends Node { return this; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Function.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Function.java index 9d644a8c0..23f96f95c 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Function.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Function.java @@ -19,20 +19,19 @@ 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.RetentionPolicy; import java.lang.reflect.InvocationTargetException; 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) - * - * @author TomyLobo + * Wrapper for a Java method and its arguments (other Nodes). */ public class Function extends Node { + /** * Add this annotation on functions that don't always return the same value * for the same inputs and on functions with side-effects. @@ -120,4 +119,5 @@ public class Function extends Node { return this; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Functions.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Functions.java index 493eef690..636bcd8d0 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Functions.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Functions.java @@ -27,17 +27,16 @@ import java.util.*; /** * Contains all functions that can be used in expressions. - * - * @author TomyLobo */ @SuppressWarnings("UnusedDeclaration") public final class Functions { + private static class Overload { private final Method method; private final int mask; private final boolean isSetter; - public Overload(Method method) throws IllegalArgumentException { + private Overload(Method method) throws IllegalArgumentException { this.method = method; boolean isSetter = false; @@ -436,4 +435,5 @@ public final class Functions { return queryInternal(type, data, typeId, dataValue); } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/LValue.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/LValue.java index 013f362fe..a0f71cadf 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/LValue.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/LValue.java @@ -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. - * - * @author TomyLobo */ public interface LValue extends RValue { + public double assign(double value) throws EvaluationException; + @Override public LValue optimize() throws EvaluationException; + @Override public LValue bindVariables(Expression expression, boolean preferLValue) throws ParserException; + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/LValueFunction.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/LValueFunction.java index 008bbd053..de145514a 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/LValueFunction.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/LValueFunction.java @@ -19,17 +19,17 @@ 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.parser.ParserException; +import java.lang.reflect.Method; + /** - * Wrapper for a pair of Java methods and their arguments (other Nodes), forming an LValue - * - * @author TomyLobo + * Wrapper for a pair of Java methods and their arguments (other Nodes), + * forming an LValue. */ public class LValueFunction extends Function implements LValue { + private final Object[] setterArgs; private final Method setter; @@ -73,4 +73,5 @@ public class LValueFunction extends Function implements LValue { return this; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Node.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Node.java index b12a588a7..1c1836c4d 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Node.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Node.java @@ -24,10 +24,9 @@ import com.sk89q.worldedit.internal.expression.parser.ParserException; /** * A node in the execution tree of an expression. - * - * @author TomyLobo */ public abstract class Node implements RValue { + private final int position; public Node(int position) { @@ -37,6 +36,7 @@ public abstract class Node implements RValue { @Override public abstract String toString(); + @Override public RValue optimize() throws EvaluationException { return this; } @@ -50,4 +50,5 @@ public abstract class Node implements RValue { public RValue bindVariables(Expression expression, boolean preferLValue) throws ParserException { return this; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Operators.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Operators.java index 8f69e8d00..cb4f9d78b 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Operators.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Operators.java @@ -21,11 +21,10 @@ package com.sk89q.worldedit.internal.expression.runtime; /** * Contains all unary and binary operators. - * - * @author TomyLobo */ @SuppressWarnings("UnusedDeclaration") public final class Operators { + private Operators() { } @@ -225,4 +224,5 @@ public final class Operators { final long longDiff = Math.abs(aLong - bLong); return longDiff <= maxUlps; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/RValue.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/RValue.java index 872ae45a2..c47c5c98f 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/RValue.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/RValue.java @@ -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. - * - * @author TomyLobo */ public interface RValue extends Identifiable { + public double getValue() throws EvaluationException; public RValue optimize() throws EvaluationException; public RValue bindVariables(Expression expression, boolean preferLValue) throws ParserException; + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Return.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Return.java index 6434b96b4..455a09a3b 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Return.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Return.java @@ -24,10 +24,9 @@ import com.sk89q.worldedit.internal.expression.parser.ParserException; /** * A return statement. - * - * @author TomyLobo */ public class Return extends Node { + RValue value; public Return(int position, RValue value) { @@ -57,4 +56,5 @@ public class Return extends Node { return this; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/ReturnException.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/ReturnException.java index 7a13dcda2..84b60021b 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/ReturnException.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/ReturnException.java @@ -21,12 +21,10 @@ package com.sk89q.worldedit.internal.expression.runtime; /** * Thrown when a return statement is encountered. - * {@link com.sk89q.worldedit.internal.expression.Expression#evaluate} catches this exception and returns the enclosed value. - * - * @author TomyLobo + * {@link com.sk89q.worldedit.internal.expression.Expression#evaluate} + * catches this exception and returns the enclosed value. */ public class ReturnException extends EvaluationException { - private static final long serialVersionUID = 1L; final double value; @@ -39,4 +37,5 @@ public class ReturnException extends EvaluationException { public double getValue() { return value; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Sequence.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Sequence.java index ffb17b501..0cdd92c51 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Sequence.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Sequence.java @@ -19,18 +19,19 @@ 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.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. - * - * @author TomyLobo + * A sequence of operations, usually separated by semicolons in the + * input stream. */ public class Sequence extends Node { + final RValue[] sequence; public Sequence(int position, RValue... sequence) { @@ -77,9 +78,7 @@ public class Sequence extends Node { droppedLast = null; invokable = invokable.optimize(); if (invokable instanceof Sequence) { - for (RValue subInvokable : ((Sequence) invokable).sequence) { - newSequence.add(subInvokable); - } + Collections.addAll(newSequence, ((Sequence) invokable).sequence); } else if (invokable instanceof Constant) { droppedLast = invokable; } else { @@ -106,4 +105,5 @@ public class Sequence extends Node { return this; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/SimpleFor.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/SimpleFor.java index b7a5939cd..5de499ec7 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/SimpleFor.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/SimpleFor.java @@ -24,10 +24,9 @@ import com.sk89q.worldedit.internal.expression.parser.ParserException; /** * A simple-style for loop. - * - * @author TomyLobo */ public class SimpleFor extends Node { + LValue counter; RValue first; RValue last; @@ -98,4 +97,5 @@ public class SimpleFor extends Node { return this; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Switch.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Switch.java index f56c053f8..80754f8a9 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Switch.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Switch.java @@ -19,6 +19,9 @@ 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.Collections; import java.util.HashMap; @@ -26,15 +29,11 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import com.sk89q.worldedit.internal.expression.Expression; -import com.sk89q.worldedit.internal.expression.parser.ParserException; - /** * A switch/case construct. - * - * @author TomyLobo */ public class Switch extends Node implements RValue { + private RValue parameter; private final Map valueMap; private final RValue[] caseStatements; @@ -205,4 +204,5 @@ public class Switch extends Node implements RValue { return this; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Variable.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Variable.java index 86306b4c5..01fe6764f 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Variable.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Variable.java @@ -24,10 +24,9 @@ import com.sk89q.worldedit.internal.expression.parser.ParserException; /** * A variable. - * - * @author TomyLobo */ public final class Variable extends Node implements LValue { + public 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 { return this; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/While.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/While.java index bd24e0c77..4c277058a 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/While.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/While.java @@ -24,10 +24,9 @@ import com.sk89q.worldedit.internal.expression.parser.ParserException; /** * A while loop. - * - * @author TomyLobo */ public class While extends Node { + RValue condition; RValue body; boolean footChecked; @@ -124,4 +123,5 @@ public class While extends Node { return this; } + } diff --git a/src/main/java/com/sk89q/worldedit/internal/util/DocumentationPrinter.java b/src/main/java/com/sk89q/worldedit/internal/util/DocumentationPrinter.java index 26ba92d87..d4e38e34d 100644 --- a/src/main/java/com/sk89q/worldedit/internal/util/DocumentationPrinter.java +++ b/src/main/java/com/sk89q/worldedit/internal/util/DocumentationPrinter.java @@ -33,7 +33,9 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; +@SuppressWarnings("UseOfSystemOutOrSystemErr") public final class DocumentationPrinter { + private DocumentationPrinter() { } @@ -191,7 +193,6 @@ public final class DocumentationPrinter { } private static void writeBukkitYAML(PrintStream stream) { - stream.println("name: WorldEdit"); stream.println("main: com.sk89q.worldedit.bukkit.WorldEditPlugin"); 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("# for how WorldEdit permissions actually work."); } + } diff --git a/src/main/java/com/sk89q/worldedit/math/MathUtils.java b/src/main/java/com/sk89q/worldedit/math/MathUtils.java index 568019499..65a72a72c 100644 --- a/src/main/java/com/sk89q/worldedit/math/MathUtils.java +++ b/src/main/java/com/sk89q/worldedit/math/MathUtils.java @@ -26,10 +26,10 @@ public final class MathUtils { /** * Safe minimum, such that 1 / SAFE_MIN does not overflow. - *

- * In IEEE 754 arithmetic, this is also the smallest normalized number + * + *

In IEEE 754 arithmetic, this is also the smallest normalized number * 2-1022. The value of this constant is from Apache Commons - * Math 2.2. + * Math 2.2.

*/ public static final double SAFE_MIN = 0x1.0p-1022; diff --git a/src/main/java/com/sk89q/worldedit/math/convolution/GaussianKernel.java b/src/main/java/com/sk89q/worldedit/math/convolution/GaussianKernel.java index 1bc86cfe3..bc8b647f7 100644 --- a/src/main/java/com/sk89q/worldedit/math/convolution/GaussianKernel.java +++ b/src/main/java/com/sk89q/worldedit/math/convolution/GaussianKernel.java @@ -22,11 +22,8 @@ package com.sk89q.worldedit.math.convolution; import java.awt.image.Kernel; /** - * A Gaussian Kernel generator (2D bellcurve) - * - * @author Grum + * A Gaussian Kernel generator (2D bellcurve). */ - 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 sigma controls 'flatness' */ - public GaussianKernel(int radius, double sigma) { super(radius * 2 + 1, radius * 2 + 1, createKernel(radius, sigma)); } @@ -54,4 +50,5 @@ public class GaussianKernel extends Kernel { return data; } + } diff --git a/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java b/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java index 3d3768c85..44f750760 100644 --- a/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java +++ b/src/main/java/com/sk89q/worldedit/math/convolution/HeightMap.java @@ -26,14 +26,15 @@ import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BlockID; import com.sk89q.worldedit.regions.Region; -/** - * Allows applications of Kernels onto the region's heightmap. - * Currently only used for smoothing (with a GaussianKernel). - * - * @author Grum - */ +import static com.google.common.base.Preconditions.checkNotNull; +/** + * Allows applications of Kernels onto the region's height map. + * + *

Currently only used for smoothing (with a GaussianKernel)

. + */ public class HeightMap { + private int[] data; private int width; private int height; @@ -44,8 +45,8 @@ public class HeightMap { /** * Constructs the HeightMap * - * @param session - * @param region + * @param session an edit session + * @param region the region */ public HeightMap(EditSession session, Region region) { this(session, region, false); @@ -53,12 +54,15 @@ public class HeightMap { /** * Constructs the HeightMap - * - * @param session - * @param region + * + * @param session an edit session + * @param region the region * @param naturalOnly ignore non-natural blocks */ public HeightMap(EditSession session, Region region, boolean naturalOnly) { + checkNotNull(session); + checkNotNull(region); + this.session = session; this.region = region; @@ -82,13 +86,15 @@ public class HeightMap { /** * Apply the filter 'iterations' amount times. * - * @param filter - * @param iterations + * @param filter the filter + * @param iterations the number of iterations * @return number of blocks affected * @throws MaxChangedBlocksException */ public int applyFilter(HeightMapFilter filter, int iterations) throws MaxChangedBlocksException { + checkNotNull(filter); + int[] newData = new int[data.length]; System.arraycopy(data, 0, newData, 0, data.length); @@ -102,12 +108,14 @@ public class HeightMap { /** * Apply a raw heightmap to the region * - * @param data + * @param data the data * @return number of blocks affected * @throws MaxChangedBlocksException */ public int apply(int[] data) throws MaxChangedBlocksException { + checkNotNull(data); + Vector minY = region.getMinimumPoint(); int originX = minY.getBlockX(); int originY = minY.getBlockY(); @@ -178,4 +186,5 @@ public class HeightMap { return blocksChanged; } + } diff --git a/src/main/java/com/sk89q/worldedit/math/convolution/HeightMapFilter.java b/src/main/java/com/sk89q/worldedit/math/convolution/HeightMapFilter.java index 80de5f95a..93f4f7c06 100644 --- a/src/main/java/com/sk89q/worldedit/math/convolution/HeightMapFilter.java +++ b/src/main/java/com/sk89q/worldedit/math/convolution/HeightMapFilter.java @@ -21,33 +21,36 @@ package com.sk89q.worldedit.math.convolution; import java.awt.image.Kernel; -/** - * Allows applications of Kernels onto the region's heightmap. - * Only used for smoothing (with a GaussianKernel). - * - * @author Grum - */ +import static com.google.common.base.Preconditions.checkNotNull; +/** + * Allows applications of Kernels onto the region's height map. + * + *

Only used for smoothing (with a GaussianKernel).

+ */ public class HeightMapFilter { + private Kernel kernel; /** * Construct the HeightMapFilter object. * - * @param kernel + * @param kernel the kernel */ public HeightMapFilter(Kernel kernel) { + checkNotNull(kernel); this.kernel = kernel; } /** * Construct the HeightMapFilter object. * - * @param kernelWidth - * @param kernelHeight - * @param kernelData + * @param kernelWidth the width + * @param kernelHeight the height + * @param kernelData the data */ public HeightMapFilter(int kernelWidth, int kernelHeight, float[] kernelData) { + checkNotNull(kernelData); this.kernel = new Kernel(kernelWidth, kernelHeight, kernelData); } @@ -61,21 +64,26 @@ public class HeightMapFilter { /** * Set Kernel * - * @param kernel + * @param kernel the kernel */ public void setKernel(Kernel kernel) { + checkNotNull(kernel); + this.kernel = kernel; } /** * Filter with a 2D kernel - * - * @param inData - * @param width - * @param height - * @return the modified heightmap + * + * @param inData the data + * @param width the width + * @param height the height + * + * @return the modified height map */ public int[] filter(int[] inData, int width, int height) { + checkNotNull(inData); + int index = 0; float[] matrix = kernel.getKernelData(null); int[] outData = new int[inData.length]; @@ -117,4 +125,5 @@ public class HeightMapFilter { } return outData; } + } diff --git a/src/main/java/com/sk89q/worldedit/math/convolution/LinearKernel.java b/src/main/java/com/sk89q/worldedit/math/convolution/LinearKernel.java index 3a65ffeb5..3e31c199e 100644 --- a/src/main/java/com/sk89q/worldedit/math/convolution/LinearKernel.java +++ b/src/main/java/com/sk89q/worldedit/math/convolution/LinearKernel.java @@ -23,10 +23,7 @@ import java.awt.image.Kernel; /** * A linear Kernel generator (all cells weight the same) - * - * @author Grum */ - public class LinearKernel extends Kernel { public LinearKernel(int radius) { @@ -37,8 +34,9 @@ public class LinearKernel extends Kernel { int diameter = radius * 2 + 1; float[] data = new float[diameter * diameter]; - for (int i = 0; i < data.length; data[i++] = 1.0f / data.length) ; + for (int i = 0; i < data.length; data[i++] = 1.0f / data.length); return data; } + } diff --git a/src/main/java/com/sk89q/worldedit/math/interpolation/Interpolation.java b/src/main/java/com/sk89q/worldedit/math/interpolation/Interpolation.java index 0652d598a..89f0a8012 100644 --- a/src/main/java/com/sk89q/worldedit/math/interpolation/Interpolation.java +++ b/src/main/java/com/sk89q/worldedit/math/interpolation/Interpolation.java @@ -21,38 +21,36 @@ package com.sk89q.worldedit.math.interpolation; -import java.util.List; - import com.sk89q.worldedit.Vector; +import java.util.List; + /** * Represents an arbitrary function in ℝ → ℝ3 - * - * @author TomyLobo - * */ public interface Interpolation { + /** * Sets nodes to be used by subsequent calls to * {@link #getPosition(double)} and the other methods. * - * @param nodes + * @param nodes the nodes */ public void setNodes(List nodes); /** * Gets the result of f(position) * - * @param position - * @return + * @param position the position to interpolate + * @return the result */ public Vector getPosition(double position); /** * Gets the result of f'(position). * - * @param position - * @return + * @param position the position to interpolate + * @return the result */ public Vector get1stDerivative(double position); @@ -63,9 +61,16 @@ public interface Interpolation { * * @param positionA lower limit * @param positionB upper limit - * @return + * @return the arc length */ double arcLength(double positionA, double positionB); + /** + * Get the segment position. + * + * @param position the position + * @return the segment position + */ int getSegment(double position); + } diff --git a/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java b/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java index 20d60bc5f..f953d3de6 100644 --- a/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java +++ b/src/main/java/com/sk89q/worldedit/math/interpolation/KochanekBartelsInterpolation.java @@ -21,21 +21,21 @@ package com.sk89q.worldedit.math.interpolation; +import com.sk89q.worldedit.Vector; + import java.util.Collections; import java.util.List; -import com.sk89q.worldedit.Vector; +import static com.google.common.base.Preconditions.checkNotNull; /** - * Kochanek-Bartels interpolation.
- * Continuous in the 2nd derivative.
- * Supports {@link Node#tension tension}, {@link Node#bias bias} and - * {@link Node#continuity continuity} parameters per {@link Node} - * - * @author TomyLobo + * A Kochanek-Bartels interpolation; continuous in the 2nd derivative. * + *

Supports {@link Node#tension tension}, {@link Node#bias bias} and + * {@link Node#continuity continuity} parameters per {@link Node}.

*/ public class KochanekBartelsInterpolation implements Interpolation { + private List nodes; private Vector[] coeffA; private Vector[] coeffB; @@ -49,6 +49,8 @@ public class KochanekBartelsInterpolation implements Interpolation { @Override public void setNodes(List nodes) { + checkNotNull(nodes); + this.nodes = nodes; recalc(); } @@ -197,12 +199,6 @@ public class KochanekBartelsInterpolation implements Interpolation { /** * Assumes a < b - * - * @param indexLeft - * @param remainderLeft - * @param indexRight - * @param remainderRight - * @return */ private double arcLengthRecursive(int indexLeft, double remainderLeft, int indexRight, double remainderRight) { switch (indexRight - indexLeft) { @@ -250,7 +246,7 @@ public class KochanekBartelsInterpolation implements Interpolation { position *= scaling; - final int index = (int) Math.floor(position); - return index; + return (int) Math.floor(position); } + } diff --git a/src/main/java/com/sk89q/worldedit/math/interpolation/LinearInterpolation.java b/src/main/java/com/sk89q/worldedit/math/interpolation/LinearInterpolation.java index 75e7d8739..00fa7c12f 100644 --- a/src/main/java/com/sk89q/worldedit/math/interpolation/LinearInterpolation.java +++ b/src/main/java/com/sk89q/worldedit/math/interpolation/LinearInterpolation.java @@ -21,21 +21,23 @@ package com.sk89q.worldedit.math.interpolation; +import com.sk89q.worldedit.Vector; + import java.util.List; -import com.sk89q.worldedit.Vector; +import static com.google.common.base.Preconditions.checkNotNull; /** * Simple linear interpolation. Mainly used for testing. - * - * @author TomyLobo - * */ public class LinearInterpolation implements Interpolation { + private List nodes; @Override public void setNodes(List nodes) { + checkNotNull(nodes); + this.nodes = nodes; } @@ -112,13 +114,7 @@ public class LinearInterpolation implements Interpolation { } /** - * Assumes a < b - * - * @param indexA - * @param remainderA - * @param indexB - * @param remainderB - * @return + * Assumes a < b. */ private double arcLengthRecursive(int indexA, double remainderA, int indexB, double remainderB) { switch (indexB - indexA) { @@ -155,7 +151,7 @@ public class LinearInterpolation implements Interpolation { position *= nodes.size() - 1; - final int index = (int) Math.floor(position); - return index; + return (int) Math.floor(position); } + } diff --git a/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java b/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java index ce76e0c28..ce604824c 100644 --- a/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java +++ b/src/main/java/com/sk89q/worldedit/math/interpolation/Node.java @@ -24,14 +24,13 @@ package com.sk89q.worldedit.math.interpolation; import com.sk89q.worldedit.Vector; /** - * Represents a node for interpolation.
- * The {@link #tension}, {@link #bias} and {@link #continuity} fields - * are parameters for the Kochanek-Bartels interpolation algorithm. - * - * @author TomyLobo + * Represents a node for interpolation. * + *

The {@link #tension}, {@link #bias} and {@link #continuity} fields + * are parameters for the Kochanek-Bartels interpolation algorithm.

*/ public class Node { + private Vector position; private double tension; @@ -86,4 +85,5 @@ public class Node { public void setContinuity(double continuity) { this.continuity = continuity; } + } diff --git a/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java b/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java index 4d5695bda..8a0df7b9f 100644 --- a/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java +++ b/src/main/java/com/sk89q/worldedit/math/interpolation/ReparametrisingInterpolation.java @@ -21,31 +21,39 @@ package com.sk89q.worldedit.math.interpolation; +import com.sk89q.worldedit.Vector; + import java.util.List; import java.util.Map.Entry; import java.util.TreeMap; +import java.util.logging.Logger; -import com.sk89q.worldedit.Vector; +import static com.google.common.base.Preconditions.checkNotNull; /** - * Reparametrises another interpolation function by arc length.
- * This is done so entities travel at roughly the same speed across - * the whole route. - * - * @author TomyLobo + * Reparametrises another interpolation function by arc length. * + *

This is done so entities travel at roughly the same speed across + * the whole route.

*/ public class ReparametrisingInterpolation implements Interpolation { + + private static final Logger log = Logger.getLogger(ReparametrisingInterpolation.class.getCanonicalName()); + private final Interpolation baseInterpolation; private double totalArcLength; private final TreeMap cache = new TreeMap(); public ReparametrisingInterpolation(Interpolation baseInterpolation) { + checkNotNull(baseInterpolation); + this.baseInterpolation = baseInterpolation; } @Override public void setNodes(List nodes) { + checkNotNull(nodes); + baseInterpolation.setNodes(nodes); cache.clear(); cache.put(0.0, 0.0); @@ -94,7 +102,7 @@ public class ReparametrisingInterpolation implements Interpolation { Entry ceilingEntry = cache.ceilingEntry(arc); if (ceilingEntry == null) { - System.out.println("Error in arcToParameter: no ceiling entry for "+arc+" found!"); + log.warning("Error in arcToParameter: no ceiling entry for " + arc + " found!"); return 0; } final double rightArc = ceilingEntry.getKey(); @@ -148,4 +156,5 @@ public class ReparametrisingInterpolation implements Interpolation { return baseInterpolation.getSegment(arcToParameter(position)); } + } diff --git a/src/main/java/com/sk89q/worldedit/math/noise/RandomNoise.java b/src/main/java/com/sk89q/worldedit/math/noise/RandomNoise.java index 4765328d5..6daed2841 100644 --- a/src/main/java/com/sk89q/worldedit/math/noise/RandomNoise.java +++ b/src/main/java/com/sk89q/worldedit/math/noise/RandomNoise.java @@ -33,7 +33,7 @@ public class RandomNoise implements NoiseGenerator { private final Random random; /** - * Create a new noise generator using the given Random. + * Create a new noise generator using the given {@code Random}. * * @param random the random instance */ @@ -42,7 +42,7 @@ public class RandomNoise implements NoiseGenerator { } /** - * Create a new noise generator with a newly constructed Random + * Create a new noise generator with a newly constructed {@code Random} * instance. */ public RandomNoise() { diff --git a/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java b/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java index 3540daa77..3d5fb7186 100644 --- a/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java +++ b/src/main/java/com/sk89q/worldedit/math/transform/AffineTransform.java @@ -23,27 +23,27 @@ import com.sk89q.worldedit.Vector; /** * An affine transform. - *

- * This class is from the + * + *

This class is from the * getChunks() { final Set chunks = new HashSet(); @@ -241,11 +205,7 @@ public class EllipsoidRegion extends AbstractRegion { return chunks; } - /** - * Returns true based on whether the region contains the point, - * - * @param pt - */ + @Override public boolean contains(Vector pt) { return pt.subtract(center).divide(radius).lengthSq() <= 1; } @@ -265,7 +225,9 @@ public class EllipsoidRegion extends AbstractRegion { setRadius(Vector.getMaximum(minRadius, getRadius())); } + @Override public EllipsoidRegion clone() { return (EllipsoidRegion) super.clone(); } + } diff --git a/src/main/java/com/sk89q/worldedit/regions/FlatRegion.java b/src/main/java/com/sk89q/worldedit/regions/FlatRegion.java index 3d8fd8014..39fc6dcf0 100644 --- a/src/main/java/com/sk89q/worldedit/regions/FlatRegion.java +++ b/src/main/java/com/sk89q/worldedit/regions/FlatRegion.java @@ -26,16 +26,21 @@ public interface FlatRegion extends Region { /** * Gets the minimum Y value * - * @return + * @return the Y value */ public int getMinimumY(); /** * Gets the maximum Y value * - * @return + * @return the Y value */ public int getMaximumY(); + /** + * Get this region as an iterable flat region. + * + * @return a flat region iterable + */ public Iterable asFlatRegion(); } diff --git a/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java b/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java index 80d4d3982..7cfeff11e 100644 --- a/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java +++ b/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegion3DIterator.java @@ -19,13 +19,15 @@ package com.sk89q.worldedit.regions.iterator; -import java.util.Iterator; -import java.util.NoSuchElementException; - import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.regions.FlatRegion; +import java.util.Iterator; +import java.util.NoSuchElementException; + +import static com.google.common.base.Preconditions.checkNotNull; + public class FlatRegion3DIterator implements Iterator { private Iterator flatIterator; @@ -36,6 +38,9 @@ public class FlatRegion3DIterator implements Iterator { private int nextY; public FlatRegion3DIterator(FlatRegion region, Iterator flatIterator) { + checkNotNull(region); + checkNotNull(flatIterator); + this.flatIterator = flatIterator; this.minY = region.getMinimumY(); this.maxY = region.getMaximumY(); @@ -80,4 +85,5 @@ public class FlatRegion3DIterator implements Iterator { public void remove() { throw new UnsupportedOperationException(); } + } diff --git a/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java b/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java index 448c50433..6657613b2 100644 --- a/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java +++ b/src/main/java/com/sk89q/worldedit/regions/iterator/FlatRegionIterator.java @@ -19,12 +19,14 @@ package com.sk89q.worldedit.regions.iterator; -import java.util.Iterator; - import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector2D; import com.sk89q.worldedit.regions.Region; +import java.util.Iterator; + +import static com.google.common.base.Preconditions.checkNotNull; + public class FlatRegionIterator implements Iterator { private Region region; @@ -36,6 +38,8 @@ public class FlatRegionIterator implements Iterator { private int maxZ; public FlatRegionIterator(Region region) { + checkNotNull(region); + this.region = region; Vector min = region.getMinimumPoint(); @@ -95,4 +99,5 @@ public class FlatRegionIterator implements Iterator { public void remove() { throw new UnsupportedOperationException(); } + } diff --git a/src/main/java/com/sk89q/worldedit/regions/iterator/RegionIterator.java b/src/main/java/com/sk89q/worldedit/regions/iterator/RegionIterator.java index 1f3de55de..9d3b4542d 100644 --- a/src/main/java/com/sk89q/worldedit/regions/iterator/RegionIterator.java +++ b/src/main/java/com/sk89q/worldedit/regions/iterator/RegionIterator.java @@ -19,13 +19,16 @@ package com.sk89q.worldedit.regions.iterator; -import java.util.Iterator; - import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.regions.Region; +import java.util.Iterator; + +import static com.google.common.base.Preconditions.checkNotNull; + public class RegionIterator implements Iterator { + private final Region region; private final int maxX; private final int maxY; @@ -36,6 +39,8 @@ public class RegionIterator implements Iterator { private int nextZ; public RegionIterator(Region region) { + checkNotNull(region); + this.region = region; Vector max = region.getMaximumPoint(); @@ -51,6 +56,7 @@ public class RegionIterator implements Iterator { forward(); } + @Override public boolean hasNext() { return nextX != Integer.MIN_VALUE; } @@ -61,6 +67,7 @@ public class RegionIterator implements Iterator { } } + @Override public BlockVector next() { if (!hasNext()) throw new java.util.NoSuchElementException(); @@ -89,7 +96,9 @@ public class RegionIterator implements Iterator { nextX = Integer.MIN_VALUE; } + @Override public void remove() { throw new UnsupportedOperationException(); } + } diff --git a/src/main/java/com/sk89q/worldedit/regions/polyhedron/Edge.java b/src/main/java/com/sk89q/worldedit/regions/polyhedron/Edge.java index b0c6dcf8a..875af7659 100644 --- a/src/main/java/com/sk89q/worldedit/regions/polyhedron/Edge.java +++ b/src/main/java/com/sk89q/worldedit/regions/polyhedron/Edge.java @@ -21,11 +21,17 @@ package com.sk89q.worldedit.regions.polyhedron; import com.sk89q.worldedit.Vector; +import static com.google.common.base.Preconditions.checkNotNull; + public class Edge { + private final Vector start; private final Vector end; public Edge(Vector start, Vector end) { + checkNotNull(start); + checkNotNull(end); + this.start = start; this.end = end; } @@ -60,15 +66,25 @@ public class Edge { } /** - * Generates a triangle from { this.start, this.end, vertex } - * - * @param vertex The 3rd vertex for the triangle + * Create a triangle from { this.start, this.end, vertex } + * + * @param vertex the 3rd vertex for the triangle * @return a triangle */ public Triangle createTriangle(Vector vertex) { + checkNotNull(vertex); return new Triangle(this.start, this.end, vertex); } + + /** + * Create a triangle from { this.start, vertex, this.end }. + * + * @param vertex the second vertex + * @return a new triangle + */ public Triangle createTriangle2(Vector vertex) { + checkNotNull(vertex); return new Triangle(this.start, vertex, this.end); } + } diff --git a/src/main/java/com/sk89q/worldedit/regions/polyhedron/Triangle.java b/src/main/java/com/sk89q/worldedit/regions/polyhedron/Triangle.java index 1e1bfcb96..ed1ee46c8 100644 --- a/src/main/java/com/sk89q/worldedit/regions/polyhedron/Triangle.java +++ b/src/main/java/com/sk89q/worldedit/regions/polyhedron/Triangle.java @@ -21,7 +21,11 @@ package com.sk89q.worldedit.regions.polyhedron; import com.sk89q.worldedit.Vector; +import static com.google.common.base.Preconditions.checkNotNull; + public class Triangle { + + private String tag = "Triangle"; private final Vector[] vertices; private final Vector normal; private final double b; @@ -29,11 +33,15 @@ public class Triangle { /** * Constructs a triangle with the given vertices (counter-clockwise) * - * @param v0 - * @param v1 - * @param v2 + * @param v0 first vertex + * @param v1 second vertex + * @param v2 third vertex */ public Triangle(Vector v0, Vector v1, Vector v2) { + checkNotNull(v0); + checkNotNull(v1); + checkNotNull(v2); + vertices = new Vector[] { v0, v1, v2 }; this.normal = v1.subtract(v0).cross(v2.subtract(v0)).normalize(); @@ -66,30 +74,40 @@ public class Triangle { /** * Returns whether the given point is above the plane the triangle is in. * - * @param pt - * @return + * @param pt the point to test + * @return true if the point is below */ public boolean below(Vector pt) { + checkNotNull(pt); return normal.dot(pt) < b; } /** * Returns whether the given point is above the plane the triangle is in. * - * @param pt - * @return + * @param pt the point to test + * @return true if the point is above */ public boolean above(Vector pt) { + checkNotNull(pt); return normal.dot(pt) > b; } + /** + * Set the triangle's tag. + * + * @param tag the tag + * @return this object + */ + public Triangle tag(String tag) { + checkNotNull(tag); + this.tag = tag; + return this; + } + @Override public String toString() { - return tag+"(" + this.vertices[0] + "," + this.vertices[1] + "," + this.vertices[2] + ")"; - } - String tag = "Triangle"; - public Triangle tag(String tag) { - this.tag = tag; - return this; + return tag + "(" + this.vertices[0] + "," + this.vertices[1] + "," + this.vertices[2] + ")"; } + } diff --git a/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java b/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java index b048094f5..32dbbd276 100644 --- a/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java +++ b/src/main/java/com/sk89q/worldedit/regions/selector/ConvexPolyhedralRegionSelector.java @@ -19,13 +19,17 @@ package com.sk89q.worldedit.regions.selector; -import com.sk89q.worldedit.*; +import com.sk89q.worldedit.BlockVector; +import com.sk89q.worldedit.BlockVector2D; +import com.sk89q.worldedit.IncompleteRegionException; +import com.sk89q.worldedit.LocalPlayer; +import com.sk89q.worldedit.LocalSession; +import com.sk89q.worldedit.LocalWorld; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.internal.cui.CUIRegion; import com.sk89q.worldedit.internal.cui.SelectionPointEvent; import com.sk89q.worldedit.internal.cui.SelectionPolygonEvent; -import com.sk89q.worldedit.internal.cui.SelectionShapeEvent; import com.sk89q.worldedit.regions.ConvexPolyhedralRegion; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.RegionSelector; @@ -33,7 +37,11 @@ import com.sk89q.worldedit.regions.polyhedron.Triangle; import com.sk89q.worldedit.world.World; import javax.annotation.Nullable; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; import static com.google.common.base.Preconditions.checkNotNull; @@ -46,6 +54,9 @@ public class ConvexPolyhedralRegionSelector extends com.sk89q.worldedit.regions. private final ConvexPolyhedralRegion region; private BlockVector pos1; + /** + * @deprecated cast {@code world} to {@link World} + */ @Deprecated public ConvexPolyhedralRegionSelector(@Nullable LocalWorld world, int maxVertices) { this((World) world, maxVertices); diff --git a/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java b/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java index 18f2a23a7..43d274176 100644 --- a/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java +++ b/src/main/java/com/sk89q/worldedit/regions/selector/CuboidRegionSelector.java @@ -50,6 +50,9 @@ public class CuboidRegionSelector extends com.sk89q.worldedit.regions.CuboidRegi this((World) null); } + /** + * @deprecated cast {@code world} to {@link World} + */ @Deprecated public CuboidRegionSelector(@Nullable LocalWorld world) { this((World) world); @@ -92,6 +95,9 @@ public class CuboidRegionSelector extends com.sk89q.worldedit.regions.CuboidRegi region.setPos2(pos2); } + /** + * @deprecated cast {@code world} to {@link World} + */ @Deprecated public CuboidRegionSelector(@Nullable LocalWorld world, Vector pos1, Vector pos2) { this((World) world, pos1, pos2); @@ -106,7 +112,6 @@ public class CuboidRegionSelector extends com.sk89q.worldedit.regions.CuboidRegi */ public CuboidRegionSelector(@Nullable World world, Vector pos1, Vector pos2) { this(world); - checkNotNull(world); checkNotNull(pos1); checkNotNull(pos2); this.pos1 = pos1.toBlockVector(); diff --git a/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java b/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java index 899a45d31..4d591510a 100644 --- a/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java +++ b/src/main/java/com/sk89q/worldedit/regions/selector/CylinderRegionSelector.java @@ -47,6 +47,9 @@ public class CylinderRegionSelector extends com.sk89q.worldedit.regions.Cylinder format.setMaximumFractionDigits(3); } + /** + * @deprecated cast {@code world} to {@link World} + */ @Deprecated public CylinderRegionSelector(@Nullable LocalWorld world) { this((World) world); diff --git a/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java b/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java index 21a2eee6e..1215d5a95 100644 --- a/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java +++ b/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java @@ -50,6 +50,9 @@ public class EllipsoidRegionSelector extends com.sk89q.worldedit.regions.Ellipso this((World) null); } + /** + * @deprecated cast {@code world} to {@link World} + */ @Deprecated public EllipsoidRegionSelector(@Nullable LocalWorld world) { this((World) world); @@ -76,7 +79,7 @@ public class EllipsoidRegionSelector extends com.sk89q.worldedit.regions.Ellipso region = new EllipsoidRegion(ellipsoidRegionSelector.getIncompleteRegion()); } else { - Region oldRegion = null; + Region oldRegion; try { oldRegion = oldSelector.getRegion(); } catch (IncompleteRegionException e) { diff --git a/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java b/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java index 6e8c149cd..1a36f5572 100644 --- a/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java +++ b/src/main/java/com/sk89q/worldedit/regions/selector/Polygonal2DRegionSelector.java @@ -53,6 +53,9 @@ public class Polygonal2DRegionSelector extends com.sk89q.worldedit.regions.Polyg this(world, 50); } + /** + * @deprecated cast {@code world} to {@link World} + */ @Deprecated public Polygonal2DRegionSelector(@Nullable LocalWorld world, int maxPoints) { this((World) world, maxPoints); @@ -108,6 +111,9 @@ public class Polygonal2DRegionSelector extends com.sk89q.worldedit.regions.Polyg } } + /** + * @deprecated cast {@code world} to {@link World} + */ @Deprecated public Polygonal2DRegionSelector(@Nullable LocalWorld world, List points, int minY, int maxY) { this((World) world, points, minY, maxY); diff --git a/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java b/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java index a5a3b883d..485f5834a 100644 --- a/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java +++ b/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryBiomeShape.java @@ -29,10 +29,9 @@ import com.sk89q.worldedit.world.biome.BaseBiome; /** * Generates solid and hollow shapes according to materials returned by the * {@link #getBiome} method. - * - * @author TomyLobo */ public abstract class ArbitraryBiomeShape { + private final FlatRegion extent; private int cacheOffsetX; private int cacheOffsetZ; @@ -192,4 +191,5 @@ public abstract class ArbitraryBiomeShape { return this == o; } }; + } diff --git a/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java b/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java index 1bafa555d..a842936c5 100644 --- a/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java +++ b/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java @@ -30,10 +30,9 @@ import com.sk89q.worldedit.regions.Region; /** * Generates solid and hollow shapes according to materials returned by the * {@link #getMaterial} method. - * - * @author TomyLobo */ -public abstract class ArbitraryShape { +public abstract class ArbitraryShape +{ protected final Region extent; private int cacheOffsetX; private int cacheOffsetY; @@ -208,4 +207,5 @@ public abstract class ArbitraryShape { return affected; } + } diff --git a/src/main/java/com/sk89q/worldedit/regions/shape/RegionShape.java b/src/main/java/com/sk89q/worldedit/regions/shape/RegionShape.java index 8be88f608..94478527a 100644 --- a/src/main/java/com/sk89q/worldedit/regions/shape/RegionShape.java +++ b/src/main/java/com/sk89q/worldedit/regions/shape/RegionShape.java @@ -26,10 +26,9 @@ import com.sk89q.worldedit.regions.Region; /** * Generates solid and hollow shapes according to materials returned by the * {@link #getMaterial} method. - * - * @author TomyLobo */ public class RegionShape extends ArbitraryShape { + public RegionShape(Region extent) { super(extent); } @@ -42,4 +41,5 @@ public class RegionShape extends ArbitraryShape { return defaultMaterial; } + } diff --git a/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java b/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java index d252220b3..744d53609 100644 --- a/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java +++ b/src/main/java/com/sk89q/worldedit/regions/shape/WorldEditExpressionEnvironment.java @@ -25,6 +25,7 @@ import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.internal.expression.runtime.ExpressionEnvironment; public class WorldEditExpressionEnvironment implements ExpressionEnvironment { + private final Vector unit; private final Vector zero2; private Vector current = new Vector(); @@ -78,4 +79,5 @@ public class WorldEditExpressionEnvironment implements ExpressionEnvironment { public void setCurrentBlock(Vector current) { this.current = current; } + } diff --git a/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java b/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java index 3491b8f55..39dd8886a 100644 --- a/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java +++ b/src/main/java/com/sk89q/worldedit/schematic/MCEditSchematicFormat.java @@ -36,10 +36,8 @@ import java.util.Map.Entry; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; -/** - * @author zml2008 - */ public class MCEditSchematicFormat extends SchematicFormat { + private static final int MAX_SIZE = Short.MAX_VALUE - Short.MIN_VALUE; protected MCEditSchematicFormat() { @@ -327,4 +325,5 @@ public class MCEditSchematicFormat extends SchematicFormat { } return expected.cast(tag); } + } \ No newline at end of file diff --git a/src/main/java/com/sk89q/worldedit/schematic/SchematicFormat.java b/src/main/java/com/sk89q/worldedit/schematic/SchematicFormat.java index 5a99c1083..1de675822 100644 --- a/src/main/java/com/sk89q/worldedit/schematic/SchematicFormat.java +++ b/src/main/java/com/sk89q/worldedit/schematic/SchematicFormat.java @@ -27,11 +27,8 @@ import java.io.File; import java.io.IOException; import java.util.*; -/** - * Represents a format that a schematic can be stored as - * @author zml2008 - */ public abstract class SchematicFormat { + private static final Map SCHEMATIC_FORMATS = new HashMap(); // Built-in schematic formats @@ -142,4 +139,5 @@ public abstract class SchematicFormat { public abstract void save(CuboidClipboard clipboard, File file) throws IOException, DataException; public abstract boolean isOfFormat(File file); + } diff --git a/src/main/java/com/sk89q/worldedit/world/NbtValued.java b/src/main/java/com/sk89q/worldedit/world/NbtValued.java index dc312a447..02a3db0cc 100644 --- a/src/main/java/com/sk89q/worldedit/world/NbtValued.java +++ b/src/main/java/com/sk89q/worldedit/world/NbtValued.java @@ -43,8 +43,8 @@ public interface NbtValued { * in any way, should be sent to {@link #setNbtData(CompoundTag)} so that * the instance knows of the changes. Making changes without calling * {@link #setNbtData(CompoundTag)} could have unintended consequences. - *

- * {@link #hasNbtData()} must return true if and only if method does not return null. + * + *

{@link #hasNbtData()} must return true if and only if method does not return null.

* * @return compound tag, or null */ @@ -55,7 +55,6 @@ public interface NbtValued { * Set the object's NBT data (tile entity data). * * @param nbtData NBT data, or null if no data - * @throws DataException if possibly the data is invalid */ void setNbtData(@Nullable CompoundTag nbtData);