Skip to content
This repository was archived by the owner on Jul 24, 2021. It is now read-only.

Commit 812324a

Browse files
committed
🐛 Fix concatenate arguments
1 parent 5a01bd1 commit 812324a

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

build.gradle

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ plugins {
33
}
44

55
group 'fr.bakaaless'
6-
version '1.0.1-SNAPSHOT'
6+
version '1.0.2-SNAPSHOT'
77

88
def spigotVersion = '1.16'
99
def subVersion = '.5'
@@ -21,10 +21,6 @@ dependencies {
2121
implementation group: 'org.spigotmc', name: 'spigot-api', version: spigotVersion + subVersion + '-R0.1-SNAPSHOT'
2222
}
2323

24-
test {
25-
useJUnitPlatform()
26-
}
27-
2824
jar {
2925
archiveName rootProject.name + '.jar'
3026
}

src/main/java/fr/bakaaless/api/command/CommandManager.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,18 @@ public CommandManager(final Class<? extends JavaPlugin> clazz) {
192192
@Override
193193
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
194194

195-
final StringBuilder builder = new StringBuilder();
196195
final StringBuilder rawArgs = new StringBuilder();
196+
final StringBuilder builder = new StringBuilder();
197197
Pair<Boolean, String> concatenateArgs = Pair.from(false, "");
198198
for (final String arg : args) {
199199
rawArgs.append(" ").append(arg);
200200
if (concatenateArgs.getFirst()) {
201201
if (arg.endsWith("\"") && !arg.endsWith("\\\"") && concatenateArgs.getSecond().equalsIgnoreCase("\"")) {
202202
concatenateArgs = Pair.from(false, "");
203-
builder.append(" ").append(arg, 0, arg.length() - 1).append(",");
203+
builder.append(" ").append(arg, 0, arg.length() - 1).append("\n");
204204
} else if (arg.endsWith("'") && !arg.endsWith("\\'") && concatenateArgs.getSecond().equalsIgnoreCase("'")) {
205205
concatenateArgs = Pair.from(false, "");
206-
builder.append(" ").append(arg, 0, arg.length() - 1).append(",");
206+
builder.append(" ").append(arg, 0, arg.length() - 1).append("\n");
207207
} else
208208
builder.append(" ").append(arg);
209209
} else {
@@ -214,15 +214,15 @@ public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Comman
214214
concatenateArgs = Pair.from(true, "'");
215215
builder.append(arg.substring(1));
216216
} else
217-
builder.append(arg).append(",");
217+
builder.append(arg).append("\n");
218218

219219
}
220220
}
221221

222222
String argument = "";
223223
if (rawArgs.length() > 0) {
224224
rawArgs.deleteCharAt(0);
225-
argument = (builder.charAt(builder.length() - 1) == ',' ? builder.deleteCharAt(builder.length() - 1).toString() : builder.toString());
225+
argument = (builder.charAt(builder.length() - 1) == '\n' ? builder.deleteCharAt(builder.length() - 1).toString() : builder.toString()).replace("\\\"", "\"");
226226
}
227227

228228
String containsCommand = "";
@@ -267,12 +267,12 @@ else if (toExec.getSecond().length() < aliases.length())
267267
}
268268

269269
if (toExec != null) {
270-
final String finalArg = argument.replace(toExec.getSecond().replace(" ", ","), "")
271-
.replaceFirst("[,]", "");
270+
final String finalArg = argument.replace(toExec.getSecond().replace(" ", "\n"), "");
271+
272272

273273
final List<String> arguments = (finalArg.equals("") ?
274274
new ArrayList<>() :
275-
new ArrayList<>(Arrays.asList(finalArg.split(",")))
275+
new ArrayList<>(Arrays.asList(finalArg.split("\n")))
276276
);
277277

278278
return Optional.ofNullable(toExec.getFirst().tabCompleter(sender, arguments)).orElse(new ArrayList<>());

0 commit comments

Comments
 (0)