mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 17:57:38 +00:00
Allow //replace to ignore from block damage values (and force them to not be ignored with the -f flag)
This commit is contained in:
parent
56fd654eed
commit
a1cf6eb6da
@ -207,9 +207,9 @@ public class EditSession {
|
|||||||
|
|
||||||
if (BlockType.usesData(type)) {
|
if (BlockType.usesData(type)) {
|
||||||
if (fastMode) {
|
if (fastMode) {
|
||||||
result = world.setTypeIdAndDataFast(pt, type, block.getData());
|
result = world.setTypeIdAndDataFast(pt, type, block.getData() > -1 ? block.getData() : 0);
|
||||||
} else {
|
} else {
|
||||||
result = world.setTypeIdAndData(pt, type, block.getData());
|
result = world.setTypeIdAndData(pt, type, block.getData() > -1 ? block.getData() : 0);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (fastMode) {
|
if (fastMode) {
|
||||||
|
@ -246,6 +246,11 @@ public class WorldEdit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BaseBlock getBlock(LocalPlayer player, String arg, boolean allAllowed)
|
||||||
|
throws UnknownItemException, DisallowedItemException {
|
||||||
|
return getBlock(player, arg, allAllowed, false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an item ID from an item name or an item ID number.
|
* Get an item ID from an item name or an item ID number.
|
||||||
*
|
*
|
||||||
@ -256,7 +261,8 @@ public class WorldEdit {
|
|||||||
* @throws UnknownItemException
|
* @throws UnknownItemException
|
||||||
* @throws DisallowedItemException
|
* @throws DisallowedItemException
|
||||||
*/
|
*/
|
||||||
public BaseBlock getBlock(LocalPlayer player, String arg, boolean allAllowed)
|
public BaseBlock getBlock(LocalPlayer player, String arg,
|
||||||
|
boolean allAllowed, boolean allowNoData)
|
||||||
throws UnknownItemException, DisallowedItemException {
|
throws UnknownItemException, DisallowedItemException {
|
||||||
BlockType blockType;
|
BlockType blockType;
|
||||||
arg = arg.replace("_", " ");
|
arg = arg.replace("_", " ");
|
||||||
@ -307,8 +313,8 @@ public class WorldEdit {
|
|||||||
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 {
|
||||||
data = args1.length > 1 ? Integer.parseInt(args1[1]) : 0;
|
data = args1.length > 1 ? Integer.parseInt(args1[1]) : (allowNoData ? -1 : 0);
|
||||||
if (data > 15 || data < 0) {
|
if (data > 15 || (data < 0 && !(allAllowed && data == -1))) {
|
||||||
data = 0;
|
data = 0;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
@ -344,6 +350,11 @@ public class WorldEdit {
|
|||||||
case COBBLESTONE:
|
case COBBLESTONE:
|
||||||
data = 3;
|
data = 3;
|
||||||
break;
|
break;
|
||||||
|
case BRICK:
|
||||||
|
data = 4;
|
||||||
|
break;
|
||||||
|
case STONE_BRICK:
|
||||||
|
data = 5;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new InvalidItemException(arg, "Invalid step type '" + args1[1] + "'");
|
throw new InvalidItemException(arg, "Invalid step type '" + args1[1] + "'");
|
||||||
@ -425,16 +436,22 @@ public class WorldEdit {
|
|||||||
return getBlock(player, id, false);
|
return getBlock(player, id, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<BaseBlock> getBlocks (LocalPlayer player, String list, boolean allAllowed)
|
public Set<BaseBlock> getBlocks (LocalPlayer player, String list,
|
||||||
|
boolean allAllowed, boolean allowNoData)
|
||||||
throws DisallowedItemException, UnknownItemException {
|
throws DisallowedItemException, UnknownItemException {
|
||||||
String[] items = list.split(",");
|
String[] items = list.split(",");
|
||||||
Set<BaseBlock> blocks = new HashSet<BaseBlock>();
|
Set<BaseBlock> blocks = new HashSet<BaseBlock>();
|
||||||
for (String id : items) {
|
for (String id : items) {
|
||||||
blocks.add(getBlock(player, id, allAllowed));
|
blocks.add(getBlock(player, id, allAllowed, allowNoData));
|
||||||
}
|
}
|
||||||
return blocks;
|
return blocks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<BaseBlock> getBlocks(LocalPlayer player, String list, boolean allAllowed)
|
||||||
|
throws DisallowedItemException, UnknownItemException {
|
||||||
|
return getBlocks(player, list, allAllowed);
|
||||||
|
}
|
||||||
|
|
||||||
public Set<BaseBlock> getBlocks(LocalPlayer player, String list)
|
public Set<BaseBlock> getBlocks(LocalPlayer player, String list)
|
||||||
throws DisallowedItemException, UnknownItemException {
|
throws DisallowedItemException, UnknownItemException {
|
||||||
return getBlocks(player, list, false);
|
return getBlocks(player, list, false);
|
||||||
|
@ -129,7 +129,8 @@ public class BaseBlock {
|
|||||||
if (!(o instanceof BaseBlock)) {
|
if (!(o instanceof BaseBlock)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (type == ((BaseBlock)o).type) && (data == ((BaseBlock)o).data);
|
return (type == ((BaseBlock)o).type)
|
||||||
|
&& (data == ((BaseBlock)o).data || data == -1 || ((BaseBlock)o).data == -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,6 +73,7 @@ public class RegionCommands {
|
|||||||
aliases = {"/replace"},
|
aliases = {"/replace"},
|
||||||
usage = "[from-block] <to-block>",
|
usage = "[from-block] <to-block>",
|
||||||
desc = "Replace all blocks in the selection with another",
|
desc = "Replace all blocks in the selection with another",
|
||||||
|
flags = "f",
|
||||||
min = 1,
|
min = 1,
|
||||||
max = 2
|
max = 2
|
||||||
)
|
)
|
||||||
@ -88,7 +89,7 @@ public class RegionCommands {
|
|||||||
from = null;
|
from = null;
|
||||||
to = we.getBlockPattern(player, args.getString(0));
|
to = we.getBlockPattern(player, args.getString(0));
|
||||||
} else {
|
} else {
|
||||||
from = we.getBlocks(player, args.getString(0), true);
|
from = we.getBlocks(player, args.getString(0), true, !args.hasFlag('f'));
|
||||||
to = we.getBlockPattern(player, args.getString(1));
|
to = we.getBlockPattern(player, args.getString(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,6 +228,7 @@ public class UtilityCommands {
|
|||||||
aliases = {"/replacenear", "replacenear"},
|
aliases = {"/replacenear", "replacenear"},
|
||||||
usage = "<size> <from-id> <to-id>",
|
usage = "<size> <from-id> <to-id>",
|
||||||
desc = "Replace nearby blocks",
|
desc = "Replace nearby blocks",
|
||||||
|
flags = "f",
|
||||||
min = 3,
|
min = 3,
|
||||||
max = 3
|
max = 3
|
||||||
)
|
)
|
||||||
@ -245,7 +246,7 @@ public class UtilityCommands {
|
|||||||
from = null;
|
from = null;
|
||||||
to = we.getBlockPattern(player, args.getString(1));
|
to = we.getBlockPattern(player, args.getString(1));
|
||||||
} else {
|
} else {
|
||||||
from = we.getBlocks(player, args.getString(1), true);
|
from = we.getBlocks(player, args.getString(1), true, !args.hasFlag('f'));
|
||||||
to = we.getBlockPattern(player, args.getString(2));
|
to = we.getBlockPattern(player, args.getString(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user