Skip to content

Commit

Permalink
More default parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
melontini committed Mar 30, 2024
1 parent 086c238 commit ae92fee
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public interface Extractor extends Function<ServerCommandSource, String> {
static Consumer<Map<String, Extractor>> forEntity() {
return map -> {
map.put("uuid", source -> Objects.requireNonNull(source.getEntity()).getUuidAsString());
map.put("vel/x", source -> String.valueOf(Objects.requireNonNull(source.getEntity()).getVelocity().x));
map.put("vel/y", source -> String.valueOf(Objects.requireNonNull(source.getEntity()).getVelocity().y));
map.put("vel/z", source -> String.valueOf(Objects.requireNonNull(source.getEntity()).getVelocity().z));
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import me.melontini.commander.command.selector.Selector;
import me.melontini.commander.util.MagicCodecs;
import me.melontini.dark_matter.api.base.util.Utilities;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.util.Identifier;

import java.util.Collections;
Expand All @@ -24,6 +25,10 @@ public final class SelectorTypes {
map.put("x", source -> String.valueOf(source.getPosition().x));
map.put("y", source -> String.valueOf(source.getPosition().y));
map.put("z", source -> String.valueOf(source.getPosition().z));
map.put("rot/x", source -> String.valueOf(source.getRotation().x));
map.put("rot/y", source -> String.valueOf(source.getRotation().y));
map.put("name", ServerCommandSource::getName);
map.put("world/key", source -> source.getWorld().getRegistryKey().getValue().toString());
}));

public static final Codec<Selector> CODEC = MagicCodecs.mapLookup(SELECTORS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ static DataResult<BrigadierMacro> buildCommand(String input) {
Extractor extractor = SelectorTypes.getExtractor(identifier.result().orElseThrow(), field);
if (extractor == null) return DataResult.error(() -> "Selector %s does not support extractor %s".formatted(identifier, field));


var builder = new StringBuilder();
matcher.appendReplacement(builder,"");
String cmd = builder.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
public record DynamicMacro(String original, Function<EventContext, String> start) implements BrigadierMacro {

public String build(EventContext context) {
var s = start.apply(context);
System.out.println(s);
return s;
return start.apply(context);
}
}

0 comments on commit ae92fee

Please sign in to comment.