Skip to content

Commit 05867f7

Browse files
authored
feat: Create TabCompleter; version: Change version
1 parent 031bac3 commit 05867f7

File tree

5 files changed

+49
-3
lines changed

5 files changed

+49
-3
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
}
55

66
// Set project version using a property, defaulting to 'unspecified' if not found
7-
version = '1.4.2-RELEASE'
7+
version = '1.5.0-RELEASE'
88
group = 'io.github.mcengine'
99

1010
ext {

common/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
id 'java'
33
}
44

5-
version = '1.2.4-RELEASE'
5+
version = '1.3.0-RELEASE'
66

77
dependencies {
88
// Self Api
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package io.github.mcengine.common.artificialintelligence.tabcompleter;
2+
3+
import org.bukkit.command.Command;
4+
import org.bukkit.command.CommandSender;
5+
import org.bukkit.command.TabCompleter;
6+
import org.bukkit.entity.Player;
7+
8+
import java.util.ArrayList;
9+
import java.util.Collections;
10+
import java.util.List;
11+
12+
/**
13+
* Tab completer for the /ai command.
14+
* Provides suggestions for subcommands such as "reload".
15+
*/
16+
public class MCEngineArtificialIntelligenceCommonTabCompleter implements TabCompleter {
17+
18+
/**
19+
* Provides tab completion suggestions for the /ai command.
20+
*
21+
* @param sender The sender of the command.
22+
* @param command The command object.
23+
* @param alias The alias used for the command.
24+
* @param args The arguments provided with the command.
25+
* @return A list of possible completions for the last argument.
26+
*/
27+
@Override
28+
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
29+
// Only one argument supported currently
30+
if (args.length == 1) {
31+
List<String> completions = new ArrayList<>();
32+
if (sender.hasPermission("mcengine.artificialintelligence.reload")) {
33+
if ("reload".startsWith(args[0].toLowerCase())) {
34+
completions.add("reload");
35+
}
36+
}
37+
return completions;
38+
}
39+
40+
return Collections.emptyList();
41+
}
42+
}

server/spigotmc/engine/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ plugins {
22
id 'java'
33
}
44

5-
version = '1.3.2-RELEASE'
5+
version = '1.4.0-RELEASE'
66

77
dependencies {
88
compileOnly 'org.spigotmc:spigot-api:1.21.5-R0.1-SNAPSHOT'

server/spigotmc/engine/src/main/java/io/github/mcengine/spigotmc/artificialintelligence/engine/MCEngineArtificialIntelligenceSpigotMC.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import io.github.mcengine.api.artificialintelligence.ThreadPoolManager;
77
import io.github.mcengine.common.artificialintelligence.command.MCEngineArtificialIntelligenceCommonCommand;
88
import io.github.mcengine.common.artificialintelligence.listener.MCEngineArtificialIntelligenceCommonListenerConversation;
9+
import io.github.mcengine.common.artificialintelligence.tabcompleter.MCEngineArtificialIntelligenceCommonTabCompleter;
910
import io.github.mcengine.spigotmc.artificialintelligence.engine.Metrics;
1011
import org.bukkit.event.HandlerList;
1112
import org.bukkit.plugin.PluginManager;
@@ -78,6 +79,9 @@ public void reloadAiComponents() {
7879
getCommand("ai").setExecutor(
7980
new MCEngineArtificialIntelligenceCommonCommand(this, this::reloadAiComponents)
8081
);
82+
getCommand("ai").setTabCompleter(
83+
new MCEngineArtificialIntelligenceCommonTabCompleter()
84+
);
8185

8286
getLogger().info("AI components reloaded successfully.");
8387
} catch (Exception e) {

0 commit comments

Comments
 (0)