Update from sk89q/master

This commit is contained in:
Jesse Boyd 2018-09-03 00:10:38 +10:00
commit b24d322d29
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
59 changed files with 231 additions and 200 deletions

View File

@ -55,6 +55,7 @@ import javax.annotation.Nullable;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.*; import java.util.*;
import java.util.function.Consumer;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -87,6 +88,20 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
nbtCreateTagMethod.setAccessible(true); nbtCreateTagMethod.setAccessible(true);
} }
private int[] idbToStateOrdinal;
private boolean init() {
if (idbToStateOrdinal != null) return false;
idbToStateOrdinal = new int[Block.REGISTRY_ID.a()]; // size
for (int i = 0; i < idbToStateOrdinal.length; i++) {
BlockState state = BlockTypes.states[i];
BlockMaterial_1_13 material = (BlockMaterial_1_13) state.getMaterial();
int id = Block.REGISTRY_ID.getId(material.getState());
idbToStateOrdinal[id] = state.getOrdinal();
}
return true;
}
/** /**
* Read the given NBT data into the given tile entity. * Read the given NBT data into the given tile entity.
* *
@ -492,20 +507,6 @@ public final class Spigot_v1_13_R2 extends CachedBukkitAdapter implements Bukkit
} }
} }
private int[] idbToStateOrdinal;
private boolean init() {
if (idbToStateOrdinal != null) return false;
idbToStateOrdinal = new int[Block.REGISTRY_ID.a()]; // size
for (int i = 0; i < idbToStateOrdinal.length; i++) {
BlockState state = BlockTypes.states[i];
BlockMaterial_1_13 material = (BlockMaterial_1_13) state.getMaterial();
int id = Block.REGISTRY_ID.getId(material.getState());
idbToStateOrdinal[id] = state.getOrdinal();
}
return true;
}
@Override @Override
public BlockState adapt(BlockData blockData) { public BlockState adapt(BlockData blockData) {
try { try {

View File

@ -2,6 +2,7 @@ package com.boydti.fawe.bukkit.v0;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.config.Settings;
import com.boydti.fawe.example.IntFaweChunk; import com.boydti.fawe.example.IntFaweChunk;
import com.boydti.fawe.object.FaweChunk; import com.boydti.fawe.object.FaweChunk;
import com.boydti.fawe.object.FaweQueue; import com.boydti.fawe.object.FaweQueue;
@ -92,9 +93,9 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
@Override @Override
public FaweChunk call() { public FaweChunk call() {
long start = System.currentTimeMillis(); long start = System.currentTimeMillis();
int recommended = 25 + BukkitQueue_All.ALLOCATE; int recommended = 25 + Settings.IMP.QUEUE.EXTRA_TIME_MS;
boolean more = true; boolean more = true;
final BukkitQueue_All parent = (BukkitQueue_All) getParent(); final BukkitQueue_All parent = getParent();
BukkitImplAdapter adapter = BukkitQueue_0.getAdapter(); BukkitImplAdapter adapter = BukkitQueue_0.getAdapter();
final Chunk chunk = getChunk(); final Chunk chunk = getChunk();
Object[] disableResult = parent.disableLighting(chunk); Object[] disableResult = parent.disableLighting(chunk);
@ -183,8 +184,6 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
} }
} }
} }
} else if (index != 0) { } else if (index != 0) {
if (place) { if (place) {
layer--; layer--;
@ -336,7 +335,7 @@ public class BukkitChunk_All extends IntFaweChunk<Chunk, BukkitQueue_All> {
} }
break; break;
} }
if (checkTime && System.currentTimeMillis() - start > recommended) { if (System.currentTimeMillis() - start > recommended) {
index++; index++;
break mainloop; break mainloop;
} }

View File

@ -33,27 +33,18 @@ import org.bukkit.block.data.BlockData;
public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot, ChunkSnapshot> { public class BukkitQueue_All extends BukkitQueue_0<ChunkSnapshot, ChunkSnapshot, ChunkSnapshot> {
public static int ALLOCATE;
private ConcurrentMap<Long, ChunkSnapshot> chunkCache = new MapMaker() private ConcurrentMap<Long, ChunkSnapshot> chunkCache = new MapMaker()
.weakValues() .weakValues()
.makeMap(); .makeMap();
public BukkitQueue_All(com.sk89q.worldedit.world.World world) { public BukkitQueue_All(com.sk89q.worldedit.world.World world) {
super(world); super(world);
if (Settings.IMP.QUEUE.EXTRA_TIME_MS != Integer.MIN_VALUE) { Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
ALLOCATE = Settings.IMP.QUEUE.EXTRA_TIME_MS;
Settings.IMP.QUEUE.EXTRA_TIME_MS = Integer.MIN_VALUE;
Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
}
} }
public BukkitQueue_All(String world) { public BukkitQueue_All(String world) {
super(world); super(world);
if (Settings.IMP.QUEUE.EXTRA_TIME_MS != Integer.MIN_VALUE) { Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
ALLOCATE = Settings.IMP.QUEUE.EXTRA_TIME_MS;
Settings.IMP.QUEUE.EXTRA_TIME_MS = Integer.MIN_VALUE;
Settings.IMP.QUEUE.PARALLEL_THREADS = 1;
}
} }
@Override @Override

View File

@ -19,16 +19,12 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import com.bekvon.bukkit.residence.commands.material;
import com.sk89q.worldedit.NotABlockException;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter; import com.sk89q.worldedit.bukkit.adapter.BukkitImplAdapter;
import com.sk89q.worldedit.bukkit.adapter.IBukkitAdapter; import com.sk89q.worldedit.bukkit.adapter.IBukkitAdapter;
import com.sk89q.worldedit.bukkit.adapter.SimpleBukkitAdapter; import com.sk89q.worldedit.bukkit.adapter.SimpleBukkitAdapter;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
@ -36,18 +32,13 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.entity.EntityType; import com.sk89q.worldedit.world.entity.EntityType;
import com.sk89q.worldedit.world.entity.EntityTypes;
import com.sk89q.worldedit.world.gamemode.GameMode; import com.sk89q.worldedit.world.gamemode.GameMode;
import com.sk89q.worldedit.world.gamemode.GameModes;
import com.sk89q.worldedit.world.item.ItemType; import com.sk89q.worldedit.world.item.ItemType;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Adapts between Bukkit and WorldEdit equivalent objects. * Adapts between Bukkit and WorldEdit equivalent objects.
*/ */

