Mirror von
https://github.com/IntellectualSites/FastAsyncWorldEdit.git
synchronisiert 2024-11-08 04:20:06 +01:00
Updated item/block lists, added Bukkit API for other plugins, moved some things around.
Dieser Commit ist enthalten in:
Ursprung
3b9fe1b0c4
Commit
80d7bbfa3c
@ -71,7 +71,7 @@ public class MinecraftSetBlockProxy extends ff {
|
||||
*/
|
||||
@Override
|
||||
public int a(int x, int y, int z) {
|
||||
return editSession.getBlock(new Vector(x, y, z)).getID();
|
||||
return editSession.getBlock(new Vector(x, y, z)).getType();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -73,8 +73,8 @@ public class BlockVector extends Vector {
|
||||
return false;
|
||||
}
|
||||
Vector other = (Vector)obj;
|
||||
return (int)other.x == (int)this.x && (int)other.y == (int)this.y
|
||||
&& (int)other.z == (int)this.z;
|
||||
return (int)other.getX() == (int)this.x && (int)other.getY() == (int)this.y
|
||||
&& (int)other.getZ() == (int)this.z;
|
||||
|
||||
}
|
||||
|
||||
|
@ -296,7 +296,7 @@ public class CuboidClipboard {
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int z = 0; z < length; z++) {
|
||||
int index = y * width * length + z * width + x;
|
||||
blocks[index] = (byte)data[x][y][z].getID();
|
||||
blocks[index] = (byte)data[x][y][z].getType();
|
||||
blockData[index] = (byte)data[x][y][z].getData();
|
||||
|
||||
// Store TileEntity data
|
||||
|
@ -158,7 +158,7 @@ public class EditSession {
|
||||
world.setBlockType(pt, 0);
|
||||
}
|
||||
|
||||
int id = block.getID();
|
||||
int id = block.getType();
|
||||
|
||||
if (blockBag != null) {
|
||||
if (id > 0) {
|
||||
@ -258,15 +258,15 @@ public class EditSession {
|
||||
private boolean smartSetBlock(Vector pt, BaseBlock block) {
|
||||
if (queued) {
|
||||
// Place torches, etc. last
|
||||
if (BlockType.shouldPlaceLast(block.getID())) {
|
||||
if (BlockType.shouldPlaceLast(block.getType())) {
|
||||
queueLast.put(pt.toBlockVector(), block);
|
||||
return getBlock(pt).getID() != block.getID();
|
||||
return getBlock(pt).getType() != block.getType();
|
||||
// Destroy torches, etc. first
|
||||
} else if (BlockType.shouldPlaceLast(getBlock(pt).getID())) {
|
||||
} else if (BlockType.shouldPlaceLast(getBlock(pt).getType())) {
|
||||
rawSetBlock(pt, new BaseBlock(0));
|
||||
} else {
|
||||
queueAfter.put(pt.toBlockVector(), block);
|
||||
return getBlock(pt).getID() != block.getID();
|
||||
return getBlock(pt).getType() != block.getType();
|
||||
}
|
||||
}
|
||||
|
||||
@ -719,7 +719,7 @@ public class EditSession {
|
||||
for (int z = -size; z <= size; z++) {
|
||||
Vector p = pos.add(x, y, z);
|
||||
|
||||
if (getBlock(p).getID() == blockType) {
|
||||
if (getBlock(p).getType() == blockType) {
|
||||
if (setBlock(p, air)) {
|
||||
affected++;
|
||||
}
|
||||
@ -853,7 +853,7 @@ public class EditSession {
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
Vector pt = new Vector(x, y, z);
|
||||
int curBlockType = getBlock(pt).getID();
|
||||
int curBlockType = getBlock(pt).getType();
|
||||
|
||||
if ((fromBlockTypes == null && curBlockType != 0)
|
||||
|| (fromBlockTypes != null && fromBlockTypes
|
||||
@ -867,7 +867,7 @@ public class EditSession {
|
||||
}
|
||||
} else {
|
||||
for (Vector pt : region) {
|
||||
int curBlockType = getBlock(pt).getID();
|
||||
int curBlockType = getBlock(pt).getType();
|
||||
|
||||
if (fromBlockTypes == null && curBlockType != 0
|
||||
|| fromBlockTypes.contains(curBlockType)) {
|
||||
@ -911,7 +911,7 @@ public class EditSession {
|
||||
for (int y = minY; y <= maxY; y++) {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
Vector pt = new Vector(x, y, z);
|
||||
int curBlockType = getBlock(pt).getID();
|
||||
int curBlockType = getBlock(pt).getType();
|
||||
|
||||
if ((fromBlockTypes == null && curBlockType != 0)
|
||||
|| (fromBlockTypes != null && fromBlockTypes
|
||||
@ -925,7 +925,7 @@ public class EditSession {
|
||||
}
|
||||
} else {
|
||||
for (Vector pt : region) {
|
||||
int curBlockType = getBlock(pt).getID();
|
||||
int curBlockType = getBlock(pt).getType();
|
||||
|
||||
if (fromBlockTypes == null && curBlockType != 0
|
||||
|| fromBlockTypes.contains(curBlockType)) {
|
||||
@ -1231,7 +1231,7 @@ public class EditSession {
|
||||
while (!queue.empty()) {
|
||||
BlockVector cur = queue.pop();
|
||||
|
||||
int type = getBlock(cur).getID();
|
||||
int type = getBlock(cur).getType();
|
||||
|
||||
// Check block type
|
||||
if (type != 8 && type != 9 && type != 10 && type != 11) {
|
||||
@ -1288,7 +1288,7 @@ public class EditSession {
|
||||
for (int x = pos.getBlockX() - 1; x <= pos.getBlockX() + 1; x++) {
|
||||
for (int z = pos.getBlockZ() - 1; z <= pos.getBlockZ() + 1; z++) {
|
||||
for (int y = pos.getBlockY() - 1; y <= pos.getBlockY() + 1; y++) {
|
||||
int type = getBlock(new Vector(x, y, z)).getID();
|
||||
int type = getBlock(new Vector(x, y, z)).getType();
|
||||
|
||||
// Check block type
|
||||
if (type == moving || type == stationary) {
|
||||
@ -1303,7 +1303,7 @@ public class EditSession {
|
||||
while (!queue.empty()) {
|
||||
BlockVector cur = queue.pop();
|
||||
|
||||
int type = getBlock(cur).getID();
|
||||
int type = getBlock(cur).getType();
|
||||
|
||||
// Check block type
|
||||
if (type != moving && type != stationary && type != 0) {
|
||||
@ -1598,7 +1598,7 @@ public class EditSession {
|
||||
|
||||
for (int y = 127; y >= 1; y--) {
|
||||
Vector pt = new Vector(x, y, z);
|
||||
int id = getBlock(pt).getID();
|
||||
int id = getBlock(pt).getType();
|
||||
|
||||
if (id == BlockID.ICE) { // Ice
|
||||
if (setBlock(pt, water)) {
|
||||
@ -1646,7 +1646,7 @@ public class EditSession {
|
||||
|
||||
for (int y = 127; y >= 1; y--) {
|
||||
Vector pt = new Vector(x, y, z);
|
||||
int id = getBlock(pt).getID();
|
||||
int id = getBlock(pt).getType();
|
||||
|
||||
// Snow should not cover these blocks
|
||||
if (id == 6 // Saplings
|
||||
@ -1747,12 +1747,12 @@ public class EditSession {
|
||||
throws MaxChangedBlocksException {
|
||||
if (pos.distance(basePos) > 4)
|
||||
return;
|
||||
if (getBlock(pos).getID() != 0)
|
||||
if (getBlock(pos).getType() != 0)
|
||||
return;
|
||||
|
||||
for (int i = -1; i > -3; i--) {
|
||||
Vector testPos = pos.add(0, i, 0);
|
||||
if (getBlock(testPos).getID() == 0) {
|
||||
if (getBlock(testPos).getType() == 0) {
|
||||
pos = testPos;
|
||||
} else {
|
||||
break;
|
||||
@ -1816,7 +1816,7 @@ public class EditSession {
|
||||
|
||||
for (int y = basePos.getBlockY(); y >= basePos.getBlockY() - 10; y--) {
|
||||
// Check if we hit the ground
|
||||
int t = getBlock(new Vector(x, y, z)).getID();
|
||||
int t = getBlock(new Vector(x, y, z)).getType();
|
||||
if (t == 2 || t == 3) {
|
||||
makePumpkinPatch(new Vector(x, y + 1, z));
|
||||
affected++;
|
||||
@ -1858,7 +1858,7 @@ public class EditSession {
|
||||
|
||||
for (int y = basePos.getBlockY(); y >= basePos.getBlockY() - 10; y--) {
|
||||
// Check if we hit the ground
|
||||
int t = getBlock(new Vector(x, y, z)).getID();
|
||||
int t = getBlock(new Vector(x, y, z)).getType();
|
||||
if (t == 2 || t == 3) {
|
||||
if (pineTree) {
|
||||
makePineTree(new Vector(x, y + 1, z));
|
||||
@ -1962,7 +1962,7 @@ public class EditSession {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
Vector pt = new Vector(x, y, z);
|
||||
|
||||
if (searchIDs.contains(getBlock(pt).getID())) {
|
||||
if (searchIDs.contains(getBlock(pt).getType())) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@ -1970,7 +1970,7 @@ public class EditSession {
|
||||
}
|
||||
} else {
|
||||
for (Vector pt : region) {
|
||||
if (searchIDs.contains(getBlock(pt).getID())) {
|
||||
if (searchIDs.contains(getBlock(pt).getType())) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
@ -2006,7 +2006,7 @@ public class EditSession {
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
Vector pt = new Vector(x, y, z);
|
||||
|
||||
int id = getBlock(pt).getID();
|
||||
int id = getBlock(pt).getType();
|
||||
|
||||
if (map.containsKey(id)) {
|
||||
map.get(id).increment();
|
||||
@ -2020,7 +2020,7 @@ public class EditSession {
|
||||
}
|
||||
} else {
|
||||
for (Vector pt : region) {
|
||||
int id = getBlock(pt).getID();
|
||||
int id = getBlock(pt).getType();
|
||||
|
||||
if (map.containsKey(id)) {
|
||||
map.get(id).increment();
|
||||
@ -2053,7 +2053,7 @@ public class EditSession {
|
||||
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
||||
for (int y = maxY; y >= minY; y--) {
|
||||
Vector pt = new Vector(x, y, z);
|
||||
int id = getBlock(pt).getID();
|
||||
int id = getBlock(pt).getType();
|
||||
|
||||
if (id == 1 // stone
|
||||
|| id == 2 // grass
|
||||
|
@ -125,7 +125,7 @@ public class HeightMap {
|
||||
BaseBlock existing = session.getBlock(new Vector(X, curHeight, Z));
|
||||
|
||||
// Skip water/lava
|
||||
if (existing.getID() < 8 || existing.getID() > 11) {
|
||||
if (existing.getType() < 8 || existing.getType() > 11) {
|
||||
session.setBlock(new Vector(X, newHeight, Z), existing);
|
||||
blocksChanged++;
|
||||
|
||||
|
@ -544,7 +544,7 @@ public class Vector {
|
||||
return false;
|
||||
}
|
||||
Vector other = (Vector)obj;
|
||||
return other.x == this.x && other.y == this.y && other.z == this.z;
|
||||
return other.getX() == this.x && other.getY() == this.y && other.getZ() == this.z;
|
||||
|
||||
}
|
||||
|
||||
|
@ -47,15 +47,6 @@ public class WorldEditController {
|
||||
*/
|
||||
private static final Logger logger = Logger.getLogger("Minecraft.WorldEdit");
|
||||
|
||||
/**
|
||||
* Default list of allowed block types.
|
||||
*/
|
||||
private final static Integer[] DEFAULT_ALLOWED_BLOCKS = {
|
||||
0, 1, 2, 3, 4, 5, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
|
||||
20, 35, 41, 42, 43, 44, 45, 47, 48, 49, 52, 53, 54, 56, 57, 58, 60,
|
||||
61, 62, 67, 73, 78, 79, 80, 82, 85, 86, 87, 88, 89, 91
|
||||
};
|
||||
|
||||
/**
|
||||
* Server interface.
|
||||
*/
|
||||
@ -374,7 +365,7 @@ public class WorldEditController {
|
||||
String[] items = list.split(",");
|
||||
Set<Integer> blocks = new HashSet<Integer>();
|
||||
for (String s : items) {
|
||||
blocks.add(getBlock(player, s, allBlocksAllowed).getID());
|
||||
blocks.add(getBlock(player, s, allBlocksAllowed).getType());
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
@ -896,7 +887,7 @@ public class WorldEditController {
|
||||
checkMaxRadius(size);
|
||||
|
||||
int affected = editSession.removeNear(
|
||||
session.getPlacementPosition(player), block.getID(), size);
|
||||
session.getPlacementPosition(player), block.getType(), size);
|
||||
player.print(affected + " block(s) have been removed.");
|
||||
|
||||
return true;
|
||||
@ -1782,19 +1773,6 @@ public class WorldEditController {
|
||||
sessions.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a comma-delimited list of the default allowed blocks.
|
||||
*
|
||||
* @return comma-delimited list
|
||||
*/
|
||||
public static String getDefaultAllowedBlocks() {
|
||||
StringBuilder b = new StringBuilder();
|
||||
for (Integer id : DEFAULT_ALLOWED_BLOCKS) {
|
||||
b.append(id).append(",");
|
||||
}
|
||||
return b.substring(0, b.length() - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param player
|
||||
|
@ -56,7 +56,7 @@ public class BaseBlock {
|
||||
/**
|
||||
* @return the type
|
||||
*/
|
||||
public int getID() {
|
||||
public int getType() {
|
||||
return (int)type;
|
||||
}
|
||||
|
||||
|
@ -33,10 +33,10 @@ public enum BlockType {
|
||||
STONE(1, "Stone", new String[]{"stone", "rock"}),
|
||||
GRASS(2, "Grass", "grass"),
|
||||
DIRT(3, "Dirt", "dirt"),
|
||||
COBBLESTONE(4, "Cobblestone", "cobblestone"),
|
||||
COBBLESTONE(4, "Cobblestone", new String[]{"cobblestone", "cobble"}),
|
||||
WOOD(5, "Wood", "wood"),
|
||||
SAPLING(6, "Sapling", "sapling"),
|
||||
BEDROCK(7, "Bedrock", "bedrock"),
|
||||
BEDROCK(7, "Bedrock", new String[]{"adminium", "bedrock"}),
|
||||
WATER(8, "Water", "watermoving"),
|
||||
STATIONARY_WATER(9, "Water (stationary)", "water"),
|
||||
LAVA(10, "Lava", "lavamoving"),
|
||||
@ -46,51 +46,56 @@ public enum BlockType {
|
||||
GOLD_ORE(14, "Gold ore", "goldore"),
|
||||
IRON_ORE(15, "Iron ore", "ironore"),
|
||||
COAL_ORE(16, "Coal ore", "coalore"),
|
||||
LOG(17, "Log", "log"),
|
||||
LEAVES(18, "Leaves", "leaves"),
|
||||
LOG(17, "Log", new String[]{"log", "tree", "pine", "oak", "birch"}),
|
||||
LEAVES(18, "Leaves", new String[]{"leaves", "leaf"}),
|
||||
SPONGE(19, "Sponge", "sponge"),
|
||||
GLASS(20, "Glass", "glass"),
|
||||
LAPIS_LAZULI_ORE(21, "Lapis lazuli ore", new String[]{"lapislazuliore", "blueore"}),
|
||||
LAPIS_LAZULI(22, "Lapis lazuli", new String[]{"lapislazuli", "lapislazuliblock", "blue", "bluerock"}),
|
||||
DISPENSER(23, "Dispenser", "dispenser"),
|
||||
SANDSTONE(24, "Sandstone", "sandstone"),
|
||||
NOTE_BLOCK(25, "Note block", new String[]{"musicblock", "noteblock", "note", "music", "instrument"}),
|
||||
CLOTH(35, "Cloth", "cloth"),
|
||||
YELLOW_FLOWER(37, "Yellow flower", "yellowflower"),
|
||||
RED_FLOWER(38, "Red rose", new String[]{"redflower", "redrose"}),
|
||||
BROWN_MUSHROOM(39, "Brown mushroom", "brownmushroom"),
|
||||
BROWN_MUSHROOM(39, "Brown mushroom", new String[]{"brownmushroom", "mushroom"}),
|
||||
RED_MUSHROOM(40, "Red mushroom", "redmushroom"),
|
||||
GOLD_BLOCK(41, "Gold block", new String[]{"gold", "goldblock"}),
|
||||
IRON_BLOCK(42, "Iron block", new String[]{"iron", "ironblock"}),
|
||||
DOUBLE_STEP(43, "Double step", "doublestep"),
|
||||
STEP(44, "Step", "step"),
|
||||
BRICK(45, "Brick", "brick"),
|
||||
DOUBLE_STEP(43, "Double step", new String[]{"doubleslab", "doublestoneslab", "doublestep"}),
|
||||
STEP(44, "Step", new String[]{"slab", "stoneslab", "step"}),
|
||||
BRICK(45, "Brick", new String[]{"brick", "brickblock"}),
|
||||
TNT(46, "TNT", "tnt"),
|
||||
BOOKCASE(47, "Bookcase", new String[]{"bookshelf", "bookshelf"}),
|
||||
MOSSY_COBBLESTONE(48, "Cobblestone (mossy)", "mossycobblestone"),
|
||||
BOOKCASE(47, "Bookcase", new String[]{"bookshelf", "bookshelves"}),
|
||||
MOSSY_COBBLESTONE(48, "Cobblestone (mossy)", new String[]{"mossycobblestone", "mossstone", "mossystone", "mosscobble", "mossycobble"}),
|
||||
OBSIDIAN(49, "Obsidian", "obsidian"),
|
||||
TORCH(50, "Torch", "torch"),
|
||||
FIRE(51, "Fire", "fire"),
|
||||
MOB_SPAWNER(52, "Mob spawner", "mobspawner"),
|
||||
WOODEN_STAIRS(53, "Wooden stairs", "woodstairs"),
|
||||
WOODEN_STAIRS(53, "Wooden stairs", new String[]{"woodstair", "woodstairs", "woodenstair", "woodenstairs"}),
|
||||
CHEST(54, "Chest", "chest"),
|
||||
REDSTONE_WIRE(55, "Redstone wire", "redstone"),
|
||||
DIAMOND_ORE(56, "Diamond ore", "diamondore"),
|
||||
DIAMOND_BLOCK(57, "Diamond block", new String[]{"diamond", "diamondblock"}),
|
||||
WORKBENCH(58, "Workbench", "workbench"),
|
||||
CROPS(59, "Crops", "crops"),
|
||||
WORKBENCH(58, "Workbench", new String[]{"workbench", "table", "craftingtable"}),
|
||||
CROPS(59, "Crops", new String[]{"crops", "crop", "plant", "plants"}),
|
||||
SOIL(60, "Soil", "soil"),
|
||||
FURNACE(61, "Furnace", "furnace"),
|
||||
BURNING_FURNACE(62, "Furnace (burning)", "burningfurnace"),
|
||||
SIGN_POST(63, "Sign post", new String[]{"sign", "signpost"}),
|
||||
WOODEN_DOOR(64, "Wooden door", "wooddoor"),
|
||||
WOODEN_DOOR(64, "Wooden door", new String[]{"wooddoor", "woodendoor"}),
|
||||
LADDER(65, "Ladder", "ladder"),
|
||||
MINECART_TRACKS(66, "Minecart tracks", new String[]{"track", "tracks"}),
|
||||
COBBLESTONE_STAIRS(67, "Cobblestone stairs", "cobblestonestairs"),
|
||||
MINECART_TRACKS(66, "Minecart tracks", new String[]{"track", "tracks", "minecrattrack", "minecarttracks"}),
|
||||
COBBLESTONE_STAIRS(67, "Cobblestone stairs", new String[]{"cobblestonestair", "cobblestonestairs", "cobblestair", "cobblestairs"}),
|
||||
WALL_SIGN(68, "Wall sign", "wallsign"),
|
||||
LEVER(69, "Lever", "level"),
|
||||
STONE_PRESSURE_PLATE(70, "Stone pressure plate", "stonepressureplate"),
|
||||
LEVER(69, "Lever", "lever"),
|
||||
STONE_PRESSURE_PLATE(70, "Stone pressure plate", new String[]{"stonepressureplate", "stoneplate"}),
|
||||
IRON_DOOR(71, "Iron Door", "irondoor"),
|
||||
WOODEN_PRESSURE_PLATE(72, "Wooden pressure plate", "woodpressureplate"),
|
||||
WOODEN_PRESSURE_PLATE(72, "Wooden pressure plate", new String[]{"woodpressureplate", "woodplate", "woodenpressureplate", "woodenplate"}),
|
||||
REDSTONE_ORE(73, "Redstone ore", "redstoneore"),
|
||||
GLOWING_REDSTONE_ORE(74, "Glowing redstone ore", "glowingredstoneore"),
|
||||
REDSTONE_TORCH_OFF(75, "Redstone torch (off)",
|
||||
new String[]{"redstonetorch"," redstonetorchon"}),
|
||||
new String[]{"redstonetorch"," redstonetorchoff", "rstorch"}),
|
||||
REDSTONE_TORCH_ON(76, "Redstone torch (on)", "redstonetorchon"),
|
||||
STONE_BUTTON(77, "Stone Button", "stonebutton"),
|
||||
SNOW(78, "Snow", "snow"),
|
||||
@ -98,15 +103,16 @@ public enum BlockType {
|
||||
SNOW_BLOCK(80, "Snow block", "snowblock"),
|
||||
CACTUS(81, "Cactus", "cactus"),
|
||||
CLAY(82, "Clay", "clay"),
|
||||
REED(83, "Reed", "reed"),
|
||||
SUGAR_CANE(83, "Reed", new String[]{"reed", "cane", "sugarcane", "sugarcanes"}),
|
||||
JUKEBOX(84, "Jukebox", "jukebox"),
|
||||
FENCE(85, "Fence", "fence"),
|
||||
PUMPKIN(86, "Pumpkin", "pumpkin"),
|
||||
RED_BLOCK(87, "Cobblestone (red mossy)", new String[]{"redmossycobblestone", "redcobblestone"}),
|
||||
HELL_DIRT(88, "Mud", "mud"),
|
||||
HELL_GOLD(89, "Brittle gold", "brittlegold"),
|
||||
NETHERRACK(87, "Netherrack", new String[]{"redmossycobblestone", "redcobblestone", "redmosstone", "redcobble", "netherstone", "netherrack", "nether"}),
|
||||
SOUL_SAND(88, "Soul sand", new String[]{"slowmud", "mud", "soulsand"}),
|
||||
GLOWSTONE(89, "Glowstone", new String[]{"brittlegold", "glowstone", "lightstone"}),
|
||||
PORTAL(90, "Portal", "portal"),
|
||||
LIGHTED_PUMPKIN(91, "Pumpkin (on)", new String[]{"pumpkinlighted", "pumpkinon", "litpumpkin"});
|
||||
JACK_O_LANTERN(91, "Pumpkin (on)", new String[]{"pumpkinlighted", "pumpkinon", "litpumpkin"}),
|
||||
CAKE(92, "Cake", "Cake");
|
||||
|
||||
/**
|
||||
* Stores a list of dropped blocks for blocks.
|
||||
@ -133,6 +139,11 @@ public enum BlockType {
|
||||
blockDrops.put(18, 18);
|
||||
blockDrops.put(19, 19);
|
||||
blockDrops.put(20, 20); // Have to drop glass for //undo
|
||||
blockDrops.put(21, 21); // Block damage drops not implemented
|
||||
blockDrops.put(22, 22);
|
||||
blockDrops.put(23, 23);
|
||||
blockDrops.put(24, 24);
|
||||
blockDrops.put(25, 25);
|
||||
blockDrops.put(35, 35);
|
||||
blockDrops.put(37, 37);
|
||||
blockDrops.put(38, 38);
|
||||
|
332
src/com/sk89q/worldedit/blocks/ItemType.java
Normale Datei
332
src/com/sk89q/worldedit/blocks/ItemType.java
Normale Datei
@ -0,0 +1,332 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.blocks;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumSet;
|
||||
|
||||
/**
|
||||
* ItemType types.
|
||||
*
|
||||
* @author sk89q
|
||||
*/
|
||||
public enum ItemType {
|
||||
AIR(0, "Air", "air"),
|
||||
STONE(1, "Stone", new String[]{"stone", "rock"}),
|
||||
GRASS(2, "Grass", "grass"),
|
||||
DIRT(3, "Dirt", "dirt"),
|
||||
COBBLESTONE(4, "Cobblestone", new String[]{"cobblestone", "cobble"}),
|
||||
WOOD(5, "Wood", "wood"),
|
||||
SAPLING(6, "Sapling", "sapling"),
|
||||
BEDROCK(7, "Bedrock", new String[]{"adminium", "bedrock"}),
|
||||
WATER(8, "Water", "watermoving"),
|
||||
STATIONARY_WATER(9, "Water (stationary)", "water"),
|
||||
LAVA(10, "Lava", "lavamoving"),
|
||||
STATIONARY_LAVA(11, "Lava (stationary)", "lava"),
|
||||
SAND(12, "Sand", "sand"),
|
||||
GRAVEL(13, "Gravel", "gravel"),
|
||||
GOLD_ORE(14, "Gold ore", "goldore"),
|
||||
IRON_ORE(15, "Iron ore", "ironore"),
|
||||
COAL_ORE(16, "Coal ore", "coalore"),
|
||||
LOG(17, "Log", new String[]{"log", "tree", "pine", "oak", "birch"}),
|
||||
LEAVES(18, "Leaves", new String[]{"leaves", "leaf"}),
|
||||
SPONGE(19, "Sponge", "sponge"),
|
||||
GLASS(20, "Glass", "glass"),
|
||||
LAPIS_LAZULI_ORE(21, "Lapis lazuli ore", new String[]{"lapislazuliore", "blueore"}),
|
||||
LAPIS_LAZULI(22, "Lapis lazuli", new String[]{"lapislazuli", "lapislazuliblock", "blue", "bluerock"}),
|
||||
DISPENSER(23, "Dispenser", "dispenser"),
|
||||
SANDSTONE(24, "Sandstone", "sandstone"),
|
||||
NOTE_BLOCK(25, "Note block", new String[]{"musicblock", "noteblock", "note", "music", "instrument"}),
|
||||
CLOTH(35, "Cloth", "cloth"),
|
||||
YELLOW_FLOWER(37, "Yellow flower", "yellowflower"),
|
||||
RED_FLOWER(38, "Red rose", new String[]{"redflower", "redrose"}),
|
||||
BROWN_MUSHROOM(39, "Brown mushroom", new String[]{"brownmushroom", "mushroom"}),
|
||||
RED_MUSHROOM(40, "Red mushroom", "redmushroom"),
|
||||
GOLD_BLOCK(41, "Gold block", new String[]{"gold", "goldblock"}),
|
||||
IRON_BLOCK(42, "Iron block", new String[]{"iron", "ironblock"}),
|
||||
DOUBLE_STEP(43, "Double step", new String[]{"doubleslab", "doublestoneslab", "doublestep"}),
|
||||
STEP(44, "Step", new String[]{"slab", "stoneslab", "step"}),
|
||||
BRICK(45, "Brick", new String[]{"brick", "brickblock"}),
|
||||
TNT(46, "TNT", "tnt"),
|
||||
BOOKCASE(47, "Bookcase", new String[]{"bookshelf", "bookshelves"}),
|
||||
MOSSY_COBBLESTONE(48, "Cobblestone (mossy)", new String[]{"mossycobblestone", "mossstone", "mossystone", "mosscobble", "mossycobble"}),
|
||||
OBSIDIAN(49, "Obsidian", "obsidian"),
|
||||
TORCH(50, "Torch", "torch"),
|
||||
FIRE(51, "Fire", "fire"),
|
||||
MOB_SPAWNER(52, "Mob spawner", "mobspawner"),
|
||||
WOODEN_STAIRS(53, "Wooden stairs", new String[]{"woodstair", "woodstairs", "woodenstair", "woodenstairs"}),
|
||||
CHEST(54, "Chest", "chest"),
|
||||
REDSTONE_WIRE(55, "Redstone wire", "redstone"),
|
||||
DIAMOND_ORE(56, "Diamond ore", "diamondore"),
|
||||
DIAMOND_BLOCK(57, "Diamond block", new String[]{"diamond", "diamondblock"}),
|
||||
WORKBENCH(58, "Workbench", new String[]{"workbench", "table", "craftingtable"}),
|
||||
CROPS(59, "Crops", new String[]{"crops", "crop", "plant", "plants"}),
|
||||
SOIL(60, "Soil", "soil"),
|
||||
FURNACE(61, "Furnace", "furnace"),
|
||||
BURNING_FURNACE(62, "Furnace (burning)", "burningfurnace"),
|
||||
SIGN_POST(63, "Sign post", new String[]{"sign", "signpost"}),
|
||||
WOODEN_DOOR(64, "Wooden door", new String[]{"wooddoor", "woodendoor"}),
|
||||
LADDER(65, "Ladder", "ladder"),
|
||||
MINECART_TRACKS(66, "Minecart tracks", new String[]{"track", "tracks", "minecrattrack", "minecarttracks"}),
|
||||
COBBLESTONE_STAIRS(67, "Cobblestone stairs", new String[]{"cobblestonestair", "cobblestonestairs", "cobblestair", "cobblestairs"}),
|
||||
WALL_SIGN(68, "Wall sign", "wallsign"),
|
||||
LEVER(69, "Lever", "lever"),
|
||||
STONE_PRESSURE_PLATE(70, "Stone pressure plate", new String[]{"stonepressureplate", "stoneplate"}),
|
||||
IRON_DOOR(71, "Iron Door", "irondoor"),
|
||||
WOODEN_PRESSURE_PLATE(72, "Wooden pressure plate", new String[]{"woodpressureplate", "woodplate", "woodenpressureplate", "woodenplate"}),
|
||||
REDSTONE_ORE(73, "Redstone ore", "redstoneore"),
|
||||
GLOWING_REDSTONE_ORE(74, "Glowing redstone ore", "glowingredstoneore"),
|
||||
REDSTONE_TORCH_OFF(75, "Redstone torch (off)",
|
||||
new String[]{"redstonetorch"," redstonetorchoff", "rstorch"}),
|
||||
REDSTONE_TORCH_ON(76, "Redstone torch (on)", "redstonetorchon"),
|
||||
STONE_BUTTON(77, "Stone Button", "stonebutton"),
|
||||
SNOW(78, "Snow", "snow"),
|
||||
ICE(79, "Ice", "ice"),
|
||||
SNOW_BLOCK(80, "Snow block", "snowblock"),
|
||||
CACTUS(81, "Cactus", "cactus"),
|
||||
CLAY(82, "Clay", "clay"),
|
||||
SUGAR_CANE(83, "Reed", new String[]{"reed", "cane", "sugarcane", "sugarcanes"}),
|
||||
JUKEBOX(84, "Jukebox", "jukebox"),
|
||||
FENCE(85, "Fence", "fence"),
|
||||
PUMPKIN(86, "Pumpkin", "pumpkin"),
|
||||
NETHERRACK(87, "Netherrack", new String[]{"redmossycobblestone", "redcobblestone", "redmosstone", "redcobble", "netherstone", "netherrack", "nether"}),
|
||||
SOUL_SAND(88, "Soul sand", new String[]{"slowmud", "mud", "soulsand"}),
|
||||
GLOWSTONE(89, "Glowstone", new String[]{"brittlegold", "glowstone", "lightstone"}),
|
||||
PORTAL(90, "Portal", "portal"),
|
||||
JACK_O_LANTERN(91, "Pumpkin (on)", new String[]{"pumpkinlighted", "pumpkinon", "litpumpkin"}),
|
||||
CAKE(92, "Cake", "Cake"),
|
||||
IRON_SHOVEL(256, "Iron shovel", "ironshovel"),
|
||||
IRON_PICK(257, "Iron pick", "ironpick"),
|
||||
IRON_AXE(258, "Iron axe", "ironaxe"),
|
||||
FLINT_AND_TINDER(259, "Flint and tinder", "flintandtinder"),
|
||||
RED_APPLE(260, "Red apple", "redapple"),
|
||||
BOW(261, "Bow", "bow"),
|
||||
ARROW(262, "Arrow", "arrow"),
|
||||
COAL(263, "Coal", "coal"),
|
||||
DIAMOND(264, "Diamond", "diamond"),
|
||||
IRON_BAR(265, "Iron bar", "ironbar"),
|
||||
GOLD_BAR(266, "Gold bar", "goldbar"),
|
||||
IRON_SWORD(267, "Iron sword", "ironsword"),
|
||||
WOOD_SWORD(268, "Wooden sword", "woodsword"),
|
||||
WOOD_SHOVEL(269, "Wooden shovel", "woodshovel"),
|
||||
WOOD_PICKAXE(270, "Wooden pickaxe", "woodpick"),
|
||||
WOOD_AXE(271, "Wooden axe", "woodaxe"),
|
||||
STONE_SWORD(272, "Stone sword", "stonesword"),
|
||||
STONE_SHOVEL(273, "Stone shovel", "stoneshovel"),
|
||||
STONE_PICKAXE(274, "Stone pickaxe", "stonepick"),
|
||||
STONE_AXE(275, "Stone pickaxe", "stoneaxe"),
|
||||
DIAMOND_SWORD(276, "Diamond sword", "diamondsword"),
|
||||
DIAMOND_SHOVEL(277, "Diamond shovel", "diamondshovel"),
|
||||
DIAMOND_PICKAXE(278, "Diamond pickaxe", "diamondpick"),
|
||||
DIAMOND_AXE(279, "Diamond axe", "diamondaxe"),
|
||||
STICK(280, "Stick", "stick"),
|
||||
BOWL(281, "Bowl", "bowl"),
|
||||
MUSHROOM_SOUP(282, "Mushroom soup", "mushroomsoup"),
|
||||
GOLD_SWORD(283, "Golden sword", "goldsword"),
|
||||
GOLD_SHOVEL(284, "Golden shovel", "goldshovel"),
|
||||
GOLD_PICKAXE(285, "Golden pickaxe", "goldpick"),
|
||||
GOLD_AXE(286, "Golden axe", "goldaxe"),
|
||||
STRING(287, "String", "string"),
|
||||
FEATHER(288, "Feather", "feather"),
|
||||
SULPHUR(289, "Sulphur", "sulphur"),
|
||||
WOOD_HOE(290, "Wooden hoe", "woodhoe"),
|
||||
STONE_HOE(291, "Stone hoe", "stonehoe"),
|
||||
IRON_HOE(292, "Iron hoe", "ironhoe"),
|
||||
DIAMOND_HOE(293, "Diamond hoe", "diamondhoe"),
|
||||
GOLD_HOE(294, "Golden hoe", "goldhoe"),
|
||||
SEEDS(295, "Seeds", "seeds"),
|
||||
WHEAT(296, "Wheat", "wheat"),
|
||||
BREAD(297, "Bread", "bread"),
|
||||
LEATHER_HELMET(298, "Leather helmet", "leatherhelmet"),
|
||||
LEATHER_CHEST(299, "Leather chestplate", "leatherchest"),
|
||||
LEATHER_PANTS(300, "Leather pants", "leatherpants"),
|
||||
LEATHER_BOOTS(301, "Leather boots", "leatherboots"),
|
||||
CHAINMAIL_HELMET(302, "Chainmail helmet", "chainmailhelmet"),
|
||||
CHAINMAIL_CHEST(303, "Chainmail chestplate", "chainmailchest"),
|
||||
CHAINMAIL_PANTS(304, "Chainmail pants", "chainmailpants"),
|
||||
CHAINMAIL_BOOTS(305, "Chainmail boots", "chainmailboots"),
|
||||
IRON_HELMET(306, "Iron helmet", "ironhelmet"),
|
||||
IRON_CHEST(307, "Iron chestplate", "ironchest"),
|
||||
IRON_PANTS(308, "Iron pants", "ironpants"),
|
||||
IRON_BOOTS(309, "Iron boots", "ironboots"),
|
||||
DIAMOND_HELMET(310, "Diamond helmet", "diamondhelmet"),
|
||||
DIAMOND_CHEST(311, "Diamond chestplate", "diamondchest"),
|
||||
DIAMOND_PANTS(312, "Diamond pants", "diamondpants"),
|
||||
DIAMOND_BOOTS(313, "Diamond boots", "diamondboots"),
|
||||
GOLD_HELMET(314, "Gold helmet", "goldhelmet"),
|
||||
GOLD_CHEST(315, "Gold chestplate", "goldchest"),
|
||||
GOLD_PANTS(316, "Gold pants", "goldpants"),
|
||||
GOLD_BOOTS(317, "Gold boots", "goldboots"),
|
||||
FLINT(318, "Flint", "flint"),
|
||||
RAW_PORKCHOP(319, "Raw porkchop", "rawporkchop"),
|
||||
COOKED_PORKCHOP(320, "Cooked porkchop", "cookedporkchop"),
|
||||
PAINTING(321, "Painting", "painting"),
|
||||
GOLD_APPLE(322, "Golden apple", "goldapple"),
|
||||
SIGN(323, "Wooden sign", "sign"),
|
||||
WOODEN_DOOR_ITEM(324, "Wooden door", "wooddoor"),
|
||||
BUCKET(325, "Bucket", "bucket"),
|
||||
WATER_BUCKET(326, "Water bucket", "waterbucket"),
|
||||
LAVA_BUCKET(327, "Lava bucket", "lavabucket"),
|
||||
MINECART(328, "Minecart", "minecart"),
|
||||
SADDLE(329, "Saddle", "saddle"),
|
||||
IRON_DOOR_ITEM(330, "Iron door", "irondoor"),
|
||||
REDSTONE_DUST(331, "Redstone dust", "redstonedust"),
|
||||
SNOWBALL(332, "Snowball", "snowball"),
|
||||
WOOD_BOAT(333, "Wooden boat", "woodboat"),
|
||||
LEATHER(334, "Leather", "leather"),
|
||||
MILK_BUCKET(335, "Milk bucket", "milkbucket"),
|
||||
BRICK_BAR(336, "Brick", "brick"),
|
||||
CLAY_BALL(337, "Clay", "clay"),
|
||||
SUGAR_CANE_ITEM(338, "Sugar cane", new String[]{"sugarcane", "reed", "reeds"}),
|
||||
PAPER(339, "Paper", "paper"),
|
||||
BOOK(340, "Book", "book"),
|
||||
SLIME_BALL(341, "Slime ball", "slimeball"),
|
||||
STORAGE_MINECART(342, "Storage minecart", "storageminecart"),
|
||||
POWERED_MINECART(343, "Powered minecart", "poweredminecart"),
|
||||
EGG(344, "Egg", "egg"),
|
||||
COMPASS(345, "Compass", "compass"),
|
||||
FISHING_ROD(346, "Fishing rod", "fishingrod"),
|
||||
WATCH(347, "Watch", "watch"),
|
||||
LIGHTSTONE_DUST(348, "Lightstone dust", "lightstonedust"),
|
||||
RAW_FISH(349, "Raw fish", "rawfish"),
|
||||
COOKED_FISH(350, "Cooked fish", "cookedfish"),
|
||||
INK_SACK(351, "Ink sack", "inksack"),
|
||||
BONE(352, "Bone", "bone"),
|
||||
SUGAR(353, "Sugar", "sugar"),
|
||||
CAKE_ITEM(354, "Cake", "cake"),
|
||||
GOLD_RECORD(2256, "Gold Record", "goldrecord"),
|
||||
GREEN_RECORD(2257, "Green Record", "greenrecord");
|
||||
|
||||
/**
|
||||
* Stores a map of the IDs for fast access.
|
||||
*/
|
||||
private static final Map<Integer,ItemType> ids = new HashMap<Integer,ItemType>();
|
||||
/**
|
||||
* Stores a map of the names for fast access.
|
||||
*/
|
||||
private static final Map<String,ItemType> lookup = new HashMap<String,ItemType>();
|
||||
|
||||
private final int id;
|
||||
private final String name;
|
||||
private final String[] lookupKeys;
|
||||
|
||||
static {
|
||||
for (ItemType type : EnumSet.allOf(ItemType.class)) {
|
||||
ids.put(type.id, type);
|
||||
for (String key : type.lookupKeys) {
|
||||
lookup.put(key, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct the type.
|
||||
*
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
ItemType(int id, String name, String lookupKey) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.lookupKeys = new String[]{lookupKey};
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct the type.
|
||||
*
|
||||
* @param id
|
||||
* @param name
|
||||
*/
|
||||
ItemType(int id, String name, String[] lookupKeys) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.lookupKeys = lookupKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return type from ID. May return null.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static ItemType fromID(int id) {
|
||||
return ids.get(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return type from name. May return null.
|
||||
*
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
public static ItemType lookup(String name) {
|
||||
return lookup.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get item numeric ID.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user-friendly item name.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if an item should not be stacked.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static boolean shouldNotStack(int id) {
|
||||
return (id >= 256 && id <= 259)
|
||||
|| id == 261
|
||||
|| (id >= 267 && id <= 279)
|
||||
|| (id >= 281 && id <= 286)
|
||||
|| (id >= 290 && id <= 294)
|
||||
|| (id >= 298 && id <= 317)
|
||||
|| (id >= 325 && id <= 327)
|
||||
|| id == 335
|
||||
|| id == 346;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if an item uses its damage value for something
|
||||
* other than damage.
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static boolean usesDamageValue(int id) {
|
||||
return id == 35
|
||||
|| id == 351;
|
||||
}
|
||||
}
|
@ -20,8 +20,9 @@
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import com.sk89q.worldedit.*;
|
||||
import com.sk89q.worldedit.Vector;
|
||||
import com.sk89q.worldedit.bags.BlockBag;
|
||||
|
||||
public class BukkitPlayer extends LocalPlayer {
|
||||
@ -47,7 +48,7 @@ public class BukkitPlayer extends LocalPlayer {
|
||||
@Override
|
||||
public int getItemInHand() {
|
||||
ItemStack itemStack = player.getItemInHand();
|
||||
return itemStack != null ? itemStack.getTypeID() : 0;
|
||||
return itemStack != null ? itemStack.getTypeId() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -21,7 +21,7 @@ package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.ItemStack;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
@ -47,12 +47,12 @@ public class BukkitWorld extends LocalWorld {
|
||||
|
||||
@Override
|
||||
public boolean setBlockType(Vector pt, int type) {
|
||||
return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setTypeID(type);
|
||||
return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).setTypeId(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBlockType(Vector pt) {
|
||||
return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getTypeID();
|
||||
return world.getBlockAt(pt.getBlockX(), pt.getBlockY(), pt.getBlockZ()).getTypeId();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
41
src/com/sk89q/worldedit/bukkit/WorldEditAPI.java
Normale Datei
41
src/com/sk89q/worldedit/bukkit/WorldEditAPI.java
Normale Datei
@ -0,0 +1,41 @@
|
||||
// $Id$
|
||||
/*
|
||||
* WorldEdit
|
||||
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import com.sk89q.worldedit.LocalSession;
|
||||
|
||||
public class WorldEditAPI {
|
||||
private WorldEditPlugin plugin;
|
||||
|
||||
public WorldEditAPI(WorldEditPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the session for a player.
|
||||
*
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public LocalSession getSession(Player player) {
|
||||
return plugin.controller.getSession(new BukkitPlayer(plugin.server, player));
|
||||
}
|
||||
}
|
@ -19,11 +19,10 @@
|
||||
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import org.bukkit.Player;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockBrokenEvent;
|
||||
import org.bukkit.event.block.BlockPlacedEvent;
|
||||
import org.bukkit.event.block.BlockRightClickedEvent;
|
||||
import org.bukkit.event.block.BlockRightClickEvent;
|
||||
|
||||
import com.sk89q.worldedit.*;
|
||||
|
||||
@ -43,17 +42,19 @@ public class WorldEditBlockListener extends BlockListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a block is broken (or destroyed)
|
||||
* Called when a block is damaged (or broken)
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
public void onBlockBroken(BlockBrokenEvent event) {
|
||||
public void onBlockDamage(BlockDamageEvent event) {
|
||||
LocalWorld world = new BukkitWorld(event.getBlock().getWorld());
|
||||
WorldVector pos = new WorldVector(world, event.getBlock().getX(),
|
||||
event.getBlock().getY(), event.getBlock().getZ());
|
||||
LocalPlayer player = wrapPlayer(event.getPlayer());
|
||||
|
||||
plugin.controller.handleBlockLeftClick(player, pos);
|
||||
if (plugin.controller.handleBlockLeftClick(player, pos)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -61,7 +62,7 @@ public class WorldEditBlockListener extends BlockListener {
|
||||
*
|
||||
* @param event Relevant event details
|
||||
*/
|
||||
public void onBlockRightClicked(BlockRightClickedEvent event) {
|
||||
public void onBlockRightClick(BlockRightClickEvent event) {
|
||||
LocalWorld world = new BukkitWorld(event.getBlock().getWorld());
|
||||
WorldVector pos = new WorldVector(world, event.getBlock().getX(),
|
||||
event.getBlock().getY(), event.getBlock().getZ());
|
||||
|
@ -20,6 +20,7 @@
|
||||
package com.sk89q.worldedit.bukkit;
|
||||
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
|
@ -37,6 +37,7 @@ import com.sk89q.worldedit.*;
|
||||
public class WorldEditPlugin extends JavaPlugin {
|
||||
public final ServerInterface server;
|
||||
public final WorldEditController controller;
|
||||
public final WorldEditAPI api;
|
||||
|
||||
private final WorldEditPlayerListener playerListener =
|
||||
new WorldEditPlayerListener(this);
|
||||
@ -44,8 +45,8 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
new WorldEditBlockListener(this);
|
||||
|
||||
public WorldEditPlugin(PluginLoader pluginLoader, Server instance,
|
||||
PluginDescriptionFile desc, File plugin, ClassLoader cLoader) {
|
||||
super(pluginLoader, instance, desc, plugin, cLoader);
|
||||
PluginDescriptionFile desc, File folder, File plugin, ClassLoader cLoader) {
|
||||
super(pluginLoader, instance, desc, folder, plugin, cLoader);
|
||||
|
||||
LocalConfiguration config = new LocalConfiguration() {
|
||||
@Override
|
||||
@ -58,6 +59,8 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
server = new BukkitServerInterface(getServer());
|
||||
controller = new WorldEditController(server, config);
|
||||
|
||||
api = new WorldEditAPI(this);
|
||||
|
||||
registerEvents();
|
||||
}
|
||||
|
||||
@ -79,4 +82,8 @@ public class WorldEditPlugin extends JavaPlugin {
|
||||
getServer().getPluginManager().registerEvent(Event.Type.BLOCK_RIGHTCLICKED,
|
||||
blockListener, Priority.Normal, this);
|
||||
}
|
||||
|
||||
public WorldEditAPI getAPI() {
|
||||
return api;
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class WorldSetBlockProxy extends World {
|
||||
*/
|
||||
@Override
|
||||
public int a(int x, int y, int z) {
|
||||
return editSession.getBlock(new Vector(x, y, z)).getID();
|
||||
return editSession.getBlock(new Vector(x, y, z)).getType();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,8 +37,8 @@ public class QueryTool implements SuperPickaxeMode {
|
||||
BaseBlock block = (new EditSession(server, world, 0)).rawGetBlock(clicked);
|
||||
|
||||
player.print("\u00A79@" + clicked + ": " + "\u00A7e"
|
||||
+ "Type: " + block.getID() + "\u00A77" + " ("
|
||||
+ BlockType.fromID(block.getID()).getName() + ") "
|
||||
+ "Type: " + block.getType() + "\u00A77" + " ("
|
||||
+ BlockType.fromID(block.getType()).getName() + ") "
|
||||
+ "\u00A7f"
|
||||
+ "[" + block.getData() + "]");
|
||||
|
||||
|
@ -94,7 +94,7 @@ public class RecursivePickaxe implements SuperPickaxeMode {
|
||||
|
||||
visited.add(pos);
|
||||
|
||||
if (editSession.getBlock(pos).getID() == initialType) {
|
||||
if (editSession.getBlock(pos).getType() == initialType) {
|
||||
if (drop) {
|
||||
world.simulateBlockMine(pos);
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren