Skip to content

Commit eca31b7

Browse files
authored
Merge branch 'dev/dev' into fix/nullcommandsender-exception
2 parents 47aa428 + 96088e5 commit eca31b7

File tree

115 files changed

+1462
-443
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+1462
-443
lines changed

Doxyfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = CommandAPI
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = 9.5.1
41+
PROJECT_NUMBER = 9.6.0-SNAPSHOT
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,15 @@ This is the current roadmap for the CommandAPI (as of 30th April 2024):
408408
</tr>
409409
</thead>
410410
<tbody>
411+
<tr>
412+
<td valign="top"><b>9.6.0</b></td>
413+
<td valign="top">???</td>
414+
<td valign="top">
415+
<ul>
416+
<li>https://github.com/JorelAli/CommandAPI/issues/577 Adds a <code>CommandAPIBukkit#failWithAdventureComponent(ComponentLike)</code> method</li>
417+
</ul>
418+
</td>
419+
</tr>
411420
<tr>
412421
<td valign="top"><b>9.5.1</b></td>
413422
<td valign="top">June 2024</td>

commandapi-annotations/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<parent>
1919
<groupId>dev.jorel</groupId>
2020
<artifactId>commandapi</artifactId>
21-
<version>9.5.1</version>
21+
<version>9.6.0-SNAPSHOT</version>
2222
</parent>
2323

2424
<artifactId>commandapi-annotations</artifactId>

commandapi-codecov/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<parent>
2121
<groupId>dev.jorel</groupId>
2222
<artifactId>commandapi</artifactId>
23-
<version>9.5.1</version>
23+
<version>9.6.0-SNAPSHOT</version>
2424
</parent>
2525

2626
<artifactId>commandapi-codecov</artifactId>

commandapi-core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<parent>
2020
<artifactId>commandapi</artifactId>
2121
<groupId>dev.jorel</groupId>
22-
<version>9.5.1</version>
22+
<version>9.6.0-SNAPSHOT</version>
2323
</parent>
2424
<modelVersion>4.0.0</modelVersion>
2525

