Add a cloudburst test plugin

This commit is contained in:
Alexander Söderberg 2020-09-23 13:01:50 +02:00
parent a9b65c601d
commit b0cd22886d
10 changed files with 211 additions and 12 deletions

View file

@ -8,6 +8,7 @@ This directory hosts Minecraft specific implementations of cloud. Their features
| `cloud-paper` | Bukkit, Spigot, Paper | 1.8+ | Via Paper for MC 1.15+, Via commodore for MC 1.13+ |
| `cloud-bungee` | BungeeCord | 1.8+ | No |
| `cloud-velocity` | Velocity 1.1.0 | 1.7+ | Yes |
| `cloud-cloudburst` | CloudBurst 1.0.0 | Bedrock 1.16.20+ | No |
## cloud-bukkit
Bukkit mappings for cloud. If `commodore` is present on the classpath and the server is running at least version 1.13+, Brigadier mappings will be available.

View file

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~
~ MIT License
~
~ Copyright (c) 2020 Alexander Söderberg
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in all
~ copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
~ SOFTWARE.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>cloud</artifactId>
<groupId>com.intellectualsites</groupId>
<version>1.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cloud-cloudburst-test</artifactId>
<version>0.2.0-SNAPSHOT</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>nukkit-repo</id>
<url>https://repo.nukkitx.com/maven-snapshots</url>
</repository>
<repository>
<id>jitpack</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.intellectualsites</groupId>
<artifactId>cloud-cloudburst</artifactId>
<version>0.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.intellectualsites</groupId>
<artifactId>cloud-annotations</artifactId>
<version>0.2.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.cloudburstmc</groupId>
<artifactId>cloudburst-server</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

View file

@ -0,0 +1,73 @@
//
// MIT License
//
// Copyright (c) 2020 Alexander Söderberg
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
package com.intellectualsites.commands.cloudburst;
import com.intellectualsites.commands.annotations.AnnotationParser;
import com.intellectualsites.commands.annotations.Argument;
import com.intellectualsites.commands.annotations.CommandMethod;
import com.intellectualsites.commands.annotations.specifier.Range;
import com.intellectualsites.commands.execution.CommandExecutionCoordinator;
import com.intellectualsites.commands.meta.SimpleCommandMeta;
import org.cloudburstmc.server.command.CommandSender;
import org.cloudburstmc.server.plugin.PluginBase;
import org.cloudburstmc.server.utils.TextFormat;
import javax.annotation.Nonnull;
import java.util.function.Function;
/**
* Cloudburst test plugin
*/
public final class CloudCloudburstTest extends PluginBase {
@Override
public void onLoad() {
setEnabled(true);
}
@Override
public void onEnable() {
final CloudburstCommandManager<CommandSender> cloudburstCommandManager = new CloudburstCommandManager<>(
this,
CommandExecutionCoordinator.simpleCoordinator(),
Function.identity(),
Function.identity()
);
final AnnotationParser<CommandSender> annotationParser = new AnnotationParser<>(cloudburstCommandManager,
CommandSender.class,
p -> SimpleCommandMeta.empty());
annotationParser.parse(this);
}
@CommandMethod("test <num> [str]")
private void testCommand(@Nonnull @Argument(value = "str", defaultValue = "potato") final String string,
@Nonnull final CommandSender source,
@Argument("num") @Range(min = "10", max = "33") final int num) {
source.sendMessage(TextFormat.RED + "You said: "
+ TextFormat.GOLD + string
+ TextFormat.RED + " & "
+ TextFormat.GOLD + num);
}
}

View file

@ -0,0 +1,28 @@
//
// MIT License
//
// Copyright (c) 2020 Alexander Söderberg
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
/**
* Cloudburst test plugin
*/
package com.intellectualsites.commands.cloudburst;

View file

@ -0,0 +1,5 @@
name: CloudTest
main: com.intellectualsites.commands.cloudburst.CloudCloudburstTest
version: 0.2.0-SNAPSHOT
load: POSTWORLD
api: ["2.0.0"]

View file

@ -54,7 +54,7 @@
<dependency>
<groupId>org.cloudburstmc</groupId>
<artifactId>cloudburst-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<version>1.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>

View file

