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