10000 adding #360 by DerEchtePilz · Pull Request #369 · CommandAPI/CommandAPI · GitHub
[go: up one dir, main page]

Skip to content

adding #360 #369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 29 commits into from
Dec 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
9e519fd
adding #360
DerEchtePilz Nov 24, 2022
832128e
provide ExecutionInfo with a record
DerEchtePilz Nov 25, 2022
ad5ef54
fixing JavaDocs
DerEchtePilz Nov 25, 2022
31d9b61
fixing some things
DerEchtePilz Nov 25, 2022
e7626e8
adding a CommandArguments class to hold provided arguments
DerEchtePilz Dec 9, 2022
f23361a
remove method parameters, fix documentation code to match new syntax
DerEchtePilz Dec 9, 2022
bfe45a3
Merge branch 'JorelAli:dev/dev' into dev/dev
DerEchtePilz Dec 9, 2022
45753b1
fix Kotlin DSL to match new syntax
DerEchtePilz Dec 9, 2022
0601bfc
fixing Converter
DerEchtePilz Dec 9, 2022
f512772
fix some more documentation issues
DerEchtePilz Dec 9, 2022
d21d50b
fixing some annotation examples to match new syntax
DerEchtePilz Dec 9, 2022
15f29ff
fix annotation generation to match new syntax 8000
DerEchtePilz Dec 9, 2022
47b86f8
handle String[] for converted commands correctly
DerEchtePilz Dec 9, 2022
92f4e37
parse arguments only once
DerEchtePilz Dec 13, 2022
88b232f
Make argsToObjectArr return a CommandArguments object. Change name of…
DerEchtePilz Dec 13, 2022
328295e
fixing generateCommand method
DerEchtePilz Dec 13, 2022
18eb95d
fix Brigadier#parseArguments method
DerEchtePilz Dec 13, 2022
d4d07c9
add Javadocs to ExecutionInfo
DerEchtePilz Dec 13, 2022
374ebcc
Remove test command thingy from CommandAPIMain. Add Javadocs to Comma…
DerEchtePilz Dec 13, 2022
e6d8cab
updating branch to support new project structure
DerEchtePilz Dec 14, 2022
43d3382
clean up after merge
DerEchtePilz Dec 14, 2022
9fbf5a7
fixing a method call in Brigadier#parseArguments
DerEchtePilz Dec 14, 2022
5c01e6a
fixing CommandTree DSL
DerEchtePilz Dec 14, 2022
6d4fa44
optimizing some imports
DerEchtePilz Dec 14, 2022
9142d85
fixing some formatting issues
DerEchtePilz Dec 15, 2022
7057cf5
Merge branch 'JorelAli:dev/dev' into dev/dev
DerEchtePilz Dec 15, 2022
a02a8b8
fixing documentation example code
DerEchtePilz Dec 15, 2022
eb5bf6e
fix commands not being executable
DerEchtePilz Dec 17, 2022
104391c
fixing build error
DerEchtePilz Dec 17, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Prev Previous commit
Next Next commit
updating branch to support new project structure
  • Loading branch information
