Add a cloudburst test plugin
This commit is contained in:
parent
a9b65c601d
commit
b0cd22886d
10 changed files with 211 additions and 12 deletions
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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", ""))
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue