Enable users to override exception handling and make the velocity test plugin less stupid

This commit is contained in:
Alexander Söderberg 2020-09-19 16:38:58 +02:00
parent 5f48b0a032
commit 1fede2b4c0
No known key found for this signature in database
GPG key ID: C0207FF7EA146678
8 changed files with 285 additions and 100 deletions

View file

@ -24,7 +24,12 @@
package com.intellectualsites.cloudvelocitytest;
import com.google.inject.Inject;
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 com.intellectualsites.commands.velocity.VelocityCommandManager;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.event.Subscribe;
@ -68,6 +73,22 @@ public class CloudVelocityTest {
.handler(c -> c.getSender().sendMessage(TextComponent.of("That's right ;)").color(NamedTextColor.GOLD)))
.build()
);
final AnnotationParser<CommandSource> annotationParser = new AnnotationParser<>(m, CommandSource.class,
p -> SimpleCommandMeta.empty());
annotationParser.parse(this);
}
@CommandMethod("test <num> [str]")
private void testCommand(@Nonnull @Argument("str") final String string,
@Nonnull final CommandSource source,
@Argument("num") @Range(max = "33") final int num) {
source.sendMessage(TextComponent.builder()
.append("You wrote: ", NamedTextColor.GOLD)
.append(string, NamedTextColor.LIGHT_PURPLE)
.append(" and ", NamedTextColor.GOLD)
.append(Integer.toString(num), NamedTextColor.LIGHT_PURPLE)
.append("!", NamedTextColor.GOLD)
);
}
}