From 71ca7a909d280ac7d614ef852bc4cb5f1fe93811 Mon Sep 17 00:00:00 2001 From: daoge_cmd <3523206925@qq.com> Date: Tue, 15 Oct 2024 14:07:52 +0800 Subject: [PATCH] feat(BlockPropertyValuesNode): BlockPropertyValuesNode now will fill missing property values --- .../command/tree/node/BlockPropertyValuesNode.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/org/allaymc/server/command/tree/node/BlockPropertyValuesNode.java b/server/src/main/java/org/allaymc/server/command/tree/node/BlockPropertyValuesNode.java index dcf7bb4d0..92fb0e421 100644 --- a/server/src/main/java/org/allaymc/server/command/tree/node/BlockPropertyValuesNode.java +++ b/server/src/main/java/org/allaymc/server/command/tree/node/BlockPropertyValuesNode.java @@ -10,8 +10,7 @@ import org.cloudburstmc.protocol.bedrock.data.command.CommandParam; import org.cloudburstmc.protocol.bedrock.data.command.CommandParamData; -import java.util.ArrayList; -import java.util.List; +import java.util.*; /** * @author daoge_cmd @@ -39,7 +38,7 @@ public boolean match(CommandContext context) { } BlockType blockType = context.getResult(context.getCurrentResultIndex() - 1); - var properties = new ArrayList>(); + var propertyValues = new HashMap, BlockPropertyType.BlockPropertyValue>(); for (var propertyStr : AllayStringUtils.fastSplit(substring, ",")) { var split = AllayStringUtils.fastTwoPartSplit(propertyStr, "=", ""); var key = removeQuote(split[0]); @@ -56,10 +55,14 @@ public boolean match(CommandContext context) { context.addError("%" + TrKeys.M_COMMANDS_BLOCKSTATE_VALUEERROR, key + "=" + value); return false; } - properties.add(propertyValue); + propertyValues.put(propertyType, propertyValue); } - context.putResult(properties); + for (var propertyValue : blockType.getDefaultState().getPropertyValues().values()) { + propertyValues.putIfAbsent(propertyValue.getPropertyType(), propertyValue); + } + + context.putResult(new ArrayList<>(propertyValues.values())); context.popArg(); return true; }