View File

@ -20,9 +20,9 @@
package com.sk89q.worldedit.bukkit; package com.sk89q.worldedit.bukkit;
import com.sk89q.worldedit.entity.metadata.EntityProperties; import com.sk89q.worldedit.entity.metadata.EntityProperties;
import com.sk89q.worldedit.util.Enums;
import org.bukkit.entity.Ambient; import org.bukkit.entity.Ambient;
import org.bukkit.entity.Animals; import org.bukkit.entity.Animals;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Boat; import org.bukkit.entity.Boat;
import org.bukkit.entity.ComplexEntityPart; import org.bukkit.entity.ComplexEntityPart;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
@ -46,9 +46,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
class BukkitEntityProperties implements EntityProperties { class BukkitEntityProperties implements EntityProperties {
private static final org.bukkit.entity.EntityType armorStandType =
Enums.findByValue(org.bukkit.entity.EntityType.class, "ARMOR_STAND");
private final Entity entity; private final Entity entity;
BukkitEntityProperties(Entity entity) { BukkitEntityProperties(Entity entity) {
@ -143,7 +140,7 @@ class BukkitEntityProperties implements EntityProperties {
@Override @Override
public boolean isArmorStand() { public boolean isArmorStand() {
return entity.getType() == armorStandType; return entity instanceof ArmorStand;
} }
@Override @Override

View File

@ -22,10 +22,8 @@ package com.sk89q.worldedit.bukkit;
import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extent.inventory.*; import com.sk89q.worldedit.extent.inventory.*;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.block.BlockState;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;

View File

@ -153,11 +153,10 @@ public class WorldEditPlugin extends JavaPlugin //implements TabCompleter
WorldEdit worldEdit = WorldEdit.getInstance(); WorldEdit worldEdit = WorldEdit.getInstance();
loadAdapter(); // Need an adapter to work with special blocks with NBT data
// Setup platform // Setup platform
server = new BukkitServerInterface(this, getServer()); server = new BukkitServerInterface(this, getServer());
worldEdit.getPlatformManager().register(server); worldEdit.getPlatformManager().register(server);
loadAdapter(); // Need an adapter to work with special blocks with NBT data
worldEdit.loadMappings(); worldEdit.loadMappings();
loadConfig(); // Load configuration loadConfig(); // Load configuration

View File

@ -15,7 +15,9 @@ dependencies {
// Fawe depends // Fawe depends
compile 'org.yaml:snakeyaml:1.19' compile 'org.yaml:snakeyaml:1.19'
compile 'net.fabiozumbi12:redprotect:1.9.6' compile 'net.fabiozumbi12:redprotect:1.9.6'
compile group: "com.plotsquared", name: "plotsquared-api", version: "latest" compile ("com.plotsquared:plotsquared-api:latest") {
transitive = false
}
// compile 'org.primesoft:BlocksHub:2.0' // compile 'org.primesoft:BlocksHub:2.0'
compile 'com.github.luben:zstd-jni:1.1.1' compile 'com.github.luben:zstd-jni:1.1.1'
compile 'co.aikar:fastutil-lite:1.0' compile 'co.aikar:fastutil-lite:1.0'

View File

@ -157,7 +157,7 @@ public class SetQueue {
return; return;
} }
long time = Settings.IMP.QUEUE.EXTRA_TIME_MS + currentAllocate - System.currentTimeMillis() + now; long time = (long) Settings.IMP.QUEUE.EXTRA_TIME_MS + currentAllocate - System.currentTimeMillis() + now;
// Disable the async catcher as it can't discern async vs parallel // Disable the async catcher as it can't discern async vs parallel
boolean parallel = Settings.IMP.QUEUE.PARALLEL_THREADS > 1; boolean parallel = Settings.IMP.QUEUE.PARALLEL_THREADS > 1;
queue.startSet(parallel); queue.startSet(parallel);

View File

@ -35,6 +35,6 @@ public interface Injector {
* @throws InstantiationException thrown on injection fault * @throws InstantiationException thrown on injection fault
* @throws InvocationTargetException thrown on injection fault * @throws InvocationTargetException thrown on injection fault
*/ */
public Object getInstance(Class<?> cls) throws InvocationTargetException, IllegalAccessException, InstantiationException; Object getInstance(Class<?> cls) throws InvocationTargetException, IllegalAccessException, InstantiationException;
} }

View File

@ -31,7 +31,7 @@ import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME) @Retention(RetentionPolicy.RUNTIME)
public @interface Logging { public @interface Logging {
public enum LogMode { enum LogMode {
/** /**
* Player position * Player position
*/ */

View File

@ -150,7 +150,7 @@ public class YAMLNode {
return; return;
} }
if (o == null || !(o instanceof Map)) { if (!(o instanceof Map)) {
// This will override existing configuration data! // This will override existing configuration data!
o = new LinkedHashMap<String, Object>(); o = new LinkedHashMap<String, Object>();
node.put(parts[i], o); node.put(parts[i], o);

View File

@ -19,10 +19,8 @@
package com.sk89q.worldedit; package com.sk89q.worldedit;
import com.boydti.fawe.object.IntegerTrio;
import com.boydti.fawe.object.schematic.Schematic; import com.boydti.fawe.object.schematic.Schematic;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.command.ClipboardCommands; import com.sk89q.worldedit.command.ClipboardCommands;
import com.sk89q.worldedit.command.FlattenedClipboardTransform; import com.sk89q.worldedit.command.FlattenedClipboardTransform;
@ -34,10 +32,8 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.schematic.SchematicFormat;
import com.sk89q.worldedit.util.Countable; import com.sk89q.worldedit.util.Countable;
import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.world.DataException; import com.sk89q.worldedit.world.DataException;
@ -48,8 +44,9 @@ import com.sk89q.worldedit.world.registry.LegacyMapper;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.ArrayList;
import java.util.function.Consumer; import java.util.List;
import java.util.UUID;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;
@ -102,6 +99,11 @@ public class CuboidClipboard {
this.clipboard = this.init(Vector.ZERO, Vector.ZERO); this.clipboard = this.init(Vector.ZERO, Vector.ZERO);
} }
public CuboidClipboard(BlockArrayClipboard clipboard) {
this.clipboard = clipboard;
this.size = clipboard.getDimensions();
}
/** /**
* Constructs the clipboard. * Constructs the clipboard.
* *
@ -326,25 +328,6 @@ public class CuboidClipboard {
paste(editSession, newOrigin, noAir, false); paste(editSession, newOrigin, noAir, false);
} }
/**
* Paste the stored entities to the given position.
*
* @param newOrigin the new origin
* @return a list of entities that were pasted
*/
public LocalEntity[] pasteEntities(Vector newOrigin) {
return new LocalEntity[0];
}
/**
* Store an entity.
*
* @param entity the entity
*/
public void storeEntity(LocalEntity entity) {
}
/** /**
* Get the block at the given position. * Get the block at the given position.
* <p> * <p>
@ -438,7 +421,7 @@ public class CuboidClipboard {
* @param path the path to the file to save * @param path the path to the file to save
* @throws IOException thrown on I/O error * @throws IOException thrown on I/O error
* @throws DataException thrown on error writing the data for other reasons * @throws DataException thrown on error writing the data for other reasons
* @deprecated use {@link SchematicFormat#MCEDIT} * @deprecated use {@link ClipboardFormat#SCHEMATIC}
*/ */
@Deprecated @Deprecated
public void saveSchematic(File path) throws IOException, DataException { public void saveSchematic(File path) throws IOException, DataException {
@ -460,12 +443,12 @@ public class CuboidClipboard {
* @return a clipboard * @return a clipboard
* @throws IOException thrown on I/O error * @throws IOException thrown on I/O error
* @throws DataException thrown on error writing the data for other reasons * @throws DataException thrown on error writing the data for other reasons
* @deprecated use {@link SchematicFormat#MCEDIT} * @deprecated use {@link ClipboardFormat#SCHEMATIC}
*/ */
@Deprecated @Deprecated
public static CuboidClipboard loadSchematic(File path) throws DataException, IOException { public static CuboidClipboard loadSchematic(File path) throws DataException, IOException {
checkNotNull(path); checkNotNull(path);
return SchematicFormat.MCEDIT.load(path); return new CuboidClipboard((Vector) ClipboardFormat.SCHEMATIC.load(path).getClipboard());
} }
/** /**
@ -489,7 +472,6 @@ public class CuboidClipboard {
* *
* @return a block distribution * @return a block distribution
*/ */
// TODO reduce code duplication
public List<Countable<BaseBlock>> getBlockDistributionWithData() { public List<Countable<BaseBlock>> getBlockDistributionWithData() {
List<Countable<BaseBlock>> distribution = new ArrayList<>(); List<Countable<BaseBlock>> distribution = new ArrayList<>();
List<Countable<BlockStateHolder>> distr = clipboard.getBlockDistributionWithData(clipboard.getRegion()); List<Countable<BlockStateHolder>> distr = clipboard.getBlockDistributionWithData(clipboard.getRegion());
@ -498,17 +480,4 @@ public class CuboidClipboard {
} }
return distribution; return distribution;
} }
/**
* Stores a copied entity.
*/
private class CopiedEntity {
private final LocalEntity entity;
private final Vector relativePosition;
private CopiedEntity(LocalEntity entity) {
this.entity = entity;
this.relativePosition = entity.getPosition().getPosition().subtract(getOrigin());
}
}
} }

View File

@ -44,6 +44,7 @@ import com.boydti.fawe.wrappers.WorldWrapper;
import com.google.common.base.Supplier; import com.google.common.base.Supplier;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.function.mask.*;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
@ -62,7 +63,6 @@ import com.sk89q.worldedit.function.RegionMaskingFilter;
import com.sk89q.worldedit.function.block.BlockReplace; import com.sk89q.worldedit.function.block.BlockReplace;
import com.sk89q.worldedit.function.block.Naturalizer; import com.sk89q.worldedit.function.block.Naturalizer;
import com.sk89q.worldedit.function.generator.GardenPatchGenerator; import com.sk89q.worldedit.function.generator.GardenPatchGenerator;
import com.sk89q.worldedit.function.mask.*;
import com.sk89q.worldedit.function.operation.ChangeSetExecutor; import com.sk89q.worldedit.function.operation.ChangeSetExecutor;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
@ -92,8 +92,24 @@ import com.sk89q.worldedit.util.eventbus.EventBus;
import com.sk89q.worldedit.world.SimpleWorld; import com.sk89q.worldedit.world.SimpleWorld;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BaseBiome; import com.sk89q.worldedit.world.biome.BaseBiome;
import com.sk89q.worldedit.world.block.*;
import com.sk89q.worldedit.world.weather.WeatherType; import com.sk89q.worldedit.world.weather.WeatherType;
import com.sk89q.worldedit.world.block.BlockCategories;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.registry.LegacyMapper;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.*; import java.util.*;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
@ -1593,6 +1609,35 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
return this.changes = visitor.getAffected(); return this.changes = visitor.getAffected();
} }
/**
* Replaces all the blocks matching a given filter, within a given region, to a block
* returned by a given pattern.
*
* @param region the region to replace the blocks within
* @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.function.mask.ExistingBlockMask}
* @param replacement the replacement block
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int replaceBlocks(Region region, Set<BlockStateHolder> filter, BlockStateHolder replacement) throws MaxChangedBlocksException {
return replaceBlocks(region, filter, new BlockPattern(replacement));
}
/**
* Replaces all the blocks matching a given filter, within a given region, to a block
* returned by a given pattern.
*
* @param region the region to replace the blocks within
* @param filter a list of block types to match, or null to use {@link com.sk89q.worldedit.function.mask.ExistingBlockMask}
* @param pattern the pattern that provides the new blocks
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int replaceBlocks(Region region, Set<BlockStateHolder> filter, Pattern pattern) throws MaxChangedBlocksException {
Mask mask = filter == null ? new ExistingBlockMask(this) : new BlockMaskBuilder().addBlocks(filter).build(this);
return replaceBlocks(region, mask, pattern);
}
/** /**
* Replaces all the blocks matching a given mask, within a given region, to a block * Replaces all the blocks matching a given mask, within a given region, to a block
* returned by a given pattern. * returned by a given pattern.

View File

@ -489,10 +489,10 @@ public class WorldEdit {
int size = missingBlocks.size(); int size = missingBlocks.size();
int i = 0; int i = 0;
for (BlockType id : missingBlocks.keySet()) { for (Map.Entry<BlockType, Integer> blockTypeIntegerEntry : missingBlocks.entrySet()) {
str.append(id.getName()); str.append((blockTypeIntegerEntry.getKey()).getName());
str.append(" [Amt: ").append(missingBlocks.get(id)).append("]"); str.append(" [Amt: ").append(blockTypeIntegerEntry.getValue()).append("]");
++i; ++i;
@ -567,7 +567,7 @@ public class WorldEdit {
Request.reset(); Request.reset();
String filename = f.getPath(); String filename = f.getPath();
int index = filename.lastIndexOf("."); int index = filename.lastIndexOf('.');
String ext = filename.substring(index + 1); String ext = filename.substring(index + 1);
if (!ext.equalsIgnoreCase("js")) { if (!ext.equalsIgnoreCase("js")) {

View File

@ -55,7 +55,7 @@ public enum MobType {
private final String name; private final String name;
private MobType(String name) { MobType(String name) {
this.name = name; this.name = name;
} }

View File

@ -47,6 +47,7 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.function.mask.ExistingBlockMask; import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.SingleBlockTypeMask; import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
import com.sk89q.worldedit.function.pattern.BlockPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;

View File

@ -428,7 +428,7 @@ public class RegionCommands extends MethodCommands {
@Logging(REGION) @Logging(REGION)
public void walls(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException { public void walls(FawePlayer player, EditSession editSession, @Selection Region region, Pattern pattern, CommandContext context) throws WorldEditException {
player.checkConfirmationRegion(getArguments(context), region); player.checkConfirmationRegion(getArguments(context), region);
int affected = editSession.makeCuboidWalls(region, pattern); int affected = editSession.makeWalls(region, pattern);
BBC.VISITOR_BLOCK.send(player, affected); BBC.VISITOR_BLOCK.send(player, affected);
} }

View File

@ -27,5 +27,5 @@ import com.sk89q.worldedit.util.Location;
public interface BlockTool extends Tool { public interface BlockTool extends Tool {
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked); boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked);
} }

View File

@ -30,6 +30,6 @@ import com.sk89q.worldedit.util.Location;
*/ */
public interface DoubleActionBlockTool extends BlockTool { public interface DoubleActionBlockTool extends BlockTool {
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked); boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked);
} }

View File

@ -29,6 +29,6 @@ import com.sk89q.worldedit.extension.platform.Platform;
*/ */
public interface DoubleActionTraceTool extends TraceTool { public interface DoubleActionTraceTool extends TraceTool {
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session); boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session);
} }

View File

@ -31,7 +31,6 @@ import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
/** /**
* A tool that can place (or remove) blocks at a distance. * A tool that can place (or remove) blocks at a distance.

View File

@ -34,6 +34,6 @@ public interface Tool {
* @param actor the actor * @param actor the actor
* @return true if use is permitted * @return true if use is permitted
*/ */
public boolean canUse(Actor actor); boolean canUse(Actor actor);
} }

