Permalink
Browse files

Merge pull request #441 from sk89q/feature/no-rawtypes

Cleanup compiler warnings and BlockStateHolder raw types
  • Loading branch information...
me4502 committed Dec 27, 2018
2 parents a88f6b8 + 386668d commit f4ed48b262eff56b2f995f6084099cc8dbe16642
Showing with 265 additions and 294 deletions.
  1. +1 −1 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitAdapter.java
  2. +1 −1 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockRegistry.java
  3. +1 −1 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java
  4. +2 −2 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitWorld.java
  5. +16 −29 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlugin.java
  6. +2 −2 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplAdapter.java
  7. +1 −1 worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java
  8. +1 −1 worldedit-core/src/main/java/com/sk89q/jnbt/ListTagBuilder.java
  9. +17 −17 worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java
  10. +2 −2 worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java
  11. +0 −1 worldedit-core/src/main/java/com/sk89q/worldedit/command/NavigationCommands.java
  12. +0 −1 worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java
  13. +8 −7 worldedit-core/src/main/java/com/sk89q/worldedit/command/SelectionCommands.java
  14. +3 −3 worldedit-core/src/main/java/com/sk89q/worldedit/command/UtilityCommands.java
  15. +4 −2 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockDataCyler.java
  16. +2 −2 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/BlockReplacer.java
  17. +3 −3 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/LongRangeBuildTool.java
  18. +2 −2 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/QueryTool.java
  19. +3 −3 worldedit-core/src/main/java/com/sk89q/worldedit/command/tool/brush/GravityBrush.java
  20. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/entity/Player.java
  21. +4 −5 worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/BlockFactory.java
  22. +11 −9 worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/DefaultBlockParser.java
  23. +2 −2 worldedit-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/mask/BlocksMaskParser.java
  24. +2 −2 ...-core/src/main/java/com/sk89q/worldedit/extension/factory/parser/pattern/RandomPatternParser.java
  25. +3 −3 worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java
  26. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlayerProxy.java
  27. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/extent/AbstractDelegateExtent.java
  28. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/extent/ChangeSetExtent.java
  29. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/extent/MaskingExtent.java
  30. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/extent/NullExtent.java
  31. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/extent/OutputExtent.java
  32. +7 −6 worldedit-core/src/main/java/com/sk89q/worldedit/extent/buffer/ForgetfulExtentBuffer.java
  33. +7 −7 worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/BlockArrayClipboard.java
  34. +2 −2 ...e/src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/NBTCompatibilityHandler.java
  35. +3 −2 .../src/main/java/com/sk89q/worldedit/extent/clipboard/io/legacycompat/SignCompatibilityHandler.java
  36. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/extent/inventory/BlockBagExtent.java
  37. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/ChunkBatchingExtent.java
  38. +4 −3 worldedit-core/src/main/java/com/sk89q/worldedit/extent/reorder/MultiStageReorder.java
  39. +14 −24 worldedit-core/src/main/java/com/sk89q/worldedit/extent/transform/BlockTransformExtent.java
  40. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/BlockChangeLimiter.java
  41. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/extent/validation/DataValidatorExtent.java
  42. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/BlockQuirkExtent.java
  43. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/ChunkLoadingExtent.java
  44. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/FastModeExtent.java
  45. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/extent/world/SurvivalModeExtent.java
  46. +10 −11 worldedit-core/src/main/java/com/sk89q/worldedit/function/block/BlockDistributionCounter.java
  47. +2 −2 worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/FloraGenerator.java
  48. +2 −2 worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/ForestGenerator.java
  49. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/function/generator/GardenPatchGenerator.java
  50. +10 −9 worldedit-core/src/main/java/com/sk89q/worldedit/function/mask/BlockMask.java
  51. +6 −6 worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/BlockPattern.java
  52. +2 −2 worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/ClipboardPattern.java
  53. +2 −1 worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/Pattern.java
  54. +2 −2 worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RandomPattern.java
  55. +2 −2 worldedit-core/src/main/java/com/sk89q/worldedit/function/pattern/RepeatingExtentPattern.java
  56. +8 −7 worldedit-core/src/main/java/com/sk89q/worldedit/history/change/BlockChange.java
  57. +1 −14 worldedit-core/src/main/java/com/sk89q/worldedit/internal/command/WorldEditBinding.java
  58. +0 −1 worldedit-core/src/main/java/com/sk89q/worldedit/internal/registry/AbstractFactory.java
  59. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/regions/RegionIntersection.java
  60. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/regions/selector/EllipsoidRegionSelector.java
  61. +4 −4 worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/ArbitraryShape.java
  62. +2 −2 worldedit-core/src/main/java/com/sk89q/worldedit/regions/shape/RegionShape.java
  63. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/registry/state/AbstractProperty.java
  64. +4 −4 worldedit-core/src/main/java/com/sk89q/worldedit/scripting/CraftScriptContext.java
  65. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/util/FileDialogUtil.java
  66. +4 −4 worldedit-core/src/main/java/com/sk89q/worldedit/util/LocatedBlock.java
  67. +2 −2 worldedit-core/src/main/java/com/sk89q/worldedit/util/TreeGenerator.java
  68. +2 −2 worldedit-core/src/main/java/com/sk89q/worldedit/util/collection/LocatedBlockList.java
  69. +2 −1 worldedit-core/src/main/java/com/sk89q/worldedit/world/AbstractWorld.java
  70. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/world/NullWorld.java
  71. +1 −3 worldedit-core/src/main/java/com/sk89q/worldedit/world/World.java
  72. +2 −2 worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java
  73. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategory.java
  74. +9 −9 worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockState.java
  75. +3 −3 worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockStateHolder.java
  76. +6 −5 worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockType.java
  77. +4 −4 worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk.java
  78. +3 −3 worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/AnvilChunk13.java
  79. +3 −3 worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/Chunk.java
  80. +4 −4 worldedit-core/src/main/java/com/sk89q/worldedit/world/chunk/OldChunk.java
  81. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BlockRegistry.java
  82. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/BundledBlockRegistry.java
  83. +1 −1 worldedit-core/src/main/java/com/sk89q/worldedit/world/registry/LegacyMapper.java
  84. +4 −3 worldedit-core/src/main/java/com/sk89q/worldedit/world/snapshot/Snapshot.java
  85. +1 −1 worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlayer.java
  86. +1 −2 worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java
  87. +2 −1 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongePlayer.java
  88. +1 −1 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeWorld.java
  89. +1 −1 worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/adapter/SpongeImplLoader.java