DerEchtePilz committed Dec 14, 2022
commit e6d8cab43f61c679c4a63e6abdb06fceb178acb6
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
java-version: ${{ matrix.java }}
cache: maven
- name: build CommandAPI using maven
run: mvn clean install --batch-mode
run: mvn clean install --batch-mode -PPlatform.Bukkit
- name: CommandAPI plugin artifact
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v2
Expand Down Expand Up @@ -57,4 +57,4 @@ jobs:
!commandapi-shade/target/*sources.jar
!commandapi-shade/target/*javadoc.jar
- name: build CommandAPI examples in examples/
run: for folder in examples/*/; do ( cd $folder; mvn clean package ); done
run: cd ./examples; ./build.sh;
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.idea/**
**/.idea/
*.iml
build-works/
libs/
Expand All @@ -8,8 +8,5 @@ bin
.settings
target
logs/latest.log
commandapi-plugin/dependency-reduced-pom.xml
commandapi-shade/dependency-reduced-pom.xml
.vscode
commandapi-plugin-test/command_registration.json
commandapi-plugin-test/logs/*
.DS_Store
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = CommandAPI
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 8.6.1
PROJECT_NUMBER = 8.7.0

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
44 changes: 28 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,23 @@ The list of what version of the CommandAPI you'll need to run on a specific vers

| Minecraft version | Compatible versions | Latest compatible<br>version | Minimum Java<br>version required<br>to run latest version |
|--------------------|-----------------------------|------------------------------|-----------------------------------------------------------|
| **1.13.x** | v1.0 - 5.12, 8.3.0 - 8.6.0 | 8.6.0 | 16 |
| **1.14.1, 1.14.2** | v2.0 - 5.12, 8.3.0 - 8.6.0 | 8.6.0 | 16 |
| **1.14.3, 1.14.4** | v2.1 - 5.12, 8.3.0 - 8.6.0 | 8.6.0 | 16 |
| **1.15.x** | v2.3a - 5.12, 8.3.0 - 8.6.0 | 8.6.0 | 16 |
| **1.16.1** | v3.0 - 5.12, 8.3.0 - 8.6.0 | 8.6.0 | 16 |
| **1.16.2** | v4.0 - 5.12, 8.3.0 - 8.6.0 | 8.6.0 | 16 |
| **1.16.3** | v4.2 - 5.12, 8.3.0 - 8.6.0 | 8.6.0 | 16 |
| **1.16.4** | v5.2 - 5.12, 8.3.0 - 8.6.0 | 8.6.0 | 16 |
| **1.16.5** | v5.7 - 7.0.0, 8.3.0 - 8.6.0 | 8.6.0 | 16 |
| **1.17** | 6.0.x - 8.6.0 | 8.6.0 | 16 |
| **1.17.1** | 6.1.x - 8.6.0 | 8.6.0 | 16 |
| **1.18, 1.18.1** | 6.5.2 - 8.6.0 | 8.6.0 | 16 |
| **1.18.2** | 6.5.4 - 8.6.0 | 8.6.0 | 16 |
| **1.19** | 8.3.0 - 8.6.0 | 8.6.0 | 16 |
| **1.19.1** | 8.5.0 - 8.6.0 | 8.6.0 | 16 |
| **1.19.2** | 8.5.1 - 8.6.0 | 8.6.0 | 16 |
| **1.13.x** | v1.0 - 5.12, 8.3.0 - 8.7.0 | 8.7.0 | 16 |
| **1.14.1, 1.14.2** | v2.0 - 5.12, 8.3.0 - 8.7.0 | 8.7.0 | 16 |
| **1.14.3, 1.14.4** | v2.1 - 5.12, 8.3.0 - 8.7.0 | 8.7.0 | 16 |
| **1.15.x** | v2.3a - 5.12, 8.3.0 - 8.7.0 | 8.7.0 | 16 |
| **1.16.1** | v3.0 - 5.12, 8.3.0 - 8.7.0 | 8.7.0 | 16 |
| **1.16.2** | v4.0 - 5.12, 8.3.0 - 8.7.0 | 8.7.0 | 16 |
| **1.16.3** | v4.2 - 5.12, 8.3.0 - 8.7.0 | 8.7.0 | 16 |
| **1.16.4** | v5.2 - 5.12, 8.3.0 - 8.7.0 | 8.7.0 | 16 |
| **1.16.5** | v5.7 - 7.0.0, 8.3.0 - 8.7.0 | 8.7.0 | 16 |
| **1.17** | 6.0.x - 8.7.0 | 8.7.0 | 16 |
| **1.17.1** | 6.1.x - 8.7.0 | 8.7.0 | 16 |
| **1.18, 1.18.1** | 6.5.2 - 8.7.0 | 8.7.0 | 16 |
| **1.18.2** | 6.5.4 - 8.7.0 | 8.7.0 | 16 |
| **1.19** | 8.3.0 - 8.7.0 | 8.7.0 | 16 |
| **1.19.1** | 8.5.0 - 8.7.0 | 8.7.0 | 16 |
| **1.19.2** | 8.5.1 - 8.7.0 | 8.7.0 | 16 |
| **1.19.3** | 8.7.0 - 8.7.0 | 8.7.0 | 16 |

-----

Expand Down Expand Up @@ -368,6 +369,17 @@ This is the current roadmap for the CommandAPI (as of 2nd November 2022):
</tr>
</thead>
<tbody>
<tr>
<td valign="top"><b>8.7.0</b></td>
<td valign="top">December 2022</td>
<td valign="top">
<ul>
<li><b>Note: This version is incompatible with any plugin that used the <code>SoundArgument</code> in version 8.6.0! (See documentation for more information)</b></li>
<li>Adds support for Minecraft 1.19.3</li>
<li>Deprecates Argument "type" constructors in favour of static inner classes</li>
</ul>
</td>
</tr>
<tr>
<td valign="top"><b>8.6.0</b></td>
<td valign="top">December 2022</td>
Expand Down
4 changes: 2 additions & 2 deletions commandapi-annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<parent>
<groupId>dev.jorel</groupId>
<artifactId>commandapi</artifactId>
<version>8.6.1-SNAPSHOT</version>
<version>9.0.0-SNAPSHOT</version>
</parent>

<artifactId>commandapi-annotations</artifactId>
Expand All @@ -33,7 +33,7 @@
<dependencies>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-core</artifactId>
<artifactId>commandapi-bukkit-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
import dev.jorel.commandapi.annotations.arguments.AEnchantmentArgument;
import dev.jorel.commandapi.annotations.arguments.AEntitySelectorArgument;
import dev.jorel.commandapi.annotations.arguments.AEntityTypeArgument;
import dev.jorel.commandapi.annotations.arguments.AEnvironmentArgument;
import dev.jorel.commandapi.annotations.arguments.AFloatArgument;
import dev.jorel.commandapi.annotations.arguments.AFloatRangeArgument;
import dev.jorel.commandapi.annotations.arguments.AFunctionArgument;
Expand Down Expand Up @@ -101,10 +100,8 @@
import dev.jorel.commandapi.annotations.arguments.ATimeArgument;
import dev.jorel.commandapi.annotations.arguments.AUUIDArgument;
import dev.jorel.commandapi.annotations.arguments.Primitive;
import dev.jorel.commandapi.arguments.EntitySelector;
import dev.jorel.commandapi.arguments.LocationType;
import dev.jorel.commandapi.arguments.MultiLiteralArgument;
import dev.jorel.commandapi.arguments.ScoreHolderArgument.ScoreHolderType;

/**
* The main annotation processor for annotation-based arguments
Expand All @@ -113,19 +110,21 @@
public class Annotations extends AbstractProcessor {

private final Class<?>[] ARGUMENT_ANNOTATIONS = new Class<?>[] { AAdvancementArgument.class,
AAdventureChatArgument.class, AAdventureChatComponentArgument.class, AAngleArgument.class,
AAxisArgument.class, ABiomeArgument.class, ABlockPredicateArgument.class, ABlockStateArgument.class,
ABooleanArgument.class, AChatArgument.class, AChatColorArgument.class, AChatComponentArgument.class,
ADoubleArgument.class, AEnchantmentArgument.class, AEntitySelectorArgument.class, AEntityTypeArgument.class,
AEnvironmentArgument.class, AFloatArgument.class, AFloatRangeArgument.class, AFunctionArgument.class,
AGreedyStringArgument.class, AIntegerArgument.class, AIntegerRangeArgument.class, AItemStackArgument.class,
AItemStackPredicateArgument.class, ALiteralArgument.class, ALocation2DArgument.class,
ALocationArgument.class, ALongArgument.class, ALootTableArgument.class, AMathOperationArgument.class,
AMultiLiteralArgument.class, ANamespacedKeyArgument.class, ANBTCompoundArgument.class, AObjectiveArgument.class,
AObjectiveCriteriaArgument.class, AOfflinePlayerArgument.class, AParticleArgument.class, APlayerArgument.class,
APotionEffectArgument.class, ARecipeArgument.class, ARotationArgument.class, AScoreboardSlotArgument.class,
AScoreHolderArgument.class, ASoundArgument.class, AStringArgument.class, ATeamArgument.class,
ATextArgument.class, ATimeArgument.class, AUUIDArgument.class };
AAdventureChatArgument.class, AAdventureChatComponentArgument.class, AAngleArgument.class,
AAxisArgument.class, ABiomeArgument.class, ABlockPredicateArgument.class, ABlockStateArgument.class,
ABooleanArgument.class, AChatArgument.class, AChatColorArgument.class, AChatComponentArgument.class,
ADoubleArgument.class, AEnchantmentArgument.class, AEntitySelectorArgument.ManyEntities.class,
AEntitySelectorArgument.ManyPlayers.class, AEntitySelectorArgument.OneEntity.class,
AEntitySelectorArgument.OnePlayer.class, AEntityTypeArgument.class,
AFloatArgument.class, AFloatRangeArgument.class, AFunctionArgument.class,
AGreedyStringArgument.class, AIntegerArgument.class, AIntegerRangeArgument.class, AItemStackArgument.class,
AItemStackPredicateArgument.class, ALiteralArgument.class, ALocation2DArgument.class,
ALocationArgument.class, ALongArgument.class, ALootTableArgument.class, AMathOperationArgument.class,
AMultiLiteralArgument.class, ANamespacedKeyArgument.class, ANBTCompoundArgument.class, AObjectiveArgument.class,
AObjectiveCriteriaArgument.class, AOfflinePlayerArgument.class, AParticleArgument.class, APlayerArgument.class,
APotionEffectArgument.class, ARecipeArgument.class, ARotationArgument.class, AScoreboardSlotArgument.class,
AScoreHolderArgument.Single.class, AScoreHolderArgument.Multiple.class, ASoundArgument.class, AStringArgument.class, ATeamArgument.class,
ATextArgument.class, ATimeArgument.class, AUUIDArgument.class };

// List of stu F438 ff we can deal with
@Override
Expand Down Expand Up @@ -187,15 +186,20 @@ private SortedSet<String> calculateImports(Element classElement) {
if(methodElement instanceof ExecutableElement) {
ExecutableElement method = (ExecutableElement) methodElement;
for(VariableElement parameter : method.getParameters()) {
if(getArgument(parameter) != null) {
imports.addAll(Arrays.asList(getPrimitive(getArgument(parameter)).value()));
imports.add("dev.jorel.commandapi.arguments." + getArgument(parameter).annotationType().getSimpleName().substring(1));
if(getArgument(parameter) instanceof ALocationArgument || getArgument(parameter) instanceof ALocation2DArgument) {
Annotation argument = getArgument(parameter);
if(argument != null) {
imports.addAll(Arrays.asList(getPrimitive(argument).value()));

if(argument.annotationType().getEnclosingClass() == null) {
// Normal arguments
imports.add("dev.jorel.commandapi.arguments." + argument.annotationType().getSimpleName().substring(1));
} else {
// Nested arguments, like EntitySelectorArgument
imports.add("dev.jorel.commandapi.arguments." + argument.annotationType().getEnclosingClass().getSimpleName().substring(1));
}

if(argument instanceof ALocationArgument || argument instanceof ALocation2DArgument) {
imports.add(LocationType.class.getCanonicalName());
} else if(getArgument(parameter) instanceof AScoreHolderArgument) {
imports.add(ScoreHolderType.class.getCanonicalName());
} else if(getArgument(parameter) instanceof AEntitySelectorArgument) {
imports.add(EntitySelector.class.getCanonicalName());
}
}

Expand Down Expand Up @@ -303,22 +307,6 @@ private <T extends Annotation> Map<Integer, String> emitArgumentsAndGenerateArgu
Primitive primitive = getPrimitive(argumentAnnotation);
if(primitive.value().length == 1) {
argumentMapping.put(i - 1, primitive.value()[0]);
} else {
if(argumentAnnotation instanceof AEntitySelectorArgument argument) {
switch(argument.value()) {
case MANY_ENTITIES -> argumentMapping.put(i - 1, primitive.value()[0]);
case MANY_PLAYERS -> argumentMapping.put(i - 1, primitive.value()[1]);
case ONE_ENTITY -> argumentMapping.put(i - 1, primitive.value()[2]);
case ONE_PLAYER -> argumentMapping.put(i - 1, primitive.value()[3]);
default -> throw new IllegalArgumentException("Unexpected value: " + argument.value());
}
} else if (argumentAnnotation instanceof AScoreHolderArgument argument) {
switch(argument.value()) {
case MULTIPLE -> argumentMapping.put(i - 1, primitive.value()[0]);
case SINGLE -> argumentMapping.put(i - 1, primitive.value()[1]);
default -> throw new IllegalArgumentException("Unexpected value: " + argument.value());
}
}
}
}

Expand Down Expand Up @@ -492,7 +480,15 @@ private <T extends Annotation> void processCommand(RoundEnvironment roundEnv, El
private <T extends Annotation> void emitArgument(PrintWriter out, T argumentAnnotation, VariableElement parameter, int indent) {
out.print(indent(indent) + ".withArguments(new ");
// We're assuming that the name of the argument MUST be "A" + the same name
out.print(argumentAnnotation.annotationType().getSimpleName().substring(1));
if(argumentAnnotation.annotationType().getEnclosingClass() == null) {
// Normal arguments
out.print(argumentAnnotation.annotationType().getSimpleName().substring(1));
} else {
// Nested arguments, like EntitySelectorArgument
out.print(argumentAnnotation.annotationType().getEnclosingClass().getSimpleName().substring(1));
out.print(".");
out.print(argumentAnnotation.annotationType().getSimpleName());
}

// Node name
if(argumentAnnotation instanceof AMultiLiteralArgument || argumentAnnotation instanceof ALiteralArgument) {
Expand Down Expand Up @@ -521,10 +517,6 @@ else if(argumentAnnotation instanceof ALocation2DArgument argument) {
out.print(", " + LocationType.class.getSimpleName() + "." + argument.value().toString());
} else if(argumentAnnotation instanceof ALocationArgument argument) {
out.print(", " + LocationType.class.getSimpleName() + "." + argument.value().toString());
} else if(argumentAnnotation instanceof AEntitySelectorArgument argument) {
out.print(", " + EntitySelector.class.getSimpleName() + "." + argument.value().toString());
} else if(argumentAnnotation instanceof AScoreHolderArgument argument) {
out.print(", " + ScoreHolderType.class.getSimpleName() + "." + argument.value().toString());
} else if(argumentAnnotation instanceof AMultiLiteralArgument argument) {
out.print(Arrays.stream(argument.value()).map(s -> "\"" + s + "\"&quo 10000 t;).collect(Collectors.joining(", ")));
} else if(argumentAnnotation instanceof ALiteralArgument argument) {
Expand Down Expand Up @@ -557,11 +549,22 @@ private <T extends Annotation> Primitive getPrimitive(T annotation) {
private <T extends Annotation> T getArgument(VariableElement tMirror) {
for(AnnotationMirror mirror : tMirror.getAnnotationMirrors()) {
if(isArgument(mirror)) {
T argumentAnnotation = null;
String mirrorCanonicalName = mirror.getAnnotationType().toString();
try {
return tMirror.getAnnotationsByType((Class<T>) Class.forName(mirror.getAnnotationType().toString()))[0];
argumentAnnotation = tMirror.getAnnotationsByType((Class<T>) Class.forName(mirrorCanonicalName))[0];
} catch (ClassNotFoundException e) {
e.printStackTrace();
// We might be in a nested class. Let's try accessing that
try {
// Replace final . with $
mirrorCanonicalName = mirrorCanonicalName.substring(0, mirrorCanonicalName.lastIndexOf(".")) + "$" + mirrorCanonicalName.substring(mirrorCanonicalName.lastIndexOf(".") + 1);
argumentAnnotation = tMirror.getAnnotationsByType((Class<T>) Class.forName(mirrorCanonicalName))[0];
} catch (ClassNotFoundException e1) {
e1.printStackTrace();
}
}

return argumentAnnotation;
}
}
return null;
Expand Down
< 5338 td id="diff-c6ed3e81a8d1086a3af7460fe6987227285b146521747695581b9ff5101ba744R59" data-line-number="59" class="blob-num blob-num-addition js-linkable-line-number js-blob-rnum">
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,41 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import dev.jorel.commandapi.arguments.EntitySelector;
import dev.jorel.commandapi.arguments.EntitySelectorArgument;

/**
* Annotation equivalent of the {@link EntitySelectorArgument}
*/
@Primitive({ "java.util.Collection<org.bukkit.entity.Entity>", // MANY_ENTITIES
"java.util.Collection<org.bukkit.entity.Player>", // MANY_PLAYERS
"org.bukkit.entity.Entity", // ONE_ENTITY
"org.bukkit.entity.Player" // ONE_PLAYER
})
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.PARAMETER)
public @interface AEntitySelectorArgument {
public interface AEntitySelectorArgument {

/**
* Annotation equivalent of the {@link EntitySelectorArgument} for one entity
*/
@Primitive("org.bukkit.entity.Entity")
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.PARAMETER)
public @interface OneEntity { }

/**
* Annotation equivalent of the {@link EntitySelectorArgument} for one player
*/
@Primitive("org.bukkit.entity.Player")
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.PARAMETER)
public @interface OnePlayer { }

/**
* @return the entity selector for this argument
* Annotation equivalent of the {@link EntitySelectorArgument} for many entities
*/
EntitySelector value() default EntitySelector.ONE_ENTITY;
@Primitive("java.util.Collection<org.bukkit.entity.Entity>")
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.PARAMETER)
public @interface ManyEntities { }

/**
* Annotation equivalent of the {@link EntitySelectorArgument} for many players
*/
@Primitive("java.util.Collection<org.bukkit.entity.Player>")
@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.PARAMETER)
public @interface ManyPlayers { }


}
Loading
You are viewing a condensed version of this merge commit. You can view the full changes here.
0