View File

@ -26,5 +26,5 @@ import com.sk89q.worldedit.extension.platform.Platform;
public interface TraceTool extends Tool { public interface TraceTool extends Tool {
public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session); boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session);
} }

View File

@ -39,6 +39,6 @@ public interface Brush {
* @param size the size of the brush * @param size the size of the brush
* @throws MaxChangedBlocksException * @throws MaxChangedBlocksException
*/ */
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws WorldEditException; void build(EditSession editSession, Vector position, Pattern pattern, double size) throws WorldEditException;
} }

View File

@ -19,9 +19,6 @@
package com.sk89q.worldedit.extent.clipboard.io; package com.sk89q.worldedit.extent.clipboard.io;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.base.Function;
import com.google.common.collect.Maps; import com.google.common.collect.Maps;
import com.sk89q.jnbt.ByteArrayTag; import com.sk89q.jnbt.ByteArrayTag;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
@ -34,20 +31,16 @@ import com.sk89q.jnbt.ShortTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.legacycompat.NBTCompatibilityHandler; import com.sk89q.worldedit.extent.clipboard.io.legacycompat.NBTCompatibilityHandler;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockState;
import javax.annotation.Nullable;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
@ -56,6 +49,8 @@ import java.util.Map;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* Reads schematic files using the Sponge Schematic Specification. * Reads schematic files using the Sponge Schematic Specification.
*/ */

