Remove FAWE-Piston

Disables a lot of previous functionality in FAWE until replacements can be made. This commit was untested and may cause major issues.
This commit is contained in:
MattBDev
2020-02-05 00:37:42 -05:00
parent 3452fd5a63
commit 75653087b9
46 changed files with 3643 additions and 3867 deletions

View File

@ -43,6 +43,7 @@ import com.sk89q.worldedit.extension.input.InputParseException;
import com.sk89q.worldedit.extension.input.NoMatchException;
import com.sk89q.worldedit.extension.input.ParserContext;
import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.extension.platform.Capability;
import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.extent.inventory.SlottableBlockBag;
import com.sk89q.worldedit.internal.registry.InputParser;
@ -289,8 +290,17 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
if (typeString.isEmpty()) {
throw new InputParseException("Invalid format");
}
// PosX
if (typeString.matches("pos[0-9]+")) {
if ("hand".equalsIgnoreCase(typeString)) {
// Get the block type from the item in the user's hand.
final BaseBlock blockInHand = getBlockInHand(context.requireActor(), HandSide.MAIN_HAND);
state = blockInHand.toBlockState();
nbt = blockInHand.getNbtData();
} else if ("offhand".equalsIgnoreCase(typeString)) {
// Get the block type from the item in the user's off hand.
final BaseBlock blockInHand = getBlockInHand(context.requireActor(), HandSide.OFF_HAND);
state = blockInHand.toBlockState();
nbt = blockInHand.getNbtData();
} else if (typeString.matches("pos[0-9]+")) {
int index = Integer.parseInt(typeString.replaceAll("[a-z]+", ""));
// Get the block type from the "primary position"
final World world = context.requireWorld();
@ -301,45 +311,34 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
throw new InputParseException("Your selection is not complete.");
}
state = world.getBlock(primaryPosition);
} else if (typeString.matches("slot[0-9]+")) {
int slot = Integer.parseInt(typeString.substring(4)) - 1;
Actor actor = context.requireActor();
if (!(actor instanceof Player)) {
throw new InputParseException("The user is not a player!");
}
Player player = (Player) actor;
BlockBag bag = player.getInventoryBlockBag();
if (bag == null || !(bag instanceof SlottableBlockBag)) {
throw new InputParseException("Unsupported!");
}
SlottableBlockBag slottable = (SlottableBlockBag) bag;
BaseItem item = slottable.getItem(slot);
if (!item.getType().hasBlockType()) {
throw new InputParseException("You're not holding a block!");
}
state = item.getType().getBlockType().getDefaultState();
nbt = item.getNbtData();
} else {
if ("hand".equalsIgnoreCase(typeString)) {
// Get the block type from the item in the user's hand.
BaseBlock block = getBlockInHand(context.requireActor(), HandSide.MAIN_HAND);
state = block.toBlockState();
nbt = block.getNbtData();
} else if ("offhand".equalsIgnoreCase(typeString)) {
// Get the block type from the item in the user's off hand.
BaseBlock block = getBlockInHand(context.requireActor(), HandSide.OFF_HAND);
state = block.toBlockState();
nbt = block.getNbtData();
} else if (typeString.matches("slot[0-9]+")) {
int slot = Integer.parseInt(typeString.substring(4)) - 1;
Actor actor = context.requireActor();
if (!(actor instanceof Player)) {
throw new InputParseException("The user is not a player!");
}
Player player = (Player) actor;
BlockBag bag = player.getInventoryBlockBag();
if (bag == null || !(bag instanceof SlottableBlockBag)) {
throw new InputParseException("Unsupported!");
}
SlottableBlockBag slottable = (SlottableBlockBag) bag;
BaseItem item = slottable.getItem(slot);
BlockType type = BlockTypes.parse(typeString.toLowerCase(Locale.ROOT));
if (!item.getType().hasBlockType()) {
throw new InputParseException("You're not holding a block!");
}
state = item.getType().getBlockType().getDefaultState();
nbt = item.getNbtData();
} else {
BlockType type = BlockTypes.parse(typeString.toLowerCase(Locale.ROOT));
if (type != null) {
state = type.getDefaultState();
}
if (state == null) {
throw new NoMatchException("Does not match a valid block type: '" + input + "'");
}
if (type != null) {
state = type.getDefaultState();
}
if (state == null) {
throw new NoMatchException(
"Does not match a valid block type: '" + input + "'");
}
}
if (nbt == null) nbt = state.getNbtData();
@ -351,15 +350,15 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
if (stateString == null || stateString.isEmpty()) {
state = new FuzzyBlockState(state);
} else {
BlockType type = state.getBlockType();
BlockType blockType = state.getBlockType();
FuzzyBlockState.Builder fuzzyBuilder = FuzzyBlockState.builder();
fuzzyBuilder.type(type);
fuzzyBuilder.type(blockType);
String[] entries = stateString.split(",");
for (String entry : entries) {
String[] split = entry.split("=");
String key = split[0];
String val = split[1];
Property<Object> prop = type.getProperty(key);
Property<Object> prop = blockType.getProperty(key);
fuzzyBuilder.withProperty(prop, prop.getValueFor(val));
}
state = fuzzyBuilder.build();
@ -398,9 +397,17 @@ public class DefaultBlockParser extends InputParser<BaseBlock> {
// Allow setting mob spawn type
if (blockAndExtraData.length > 1) {
String mobName = blockAndExtraData[1];
EntityType mobType = EntityTypes.parse(mobName);
EntityType ent = EntityTypes.get(mobName.toLowerCase(Locale.ROOT));
if (ent == null) {
throw new NoMatchException("Unknown entity type '" + mobName + "'");
}
mobName = ent.getId();
if (!worldEdit.getPlatformManager().queryCapability(Capability.USER_COMMANDS).isValidMobType(mobName)) {
throw new NoMatchException("Unknown mob type '" + mobName + "'");
}
return validate(context, new MobSpawnerBlock(state, mobName));
} else {
//noinspection ConstantConditions
return validate(context, new MobSpawnerBlock(state, EntityTypes.PIG.getId()));
}
} else if (blockType == BlockTypes.PLAYER_HEAD || blockType == BlockTypes.PLAYER_WALL_HEAD) {