Change the block type check to be implementation-dependent. The Bukkit plugin now checks Bukkit's Material.

Dieser Commit ist enthalten in:
sk89q 2011-06-04 22:22:23 -07:00
Ursprung 0f040429c5
Commit e20cca38fd
6 geänderte Dateien mit 53 neuen und 5 gelöschten Zeilen

Datei anzeigen

@ -164,7 +164,7 @@ public class EditSession {
}
// No invalid blocks
if ((type > 32 && type < 35) || type == 36 || type == 29 || type > 96) {
if (!world.isValidBlockType(type)) {
return false;
}

Datei anzeigen

@ -304,6 +304,16 @@ public abstract class LocalWorld {
* @return
*/
public abstract int removeEntities(EntityType type, Vector origin, int radius);
/**
* Returns whether a block has a valid ID.
*
* @param type
* @return
*/
public boolean isValidBlockType(int type) {
return !((type > 32 && type < 35) || type == 36 || type == 29 || type > 96);
}
/**
* Compare if the other world is equal.

Datei anzeigen

@ -40,6 +40,16 @@ public abstract class ServerInterface {
*/
public abstract boolean isValidMobType(String type);
/**
* Returns whether a block has a valid ID.
*
* @param type
* @return
*/
public boolean isValidBlockType(int type) {
return !((type > 32 && type < 35) || type == 36 || type == 29 || type > 96);
}
/**
* Reload WorldEdit configuration.
*/

Datei anzeigen

@ -202,13 +202,15 @@ public class WorldEdit {
String[] args0 = arg.split("\\|");
String[] args1 = args0[0].split(":", 2);
String testID = args1[0];
int blockId = -1;
int data = -1;
// Attempt to parse the item ID or otherwise resolve an item/block
// name to its numeric ID
try {
blockType = BlockType.fromID(Integer.parseInt(testID));
blockId = Integer.parseInt(testID);
blockType = BlockType.fromID(blockId);
} catch (NumberFormatException e) {
blockType = BlockType.lookup(testID);
if (blockType == null) {
@ -219,7 +221,7 @@ public class WorldEdit {
}
}
if (blockType == null) {
if (blockId == -1 && blockType == null) {
// Maybe it's a cloth
ClothColor col = ClothColor.lookup(testID);
@ -231,6 +233,15 @@ public class WorldEdit {
}
}
// Read block ID
if (blockId == -1) {
blockId = blockType.getID();
}
if (!server.isValidBlockType(blockId)) {
throw new UnknownItemException(arg);
}
if (data == -1) { // Block data not yet detected
// Parse the block data (optional)
try {
@ -274,7 +285,7 @@ public class WorldEdit {
// Check if the item is allowed
if (allAllowed || player.hasPermission("worldedit.anyblock")
|| !config.disallowedBlocks.contains(blockType.getID())) {
|| !config.disallowedBlocks.contains(blockId)) {
// Allow special sign text syntax
if (blockType == BlockType.SIGN_POST
@ -317,7 +328,7 @@ public class WorldEdit {
}
}
return new BaseBlock(blockType.getID(), data);
return new BaseBlock(blockId, data);
}
throw new DisallowedItemException(arg);

Datei anzeigen

@ -42,6 +42,11 @@ public class BukkitServerInterface extends ServerInterface {
public boolean isValidMobType(String type) {
return CreatureType.fromName(type) != null;
}
@Override
public boolean isValidBlockType(int type) {
return Material.getMaterial(type) != null;
}
@Override
public void reload() {

Datei anzeigen

@ -39,6 +39,7 @@ import org.bukkit.entity.Wolf;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.TreeType;
import org.bukkit.World;
import com.sk89q.worldedit.EditSession;
@ -627,6 +628,17 @@ public class BukkitWorld extends LocalWorld {
return true;
}
/**
* Returns whether a block has a valid ID.
*
* @param type
* @return
*/
@Override
public boolean isValidBlockType(int type) {
return Material.getMaterial(type) != null;
}
@Override
public boolean equals(Object other) {