Skip to content

Commit

Permalink
1.6.6
Browse files Browse the repository at this point in the history
  • Loading branch information
ancap-kun committed Feb 17, 2023
1 parent 100c6b4 commit ce85459
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Artifex/dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>Artifex</artifactId>
<name>Artifex</name>
<version>1.6.5</version>
<version>1.6.6</version>
<description>AncapAPI runtime part</description>
<build>
<finalName>artifex-v${version}</finalName>
Expand Down
2 changes: 1 addition & 1 deletion Artifex/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<packaging>jar</packaging>

<artifactId>Artifex</artifactId>
<version>1.6.5</version>
<version>1.6.6</version>

<name>Artifex</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import ru.ancap.framework.communicate.Communicator;
import ru.ancap.framework.communicate.replacement.Placeholder;
import ru.ancap.framework.artifex.Artifex;
import ru.ancap.framework.command.api.event.OperableEvent;
import ru.ancap.framework.command.api.event.classic.*;
import ru.ancap.framework.communicate.Communicator;
import ru.ancap.framework.communicate.replacement.Placeholder;
import ru.ancap.framework.language.additional.LAPIMessage;

@AllArgsConstructor
Expand Down Expand Up @@ -59,7 +59,7 @@ public void on(CannotTransformArgumentEvent event) {
new Form(event, event.sender()),
"command.api.error.cannot-transform-argument",
new Placeholder("ARGUMENT", String.join(" ", event.argument())),
new Placeholder("TYPE", event.type())
new Placeholder("TYPE", new LAPIMessage("ru.ancap.types."+event.type().getName()))
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.bukkit.command.CommandSender;
import ru.ancap.framework.command.api.commands.object.tab.TabCompletion;
import ru.ancap.framework.command.api.commands.operator.arguments.extractor.ArgumentExtractor;
import ru.ancap.framework.communicate.message.CallableMessage;

import java.util.List;
import java.util.function.Function;

@AllArgsConstructor
@ToString
Expand All @@ -13,10 +19,15 @@ public class Argument {
private final String argumentName;
private final ArgumentExtractor<?> argumentExtractor;
private final boolean optional;
private final Function<CommandSender, List<TabCompletion>> help;

public Argument(String argumentName, ArgumentExtractor<?> argumentExtractor) {
this(argumentName, argumentExtractor, false);
}

public Argument(String argumentName, ArgumentExtractor<?> argumentExtractor, boolean optional) {
this(argumentName, argumentExtractor, optional, null);
}

public String argumentName() {
return this.argumentName;
Expand All @@ -30,4 +41,8 @@ public boolean optional() {
return this.optional;
}

public Function<CommandSender, List<TabCompletion>> help() {
return this.help;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import lombok.ToString;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import ru.ancap.commons.AncapDebug;
import ru.ancap.framework.command.api.commands.object.dispatched.LeveledCommand;
import ru.ancap.framework.command.api.commands.object.dispatched.exception.NoNextArgumentException;
import ru.ancap.framework.command.api.commands.object.event.CommandDispatch;
import ru.ancap.framework.command.api.commands.object.event.CommandWrite;
import ru.ancap.framework.command.api.commands.object.executor.CommandOperator;
import ru.ancap.framework.command.api.commands.object.tab.OptionalTab;
import ru.ancap.framework.command.api.commands.object.tab.TabBundle;
import ru.ancap.framework.command.api.commands.object.tab.TabCompletion;
import ru.ancap.framework.command.api.commands.operator.arguments.bundle.ArgumentsBundle;
import ru.ancap.framework.command.api.commands.operator.arguments.bundle.ArgumentsMap;
import ru.ancap.framework.command.api.commands.operator.arguments.command.ArgumentCommandDispatch;
Expand All @@ -26,6 +26,7 @@
import java.util.Map;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;

@RequiredArgsConstructor
Expand Down Expand Up @@ -83,7 +84,7 @@ public void on(CommandDispatch dispatch) {
}

while (!command.isRaw() && argumentIndex <= this.arguments.size() - 1) {
Argument argument = this.arguments.get(0);
Argument argument = this.arguments.get(argumentIndex);
Object extracted;
try {
extracted = argument.extractor().extract(command);
Expand All @@ -102,6 +103,7 @@ public void on(CommandDispatch dispatch) {
else throw new IllegalStateException();
}
map.put(argument.argumentName(), extracted);
argumentIndex ++;
}

ArgumentsBundle bundle = new ArgumentsMap(Map.copyOf(map));
Expand Down Expand Up @@ -130,9 +132,13 @@ public void on(CommandWrite write) {
if (shard == null) return;

ArgumentBounding bounding = this.optionalityBounding.get(shard.node().optional());

Function<CommandSender, List<TabCompletion>> tabFunction = shard.node().help() != null ?
shard.node().help() :
shard.node().extractor().help();

write.speaker().sendTab(TabBundle.builder()
.tooltiped(shard.node().extractor().help().apply(write.speaker().source().sender()).stream()
.tooltiped(tabFunction.apply(write.speaker().source().sender()).stream()
.map(tabCompletion -> new OptionalTab(bounding.opening + tabCompletion.completion() + bounding.closing, tabCompletion.tooltipState()))
.collect(Collectors.toList()))
.replace((written - 1) - shard.firstLiteralIndex())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import lombok.AllArgsConstructor;
import org.bukkit.configuration.ConfigurationSection;
import org.jetbrains.annotations.Nullable;
import ru.ancap.commons.AncapDebug;

import java.util.*;
import java.util.function.Function;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

@AllArgsConstructor
public class BuiltTransferMap implements TransferMap {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.jetbrains.annotations.NotNull;
import ru.ancap.commons.AncapDebug;
import ru.ancap.framework.resource.ResourcePreparator;

import java.io.File;
Expand Down

0 comments on commit ce85459

Please sign in to comment.