Skip to content
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

Paper CommandAPI #517

Open
wants to merge 6 commits into
base: dev/dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,9 @@ indent_style = space

[commandapi-documentation-velocity-code/**{.java,.kt}]
indent_style = space

[commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/**{.java,.kt}]
indent_style = space

[commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/**{.java,.kt}]
indent_style = space
23 changes: 18 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ jobs:

### Compilation ###

- name: Setup Paper NMS for all applicable versions
run: ./setupPaperNMS.sh

- name: Build the CommandAPI (Bukkit+Velocity) using maven
run: mvn clean install --batch-mode -P Platform.Bukkit,Platform.Velocity

Expand Down Expand Up @@ -146,15 +149,25 @@ jobs:

### Upload .jar artifacts ###

- name: Upload CommandAPI (Bukkit) plugin artifact
- name: Upload CommandAPI (Spigot) plugin artifact
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v3
with:
name: CommandAPI (Bukkit plugin)
name: CommandAPI (Spigot plugin)
path: |
commandapi-platforms/commandapi-bukkit/commandapi-bukkit-plugin/target/CommandAPI*.jar
!commandapi-platforms/commandapi-bukkit/commandapi-bukkit-plugin/target/*sources.jar
!commandapi-platforms/commandapi-bukkit/commandapi-bukkit-plugin/target/*javadoc.jar
commandapi-platforms/commandapi-spigot/commandapi-spigot-plugin/target/CommandAPI*.jar
!commandapi-platforms/commandapi-spigot/commandapi-spigot-plugin/target/*sources.jar
!commandapi-platforms/commandapi-spigot/commandapi-spigot-plugin/target/*javadoc.jar

- name: Upload CommandAPI (Paper) plugin artifact
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
uses: actions/upload-artifact@v3
with:
name: CommandAPI (Paper plugin)
path: |
commandapi-platforms/commandapi-paper/commandapi-paper-plugin/target/CommandAPI*.jar
!commandapi-platforms/commandapi-paper/commandapi-paper-plugin/target/*sources.jar
!commandapi-platforms/commandapi-paper/commandapi-paper-plugin/target/*javadoc.jar

- name: Upload CommandAPI (Velocity) plugin artifact
if: ${{ runner.os == 'Linux' && matrix.java == '21' }} # Only upload artifacts built from latest java on one OS
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ docssrc/src/.markdownlint-cli2.yaml
.gradle
*.versionsBackup
dependency-reduced-pom.xml
.paper-nms
25 changes: 25 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,31 @@ This is the current roadmap for the CommandAPI (as of 30th April 2024):
</tr>
</thead>
<tbody>
<tr>
<td valign="top"><b>10.0.0</b></td>
<td valign="top">???</td>
<td valign="top">
<ul>
<li>https://github.com/JorelAli/CommandAPI/pull/517 Splits up the CommandAPI into modules specific for Paper and Spigot:
<ul>
<li>Removes the <code>commandapi-bukkit-shade</code> module and the <code>commandapi-bukkit-shade-mojang-mapped</code> module</li>
<li>Adds the <code>commandapi-paper-core</code>, <code>commandapi-paper-shade</code> and the <code>commandapi-paper-shade-mojang-mapped</code> modules which are made to work on Paper</li>
<li>Adds the <code>commandapi-spigot-core</code>, <code>commandapi-spigot-shade</code> and the <code>commandapi-spigot-shade-mojang-mapped</code> modules which do not include the logic required for Paper</li>
<li>Changed the <code>CommandAPIBukkitConfig</code> class into an abstract one in favour of the newly added <code>CommandAPIPaperConfig</code> or <code>CommandAPISpigotConfig</code> classes, depending on the modules you use</li>
<li>Moves and adds a few Kotlin DSL modules:
<ul>
<li><code>commandapi-core-kotlin -> commandapi-kotlin-core</code></li>
<li><code>commandapi-bukkit-kotlin -> commandapi-kotlin-bukkit</code></li>
<li><code>commandapi-velocity-kotlin -> commandapi-kotlin-velocity</code></li>
<li>Newly added: <code>commandapi-kotlin-paper</code></li>
<li>Newly added: <code>commandapi-kotlin-spigot</code></li>
</ul>
</li>
</ul>
</li>
</ul>
</td>
</tr>
<tr>
<td valign="top"><b>9.6.0</b></td>
<td valign="top">???</td>
Expand Down
13 changes: 1 addition & 12 deletions commandapi-annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit-core</artifactId>
<version>${project.version}</version>
<scope>provided</scope> <!-- Platform specific annotation modules implement their platform themselves -->
</dependency>
<dependency>
<groupId>com.google.auto.service</groupId>
Expand All @@ -54,18 +55,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<annotationProcessors>
<annotationProcessor>dev.jorel.commandapi.annotations.Annotations</annotationProcessor>
</annotationProcessors>
</configuration>
</execution>
</executions>
Comment on lines -57 to -68
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this build plugin no longer has any executions, does it need to be declared anymore? Could this removal be expanded to also remove the whole build section?

</plugin>
</plugins>
</build>
Expand Down
4 changes: 2 additions & 2 deletions commandapi-codecov/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
<version>${project.version}</version>
</dependency>

<!-- Code coverage the tests -->
<!-- Code coverage the tests
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit-test-tests</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependency> -->

<!-- From commandapi-bukkit-nms-dependency-mojang-mapped -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -927,21 +927,6 @@ public Optional<PreviewableFunction<?>> lookupPreviewable(List<String> path) {
}
}

/**
*
* @param path a list of Strings representing the path (names of command nodes)
* to (and including) the previewable argument
* @return Whether a previewable is legacy (non-Adventure) or not
*/
public boolean lookupPreviewableLegacyStatus(List<String> path) {
final Previewable<?, ?> previewable = previewableArguments.get(path);
if (previewable != null && previewable.getPreview().isPresent()) {
return previewable.isLegacy();
} else {
return true;
}
}

/////////////////////////
// SECTION: Reflection //
/////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ public interface CommandAPIPlatform<Argument
*
* @param config the configuration to use for the CommandAPI.
*/
public abstract void onLoad(CommandAPIConfig<?> config);
void onLoad(CommandAPIConfig<?> config);

/**
* Platform-specific stuff that should happen when the CommandAPI is enabled,
* such as registering event listeners.
*/
public abstract void onEnable();
void onEnable();

/**
* Platform-specific stuff that should happen when the CommandAPI is disabled.
*/
public abstract void onDisable();
void onDisable();

// Converting between CommandSender, AbstractCommandSender, and Brigadier Sources

Expand All @@ -54,46 +54,46 @@ public interface CommandAPIPlatform<Argument
* @param forceNative True if the CommandSender should be forced into a native CommandSender
* @return An AbstractCommandSender wrapping the CommandSender represented by the CommandContext
*/
public abstract AbstractCommandSender<? extends CommandSender> getSenderForCommand(CommandContext<Source> cmdCtx, boolean forceNative);
AbstractCommandSender<? extends CommandSender> getSenderForCommand(CommandContext<Source> cmdCtx, boolean forceNative);

/**
* Converts the class used by Brigadier when running commands into an AbstractCommandSender wrapping the platform's CommandSender
*
* @param source The Brigadier source object
* @return An AbstractCommandSender wrapping the CommandSender represented by the source object
*/
public abstract AbstractCommandSender<? extends CommandSender> getCommandSenderFromCommandSource(Source source);
AbstractCommandSender<? extends CommandSender> getCommandSenderFromCommandSource(Source source);

/**
* Converts a CommandSender wrapped in an AbstractCommandSender to an object Brigadier can use when running its commands
*
* @param sender The CommandSender to convert, wrapped in an AbstractCommandSender
* @return The Brigadier Source object represented by the sender
*/
public abstract Source getBrigadierSourceFromCommandSender(AbstractCommandSender<? extends CommandSender> sender);
Source getBrigadierSourceFromCommandSender(AbstractCommandSender<? extends CommandSender> sender);

/**
* Wraps a CommandSender in an AbstractCommandSender class, the inverse operation to {@link AbstractCommandSender#getSource()}
*
* @param sender The CommandSender to wrap
* @return An AbstractCommandSender with a class appropriate to the underlying class of the CommandSender
*/
public abstract AbstractCommandSender<? extends CommandSender> wrapCommandSender(CommandSender sender);
AbstractCommandSender<? extends CommandSender> wrapCommandSender(CommandSender sender);

// Registers a permission. Bukkit's permission system requires permissions to be "registered"
// before they can be used.
public abstract void registerPermission(String string);
void registerPermission(String string);

// Some commands have existing suggestion providers
public abstract SuggestionProvider<Source> getSuggestionProvider(SuggestionProviders suggestionProvider);
SuggestionProvider<Source> getSuggestionProvider(SuggestionProviders suggestionProvider);

/**
* Stuff to run before a command is generated. For Bukkit, this involves checking
* if a command was declared in the plugin.yml when it isn't supposed to be.
*
* @param commandName The name of the command about to be registered
*/
public abstract void preCommandRegistration(String commandName);
void preCommandRegistration(String commandName);

/**
* Stuff to run after a command has been generated.
Expand All @@ -102,12 +102,12 @@ public interface CommandAPIPlatform<Argument
* @param resultantNode The node that was registered
* @param aliasNodes Any alias nodes that were also registered as a part of this registration process
*/
public abstract void postCommandRegistration(RegisteredCommand registeredCommand, LiteralCommandNode<Source> resultantNode, List<LiteralCommandNode<Source>> aliasNodes);
void postCommandRegistration(RegisteredCommand registeredCommand, LiteralCommandNode<Source> resultantNode, List<LiteralCommandNode<Source>> aliasNodes);

/**
* Registers a Brigadier command node and returns the built node.
*/
public abstract LiteralCommandNode<Source> registerCommandNode(LiteralArgumentBuilder<Source> node, String namespace);
LiteralCommandNode<Source> registerCommandNode(LiteralArgumentBuilder<Source> node, String namespace);


/**
Expand All @@ -118,12 +118,12 @@ public interface CommandAPIPlatform<Argument
* command that start with a namespace. Eg. `minecraft:command`, `bukkit:command`,
* or `plugin:command`
*/
public abstract void unregister(String commandName, boolean unregisterNamespaces);
void unregister(String commandName, boolean unregisterNamespaces);

/**
* @return The Brigadier CommandDispatcher tree being used by the platform's server
*/
public abstract CommandDispatcher<Source> getBrigadierDispatcher();
CommandDispatcher<Source> getBrigadierDispatcher();

/**
* Creates a JSON file that describes the hierarchical structure of the commands
Expand All @@ -133,12 +133,12 @@ public interface CommandAPIPlatform<Argument
* @param dispatcher The Brigadier CommandDispatcher
* @throws IOException When the file fails to be written to
*/
public abstract void createDispatcherFile(File file, CommandDispatcher<Source> dispatcher) throws IOException;
void createDispatcherFile(File file, CommandDispatcher<Source> dispatcher) throws IOException;

/**
* @return A new default Logger meant for the CommandAPI to use
*/
public default CommandAPILogger getLogger() {
default CommandAPILogger getLogger() {
return new CommandAPILogger() {
private static final String PREFIX = "[CommandAPI] ";
private static final String YELLOW = "\u001B[33m";
Expand Down Expand Up @@ -171,19 +171,19 @@ public void severe(String message, Throwable throwable) {
/**
* Reloads the server's data packs to include CommandAPI commands
*/
public abstract void reloadDataPacks();
void reloadDataPacks();

/**
* Updates the requirements required for a given player to execute a command.
*
* @param player the player to update
*/
public abstract void updateRequirements(AbstractPlayer<?> player);
void updateRequirements(AbstractPlayer<?> player);

// Create the concrete instances of objects implemented by the platform
public abstract AbstractCommandAPICommand<?, Argument, CommandSender> newConcreteCommandAPICommand(CommandMetaData<CommandSender> meta);
AbstractCommandAPICommand<?, Argument, CommandSender> newConcreteCommandAPICommand(CommandMetaData<CommandSender> meta);

public abstract Argument newConcreteMultiLiteralArgument(String nodeName, String[] literals);
Argument newConcreteMultiLiteralArgument(String nodeName, String[] literals);

public abstract Argument newConcreteLiteralArgument(String nodeName, String literal);
Argument newConcreteLiteralArgument(String nodeName, String literal);
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,4 @@ public interface Previewable<T
*/
public T usePreview(boolean usePreview);

/**
* @return whether this argument uses legacy chat component APIs
*/
public boolean isLegacy();

}
9 changes: 7 additions & 2 deletions commandapi-documentation-code/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,17 @@
<!-- CommandAPI -->
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit-core</artifactId>
<artifactId>commandapi-paper-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-bukkit-kotlin</artifactId>
<artifactId>commandapi-spigot-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>dev.jorel</groupId>
<artifactId>commandapi-kotlin-bukkit</artifactId>
<version>${project.version}</version>
</dependency>

Expand Down
Loading
Loading