🗑️ Remove plugin test modules

This commit is contained in:
Alexander Söderberg 2020-10-03 21:46:22 +02:00
parent 7f013124b2
commit a2670722e7
No known key found for this signature in database
GPG key ID: C0207FF7EA146678
13 changed files with 1 additions and 712 deletions

View file

@ -1,21 +0,0 @@
apply plugin: 'com.github.johnrengelman.shadow'
def adventureVersion = '4.0.0-SNAPSHOT'
shadowJar {
dependencies {
exclude(dependency('org.bukkit:bukkit:1.8.8-R0.1-SNAPSHOT'))
}
}
dependencies {
/* Cloud */
implementation project(':cloud-paper')
implementation project(':cloud-annotations')
implementation project(':cloud-minecraft-extras')
/* Extras */
implementation 'me.lucko:commodore:1.9'
implementation 'net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT'
/* Bukkit */
compileOnly 'org.bukkit:bukkit:1.8.8-R0.1-SNAPSHOT'
}

View file

@ -1,274 +0,0 @@
//
// MIT License
//
// Copyright (c) 2020 Alexander Söderberg & Contributors
//
// 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 cloud.commandframework;
import cloud.commandframework.annotations.AnnotationParser;
import cloud.commandframework.annotations.Argument;
import cloud.commandframework.annotations.CommandDescription;
import cloud.commandframework.annotations.CommandMethod;
import cloud.commandframework.annotations.Confirmation;
import cloud.commandframework.annotations.specifier.Completions;
import cloud.commandframework.annotations.specifier.Range;
import cloud.commandframework.arguments.parser.ArgumentParseResult;
import cloud.commandframework.arguments.parser.StandardParameters;
import cloud.commandframework.arguments.standard.BooleanArgument;
import cloud.commandframework.arguments.standard.DoubleArgument;
import cloud.commandframework.arguments.standard.EnumArgument;
import cloud.commandframework.arguments.standard.FloatArgument;
import cloud.commandframework.arguments.standard.IntegerArgument;
import cloud.commandframework.arguments.standard.StringArgument;
import cloud.commandframework.bukkit.BukkitCommandManager;
import cloud.commandframework.bukkit.BukkitCommandMetaBuilder;
import cloud.commandframework.bukkit.CloudBukkitCapabilities;
import cloud.commandframework.bukkit.parsers.WorldArgument;
import cloud.commandframework.exceptions.InvalidSyntaxException;
import cloud.commandframework.execution.AsynchronousCommandExecutionCoordinator;
import cloud.commandframework.execution.CommandExecutionCoordinator;
import cloud.commandframework.extra.confirmation.CommandConfirmationManager;
import cloud.commandframework.meta.SimpleCommandMeta;
import cloud.commandframework.paper.PaperCommandManager;
import cloud.commandframework.types.tuples.Triplet;
import io.leangen.geantyref.TypeToken;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
import org.checkerframework.checker.nullness.qual.NonNull;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.stream.Collectors;
public final class BukkitTest extends JavaPlugin {
private static final int PERC_MIN = 0;
private static final int PERC_MAX = 100;
private BukkitCommandManager<CommandSender> mgr;
@Override
public void onEnable() {
try {
final Function<CommandTree<CommandSender>, CommandExecutionCoordinator<CommandSender>> executionCoordinatorFunction =
AsynchronousCommandExecutionCoordinator.<CommandSender>newBuilder().build();
mgr = new PaperCommandManager<>(
this,
executionCoordinatorFunction,
Function.identity(),
Function.identity()
);
final BukkitAudiences bukkitAudiences = BukkitAudiences.create(this);
final MinecraftHelp<CommandSender> minecraftHelp = new MinecraftHelp<>("/cloud help",
sender -> bukkitAudiences.player((Player) sender),
mgr);
try {
mgr.registerBrigadier();
} catch (final Exception e) {
getLogger().warning("Failed to initialize Brigadier support: " + e.getMessage());
}
try {
((PaperCommandManager<CommandSender>) mgr).registerAsynchronousCompletions();
} catch (final Throwable e) {
getLogger().warning("Failed to register asynchronous command completions: " + e.getMessage());
}
final CommandConfirmationManager<CommandSender> confirmationManager = new CommandConfirmationManager<>(
30,
TimeUnit.SECONDS,
c -> c.getCommandContext().getSender().sendMessage(ChatColor.RED + "Oh no. Confirm using /cloud confirm!"),
c -> c.sendMessage(ChatColor.RED + "You don't have any pending commands!")
);
confirmationManager.registerConfirmationProcessor(mgr);
final AnnotationParser<CommandSender> annotationParser
= new AnnotationParser<>(mgr, CommandSender.class, p ->
BukkitCommandMetaBuilder.builder().withDescription(p.get(StandardParameters.DESCRIPTION,
"No description")).build());
annotationParser.parse(this);
mgr.command(mgr.commandBuilder("gamemode", this.metaWithDescription("Your ugli"), "gajmöde")
.argument(EnumArgument.of(GameMode.class, "gamemode"))
.argument(StringArgument.<CommandSender>newBuilder("player")
.withSuggestionsProvider((v1, v2) -> {
final List<String> suggestions =
new ArrayList<>(
Bukkit.getOnlinePlayers()
.stream()
.map(Player::getName)
.collect(Collectors.toList()));
suggestions.add("dog");
suggestions.add("cat");
return suggestions;
}))
.handler(c -> ((Player) c.getSender())
.setGameMode(c.<GameMode>getOptional("gamemode")
.orElse(GameMode.SURVIVAL))))
.command(mgr.commandBuilder("kenny", "k")
.literal("sux", "s")
.argument(IntegerArgument
.<CommandSender>newBuilder("perc")
.withMin(PERC_MIN).withMax(PERC_MAX).build())
.handler(context -> {
context.getSender().sendMessage(String.format(
"Kenny sux %d%%",
context.<Integer>getOptional("perc").orElse(PERC_MIN)
));
}))
.command(mgr.commandBuilder("uuidtest")
.handler(c -> c.getSender().sendMessage("Hey yo dum, provide a UUID idiot. Thx!")))
.command(mgr.commandBuilder("uuidtest")
.argument(UUID.class, "uuid", builder -> builder
.asRequired()
.withParser((c, i) -> {
final String string = i.peek();
try {
final UUID uuid = UUID.fromString(string);
i.remove();
return ArgumentParseResult.success(uuid);
} catch (final Exception e) {
return ArgumentParseResult.failure(e);
}
}))
.handler(c -> c.getSender()
.sendMessage(String.format("UUID: %s\n", c.<UUID>getOptional("uuid").orElse(null)))))
.command(mgr.commandBuilder("give")
.withSenderType(Player.class)
.flag(mgr.flagBuilder("color")
.withArgument(EnumArgument.of(ChatColor.class, "color"))
.build())
.argument(EnumArgument.of(Material.class, "material"))
.argument(IntegerArgument.of("amount"))
.handler(c -> {
final Material material = c.get("material");
final int amount = c.get("amount");
final ItemStack itemStack = new ItemStack(material, amount);
final ChatColor color = c.flags().getValue("color", ChatColor.GOLD);
final ItemMeta itemMeta = itemStack.getItemMeta();
itemMeta.setDisplayName(color + String.format("%s's item", c.getSender().getName()));
itemStack.setItemMeta(itemMeta);
((Player) c.getSender()).getInventory().addItem(itemStack);
c.getSender().sendMessage("You've been given stuff, bro.");
}))
.command(mgr.commandBuilder("worldtp", BukkitCommandMetaBuilder.builder()
.withDescription("Teleport to a world"))
.argument(WorldArgument.of("world"))
.handler(c -> {
final World world = c.get("world");
((Player) c.getSender()).teleport(world.getSpawnLocation());
c.getSender().sendMessage("Teleported.");
}))
.command(mgr.commandBuilder("brigadier")
.argument(FloatArgument.of("float"))
.argument(DoubleArgument.of("double"))
.argument(IntegerArgument.of("int"))
.argument(BooleanArgument.of("bool"))
.argument(StringArgument.of("string"))
.handler(c -> c.getSender().sendMessage("Executed the command")))
.command(mgr.commandBuilder("annotationass")
.handler(c -> c.getSender()
.sendMessage(ChatColor.YELLOW + "Du e en ananas!")))
.command(mgr.commandBuilder("cloud")
.literal("confirm")
.handler(confirmationManager.createConfirmationExecutionHandler()).build())
.command(mgr.commandBuilder("cloud")
.literal("help")
.withPermission("cloud.help")
.argument(StringArgument.<CommandSender>newBuilder("query").greedy()
.asOptionalWithDefault("")
.build(), Description.of("Help Query"))
.handler(c -> minecraftHelp.queryCommands(c.<String>getOptional("query").orElse(""),
c.getSender())).build());
this.registerTeleportCommand(mgr);
mgr.registerExceptionHandler(InvalidSyntaxException.class, (c, e) -> e.printStackTrace());
} catch (final Exception e) {
e.printStackTrace();
}
}
private void registerTeleportCommand(final @NonNull BukkitCommandManager<CommandSender> manager) {
manager.command(mgr.commandBuilder("teleport")
.meta("description", "Takes in a location and teleports the player there")
.withSenderType(Player.class)
.argument(WorldArgument.of("world"), Description.of("World name"))
.argumentTriplet("coords",
TypeToken.get(Vector.class),
Triplet.of("x", "y", "z"),
Triplet.of(Double.class, Double.class, Double.class),
triplet -> new Vector(triplet.getFirst(), triplet.getSecond(), triplet.getThird()),
Description.of("Coordinates"))
.handler(context -> {
context.getSender().sendMessage(ChatColor.GOLD + "Teleporting!");
Bukkit.getScheduler().runTask(this, () -> {
final World world = context.get("world");
final Vector vector = context.get("coords");
((Player) context.getSender()).teleport(vector.toLocation(world));
});
}));
}
@CommandDescription("Test cloud command using @CommandMethod")
@CommandMethod(value = "annotation|a <input> [number]", permission = "some.permission.node")
private void annotatedCommand(final @NonNull Player player,
@Argument(value = "input", description = "Some string") @Completions("one,two,duck")
final @NonNull String input,
@Argument(value = "number", defaultValue = "5", description = "A number")
@Range(min = "10", max = "100") final int number) {
player.sendMessage(ChatColor.GOLD + "Your input was: " + ChatColor.AQUA + input + ChatColor.GREEN + " (" + number + ")");
}
@Confirmation
@CommandMethod(value = "cloud", permission = "cloud.debug")
private void doHelp() {
final Set<CloudBukkitCapabilities> capabilities = this.mgr.queryCapabilities();
Bukkit.broadcastMessage(ChatColor.GOLD + "" + ChatColor.BOLD + "Capabilities");
for (final CloudBukkitCapabilities capability : capabilities) {
Bukkit.broadcastMessage(ChatColor.DARK_GRAY + "- " + ChatColor.AQUA + capability);
}
Bukkit.broadcastMessage(ChatColor.GRAY + "Using Registration Manager: "
+ this.mgr.getCommandRegistrationHandler().getClass().getSimpleName());
Bukkit.broadcastMessage(ChatColor.GRAY + "Calling Thread: " + Thread.currentThread().getName());
}
private @NonNull SimpleCommandMeta metaWithDescription(final @NonNull String description) {
return BukkitCommandMetaBuilder.builder().withDescription(description).build();
}
}