View File

@ -19,10 +19,8 @@
package com.sk89q.worldedit.extent.inventory; package com.sk89q.worldedit.extent.inventory;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.block.BlockState;
/** /**
* Represents a source to get blocks from and store removed ones. * Represents a source to get blocks from and store removed ones.

View File

@ -1,24 +1,19 @@
package com.sk89q.worldedit.extent.inventory; package com.sk89q.worldedit.extent.inventory;
import com.boydti.fawe.FaweCache;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;

View File

@ -26,7 +26,6 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;

View File

@ -34,6 +34,6 @@ public interface EntityFunction {
* @return true if something was changed * @return true if something was changed
* @throws WorldEditException thrown on an error * @throws WorldEditException thrown on an error
*/ */
public boolean apply(Entity entity) throws WorldEditException; boolean apply(Entity entity) throws WorldEditException;
} }

View File

@ -36,6 +36,6 @@ public interface FlatRegionFunction {
* @return true if something was changed * @return true if something was changed
* @throws WorldEditException thrown on an error * @throws WorldEditException thrown on an error
*/ */
public boolean apply(Vector2D position) throws WorldEditException; boolean apply(Vector2D position) throws WorldEditException;
} }

View File

@ -34,6 +34,6 @@ public interface RegionFunction {
* @return true if something was changed * @return true if something was changed
* @throws WorldEditException thrown on an error * @throws WorldEditException thrown on an error
*/ */
public boolean apply(Vector position) throws WorldEditException; boolean apply(Vector position) throws WorldEditException;
} }

