mirror of
https://github.com/plexusorg/Skyblock.git
synced 2025-01-22 07:50:07 +00:00
setup cloud framework
This commit is contained in:
parent
094079e4f4
commit
37c8f49a8d
@ -1,6 +1,7 @@
|
||||
plugins {
|
||||
`java-library`
|
||||
id("io.papermc.paperweight.userdev") version "1.5.5"
|
||||
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
|
||||
}
|
||||
|
||||
group = "dev.plex"
|
||||
@ -21,6 +22,9 @@ repositories {
|
||||
maven {
|
||||
url = uri("https://repo.rapture.pw/repository/maven-releases/")
|
||||
}
|
||||
maven {
|
||||
url = uri("https://oss.sonatype.org/content/repositories/snapshots")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -28,6 +32,8 @@ dependencies {
|
||||
compileOnly("com.infernalsuite.aswm:api:1.20-R0.1-SNAPSHOT")
|
||||
compileOnly("org.projectlombok:lombok:1.18.28")
|
||||
|
||||
library("cloud.commandframework", "cloud-paper", "1.8.3")
|
||||
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.28")
|
||||
}
|
||||
|
||||
@ -49,16 +55,6 @@ tasks {
|
||||
}
|
||||
processResources {
|
||||
filteringCharset = Charsets.UTF_8.name() // We want UTF-8 for everything
|
||||
val props = mapOf(
|
||||
"name" to project.name,
|
||||
"version" to project.version,
|
||||
"description" to project.description,
|
||||
"apiVersion" to "1.20"
|
||||
)
|
||||
inputs.properties(props)
|
||||
filesMatching("plugin.yml") {
|
||||
expand(props)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -68,4 +64,11 @@ tasks {
|
||||
outputJar.set(layout.buildDirectory.file("libs/PaperweightTestPlugin-${project.version}.jar"))
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
bukkit {
|
||||
main = "dev.plex.skyblock.Skyblock"
|
||||
name = "Plex-Skyblock"
|
||||
version = project.version.toString()
|
||||
apiVersion = "1.20"
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package dev.plex.skyblock;
|
||||
|
||||
import dev.plex.skyblock.command.CommandHandler;
|
||||
import dev.plex.skyblock.hook.SlimeWorldHook;
|
||||
import dev.plex.skyblock.listener.PlayerListener;
|
||||
import lombok.Getter;
|
||||
@ -15,6 +16,7 @@ public final class Skyblock extends JavaPlugin {
|
||||
@Getter
|
||||
private final SlimeWorldHook slimeWorldHook = new SlimeWorldHook();
|
||||
|
||||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
plugin = this;
|
||||
@ -22,6 +24,12 @@ public final class Skyblock extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
try {
|
||||
new CommandHandler().setup();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
||||
slimeWorldHook.onEnable(this);
|
||||
}
|
||||
|
41
src/main/java/dev/plex/skyblock/command/CommandHandler.java
Normal file
41
src/main/java/dev/plex/skyblock/command/CommandHandler.java
Normal file
@ -0,0 +1,41 @@
|
||||
package dev.plex.skyblock.command;
|
||||
|
||||
import cloud.commandframework.CommandTree;
|
||||
import cloud.commandframework.execution.AsynchronousCommandExecutionCoordinator;
|
||||
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||
import cloud.commandframework.execution.FilteringCommandSuggestionProcessor;
|
||||
import cloud.commandframework.paper.PaperCommandManager;
|
||||
import dev.plex.skyblock.Skyblock;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* @author Taah
|
||||
* @project plex-skyblock
|
||||
* @since 10:32 PM [02-07-2023]
|
||||
*/
|
||||
public class CommandHandler {
|
||||
private PaperCommandManager<CommandSender> commandManager;
|
||||
|
||||
public void setup() throws Exception {
|
||||
final Function<CommandTree<CommandSender>, CommandExecutionCoordinator<CommandSender>> executionCoordinatorFunction =
|
||||
AsynchronousCommandExecutionCoordinator.<CommandSender>builder().build();
|
||||
final Function<CommandSender, CommandSender> mapperFunction = Function.identity();
|
||||
this.commandManager = new PaperCommandManager<>(
|
||||
Skyblock.plugin(),
|
||||
executionCoordinatorFunction,
|
||||
mapperFunction,
|
||||
mapperFunction
|
||||
);
|
||||
|
||||
this.commandManager.commandSuggestionProcessor(new FilteringCommandSuggestionProcessor<>(
|
||||
FilteringCommandSuggestionProcessor.Filter.<CommandSender>contains(true).andTrimBeforeLastSpace()
|
||||
));
|
||||
this.commandManager.registerBrigadier();
|
||||
this.commandManager.registerAsynchronousCompletions();
|
||||
|
||||
|
||||
WorldCommand.register(this.commandManager);
|
||||
}
|
||||
}
|
43
src/main/java/dev/plex/skyblock/command/WorldCommand.java
Normal file
43
src/main/java/dev/plex/skyblock/command/WorldCommand.java
Normal file
@ -0,0 +1,43 @@
|
||||
package dev.plex.skyblock.command;
|
||||
|
||||
import cloud.commandframework.ArgumentDescription;
|
||||
import cloud.commandframework.bukkit.parsers.PlayerArgument;
|
||||
import cloud.commandframework.bukkit.parsers.WorldArgument;
|
||||
import cloud.commandframework.paper.PaperCommandManager;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Taah
|
||||
* @project plex-skyblock
|
||||
* @since 9:29 PM [02-07-2023]
|
||||
*/
|
||||
|
||||
public class WorldCommand {
|
||||
|
||||
public static void register(PaperCommandManager<CommandSender> commandManager) {
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder("goto", ArgumentDescription.of("Teleports you to a world"), "gotoworld", "world", "tpworld")
|
||||
.argument(WorldArgument.of("world"))
|
||||
.senderType(Player.class)
|
||||
.permission("skyblock.command.goto")
|
||||
.handler(commandContext -> {
|
||||
final World world = commandContext.get("world");
|
||||
((Player) commandContext.getSender()).teleportAsync(world.getSpawnLocation());
|
||||
})
|
||||
);
|
||||
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder("goto", ArgumentDescription.of("Teleports a player to a world"), "gotoworld", "world", "tpworld")
|
||||
.argument(WorldArgument.of("world"))
|
||||
.argument(PlayerArgument.of("player"))
|
||||
.permission("skyblock.command.goto.other")
|
||||
.handler(commandContext -> {
|
||||
final World world = commandContext.get("world");
|
||||
((Player) commandContext.get("player")).teleportAsync(world.getSpawnLocation());
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
name: "${name}"
|
||||
version: "${version}"
|
||||
main: dev.plex.skyblock.Skyblock
|
||||
api-version: "1.20"
|
Loading…
x
Reference in New Issue
Block a user