View file

@ -1,28 +0,0 @@
//
// MIT License
//
// Copyright (c) 2020 Alexander Söderberg & Contributors
//
// 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.
//
/**
* Stuff
*/
package cloud.commandframework;

View file

@ -1,5 +0,0 @@
name: Command-Test
author: Citymonstret
main: cloud.commandframework.BukkitTest
version: 1.0
api-version: 1.13

View file

@ -174,5 +174,5 @@ public final class SinglePlayerSelectorArgument<C> extends CommandArgument<C, Si
return output;
}
}
}

View file

@ -1,18 +0,0 @@
apply plugin: 'com.github.johnrengelman.shadow'
def adventureVersion = '4.0.0-SNAPSHOT'
shadowJar {
dependencies {
include(project(':cloud-cloudburst'))
include(project(':cloud-annotations'))
include(project(':cloud-core'))
include(project(':cloud-services'))
}
}
dependencies {
compile project(':cloud-cloudburst')
compile project(':cloud-annotations')
compileOnly 'org.cloudburstmc:cloudburst-server:1.0.0-SNAPSHOT'
}

View file

@ -1,73 +0,0 @@
//
// MIT License
//
// Copyright (c) 2020 Alexander Söderberg & Contributors
//
// 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 cloud.commandframework.cloudburst;
import cloud.commandframework.annotations.AnnotationParser;
import cloud.commandframework.annotations.Argument;
import cloud.commandframework.annotations.CommandMethod;
import cloud.commandframework.annotations.specifier.Range;
import cloud.commandframework.execution.CommandExecutionCoordinator;
import cloud.commandframework.meta.SimpleCommandMeta;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.cloudburstmc.server.command.CommandSender;
import org.cloudburstmc.server.plugin.PluginBase;
import org.cloudburstmc.server.utils.TextFormat;
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,
final @NonNull 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