View File

@ -28,7 +28,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.function.LayerFunction; import com.sk89q.worldedit.function.LayerFunction;
import com.sk89q.worldedit.function.mask.BlockMask; import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import static com.google.common.base.Preconditions.checkNotNull; import static com.google.common.base.Preconditions.checkNotNull;

View File

@ -23,9 +23,9 @@ import java.util.Map;
/** /**
* A mask that checks whether blocks at the given positions are matched by * A mask that checks whether blocks at the given positions are matched by
* a block in a list. * a block in a list.
* <p> *
* <p>This mask checks for both an exact block ID and data value match, as well * <p>This mask checks for both an exact block type and state value match,
* for a block with the same ID but a data value of -1.</p> * respecting fuzzy status of the BlockState.</p>
*/ */
public class BlockMask extends AbstractExtentMask { public class BlockMask extends AbstractExtentMask {

View File

@ -5,6 +5,12 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull;
public class BlockTypeMask extends AbstractExtentMask { public class BlockTypeMask extends AbstractExtentMask {
private final boolean[] types; private final boolean[] types;
@ -19,6 +25,55 @@ public class BlockTypeMask extends AbstractExtentMask {
for (BlockType type : types) this.types[type.getInternalId()] = true; for (BlockType type : types) this.types[type.getInternalId()] = true;
} }
/**
* Create a new block mask.
*
* @param extent the extent
* @param blocks a list of blocks to match
*/
public BlockTypeMask(Extent extent, Collection<BlockType> blocks) {
this(extent, blocks.toArray(new BlockType[blocks.size()]));
}
/**
* Add the given blocks to the list of criteria.
*
* @param blocks a list of blocks
*/
public void add(Collection<BlockType> blocks) {
checkNotNull(blocks);
for (BlockType type : blocks) {
add(type);
}
for (BlockType type : blocks) {
this.types[type.getInternalId()] = true;
}
}
/**
* Add the given blocks to the list of criteria.
*
* @param blocks an array of blocks
*/
public void add(BlockType... blocks) {
for (BlockType type : blocks) {
this.types[type.getInternalId()] = true;
}
}
/**
* Get the list of blocks that are tested with.
*
* @return a list of blocks
*/
public Collection<BlockType> getBlocks() {
Set<BlockType> blocks = new HashSet<>();
for (int i = 0; i < types.length; i++) {
if (types[i]) blocks.add(BlockTypes.get(i));
}
return blocks;
}
@Override @Override
public boolean test(Vector vector) { public boolean test(Vector vector) {
return types[getExtent().getBlockType(vector).getInternalId()]; return types[getExtent().getBlockType(vector).getInternalId()];

View File

@ -19,7 +19,6 @@
package com.sk89q.worldedit.function.mask; package com.sk89q.worldedit.function.mask;
import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.Vector;
@ -42,7 +41,7 @@ public class ExistingBlockMask extends AbstractExtentMask {
@Override @Override
public boolean test(Vector vector) { public boolean test(Vector vector) {
return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir(); return !getExtent().getBlock(vector).getMaterial().isAir();
} }
@Nullable @Nullable

View File

@ -34,6 +34,6 @@ import java.lang.annotation.Target;
@Target(ElementType.PARAMETER) @Target(ElementType.PARAMETER)
public @interface Direction { public @interface Direction {
public static final String AIM = "me"; String AIM = "me";
} }

View File

@ -21,7 +21,7 @@ package com.sk89q.worldedit.internal.cui;
public interface CUIEvent { public interface CUIEvent {
public String getTypeId(); String getTypeId();
public String[] getParameters(); String[] getParameters();
} }

View File

@ -30,7 +30,7 @@ public interface CUIRegion {
* value supplied by getProtocolVersion(). * value supplied by getProtocolVersion().
* *
*/ */
public void describeCUI(LocalSession session, Actor player); void describeCUI(LocalSession session, Actor player);
/** /**
* Sends CUI events describing the region for * Sends CUI events describing the region for
@ -38,7 +38,7 @@ public interface CUIRegion {
* supplied by getProtocolVersion(). * supplied by getProtocolVersion().
* *
*/ */
public void describeLegacyCUI(LocalSession session, Actor player); void describeLegacyCUI(LocalSession session, Actor player);
/** /**
* Returns the CUI version that is required to send * Returns the CUI version that is required to send
@ -47,14 +47,14 @@ public interface CUIRegion {
* *
* @return the protocol version * @return the protocol version
*/ */
public int getProtocolVersion(); int getProtocolVersion();
/** /**
* Returns the type ID to send to CUI in the selection event. * Returns the type ID to send to CUI in the selection event.
* *
* @return the type ID * @return the type ID
*/ */
public String getTypeID(); String getTypeID();
/** /**
* Returns the type ID to send to CUI in the selection * Returns the type ID to send to CUI in the selection
@ -62,5 +62,5 @@ public interface CUIRegion {
* *
* @return the legacy type ID * @return the legacy type ID
*/ */
public String getLegacyTypeID(); String getLegacyTypeID();
} }

View File

@ -54,8 +54,8 @@ public interface Identifiable {
* C - Switch * C - Switch
* </pre> * </pre>
*/ */
public abstract char id(); char id();
public int getPosition(); int getPosition();
} }

View File

@ -27,12 +27,12 @@ import com.sk89q.worldedit.internal.expression.parser.ParserException;
*/ */
public interface LValue extends RValue { public interface LValue extends RValue {
public double assign(double value) throws EvaluationException; double assign(double value) throws EvaluationException;
@Override @Override
public LValue optimize() throws EvaluationException; LValue optimize() throws EvaluationException;
@Override @Override
public LValue bindVariables(Expression expression, boolean preferLValue) throws ParserException; LValue bindVariables(Expression expression, boolean preferLValue) throws ParserException;
} }

View File

@ -28,10 +28,10 @@ import com.sk89q.worldedit.internal.expression.parser.ParserException;
*/ */
public interface RValue extends Identifiable { public interface RValue extends Identifiable {
public double getValue() throws EvaluationException; double getValue() throws EvaluationException;
public RValue optimize() throws EvaluationException; RValue optimize() throws EvaluationException;
public RValue bindVariables(Expression expression, boolean preferLValue) throws ParserException; RValue bindVariables(Expression expression, boolean preferLValue) throws ParserException;
} }

View File

@ -147,13 +147,13 @@ public final class DocumentationPrinter {
stream.print(" || "); stream.print(" || ");
if (cmd.flags() != null && !cmd.flags().equals("")) { if (cmd.flags() != null && !cmd.flags().isEmpty()) {
stream.print(cmd.flags()); stream.print(cmd.flags());
} }
stream.print(" || "); stream.print(" || ");
if (cmd.desc() != null && !cmd.desc().equals("")) { if (cmd.desc() != null && !cmd.desc().isEmpty()) {
stream.print(cmd.desc()); stream.print(cmd.desc());
} }

View File

@ -36,7 +36,7 @@ public interface Interpolation {
* *
* @param nodes the nodes * @param nodes the nodes
*/ */
public void setNodes(List<Node> nodes); void setNodes(List<Node> nodes);
/** /**
* Gets the result of f(position) * Gets the result of f(position)
@ -44,7 +44,7 @@ public interface Interpolation {
* @param position the position to interpolate * @param position the position to interpolate
* @return the result * @return the result
*/ */
public Vector getPosition(double position); Vector getPosition(double position);
/** /**
* Gets the result of f'(position). * Gets the result of f'(position).
@ -52,7 +52,7 @@ public interface Interpolation {
* @param position the position to interpolate * @param position the position to interpolate
* @return the result * @return the result
*/ */
public Vector get1stDerivative(double position); Vector get1stDerivative(double position);
/** /**
* Gets the result of &int;<sub>a</sub><sup style="position: relative; left: -1ex">b</sup>|f'(t)| dt.<br /> * Gets the result of &int;<sub>a</sub><sup style="position: relative; left: -1ex">b</sup>|f'(t)| dt.<br />

View File

@ -28,19 +28,19 @@ public interface FlatRegion extends Region {
* *
* @return the Y value * @return the Y value
*/ */
public int getMinimumY(); int getMinimumY();
/** /**
* Gets the maximum Y value * Gets the maximum Y value
* *
* @return the Y value * @return the Y value
*/ */
public int getMaximumY(); int getMaximumY();
/** /**
* Get this region as an iterable flat region. * Get this region as an iterable flat region.
* *
* @return a flat region iterable * @return a flat region iterable
*/ */
public Iterable<Vector2D> asFlatRegion(); Iterable<Vector2D> asFlatRegion();
} }

View File

@ -44,14 +44,14 @@ public interface RegionSelector {
* @return a world, which may be null * @return a world, which may be null
*/ */
@Nullable @Nullable
public World getWorld(); World getWorld();
/** /**
* Set the world for the region selector. * Set the world for the region selector.
* *
* @param world the world, which may be null * @param world the world, which may be null
*/ */
public void setWorld(@Nullable World world); void setWorld(@Nullable World world);
/** /**
* Called when the first point is selected. * Called when the first point is selected.
@ -59,7 +59,7 @@ public interface RegionSelector {
* @param position the position * @param position the position
* @return true if something changed * @return true if something changed
*/ */
public boolean selectPrimary(Vector position, SelectorLimits limits); boolean selectPrimary(Vector position, SelectorLimits limits);
/** /**
* Called when the second point is selected. * Called when the second point is selected.
@ -67,7 +67,7 @@ public interface RegionSelector {
* @param position the position * @param position the position
* @return true if something changed * @return true if something changed
*/ */
public boolean selectSecondary(Vector position, SelectorLimits limits); boolean selectSecondary(Vector position, SelectorLimits limits);
/** /**
* Tell the player information about his/her primary selection. * Tell the player information about his/her primary selection.
@ -76,7 +76,7 @@ public interface RegionSelector {
* @param session the session * @param session the session
* @param position position * @param position position
*/ */
public void explainPrimarySelection(Actor actor, LocalSession session, Vector position); void explainPrimarySelection(Actor actor, LocalSession session, Vector position);
/** /**
* Tell the player information about his/her secondary selection. * Tell the player information about his/her secondary selection.
@ -85,7 +85,7 @@ public interface RegionSelector {
* @param session the session * @param session the session
* @param position position * @param position position
*/ */
public void explainSecondarySelection(Actor actor, LocalSession session, Vector position); void explainSecondarySelection(Actor actor, LocalSession session, Vector position);
/** /**
* The the player information about the region's changes. This may resend * The the player information about the region's changes. This may resend
@ -94,7 +94,7 @@ public interface RegionSelector {
* @param actor the actor * @param actor the actor
* @param session the session * @param session the session
*/ */
public void explainRegionAdjust(Actor actor, LocalSession session); void explainRegionAdjust(Actor actor, LocalSession session);
/** /**
* Get the primary position. * Get the primary position.
@ -102,7 +102,7 @@ public interface RegionSelector {
* @return the primary position * @return the primary position
* @throws IncompleteRegionException thrown if a region has not been fully defined * @throws IncompleteRegionException thrown if a region has not been fully defined
*/ */
public BlockVector getPrimaryPosition() throws IncompleteRegionException; BlockVector getPrimaryPosition() throws IncompleteRegionException;
/** /**
* Get the selection. * Get the selection.
@ -110,52 +110,52 @@ public interface RegionSelector {
* @return the created region * @return the created region
* @throws IncompleteRegionException thrown if a region has not been fully defined * @throws IncompleteRegionException thrown if a region has not been fully defined
*/ */
public Region getRegion() throws IncompleteRegionException; Region getRegion() throws IncompleteRegionException;
/** /**
* Get the region even if it's not fully defined. * Get the region even if it's not fully defined.
* *
* @return an incomplete region object that is incomplete * @return an incomplete region object that is incomplete
*/ */
public Region getIncompleteRegion(); Region getIncompleteRegion();
/** /**
* Returns whether the region has been fully defined. * Returns whether the region has been fully defined.
* *
* @return true if a selection is available * @return true if a selection is available
*/ */
public boolean isDefined(); boolean isDefined();
/** /**
* Get the number of blocks inside the region. * Get the number of blocks inside the region.
* *
* @return number of blocks, or -1 if undefined * @return number of blocks, or -1 if undefined
*/ */
public int getArea(); int getArea();
/** /**
* Update the selector with changes to the region. * Update the selector with changes to the region.
*/ */
public void learnChanges(); void learnChanges();
/** /**
* Clear the selection. * Clear the selection.
*/ */
public void clear(); void clear();
/** /**
* Get a lowercase name of this region selector type. * Get a lowercase name of this region selector type.
* *
* @return a lower case name of the type * @return a lower case name of the type
*/ */
public String getTypeName(); String getTypeName();
/** /**
* Get lines of information about the selection. * Get lines of information about the selection.
* *
* @return a list of lines describing the region * @return a list of lines describing the region
*/ */
public List<String> getInformationLines(); List<String> getInformationLines();
/** /**
* Get the verticies * Get the verticies

View File

@ -36,7 +36,7 @@ public enum RegionSelectorType {
private final Class<? extends RegionSelector> selectorClass; private final Class<? extends RegionSelector> selectorClass;
private RegionSelectorType(Class<? extends RegionSelector> selectorClass) { RegionSelectorType(Class<? extends RegionSelector> selectorClass) {
this.selectorClass = selectorClass; this.selectorClass = selectorClass;
} }

View File

@ -23,10 +23,10 @@ import java.util.Map;
import javax.script.ScriptException; import javax.script.ScriptException;
public interface CraftScriptEngine { public interface CraftScriptEngine {
public void setTimeLimit(int milliseconds); void setTimeLimit(int milliseconds);
public int getTimeLimit(); int getTimeLimit();
public Object evaluate(String script, String filename, Map<String, Object> args) Object evaluate(String script, String filename, Map<String, Object> args)
throws ScriptException, Throwable; throws ScriptException, Throwable;
} }

View File

@ -106,7 +106,7 @@ public class SessionManager {
checkNotNull(name); checkNotNull(name);
for (SessionHolder holder : sessions.values()) { for (SessionHolder holder : sessions.values()) {
String test = holder.key.getName(); String test = holder.key.getName();
if (test != null && name.equals(test)) { if (name.equals(test)) {
return holder.session; return holder.session;
} }
} }

View File

@ -126,7 +126,7 @@ public class YAMLConfiguration extends LocalConfiguration {
} }
String type = config.getString("shell-save-type", "").trim(); String type = config.getString("shell-save-type", "").trim();
shellSaveType = type.equals("") ? null : type; shellSaveType = type.isEmpty() ? null : type;
} }

View File

@ -61,6 +61,6 @@ public interface Parameter {
* *
* @return a default value, or null if none is set * @return a default value, or null if none is set
*/ */
public String[] getDefaultValue(); String[] getDefaultValue();
} }

View File

@ -136,11 +136,11 @@ public enum Style {
private final static Map<Integer, Style> BY_ID = Maps.newHashMap(); private final static Map<Integer, Style> BY_ID = Maps.newHashMap();
private final static Map<Character, Style> BY_CHAR = Maps.newHashMap(); private final static Map<Character, Style> BY_CHAR = Maps.newHashMap();
private Style(char code, int intCode) { Style(char code, int intCode) {
this(code, intCode, false); this(code, intCode, false);
} }
private Style(char code, int intCode, boolean isFormat) { Style(char code, int intCode, boolean isFormat) {
this.code = code; this.code = code;
this.intCode = intCode; this.intCode = intCode;
this.isFormat = isFormat; this.isFormat = isFormat;
@ -183,7 +183,7 @@ public enum Style {
* Gets the color represented by the specified color code * Gets the color represented by the specified color code
* *
* @param code Code to check * @param code Code to check
* @return Associative {@link org.bukkit.ChatColor} with the given code, or null if it doesn't exist * @return Associative Style with the given code, or null if it doesn't exist
*/ */
public static Style getByChar(char code) { public static Style getByChar(char code) {
return BY_CHAR.get(code); return BY_CHAR.get(code);
@ -193,7 +193,7 @@ public enum Style {
* Gets the color represented by the specified color code * Gets the color represented by the specified color code
* *
* @param code Code to check * @param code Code to check
* @return Associative {@link org.bukkit.ChatColor} with the given code, or null if it doesn't exist * @return Associative Style with the given code, or null if it doesn't exist
*/ */
public static Style getByChar(String code) { public static Style getByChar(String code) {
checkNotNull(code); checkNotNull(code);

View File

@ -27,13 +27,11 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.function.mask.BlockMask;
import com.sk89q.worldedit.function.mask.BlockTypeMask; import com.sk89q.worldedit.function.mask.BlockTypeMask;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.Operation; import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.util.Direction; import com.sk89q.worldedit.util.Direction;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;

View File

@ -193,7 +193,7 @@ public class Snapshot implements Comparable<Snapshot> {
public int compareTo(Snapshot o) { public int compareTo(Snapshot o) {
if (o.date == null || date == null) { if (o.date == null || date == null) {
// Remove the folder from the name // Remove the folder from the name
int i = name.indexOf("/"), j = o.name.indexOf("/"); int i = name.indexOf('/'), j = o.name.indexOf('/');
return name.substring((i > 0 ? 0 : i)).compareTo(o.name.substring((j > 0 ? 0 : j))); return name.substring((i > 0 ? 0 : i)).compareTo(o.name.substring((j > 0 ? 0 : j)));
} else { } else {
return date.compareTo(o.date); return date.compareTo(o.date);

View File

@ -35,6 +35,6 @@ public interface SnapshotDateParser {
* @return date or null * @return date or null
*/ */
@Nullable @Nullable
public Calendar detectDate(File file); Calendar detectDate(File file);
} }

View File

@ -88,7 +88,7 @@ public class TrueZipLegacyChunkStore extends LegacyChunkStore {
// Detect subfolder for the world's files // Detect subfolder for the world's files
if (folder != null) { if (folder != null) {
if (!folder.equals("")) { if (!folder.isEmpty()) {
file = folder + "/" + file; file = folder + "/" + file;
} }
} else { } else {

View File

@ -87,7 +87,7 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
protected InputStream getInputStream(String name, String worldName) throws IOException, DataException { protected InputStream getInputStream(String name, String worldName) throws IOException, DataException {
// Detect subfolder for the world's files // Detect subfolder for the world's files
if (folder != null) { if (folder != null) {
if (!folder.equals("")) { if (!folder.isEmpty()) {
name = folder + "/" + name; name = folder + "/" + name;
} }
} else { } else {
@ -100,7 +100,7 @@ public class TrueZipMcRegionChunkStore extends McRegionChunkStore {
if (worldPattern.matcher(worldName).matches()) { if (worldPattern.matcher(worldName).matches()) {
// Check for file // Check for file
if (pattern.matcher(testEntry.getName()).matches()) { if (pattern.matcher(testEntry.getName()).matches()) {
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf("/")); folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/'));
name = folder + "/" + name; name = folder + "/" + name;
break; break;
} }

View File

@ -82,7 +82,7 @@ public class ZippedLegacyChunkStore extends LegacyChunkStore {
// Detect subfolder for the world's files // Detect subfolder for the world's files
if (folder != null) { if (folder != null) {
if (!folder.equals("")) { if (!folder.isEmpty()) {
file = folder + "/" + file; file = folder + "/" + file;
} }
} else { } else {

View File

@ -76,7 +76,7 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
protected InputStream getInputStream(String name, String worldName) throws IOException, DataException { protected InputStream getInputStream(String name, String worldName) throws IOException, DataException {
// Detect subfolder for the world's files // Detect subfolder for the world's files
if (folder != null) { if (folder != null) {
if (!folder.equals("")) { if (!folder.isEmpty()) {
name = folder + "/" + name; name = folder + "/" + name;
} }
} else { } else {
@ -86,7 +86,7 @@ public class ZippedMcRegionChunkStore extends McRegionChunkStore {
// Check for world // Check for world
if (testEntry.getName().startsWith(worldName + "/")) { if (testEntry.getName().startsWith(worldName + "/")) {
if (pattern.matcher(testEntry.getName()).matches()) { // does entry end in .mca if (pattern.matcher(testEntry.getName()).matches()) { // does entry end in .mca
folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf("/")); folder = testEntry.getName().substring(0, testEntry.getName().lastIndexOf('/'));
name = folder + "/" + name; name = folder + "/" + name;
break; break;
} }