Improved handling of valid blocks not in BlockType and added dragon egg to BlockType

This commit is contained in:
zml2008 2011-11-27 15:29:26 -08:00
parent 5d59dd764e
commit 51dd7a0c9c
4 changed files with 89 additions and 78 deletions

View File

@ -321,6 +321,7 @@ public class WorldEdit {
data = 0; data = 0;
} }
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
if (blockType != null) {
switch (blockType) { switch (blockType) {
case CLOTH: case CLOTH:
ClothColor col = ClothColor.lookup(typeAndData[1]); ClothColor col = ClothColor.lookup(typeAndData[1]);
@ -370,11 +371,15 @@ public class WorldEdit {
default: default:
throw new InvalidItemException(arg, "Unknown data value '" + typeAndData[1] + "'"); throw new InvalidItemException(arg, "Unknown data value '" + typeAndData[1] + "'");
} }
} else {
throw new InvalidItemException(arg, "Unknown data value '" + typeAndData[1] + "'");
}
} }
} }
// Check if the item is allowed // Check if the item is allowed
if (allAllowed || player.hasPermission("worldedit.anyblock") || !config.disallowedBlocks.contains(blockId)) { if (allAllowed || player.hasPermission("worldedit.anyblock") || !config.disallowedBlocks.contains(blockId)) {
if (blockType != null) {
switch (blockType) { switch (blockType) {
case SIGN_POST: case SIGN_POST:
case WALL_SIGN: case WALL_SIGN:
@ -420,6 +425,9 @@ public class WorldEdit {
default: default:
return new BaseBlock(blockId, data); return new BaseBlock(blockId, data);
} }
} else {
return new BaseBlock(blockId, data);
}
} }
throw new DisallowedItemException(arg); throw new DisallowedItemException(arg);

View File

@ -148,4 +148,5 @@ public final class BlockID {
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;
} }

View File

@ -157,7 +157,8 @@ public enum BlockType {
CAULDRON(BlockID.CAULDRON, "Cauldron"), CAULDRON(BlockID.CAULDRON, "Cauldron"),
END_PORTAL(BlockID.END_PORTAL, "End Portal", "endportal", "blackstuff", "airportal", "weirdblackstuff"), END_PORTAL(BlockID.END_PORTAL, "End Portal", "endportal", "blackstuff", "airportal", "weirdblackstuff"),
END_PORTAL_FRAME(BlockID.END_PORTAL_FRAME, "End Portal Frame", "endportalframe", "airportalframe", "crystalblock"), END_PORTAL_FRAME(BlockID.END_PORTAL_FRAME, "End Portal Frame", "endportalframe", "airportalframe", "crystalblock"),
END_STONE(BlockID.END_STONE, "End Stone", "endstone", "enderstone", "endersand"); END_STONE(BlockID.END_STONE, "End Stone", "endstone", "enderstone", "endersand"),
DRAGON_EGG(BlockID.DRAGON_EGG, "Dragon Egg", "dragonegg", "dragons");
/** /**
* Stores a map of the IDs for fast access. * Stores a map of the IDs for fast access.

View File

@ -158,6 +158,7 @@ public enum ItemType {
END_PORTAL(BlockID.END_PORTAL, "End Portal", "endportal", "blackstuff", "airportal", "weirdblackstuff"), END_PORTAL(BlockID.END_PORTAL, "End Portal", "endportal", "blackstuff", "airportal", "weirdblackstuff"),
END_PORTAL_FRAME(BlockID.END_PORTAL_FRAME, "End Portal Frame", "endportalframe", "airportalframe", "crystalblock"), END_PORTAL_FRAME(BlockID.END_PORTAL_FRAME, "End Portal Frame", "endportalframe", "airportalframe", "crystalblock"),
END_STONE(BlockID.END_STONE, "End Stone", "endstone", "enderstone", "endersand"), END_STONE(BlockID.END_STONE, "End Stone", "endstone", "enderstone", "endersand"),
DRAGON_EGG(BlockID.DRAGON_EGG, "Dragon Egg", "dragonegg", "dragons"),
// Items // Items
IRON_SHOVEL(ItemID.IRON_SHOVEL, "Iron shovel", "ironshovel"), IRON_SHOVEL(ItemID.IRON_SHOVEL, "Iron shovel", "ironshovel"),