@ -1,28 +0,0 @@
//
// MIT License
//
// Copyright (c) 2020 Alexander Söderberg & Contributors
//
// 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 cloud.commandframework.cloudburst;

View file

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

View file

@ -1,113 +0,0 @@
# User-specific stuff
.idea/
*.iml
*.ipr
*.iws
# IntelliJ
out/
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
# General
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Windows thumbnail cache files
Thumbs.db
Thumbs.db:encryptable
ehthumbs.db
ehthumbs_vista.db
# Dump file
*.stackdump
# Folder config file
[Dd]esktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msix
*.msm
*.msp
# Windows shortcuts
*.lnk
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
.flattened-pom.xml
# Common working directory
run/

View file

@ -1,19 +0,0 @@
apply plugin: 'com.github.johnrengelman.shadow'
def adventureVersion = '4.0.0-SNAPSHOT'
shadowJar {
dependencies {
include(project(':cloud-velocity'))
include(project(':cloud-annotations'))
include(project(':cloud-core'))
include(project(':cloud-services'))
include(project(':cloud-brigadier'))
}
}
dependencies {
implementation project(':cloud-velocity')
implementation project(':cloud-annotations')
compileOnly 'com.velocitypowered:velocity-api:1.1.0-SNAPSHOT'
}

View file

