mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
Change the block type check to be implementation-dependent. The Bukkit plugin now checks Bukkit's Material.
This commit is contained in:
parent
0f040429c5
commit
e20cca38fd
@ -164,7 +164,7 @@ public class EditSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// No invalid blocks
|
// No invalid blocks
|
||||||
if ((type > 32 && type < 35) || type == 36 || type == 29 || type > 96) {
|
if (!world.isValidBlockType(type)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,6 +304,16 @@ public abstract class LocalWorld {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public abstract int removeEntities(EntityType type, Vector origin, int radius);
|
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.
|
* Compare if the other world is equal.
|
||||||
|
@ -40,6 +40,16 @@ public abstract class ServerInterface {
|
|||||||
*/
|
*/
|
||||||
public abstract boolean isValidMobType(String type);
|
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.
|
* Reload WorldEdit configuration.
|
||||||
*/
|
*/
|
||||||
|
@ -202,13 +202,15 @@ public class WorldEdit {
|
|||||||
String[] args0 = arg.split("\\|");
|
String[] args0 = arg.split("\\|");
|
||||||
String[] args1 = args0[0].split(":", 2);
|
String[] args1 = args0[0].split(":", 2);
|
||||||
String testID = args1[0];
|
String testID = args1[0];
|
||||||
|
int blockId = -1;
|
||||||
|
|
||||||
int data = -1;
|
int data = -1;
|
||||||
|
|
||||||
// Attempt to parse the item ID or otherwise resolve an item/block
|
// Attempt to parse the item ID or otherwise resolve an item/block
|
||||||
// name to its numeric ID
|
// name to its numeric ID
|
||||||
try {
|
try {
|
||||||
blockType = BlockType.fromID(Integer.parseInt(testID));
|
blockId = Integer.parseInt(testID);
|
||||||
|
blockType = BlockType.fromID(blockId);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
blockType = BlockType.lookup(testID);
|
blockType = BlockType.lookup(testID);
|
||||||
if (blockType == null) {
|
if (blockType == null) {
|
||||||
@ -219,7 +221,7 @@ public class WorldEdit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockType == null) {
|
if (blockId == -1 && blockType == null) {
|
||||||
// Maybe it's a cloth
|
// Maybe it's a cloth
|
||||||
ClothColor col = ClothColor.lookup(testID);
|
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
|
if (data == -1) { // Block data not yet detected
|
||||||
// Parse the block data (optional)
|
// Parse the block data (optional)
|
||||||
try {
|
try {
|
||||||
@ -274,7 +285,7 @@ public class WorldEdit {
|
|||||||
|
|
||||||
// Check if the item is allowed
|
// Check if the item is allowed
|
||||||
if (allAllowed || player.hasPermission("worldedit.anyblock")
|
if (allAllowed || player.hasPermission("worldedit.anyblock")
|
||||||
|| !config.disallowedBlocks.contains(blockType.getID())) {
|
|| !config.disallowedBlocks.contains(blockId)) {
|
||||||
|
|
||||||
// Allow special sign text syntax
|
// Allow special sign text syntax
|
||||||
if (blockType == BlockType.SIGN_POST
|
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);
|
throw new DisallowedItemException(arg);
|
||||||
|
@ -42,6 +42,11 @@ public class BukkitServerInterface extends ServerInterface {
|
|||||||
public boolean isValidMobType(String type) {
|
public boolean isValidMobType(String type) {
|
||||||
return CreatureType.fromName(type) != null;
|
return CreatureType.fromName(type) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValidBlockType(int type) {
|
||||||
|
return Material.getMaterial(type) != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload() {
|
public void reload() {
|
||||||
|
@ -39,6 +39,7 @@ import org.bukkit.entity.Wolf;
|
|||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.TreeType;
|
import org.bukkit.TreeType;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
@ -627,6 +628,17 @@ public class BukkitWorld extends LocalWorld {
|
|||||||
|
|
||||||
return true;
|
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
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
|
Loading…
Reference in New Issue
Block a user