commandapi-core/src/main/java/dev/jorel/commandapi/AbstractCommandAPICommand.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Impl setConverted(boolean isConverted) {
215215
// shouldn't be accessing/depending on any of the contents of the current class instance)
216216
@SuppressWarnings({ "unchecked", "rawtypes" })
217217
private static <Impl extends AbstractCommandAPICommand<Impl, Argument, CommandSender>, Argument extends AbstractArgument<?, ?, Argument, CommandSender>, CommandSender>
218-
void flatten(Impl rootCommand, List<Argument> prevArguments, Impl subcommand) {
218+
void flatten(Impl rootCommand, List<Argument> prevArguments, Impl subcommand, String namespace) {
219219
// Get the list of literals represented by the current subcommand. This
220220
// includes the subcommand's name and any aliases for this subcommand
221221
String[] literals = new String[subcommand.meta.aliases.length + 1];
@@ -243,11 +243,11 @@ void flatten(Impl rootCommand, List<Argument> prevArguments, Impl subcommand) {
243243
rootCommand.withArguments(subcommand.arguments);
244244
rootCommand.executor = subcommand.executor;
245245
rootCommand.subcommands = new ArrayList<>();
246-
rootCommand.register();
246+
rootCommand.register(namespace);
247247
}
248248

249249
for (Impl subsubcommand : subcommand.getSubcommands()) {
250-
flatten(rootCommand, new ArrayList<>(prevArguments), subsubcommand);
250+
flatten(rootCommand, new ArrayList<>(prevArguments), subsubcommand, namespace);
251251
}
252252
}
253253

@@ -310,7 +310,7 @@ public void register(String namespace) {
310310

311311
// Convert subcommands into multiliteral arguments
312312
for (Impl subcommand : this.subcommands) {
313-
flatten(this.copy(), new ArrayList<>(), subcommand);
313+
flatten(this.copy(), new ArrayList<>(), subcommand, namespace);
314314
}
315315
}
316316

commandapi-core/src/main/java/dev/jorel/commandapi/CommandAPI.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ private CommandAPI() {
2727
private static boolean loaded;
2828
private static InternalConfig config;
2929
private static CommandAPILogger logger;
30+
private static String loadedStack;
3031

3132
// Accessing static variables
3233

@@ -96,6 +97,14 @@ public static CommandAPILogger getLogger() {
9697
*/
9798
public static void onLoad(CommandAPIConfig<?> config) {
9899
if (!loaded) {
100+
// Store the current stack trace to help diagnose multi-loading errors
101+
final StringBuilder currentStack = new StringBuilder();
102+
for (StackTraceElement e : Thread.currentThread().getStackTrace()) {
103+
currentStack.append(e.toString());
104+
currentStack.append("\n");
105+
}
106+
CommandAPI.loadedStack = currentStack.toString();
107+
99108
// Setup variables
100109
CommandAPI.config = new InternalConfig(config);
101110

@@ -124,6 +133,14 @@ public static void onLoad(CommandAPIConfig<?> config) {
124133
loaded = true;
125134
} else {
126135
getLogger().severe("You've tried to call the CommandAPI's onLoad() method more than once!");
136+
final StringBuilder currentStack = new StringBuilder();
137+
for (StackTraceElement e : Thread.currentThread().getStackTrace()) {
138+
currentStack.append(e.toString());
139+
currentStack.append("\n");
140+
}
141+
getLogger().severe("The CommandAPI was first loaded here:\n\n" + CommandAPI.loadedStack +
142+
"\n\nBut it is now being loaded here:\n\n" + currentStack.toString());
143+
127144
}
128145
}
129146

commandapi-core/src/main/java/dev/jorel/commandapi/executors/CommandArguments.java

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
package dev.jorel.commandapi.executors;
22

3-
import dev.jorel.commandapi.arguments.AbstractArgument;
4-
5-
import javax.annotation.Nullable;
6-
3+
import java.util.Arrays;
74
import java.util.Collection;
85
import java.util.Collections;
9-
import java.util.HashMap;
106
import java.util.Map;
7+
import java.util.Objects;
118
import java.util.Optional;
129
import java.util.function.Supplier;
1310

11+
import javax.annotation.Nullable;
12+
13+
import dev.jorel.commandapi.arguments.AbstractArgument;
14+
1415
/**
1516
* This class stores the arguments for this command
1617
*
@@ -600,4 +601,28 @@ private String buildExceptionMessage(Object argumentNameOrIndex, String expected
600601
"contact the developers of the CommandAPI, we'd love to know how you managed to get this error!");
601602
}
602603

604+
@Override
605+
public int hashCode() {
606+
final int prime = 31;
607+
int result = 1;
608+
result = prime * result + Arrays.deepHashCode(args);
609+
result = prime * result + Arrays.hashCode(rawArgs);
610+
result = prime * result + Objects.hash(argsMap, fullInput, rawArgsMap);
611+
return result;
612+
}
613+
614+
@Override
615+
public boolean equals(Object obj) {
616+
if (this == obj)
617+
return true;
618+
if (obj == null)
619+
return false;
620+
if (getClass() != obj.getClass())
621+
return false;
622+
CommandArguments other = (CommandArguments) obj;
623+
return Arrays.deepEquals(args, other.args) && Objects.equals(argsMap, other.argsMap)
624+
&& Objects.equals(fullInput, other.fullInput) && Arrays.equals(rawArgs, other.rawArgs)
625+
&& Objects.equals(rawArgsMap, other.rawArgsMap);
626+
}
627+
603628
}

commandapi-documentation-code/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<artifactId>commandapi</artifactId>
99
<groupId>dev.jorel</groupId>
10-
<version>9.5.1</version>
10+
<version>9.6.0-SNAPSHOT</version>
1111
</parent>
1212

1313
<artifactId>commandapi-documentation-code</artifactId>
@@ -19,7 +19,7 @@
1919
</repository>
2020
<repository>
2121
<id>papermc</id>
22-
<url>https://papermc.io/repo/repository/maven-public/</url>
22+
<url>https://repo.papermc.io/repository/maven-public/</url>
2323
</repository>
2424
<repository>
2525
<id>codemc-repo</id>

commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,23 @@ void argument_entities() {
460460
/* ANCHOR_END: argumentEntities1 */
461461

462462
/* ANCHOR: argumentEntities2 */
463+
Argument<?> noSelectorSuggestions = new PlayerArgument("target")
464+
.replaceSafeSuggestions(SafeSuggestions.suggest(info ->
465+
Bukkit.getOnlinePlayers().toArray(new Player[0])
466+
));
467+
/* ANCHOR_END: argumentEntities2 */
468+
469+
/* ANCHOR: argumentEntities3 */
470+
new CommandAPICommand("warp")
471+
.withArguments(noSelectorSuggestions)
472+
.executesPlayer((player, args) -> {
473+
Player target = (Player) args.get("target");
474+
player.teleport(target);
475+
})
476+
.register();
477+
/* ANCHOR_END: argumentEntities3 */
478+
479+
/* ANCHOR: argumentEntities4 */
463480
new CommandAPICommand("spawnmob")
464481
.withArguments(new EntityTypeArgument("entity"))
465482
.withArguments(new IntegerArgument("amount", 1, 100)) // Prevent spawning too many entities
@@ -469,7 +486,7 @@ void argument_entities() {
469486
}
470487
})
471488
.register();
472-
/* ANCHOR_END: argumentEntities2 */
489+
/* ANCHOR_END: argumentEntities4 */
473490
}
474491

475492
void argument_function() {
@@ -2685,4 +2702,4 @@ static String getBalance(Player player) {
26852702
static void resetBalance(Player target) {
26862703
throw new UnsupportedOperationException();
26872704
}
2688-
}
2705+
}

0 commit comments

Comments
 (0)