@ -32,13 +32,13 @@ import com.intellectualsites.commands.exceptions.NoSuchCommandException;
import org.cloudburstmc.server.command.CommandSender;
import org.cloudburstmc.server.command.PluginCommand;
import org.cloudburstmc.server.command.data.CommandData;
import org.cloudburstmc.server.plugin.PluginContainer;
import org.cloudburstmc.server.plugin.Plugin;
import javax.annotation.Nonnull;
import java.util.List;
import java.util.concurrent.CompletionException;
final class CloudburstCommand<C> extends PluginCommand<PluginContainer> {
final class CloudburstCommand<C> extends PluginCommand<Plugin> {
private static final String MESSAGE_NO_PERMS =
"I'm sorry, but you do not have permission to perform this command. "
@ -54,7 +54,7 @@ final class CloudburstCommand<C> extends PluginCommand<PluginContainer> {
@Nonnull final com.intellectualsites.commands.Command<C> cloudCommand,
@Nonnull final CommandArgument<C, ?> command,
@Nonnull final CloudburstCommandManager<C> manager) {
super(manager.getOwningPlugin(), null, CommandData.builder(label)
super(manager.getOwningPlugin(), CommandData.builder(label)
.addAliases(aliases.toArray(new String[0]))
.addPermission(cloudCommand.getCommandPermission())
.setDescription(cloudCommand.getCommandMeta().getOrDefault("description", ""))

View file

@ -29,7 +29,7 @@ import com.intellectualsites.commands.execution.CommandExecutionCoordinator;
import com.intellectualsites.commands.meta.CommandMeta;
import com.intellectualsites.commands.meta.SimpleCommandMeta;
import org.cloudburstmc.server.command.CommandSender;
import org.cloudburstmc.server.plugin.PluginContainer;
import org.cloudburstmc.server.plugin.Plugin;
import javax.annotation.Nonnull;
import java.util.function.Function;
@ -44,7 +44,7 @@ public class CloudburstCommandManager<C> extends CommandManager<C> {
private final Function<CommandSender, C> commandSenderMapper;
private final Function<C, CommandSender> backwardsCommandSenderMapper;
private final PluginContainer owningPlugin;
private final Plugin owningPlugin;
/**
* Construct a new Cloudburst command manager
@ -53,13 +53,12 @@ public class CloudburstCommandManager<C> extends CommandManager<C> {
* @param commandExecutionCoordinator Coordinator provider
* @param commandSenderMapper Function that maps {@link CommandSender} to the command sender type
* @param backwardsCommandSenderMapper Function that maps the command sender type to {@link CommandSender}
* @throws Exception If the construction of the manager fails
*/
public CloudburstCommandManager(@Nonnull final PluginContainer owningPlugin,
public CloudburstCommandManager(@Nonnull final Plugin owningPlugin,
@Nonnull final Function<CommandTree<C>,
CommandExecutionCoordinator<C>> commandExecutionCoordinator,
@Nonnull final Function<CommandSender, C> commandSenderMapper,
@Nonnull final Function<C, CommandSender> backwardsCommandSenderMapper) throws Exception {
@Nonnull final Function<C, CommandSender> backwardsCommandSenderMapper) {
super(commandExecutionCoordinator, new CloudburstPluginRegistrationHandler<>());
((CloudburstPluginRegistrationHandler<C>) this.getCommandRegistrationHandler()).initialize(this);
this.commandSenderMapper = commandSenderMapper;
@ -90,7 +89,7 @@ public class CloudburstCommandManager<C> extends CommandManager<C> {
* @return Owning plugin
*/
@Nonnull
public final PluginContainer getOwningPlugin() {
public final Plugin getOwningPlugin() {
return this.owningPlugin;
}

View file

@ -28,7 +28,7 @@ import com.intellectualsites.commands.arguments.CommandArgument;
import com.intellectualsites.commands.arguments.StaticArgument;
import com.intellectualsites.commands.internal.CommandRegistrationHandler;
import org.cloudburstmc.server.Server;
import org.cloudburstmc.server.plugin.PluginContainer;
import org.cloudburstmc.server.plugin.Plugin;
import javax.annotation.Nonnull;
import java.util.HashMap;
@ -54,7 +54,7 @@ class CloudburstPluginRegistrationHandler<C> implements CommandRegistrationHandl
if (this.registeredCommands.containsKey(commandArgument)) {
return false;
}
final PluginContainer plugin = this.cloudburstCommandManager.getOwningPlugin();
final Plugin plugin = this.cloudburstCommandManager.getOwningPlugin();
final CloudburstCommand<C> cloudburstCommand = new CloudburstCommand<>(
commandArgument.getName(),
((StaticArgument<C>) commandArgument).getAlternativeAliases(),