@@ -381,7 +381,7 @@ public BlockState apply(@Nullable String input) {
* @param block The WorldEdit BlockStateHolder
* @return The Bukkit BlockData
*/
public static BlockData adapt(BlockStateHolder block) {
public static <B extends BlockStateHolder<B>> BlockData adapt(B block) {
checkNotNull(block);
return blockDataCache.computeIfAbsent(block.getAsString(), new Function<String, BlockData>() {
@Nullable
@@ -47,7 +47,7 @@ public BlockMaterial getMaterial(BlockType blockType) {

@Nullable
@Override
public Map<String, ? extends Property> getProperties(BlockType blockType) {
public Map<String, ? extends Property<?>> getProperties(BlockType blockType) {
if (WorldEditPlugin.getInstance().getBukkitImplAdapter() != null) {
return WorldEditPlugin.getInstance().getBukkitImplAdapter().getProperties(blockType);
}
@@ -255,7 +255,7 @@ public boolean isPersistent() {
}

@Override
public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) {
public <B extends BlockStateHolder<B>> void sendFakeBlock(BlockVector3 pos, B block) {
Location loc = new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ());
if (block == null) {
player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData());
@@ -166,7 +166,7 @@ public int getBlockLightLevel(BlockVector3 pt) {

@Override
public boolean regenerate(Region region, EditSession editSession) {
BlockStateHolder[] history = new BlockStateHolder[16 * 16 * (getMaxY() + 1)];
BaseBlock[] history = new BaseBlock[16 * 16 * (getMaxY() + 1)];

for (BlockVector2 chunk : region.getChunks()) {
BlockVector3 min = BlockVector3.at(chunk.getBlockX() * 16, 0, chunk.getBlockZ() * 16);
@@ -421,7 +421,7 @@ public void simulateBlockMine(BlockVector3 pt) {
}

@Override
public boolean setBlock(BlockVector3 position, BlockStateHolder block, boolean notifyAndLight) throws WorldEditException {
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, boolean notifyAndLight) throws WorldEditException {
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
if (adapter != null) {
try {
@@ -37,6 +37,7 @@
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extension.platform.Platform;
import com.sk89q.worldedit.extent.inventory.BlockBag;

import org.bstats.bukkit.Metrics;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -181,41 +182,27 @@ protected void loadConfiguration() {
protected void createDefaultConfiguration(String name) {
File actual = new File(getDataFolder(), name);
if (!actual.exists()) {
InputStream input = null;
try {
JarFile file = new JarFile(getFile());
try (JarFile file = new JarFile(getFile())) {
ZipEntry copy = file.getEntry("defaults/" + name);
if (copy == null) throw new FileNotFoundException();
input = file.getInputStream(copy);
copyDefaultConfig(file.getInputStream(copy), actual, name);
} catch (IOException e) {
getLogger().severe("Unable to read default configuration: " + name);
}
if (input != null) {
FileOutputStream output = null;

try {
output = new FileOutputStream(actual);
byte[] buf = new byte[8192];
int length;
while ((length = input.read(buf)) > 0) {
output.write(buf, 0, length);
}

getLogger().info("Default configuration file written: " + name);
} catch (IOException e) {
getLogger().log(Level.WARNING, "Failed to write default config file", e);
} finally {
try {
input.close();
} catch (IOException ignored) {}

try {
if (output != null) {
output.close();
}
} catch (IOException ignored) {}
}
}
}

private void copyDefaultConfig(InputStream input, File actual, String name) {
try (FileOutputStream output = new FileOutputStream(actual)) {
byte[] buf = new byte[8192];
int length;
while ((length = input.read(buf)) > 0) {
output.write(buf, 0, length);
}

getLogger().info("Default configuration file written: " + name);
} catch (IOException e) {
getLogger().log(Level.WARNING, "Failed to write default config file", e);
}
}

@@ -77,7 +77,7 @@
* @param notifyAndLight notify and light if set
* @return true if a block was likely changed
*/
boolean setBlock(Location location, BlockStateHolder state, boolean notifyAndLight);
boolean setBlock(Location location, BlockStateHolder<?> state, boolean notifyAndLight);

/**
* Notifies the simulation that the block at the given location has
@@ -113,7 +113,7 @@
* @param blockType The block type
* @return The properties map
*/
Map<String, ? extends Property> getProperties(BlockType blockType);
Map<String, ? extends Property<?>> getProperties(BlockType blockType);

/**
* Send the given NBT data to the player.
@@ -87,7 +87,7 @@ public void addFromJar(File file) throws IOException {
Closer closer = Closer.create();
JarFile jar = closer.register(new JarFile(file));
try {
Enumeration entries = jar.entries();
Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
JarEntry jarEntry = (JarEntry) entries.nextElement();

@@ -97,7 +97,7 @@ public static ListTagBuilder create(Class<? extends Tag> type) {
*
* @return a new builder
*/
public static <T extends Tag> ListTagBuilder createWith(T ... entries) {
public static ListTagBuilder createWith(Tag... entries) {
checkNotNull(entries);

if (entries.length == 0) {
@@ -609,7 +609,7 @@ public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
* @return whether the block changed
* @throws WorldEditException thrown on a set error
*/
public boolean setBlock(BlockVector3 position, BlockStateHolder block, Stage stage) throws WorldEditException {
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block, Stage stage) throws WorldEditException {
switch (stage) {
case BEFORE_HISTORY:
return bypassNone.setBlock(position, block);
@@ -629,7 +629,7 @@ public boolean setBlock(BlockVector3 position, BlockStateHolder block, Stage sta
* @param block the block
* @return whether the block changed
*/
public boolean rawSetBlock(BlockVector3 position, BlockStateHolder block) {
public <B extends BlockStateHolder<B>> boolean rawSetBlock(BlockVector3 position, B block) {
try {
return setBlock(position, block, Stage.BEFORE_CHANGE);
} catch (WorldEditException e) {
@@ -644,7 +644,7 @@ public boolean rawSetBlock(BlockVector3 position, BlockStateHolder block) {
* @param block the block
* @return whether the block changed
*/
public boolean smartSetBlock(BlockVector3 position, BlockStateHolder block) {
public <B extends BlockStateHolder<B>> boolean smartSetBlock(BlockVector3 position, B block) {
try {
return setBlock(position, block, Stage.BEFORE_REORDER);
} catch (WorldEditException e) {
@@ -653,7 +653,7 @@ public boolean smartSetBlock(BlockVector3 position, BlockStateHolder block) {
}

@Override
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws MaxChangedBlocksException {
public <B extends BlockStateHolder<B>> boolean setBlock(BlockVector3 position, B block) throws MaxChangedBlocksException {
try {
return setBlock(position, block, Stage.BEFORE_HISTORY);
} catch (MaxChangedBlocksException e) {
@@ -779,7 +779,7 @@ public void flushSession() {
* @param searchBlocks the list of blocks to search
* @return the number of blocks that matched the pattern
*/
public int countBlocks(Region region, Set<BlockStateHolder> searchBlocks) {
public int countBlocks(Region region, Set<BaseBlock> searchBlocks) {
BlockMask mask = new BlockMask(this, searchBlocks);
Counter count = new Counter();
RegionMaskingFilter filter = new RegionMaskingFilter(mask, count);
@@ -799,7 +799,7 @@ public int countBlocks(Region region, Set<BlockStateHolder> searchBlocks) {
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int fillXZ(BlockVector3 origin, BlockStateHolder block, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
public <B extends BlockStateHolder<B>> int fillXZ(BlockVector3 origin, B block, double radius, int depth, boolean recursive) throws MaxChangedBlocksException {
return fillXZ(origin, new BlockPattern(block), radius, depth, recursive);
}

@@ -922,7 +922,7 @@ public int removeNear(BlockVector3 position, BlockType blockType, int apothem) t
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int setBlocks(Region region, BlockStateHolder block) throws MaxChangedBlocksException {
public <B extends BlockStateHolder<B>> int setBlocks(Region region, B block) throws MaxChangedBlocksException {
return setBlocks(region, new BlockPattern(block));
}

@@ -954,7 +954,7 @@ public int setBlocks(Region region, Pattern pattern) throws MaxChangedBlocksExce
* @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 {
public <B extends BlockStateHolder<B>> int replaceBlocks(Region region, Set<BaseBlock> filter, B replacement) throws MaxChangedBlocksException {
return replaceBlocks(region, filter, new BlockPattern(replacement));
}

@@ -968,7 +968,7 @@ public int replaceBlocks(Region region, Set<BlockStateHolder> filter, BlockState
* @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 {
public int replaceBlocks(Region region, Set<BaseBlock> filter, Pattern pattern) throws MaxChangedBlocksException {
Mask mask = filter == null ? new ExistingBlockMask(this) : new BlockMask(this, filter);
return replaceBlocks(region, mask, pattern);
}
@@ -1026,7 +1026,7 @@ public int center(Region region, Pattern pattern) throws MaxChangedBlocksExcepti
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int makeCuboidFaces(Region region, BlockStateHolder block) throws MaxChangedBlocksException {
public <B extends BlockStateHolder<B>> int makeCuboidFaces(Region region, B block) throws MaxChangedBlocksException {
return makeCuboidFaces(region, new BlockPattern(block));
}

@@ -1078,7 +1078,7 @@ public int makeFaces(final Region region, Pattern pattern) throws MaxChangedBloc
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int makeCuboidWalls(Region region, BlockStateHolder block) throws MaxChangedBlocksException {
public <B extends BlockStateHolder<B>> int makeCuboidWalls(Region region, B block) throws MaxChangedBlocksException {
return makeCuboidWalls(region, new BlockPattern(block));
}

@@ -1121,7 +1121,7 @@ public int makeWalls(final Region region, Pattern pattern) throws MaxChangedBloc
final int maxY = region.getMaximumPoint().getBlockY();
final ArbitraryShape shape = new RegionShape(region) {
@Override
protected BlockStateHolder getMaterial(int x, int y, int z, BlockStateHolder defaultMaterial) {
protected BaseBlock getMaterial(int x, int y, int z, BaseBlock defaultMaterial) {
if (y > maxY || y < minY) {
// Put holes into the floor and ceiling by telling ArbitraryShape that the shape goes on outside the region
return defaultMaterial;
@@ -1143,7 +1143,7 @@ protected BlockStateHolder getMaterial(int x, int y, int z, BlockStateHolder def
* @return number of blocks affected
* @throws MaxChangedBlocksException thrown if too many blocks are changed
*/
public int overlayCuboidBlocks(Region region, BlockStateHolder block) throws MaxChangedBlocksException {
public <B extends BlockStateHolder<B>> int overlayCuboidBlocks(Region region, B block) throws MaxChangedBlocksException {
checkNotNull(block);

return overlayCuboidBlocks(region, new BlockPattern(block));
@@ -1831,8 +1831,8 @@ public int makeForest(BlockVector3 basePosition, int size, double density, TreeG
* @param region a region
* @return the results
*/
public List<Countable<BlockStateHolder>> getBlockDistribution(Region region, boolean fuzzy) {
BlockDistributionCounter count = new BlockDistributionCounter(this, fuzzy);
public List<Countable<BlockState>> getBlockDistribution(Region region, boolean separateStates) {
BlockDistributionCounter count = new BlockDistributionCounter(this, separateStates);
RegionVisitor visitor = new RegionVisitor(region, count);
Operations.completeBlindly(visitor);
return count.getDistribution();
@@ -1850,7 +1850,7 @@ public int makeShape(final Region region, final Vector3 zero, final Vector3 unit

final ArbitraryShape shape = new ArbitraryShape(region) {
@Override
protected BlockStateHolder getMaterial(int x, int y, int z, BlockStateHolder defaultMaterial) {
protected BaseBlock getMaterial(int x, int y, int z, BaseBlock defaultMaterial) {
final Vector3 current = Vector3.at(x, y, z);
environment.setCurrentBlock(current);
final Vector3 scaled = current.subtract(zero).divide(unit);
@@ -1861,7 +1861,7 @@ protected BlockStateHolder getMaterial(int x, int y, int z, BlockStateHolder def
return null;
}

return LegacyMapper.getInstance().getBlockFromLegacy((int) typeVariable.getValue(), (int) dataVariable.getValue());
return LegacyMapper.getInstance().getBlockFromLegacy((int) typeVariable.getValue(), (int) dataVariable.getValue()).toBaseBlock();
} catch (Exception e) {
log.log(Level.WARNING, "Failed to create shape", e);
return null;
@@ -38,9 +38,9 @@ private Blocks() {
* @param o the block
* @return true if the collection contains the given block
*/
public static boolean containsFuzzy(Collection<? extends BlockStateHolder> collection, BlockStateHolder o) {
public static <B extends BlockStateHolder<B>> boolean containsFuzzy(Collection<? extends BlockStateHolder<?>> collection, B o) {
// Allow masked data in the searchBlocks to match various types
for (BlockStateHolder b : collection) {
for (BlockStateHolder<?> b : collection) {
if (b.equalsFuzzy(o)) {
return true;
}
@@ -40,7 +40,6 @@
*/
public class NavigationCommands {

@SuppressWarnings("unused")
private final WorldEdit worldEdit;

/**
@@ -62,7 +62,6 @@
import com.sk89q.worldedit.util.command.binding.Switch;
import com.sk89q.worldedit.util.command.binding.Text;
import com.sk89q.worldedit.util.command.parametric.Optional;
import com.sk89q.worldedit.world.block.BlockStateHolder;

import java.util.ArrayList;
import java.util.List;
@@ -57,7 +57,8 @@
import com.sk89q.worldedit.util.formatting.StyledFragment;
import com.sk89q.worldedit.util.formatting.component.CommandListBox;
import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.item.ItemTypes;
import com.sk89q.worldedit.world.storage.ChunkStore;

@@ -638,7 +639,7 @@ public void count(Player player, LocalSession session, EditSession editSession,
context.setSession(session);
context.setRestricted(false);

Set<BlockStateHolder> searchBlocks = we.getBlockFactory().parseFromListInput(args.getString(0), context);
Set<BaseBlock> searchBlocks = we.getBlockFactory().parseFromListInput(args.getString(0), context);
int count = editSession.countBlocks(session.getSelection(player.getWorld()), searchBlocks);
player.print("Counted: " + count);
}
@@ -659,14 +660,14 @@ public void count(Player player, LocalSession session, EditSession editSession,
public void distr(Player player, LocalSession session, EditSession editSession, CommandContext args) throws WorldEditException, CommandException {

int size;
boolean useData = args.hasFlag('d');
List<Countable<BlockStateHolder>> distribution;
boolean separateStates = args.hasFlag('d');
List<Countable<BlockState>> distribution;

if (args.hasFlag('c')) {
// TODO: Update for new clipboard
throw new CommandException("Needs to be re-written again");
} else {
distribution = editSession.getBlockDistribution(session.getSelection(player.getWorld()), !useData);
distribution = editSession.getBlockDistribution(session.getSelection(player.getWorld()), separateStates);
size = session.getSelection(player.getWorld()).getArea();
}

@@ -677,10 +678,10 @@ public void distr(Player player, LocalSession session, EditSession editSession,

player.print("# total blocks: " + size);

for (Countable<BlockStateHolder> c : distribution) {
for (Countable<BlockState> c : distribution) {
String name = c.getID().getBlockType().getName();
String str;
if (useData) {
if (separateStates) {
str = String.format("%-7s (%.3f%%) %s #%s",
String.valueOf(c.getAmount()),
c.getAmount() / (double) size * 100,
Oops, something went wrong.

0 comments on commit f4ed48b

Please sign in to comment.