@ -1,99 +0,0 @@
//
// MIT License
//
// Copyright (c) 2020 Alexander Söderberg & Contributors
//
// 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 cloud.commandframework.cloudvelocitytest;
import com.google.inject.Inject;
import cloud.commandframework.annotations.AnnotationParser;
import cloud.commandframework.annotations.Argument;
import cloud.commandframework.annotations.CommandMethod;
import cloud.commandframework.annotations.specifier.Range;
import cloud.commandframework.execution.CommandExecutionCoordinator;
import cloud.commandframework.meta.SimpleCommandMeta;
import cloud.commandframework.velocity.VelocityCommandManager;
import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.event.Subscribe;
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
import com.velocitypowered.api.plugin.Plugin;
import com.velocitypowered.api.proxy.ProxyServer;
import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.NamedTextColor;
import org.slf4j.Logger;
import javax.annotation.Nonnull;
import java.util.function.Function;
@Plugin(
id = "cloud-velocity-test",
name = "Cloud Velocity Test",
version = "0.0.2.0-SNAPSHOT"
)
public class CloudVelocityTest {
@Inject private ProxyServer server;
@Inject private Logger logger;
/**
* Event listener
*
* @param event Event
*/
@Subscribe
public final void onProxyInitialization(@Nonnull final ProxyInitializeEvent event) {
final VelocityCommandManager<CommandSource> m = new VelocityCommandManager<>(
server,
CommandExecutionCoordinator.simpleCoordinator(),
Function.identity(),
Function.identity()
);
m.command(
m.commandBuilder("proxi", "pp")
.literal("is")
.literal("cute")
.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(value = "test", permission = "cloud.root")
private void testRoot(@Nonnull final CommandSource source) {
source.sendMessage(TextComponent.builder("Hello from the root!", NamedTextColor.GOLD));
}
@CommandMethod("test <num> [str]")
private void testCommand(@Nonnull @Argument(value = "str", defaultValue = "potato") final String string,
@Nonnull final CommandSource source,
@Argument("num") @Range(min = "10", max = "33") final int num) {
source.sendMessage(TextComponent.builder()
.append("You wrote: ", NamedTextColor.GOLD)
.append(string, NamedTextColor.RED)
.append(" and ", NamedTextColor.GOLD)
.append(Integer.toString(num), NamedTextColor.RED)
.append("!", NamedTextColor.GOLD)
);
}
}

View file

@ -1,28 +0,0 @@
//
// MIT License
//
// Copyright (c) 2020 Alexander Söderberg & Contributors
//
// 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.
//
/**
* Velocity test plugin
*/
package cloud.commandframework.cloudvelocitytest;