Skip to content

Commit

Permalink
feat(BlockPropertyValuesNode): BlockPropertyValuesNode now will fill …
Browse files Browse the repository at this point in the history
…missing property values
  • Loading branch information
smartcmd committed Oct 15, 2024
1 parent b52f8f6 commit 71ca7a9
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -39,7 +38,7 @@ public boolean match(CommandContext context) {
}

BlockType<?> blockType = context.getResult(context.getCurrentResultIndex() - 1);
var properties = new ArrayList<BlockPropertyType.BlockPropertyValue<?, ?, ?>>();
var propertyValues = new HashMap<BlockPropertyType<?>, BlockPropertyType.BlockPropertyValue<?, ?, ?>>();
for (var propertyStr : AllayStringUtils.fastSplit(substring, ",")) {
var split = AllayStringUtils.fastTwoPartSplit(propertyStr, "=", "");
var key = removeQuote(split[0]);
Expand All @@ -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;
}
Expand Down

0 comments on commit 71ca7a9

Please sign in to comment.