Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-07 20:10:06 +01:00
Moved Spout plugin to separate Maven profile.
This was done so that WorldEdit doesn't break during compilation out of the blue. To compile WorldEdit with spout, use "mvn -Pspout".
Dieser Commit ist enthalten in:
Ursprung
1ba6825124
Commit
417c9a2137
54
pom.xml
54
pom.xml
@ -96,18 +96,6 @@
|
||||
<scope>compile</scope>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spout</groupId>
|
||||
<artifactId>spoutapi</artifactId>
|
||||
<version>dev-SNAPSHOT</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spout</groupId>
|
||||
<artifactId>vanilla</artifactId>
|
||||
<version>1.3.2-SNAPSHOT</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<distributionManagement>
|
||||
<site>
|
||||
@ -272,4 +260,46 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>spout</id>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spout</groupId>
|
||||
<artifactId>spoutapi</artifactId>
|
||||
<version>dev-SNAPSHOT</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spout</groupId>
|
||||
<artifactId>vanilla</artifactId>
|
||||
<version>1.3.2-SNAPSHOT</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-sources</id>
|
||||
<phase>generate-sources</phase>
|
||||
<goals>
|
||||
<goal>add-source</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<sources>
|
||||
<source>${basedir}/src/spout/java</source>
|
||||
</sources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</profile>
|
||||
</profiles>
|
||||
</project>
|
||||
|
@ -1,167 +1,167 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
/**
|
||||
* List of block IDs.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public final class BlockID {
|
||||
public static final int AIR = 0;
|
||||
public static final int STONE = 1;
|
||||
public static final int GRASS = 2;
|
||||
public static final int DIRT = 3;
|
||||
public static final int COBBLESTONE = 4;
|
||||
public static final int WOOD = 5;
|
||||
public static final int SAPLING = 6;
|
||||
public static final int BEDROCK = 7;
|
||||
public static final int WATER = 8;
|
||||
public static final int STATIONARY_WATER = 9;
|
||||
public static final int LAVA = 10;
|
||||
public static final int STATIONARY_LAVA = 11;
|
||||
public static final int SAND = 12;
|
||||
public static final int GRAVEL = 13;
|
||||
public static final int GOLD_ORE = 14;
|
||||
public static final int IRON_ORE = 15;
|
||||
public static final int COAL_ORE = 16;
|
||||
public static final int LOG = 17;
|
||||
public static final int LEAVES = 18;
|
||||
public static final int SPONGE = 19;
|
||||
public static final int GLASS = 20;
|
||||
public static final int LAPIS_LAZULI_ORE = 21;
|
||||
public static final int LAPIS_LAZULI_BLOCK = 22;
|
||||
public static final int DISPENSER = 23;
|
||||
public static final int SANDSTONE = 24;
|
||||
public static final int NOTE_BLOCK = 25;
|
||||
public static final int BED = 26;
|
||||
public static final int POWERED_RAIL = 27;
|
||||
public static final int DETECTOR_RAIL = 28;
|
||||
public static final int PISTON_STICKY_BASE = 29;
|
||||
public static final int WEB = 30;
|
||||
public static final int LONG_GRASS = 31;
|
||||
public static final int DEAD_BUSH = 32;
|
||||
public static final int PISTON_BASE = 33;
|
||||
public static final int PISTON_EXTENSION = 34;
|
||||
public static final int CLOTH = 35;
|
||||
public static final int PISTON_MOVING_PIECE = 36;
|
||||
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 GOLD_BLOCK = 41;
|
||||
public static final int IRON_BLOCK = 42;
|
||||
public static final int DOUBLE_STEP = 43;
|
||||
public static final int STEP = 44;
|
||||
public static final int BRICK = 45;
|
||||
public static final int TNT = 46;
|
||||
public static final int BOOKCASE = 47;
|
||||
public static final int MOSSY_COBBLESTONE = 48;
|
||||
public static final int OBSIDIAN = 49;
|
||||
public static final int TORCH = 50;
|
||||
public static final int FIRE = 51;
|
||||
public static final int MOB_SPAWNER = 52;
|
||||
public static final int WOODEN_STAIRS = 53;
|
||||
public static final int OAK_WOOD_STAIRS = 53;
|
||||
public static final int CHEST = 54;
|
||||
public static final int REDSTONE_WIRE = 55;
|
||||
public static final int DIAMOND_ORE = 56;
|
||||
public static final int DIAMOND_BLOCK = 57;
|
||||
public static final int WORKBENCH = 58;
|
||||
public static final int CROPS = 59;
|
||||
public static final int SOIL = 60;
|
||||
public static final int FURNACE = 61;
|
||||
public static final int BURNING_FURNACE = 62;
|
||||
public static final int SIGN_POST = 63;
|
||||
public static final int WOODEN_DOOR = 64;
|
||||
public static final int LADDER = 65;
|
||||
public static final int MINECART_TRACKS = 66;
|
||||
public static final int COBBLESTONE_STAIRS = 67;
|
||||
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_ORE = 73;
|
||||
public static final int GLOWING_REDSTONE_ORE = 74;
|
||||
public static final int REDSTONE_TORCH_OFF = 75;
|
||||
public static final int REDSTONE_TORCH_ON = 76;
|
||||
public static final int STONE_BUTTON = 77;
|
||||
public static final int SNOW = 78;
|
||||
public static final int ICE = 79;
|
||||
public static final int SNOW_BLOCK = 80;
|
||||
public static final int CACTUS = 81;
|
||||
public static final int CLAY = 82;
|
||||
public static final int REED = 83;
|
||||
public static final int JUKEBOX = 84;
|
||||
public static final int FENCE = 85;
|
||||
public static final int PUMPKIN = 86;
|
||||
public static final int NETHERSTONE = 87;
|
||||
public static final int NETHERRACK = 87;
|
||||
public static final int SLOW_SAND = 88;
|
||||
public static final int LIGHTSTONE = 89;
|
||||
public static final int PORTAL = 90;
|
||||
public static final int JACKOLANTERN = 91;
|
||||
public static final int CAKE_BLOCK = 92;
|
||||
public static final int REDSTONE_REPEATER_OFF = 93;
|
||||
public static final int REDSTONE_REPEATER_ON = 94;
|
||||
public static final int LOCKED_CHEST = 95;
|
||||
public static final int TRAP_DOOR = 96;
|
||||
public static final int SILVERFISH_BLOCK = 97;
|
||||
public static final int STONE_BRICK = 98;
|
||||
public static final int BROWN_MUSHROOM_CAP = 99;
|
||||
public static final int RED_MUSHROOM_CAP = 100;
|
||||
public static final int IRON_BARS = 101;
|
||||
public static final int GLASS_PANE = 102;
|
||||
public static final int MELON_BLOCK = 103;
|
||||
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 BRICK_STAIRS = 108;
|
||||
public static final int STONE_BRICK_STAIRS = 109;
|
||||
public static final int MYCELIUM = 110;
|
||||
public static final int LILY_PAD = 111;
|
||||
public static final int NETHER_BRICK = 112;
|
||||
public static final int NETHER_BRICK_FENCE = 113;
|
||||
public static final int NETHER_BRICK_STAIRS = 114;
|
||||
public static final int NETHER_WART = 115;
|
||||
public static final int ENCHANTMENT_TABLE = 116;
|
||||
public static final int BREWING_STAND = 117;
|
||||
public static final int CAULDRON = 118;
|
||||
public static final int END_PORTAL = 119;
|
||||
public static final int END_PORTAL_FRAME = 120;
|
||||
public static final int END_STONE = 121;
|
||||
public static final int DRAGON_EGG = 122;
|
||||
public static final int REDSTONE_LAMP_OFF = 123;
|
||||
public static final int REDSTONE_LAMP_ON = 124;
|
||||
public static final int DOUBLE_WOODEN_STEP = 125;
|
||||
public static final int WOODEN_STEP = 126;
|
||||
public static final int COCOA_PLANT = 127;
|
||||
public static final int SANDSTONE_STAIRS = 128;
|
||||
public static final int EMERALD_ORE = 129;
|
||||
public static final int ENDER_CHEST = 130;
|
||||
public static final int TRIPWIRE_HOOK = 131;
|
||||
public static final int TRIPWIRE = 132;
|
||||
public static final int EMERALD_BLOCK = 133;
|
||||
public static final int SPRUCE_WOOD_STAIRS = 134;
|
||||
public static final int BIRCH_WOOD_STAIRS = 135;
|
||||
public static final int JUNGLE_WOOD_STAIRS = 136;
|
||||
}
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
/**
|
||||
* List of block IDs.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public final class BlockID {
|
||||
public static final int AIR = 0;
|
||||
public static final int STONE = 1;
|
||||
public static final int GRASS = 2;
|
||||
public static final int DIRT = 3;
|
||||
public static final int COBBLESTONE = 4;
|
||||
public static final int WOOD = 5;
|
||||
public static final int SAPLING = 6;
|
||||
public static final int BEDROCK = 7;
|
||||
public static final int WATER = 8;
|
||||
public static final int STATIONARY_WATER = 9;
|
||||
public static final int LAVA = 10;
|
||||
public static final int STATIONARY_LAVA = 11;
|
||||
public static final int SAND = 12;
|
||||
public static final int GRAVEL = 13;
|
||||
public static final int GOLD_ORE = 14;
|
||||
public static final int IRON_ORE = 15;
|
||||
public static final int COAL_ORE = 16;
|
||||
public static final int LOG = 17;
|
||||
public static final int LEAVES = 18;
|
||||
public static final int SPONGE = 19;
|
||||
public static final int GLASS = 20;
|
||||
public static final int LAPIS_LAZULI_ORE = 21;
|
||||
public static final int LAPIS_LAZULI_BLOCK = 22;
|
||||
public static final int DISPENSER = 23;
|
||||
public static final int SANDSTONE = 24;
|
||||
public static final int NOTE_BLOCK = 25;
|
||||
public static final int BED = 26;
|
||||
public static final int POWERED_RAIL = 27;
|
||||
public static final int DETECTOR_RAIL = 28;
|
||||
public static final int PISTON_STICKY_BASE = 29;
|
||||
public static final int WEB = 30;
|
||||
public static final int LONG_GRASS = 31;
|
||||
public static final int DEAD_BUSH = 32;
|
||||
public static final int PISTON_BASE = 33;
|
||||
public static final int PISTON_EXTENSION = 34;
|
||||
public static final int CLOTH = 35;
|
||||
public static final int PISTON_MOVING_PIECE = 36;
|
||||
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 GOLD_BLOCK = 41;
|
||||
public static final int IRON_BLOCK = 42;
|
||||
public static final int DOUBLE_STEP = 43;
|
||||
public static final int STEP = 44;
|
||||
public static final int BRICK = 45;
|
||||
public static final int TNT = 46;
|
||||
public static final int BOOKCASE = 47;
|
||||
public static final int MOSSY_COBBLESTONE = 48;
|
||||
public static final int OBSIDIAN = 49;
|
||||
public static final int TORCH = 50;
|
||||
public static final int FIRE = 51;
|
||||
public static final int MOB_SPAWNER = 52;
|
||||
public static final int WOODEN_STAIRS = 53;
|
||||
public static final int OAK_WOOD_STAIRS = 53;
|
||||
public static final int CHEST = 54;
|
||||
public static final int REDSTONE_WIRE = 55;
|
||||
public static final int DIAMOND_ORE = 56;
|
||||
public static final int DIAMOND_BLOCK = 57;
|
||||
public static final int WORKBENCH = 58;
|
||||
public static final int CROPS = 59;
|
||||
public static final int SOIL = 60;
|
||||
public static final int FURNACE = 61;
|
||||
public static final int BURNING_FURNACE = 62;
|
||||
public static final int SIGN_POST = 63;
|
||||
public static final int WOODEN_DOOR = 64;
|
||||
public static final int LADDER = 65;
|
||||
public static final int MINECART_TRACKS = 66;
|
||||
public static final int COBBLESTONE_STAIRS = 67;
|
||||
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_ORE = 73;
|
||||
public static final int GLOWING_REDSTONE_ORE = 74;
|
||||
public static final int REDSTONE_TORCH_OFF = 75;
|
||||
public static final int REDSTONE_TORCH_ON = 76;
|
||||
public static final int STONE_BUTTON = 77;
|
||||
public static final int SNOW = 78;
|
||||
public static final int ICE = 79;
|
||||
public static final int SNOW_BLOCK = 80;
|
||||
public static final int CACTUS = 81;
|
||||
public static final int CLAY = 82;
|
||||
public static final int REED = 83;
|
||||
public static final int JUKEBOX = 84;
|
||||
public static final int FENCE = 85;
|
||||
public static final int PUMPKIN = 86;
|
||||
public static final int NETHERSTONE = 87;
|
||||
public static final int NETHERRACK = 87;
|
||||
public static final int SLOW_SAND = 88;
|
||||
public static final int LIGHTSTONE = 89;
|
||||
public static final int PORTAL = 90;
|
||||
public static final int JACKOLANTERN = 91;
|
||||
public static final int CAKE_BLOCK = 92;
|
||||
public static final int REDSTONE_REPEATER_OFF = 93;
|
||||
public static final int REDSTONE_REPEATER_ON = 94;
|
||||
public static final int LOCKED_CHEST = 95;
|
||||
public static final int TRAP_DOOR = 96;
|
||||
public static final int SILVERFISH_BLOCK = 97;
|
||||
public static final int STONE_BRICK = 98;
|
||||
public static final int BROWN_MUSHROOM_CAP = 99;
|
||||
public static final int RED_MUSHROOM_CAP = 100;
|
||||
public static final int IRON_BARS = 101;
|
||||
public static final int GLASS_PANE = 102;
|
||||
public static final int MELON_BLOCK = 103;
|
||||
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 BRICK_STAIRS = 108;
|
||||
public static final int STONE_BRICK_STAIRS = 109;
|
||||
public static final int MYCELIUM = 110;
|
||||
public static final int LILY_PAD = 111;
|
||||
public static final int NETHER_BRICK = 112;
|
||||
public static final int NETHER_BRICK_FENCE = 113;
|
||||
public static final int NETHER_BRICK_STAIRS = 114;
|
||||
public static final int NETHER_WART = 115;
|
||||
public static final int ENCHANTMENT_TABLE = 116;
|
||||
public static final int BREWING_STAND = 117;
|
||||
public static final int CAULDRON = 118;
|
||||
public static final int END_PORTAL = 119;
|
||||
public static final int END_PORTAL_FRAME = 120;
|
||||
public static final int END_STONE = 121;
|
||||
public static final int DRAGON_EGG = 122;
|
||||
public static final int REDSTONE_LAMP_OFF = 123;
|
||||
public static final int REDSTONE_LAMP_ON = 124;
|
||||
public static final int DOUBLE_WOODEN_STEP = 125;
|
||||
public static final int WOODEN_STEP = 126;
|
||||
public static final int COCOA_PLANT = 127;
|
||||
public static final int SANDSTONE_STAIRS = 128;
|
||||
public static final int EMERALD_ORE = 129;
|
||||
public static final int ENDER_CHEST = 130;
|
||||
public static final int TRIPWIRE_HOOK = 131;
|
||||
public static final int TRIPWIRE = 132;
|
||||
public static final int EMERALD_BLOCK = 133;
|
||||
public static final int SPRUCE_WOOD_STAIRS = 134;
|
||||
public static final int BIRCH_WOOD_STAIRS = 135;
|
||||
public static final int JUNGLE_WOOD_STAIRS = 136;
|
||||
}
|
||||
|
@ -1,174 +1,174 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
/**
|
||||
* List of item IDs.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public final class ItemID {
|
||||
public static final int IRON_SHOVEL = 256;
|
||||
public static final int IRON_PICK = 257;
|
||||
public static final int IRON_AXE = 258;
|
||||
public static final int FLINT_AND_TINDER = 259;
|
||||
public static final int RED_APPLE = 260;
|
||||
public static final int BOW = 261;
|
||||
public static final int ARROW = 262;
|
||||
public static final int COAL = 263;
|
||||
public static final int DIAMOND = 264;
|
||||
public static final int IRON_BAR = 265;
|
||||
public static final int GOLD_BAR = 266;
|
||||
public static final int IRON_SWORD = 267;
|
||||
public static final int WOOD_SWORD = 268;
|
||||
public static final int WOOD_SHOVEL = 269;
|
||||
public static final int WOOD_PICKAXE = 270;
|
||||
public static final int WOOD_AXE = 271;
|
||||
public static final int STONE_SWORD = 272;
|
||||
public static final int STONE_SHOVEL = 273;
|
||||
public static final int STONE_PICKAXE = 274;
|
||||
public static final int STONE_AXE = 275;
|
||||
public static final int DIAMOND_SWORD = 276;
|
||||
public static final int DIAMOND_SHOVEL = 277;
|
||||
public static final int DIAMOND_PICKAXE = 278;
|
||||
public static final int DIAMOND_AXE = 279;
|
||||
public static final int STICK = 280;
|
||||
public static final int BOWL = 281;
|
||||
public static final int MUSHROOM_SOUP = 282;
|
||||
public static final int GOLD_SWORD = 283;
|
||||
public static final int GOLD_SHOVEL = 284;
|
||||
public static final int GOLD_PICKAXE = 285;
|
||||
public static final int GOLD_AXE = 286;
|
||||
public static final int STRING = 287;
|
||||
public static final int FEATHER = 288;
|
||||
public static final int SULPHUR = 289;
|
||||
public static final int WOOD_HOE = 290;
|
||||
public static final int STONE_HOE = 291;
|
||||
public static final int IRON_HOE = 292;
|
||||
public static final int DIAMOND_HOE = 293;
|
||||
public static final int GOLD_HOE = 294;
|
||||
public static final int SEEDS = 295;
|
||||
public static final int WHEAT = 296;
|
||||
public static final int BREAD = 297;
|
||||
public static final int LEATHER_HELMET = 298;
|
||||
public static final int LEATHER_CHEST = 299;
|
||||
public static final int LEATHER_PANTS = 300;
|
||||
public static final int LEATHER_BOOTS = 301;
|
||||
public static final int CHAINMAIL_HELMET = 302;
|
||||
public static final int CHAINMAIL_CHEST = 303;
|
||||
public static final int CHAINMAIL_PANTS = 304;
|
||||
public static final int CHAINMAIL_BOOTS = 305;
|
||||
public static final int IRON_HELMET = 306;
|
||||
public static final int IRON_CHEST = 307;
|
||||
public static final int IRON_PANTS = 308;
|
||||
public static final int IRON_BOOTS = 309;
|
||||
public static final int DIAMOND_HELMET = 310;
|
||||
public static final int DIAMOND_CHEST = 311;
|
||||
public static final int DIAMOND_PANTS = 312;
|
||||
public static final int DIAMOND_BOOTS = 313;
|
||||
public static final int GOLD_HELMET = 314;
|
||||
public static final int GOLD_CHEST = 315;
|
||||
public static final int GOLD_PANTS = 316;
|
||||
public static final int GOLD_BOOTS = 317;
|
||||
public static final int FLINT = 318;
|
||||
public static final int RAW_PORKCHOP = 319;
|
||||
public static final int COOKED_PORKCHOP = 320;
|
||||
public static final int PAINTING = 321;
|
||||
public static final int GOLD_APPLE = 322;
|
||||
public static final int SIGN = 323;
|
||||
public static final int WOODEN_DOOR_ITEM = 324;
|
||||
public static final int BUCKET = 325;
|
||||
public static final int WATER_BUCKET = 326;
|
||||
public static final int LAVA_BUCKET = 327;
|
||||
public static final int MINECART = 328;
|
||||
public static final int SADDLE = 329;
|
||||
public static final int IRON_DOOR_ITEM = 330;
|
||||
public static final int REDSTONE_DUST = 331;
|
||||
public static final int SNOWBALL = 332;
|
||||
public static final int WOOD_BOAT = 333;
|
||||
public static final int LEATHER = 334;
|
||||
public static final int MILK_BUCKET = 335;
|
||||
public static final int BRICK_BAR = 336;
|
||||
public static final int CLAY_BALL = 337;
|
||||
public static final int SUGAR_CANE_ITEM = 338;
|
||||
public static final int PAPER = 339;
|
||||
public static final int BOOK = 340;
|
||||
public static final int SLIME_BALL = 341;
|
||||
public static final int STORAGE_MINECART = 342;
|
||||
public static final int POWERED_MINECART = 343;
|
||||
public static final int EGG = 344;
|
||||
public static final int COMPASS = 345;
|
||||
public static final int FISHING_ROD = 346;
|
||||
public static final int WATCH = 347;
|
||||
public static final int LIGHTSTONE_DUST = 348;
|
||||
public static final int RAW_FISH = 349;
|
||||
public static final int COOKED_FISH = 350;
|
||||
public static final int INK_SACK = 351;
|
||||
public static final int BONE = 352;
|
||||
public static final int SUGAR = 353;
|
||||
public static final int CAKE_ITEM = 354;
|
||||
public static final int BED_ITEM = 355;
|
||||
public static final int REDSTONE_REPEATER = 356;
|
||||
public static final int COOKIE = 357;
|
||||
public static final int MAP = 358;
|
||||
public static final int SHEARS = 359;
|
||||
public static final int MELON = 360;
|
||||
public static final int PUMPKIN_SEEDS = 361;
|
||||
public static final int MELON_SEEDS = 362;
|
||||
public static final int RAW_BEEF = 363;
|
||||
public static final int COOKED_BEEF = 364;
|
||||
public static final int RAW_CHICKEN = 365;
|
||||
public static final int COOKED_CHICKEN = 366;
|
||||
public static final int ROTTEN_FLESH = 367;
|
||||
public static final int ENDER_PEARL = 368;
|
||||
public static final int BLAZE_ROD = 369;
|
||||
public static final int GHAST_TEAR = 370;
|
||||
public static final int GOLD_NUGGET = 371;
|
||||
public static final int NETHER_WART_SEED = 372;
|
||||
public static final int POTION = 373;
|
||||
public static final int GLASS_BOTTLE = 374;
|
||||
public static final int SPIDER_EYE = 375;
|
||||
public static final int FERMENTED_SPIDER_EYE = 376;
|
||||
public static final int BLAZE_POWDER = 377;
|
||||
public static final int MAGMA_CREAM = 378;
|
||||
public static final int BREWING_STAND = 379;
|
||||
public static final int CAULDRON = 380;
|
||||
public static final int EYE_OF_ENDER = 381;
|
||||
public static final int GLISTERING_MELON = 382;
|
||||
public static final int SPAWN_EGG = 383;
|
||||
public static final int BOTTLE_O_ENCHANTING = 384;
|
||||
public static final int FIRE_CHARGE = 385;
|
||||
public static final int BOOK_AND_QUILL = 386;
|
||||
public static final int WRITTEN_BOOK = 387;
|
||||
public static final int EMERALD = 388;
|
||||
@Deprecated public static final int GOLD_RECORD = 2256; // deprecated, but leave it there
|
||||
@Deprecated public static final int GREEN_RECORD = 2257; // deprecated, but leave it there
|
||||
public static final int DISC_13 = 2256;
|
||||
public static final int DISC_CAT = 2257;
|
||||
public static final int DISC_BLOCKS = 2258;
|
||||
public static final int DISC_CHIRP = 2259;
|
||||
public static final int DISC_FAR = 2260;
|
||||
public static final int DISC_MALL = 2261;
|
||||
public static final int DISC_MELLOHI = 2262;
|
||||
public static final int DISC_STAL = 2263;
|
||||
public static final int DISC_STRAD = 2264;
|
||||
public static final int DISC_WARD = 2265;
|
||||
public static final int DISC_11 = 2266;
|
||||
}
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
/**
|
||||
* List of item IDs.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public final class ItemID {
|
||||
public static final int IRON_SHOVEL = 256;
|
||||
public static final int IRON_PICK = 257;
|
||||
public static final int IRON_AXE = 258;
|
||||
public static final int FLINT_AND_TINDER = 259;
|
||||
public static final int RED_APPLE = 260;
|
||||
public static final int BOW = 261;
|
||||
public static final int ARROW = 262;
|
||||
public static final int COAL = 263;
|
||||
public static final int DIAMOND = 264;
|
||||
public static final int IRON_BAR = 265;
|
||||
public static final int GOLD_BAR = 266;
|
||||
public static final int IRON_SWORD = 267;
|
||||
public static final int WOOD_SWORD = 268;
|
||||
public static final int WOOD_SHOVEL = 269;
|
||||
public static final int WOOD_PICKAXE = 270;
|
||||
public static final int WOOD_AXE = 271;
|
||||
public static final int STONE_SWORD = 272;
|
||||
public static final int STONE_SHOVEL = 273;
|
||||
public static final int STONE_PICKAXE = 274;
|
||||
public static final int STONE_AXE = 275;
|
||||
public static final int DIAMOND_SWORD = 276;
|
||||
public static final int DIAMOND_SHOVEL = 277;
|
||||
public static final int DIAMOND_PICKAXE = 278;
|
||||
public static final int DIAMOND_AXE = 279;
|
||||
public static final int STICK = 280;
|
||||
public static final int BOWL = 281;
|
||||
public static final int MUSHROOM_SOUP = 282;
|
||||
public static final int GOLD_SWORD = 283;
|
||||
public static final int GOLD_SHOVEL = 284;
|
||||
public static final int GOLD_PICKAXE = 285;
|
||||
public static final int GOLD_AXE = 286;
|
||||
public static final int STRING = 287;
|
||||
public static final int FEATHER = 288;
|
||||
public static final int SULPHUR = 289;
|
||||
public static final int WOOD_HOE = 290;
|
||||
public static final int STONE_HOE = 291;
|
||||
public static final int IRON_HOE = 292;
|
||||
public static final int DIAMOND_HOE = 293;
|
||||
public static final int GOLD_HOE = 294;
|
||||
public static final int SEEDS = 295;
|
||||
public static final int WHEAT = 296;
|
||||
public static final int BREAD = 297;
|
||||
public static final int LEATHER_HELMET = 298;
|
||||
public static final int LEATHER_CHEST = 299;
|
||||
public static final int LEATHER_PANTS = 300;
|
||||
public static final int LEATHER_BOOTS = 301;
|
||||
public static final int CHAINMAIL_HELMET = 302;
|
||||
public static final int CHAINMAIL_CHEST = 303;
|
||||
public static final int CHAINMAIL_PANTS = 304;
|
||||
public static final int CHAINMAIL_BOOTS = 305;
|
||||
public static final int IRON_HELMET = 306;
|
||||
public static final int IRON_CHEST = 307;
|
||||
public static final int IRON_PANTS = 308;
|
||||
public static final int IRON_BOOTS = 309;
|
||||
public static final int DIAMOND_HELMET = 310;
|
||||
public static final int DIAMOND_CHEST = 311;
|
||||
public static final int DIAMOND_PANTS = 312;
|
||||
public static final int DIAMOND_BOOTS = 313;
|
||||
public static final int GOLD_HELMET = 314;
|
||||
public static final int GOLD_CHEST = 315;
|
||||
public static final int GOLD_PANTS = 316;
|
||||
public static final int GOLD_BOOTS = 317;
|
||||
public static final int FLINT = 318;
|
||||
public static final int RAW_PORKCHOP = 319;
|
||||
public static final int COOKED_PORKCHOP = 320;
|
||||
public static final int PAINTING = 321;
|
||||
public static final int GOLD_APPLE = 322;
|
||||
public static final int SIGN = 323;
|
||||
public static final int WOODEN_DOOR_ITEM = 324;
|
||||
public static final int BUCKET = 325;
|
||||
public static final int WATER_BUCKET = 326;
|
||||
public static final int LAVA_BUCKET = 327;
|
||||
public static final int MINECART = 328;
|
||||
public static final int SADDLE = 329;
|
||||
public static final int IRON_DOOR_ITEM = 330;
|
||||
public static final int REDSTONE_DUST = 331;
|
||||
public static final int SNOWBALL = 332;
|
||||
public static final int WOOD_BOAT = 333;
|
||||
public static final int LEATHER = 334;
|
||||
public static final int MILK_BUCKET = 335;
|
||||
public static final int BRICK_BAR = 336;
|
||||
public static final int CLAY_BALL = 337;
|
||||
public static final int SUGAR_CANE_ITEM = 338;
|
||||
public static final int PAPER = 339;
|
||||
public static final int BOOK = 340;
|
||||
public static final int SLIME_BALL = 341;
|
||||
public static final int STORAGE_MINECART = 342;
|
||||
public static final int POWERED_MINECART = 343;
|
||||
public static final int EGG = 344;
|
||||
public static final int COMPASS = 345;
|
||||
public static final int FISHING_ROD = 346;
|
||||
public static final int WATCH = 347;
|
||||
public static final int LIGHTSTONE_DUST = 348;
|
||||
public static final int RAW_FISH = 349;
|
||||
public static final int COOKED_FISH = 350;
|
||||
public static final int INK_SACK = 351;
|
||||
public static final int BONE = 352;
|
||||
public static final int SUGAR = 353;
|
||||
public static final int CAKE_ITEM = 354;
|
||||
public static final int BED_ITEM = 355;
|
||||
public static final int REDSTONE_REPEATER = 356;
|
||||
public static final int COOKIE = 357;
|
||||
public static final int MAP = 358;
|
||||
public static final int SHEARS = 359;
|
||||
public static final int MELON = 360;
|
||||
public static final int PUMPKIN_SEEDS = 361;
|
||||
public static final int MELON_SEEDS = 362;
|
||||
public static final int RAW_BEEF = 363;
|
||||
public static final int COOKED_BEEF = 364;
|
||||
public static final int RAW_CHICKEN = 365;
|
||||
public static final int COOKED_CHICKEN = 366;
|
||||
public static final int ROTTEN_FLESH = 367;
|
||||
public static final int ENDER_PEARL = 368;
|
||||
public static final int BLAZE_ROD = 369;
|
||||
public static final int GHAST_TEAR = 370;
|
||||
public static final int GOLD_NUGGET = 371;
|
||||
public static final int NETHER_WART_SEED = 372;
|
||||
public static final int POTION = 373;
|
||||
public static final int GLASS_BOTTLE = 374;
|
||||
public static final int SPIDER_EYE = 375;
|
||||
public static final int FERMENTED_SPIDER_EYE = 376;
|
||||
public static final int BLAZE_POWDER = 377;
|
||||
public static final int MAGMA_CREAM = 378;
|
||||
public static final int BREWING_STAND = 379;
|
||||
public static final int CAULDRON = 380;
|
||||
public static final int EYE_OF_ENDER = 381;
|
||||
public static final int GLISTERING_MELON = 382;
|
||||
public static final int SPAWN_EGG = 383;
|
||||
public static final int BOTTLE_O_ENCHANTING = 384;
|
||||
public static final int FIRE_CHARGE = 385;
|
||||
public static final int BOOK_AND_QUILL = 386;
|
||||
public static final int WRITTEN_BOOK = 387;
|
||||
public static final int EMERALD = 388;
|
||||
@Deprecated public static final int GOLD_RECORD = 2256; // deprecated, but leave it there
|
||||
@Deprecated public static final int GREEN_RECORD = 2257; // deprecated, but leave it there
|
||||
public static final int DISC_13 = 2256;
|
||||
public static final int DISC_CAT = 2257;
|
||||
public static final int DISC_BLOCKS = 2258;
|
||||
public static final int DISC_CHIRP = 2259;
|
||||
public static final int DISC_FAR = 2260;
|
||||
public static final int DISC_MALL = 2261;
|
||||
public static final int DISC_MELLOHI = 2262;
|
||||
public static final int DISC_STAL = 2263;
|
||||
public static final int DISC_STRAD = 2264;
|
||||
public static final int DISC_WARD = 2265;
|
||||
public static final int DISC_11 = 2266;
|
||||
}
|
||||
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -1,54 +1,54 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout;
|
||||
|
||||
import com.sk89q.worldedit.SessionCheck;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import org.spout.api.Engine;
|
||||
import org.spout.api.Server;
|
||||
import org.spout.api.entity.Player;
|
||||
|
||||
/**
|
||||
* Used to remove expired sessions in Bukkit.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class SessionTimer implements Runnable {
|
||||
|
||||
private WorldEdit worldEdit;
|
||||
private SessionCheck checker;
|
||||
|
||||
public SessionTimer(WorldEdit worldEdit, final Server game) {
|
||||
this.worldEdit = worldEdit;
|
||||
this.checker = new SessionCheck() {
|
||||
public boolean isOnlinePlayer(String name) {
|
||||
Player player = game.getPlayer(name, true);
|
||||
return player != null && player.isOnline();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void run() {
|
||||
worldEdit.flushExpiredSessions(checker);
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout;
|
||||
|
||||
import com.sk89q.worldedit.SessionCheck;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import org.spout.api.Engine;
|
||||
import org.spout.api.Server;
|
||||
import org.spout.api.entity.Player;
|
||||
|
||||
/**
|
||||
* Used to remove expired sessions in Bukkit.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class SessionTimer implements Runnable {
|
||||
|
||||
private WorldEdit worldEdit;
|
||||
private SessionCheck checker;
|
||||
|
||||
public SessionTimer(WorldEdit worldEdit, final Server game) {
|
||||
this.worldEdit = worldEdit;
|
||||
this.checker = new SessionCheck() {
|
||||
public boolean isOnlinePlayer(String name) {
|
||||
Player player = game.getPlayer(name, true);
|
||||
return player != null && player.isOnline();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void run() {
|
||||
worldEdit.flushExpiredSessions(checker);
|
||||
}
|
||||
|
||||
}
|
@ -1,126 +1,126 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout;
|
||||
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.PlayerNeededException;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.bags.BlockBag;
|
||||
import org.spout.api.chat.style.ChatStyle;
|
||||
import org.spout.api.command.CommandSource;
|
||||
import org.spout.api.entity.Player;
|
||||
|
||||
public class SpoutCommandSender extends LocalPlayer {
|
||||
private CommandSource sender;
|
||||
@SuppressWarnings("unused")
|
||||
private WorldEditPlugin plugin;
|
||||
|
||||
public SpoutCommandSender(WorldEditPlugin plugin, ServerInterface server, CommandSource sender) {
|
||||
super(server);
|
||||
this.plugin = plugin;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return sender.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printRaw(String msg) {
|
||||
sender.sendRawMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printDebug(String msg) {
|
||||
sender.sendMessage(ChatStyle.GRAY, msg);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String msg) {
|
||||
sender.sendMessage(ChatStyle.PURPLE, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printError(String msg) {
|
||||
sender.sendMessage(ChatStyle.RED, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return sender.getGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String perm) {
|
||||
return sender.hasPermission(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return sender instanceof Player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemInHand() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldVector getPosition() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalWorld getWorld() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPitch() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getYaw() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveItem(int type, int amt) {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockBag getInventoryBlockBag() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
}
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout;
|
||||
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.PlayerNeededException;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.bags.BlockBag;
|
||||
import org.spout.api.chat.style.ChatStyle;
|
||||
import org.spout.api.command.CommandSource;
|
||||
import org.spout.api.entity.Player;
|
||||
|
||||
public class SpoutCommandSender extends LocalPlayer {
|
||||
private CommandSource sender;
|
||||
@SuppressWarnings("unused")
|
||||
private WorldEditPlugin plugin;
|
||||
|
||||
public SpoutCommandSender(WorldEditPlugin plugin, ServerInterface server, CommandSource sender) {
|
||||
super(server);
|
||||
this.plugin = plugin;
|
||||
this.sender = sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return sender.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printRaw(String msg) {
|
||||
sender.sendRawMessage(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printDebug(String msg) {
|
||||
sender.sendMessage(ChatStyle.GRAY, msg);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String msg) {
|
||||
sender.sendMessage(ChatStyle.PURPLE, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printError(String msg) {
|
||||
sender.sendMessage(ChatStyle.RED, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return sender.getGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String perm) {
|
||||
return sender.hasPermission(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return sender instanceof Player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemInHand() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldVector getPosition() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalWorld getWorld() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPitch() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getYaw() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveItem(int type, int amt) {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockBag getInventoryBlockBag() {
|
||||
throw new PlayerNeededException();
|
||||
}
|
||||
}
|
@ -1,158 +1,158 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout;
|
||||
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.bags.BlockBag;
|
||||
import com.sk89q.worldedit.cui.CUIEvent;
|
||||
|
||||
import org.spout.api.Client;
|
||||
import org.spout.api.chat.style.ChatStyle;
|
||||
import org.spout.api.component.components.TransformComponent;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
import org.spout.api.inventory.Inventory;
|
||||
import org.spout.api.inventory.ItemStack;
|
||||
import org.spout.api.entity.Player;
|
||||
import org.spout.vanilla.component.inventory.window.Window;
|
||||
import org.spout.vanilla.component.living.Human;
|
||||
import org.spout.vanilla.material.VanillaMaterial;
|
||||
import org.spout.vanilla.material.VanillaMaterials;
|
||||
|
||||
public class SpoutPlayer extends LocalPlayer {
|
||||
private Player player;
|
||||
@SuppressWarnings("unused")
|
||||
private WorldEditPlugin plugin;
|
||||
|
||||
public SpoutPlayer(WorldEditPlugin plugin, ServerInterface server, Player player) {
|
||||
super(server);
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemInHand() {
|
||||
if (player.has(Human.class)) {
|
||||
return ((VanillaMaterial) player.get(Human.class).getInventory().getQuickbar()
|
||||
.getCurrentItem().getMaterial()).getMinecraftId();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return player.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldVector getPosition() {
|
||||
Point loc = player.getTransform().getPosition();
|
||||
return new WorldVector(SpoutUtil.getLocalWorld(loc.getWorld()),
|
||||
loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPitch() {
|
||||
return player.getTransform().getPitch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getYaw() {
|
||||
return player.getTransform().getYaw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveItem(int type, int amt) {
|
||||
if (player.has(Human.class)) {
|
||||
player.get(Human.class).getInventory().add(new ItemStack(VanillaMaterials.getMaterial((short) type), amt));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printRaw(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage(part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage(ChatStyle.PINK, part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printDebug(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage(ChatStyle.GRAY, part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printError(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage(ChatStyle.RED, part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
||||
TransformComponent component = player.getTransform();
|
||||
player.teleport(SpoutUtil.toPoint(player.getWorld(), pos));
|
||||
component.setPitch(pitch);
|
||||
component.setYaw(yaw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return player.getGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockBag getInventoryBlockBag() {
|
||||
return new SpoutPlayerBlockBag(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String perm) {
|
||||
return player.hasPermission(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalWorld getWorld() {
|
||||
return SpoutUtil.getLocalWorld(player.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatchCUIEvent(CUIEvent event) {
|
||||
player.getSession().send(player.getSession().getEngine() instanceof Client, new WorldEditCUIMessage(event));
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout;
|
||||
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.bags.BlockBag;
|
||||
import com.sk89q.worldedit.cui.CUIEvent;
|
||||
|
||||
import org.spout.api.Client;
|
||||
import org.spout.api.chat.style.ChatStyle;
|
||||
import org.spout.api.component.components.TransformComponent;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
import org.spout.api.inventory.Inventory;
|
||||
import org.spout.api.inventory.ItemStack;
|
||||
import org.spout.api.entity.Player;
|
||||
import org.spout.vanilla.component.inventory.window.Window;
|
||||
import org.spout.vanilla.component.living.Human;
|
||||
import org.spout.vanilla.material.VanillaMaterial;
|
||||
import org.spout.vanilla.material.VanillaMaterials;
|
||||
|
||||
public class SpoutPlayer extends LocalPlayer {
|
||||
private Player player;
|
||||
@SuppressWarnings("unused")
|
||||
private WorldEditPlugin plugin;
|
||||
|
||||
public SpoutPlayer(WorldEditPlugin plugin, ServerInterface server, Player player) {
|
||||
super(server);
|
||||
this.plugin = plugin;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemInHand() {
|
||||
if (player.has(Human.class)) {
|
||||
return ((VanillaMaterial) player.get(Human.class).getInventory().getQuickbar()
|
||||
.getCurrentItem().getMaterial()).getMinecraftId();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return player.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorldVector getPosition() {
|
||||
Point loc = player.getTransform().getPosition();
|
||||
return new WorldVector(SpoutUtil.getLocalWorld(loc.getWorld()),
|
||||
loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getPitch() {
|
||||
return player.getTransform().getPitch();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getYaw() {
|
||||
return player.getTransform().getYaw();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveItem(int type, int amt) {
|
||||
if (player.has(Human.class)) {
|
||||
player.get(Human.class).getInventory().add(new ItemStack(VanillaMaterials.getMaterial((short) type), amt));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printRaw(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage(part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void print(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage(ChatStyle.PINK, part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printDebug(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage(ChatStyle.GRAY, part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void printError(String msg) {
|
||||
for (String part : msg.split("\n")) {
|
||||
player.sendMessage(ChatStyle.RED, part);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPosition(Vector pos, float pitch, float yaw) {
|
||||
TransformComponent component = player.getTransform();
|
||||
player.teleport(SpoutUtil.toPoint(player.getWorld(), pos));
|
||||
component.setPitch(pitch);
|
||||
component.setYaw(yaw);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getGroups() {
|
||||
return player.getGroups();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockBag getInventoryBlockBag() {
|
||||
return new SpoutPlayerBlockBag(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String perm) {
|
||||
return player.hasPermission(perm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocalWorld getWorld() {
|
||||
return SpoutUtil.getLocalWorld(player.getWorld());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispatchCUIEvent(CUIEvent event) {
|
||||
player.getSession().send(player.getSession().getEngine() instanceof Client, new WorldEditCUIMessage(event));
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
}
|
@ -1,269 +1,269 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout;
|
||||
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.bags.BlockBag;
|
||||
import com.sk89q.worldedit.bags.BlockBagException;
|
||||
import com.sk89q.worldedit.bags.OutOfBlocksException;
|
||||
import com.sk89q.worldedit.bags.OutOfSpaceException;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import org.spout.api.inventory.Inventory;
|
||||
import org.spout.api.inventory.ItemStack;
|
||||
import org.spout.api.material.Material;
|
||||
import org.spout.api.entity.Player;
|
||||
import org.spout.vanilla.component.inventory.PlayerInventory;
|
||||
import org.spout.vanilla.component.living.Human;
|
||||
import org.spout.vanilla.material.VanillaMaterials;
|
||||
import org.spout.vanilla.util.VanillaPlayerUtil;
|
||||
|
||||
public class SpoutPlayerBlockBag extends BlockBag {
|
||||
/**
|
||||
* Player instance.
|
||||
*/
|
||||
private Player player;
|
||||
/**
|
||||
* The player's inventory;
|
||||
*/
|
||||
private ItemInfo items;
|
||||
|
||||
private static class ItemInfo {
|
||||
ItemStack[] inventory;
|
||||
boolean includesFullInventory;
|
||||
|
||||
public ItemInfo(ItemStack[] inventory, boolean full) {
|
||||
this.inventory = inventory;
|
||||
this.includesFullInventory = full;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public SpoutPlayerBlockBag(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads inventory on first use.
|
||||
*/
|
||||
private void loadInventory() {
|
||||
if (items == null) {
|
||||
items = getViewableItems(player);
|
||||
}
|
||||
}
|
||||
|
||||
private ItemInfo getViewableItems(Player player) {
|
||||
boolean includesFullInventory = true;
|
||||
ItemStack[] items;
|
||||
Human human = player.get(Human.class);
|
||||
PlayerInventory inv = human.getInventory();
|
||||
if (human.isCreative()) {
|
||||
includesFullInventory = false;
|
||||
items = new ItemStack[inv.getQuickbar().size()];
|
||||
} else {
|
||||
items = new ItemStack[inv.getQuickbar().size() + inv.getMain().size()];
|
||||
}
|
||||
int index = 0;
|
||||
for (; index < inv.getQuickbar().size(); ++index) {
|
||||
items[index] = inv.getQuickbar().get(index);
|
||||
}
|
||||
|
||||
if (!human.isCreative()) {
|
||||
for (int i = 0; i < inv.getMain().size() && index < items.length; ++i) {
|
||||
items[index++] = inv.getMain().get(i);
|
||||
}
|
||||
}
|
||||
return new ItemInfo(items, includesFullInventory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the player.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a block.
|
||||
*
|
||||
* @param item
|
||||
*/
|
||||
@Override
|
||||
public void fetchItem(BaseItem item) throws BlockBagException {
|
||||
final short id = (short)item.getType();
|
||||
final short damage = item.getData();
|
||||
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
|
||||
assert(amount == 1);
|
||||
Material mat = VanillaMaterials.getMaterial(id, damage);
|
||||
|
||||
if (mat == VanillaMaterials.AIR) {
|
||||
throw new IllegalArgumentException("Can't fetch air block");
|
||||
}
|
||||
|
||||
loadInventory();
|
||||
|
||||
boolean found = false;
|
||||
|
||||
for (int slot = 0; slot < items.inventory.length; ++slot) {
|
||||
ItemStack spoutItem = items.inventory[slot];
|
||||
|
||||
if (spoutItem == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!spoutItem.getMaterial().equals(mat)) {
|
||||
// Type id or damage value doesn't fit
|
||||
continue;
|
||||
}
|
||||
|
||||
int currentAmount = spoutItem.getAmount();
|
||||
if (currentAmount < 0) {
|
||||
// Unlimited
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentAmount > 1) {
|
||||
spoutItem.setAmount(currentAmount - 1);
|
||||
found = true;
|
||||
} else {
|
||||
items.inventory[slot] = null;
|
||||
found = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
throw new OutOfBlocksException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a block.
|
||||
*
|
||||
* @param item
|
||||
*/
|
||||
@Override
|
||||
public void storeItem(BaseItem item) throws BlockBagException {
|
||||
final short id = (short) item.getType();
|
||||
final short damage = item.getData();
|
||||
Material mat = VanillaMaterials.getMaterial(id, damage);
|
||||
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
|
||||
assert(amount <= mat.getMaxStackSize());
|
||||
|
||||
if (mat == VanillaMaterials.AIR) {
|
||||
throw new IllegalArgumentException("Can't store air block");
|
||||
}
|
||||
|
||||
loadInventory();
|
||||
|
||||
int freeSlot = -1;
|
||||
|
||||
for (int slot = 0; slot < items.inventory.length; ++slot) {
|
||||
ItemStack spoutItem = items.inventory[slot];
|
||||
|
||||
if (spoutItem == null) {
|
||||
// Delay using up a free slot until we know there are no stacks
|
||||
// of this item to merge into
|
||||
|
||||
if (freeSlot == -1) {
|
||||
freeSlot = slot;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!spoutItem.getMaterial().equals(mat)) {
|
||||
// Type id or damage value doesn't fit
|
||||
continue;
|
||||
}
|
||||
|
||||
int currentAmount = spoutItem.getAmount();
|
||||
if (currentAmount < 0) {
|
||||
// Unlimited
|
||||
return;
|
||||
}
|
||||
if (currentAmount >= mat.getMaxStackSize()) {
|
||||
// Full stack
|
||||
continue;
|
||||
}
|
||||
|
||||
int spaceLeft = mat.getMaxStackSize() - currentAmount;
|
||||
if (spaceLeft >= amount) {
|
||||
spoutItem.setAmount(currentAmount + amount);
|
||||
return;
|
||||
}
|
||||
|
||||
spoutItem.setAmount(mat.getMaxStackSize());
|
||||
amount -= spaceLeft;
|
||||
}
|
||||
|
||||
if (freeSlot > -1) {
|
||||
items.inventory[freeSlot] = new ItemStack(mat, amount);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new OutOfSpaceException(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush any changes. This is called at the end.
|
||||
*/
|
||||
@Override
|
||||
public void flushChanges() {
|
||||
if (items != null) {
|
||||
PlayerInventory inv = player.get(Human.class).getInventory();
|
||||
for (int i = 0; i < inv.getQuickbar().size(); i++) {
|
||||
inv.getQuickbar().set(i, items.inventory[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < inv.getMain().size(); ++i) {
|
||||
inv.getMain().set(i, items.inventory[inv.getQuickbar().size() + i]);
|
||||
}
|
||||
items = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a position to be used a source.
|
||||
* (TODO: Figure out what this does)
|
||||
* @param pos
|
||||
*/
|
||||
@Override
|
||||
public void addSourcePosition(WorldVector pos) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a position to be used a source.
|
||||
* (TODO: Figure out what this does)
|
||||
* @param pos
|
||||
*/
|
||||
@Override
|
||||
public void addSingleSourcePosition(WorldVector pos) {
|
||||
}
|
||||
}
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout;
|
||||
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import com.sk89q.worldedit.bags.BlockBag;
|
||||
import com.sk89q.worldedit.bags.BlockBagException;
|
||||
import com.sk89q.worldedit.bags.OutOfBlocksException;
|
||||
import com.sk89q.worldedit.bags.OutOfSpaceException;
|
||||
import com.sk89q.worldedit.blocks.BaseItem;
|
||||
import com.sk89q.worldedit.blocks.BaseItemStack;
|
||||
import com.sk89q.worldedit.blocks.BlockID;
|
||||
import org.spout.api.inventory.Inventory;
|
||||
import org.spout.api.inventory.ItemStack;
|
||||
import org.spout.api.material.Material;
|
||||
import org.spout.api.entity.Player;
|
||||
import org.spout.vanilla.component.inventory.PlayerInventory;
|
||||
import org.spout.vanilla.component.living.Human;
|
||||
import org.spout.vanilla.material.VanillaMaterials;
|
||||
import org.spout.vanilla.util.VanillaPlayerUtil;
|
||||
|
||||
public class SpoutPlayerBlockBag extends BlockBag {
|
||||
/**
|
||||
* Player instance.
|
||||
*/
|
||||
private Player player;
|
||||
/**
|
||||
* The player's inventory;
|
||||
*/
|
||||
private ItemInfo items;
|
||||
|
||||
private static class ItemInfo {
|
||||
ItemStack[] inventory;
|
||||
boolean includesFullInventory;
|
||||
|
||||
public ItemInfo(ItemStack[] inventory, boolean full) {
|
||||
this.inventory = inventory;
|
||||
this.includesFullInventory = full;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the object.
|
||||
*
|
||||
* @param player
|
||||
*/
|
||||
public SpoutPlayerBlockBag(Player player) {
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads inventory on first use.
|
||||
*/
|
||||
private void loadInventory() {
|
||||
if (items == null) {
|
||||
items = getViewableItems(player);
|
||||
}
|
||||
}
|
||||
|
||||
private ItemInfo getViewableItems(Player player) {
|
||||
boolean includesFullInventory = true;
|
||||
ItemStack[] items;
|
||||
Human human = player.get(Human.class);
|
||||
PlayerInventory inv = human.getInventory();
|
||||
if (human.isCreative()) {
|
||||
includesFullInventory = false;
|
||||
items = new ItemStack[inv.getQuickbar().size()];
|
||||
} else {
|
||||
items = new ItemStack[inv.getQuickbar().size() + inv.getMain().size()];
|
||||
}
|
||||
int index = 0;
|
||||
for (; index < inv.getQuickbar().size(); ++index) {
|
||||
items[index] = inv.getQuickbar().get(index);
|
||||
}
|
||||
|
||||
if (!human.isCreative()) {
|
||||
for (int i = 0; i < inv.getMain().size() && index < items.length; ++i) {
|
||||
items[index++] = inv.getMain().get(i);
|
||||
}
|
||||
}
|
||||
return new ItemInfo(items, includesFullInventory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the player.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a block.
|
||||
*
|
||||
* @param item
|
||||
*/
|
||||
@Override
|
||||
public void fetchItem(BaseItem item) throws BlockBagException {
|
||||
final short id = (short)item.getType();
|
||||
final short damage = item.getData();
|
||||
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
|
||||
assert(amount == 1);
|
||||
Material mat = VanillaMaterials.getMaterial(id, damage);
|
||||
|
||||
if (mat == VanillaMaterials.AIR) {
|
||||
throw new IllegalArgumentException("Can't fetch air block");
|
||||
}
|
||||
|
||||
loadInventory();
|
||||
|
||||
boolean found = false;
|
||||
|
||||
for (int slot = 0; slot < items.inventory.length; ++slot) {
|
||||
ItemStack spoutItem = items.inventory[slot];
|
||||
|
||||
if (spoutItem == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!spoutItem.getMaterial().equals(mat)) {
|
||||
// Type id or damage value doesn't fit
|
||||
continue;
|
||||
}
|
||||
|
||||
int currentAmount = spoutItem.getAmount();
|
||||
if (currentAmount < 0) {
|
||||
// Unlimited
|
||||
return;
|
||||
}
|
||||
|
||||
if (currentAmount > 1) {
|
||||
spoutItem.setAmount(currentAmount - 1);
|
||||
found = true;
|
||||
} else {
|
||||
items.inventory[slot] = null;
|
||||
found = true;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
throw new OutOfBlocksException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a block.
|
||||
*
|
||||
* @param item
|
||||
*/
|
||||
@Override
|
||||
public void storeItem(BaseItem item) throws BlockBagException {
|
||||
final short id = (short) item.getType();
|
||||
final short damage = item.getData();
|
||||
Material mat = VanillaMaterials.getMaterial(id, damage);
|
||||
int amount = (item instanceof BaseItemStack) ? ((BaseItemStack) item).getAmount() : 1;
|
||||
assert(amount <= mat.getMaxStackSize());
|
||||
|
||||
if (mat == VanillaMaterials.AIR) {
|
||||
throw new IllegalArgumentException("Can't store air block");
|
||||
}
|
||||
|
||||
loadInventory();
|
||||
|
||||
int freeSlot = -1;
|
||||
|
||||
for (int slot = 0; slot < items.inventory.length; ++slot) {
|
||||
ItemStack spoutItem = items.inventory[slot];
|
||||
|
||||
if (spoutItem == null) {
|
||||
// Delay using up a free slot until we know there are no stacks
|
||||
// of this item to merge into
|
||||
|
||||
if (freeSlot == -1) {
|
||||
freeSlot = slot;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!spoutItem.getMaterial().equals(mat)) {
|
||||
// Type id or damage value doesn't fit
|
||||
continue;
|
||||
}
|
||||
|
||||
int currentAmount = spoutItem.getAmount();
|
||||
if (currentAmount < 0) {
|
||||
// Unlimited
|
||||
return;
|
||||
}
|
||||
if (currentAmount >= mat.getMaxStackSize()) {
|
||||
// Full stack
|
||||
continue;
|
||||
}
|
||||
|
||||
int spaceLeft = mat.getMaxStackSize() - currentAmount;
|
||||
if (spaceLeft >= amount) {
|
||||
spoutItem.setAmount(currentAmount + amount);
|
||||
return;
|
||||
}
|
||||
|
||||
spoutItem.setAmount(mat.getMaxStackSize());
|
||||
amount -= spaceLeft;
|
||||
}
|
||||
|
||||
if (freeSlot > -1) {
|
||||
items.inventory[freeSlot] = new ItemStack(mat, amount);
|
||||
return;
|
||||
}
|
||||
|
||||
throw new OutOfSpaceException(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Flush any changes. This is called at the end.
|
||||
*/
|
||||
@Override
|
||||
public void flushChanges() {
|
||||
if (items != null) {
|
||||
PlayerInventory inv = player.get(Human.class).getInventory();
|
||||
for (int i = 0; i < inv.getQuickbar().size(); i++) {
|
||||
inv.getQuickbar().set(i, items.inventory[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < inv.getMain().size(); ++i) {
|
||||
inv.getMain().set(i, items.inventory[inv.getQuickbar().size() + i]);
|
||||
}
|
||||
items = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a position to be used a source.
|
||||
* (TODO: Figure out what this does)
|
||||
* @param pos
|
||||
*/
|
||||
@Override
|
||||
public void addSourcePosition(WorldVector pos) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a position to be used a source.
|
||||
* (TODO: Figure out what this does)
|
||||
* @param pos
|
||||
*/
|
||||
@Override
|
||||
public void addSingleSourcePosition(WorldVector pos) {
|
||||
}
|
||||
}
|
@ -1,107 +1,107 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.CommandsManager;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
import org.spout.api.Engine;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.material.Material;
|
||||
import org.spout.api.material.MaterialRegistry;
|
||||
import org.spout.api.scheduler.TaskPriority;
|
||||
import org.spout.vanilla.material.VanillaMaterial;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class SpoutServerInterface extends ServerInterface {
|
||||
public Engine game;
|
||||
public WorldEditPlugin plugin;
|
||||
private final SpoutRawCommandExecutor executor;
|
||||
private SpoutBiomeTypes biomes;
|
||||
|
||||
public SpoutServerInterface(WorldEditPlugin plugin, Engine game) {
|
||||
this.plugin = plugin;
|
||||
this.game = game;
|
||||
this.biomes = new SpoutBiomeTypes();
|
||||
this.executor = new SpoutRawCommandExecutor(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int resolveItem(String name) {
|
||||
Material mat = MaterialRegistry.get(name);
|
||||
return mat == null || !(mat instanceof VanillaMaterial) ? 0 : ((VanillaMaterial) mat).getMinecraftId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidMobType(String type) {
|
||||
return false;
|
||||
//return CreatureType.fromName(type) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
plugin.loadConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpoutBiomeTypes getBiomes() {
|
||||
return biomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int schedule(long delay, long period, Runnable task) {
|
||||
return game.getScheduler().scheduleSyncRepeatingTask(plugin, task, delay * 50, period * 50, TaskPriority.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocalWorld> getWorlds() {
|
||||
Collection<World> worlds = game.getWorlds();
|
||||
List<LocalWorld> ret = new ArrayList<LocalWorld>(worlds.size());
|
||||
|
||||
for (World world : worlds) {
|
||||
ret.add(SpoutUtil.getLocalWorld(world));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandRegistration(List<Command> commands, CommandsManager<LocalPlayer> manager) {
|
||||
for (Command command : commands) {
|
||||
org.spout.api.command.Command spoutCommand = game.getRootCommand().addSubCommand(plugin, command.aliases()[0])
|
||||
.addAlias(command.aliases()).setRawExecutor(executor)
|
||||
.setHelp("/" + command.aliases()[0] + " " + command.usage() + " - " + command.desc());
|
||||
Method cmdMethod = manager.getMethods().get(null).get(command.aliases()[0]);
|
||||
if (cmdMethod != null && cmdMethod.isAnnotationPresent(CommandPermissions.class)) {
|
||||
spoutCommand.setPermissions(false, cmdMethod.getAnnotation(CommandPermissions.class).value());
|
||||
}
|
||||
spoutCommand.closeSubCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout;
|
||||
|
||||
import com.sk89q.minecraft.util.commands.Command;
|
||||
import com.sk89q.minecraft.util.commands.CommandPermissions;
|
||||
import com.sk89q.minecraft.util.commands.CommandsManager;
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.ServerInterface;
|
||||
import org.spout.api.Engine;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.material.Material;
|
||||
import org.spout.api.material.MaterialRegistry;
|
||||
import org.spout.api.scheduler.TaskPriority;
|
||||
import org.spout.vanilla.material.VanillaMaterial;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class SpoutServerInterface extends ServerInterface {
|
||||
public Engine game;
|
||||
public WorldEditPlugin plugin;
|
||||
private final SpoutRawCommandExecutor executor;
|
||||
private SpoutBiomeTypes biomes;
|
||||
|
||||
public SpoutServerInterface(WorldEditPlugin plugin, Engine game) {
|
||||
this.plugin = plugin;
|
||||
this.game = game;
|
||||
this.biomes = new SpoutBiomeTypes();
|
||||
this.executor = new SpoutRawCommandExecutor(plugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int resolveItem(String name) {
|
||||
Material mat = MaterialRegistry.get(name);
|
||||
return mat == null || !(mat instanceof VanillaMaterial) ? 0 : ((VanillaMaterial) mat).getMinecraftId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidMobType(String type) {
|
||||
return false;
|
||||
//return CreatureType.fromName(type) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
plugin.loadConfiguration();
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpoutBiomeTypes getBiomes() {
|
||||
return biomes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int schedule(long delay, long period, Runnable task) {
|
||||
return game.getScheduler().scheduleSyncRepeatingTask(plugin, task, delay * 50, period * 50, TaskPriority.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<LocalWorld> getWorlds() {
|
||||
Collection<World> worlds = game.getWorlds();
|
||||
List<LocalWorld> ret = new ArrayList<LocalWorld>(worlds.size());
|
||||
|
||||
for (World world : worlds) {
|
||||
ret.add(SpoutUtil.getLocalWorld(world));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCommandRegistration(List<Command> commands, CommandsManager<LocalPlayer> manager) {
|
||||
for (Command command : commands) {
|
||||
org.spout.api.command.Command spoutCommand = game.getRootCommand().addSubCommand(plugin, command.aliases()[0])
|
||||
.addAlias(command.aliases()).setRawExecutor(executor)
|
||||
.setHelp("/" + command.aliases()[0] + " " + command.usage() + " - " + command.desc());
|
||||
Method cmdMethod = manager.getMethods().get(null).get(command.aliases()[0]);
|
||||
if (cmdMethod != null && cmdMethod.isAnnotationPresent(CommandPermissions.class)) {
|
||||
spoutCommand.setPermissions(false, cmdMethod.getAnnotation(CommandPermissions.class).value());
|
||||
}
|
||||
spoutCommand.closeSubCommand();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,115 +1,115 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockWorldVector;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import org.spout.api.Engine;
|
||||
import org.spout.api.Server;
|
||||
import org.spout.api.entity.Entity;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.geo.cuboid.Block;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
import org.spout.api.material.block.BlockFace;
|
||||
import org.spout.api.math.MathHelper;
|
||||
import org.spout.api.math.Vector3;
|
||||
import org.spout.api.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SpoutUtil {
|
||||
private SpoutUtil() {
|
||||
}
|
||||
|
||||
private static final Map<World, LocalWorld> wlw = new HashMap<World, LocalWorld>();
|
||||
|
||||
public static LocalWorld getLocalWorld(World w) {
|
||||
LocalWorld lw = wlw.get(w);
|
||||
if (lw == null) {
|
||||
lw = new SpoutWorld(w);
|
||||
wlw.put(w, lw);
|
||||
}
|
||||
return lw;
|
||||
}
|
||||
|
||||
public static BlockVector toVector(Block block) {
|
||||
return new BlockVector(block.getX(), block.getY(), block.getZ());
|
||||
}
|
||||
|
||||
public static BlockVector toVector(BlockFace face) {
|
||||
return toBlockVector(face.getOffset());
|
||||
}
|
||||
|
||||
public static BlockVector toBlockVector(Vector3 vector) {
|
||||
return new BlockVector(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
|
||||
public static BlockWorldVector toWorldVector(Block block) {
|
||||
return new BlockWorldVector(getLocalWorld(block.getWorld()), block.getX(), block.getY(), block.getZ());
|
||||
}
|
||||
|
||||
public static Vector toVector(Point loc) {
|
||||
return new Vector(loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
public static Vector toVector(org.spout.api.math.Vector3 vector) {
|
||||
return new Vector(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
|
||||
public static Point toPoint(WorldVector pt) {
|
||||
return new Point(toWorld(pt), (float)pt.getX(), (float)pt.getY(), (float)pt.getZ());
|
||||
}
|
||||
|
||||
public static Point toPoint(World world, Vector pt) {
|
||||
return new Point(world, (float)pt.getX(), (float)pt.getY(), (float)pt.getZ());
|
||||
}
|
||||
|
||||
public static Point center(Point loc) {
|
||||
return new Point(
|
||||
loc.getWorld(),
|
||||
MathHelper.floor(loc.getX()) + 0.5F,
|
||||
MathHelper.floor(loc.getY()) + 0.5F,
|
||||
MathHelper.floor(loc.getZ()) + 0.5F
|
||||
);
|
||||
}
|
||||
|
||||
public static Player matchSinglePlayer(Engine game, String name) {
|
||||
return game instanceof Server ? ((Server) game).getPlayer(name, false) : null;
|
||||
}
|
||||
|
||||
public static Block toBlock(BlockWorldVector pt) {
|
||||
return toWorld(pt).getBlock(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ(), WorldEditPlugin.getInstance());
|
||||
}
|
||||
|
||||
public static World toWorld(WorldVector pt) {
|
||||
return ((SpoutWorld) pt.getWorld()).getWorld();
|
||||
}
|
||||
|
||||
public static Location toLocation(Entity ent) {
|
||||
return new Location(getLocalWorld(ent.getWorld()), toVector(ent.getTransform().getPosition()), ent.getTransform().getYaw(), ent.getTransform().getPitch());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.BlockWorldVector;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.Location;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import org.spout.api.Engine;
|
||||
import org.spout.api.Server;
|
||||
import org.spout.api.entity.Entity;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.geo.cuboid.Block;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
import org.spout.api.material.block.BlockFace;
|
||||
import org.spout.api.math.MathHelper;
|
||||
import org.spout.api.math.Vector3;
|
||||
import org.spout.api.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class SpoutUtil {
|
||||
private SpoutUtil() {
|
||||
}
|
||||
|
||||
private static final Map<World, LocalWorld> wlw = new HashMap<World, LocalWorld>();
|
||||
|
||||
public static LocalWorld getLocalWorld(World w) {
|
||||
LocalWorld lw = wlw.get(w);
|
||||
if (lw == null) {
|
||||
lw = new SpoutWorld(w);
|
||||
wlw.put(w, lw);
|
||||
}
|
||||
return lw;
|
||||
}
|
||||
|
||||
public static BlockVector toVector(Block block) {
|
||||
return new BlockVector(block.getX(), block.getY(), block.getZ());
|
||||
}
|
||||
|
||||
public static BlockVector toVector(BlockFace face) {
|
||||
return toBlockVector(face.getOffset());
|
||||
}
|
||||
|
||||
public static BlockVector toBlockVector(Vector3 vector) {
|
||||
return new BlockVector(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
|
||||
public static BlockWorldVector toWorldVector(Block block) {
|
||||
return new BlockWorldVector(getLocalWorld(block.getWorld()), block.getX(), block.getY(), block.getZ());
|
||||
}
|
||||
|
||||
public static Vector toVector(Point loc) {
|
||||
return new Vector(loc.getX(), loc.getY(), loc.getZ());
|
||||
}
|
||||
|
||||
public static Vector toVector(org.spout.api.math.Vector3 vector) {
|
||||
return new Vector(vector.getX(), vector.getY(), vector.getZ());
|
||||
}
|
||||
|
||||
public static Point toPoint(WorldVector pt) {
|
||||
return new Point(toWorld(pt), (float)pt.getX(), (float)pt.getY(), (float)pt.getZ());
|
||||
}
|
||||
|
||||
public static Point toPoint(World world, Vector pt) {
|
||||
return new Point(world, (float)pt.getX(), (float)pt.getY(), (float)pt.getZ());
|
||||
}
|
||||
|
||||
public static Point center(Point loc) {
|
||||
return new Point(
|
||||
loc.getWorld(),
|
||||
MathHelper.floor(loc.getX()) + 0.5F,
|
||||
MathHelper.floor(loc.getY()) + 0.5F,
|
||||
MathHelper.floor(loc.getZ()) + 0.5F
|
||||
);
|
||||
}
|
||||
|
||||
public static Player matchSinglePlayer(Engine game, String name) {
|
||||
return game instanceof Server ? ((Server) game).getPlayer(name, false) : null;
|
||||
}
|
||||
|
||||
public static Block toBlock(BlockWorldVector pt) {
|
||||
return toWorld(pt).getBlock(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ(), WorldEditPlugin.getInstance());
|
||||
}
|
||||
|
||||
public static World toWorld(WorldVector pt) {
|
||||
return ((SpoutWorld) pt.getWorld()).getWorld();
|
||||
}
|
||||
|
||||
public static Location toLocation(Entity ent) {
|
||||
return new Location(getLocalWorld(ent.getWorld()), toVector(ent.getTransform().getPosition()), ent.getTransform().getYaw(), ent.getTransform().getPitch());
|
||||
}
|
||||
}
|
Datei-Diff unterdrückt, da er zu groß ist
Diff laden
@ -1,176 +1,176 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout;
|
||||
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import org.spout.api.Spout;
|
||||
import org.spout.api.chat.ChatArguments;
|
||||
import org.spout.api.chat.ChatSection;
|
||||
import org.spout.api.event.EventHandler;
|
||||
import org.spout.api.event.Listener;
|
||||
import org.spout.api.event.Order;
|
||||
import org.spout.api.event.player.PlayerInteractEvent;
|
||||
import org.spout.api.event.player.PlayerInteractEvent.Action;
|
||||
import org.spout.api.event.player.PlayerLeaveEvent;
|
||||
import org.spout.api.event.server.PreCommandEvent;
|
||||
import org.spout.api.event.world.WorldLoadEvent;
|
||||
import org.spout.api.generator.biome.BiomeGenerator;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
import org.spout.api.scheduler.TaskPriority;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Handles all events thrown in relation to a Player
|
||||
*/
|
||||
public class WorldEditListener implements Listener {
|
||||
/**
|
||||
* Plugin.
|
||||
*/
|
||||
private WorldEditPlugin plugin;
|
||||
|
||||
private boolean ignoreLeftClickAir = false;
|
||||
|
||||
/**
|
||||
* Construct the object;
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public WorldEditListener(WorldEditPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player leaves a server
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerLeaveEvent event) {
|
||||
plugin.getWorldEdit().markExpire(plugin.wrapPlayer(event.getPlayer()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player attempts to use a command
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@EventHandler(order = Order.EARLY)
|
||||
public void onPlayerCommandPreprocess(PreCommandEvent event) {
|
||||
|
||||
if (event.getCommand().startsWith("nowe:")) {
|
||||
event.setCommand(event.getCommand().substring(5));
|
||||
return;
|
||||
}
|
||||
|
||||
List<ChatSection> args = event.getArguments().toSections(ChatSection.SplitType.WORD);
|
||||
if (args.size() > 0) {
|
||||
String[] split = new String[args.size() + 1];
|
||||
split[0] = "/" + event.getCommand();
|
||||
for (int i = 0; i < args.size(); ++i) {
|
||||
split[i + 1] = args.get(i).getPlainString();
|
||||
}
|
||||
|
||||
String[] newSplit = plugin.getWorldEdit().commandDetection(split);
|
||||
if (!Arrays.equals(split, newSplit)) {
|
||||
event.setCommand(newSplit[0]);
|
||||
ChatArguments newArgs = new ChatArguments();
|
||||
for (int i = 1; i < newSplit.length; ++i) {
|
||||
newArgs.append(newSplit[i]);
|
||||
}
|
||||
event.setArguments(newArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player interacts
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
|
||||
final LocalPlayer player = plugin.wrapPlayer(event.getPlayer());
|
||||
final LocalWorld world = player.getWorld();
|
||||
final WorldEdit we = plugin.getWorldEdit();
|
||||
|
||||
PlayerInteractEvent.Action action = event.getAction();
|
||||
if (action == Action.LEFT_CLICK) {
|
||||
if (event.isAir() && ignoreLeftClickAir) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.isAir()) {
|
||||
final Point clickedBlock = event.getInteractedPoint();
|
||||
final WorldVector pos = new WorldVector(world, clickedBlock.getBlockX(),
|
||||
clickedBlock.getBlockY(), clickedBlock.getBlockZ());
|
||||
|
||||
|
||||
if (we.handleBlockLeftClick(player, pos)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (we.handleArmSwing(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (!event.isAir() && !ignoreLeftClickAir) {
|
||||
final int taskId = Spout.getEngine().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
ignoreLeftClickAir = false;
|
||||
}
|
||||
}, 100, TaskPriority.NORMAL);
|
||||
|
||||
if (taskId != -1) {
|
||||
ignoreLeftClickAir = true;
|
||||
}
|
||||
}
|
||||
} else if (action == Action.RIGHT_CLICK) {
|
||||
if (!event.isAir()) {
|
||||
final Point clickedBlock = event.getInteractedPoint();
|
||||
final WorldVector pos = new WorldVector(world, clickedBlock.getBlockX(),
|
||||
clickedBlock.getBlockY(), clickedBlock.getBlockZ());
|
||||
|
||||
if (we.handleBlockRightClick(player, pos)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (we.handleRightClick(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
if (event.getWorld().getGenerator() instanceof BiomeGenerator) {
|
||||
plugin.getServerInterface().getBiomes().registerBiomeTypes((BiomeGenerator) event.getWorld().getGenerator());
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout;
|
||||
|
||||
import com.sk89q.worldedit.LocalPlayer;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.WorldVector;
|
||||
import org.spout.api.Spout;
|
||||
import org.spout.api.chat.ChatArguments;
|
||||
import org.spout.api.chat.ChatSection;
|
||||
import org.spout.api.event.EventHandler;
|
||||
import org.spout.api.event.Listener;
|
||||
import org.spout.api.event.Order;
|
||||
import org.spout.api.event.player.PlayerInteractEvent;
|
||||
import org.spout.api.event.player.PlayerInteractEvent.Action;
|
||||
import org.spout.api.event.player.PlayerLeaveEvent;
|
||||
import org.spout.api.event.server.PreCommandEvent;
|
||||
import org.spout.api.event.world.WorldLoadEvent;
|
||||
import org.spout.api.generator.biome.BiomeGenerator;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
import org.spout.api.scheduler.TaskPriority;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Handles all events thrown in relation to a Player
|
||||
*/
|
||||
public class WorldEditListener implements Listener {
|
||||
/**
|
||||
* Plugin.
|
||||
*/
|
||||
private WorldEditPlugin plugin;
|
||||
|
||||
private boolean ignoreLeftClickAir = false;
|
||||
|
||||
/**
|
||||
* Construct the object;
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public WorldEditListener(WorldEditPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player leaves a server
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerLeaveEvent event) {
|
||||
plugin.getWorldEdit().markExpire(plugin.wrapPlayer(event.getPlayer()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player attempts to use a command
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@EventHandler(order = Order.EARLY)
|
||||
public void onPlayerCommandPreprocess(PreCommandEvent event) {
|
||||
|
||||
if (event.getCommand().startsWith("nowe:")) {
|
||||
event.setCommand(event.getCommand().substring(5));
|
||||
return;
|
||||
}
|
||||
|
||||
List<ChatSection> args = event.getArguments().toSections(ChatSection.SplitType.WORD);
|
||||
if (args.size() > 0) {
|
||||
String[] split = new String[args.size() + 1];
|
||||
split[0] = "/" + event.getCommand();
|
||||
for (int i = 0; i < args.size(); ++i) {
|
||||
split[i + 1] = args.get(i).getPlainString();
|
||||
}
|
||||
|
||||
String[] newSplit = plugin.getWorldEdit().commandDetection(split);
|
||||
if (!Arrays.equals(split, newSplit)) {
|
||||
event.setCommand(newSplit[0]);
|
||||
ChatArguments newArgs = new ChatArguments();
|
||||
for (int i = 1; i < newSplit.length; ++i) {
|
||||
newArgs.append(newSplit[i]);
|
||||
}
|
||||
event.setArguments(newArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a player interacts
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
@EventHandler
|
||||
public void onPlayerInteract(PlayerInteractEvent event) {
|
||||
|
||||
final LocalPlayer player = plugin.wrapPlayer(event.getPlayer());
|
||||
final LocalWorld world = player.getWorld();
|
||||
final WorldEdit we = plugin.getWorldEdit();
|
||||
|
||||
PlayerInteractEvent.Action action = event.getAction();
|
||||
if (action == Action.LEFT_CLICK) {
|
||||
if (event.isAir() && ignoreLeftClickAir) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!event.isAir()) {
|
||||
final Point clickedBlock = event.getInteractedPoint();
|
||||
final WorldVector pos = new WorldVector(world, clickedBlock.getBlockX(),
|
||||
clickedBlock.getBlockY(), clickedBlock.getBlockZ());
|
||||
|
||||
|
||||
if (we.handleBlockLeftClick(player, pos)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (we.handleArmSwing(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (!event.isAir() && !ignoreLeftClickAir) {
|
||||
final int taskId = Spout.getEngine().getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||
public void run() {
|
||||
ignoreLeftClickAir = false;
|
||||
}
|
||||
}, 100, TaskPriority.NORMAL);
|
||||
|
||||
if (taskId != -1) {
|
||||
ignoreLeftClickAir = true;
|
||||
}
|
||||
}
|
||||
} else if (action == Action.RIGHT_CLICK) {
|
||||
if (!event.isAir()) {
|
||||
final Point clickedBlock = event.getInteractedPoint();
|
||||
final WorldVector pos = new WorldVector(world, clickedBlock.getBlockX(),
|
||||
clickedBlock.getBlockY(), clickedBlock.getBlockZ());
|
||||
|
||||
if (we.handleBlockRightClick(player, pos)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (we.handleRightClick(player)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
if (event.getWorld().getGenerator() instanceof BiomeGenerator) {
|
||||
plugin.getServerInterface().getBiomes().registerBiomeTypes((BiomeGenerator) event.getWorld().getGenerator());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,359 +1,359 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.bags.BlockBag;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.spout.selections.CuboidSelection;
|
||||
import com.sk89q.worldedit.spout.selections.Polygonal2DSelection;
|
||||
import com.sk89q.worldedit.spout.selections.Selection;
|
||||
import com.sk89q.worldedit.util.YAMLConfiguration;
|
||||
import org.spout.api.Server;
|
||||
import org.spout.api.command.CommandSource;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.entity.Player;
|
||||
import org.spout.api.plugin.CommonPlugin;
|
||||
import org.spout.api.protocol.Protocol;
|
||||
import org.spout.api.scheduler.TaskPriority;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
/**
|
||||
* Plugin for Spout.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class WorldEditPlugin extends CommonPlugin {
|
||||
/**
|
||||
* The server interface that all server-related API goes through.
|
||||
*/
|
||||
private SpoutServerInterface server;
|
||||
/**
|
||||
* Main WorldEdit instance.
|
||||
*/
|
||||
private WorldEdit controller;
|
||||
|
||||
/**
|
||||
* Holds the configuration for WorldEdit.
|
||||
*/
|
||||
private YAMLConfiguration config;
|
||||
|
||||
private static WorldEditPlugin instance;
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on plugin enable.
|
||||
*/
|
||||
public void onEnable() {
|
||||
final String pluginYmlVersion = getDescription().getVersion();
|
||||
final String manifestVersion = WorldEdit.getVersion();
|
||||
|
||||
getLogger().info("WorldEdit " + pluginYmlVersion + " enabled.");
|
||||
if (!manifestVersion.equalsIgnoreCase(pluginYmlVersion)) {
|
||||
WorldEdit.setVersion(manifestVersion + " (" + pluginYmlVersion + ")");
|
||||
}
|
||||
|
||||
// Make the data folders that WorldEdit uses
|
||||
getDataFolder().mkdirs();
|
||||
|
||||
// Create the default configuration file
|
||||
createDefaultConfiguration("config.yml");
|
||||
|
||||
// Set up configuration and such, including the permissions
|
||||
// resolver
|
||||
config = new SpoutConfiguration(new YAMLProcessor(new File(getDataFolder(), "config.yml"), true), this);
|
||||
|
||||
// Load the configuration
|
||||
loadConfiguration();
|
||||
|
||||
// Setup interfaces
|
||||
server = new SpoutServerInterface(this, getEngine());
|
||||
controller = new WorldEdit(server, config);
|
||||
|
||||
// Now we can register events!
|
||||
registerEvents();
|
||||
|
||||
for (Protocol proto : Protocol.getProtocols()) {
|
||||
proto.registerPacket(WorldEditCUICodec.class, new WorldEditCUIMessageHandler(this));
|
||||
}
|
||||
|
||||
getEngine().getScheduler().scheduleAsyncRepeatingTask(this,
|
||||
new SessionTimer(controller, getServer()), 6 * 1000, 6 * 1000, TaskPriority.LOWEST);
|
||||
}
|
||||
|
||||
public Server getServer() {
|
||||
if (!(getEngine() instanceof Server)) {
|
||||
throw new IllegalStateException("WorldEdit must be running on a server for this operation!");
|
||||
}
|
||||
|
||||
return (Server) getEngine();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on plugin disable.
|
||||
*/
|
||||
public void onDisable() {
|
||||
controller.clearSessions();
|
||||
config.unload();
|
||||
getEngine().getScheduler().cancelTasks(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads and reloads all configuration.
|
||||
*/
|
||||
protected void loadConfiguration() {
|
||||
config.unload();
|
||||
config.load();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the events used by WorldEdit.
|
||||
*/
|
||||
protected void registerEvents() {
|
||||
getEngine().getEventManager().registerEvents(new WorldEditListener(this), this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a default configuration file from the .jar.
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
protected void createDefaultConfiguration(String name) {
|
||||
File actual = new File(getDataFolder(), name);
|
||||
if (!actual.exists()) {
|
||||
InputStream input =
|
||||
null;
|
||||
try {
|
||||
JarFile file = new JarFile(getFile());
|
||||
ZipEntry copy = file.getEntry("defaults/" + name);
|
||||
if (copy == null) throw new FileNotFoundException();
|
||||
input = file.getInputStream(copy);
|
||||
} 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 = 0;
|
||||
while ((length = input.read(buf)) > 0) {
|
||||
output.write(buf, 0, length);
|
||||
}
|
||||
|
||||
getLogger().info("Default configuration file written: " + name);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException ignore) {}
|
||||
|
||||
try {
|
||||
if (output != null) {
|
||||
output.close();
|
||||
}
|
||||
} catch (IOException ignore) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the session for the player.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public LocalSession getSession(Player player) {
|
||||
return controller.getSession(wrapPlayer(player));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the session for the player.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public EditSession createEditSession(Player player) {
|
||||
LocalPlayer wePlayer = wrapPlayer(player);
|
||||
LocalSession session = controller.getSession(wePlayer);
|
||||
BlockBag blockBag = session.getBlockBag(wePlayer);
|
||||
|
||||
EditSession editSession =
|
||||
new EditSession(wePlayer.getWorld(), session.getBlockChangeLimit(), blockBag);
|
||||
editSession.enableQueue();
|
||||
|
||||
return editSession;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remember an edit session.
|
||||
*
|
||||
* @param player
|
||||
* @param editSession
|
||||
*/
|
||||
public void remember(Player player, EditSession editSession) {
|
||||
LocalPlayer wePlayer = wrapPlayer(player);
|
||||
LocalSession session = controller.getSession(wePlayer);
|
||||
|
||||
session.remember(editSession);
|
||||
editSession.flushQueue();
|
||||
|
||||
controller.flushBlockBag(wePlayer, editSession);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap an operation into an EditSession.
|
||||
*
|
||||
* @param player
|
||||
* @param op
|
||||
* @throws Throwable
|
||||
*/
|
||||
public void perform(Player player, WorldEditOperation op)
|
||||
throws Throwable {
|
||||
LocalPlayer wePlayer = wrapPlayer(player);
|
||||
LocalSession session = controller.getSession(wePlayer);
|
||||
|
||||
EditSession editSession = createEditSession(player);
|
||||
try {
|
||||
op.run(session, wePlayer, editSession);
|
||||
} finally {
|
||||
remember(player, editSession);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration used by WorldEdit.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public YAMLConfiguration getLocalConfiguration() {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to wrap a Bukkit Player as a LocalPlayer.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public SpoutPlayer wrapPlayer(Player player) {
|
||||
return new SpoutPlayer(this, this.server, player);
|
||||
}
|
||||
|
||||
public LocalPlayer wrapCommandSender(CommandSource sender) {
|
||||
if (sender instanceof Player) {
|
||||
return wrapPlayer((Player) sender);
|
||||
}
|
||||
|
||||
return new SpoutCommandSender(this, this.server, sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the server interface.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public SpoutServerInterface getServerInterface() {
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get WorldEdit.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public WorldEdit getWorldEdit() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the region selection for the player.
|
||||
*
|
||||
* @param player
|
||||
* @return the selection or null if there was none
|
||||
*/
|
||||
public Selection getSelection(Player player) {
|
||||
if (player == null) {
|
||||
throw new IllegalArgumentException("Null player not allowed");
|
||||
}
|
||||
if (!player.isOnline()) {
|
||||
throw new IllegalArgumentException("Offline player not allowed");
|
||||
}
|
||||
|
||||
LocalSession session = controller.getSession(wrapPlayer(player));
|
||||
RegionSelector selector = session.getRegionSelector(SpoutUtil.getLocalWorld(player.getWorld()));
|
||||
|
||||
try {
|
||||
Region region = selector.getRegion();
|
||||
World world = ((SpoutWorld) session.getSelectionWorld()).getWorld();
|
||||
|
||||
if (region instanceof CuboidRegion) {
|
||||
return new CuboidSelection(world, selector, (CuboidRegion) region);
|
||||
} else if (region instanceof Polygonal2DRegion) {
|
||||
return new Polygonal2DSelection(world, selector, (Polygonal2DRegion) region);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (IncompleteRegionException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the region selection for a player.
|
||||
*
|
||||
* @param player
|
||||
* @param selection
|
||||
*/
|
||||
public void setSelection(Player player, Selection selection) {
|
||||
if (player == null) {
|
||||
throw new IllegalArgumentException("Null player not allowed");
|
||||
}
|
||||
if (!player.isOnline()) {
|
||||
throw new IllegalArgumentException("Offline player not allowed");
|
||||
}
|
||||
if (selection == null) {
|
||||
throw new IllegalArgumentException("Null selection not allowed");
|
||||
}
|
||||
|
||||
LocalSession session = controller.getSession(wrapPlayer(player));
|
||||
RegionSelector sel = selection.getRegionSelector();
|
||||
session.setRegionSelector(SpoutUtil.getLocalWorld(player.getWorld()), sel);
|
||||
session.dispatchCUISelection(wrapPlayer(player));
|
||||
}
|
||||
|
||||
static WorldEditPlugin getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout;
|
||||
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.bags.BlockBag;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.spout.selections.CuboidSelection;
|
||||
import com.sk89q.worldedit.spout.selections.Polygonal2DSelection;
|
||||
import com.sk89q.worldedit.spout.selections.Selection;
|
||||
import com.sk89q.worldedit.util.YAMLConfiguration;
|
||||
import org.spout.api.Server;
|
||||
import org.spout.api.command.CommandSource;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.entity.Player;
|
||||
import org.spout.api.plugin.CommonPlugin;
|
||||
import org.spout.api.protocol.Protocol;
|
||||
import org.spout.api.scheduler.TaskPriority;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
/**
|
||||
* Plugin for Spout.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public class WorldEditPlugin extends CommonPlugin {
|
||||
/**
|
||||
* The server interface that all server-related API goes through.
|
||||
*/
|
||||
private SpoutServerInterface server;
|
||||
/**
|
||||
* Main WorldEdit instance.
|
||||
*/
|
||||
private WorldEdit controller;
|
||||
|
||||
/**
|
||||
* Holds the configuration for WorldEdit.
|
||||
*/
|
||||
private YAMLConfiguration config;
|
||||
|
||||
private static WorldEditPlugin instance;
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on plugin enable.
|
||||
*/
|
||||
public void onEnable() {
|
||||
final String pluginYmlVersion = getDescription().getVersion();
|
||||
final String manifestVersion = WorldEdit.getVersion();
|
||||
|
||||
getLogger().info("WorldEdit " + pluginYmlVersion + " enabled.");
|
||||
if (!manifestVersion.equalsIgnoreCase(pluginYmlVersion)) {
|
||||
WorldEdit.setVersion(manifestVersion + " (" + pluginYmlVersion + ")");
|
||||
}
|
||||
|
||||
// Make the data folders that WorldEdit uses
|
||||
getDataFolder().mkdirs();
|
||||
|
||||
// Create the default configuration file
|
||||
createDefaultConfiguration("config.yml");
|
||||
|
||||
// Set up configuration and such, including the permissions
|
||||
// resolver
|
||||
config = new SpoutConfiguration(new YAMLProcessor(new File(getDataFolder(), "config.yml"), true), this);
|
||||
|
||||
// Load the configuration
|
||||
loadConfiguration();
|
||||
|
||||
// Setup interfaces
|
||||
server = new SpoutServerInterface(this, getEngine());
|
||||
controller = new WorldEdit(server, config);
|
||||
|
||||
// Now we can register events!
|
||||
registerEvents();
|
||||
|
||||
for (Protocol proto : Protocol.getProtocols()) {
|
||||
proto.registerPacket(WorldEditCUICodec.class, new WorldEditCUIMessageHandler(this));
|
||||
}
|
||||
|
||||
getEngine().getScheduler().scheduleAsyncRepeatingTask(this,
|
||||
new SessionTimer(controller, getServer()), 6 * 1000, 6 * 1000, TaskPriority.LOWEST);
|
||||
}
|
||||
|
||||
public Server getServer() {
|
||||
if (!(getEngine() instanceof Server)) {
|
||||
throw new IllegalStateException("WorldEdit must be running on a server for this operation!");
|
||||
}
|
||||
|
||||
return (Server) getEngine();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called on plugin disable.
|
||||
*/
|
||||
public void onDisable() {
|
||||
controller.clearSessions();
|
||||
config.unload();
|
||||
getEngine().getScheduler().cancelTasks(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads and reloads all configuration.
|
||||
*/
|
||||
protected void loadConfiguration() {
|
||||
config.unload();
|
||||
config.load();
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the events used by WorldEdit.
|
||||
*/
|
||||
protected void registerEvents() {
|
||||
getEngine().getEventManager().registerEvents(new WorldEditListener(this), this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a default configuration file from the .jar.
|
||||
*
|
||||
* @param name
|
||||
*/
|
||||
protected void createDefaultConfiguration(String name) {
|
||||
File actual = new File(getDataFolder(), name);
|
||||
if (!actual.exists()) {
|
||||
InputStream input =
|
||||
null;
|
||||
try {
|
||||
JarFile file = new JarFile(getFile());
|
||||
ZipEntry copy = file.getEntry("defaults/" + name);
|
||||
if (copy == null) throw new FileNotFoundException();
|
||||
input = file.getInputStream(copy);
|
||||
} 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 = 0;
|
||||
while ((length = input.read(buf)) > 0) {
|
||||
output.write(buf, 0, length);
|
||||
}
|
||||
|
||||
getLogger().info("Default configuration file written: " + name);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
input.close();
|
||||
} catch (IOException ignore) {}
|
||||
|
||||
try {
|
||||
if (output != null) {
|
||||
output.close();
|
||||
}
|
||||
} catch (IOException ignore) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the session for the player.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public LocalSession getSession(Player player) {
|
||||
return controller.getSession(wrapPlayer(player));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the session for the player.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public EditSession createEditSession(Player player) {
|
||||
LocalPlayer wePlayer = wrapPlayer(player);
|
||||
LocalSession session = controller.getSession(wePlayer);
|
||||
BlockBag blockBag = session.getBlockBag(wePlayer);
|
||||
|
||||
EditSession editSession =
|
||||
new EditSession(wePlayer.getWorld(), session.getBlockChangeLimit(), blockBag);
|
||||
editSession.enableQueue();
|
||||
|
||||
return editSession;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remember an edit session.
|
||||
*
|
||||
* @param player
|
||||
* @param editSession
|
||||
*/
|
||||
public void remember(Player player, EditSession editSession) {
|
||||
LocalPlayer wePlayer = wrapPlayer(player);
|
||||
LocalSession session = controller.getSession(wePlayer);
|
||||
|
||||
session.remember(editSession);
|
||||
editSession.flushQueue();
|
||||
|
||||
controller.flushBlockBag(wePlayer, editSession);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap an operation into an EditSession.
|
||||
*
|
||||
* @param player
|
||||
* @param op
|
||||
* @throws Throwable
|
||||
*/
|
||||
public void perform(Player player, WorldEditOperation op)
|
||||
throws Throwable {
|
||||
LocalPlayer wePlayer = wrapPlayer(player);
|
||||
LocalSession session = controller.getSession(wePlayer);
|
||||
|
||||
EditSession editSession = createEditSession(player);
|
||||
try {
|
||||
op.run(session, wePlayer, editSession);
|
||||
} finally {
|
||||
remember(player, editSession);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration used by WorldEdit.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public YAMLConfiguration getLocalConfiguration() {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to wrap a Bukkit Player as a LocalPlayer.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public SpoutPlayer wrapPlayer(Player player) {
|
||||
return new SpoutPlayer(this, this.server, player);
|
||||
}
|
||||
|
||||
public LocalPlayer wrapCommandSender(CommandSource sender) {
|
||||
if (sender instanceof Player) {
|
||||
return wrapPlayer((Player) sender);
|
||||
}
|
||||
|
||||
return new SpoutCommandSender(this, this.server, sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the server interface.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public SpoutServerInterface getServerInterface() {
|
||||
return server;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get WorldEdit.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public WorldEdit getWorldEdit() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the region selection for the player.
|
||||
*
|
||||
* @param player
|
||||
* @return the selection or null if there was none
|
||||
*/
|
||||
public Selection getSelection(Player player) {
|
||||
if (player == null) {
|
||||
throw new IllegalArgumentException("Null player not allowed");
|
||||
}
|
||||
if (!player.isOnline()) {
|
||||
throw new IllegalArgumentException("Offline player not allowed");
|
||||
}
|
||||
|
||||
LocalSession session = controller.getSession(wrapPlayer(player));
|
||||
RegionSelector selector = session.getRegionSelector(SpoutUtil.getLocalWorld(player.getWorld()));
|
||||
|
||||
try {
|
||||
Region region = selector.getRegion();
|
||||
World world = ((SpoutWorld) session.getSelectionWorld()).getWorld();
|
||||
|
||||
if (region instanceof CuboidRegion) {
|
||||
return new CuboidSelection(world, selector, (CuboidRegion) region);
|
||||
} else if (region instanceof Polygonal2DRegion) {
|
||||
return new Polygonal2DSelection(world, selector, (Polygonal2DRegion) region);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} catch (IncompleteRegionException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the region selection for a player.
|
||||
*
|
||||
* @param player
|
||||
* @param selection
|
||||
*/
|
||||
public void setSelection(Player player, Selection selection) {
|
||||
if (player == null) {
|
||||
throw new IllegalArgumentException("Null player not allowed");
|
||||
}
|
||||
if (!player.isOnline()) {
|
||||
throw new IllegalArgumentException("Offline player not allowed");
|
||||
}
|
||||
if (selection == null) {
|
||||
throw new IllegalArgumentException("Null selection not allowed");
|
||||
}
|
||||
|
||||
LocalSession session = controller.getSession(wrapPlayer(player));
|
||||
RegionSelector sel = selection.getRegionSelector();
|
||||
session.setRegionSelector(SpoutUtil.getLocalWorld(player.getWorld()), sel);
|
||||
session.dispatchCUISelection(wrapPlayer(player));
|
||||
}
|
||||
|
||||
static WorldEditPlugin getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
@ -1,71 +1,71 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout.selections;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.spout.SpoutUtil;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.CuboidRegionSelector;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
|
||||
public class CuboidSelection extends RegionSelection {
|
||||
|
||||
protected CuboidRegion cuboid;
|
||||
|
||||
public CuboidSelection(World world, Point pt1, Point pt2) {
|
||||
this(world, SpoutUtil.toVector(pt1), SpoutUtil.toVector(pt2));
|
||||
}
|
||||
|
||||
public CuboidSelection(World world, Vector pt1, Vector pt2) {
|
||||
super(world);
|
||||
|
||||
// Validate input
|
||||
if (pt1 == null) {
|
||||
throw new IllegalArgumentException("Null point 1 not permitted");
|
||||
}
|
||||
|
||||
if (pt2 == null) {
|
||||
throw new IllegalArgumentException("Null point 2 not permitted");
|
||||
}
|
||||
|
||||
// Create new selector
|
||||
CuboidRegionSelector sel = new CuboidRegionSelector(SpoutUtil.getLocalWorld(world));
|
||||
|
||||
// set up selector
|
||||
sel.selectPrimary(pt1);
|
||||
sel.selectSecondary(pt2);
|
||||
|
||||
// set up CuboidSelection
|
||||
cuboid = sel.getIncompleteRegion();
|
||||
|
||||
// set up RegionSelection
|
||||
setRegionSelector(sel);
|
||||
setRegion(cuboid);
|
||||
}
|
||||
|
||||
public CuboidSelection(World world, RegionSelector sel, CuboidRegion region) {
|
||||
super(world, sel, region);
|
||||
this.cuboid = region;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout.selections;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.spout.SpoutUtil;
|
||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||
import com.sk89q.worldedit.regions.CuboidRegionSelector;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
|
||||
public class CuboidSelection extends RegionSelection {
|
||||
|
||||
protected CuboidRegion cuboid;
|
||||
|
||||
public CuboidSelection(World world, Point pt1, Point pt2) {
|
||||
this(world, SpoutUtil.toVector(pt1), SpoutUtil.toVector(pt2));
|
||||
}
|
||||
|
||||
public CuboidSelection(World world, Vector pt1, Vector pt2) {
|
||||
super(world);
|
||||
|
||||
// Validate input
|
||||
if (pt1 == null) {
|
||||
throw new IllegalArgumentException("Null point 1 not permitted");
|
||||
}
|
||||
|
||||
if (pt2 == null) {
|
||||
throw new IllegalArgumentException("Null point 2 not permitted");
|
||||
}
|
||||
|
||||
// Create new selector
|
||||
CuboidRegionSelector sel = new CuboidRegionSelector(SpoutUtil.getLocalWorld(world));
|
||||
|
||||
// set up selector
|
||||
sel.selectPrimary(pt1);
|
||||
sel.selectSecondary(pt2);
|
||||
|
||||
// set up CuboidSelection
|
||||
cuboid = sel.getIncompleteRegion();
|
||||
|
||||
// set up RegionSelection
|
||||
setRegionSelector(sel);
|
||||
setRegion(cuboid);
|
||||
}
|
||||
|
||||
public CuboidSelection(World world, RegionSelector sel, CuboidRegion region) {
|
||||
super(world, sel, region);
|
||||
this.cuboid = region;
|
||||
}
|
||||
}
|
@ -1,66 +1,66 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout.selections;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegionSelector;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.spout.SpoutUtil;
|
||||
import org.spout.api.geo.World;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Polygonal2DSelection extends RegionSelection {
|
||||
|
||||
protected Polygonal2DRegion poly2d;
|
||||
|
||||
public Polygonal2DSelection(World world, RegionSelector sel, Polygonal2DRegion region) {
|
||||
super(world, sel, region);
|
||||
this.poly2d = region;
|
||||
}
|
||||
|
||||
public Polygonal2DSelection(World world, List<BlockVector2D> points, int minY, int maxY) {
|
||||
super(world);
|
||||
LocalWorld lWorld = SpoutUtil.getLocalWorld(world);
|
||||
|
||||
// Validate input
|
||||
minY = Math.min(Math.max(0, minY), world.getHeight());
|
||||
maxY = Math.min(Math.max(0, maxY), world.getHeight());
|
||||
|
||||
// Create and set up new selector
|
||||
Polygonal2DRegionSelector sel = new Polygonal2DRegionSelector(lWorld, points, minY, maxY);
|
||||
|
||||
// set up CuboidSelection
|
||||
poly2d = sel.getIncompleteRegion();
|
||||
|
||||
// set up RegionSelection
|
||||
setRegionSelector(sel);
|
||||
setRegion(poly2d);
|
||||
}
|
||||
|
||||
public List<BlockVector2D> getNativePoints() {
|
||||
return Collections.unmodifiableList(poly2d.getPoints());
|
||||
}
|
||||
}
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout.selections;
|
||||
|
||||
import com.sk89q.worldedit.BlockVector2D;
|
||||
import com.sk89q.worldedit.LocalWorld;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegion;
|
||||
import com.sk89q.worldedit.regions.Polygonal2DRegionSelector;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.spout.SpoutUtil;
|
||||
import org.spout.api.geo.World;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class Polygonal2DSelection extends RegionSelection {
|
||||
|
||||
protected Polygonal2DRegion poly2d;
|
||||
|
||||
public Polygonal2DSelection(World world, RegionSelector sel, Polygonal2DRegion region) {
|
||||
super(world, sel, region);
|
||||
this.poly2d = region;
|
||||
}
|
||||
|
||||
public Polygonal2DSelection(World world, List<BlockVector2D> points, int minY, int maxY) {
|
||||
super(world);
|
||||
LocalWorld lWorld = SpoutUtil.getLocalWorld(world);
|
||||
|
||||
// Validate input
|
||||
minY = Math.min(Math.max(0, minY), world.getHeight());
|
||||
maxY = Math.min(Math.max(0, maxY), world.getHeight());
|
||||
|
||||
// Create and set up new selector
|
||||
Polygonal2DRegionSelector sel = new Polygonal2DRegionSelector(lWorld, points, minY, maxY);
|
||||
|
||||
// set up CuboidSelection
|
||||
poly2d = sel.getIncompleteRegion();
|
||||
|
||||
// set up RegionSelection
|
||||
setRegionSelector(sel);
|
||||
setRegion(poly2d);
|
||||
}
|
||||
|
||||
public List<BlockVector2D> getNativePoints() {
|
||||
return Collections.unmodifiableList(poly2d.getPoints());
|
||||
}
|
||||
}
|
@ -1,107 +1,107 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout.selections;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.spout.SpoutUtil;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
|
||||
public abstract class RegionSelection implements Selection {
|
||||
|
||||
private World world;
|
||||
private RegionSelector selector;
|
||||
private Region region;
|
||||
|
||||
public RegionSelection(World world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public RegionSelection(World world, RegionSelector selector, Region region) {
|
||||
this.world = world;
|
||||
this.region = region;
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
protected Region getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
protected void setRegion(Region region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public RegionSelector getRegionSelector() {
|
||||
return selector;
|
||||
}
|
||||
|
||||
protected void setRegionSelector(RegionSelector selector) {
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
public Point getMinimumPoint() {
|
||||
return SpoutUtil.toPoint(world, region.getMinimumPoint());
|
||||
}
|
||||
|
||||
public Vector getNativeMinimumPoint() {
|
||||
return region.getMinimumPoint();
|
||||
}
|
||||
|
||||
public Point getMaximumPoint() {
|
||||
return SpoutUtil.toPoint(world, region.getMaximumPoint());
|
||||
}
|
||||
|
||||
public Vector getNativeMaximumPoint() {
|
||||
return region.getMaximumPoint();
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public int getArea() {
|
||||
return region.getArea();
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return region.getWidth();
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return region.getHeight();
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return region.getLength();
|
||||
}
|
||||
|
||||
public boolean contains(Point pt) {
|
||||
if (!pt.getWorld().equals(world)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return region.contains(SpoutUtil.toVector(pt));
|
||||
}
|
||||
|
||||
}
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout.selections;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import com.sk89q.worldedit.spout.SpoutUtil;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
|
||||
public abstract class RegionSelection implements Selection {
|
||||
|
||||
private World world;
|
||||
private RegionSelector selector;
|
||||
private Region region;
|
||||
|
||||
public RegionSelection(World world) {
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
public RegionSelection(World world, RegionSelector selector, Region region) {
|
||||
this.world = world;
|
||||
this.region = region;
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
protected Region getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
protected void setRegion(Region region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public RegionSelector getRegionSelector() {
|
||||
return selector;
|
||||
}
|
||||
|
||||
protected void setRegionSelector(RegionSelector selector) {
|
||||
this.selector = selector;
|
||||
}
|
||||
|
||||
public Point getMinimumPoint() {
|
||||
return SpoutUtil.toPoint(world, region.getMinimumPoint());
|
||||
}
|
||||
|
||||
public Vector getNativeMinimumPoint() {
|
||||
return region.getMinimumPoint();
|
||||
}
|
||||
|
||||
public Point getMaximumPoint() {
|
||||
return SpoutUtil.toPoint(world, region.getMaximumPoint());
|
||||
}
|
||||
|
||||
public Vector getNativeMaximumPoint() {
|
||||
return region.getMaximumPoint();
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
||||
public int getArea() {
|
||||
return region.getArea();
|
||||
}
|
||||
|
||||
public int getWidth() {
|
||||
return region.getWidth();
|
||||
}
|
||||
|
||||
public int getHeight() {
|
||||
return region.getHeight();
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return region.getLength();
|
||||
}
|
||||
|
||||
public boolean contains(Point pt) {
|
||||
if (!pt.getWorld().equals(world)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return region.contains(SpoutUtil.toVector(pt));
|
||||
}
|
||||
|
||||
}
|
@ -1,107 +1,107 @@
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout.selections;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
|
||||
public interface Selection {
|
||||
/**
|
||||
* Get the lower point of a region.
|
||||
*
|
||||
* @return min. point
|
||||
*/
|
||||
public Point getMinimumPoint();
|
||||
|
||||
/**
|
||||
* Get the lower point of a region.
|
||||
*
|
||||
* @return min. point
|
||||
*/
|
||||
public Vector getNativeMinimumPoint();
|
||||
|
||||
/**
|
||||
* Get the upper point of a region.
|
||||
*
|
||||
* @return max. point
|
||||
*/
|
||||
public Point getMaximumPoint();
|
||||
|
||||
/**
|
||||
* Get the upper point of a region.
|
||||
*
|
||||
* @return max. point
|
||||
*/
|
||||
public Vector getNativeMaximumPoint();
|
||||
|
||||
/**
|
||||
* Get the region selector. This is for internal use.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RegionSelector getRegionSelector();
|
||||
|
||||
/**
|
||||
* Get the world.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public World getWorld();
|
||||
|
||||
/**
|
||||
* Get the number of blocks in the region.
|
||||
*
|
||||
* @return number of blocks
|
||||
*/
|
||||
public int getArea();
|
||||
|
||||
/**
|
||||
* Get X-size.
|
||||
*
|
||||
* @return width
|
||||
*/
|
||||
public int getWidth();
|
||||
|
||||
/**
|
||||
* Get Y-size.
|
||||
*
|
||||
* @return height
|
||||
*/
|
||||
public int getHeight();
|
||||
|
||||
/**
|
||||
* Get Z-size.
|
||||
*
|
||||
* @return length
|
||||
*/
|
||||
public int getLength();
|
||||
|
||||
/**
|
||||
* Returns true based on whether the region contains the point,
|
||||
*
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
public boolean contains(Point pt);
|
||||
}
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2012 sk89q <http://www.sk89q.com> and contributors
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
// $Id$
|
||||
|
||||
|
||||
package com.sk89q.worldedit.spout.selections;
|
||||
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.regions.RegionSelector;
|
||||
import org.spout.api.geo.World;
|
||||
import org.spout.api.geo.discrete.Point;
|
||||
|
||||
public interface Selection {
|
||||
/**
|
||||
* Get the lower point of a region.
|
||||
*
|
||||
* @return min. point
|
||||
*/
|
||||
public Point getMinimumPoint();
|
||||
|
||||
/**
|
||||
* Get the lower point of a region.
|
||||
*
|
||||
* @return min. point
|
||||
*/
|
||||
public Vector getNativeMinimumPoint();
|
||||
|
||||
/**
|
||||
* Get the upper point of a region.
|
||||
*
|
||||
* @return max. point
|
||||
*/
|
||||
public Point getMaximumPoint();
|
||||
|
||||
/**
|
||||
* Get the upper point of a region.
|
||||
*
|
||||
* @return max. point
|
||||
*/
|
||||
public Vector getNativeMaximumPoint();
|
||||
|
||||
/**
|
||||
* Get the region selector. This is for internal use.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public RegionSelector getRegionSelector();
|
||||
|
||||
/**
|
||||
* Get the world.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public World getWorld();
|
||||
|
||||
/**
|
||||
* Get the number of blocks in the region.
|
||||
*
|
||||
* @return number of blocks
|
||||
*/
|
||||
public int getArea();
|
||||
|
||||
/**
|
||||
* Get X-size.
|
||||
*
|
||||
* @return width
|
||||
*/
|
||||
public int getWidth();
|
||||
|
||||
/**
|
||||
* Get Y-size.
|
||||
*
|
||||
* @return height
|
||||
*/
|
||||
public int getHeight();
|
||||
|
||||
/**
|
||||
* Get Z-size.
|
||||
*
|
||||
* @return length
|
||||
*/
|
||||
public int getLength();
|
||||
|
||||
/**
|
||||
* Returns true based on whether the region contains the point,
|
||||
*
|
||||
* @param pt
|
||||
* @return
|
||||
*/
|
||||
public boolean contains(Point pt);
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren