diff --git a/build.gradle b/build.gradle index 496b8987a..9d91915c1 100644 --- a/build.gradle +++ b/build.gradle @@ -21,7 +21,7 @@ buildscript { configurations.all { resolutionStrategy { - force 'com.google.guava:guava:20.0' + force 'com.google.guava:guava:21.0' force 'org.ow2.asm:asm:6.0_BETA' } } diff --git a/worldedit-bukkit/build.gradle b/worldedit-bukkit/build.gradle index 447f3f447..5c1a39cd9 100644 --- a/worldedit-bukkit/build.gradle +++ b/worldedit-bukkit/build.gradle @@ -3,7 +3,6 @@ apply plugin: 'idea' apply plugin: 'maven' repositories { - mavenLocal() maven { url "https://hub.spigotmc.org/nexus/content/groups/public" } } diff --git a/worldedit-core/build.gradle b/worldedit-core/build.gradle index ac79454fd..57a5eb2ca 100644 --- a/worldedit-core/build.gradle +++ b/worldedit-core/build.gradle @@ -9,7 +9,7 @@ dependencies { compile 'com.sk89q:jchronic:0.2.4a' compile 'com.google.code.findbugs:jsr305:1.3.9' compile 'com.thoughtworks.paranamer:paranamer:2.6' - compile 'com.google.code.gson:gson:2.2.4' + compile 'com.google.code.gson:gson:2.8.0' compile 'com.sk89q.lib:jlibnoise:1.0.0' //compile 'net.sf.trove4j:trove4j:3.0.3' testCompile 'org.mockito:mockito-core:1.9.0-rc1' diff --git a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java index bcca8274a..19f730755 100644 --- a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java +++ b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java @@ -117,7 +117,7 @@ public class MobSpawnerBlock extends BaseBlock implements TileEntityBlock { @Override public CompoundTag getNbtData() { - Map values = new HashMap(); + Map values = new HashMap<>(); values.put("EntityId", new StringTag(mobType)); values.put("Delay", new ShortTag(delay)); values.put("SpawnCount", new ShortTag(spawnCount)); diff --git a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SignBlock.java b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SignBlock.java index d9d209a44..809bdfd3e 100644 --- a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SignBlock.java +++ b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/SignBlock.java @@ -92,7 +92,7 @@ public class SignBlock extends BaseBlock implements TileEntityBlock { @Override public CompoundTag getNbtData() { - Map values = new HashMap(); + Map values = new HashMap<>(); values.put("Text1", new StringTag(text[0])); values.put("Text2", new StringTag(text[1])); values.put("Text3", new StringTag(text[2])); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java index 6ec84dfcc..c69d1c3a0 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/EditSession.java @@ -107,6 +107,7 @@ 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; @@ -1785,7 +1786,7 @@ public class EditSession implements Extent { return null; } - return new BaseBlock((int) typeVariable.getValue(), (int) dataVariable.getValue()); + return LegacyMapper.getInstance().getBlockFromLegacy((int) typeVariable.getValue(), (int) dataVariable.getValue()); } catch (Exception e) { log.log(Level.WARNING, "Failed to create shape", e); return null; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/PlayerDirection.java b/worldedit-core/src/main/java/com/sk89q/worldedit/PlayerDirection.java index 92bed02f2..2a82fea88 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/PlayerDirection.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/PlayerDirection.java @@ -28,24 +28,22 @@ import com.sk89q.worldedit.util.Direction; */ public enum PlayerDirection { - NORTH(new Vector(0, 0, -1), new Vector(-1, 0, 0), true), - NORTH_EAST((new Vector(1, 0, -1)).normalize(), (new Vector(-1, 0, -1)).normalize(), false), - EAST(new Vector(1, 0, 0), new Vector(0, 0, -1), true), - SOUTH_EAST((new Vector(1, 0, 1)).normalize(), (new Vector(1, 0, -1)).normalize(), false), - SOUTH(new Vector(0, 0, 1), new Vector(1, 0, 0), true), - SOUTH_WEST((new Vector(-1, 0, 1)).normalize(), (new Vector(1, 0, 1)).normalize(), false), - WEST(new Vector(-1, 0, 0), new Vector(0, 0, 1), true), - NORTH_WEST((new Vector(-1, 0, -1)).normalize(), (new Vector(-1, 0, 1)).normalize(), false), - UP(new Vector(0, 1, 0), new Vector(0, 0, 1), true), - DOWN(new Vector(0, -1, 0), new Vector(0, 0, 1), true); + NORTH(new Vector(0, 0, -1), true), + NORTH_EAST((new Vector(1, 0, -1)).normalize(), false), + EAST(new Vector(1, 0, 0), true), + SOUTH_EAST((new Vector(1, 0, 1)).normalize(), false), + SOUTH(new Vector(0, 0, 1), true), + SOUTH_WEST((new Vector(-1, 0, 1)).normalize(), false), + WEST(new Vector(-1, 0, 0), true), + NORTH_WEST((new Vector(-1, 0, -1)).normalize(), false), + UP(new Vector(0, 1, 0), true), + DOWN(new Vector(0, -1, 0), true); private final Vector dir; - private final Vector leftDir; private final boolean isOrthogonal; - PlayerDirection(Vector vec, Vector leftDir, boolean isOrthogonal) { + PlayerDirection(Vector vec, boolean isOrthogonal) { this.dir = vec; - this.leftDir = leftDir; this.isOrthogonal = isOrthogonal; } @@ -53,11 +51,6 @@ public enum PlayerDirection { return dir; } - @Deprecated - public Vector leftVector() { - return leftDir; - } - public boolean isOrthogonal() { return isOrthogonal; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java index a3ebc113d..f8da3fc28 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BaseBlock.java @@ -83,25 +83,6 @@ public class BaseBlock implements BlockStateHolder, TileEntityBlock { this.nbtData = nbtData; } - /** - * Construct a block with the given ID and data value. - * - * @param id ID value - * @param data data value - */ - @Deprecated - public BaseBlock(int id, int data) { - try { - this.blockState = LegacyMapper.getInstance().getBlockFromLegacy(id, data); - if (this.blockState == null) { - this.blockState = BlockTypes.AIR.getDefaultState(); - } - } catch (Exception e) { - System.out.println(id); - e.printStackTrace(); - } - } - /** * Create a clone of another block. * diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockID.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockID.java index c9f382617..0e0fd917d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockID.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockID.java @@ -28,81 +28,64 @@ import com.sk89q.worldedit.world.block.BlockTypes; */ @Deprecated public final class BlockID { - public static final int SAPLING = 6; - public static final int BED = 26; - public static final int POWERED_RAIL = 27; // GOLDEN_RAIL - public static final int DETECTOR_RAIL = 28; - public static final int LONG_GRASS = 31; // TALLGRASS - public static final int DEAD_BUSH = 32; // DEADBUSH - public static final int PISTON_EXTENSION = 34; // PISTON_HEAD - public static final int YELLOW_FLOWER = 37; - public static final int RED_FLOWER = 38; - public static final int BROWN_MUSHROOM = 39; - public static final int RED_MUSHROOM = 40; - public static final int STEP = 44; // STONE_SLAB - public static final int TORCH = 50; - public static final int REDSTONE_WIRE = 55; - public static final int CROPS = 59; // WHEAT - public static final int SIGN_POST = 63; // STANDING_SIGN - public static final int WOODEN_DOOR = 64; // WOODEN_DOOR - public static final int LADDER = 65; - public static final int MINECART_TRACKS = 66; // RAIL - public static final int WALL_SIGN = 68; - public static final int LEVER = 69; - public static final int STONE_PRESSURE_PLATE = 70; - public static final int IRON_DOOR = 71; - public static final int WOODEN_PRESSURE_PLATE = 72; - public static final int REDSTONE_TORCH_OFF = 75; // UNLIT_REDSTONE_TORCH - public static final int REDSTONE_TORCH_ON = 76; // LIT_REDSTONE_TORCH - public static final int STONE_BUTTON = 77; - public static final int SNOW = 78; // SNOW_LAYER - public static final int CACTUS = 81; - public static final int REED = 83; // REEDS - public static final int FENCE = 85; - public static final int SLOW_SAND = 88; // SOUL_SAND - public static final int CAKE_BLOCK = 92; // CAKE - public static final int REDSTONE_REPEATER_OFF = 93; // UNPOWERED_REPEATER - public static final int REDSTONE_REPEATER_ON = 94; // POWERED_REPEATER - public static final int TRAP_DOOR = 96; // TRAPDOOR - public static final int PUMPKIN_STEM = 104; - public static final int MELON_STEM = 105; - public static final int VINE = 106; - public static final int FENCE_GATE = 107; - public static final int LILY_PAD = 111; // WATERLILY - public static final int NETHER_WART = 115; - public static final int ENCHANTMENT_TABLE = 116; // ENCHANTING_TABLE - public static final int BREWING_STAND = 117; - public static final int CAULDRON = 118; - public static final int END_PORTAL_FRAME = 120; - public static final int WOODEN_STEP = 126; // WOODEN_SLAB - public static final int COCOA_PLANT = 127; // COCOA - public static final int TRIPWIRE_HOOK = 131; - public static final int TRIPWIRE = 132; - public static final int COBBLESTONE_WALL = 139; - public static final int FLOWER_POT = 140; - public static final int CARROTS = 141; - public static final int POTATOES = 142; - public static final int WOODEN_BUTTON = 143; - public static final int HEAD = 144; // SKULL - public static final int ANVIL = 145; - public static final int PRESSURE_PLATE_LIGHT = 147; // LIGHT_WEIGHTED_PRESSURE_PLATE - public static final int PRESSURE_PLATE_HEAVY = 148; // HEAVY_WEIGHTED_PRESSURE_PLATE - public static final int COMPARATOR_OFF = 149; // UNPOWERED_COMPARATOR - public static final int COMPARATOR_ON = 150; // COMPARATOR - public static final int DAYLIGHT_SENSOR = 151; // DAYLIGHT_DETECTOR - public static final int HOPPER = 154; - public static final int ACTIVATOR_RAIL = 157; - public static final int IRON_TRAP_DOOR = 167; - public static final int CARPET = 171; - public static final int DOUBLE_PLANT = 175; - public static final int STANDING_BANNER = 176; - public static final int WALL_BANNER = 177; - public static final int STEP2 = 182; - public static final int SPRUCE_DOOR = 193; - public static final int BIRCH_DOOR = 194; - public static final int JUNGLE_DOOR = 195; - public static final int ACACIA_DOOR = 196; - public static final int DARK_OAK_DOOR = 197; + static final int SAPLING = 6; + static final int POWERED_RAIL = 27; // GOLDEN_RAIL + static final int DETECTOR_RAIL = 28; + static final int LONG_GRASS = 31; // TALLGRASS + static final int DEAD_BUSH = 32; // DEADBUSH + static final int PISTON_EXTENSION = 34; // PISTON_HEAD + static final int YELLOW_FLOWER = 37; + static final int RED_FLOWER = 38; + static final int BROWN_MUSHROOM = 39; + static final int RED_MUSHROOM = 40; + static final int TORCH = 50; + static final int REDSTONE_WIRE = 55; + static final int CROPS = 59; // WHEAT + static final int SIGN_POST = 63; // STANDING_SIGN + static final int WOODEN_DOOR = 64; // WOODEN_DOOR + static final int LADDER = 65; + static final int MINECART_TRACKS = 66; // RAIL + static final int WALL_SIGN = 68; + static final int LEVER = 69; + static final int STONE_PRESSURE_PLATE = 70; + static final int IRON_DOOR = 71; + static final int WOODEN_PRESSURE_PLATE = 72; + static final int REDSTONE_TORCH_OFF = 75; // UNLIT_REDSTONE_TORCH + static final int REDSTONE_TORCH_ON = 76; // LIT_REDSTONE_TORCH + static final int STONE_BUTTON = 77; + static final int CACTUS = 81; + static final int REED = 83; // REEDS + static final int CAKE_BLOCK = 92; // CAKE + static final int REDSTONE_REPEATER_OFF = 93; // UNPOWERED_REPEATER + static final int REDSTONE_REPEATER_ON = 94; // POWERED_REPEATER + static final int TRAP_DOOR = 96; // TRAPDOOR + static final int PUMPKIN_STEM = 104; + static final int MELON_STEM = 105; + static final int VINE = 106; + static final int NETHER_WART = 115; + static final int COCOA_PLANT = 127; // COCOA + static final int TRIPWIRE_HOOK = 131; + static final int TRIPWIRE = 132; + static final int FLOWER_POT = 140; + static final int CARROTS = 141; + static final int POTATOES = 142; + static final int WOODEN_BUTTON = 143; + static final int ANVIL = 145; + static final int PRESSURE_PLATE_LIGHT = 147; // LIGHT_WEIGHTED_PRESSURE_PLATE + static final int PRESSURE_PLATE_HEAVY = 148; // HEAVY_WEIGHTED_PRESSURE_PLATE + static final int COMPARATOR_OFF = 149; // UNPOWERED_COMPARATOR + static final int COMPARATOR_ON = 150; // COMPARATOR + static final int ACTIVATOR_RAIL = 157; + static final int IRON_TRAP_DOOR = 167; + static final int CARPET = 171; + static final int DOUBLE_PLANT = 175; + static final int STANDING_BANNER = 176; + static final int WALL_BANNER = 177; + static final int SPRUCE_DOOR = 193; + static final int BIRCH_DOOR = 194; + static final int JUNGLE_DOOR = 195; + static final int ACACIA_DOOR = 196; + static final int DARK_OAK_DOOR = 197; private BlockID() { } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockType.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockType.java index 8175bb278..d21635cf5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockType.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/BlockType.java @@ -19,10 +19,7 @@ package com.sk89q.worldedit.blocks; -import static com.google.common.base.Preconditions.checkNotNull; - import com.sk89q.worldedit.PlayerDirection; -import com.sk89q.worldedit.world.block.BlockStateHolder; import java.util.HashMap; import java.util.Map; @@ -37,95 +34,6 @@ public enum BlockType { ; - /** - * HashSet for centralTopLimit. - */ - private static final Map centralTopLimit = new HashMap<>(); - static { - centralTopLimit.put(BlockID.BED, 0.5625); - centralTopLimit.put(BlockID.BREWING_STAND, 0.875); - centralTopLimit.put(BlockID.CAKE_BLOCK, 0.4375); - for (int data = 6; data < 16; ++data) { - centralTopLimit.put(-16*BlockID.CAKE_BLOCK-data, 0.0); - } - centralTopLimit.put(BlockID.CAULDRON, 0.3125); - centralTopLimit.put(BlockID.COCOA_PLANT, 0.750); - centralTopLimit.put(BlockID.ENCHANTMENT_TABLE, 0.75); - for (int data = 0; data < 16; ++data) { - if ((data & 4) != 0) { - centralTopLimit.put(-16*BlockID.END_PORTAL_FRAME-data, 1.0); - } else { - centralTopLimit.put(-16*BlockID.END_PORTAL_FRAME-data, 0.8125); - } - centralTopLimit.put(-16*BlockID.HEAD-data, 0.75); - } - // Heads on the floor are lower - centralTopLimit.put(-16*BlockID.HEAD-1, 0.5); - centralTopLimit.put(-16*BlockID.HEAD-9, 0.5); - centralTopLimit.put(BlockID.FENCE, 1.5); - for (int data = 0; data < 8; ++data) { - centralTopLimit.put(-16*BlockID.STEP-data, 0.5); - centralTopLimit.put(-16*BlockID.WOODEN_STEP-data, 0.5); - centralTopLimit.put(-16*BlockID.STEP2-data, 0.5); - centralTopLimit.put(-16*BlockID.SNOW-data, 0.125*data); - centralTopLimit.put(-16*BlockID.SNOW-(data+8), 0.125*data); - } - centralTopLimit.put(BlockID.LILY_PAD, 0.015625); - centralTopLimit.put(BlockID.REDSTONE_REPEATER_ON, .125); - centralTopLimit.put(BlockID.REDSTONE_REPEATER_OFF, .125); - for (int data = 0; data < 4; ++data) { - centralTopLimit.put(-16*BlockID.TRAP_DOOR-(data+ 0), 0.1875); // closed lower trap doors - centralTopLimit.put(-16*BlockID.TRAP_DOOR-(data+ 4), 0.0); // opened lower trap doors - centralTopLimit.put(-16*BlockID.TRAP_DOOR-(data+ 8), 1.0); // closed upper trap doors - centralTopLimit.put(-16*BlockID.TRAP_DOOR-(data+12), 0.0); // opened upper trap doors - - centralTopLimit.put(-16*BlockID.FENCE_GATE-(data+ 0), 1.5); - centralTopLimit.put(-16*BlockID.FENCE_GATE-(data+ 4), 0.0); - centralTopLimit.put(-16*BlockID.FENCE_GATE-(data+ 8), 1.5); - centralTopLimit.put(-16*BlockID.FENCE_GATE-(data+12), 0.0); - } - centralTopLimit.put(BlockID.SLOW_SAND, 0.875); - centralTopLimit.put(BlockID.COBBLESTONE_WALL, 1.5); - centralTopLimit.put(BlockID.FLOWER_POT, 0.375); - centralTopLimit.put(BlockID.COMPARATOR_OFF, .125); - centralTopLimit.put(BlockID.COMPARATOR_ON, .125); - centralTopLimit.put(BlockID.DAYLIGHT_SENSOR, 0.375); - centralTopLimit.put(BlockID.HOPPER, 0.625); - - // Some default values to be used if no data value is given - centralTopLimit.put(BlockID.HEAD, 0.75); - centralTopLimit.put(BlockID.TRAP_DOOR, 1.0); - centralTopLimit.put(BlockID.FENCE_GATE, 1.5); - } - - /** - * Returns the y offset a player falls to when falling onto the top of a block at xp+0.5/zp+0.5. - * - * @param id the block ID - * @param data the block data value - * @return the y offset - */ - public static double centralTopLimit(int id, int data) { - if (centralTopLimit.containsKey(-16*id-data)) - return centralTopLimit.get(-16*id-data); - - if (centralTopLimit.containsKey(id)) - return centralTopLimit.get(id); - - return 1; - } - - /** - * Returns the y offset a player falls to when falling onto the top of a block at xp+0.5/zp+0.5. - * - * @param block the block - * @return the y offset - */ - public static double centralTopLimit(BlockStateHolder block) { - checkNotNull(block); - return centralTopLimit(block.getBlockType().getLegacyId(), 0); - } - private static final Map dataAttachments = new HashMap<>(); private static final Map nonDataAttachments = new HashMap<>(); static { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java index 284550e93..edc6282a7 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/ClipboardCommands.java @@ -221,32 +221,6 @@ public class ClipboardCommands { player.print("The clipboard copy has been flipped."); } - @Command( - aliases = { "/load" }, - usage = "", - desc = "Load a schematic into your clipboard", - min = 0, - max = 1 - ) - @Deprecated - @CommandPermissions("worldedit.clipboard.load") - public void load(Actor actor) { - actor.printError("This command is no longer used. See //schematic load."); - } - - @Command( - aliases = { "/save" }, - usage = "", - desc = "Save a schematic into your clipboard", - min = 0, - max = 1 - ) - @Deprecated - @CommandPermissions("worldedit.clipboard.save") - public void save(Actor actor) { - actor.printError("This command is no longer used. See //schematic save."); - } - @Command( aliases = { "clearclipboard" }, usage = "", diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java index b007ea2eb..affa4b491 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java @@ -87,7 +87,6 @@ public class SchematicCommands { desc = "Load a schematic into your clipboard", min = 1, max = 2 ) - @Deprecated @CommandPermissions({ "worldedit.clipboard.load", "worldedit.schematic.load" }) public void load(Player player, LocalSession session, @Optional("sponge") String formatName, String filename) throws FilenameException { LocalConfiguration config = worldEdit.getConfiguration(); @@ -131,7 +130,6 @@ public class SchematicCommands { desc = "Save a schematic into your clipboard", min = 1, max = 2 ) - @Deprecated @CommandPermissions({ "worldedit.clipboard.save", "worldedit.schematic.save" }) public void save(Player player, LocalSession session, @Optional("sponge") String formatName, String filename) throws CommandException, WorldEditException { LocalConfiguration config = worldEdit.getConfiguration(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java index 41a495c40..4372b65b6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/AbstractPlayerActor.java @@ -23,7 +23,6 @@ import com.sk89q.worldedit.PlayerDirection; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.blocks.BaseBlock; -import com.sk89q.worldedit.blocks.BlockType; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.internal.cui.CUIEvent; @@ -112,9 +111,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { if (free == 2) { if (y - 1 != origY) { - final Vector pos = new Vector(x, y - 2, z); - final BlockState state = world.getBlock(pos); - setPosition(new Vector(x + 0.5, y - 2 + BlockType.centralTopLimit(state), z + 0.5)); + setPosition(new Vector(x + 0.5, y - 2 + 1, z + 0.5)); } return; @@ -135,7 +132,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { final Vector pos = new Vector(x, y, z); final BlockState id = world.getBlock(pos); if (id.getBlockType().getMaterial().isMovementBlocker()) { - setPosition(new Vector(x + 0.5, y + BlockType.centralTopLimit(id), z + 0.5)); + setPosition(new Vector(x + 0.5, y + 1, z + 0.5)); return; } @@ -178,7 +175,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { return false; } - setPosition(platform.add(0.5, BlockType.centralTopLimit(block), 0.5)); + setPosition(platform.add(0.5, 1, 0.5)); return true; } } @@ -218,7 +215,7 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { // Don't want to end up in lava if (type != BlockTypes.AIR && type != BlockTypes.LAVA) { // Found a block! - setPosition(platform.add(0.5, BlockType.centralTopLimit(block), 0.5)); + setPosition(platform.add(0.5, 1, 0.5)); return true; } @@ -301,7 +298,10 @@ public abstract class AbstractPlayerActor implements Actor, Player, Cloneable { @Override public void floatAt(int x, int y, int z, boolean alwaysGlass) { try { - getLocation().getExtent().setBlock(new Vector(x, y - 1, z), BlockTypes.GLASS.getDefaultState()); + Vector spot = new Vector(x, y - 1, z); + if (!getLocation().getExtent().getBlock(spot).getBlockType().getMaterial().isMovementBlocker()) { + getLocation().getExtent().setBlock(spot, BlockTypes.GLASS.getDefaultState()); + } } catch (WorldEditException e) { e.printStackTrace(); } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java index 1bd8607b0..0907753a4 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/Direction.java @@ -53,7 +53,7 @@ public enum Direction { private final Vector direction; private final int flags; - private Direction(Vector vector, int flags) { + Direction(Vector vector, int flags) { this.direction = vector.normalize(); this.flags = flags; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/Closer.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/Closer.java index 2872aa48f..26ef6a0f9 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/Closer.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/Closer.java @@ -102,7 +102,8 @@ public final class Closer implements Closeable { public RuntimeException rethrow(Throwable e) throws IOException { thrown = e; Throwables.propagateIfPossible(e, IOException.class); - throw Throwables.propagate(e); + Throwables.throwIfUnchecked(e); + throw new RuntimeException(e); } /** @@ -124,7 +125,8 @@ public final class Closer implements Closeable { thrown = e; Throwables.propagateIfPossible(e, IOException.class); Throwables.propagateIfPossible(e, declaredType); - throw Throwables.propagate(e); + Throwables.throwIfUnchecked(e); + throw new RuntimeException(e); } /** @@ -147,7 +149,8 @@ public final class Closer implements Closeable { thrown = e; Throwables.propagateIfPossible(e, IOException.class); Throwables.propagateIfPossible(e, declaredType1, declaredType2); - throw Throwables.propagate(e); + Throwables.throwIfUnchecked(e); + throw new RuntimeException(e); } /** diff --git a/worldedit-core/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java b/worldedit-core/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java index 2b9a50013..5cc3c1086 100644 --- a/worldedit-core/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java +++ b/worldedit-core/src/test/java/com/sk89q/minecraft/util/commands/CommandContextTest.java @@ -42,7 +42,7 @@ public class CommandContextTest { @Before public void setUpTest() { try { - firstCommand = new CommandContext(firstCmdString, new HashSet(Arrays.asList('o', 'w'))); + firstCommand = new CommandContext(firstCmdString, new HashSet<>(Arrays.asList('o', 'w'))); } catch (CommandException e) { log.log(Level.WARNING, "Error", e); fail("Unexpected exception when creating CommandContext"); @@ -52,7 +52,7 @@ public class CommandContextTest { @Test(expected = CommandException.class) public void testInvalidFlags() throws CommandException { final String failingCommand = "herpderp -opw testers"; - new CommandContext(failingCommand, new HashSet(Arrays.asList('o', 'w'))); + new CommandContext(failingCommand, new HashSet<>(Arrays.asList('o', 'w'))); } @Test diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBiomeRegistry.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBiomeRegistry.java index 96efd1fe8..06a11ea76 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBiomeRegistry.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeBiomeRegistry.java @@ -39,7 +39,7 @@ class ForgeBiomeRegistry implements BiomeRegistry { @Override public List getBiomes() { - List list = new ArrayList(); + List list = new ArrayList<>(); for (Biome biome : Biome.REGISTRY) { list.add(new BaseBiome(Biome.getIdForBiome(biome))); } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java index 2c0b8e234..2eb66bf14 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgePlatform.java @@ -85,7 +85,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform { @Override public List getWorlds() { WorldServer[] worlds = DimensionManager.getWorlds(); - List ret = new ArrayList(worlds.length); + List ret = new ArrayList<>(worlds.length); for (WorldServer world : worlds) { ret.add(new ForgeWorld(world)); } @@ -164,7 +164,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform { @Override public Map getCapabilities() { - Map capabilities = new EnumMap(Capability.class); + Map capabilities = new EnumMap<>(Capability.class); capabilities.put(Capability.CONFIGURATION, Preference.PREFER_OTHERS); capabilities.put(Capability.WORLDEDIT_CUI, Preference.NORMAL); capabilities.put(Capability.GAME_HOOKS, Preference.NORMAL); @@ -176,7 +176,7 @@ class ForgePlatform extends AbstractPlatform implements MultiUserPlatform { @Override public Collection getConnectedUsers() { - List users = new ArrayList(); + List users = new ArrayList<>(); PlayerList scm = server.getPlayerList(); for (EntityPlayerMP entity : scm.getPlayers()) { if (entity != null) { diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/NBTConverter.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/NBTConverter.java index aef3956f4..0992d3d4f 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/NBTConverter.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/NBTConverter.java @@ -205,7 +205,7 @@ final class NBTConverter { public static ListTag fromNative(NBTTagList other) { other = other.copy(); - List list = new ArrayList(); + List list = new ArrayList<>(); Class listClass = StringTag.class; int tags = other.tagCount(); for (int i = 0; i < tags; i++) { @@ -243,7 +243,7 @@ final class NBTConverter { public static CompoundTag fromNative(NBTTagCompound other) { Set tags = other.getKeySet(); - Map map = new HashMap(); + Map map = new HashMap<>(); for (String tagName : tags) { map.put(tagName, fromNative(other.getTag(tagName))); } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ThreadSafeCache.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ThreadSafeCache.java index 6f3b4182d..a52233564 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ThreadSafeCache.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ThreadSafeCache.java @@ -55,7 +55,7 @@ public class ThreadSafeCache { long now = System.currentTimeMillis(); if (now - lastRefresh > REFRESH_DELAY) { - Set onlineIds = new HashSet(); + Set onlineIds = new HashSet<>(); MinecraftServer server = FMLCommonHandler.instance().getMinecraftServerInstance(); if (server == null || server.getPlayerList() == null) { @@ -67,7 +67,7 @@ public class ThreadSafeCache { } } - this.onlineIds = new CopyOnWriteArraySet(onlineIds); + this.onlineIds = new CopyOnWriteArraySet<>(onlineIds); lastRefresh = now; } diff --git a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/net/LeftClickAirEventMessage.java b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/net/LeftClickAirEventMessage.java index 7273439a3..1e3b2b20e 100644 --- a/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/net/LeftClickAirEventMessage.java +++ b/worldedit-forge/src/main/java/com/sk89q/worldedit/forge/net/LeftClickAirEventMessage.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ - package com.sk89q.worldedit.forge.net; +package com.sk89q.worldedit.forge.net; import com.sk89q.worldedit.forge.ForgeWorldEdit; import io.netty.buffer.ByteBuf; @@ -32,13 +32,8 @@ public class LeftClickAirEventMessage implements IMessage { @Override public IMessage onMessage(LeftClickAirEventMessage message, final MessageContext ctx) { - ctx.getServerHandler().player.mcServer.addScheduledTask(new Runnable() { - - @Override - public void run() { - ForgeWorldEdit.inst.onPlayerInteract(new PlayerInteractEvent.LeftClickEmpty(ctx.getServerHandler().player)); - } - }); + ctx.getServerHandler().player.mcServer.addScheduledTask( + () -> ForgeWorldEdit.inst.onPlayerInteract(new PlayerInteractEvent.LeftClickEmpty(ctx.getServerHandler().player))); return null; }