Skip to content

Commit de09b90

Browse files
committed
release: v1.4.0-beta.2
1 parent 0396da4 commit de09b90

9 files changed

Lines changed: 149 additions & 250 deletions

File tree

.github/workflows/maven-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ jobs:
7676
"name": "BellCommand ${{ github.ref_name }}",
7777
"version_number": "${{ github.ref_name }}",
7878
"changelog": $(echo "${{ steps.commit.outputs.message }}" | jq -Rsa .),
79-
"game_versions": ["1.13", "1.14", "1.15", "1.16", "1.17", "1.18", "1.19", "1.20", "1.21"],
79+
"game_versions": ["1.13", "1.13.1", "1.13.2", "1.14", "1.14.1", "1.14.2", "1.14.3", "1.14.4", "1.15", "1.15.1", "1.15.2", "1.16", "1.16.1", "1.16.2", "1.16.3", "1.16.4", "1.16.5", "1.17", "1.17.1", "1.18", "1.18.1", "1.18.2", "1.19", "1.19.1", "1.19.2", "1.19.3", "1.19.4", "1.20", "1.20.1", "1.20.2", "1.20.3", "1.20.4", "1.20.5", "1.20.6", "1.21", "1.21.1"],
8080
"version_type": "$VERSION_TYPE",
8181
"loaders": ["spigot", "paper", "purpur"],
8282
"project_id": "n18snJd9",

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>cn.ningmo</groupId>
88
<artifactId>bellcommand</artifactId>
9-
<version>1.4.0-beta.1</version>
9+
<version>1.4.0-beta.2</version>
1010
<packaging>jar</packaging>
1111

1212
<name>BellCommand</name>

src/main/java/cn/ningmo/bellcommand/BellCommand.java

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ public void onEnable() {
5353

5454
// 5. 注册命令和监听器
5555
getCommand("bc").setExecutor(this);
56+
getCommand("bc").setTabCompleter(this);
5657
getServer().getPluginManager().registerEvents(new ItemClickListener(this), this);
5758
getServer().getPluginManager().registerEvents(new AutoGiveListener(this), this);
5859

@@ -146,10 +147,56 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
146147
}
147148
}
148149

150+
@Override
151+
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
152+
List<String> completions = new ArrayList<>();
153+
154+
if (args.length == 1) {
155+
List<String> subCommands = new ArrayList<>();
156+
if (sender.hasPermission("bellcommand.give")) subCommands.add("give");
157+
if (sender.hasPermission("bellcommand.reload")) subCommands.add("reload");
158+
if (sender.hasPermission("bellcommand.list")) subCommands.add("list");
159+
subCommands.add("help");
160+
161+
for (String sub : subCommands) {
162+
if (sub.startsWith(args[0].toLowerCase())) {
163+
completions.add(sub);
164+
}
165+
}
166+
} else if (args.length == 2 && args[0].equalsIgnoreCase("give")) {
167+
if (sender.hasPermission("bellcommand.give")) {
168+
for (Player player : getServer().getOnlinePlayers()) {
169+
if (player.getName().toLowerCase().startsWith(args[1].toLowerCase())) {
170+
completions.add(player.getName());
171+
}
172+
}
173+
}
174+
} else if (args.length == 3 && args[0].equalsIgnoreCase("give")) {
175+
if (sender.hasPermission("bellcommand.give")) {
176+
for (CommandItem item : itemManager.getAllItems()) {
177+
if (item.getId().toLowerCase().startsWith(args[2].toLowerCase())) {
178+
completions.add(item.getId());
179+
}
180+
}
181+
}
182+
}
183+
184+
return completions;
185+
}
186+
149187
private void handleGiveCommand(CommandSender sender, String[] args) {
150188
String playerName = args[1];
151189
String itemId = args[2];
152-
int amount = args.length > 3 ? Math.max(1, Integer.parseInt(args[3])) : 1;
190+
int amount = 1;
191+
192+
if (args.length > 3) {
193+
try {
194+
amount = Math.max(1, Integer.parseInt(args[3]));
195+
} catch (NumberFormatException e) {
196+
sender.sendMessage(languageManager.getMessage("messages.command.give-usage"));
197+
return;
198+
}
199+
}
153200

154201
Player target = getServer().getPlayer(playerName);
155202
if (target == null) {

src/main/java/cn/ningmo/bellcommand/ItemClickListener.java

Lines changed: 0 additions & 155 deletions
This file was deleted.

src/main/java/cn/ningmo/bellcommand/item/CommandItem.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,13 @@ public AutoCleanupConfig(ConfigurationSection config) {
9999
public static class CommandEntry {
100100
private final String command;
101101
private final boolean asConsole;
102+
private final boolean asOp;
102103
private final double delay; // 延迟执行时间(秒)
103104

104-
public CommandEntry(String command, boolean asConsole, double delay) {
105+
public CommandEntry(String command, boolean asConsole, boolean asOp, double delay) {
105106
this.command = command;
106107
this.asConsole = asConsole;
108+
this.asOp = asOp;
107109
this.delay = delay;
108110
}
109111

@@ -115,6 +117,10 @@ public boolean isAsConsole() {
115117
return asConsole;
116118
}
117119

120+
public boolean isAsOp() {
121+
return asOp;
122+
}
123+
118124
public double getDelay() {
119125
return delay;
120126
}
@@ -153,9 +159,10 @@ public CommandItem(String id, ConfigurationSection config) {
153159
if (cmdSection != null) {
154160
String cmd = cmdSection.getString("command");
155161
boolean asConsole = cmdSection.getBoolean("as-console", false);
162+
boolean asOp = cmdSection.getBoolean("as-op", false);
156163
double delay = cmdSection.getDouble("delay", 0.0); // 获取延迟时间,默认为0秒
157164
if (cmd != null && !cmd.isEmpty()) {
158-
typeCommands.add(new CommandEntry(cmd, asConsole, delay));
165+
typeCommands.add(new CommandEntry(cmd, asConsole, asOp, delay));
159166
}
160167
}
161168
}
@@ -185,7 +192,15 @@ public double getCooldown() {
185192
}
186193

187194
public List<CommandEntry> getCommands(String type) {
188-
return commands.getOrDefault(type, new ArrayList<>());
195+
List<CommandEntry> result = commands.getOrDefault(type, new ArrayList<>());
196+
197+
// 如果是基岩版特定的点击类型且没有配置,则回退到普通点击类型
198+
if (result.isEmpty() && type.startsWith("bedrock-")) {
199+
String fallbackType = type.replace("bedrock-", "");
200+
result = commands.getOrDefault(fallbackType, new ArrayList<>());
201+
}
202+
203+
return result;
189204
}
190205

191206
public AutoGiveConfig getAutoGive() {

0 commit comments

Comments
 (0)