bazeling real hard today
This commit is contained in:
parent
5cb75791e7
commit
80d9b07f0c
45 changed files with 426 additions and 718 deletions
5
.bazelrc
Normal file
5
.bazelrc
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
build --java_language_version=25
|
||||||
|
build --java_runtime_version=25
|
||||||
|
build --tool_java_language_version=25
|
||||||
|
build --tool_java_runtime_version=25
|
||||||
|
build --define=maven_repo=https://repo.lab0x13.site/snapshots
|
||||||
9
.gitignore
vendored
9
.gitignore
vendored
|
|
@ -43,4 +43,11 @@ bin/
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
||||||
### Mac OS ###
|
### Mac OS ###
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
|
/.bazelbsp
|
||||||
|
/bazel-bin
|
||||||
|
/bazel-core
|
||||||
|
/bazel-out
|
||||||
|
/bazel-testlogs
|
||||||
|
/MODULE.bazel.lock
|
||||||
46
MODULE.bazel
Normal file
46
MODULE.bazel
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
bazel_dep(name = "rules_java", version = "9.7.0")
|
||||||
|
bazel_dep(name = "rules_jvm_external", version = "7.1")
|
||||||
|
bazel_dep(name = "bazel_jar_jar", version = "0.1.15")
|
||||||
|
|
||||||
|
git_override(
|
||||||
|
module_name = "rules_jvm_external",
|
||||||
|
remote = "http://forge.kentoj.de/scrow/rules_jvm_external.git",
|
||||||
|
)
|
||||||
|
|
||||||
|
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
|
||||||
|
maven.install(
|
||||||
|
name = "maven",
|
||||||
|
artifacts = [
|
||||||
|
"com.leakyabstractions:result:1.0.2.0",
|
||||||
|
"com.leakyabstractions:result-api:1.0.1.0",
|
||||||
|
"org.jetbrains:annotations:26.0.2-1",
|
||||||
|
"com.google.guava:guava:33.5.0-jre",
|
||||||
|
"org.projectlombok:lombok:1.18.46",
|
||||||
|
"org.slf4j:slf4j-api:2.0.18",
|
||||||
|
"org.slf4j:slf4j-simple:2.0.18",
|
||||||
|
"net.kyori:adventure-api:5.2.0",
|
||||||
|
"net.kyori:adventure-text-minimessage:5.2.0",
|
||||||
|
"io.papermc.paper:paper-api:[26.2.build,)",
|
||||||
|
"com.velocitypowered:velocity-api:4.1.0-20260802.091736-8",
|
||||||
|
"org.jdbi:jdbi3-core:3.53.0",
|
||||||
|
"org.jdbi:jdbi3-postgres:3.53.0",
|
||||||
|
"org.mongodb:bson:5.8.0",
|
||||||
|
"io.nats:jnats:2.25.2",
|
||||||
|
"de.kentoj.scrow:kencommandapi-core:0.34-SNAPSHOT",
|
||||||
|
"de.kentoj.scrow:kencommandapi-bukkit:0.34-SNAPSHOT",
|
||||||
|
"de.kentoj.scrow:kencommandapi-velocity:0.34-SNAPSHOT",
|
||||||
|
"io.papermc.paper:paper-api:[26.2.build,)",
|
||||||
|
"net.luckperms:api:5.5",
|
||||||
|
],
|
||||||
|
repositories = [
|
||||||
|
"https://repo.papermc.io/repository/maven-public/",
|
||||||
|
"https://repo.lab0x13.site/snapshots",
|
||||||
|
],
|
||||||
|
known_contributing_modules = ["protobuf"],
|
||||||
|
fail_on_missing_checksum = False, # for kencommandapi
|
||||||
|
)
|
||||||
|
|
||||||
|
# luckperms is provided at runtime
|
||||||
|
maven.amend_artifact(coordinates = "net.luckperms:api", neverlink = "true")
|
||||||
|
|
||||||
|
use_repo(maven, "maven")
|
||||||
38
README.md
38
README.md
|
|
@ -1,8 +1,30 @@
|
||||||
TODO
|
# TODO
|
||||||
- make core-lib-impl: a library -> avoid shading massive core-lib
|
|
||||||
|
## BUILD
|
||||||
|
- turn structure into
|
||||||
|
```text
|
||||||
|
//core-bukkit:api
|
||||||
|
//core-bukkit:plugin
|
||||||
|
//core-velocity:api
|
||||||
|
//core-velocity:plugin
|
||||||
|
//core-lib
|
||||||
|
```
|
||||||
|
- MAKE THIS A MONOREPO
|
||||||
|
- make sure it doesn't break when using postgres/nats (i only tested with dummies)
|
||||||
|
- lwk make sure velocity plugin works at runtime
|
||||||
|
- runServer target:
|
||||||
|
- start papermc server
|
||||||
|
- start PostgreSQL server
|
||||||
|
- maybe also have some map loaded
|
||||||
|
- refactor BUILD files: MODULES.bazel
|
||||||
|
- debate use of third_party; deduplicate
|
||||||
|
|
||||||
|
## bukkit
|
||||||
- notification: Friend is now offline/online
|
- notification: Friend is now offline/online
|
||||||
- /ignore command
|
- /ignore command
|
||||||
|
|
||||||
|
# Project
|
||||||
|
|
||||||
modules
|
modules
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
|
@ -10,4 +32,14 @@ modules
|
||||||
- **core-bukkit-api** stateful api, for minecraft development, depends on core-lib
|
- **core-bukkit-api** stateful api, for minecraft development, depends on core-lib
|
||||||
- **core-bukkit-api** stateful plugin, same as core-bukkit-api but implements it
|
- **core-bukkit-api** stateful plugin, same as core-bukkit-api but implements it
|
||||||
- **core-velocity-api** stateful api, for proxy development, depends on core-lib
|
- **core-velocity-api** stateful api, for proxy development, depends on core-lib
|
||||||
- **core-velocity-impl** stateful plugin, same as core-velocity-api but implements it
|
- **core-velocity-impl** stateful plugin, same as core-velocity-api but implements it
|
||||||
|
|
||||||
|
Building
|
||||||
|
--------
|
||||||
|
|
||||||
|
compile the bukkit-impl plugin:
|
||||||
|
```shell
|
||||||
|
bazel build //core-bukkit-impl:bukkit-impl_deploy.jar
|
||||||
|
```
|
||||||
|
This produces `bazel-bin/core-bukkit-impl/bukkit-impl.jar` with all dependencies built-in except for
|
||||||
|
LuckPerms.
|
||||||
|
|
@ -1,10 +0,0 @@
|
||||||
group = "de.kentoj.scrow"
|
|
||||||
version = "1.0.0-SNAPSHOT"
|
|
||||||
|
|
||||||
subprojects {
|
|
||||||
version = rootProject.version
|
|
||||||
|
|
||||||
configurations.configureEach {
|
|
||||||
resolutionStrategy.cacheChangingModulesFor(0, TimeUnit.SECONDS)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
20
core-bukkit-api/BUILD
Normal file
20
core-bukkit-api/BUILD
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
load("@rules_jvm_external//:defs.bzl", "artifact")
|
||||||
|
load("@rules_java//java:java_library.bzl", "java_library")
|
||||||
|
|
||||||
|
java_library(
|
||||||
|
name = "core-bukkit-api",
|
||||||
|
srcs = glob(["src/main/**/*.java"]),
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
deps = [
|
||||||
|
"//core-lib:core",
|
||||||
|
artifact("io.papermc.paper:paper-api"),
|
||||||
|
artifact("org.projectlombok:lombok"),
|
||||||
|
artifact("de.kentoj.scrow:kencommandapi-bukkit"),
|
||||||
|
],
|
||||||
|
exports = [
|
||||||
|
"//core-lib:core",
|
||||||
|
artifact("de.kentoj.scrow:kencommandapi-bukkit"),
|
||||||
|
artifact("org.mongodb:bson"),
|
||||||
|
],
|
||||||
|
plugins = [ "//third_party:lombok_plugin" ],
|
||||||
|
)
|
||||||
|
|
@ -1,30 +0,0 @@
|
||||||
plugins {
|
|
||||||
id("java")
|
|
||||||
alias(libs.plugins.scrow.publish)
|
|
||||||
alias(libs.plugins.scrow.database)
|
|
||||||
alias(libs.plugins.scrow.basedependencies)
|
|
||||||
alias(libs.plugins.scrow.javalibrary)
|
|
||||||
}
|
|
||||||
|
|
||||||
group = "de.kentoj.scrow"
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
api(project(":core-lib"))
|
|
||||||
compileOnly(libs.papermc.api)
|
|
||||||
|
|
||||||
api(libs.nats)
|
|
||||||
api(libs.scrow.commandapi.bukkit) {
|
|
||||||
isChanging = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
create<MavenPublication>("ScrowBukkitApi") {
|
|
||||||
groupId = project.group.toString()
|
|
||||||
artifactId = project.name
|
|
||||||
version = project.version.toString()
|
|
||||||
from(components["java"])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -15,6 +15,8 @@ import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.jdbi.v3.core.Jdbi;
|
import org.jdbi.v3.core.Jdbi;
|
||||||
import org.jetbrains.annotations.ApiStatus;
|
import org.jetbrains.annotations.ApiStatus;
|
||||||
|
|
@ -45,7 +47,9 @@ public class ScrowAPI {
|
||||||
@Getter
|
@Getter
|
||||||
private static RegionManager regionManager;
|
private static RegionManager regionManager;
|
||||||
@Getter
|
@Getter
|
||||||
private static CommandAPI commandApi;
|
private static CommandAPI<Player> playerCommands;
|
||||||
|
@Getter
|
||||||
|
private static CommandAPI<CommandSender> commands;
|
||||||
@Getter
|
@Getter
|
||||||
private static PlayerPrefixProvider playerPrefixProvider;
|
private static PlayerPrefixProvider playerPrefixProvider;
|
||||||
@Getter
|
@Getter
|
||||||
|
|
@ -100,11 +104,6 @@ public class ScrowAPI {
|
||||||
ScrowAPI.regionManager = regionManager;
|
ScrowAPI.regionManager = regionManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiStatus.Internal
|
|
||||||
public static void setCommandApi(CommandAPI commandApi) {
|
|
||||||
ScrowAPI.commandApi = commandApi;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
public static void setPlayerFactory(NetworkPlayerFactory playerFactory) {
|
public static void setPlayerFactory(NetworkPlayerFactory playerFactory) {
|
||||||
ScrowAPI.playerFactory = playerFactory;
|
ScrowAPI.playerFactory = playerFactory;
|
||||||
|
|
@ -114,5 +113,15 @@ public class ScrowAPI {
|
||||||
public static void setPlayerPrefixProvider(PlayerPrefixProvider playerPrefixProvider) {
|
public static void setPlayerPrefixProvider(PlayerPrefixProvider playerPrefixProvider) {
|
||||||
ScrowAPI.playerPrefixProvider = playerPrefixProvider;
|
ScrowAPI.playerPrefixProvider = playerPrefixProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
|
public static void setPlayerCommands(CommandAPI<Player> playerCommands) {
|
||||||
|
ScrowAPI.playerCommands = playerCommands;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
|
public static void setCommands(CommandAPI<CommandSender> commands) {
|
||||||
|
ScrowAPI.commands = commands;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package de.kentoj.scrow.bukkit.minigame.phase;
|
package de.kentoj.scrow.bukkit.minigame.phase;
|
||||||
|
|
||||||
import com.google.errorprone.annotations.ForOverride;
|
|
||||||
import de.kentoj.scrow.bukkit.ScrowAPI;
|
import de.kentoj.scrow.bukkit.ScrowAPI;
|
||||||
import de.kentoj.scrow.bukkit.minigame.Minigame;
|
import de.kentoj.scrow.bukkit.minigame.Minigame;
|
||||||
import de.kentoj.scrow.bukkit.minigame.phaseflow.PhaseContext;
|
import de.kentoj.scrow.bukkit.minigame.phaseflow.PhaseContext;
|
||||||
|
|
@ -25,11 +24,9 @@ public abstract class Phase<T extends Minigame> implements IPhase {
|
||||||
*/
|
*/
|
||||||
protected abstract void onCancel();
|
protected abstract void onCancel();
|
||||||
|
|
||||||
@ForOverride
|
|
||||||
protected void onEnd() {
|
protected void onEnd() {
|
||||||
}
|
}
|
||||||
|
|
||||||
@ForOverride
|
|
||||||
protected void onTick(int tick) {
|
protected void onTick(int tick) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import de.kentoj.scrow.bukkit.minigame.phase.PhaseFlow;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.jspecify.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
|
||||||
17
core-bukkit-impl/BUILD
Normal file
17
core-bukkit-impl/BUILD
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
load("@rules_java//java:java_binary.bzl", "java_binary")
|
||||||
|
load("@rules_jvm_external//:defs.bzl", "artifact")
|
||||||
|
|
||||||
|
java_binary(
|
||||||
|
name = "core-bukkit-plugin",
|
||||||
|
srcs = glob(["src/main/**/*.java"]),
|
||||||
|
main_class = "none",
|
||||||
|
resources = glob(["src/main/resources/**"], allow_empty = True),
|
||||||
|
deps = [
|
||||||
|
"//core-bukkit-api:core-bukkit-api",
|
||||||
|
artifact("net.luckperms:api"),
|
||||||
|
artifact("io.papermc.paper:paper-api"),
|
||||||
|
artifact("io.nats:jnats"),
|
||||||
|
artifact("net.kyori:adventure-key:5.2.0"),
|
||||||
|
],
|
||||||
|
plugins = [ "//third_party:lombok_plugin" ],
|
||||||
|
)
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
plugins {
|
|
||||||
id("java")
|
|
||||||
alias(libs.plugins.scrow.publish)
|
|
||||||
alias(libs.plugins.scrow.runserver)
|
|
||||||
alias(libs.plugins.shadow)
|
|
||||||
alias(libs.plugins.scrow.basedependencies)
|
|
||||||
alias(libs.plugins.scrow.database)
|
|
||||||
}
|
|
||||||
|
|
||||||
group = "de.kentoj.scrow"
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
implementation(project(":core-bukkit-api"))
|
|
||||||
compileOnly(libs.papermc.api)
|
|
||||||
|
|
||||||
implementation(libs.bson)
|
|
||||||
implementation(libs.nats)
|
|
||||||
implementation(libs.scrow.commandapi.bukkit) {
|
|
||||||
isChanging = true
|
|
||||||
}
|
|
||||||
implementation(libs.postgres)
|
|
||||||
compileOnly(libs.luckperms)
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.processResources {
|
|
||||||
filesMatching("plugin.yml") {
|
|
||||||
expand(
|
|
||||||
mapOf("version" to project.version.toString())
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.build {
|
|
||||||
dependsOn("shadowJar")
|
|
||||||
}
|
|
||||||
tasks.shadowJar {
|
|
||||||
archiveClassifier = ""
|
|
||||||
}
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA).
|
|
||||||
#Mon Jul 06 16:35:59 CEST 2026
|
|
||||||
eula=true
|
|
||||||
|
|
@ -26,12 +26,12 @@ public final class CoreImplPlugin extends JavaPlugin {
|
||||||
var cachedPrefixProvider = new CachedPrefixProvider();
|
var cachedPrefixProvider = new CachedPrefixProvider();
|
||||||
ScrowAPISurface.initScrowAPI(this, cachedPrefixProvider);
|
ScrowAPISurface.initScrowAPI(this, cachedPrefixProvider);
|
||||||
|
|
||||||
ScrowAPI.getCommandApi().register(new CoinsCommand().getRootLiteral());
|
ScrowAPI.getPlayerCommands().register(new CoinsCommand().getRootLiteral());
|
||||||
ScrowAPI.getCommandApi().register(FriendCommand.create());
|
ScrowAPI.getPlayerCommands().register(FriendCommand.create());
|
||||||
var instanceCache = new InstanceCache();
|
var instanceCache = new InstanceCache();
|
||||||
ScrowAPI.getCommandApi().register(InstanceCommand.create(instanceCache));
|
ScrowAPI.getCommands().register(InstanceCommand.create(instanceCache));
|
||||||
ScrowAPI.getCommandApi().register(new PlayCommand().getRootLiteral());
|
ScrowAPI.getPlayerCommands().register(new PlayCommand().getRootLiteral());
|
||||||
ScrowAPI.getCommandApi().register(new LobbyCommand().getRootLiteral());
|
ScrowAPI.getPlayerCommands().register(new LobbyCommand().getRootLiteral());
|
||||||
|
|
||||||
var luckperms = LuckPermsProvider.get();
|
var luckperms = LuckPermsProvider.get();
|
||||||
new LuckPermsPrefixSetter(luckperms, cachedPrefixProvider).init(this);
|
new LuckPermsPrefixSetter(luckperms, cachedPrefixProvider).init(this);
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,8 @@ import io.nats.client.Options;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.jdbi.v3.core.Jdbi;
|
import org.jdbi.v3.core.Jdbi;
|
||||||
|
|
||||||
|
|
@ -67,7 +69,8 @@ public class ScrowAPISurface {
|
||||||
|
|
||||||
ScrowAPI.setPlayerFactory(playerId -> new NetworkPlayerImpl(ScrowAPI.getMessageBroker(), playerId));
|
ScrowAPI.setPlayerFactory(playerId -> new NetworkPlayerImpl(ScrowAPI.getMessageBroker(), playerId));
|
||||||
ScrowAPI.setRegionManager(new RegionManagerImpl());
|
ScrowAPI.setRegionManager(new RegionManagerImpl());
|
||||||
ScrowAPI.setCommandApi(new CommandAPI(plugin));
|
ScrowAPI.setCommands(new CommandAPI<>(plugin, CommandSender.class));
|
||||||
|
ScrowAPI.setPlayerCommands(new CommandAPI<>(plugin, Player.class));
|
||||||
ScrowAPI.setInstanceManager(new InstanceManagerImpl(ScrowAPI.getMessageBroker()));
|
ScrowAPI.setInstanceManager(new InstanceManagerImpl(ScrowAPI.getMessageBroker()));
|
||||||
ScrowAPI.setEconomyService(ScrowAPI.getJdbi() != null ?
|
ScrowAPI.setEconomyService(ScrowAPI.getJdbi() != null ?
|
||||||
new PostgresEconomyService(ScrowAPI.getJdbi()) : new InMemoryEconomyService());
|
new PostgresEconomyService(ScrowAPI.getJdbi()) : new InMemoryEconomyService());
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package de.kentoj.scrow.bukkit.command.economy;
|
||||||
import com.leakyabstractions.result.api.Result;
|
import com.leakyabstractions.result.api.Result;
|
||||||
import com.leakyabstractions.result.core.Results;
|
import com.leakyabstractions.result.core.Results;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandExecutor;
|
|
||||||
import de.kentoj.kencommandapi.api.literal.Literal;
|
import de.kentoj.kencommandapi.api.literal.Literal;
|
||||||
import de.kentoj.kencommandapi.api.literal.RootLiteral;
|
import de.kentoj.kencommandapi.api.literal.RootLiteral;
|
||||||
import de.kentoj.kencommandapi.api.platform.MessageStyle;
|
import de.kentoj.kencommandapi.api.platform.MessageStyle;
|
||||||
|
|
@ -11,34 +10,27 @@ import de.kentoj.scrow.bukkit.ScrowAPI;
|
||||||
import de.kentoj.scrow.bukkit.scheduler.Tasks;
|
import de.kentoj.scrow.bukkit.scheduler.Tasks;
|
||||||
import de.kentoj.scrowlib.convention.ScrowMessageStyle;
|
import de.kentoj.scrowlib.convention.ScrowMessageStyle;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class CoinsCommand implements CommandExecutor<CommandSender> {
|
public final class CoinsCommand {
|
||||||
@Getter
|
@Getter
|
||||||
private final RootLiteral<CommandSender> rootLiteral;
|
private final RootLiteral<Player> rootLiteral;
|
||||||
private final MessageStyle style;
|
private final MessageStyle style;
|
||||||
|
|
||||||
public CoinsCommand() {
|
public CoinsCommand() {
|
||||||
style = ScrowMessageStyle.GENERIC;
|
style = ScrowMessageStyle.GENERIC;
|
||||||
rootLiteral = Literal.rootLiteral(style, "coins", "bal", "balance");
|
rootLiteral = Literal.<Player>builder("coins", "bal", "balance")
|
||||||
rootLiteral.setPermission("command.coins.get.self");
|
.withPermission("command.coins.get.self")
|
||||||
rootLiteral.setExecutor(this);
|
.withExecutor(this::execute)
|
||||||
|
.withLiteral(new CoinsSetLiteral(style).getLiteral())
|
||||||
var setLiteral = new CoinsSetLiteral(style).getLiteral();
|
.withLiteral(new CoinsGetLiteral(style).getLiteral())
|
||||||
setLiteral.setPermission("command.coins.set");
|
.asRootLiteral(style);
|
||||||
rootLiteral.addLiteral(setLiteral);
|
|
||||||
|
|
||||||
var getLiteral = new CoinsGetLiteral(style).getLiteral();
|
|
||||||
getLiteral.setPermission("command.coins.get.others");
|
|
||||||
rootLiteral.addLiteral(getLiteral);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public CompletableFuture<Result<Object, String>> execute(CommandContext<Player> ctx) {
|
||||||
public CompletableFuture<Result<Object, String>> execute(CommandContext<CommandSender> ctx) {
|
var player = ctx.getSender();
|
||||||
var player = ((Player) ctx.getSender());
|
|
||||||
return Tasks.supplyAsync(() ->
|
return Tasks.supplyAsync(() ->
|
||||||
ScrowAPI.getEconomyService().getCoins(player.getUniqueId()))
|
ScrowAPI.getEconomyService().getCoins(player.getUniqueId()))
|
||||||
.<Result<Object, String>>mapSync(amount -> {
|
.<Result<Object, String>>mapSync(amount -> {
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,8 @@ package de.kentoj.scrow.bukkit.command.economy;
|
||||||
|
|
||||||
import com.leakyabstractions.result.api.Result;
|
import com.leakyabstractions.result.api.Result;
|
||||||
import com.leakyabstractions.result.core.Results;
|
import com.leakyabstractions.result.core.Results;
|
||||||
import de.kentoj.kencommandapi.api.argument.CommandArgument;
|
import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandExecutor;
|
|
||||||
import de.kentoj.kencommandapi.api.literal.Literal;
|
import de.kentoj.kencommandapi.api.literal.Literal;
|
||||||
import de.kentoj.kencommandapi.api.platform.MessageStyle;
|
import de.kentoj.kencommandapi.api.platform.MessageStyle;
|
||||||
import de.kentoj.kencommandapi.type.OfflinePlayerArgumentType;
|
import de.kentoj.kencommandapi.type.OfflinePlayerArgumentType;
|
||||||
|
|
@ -13,30 +12,31 @@ import de.kentoj.scrow.bukkit.scheduler.Tasks;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class CoinsGetLiteral implements CommandExecutor<CommandSender> {
|
public final class CoinsGetLiteral {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Literal<CommandSender> literal;
|
private final Literal<Player> literal;
|
||||||
|
|
||||||
private final MessageStyle style;
|
private final MessageStyle style;
|
||||||
private final CommandArgument<CommandSender, OfflinePlayer> playerArg;
|
private final CommandArgumentSpec<Player, OfflinePlayer> playerArg;
|
||||||
|
|
||||||
public CoinsGetLiteral(MessageStyle style) {
|
public CoinsGetLiteral(MessageStyle style) {
|
||||||
this.style = style;
|
this.style = style;
|
||||||
|
|
||||||
playerArg = CommandArgument.arg("player", OfflinePlayerArgumentType.getInstance());
|
playerArg = CommandArgumentSpec.builder("player", new OfflinePlayerArgumentType<Player>())
|
||||||
playerArg.setDefaultValueProvider(sender -> (OfflinePlayer) sender);
|
.withDefaultValue(CommandContext::getSender)
|
||||||
|
.build();
|
||||||
literal = Literal.literal("get");
|
literal = Literal.<Player>builder("get")
|
||||||
literal.addArgument(playerArg);
|
.withPermission("command.coins.get.others")
|
||||||
literal.setExecutor(this);
|
.withArgument(playerArg)
|
||||||
|
.withExecutor(this::execute)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private CompletableFuture<Result<Object, String>> execute(CommandContext<Player> ctx) {
|
||||||
public CompletableFuture<Result<Object, String>> execute(CommandContext<CommandSender> ctx) {
|
|
||||||
var player = ctx.getArg(playerArg);
|
var player = ctx.getArg(playerArg);
|
||||||
return Tasks.supplyAsync(() ->
|
return Tasks.supplyAsync(() ->
|
||||||
ScrowAPI.getEconomyService().getCoins(player.getUniqueId()))
|
ScrowAPI.getEconomyService().getCoins(player.getUniqueId()))
|
||||||
|
|
@ -45,5 +45,4 @@ public class CoinsGetLiteral implements CommandExecutor<CommandSender> {
|
||||||
return Results.success(new Object());
|
return Results.success(new Object());
|
||||||
}).toFuture();
|
}).toFuture();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,11 @@ package de.kentoj.scrow.bukkit.command.economy;
|
||||||
|
|
||||||
import com.leakyabstractions.result.api.Result;
|
import com.leakyabstractions.result.api.Result;
|
||||||
import com.leakyabstractions.result.core.Results;
|
import com.leakyabstractions.result.core.Results;
|
||||||
import de.kentoj.kencommandapi.api.argument.CommandArgument;
|
import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec;
|
||||||
import de.kentoj.kencommandapi.api.argument.types.IntegerArgumentType;
|
import de.kentoj.kencommandapi.api.argument.types.IntegerArgumentType;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandExecutor;
|
|
||||||
import de.kentoj.kencommandapi.api.literal.Literal;
|
import de.kentoj.kencommandapi.api.literal.Literal;
|
||||||
|
import de.kentoj.kencommandapi.api.literal.LiteralBuilder;
|
||||||
import de.kentoj.kencommandapi.api.platform.MessageStyle;
|
import de.kentoj.kencommandapi.api.platform.MessageStyle;
|
||||||
import de.kentoj.kencommandapi.type.OfflinePlayerArgumentType;
|
import de.kentoj.kencommandapi.type.OfflinePlayerArgumentType;
|
||||||
import de.kentoj.scrow.bukkit.ScrowAPI;
|
import de.kentoj.scrow.bukkit.ScrowAPI;
|
||||||
|
|
@ -14,32 +14,35 @@ import de.kentoj.scrow.bukkit.scheduler.Tasks;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class CoinsSetLiteral implements CommandExecutor<CommandSender> {
|
public final class CoinsSetLiteral {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Literal<CommandSender> literal;
|
private final Literal<Player> literal;
|
||||||
|
|
||||||
private final MessageStyle style;
|
private final MessageStyle style;
|
||||||
private final CommandArgument<CommandSender, OfflinePlayer> playerArg;
|
private final CommandArgumentSpec<Player, OfflinePlayer> playerArg;
|
||||||
private final CommandArgument<CommandSender, Integer> amountArg;
|
private final CommandArgumentSpec<Player, Integer> amountArg;
|
||||||
|
|
||||||
public CoinsSetLiteral(MessageStyle style) {
|
public CoinsSetLiteral(MessageStyle style) {
|
||||||
this.style = style;
|
this.style = style;
|
||||||
|
playerArg = CommandArgumentSpec.builder("player", new OfflinePlayerArgumentType<Player>())
|
||||||
playerArg = CommandArgument.arg("player", OfflinePlayerArgumentType.getInstance());
|
.withDefaultValue(CommandContext::getSender)
|
||||||
amountArg = CommandArgument.arg("amount", new IntegerArgumentType<>());
|
.build();
|
||||||
|
amountArg = CommandArgumentSpec.builder("amount", new IntegerArgumentType<Player>())
|
||||||
literal = Literal.literal("set");
|
.build();
|
||||||
literal.addArgument(playerArg);
|
literal = Literal.<Player>builder("set")
|
||||||
literal.addArgument(amountArg);
|
.withPermission("command.coins.set")
|
||||||
literal.setExecutor(this);
|
.withArgument(playerArg)
|
||||||
|
.withArgument(amountArg)
|
||||||
|
.withExecutor(this::execute)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private CompletableFuture<Result<Object, String>> execute(CommandContext<Player> ctx) {
|
||||||
public CompletableFuture<Result<Object, String>> execute(CommandContext<CommandSender> ctx) {
|
|
||||||
var player = ctx.getArg(playerArg);
|
var player = ctx.getArg(playerArg);
|
||||||
var amount = ctx.getArg(amountArg);
|
var amount = ctx.getArg(amountArg);
|
||||||
return Tasks.runAsync(() ->
|
return Tasks.runAsync(() ->
|
||||||
|
|
|
||||||
|
|
@ -2,24 +2,21 @@ package de.kentoj.scrow.bukkit.command.friends;
|
||||||
|
|
||||||
import com.leakyabstractions.result.api.Result;
|
import com.leakyabstractions.result.api.Result;
|
||||||
import com.leakyabstractions.result.core.Results;
|
import com.leakyabstractions.result.core.Results;
|
||||||
import de.kentoj.kencommandapi.api.argument.CommandArgument;
|
import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandExecutor;
|
|
||||||
import de.kentoj.kencommandapi.api.literal.Literal;
|
import de.kentoj.kencommandapi.api.literal.Literal;
|
||||||
import de.kentoj.kencommandapi.type.OfflinePlayerArgumentType;
|
import de.kentoj.kencommandapi.type.OfflinePlayerArgumentType;
|
||||||
import de.kentoj.scrow.bukkit.ScrowAPI;
|
import de.kentoj.scrow.bukkit.ScrowAPI;
|
||||||
|
import de.kentoj.scrow.bukkit.scheduler.Task;
|
||||||
|
import de.kentoj.scrow.bukkit.scheduler.Tasks;
|
||||||
|
import de.kentoj.scrowlib.convention.ScrowMessageStyle;
|
||||||
import de.kentoj.scrowlib.friends.FriendRequestService;
|
import de.kentoj.scrowlib.friends.FriendRequestService;
|
||||||
import de.kentoj.scrowlib.friends.FriendshipService;
|
import de.kentoj.scrowlib.friends.FriendshipService;
|
||||||
import de.kentoj.scrowlib.friends.friendship.FriendshipImpl;
|
import de.kentoj.scrowlib.friends.friendship.FriendshipImpl;
|
||||||
import de.kentoj.scrowlib.friends.request.FriendRequestImpl;
|
import de.kentoj.scrowlib.friends.request.FriendRequestImpl;
|
||||||
import de.kentoj.scrow.bukkit.scheduler.Task;
|
|
||||||
import de.kentoj.scrow.bukkit.scheduler.Tasks;
|
|
||||||
import de.kentoj.scrowlib.convention.ScrowMessageStyle;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
@ -27,27 +24,28 @@ import java.util.Objects;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
public class FriendAddLiteral {
|
||||||
public class FriendAddLiteral implements CommandExecutor<CommandSender> {
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Literal<CommandSender> literal;
|
private final Literal<Player> literal;
|
||||||
private final CommandArgument<CommandSender, OfflinePlayer> playerArg;
|
private final CommandArgumentSpec<Player, OfflinePlayer> playerArg;
|
||||||
private final ScrowMessageStyle style;
|
private final ScrowMessageStyle style;
|
||||||
|
|
||||||
private final FriendRequestService requestService = ScrowAPI.getFriendRequestService();
|
private final FriendRequestService requestService = ScrowAPI.getFriendRequestService();
|
||||||
private final FriendshipService friendsService = ScrowAPI.getFriendshipService();
|
private final FriendshipService friendsService = ScrowAPI.getFriendshipService();
|
||||||
|
|
||||||
public FriendAddLiteral(ScrowMessageStyle style) {
|
public FriendAddLiteral(ScrowMessageStyle style) {
|
||||||
this.style = style;
|
this.style = style;
|
||||||
playerArg = CommandArgument.arg("player", OfflinePlayerArgumentType.getInstance());
|
playerArg = CommandArgumentSpec.builder("player", new OfflinePlayerArgumentType<Player>())
|
||||||
literal = Literal.literal("add");
|
.build();
|
||||||
literal.addArgument(playerArg);
|
literal = Literal.<Player>builder("add")
|
||||||
literal.setExecutor(this);
|
.withArgument(playerArg)
|
||||||
|
.withExecutor(this::execute)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private CompletableFuture<Result<Object, String>> execute(CommandContext<Player> ctx) {
|
||||||
public CompletableFuture<Result<Object, String>> execute(CommandContext<CommandSender> ctx) {
|
var self = ctx.getSender();
|
||||||
var self = (Player) ctx.getSender();
|
|
||||||
var other = ctx.getArg(playerArg);
|
var other = ctx.getArg(playerArg);
|
||||||
return Tasks.supplyAsync(() -> findAction(self, other)
|
return Tasks.supplyAsync(() -> findAction(self, other)
|
||||||
.mapSuccess(action -> {
|
.mapSuccess(action -> {
|
||||||
|
|
|
||||||
|
|
@ -9,19 +9,20 @@ import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import net.kyori.adventure.text.event.HoverEvent;
|
import net.kyori.adventure.text.event.HoverEvent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@NoArgsConstructor(access = AccessLevel.NONE)
|
@NoArgsConstructor(access = AccessLevel.NONE)
|
||||||
public class FriendCommand {
|
public class FriendCommand {
|
||||||
public static RootLiteral<CommandSender> create() {
|
|
||||||
|
public static RootLiteral<Player> create() {
|
||||||
var style = new ScrowMessageStyle("Friends", NamedTextColor.AQUA);
|
var style = new ScrowMessageStyle("Friends", NamedTextColor.AQUA);
|
||||||
RootLiteral<CommandSender> rootLiteral = Literal.rootLiteral(style, "f", "friend");
|
return Literal.<Player>builder("f", "friend")
|
||||||
rootLiteral.addLiteral(new FriendListLiteral(style).getLiteral());
|
.withLiteral(new FriendListLiteral(style).getLiteral())
|
||||||
rootLiteral.addLiteral(new FriendAddLiteral(style).getLiteral());
|
.withLiteral(new FriendAddLiteral(style).getLiteral())
|
||||||
rootLiteral.addLiteral(new FriendRemoveLiteral(style).getLiteral());
|
.withLiteral(new FriendRemoveLiteral(style).getLiteral())
|
||||||
rootLiteral.addLiteral(new FriendRequestDeclineLiteral(style).getLiteral());
|
.withLiteral(new FriendRequestDeclineLiteral(style).getLiteral())
|
||||||
rootLiteral.addLiteral(new FriendRequestsLiteral(style).getLiteral());
|
.withLiteral(new FriendRequestsLiteral(style).getLiteral())
|
||||||
return rootLiteral;
|
.asRootLiteral(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component friendRequestOptions(String requestSenderName, boolean runInstantly) {
|
public static Component friendRequestOptions(String requestSenderName, boolean runInstantly) {
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,17 @@ package de.kentoj.scrow.bukkit.command.friends;
|
||||||
import com.leakyabstractions.result.api.Result;
|
import com.leakyabstractions.result.api.Result;
|
||||||
import com.leakyabstractions.result.core.Results;
|
import com.leakyabstractions.result.core.Results;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandExecutor;
|
|
||||||
import de.kentoj.kencommandapi.api.literal.Literal;
|
import de.kentoj.kencommandapi.api.literal.Literal;
|
||||||
import de.kentoj.scrow.bukkit.ScrowAPI;
|
import de.kentoj.scrow.bukkit.ScrowAPI;
|
||||||
import de.kentoj.scrow.bukkit.scheduler.Tasks;
|
import de.kentoj.scrow.bukkit.scheduler.Tasks;
|
||||||
import de.kentoj.scrowlib.convention.ScrowMessageStyle;
|
import de.kentoj.scrowlib.convention.ScrowMessageStyle;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -23,21 +22,17 @@ import java.util.concurrent.CompletableFuture;
|
||||||
import static java.util.Objects.requireNonNull;
|
import static java.util.Objects.requireNonNull;
|
||||||
import static net.kyori.adventure.text.Component.text;
|
import static net.kyori.adventure.text.Component.text;
|
||||||
|
|
||||||
public class FriendListLiteral implements CommandExecutor<CommandSender> {
|
@RequiredArgsConstructor
|
||||||
|
public final class FriendListLiteral {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Literal<CommandSender> literal;
|
private final Literal<Player> literal = Literal.<Player>builder("list")
|
||||||
|
.withExecutor(this::displayFriendList)
|
||||||
|
.build();
|
||||||
private final ScrowMessageStyle style;
|
private final ScrowMessageStyle style;
|
||||||
|
|
||||||
public FriendListLiteral(ScrowMessageStyle style) {
|
private CompletableFuture<Result<Object, String>> displayFriendList(CommandContext<Player> ctx) {
|
||||||
this.style = style;
|
var sender = ctx.getSender();
|
||||||
this.literal = Literal.literal("list");
|
|
||||||
literal.setExecutor(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<Result<Object, String>> execute(CommandContext<CommandSender> ctx) {
|
|
||||||
var sender = (Player) ctx.getSender();
|
|
||||||
return Tasks.supplyAsync(() ->
|
return Tasks.supplyAsync(() ->
|
||||||
ScrowAPI.getFriendshipService().getFriendships(sender.getUniqueId()))
|
ScrowAPI.getFriendshipService().getFriendships(sender.getUniqueId()))
|
||||||
.<Result<Object, String>>mapSync(friendships -> {
|
.<Result<Object, String>>mapSync(friendships -> {
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,8 @@ package de.kentoj.scrow.bukkit.command.friends;
|
||||||
|
|
||||||
import com.leakyabstractions.result.api.Result;
|
import com.leakyabstractions.result.api.Result;
|
||||||
import com.leakyabstractions.result.core.Results;
|
import com.leakyabstractions.result.core.Results;
|
||||||
import de.kentoj.kencommandapi.api.argument.CommandArgument;
|
import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandExecutor;
|
|
||||||
import de.kentoj.kencommandapi.api.literal.Literal;
|
import de.kentoj.kencommandapi.api.literal.Literal;
|
||||||
import de.kentoj.kencommandapi.type.OfflinePlayerArgumentType;
|
import de.kentoj.kencommandapi.type.OfflinePlayerArgumentType;
|
||||||
import de.kentoj.scrow.bukkit.ScrowAPI;
|
import de.kentoj.scrow.bukkit.ScrowAPI;
|
||||||
|
|
@ -12,31 +11,31 @@ import de.kentoj.scrow.bukkit.scheduler.Tasks;
|
||||||
import de.kentoj.scrowlib.convention.ScrowMessageStyle;
|
import de.kentoj.scrowlib.convention.ScrowMessageStyle;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class FriendRemoveLiteral implements CommandExecutor<CommandSender> {
|
public class FriendRemoveLiteral {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Literal<CommandSender> literal;
|
private final Literal<Player> literal;
|
||||||
private final CommandArgument<CommandSender, OfflinePlayer> playerArg;
|
private final CommandArgumentSpec<Player, OfflinePlayer> playerArg;
|
||||||
private final ScrowMessageStyle style;
|
private final ScrowMessageStyle style;
|
||||||
|
|
||||||
public FriendRemoveLiteral(ScrowMessageStyle style) {
|
FriendRemoveLiteral(ScrowMessageStyle style) {
|
||||||
this.style = style;
|
this.style = style;
|
||||||
this.playerArg = CommandArgument.arg("player", OfflinePlayerArgumentType.getInstance());
|
playerArg = CommandArgumentSpec.<Player, OfflinePlayer>builder("player", new OfflinePlayerArgumentType<>())
|
||||||
this.literal = Literal.literal("remove");
|
.build();
|
||||||
this.literal.addArgument(playerArg);
|
literal = Literal.<Player>builder("remove")
|
||||||
this.literal.setExecutor(this);
|
.withArgument(playerArg)
|
||||||
|
.withExecutor(this::removeFriend)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private CompletableFuture<Result<Object, String>> removeFriend(CommandContext<Player> ctx) {
|
||||||
public CompletableFuture<Result<Object, String>> execute(CommandContext<CommandSender> ctx) {
|
|
||||||
var friend = ctx.getArg(playerArg);
|
var friend = ctx.getArg(playerArg);
|
||||||
var player = (Player) ctx.getSender();
|
|
||||||
return Tasks.supplyAsync(() ->
|
return Tasks.supplyAsync(() ->
|
||||||
ScrowAPI.getFriendshipService().deleteFriendship(friend.getUniqueId(), player.getUniqueId()))
|
ScrowAPI.getFriendshipService().deleteFriendship(friend.getUniqueId(), ctx.getSender().getUniqueId()))
|
||||||
.<Result<Object, String>>mapSync(deleted -> {
|
.<Result<Object, String>>mapSync(deleted -> {
|
||||||
if (!deleted)
|
if (!deleted)
|
||||||
return Results.failure("You are not friends with " + friend.getName() + ".");
|
return Results.failure("You are not friends with " + friend.getName() + ".");
|
||||||
|
|
|
||||||
|
|
@ -2,43 +2,42 @@ package de.kentoj.scrow.bukkit.command.friends;
|
||||||
|
|
||||||
import com.leakyabstractions.result.api.Result;
|
import com.leakyabstractions.result.api.Result;
|
||||||
import com.leakyabstractions.result.core.Results;
|
import com.leakyabstractions.result.core.Results;
|
||||||
import de.kentoj.kencommandapi.api.argument.CommandArgument;
|
import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandExecutor;
|
|
||||||
import de.kentoj.kencommandapi.api.literal.Literal;
|
import de.kentoj.kencommandapi.api.literal.Literal;
|
||||||
import de.kentoj.kencommandapi.type.OfflinePlayerArgumentType;
|
import de.kentoj.kencommandapi.type.OfflinePlayerArgumentType;
|
||||||
import de.kentoj.scrow.bukkit.ScrowAPI;
|
import de.kentoj.scrow.bukkit.ScrowAPI;
|
||||||
import de.kentoj.scrowlib.friends.FriendRequestService;
|
|
||||||
import de.kentoj.scrow.bukkit.scheduler.Tasks;
|
import de.kentoj.scrow.bukkit.scheduler.Tasks;
|
||||||
import de.kentoj.scrowlib.convention.ScrowMessageStyle;
|
import de.kentoj.scrowlib.convention.ScrowMessageStyle;
|
||||||
|
import de.kentoj.scrowlib.friends.FriendRequestService;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class FriendRequestDeclineLiteral implements CommandExecutor<CommandSender> {
|
public class FriendRequestDeclineLiteral {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Literal<CommandSender> literal;
|
private final Literal<Player> literal;
|
||||||
private final CommandArgument<CommandSender, OfflinePlayer> playerArg;
|
private final CommandArgumentSpec<Player, OfflinePlayer> playerArg;
|
||||||
private final ScrowMessageStyle style;
|
private final ScrowMessageStyle style;
|
||||||
private final FriendRequestService requestService = ScrowAPI.getFriendRequestService();
|
private final FriendRequestService requestService = ScrowAPI.getFriendRequestService();
|
||||||
|
|
||||||
public FriendRequestDeclineLiteral(ScrowMessageStyle style) {
|
FriendRequestDeclineLiteral(ScrowMessageStyle style) {
|
||||||
this.style = style;
|
this.style = style;
|
||||||
playerArg = CommandArgument.arg("player", OfflinePlayerArgumentType.getInstance());
|
playerArg = CommandArgumentSpec.builder("player", new OfflinePlayerArgumentType<Player>())
|
||||||
literal = Literal.literal("reject", "decline");
|
.build();
|
||||||
literal.addArgument(playerArg);
|
literal = Literal.<Player>builder("reject", "decline")
|
||||||
literal.setExecutor(this);
|
.withArgument(playerArg)
|
||||||
|
.withExecutor(this::declineFriendRequest)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private CompletableFuture<Result<Object, String>> declineFriendRequest(CommandContext<Player> ctx) {
|
||||||
public CompletableFuture<Result<Object, String>> execute(CommandContext<CommandSender> ctx) {
|
var self = ctx.getSender();
|
||||||
var self = (Player) ctx.getSender();
|
|
||||||
var other = ctx.getArg(playerArg);
|
var other = ctx.getArg(playerArg);
|
||||||
return Tasks.supplyAsync(() ->
|
return Tasks.supplyAsync(() ->
|
||||||
requestService.deleteFriendRequest(other.getUniqueId(), self.getUniqueId()))
|
requestService.deleteFriendRequest(other.getUniqueId(), self.getUniqueId()))
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,18 @@ package de.kentoj.scrow.bukkit.command.friends;
|
||||||
import com.leakyabstractions.result.api.Result;
|
import com.leakyabstractions.result.api.Result;
|
||||||
import com.leakyabstractions.result.core.Results;
|
import com.leakyabstractions.result.core.Results;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandExecutor;
|
|
||||||
import de.kentoj.kencommandapi.api.literal.Literal;
|
import de.kentoj.kencommandapi.api.literal.Literal;
|
||||||
import de.kentoj.scrow.bukkit.ScrowAPI;
|
import de.kentoj.scrow.bukkit.ScrowAPI;
|
||||||
import de.kentoj.scrowlib.friends.FriendRequest;
|
import de.kentoj.scrowlib.friends.FriendRequest;
|
||||||
import de.kentoj.scrow.bukkit.scheduler.Tasks;
|
import de.kentoj.scrow.bukkit.scheduler.Tasks;
|
||||||
import de.kentoj.scrowlib.convention.ScrowMessageStyle;
|
import de.kentoj.scrowlib.convention.ScrowMessageStyle;
|
||||||
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -22,28 +22,23 @@ import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import static net.kyori.adventure.text.Component.text;
|
import static net.kyori.adventure.text.Component.text;
|
||||||
|
|
||||||
public class FriendRequestsLiteral implements CommandExecutor<CommandSender> {
|
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
|
||||||
|
public class FriendRequestsLiteral {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Literal<CommandSender> literal;
|
private final Literal<Player> literal = Literal.<Player>builder("requests")
|
||||||
|
.withExecutor(this::displayFriendRequests)
|
||||||
|
.build();
|
||||||
private final ScrowMessageStyle style;
|
private final ScrowMessageStyle style;
|
||||||
|
|
||||||
public FriendRequestsLiteral(ScrowMessageStyle style) {
|
private CompletableFuture<Result<Object, String>> displayFriendRequests(CommandContext<Player> ctx) {
|
||||||
this.style = style;
|
|
||||||
literal = Literal.literal("requests");
|
|
||||||
literal.setExecutor(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompletableFuture<Result<Object, String>> execute(CommandContext<CommandSender> ctx) {
|
|
||||||
var sender = (Player) ctx.getSender();
|
|
||||||
return Tasks.supplyAsync(() ->
|
return Tasks.supplyAsync(() ->
|
||||||
ScrowAPI.getFriendRequestService().getFriendRequestsTo(sender.getUniqueId()))
|
ScrowAPI.getFriendRequestService().getFriendRequestsTo(ctx.getSender().getUniqueId()))
|
||||||
.<Result<Object, String>>mapAsync(list -> {
|
.<Result<Object, String>>mapAsync(list -> {
|
||||||
if (list.isEmpty()) return Results.failure("You have no friend requests.");
|
if (list.isEmpty()) return Results.failure("You have no friend requests.");
|
||||||
var requesters = list.stream().sorted(this::compareByAge).map(fr -> Bukkit.getOfflinePlayer(fr.getFrom()).getName());
|
var requesters = list.stream().sorted(this::compareByAge).map(fr -> Bukkit.getOfflinePlayer(fr.getFrom()).getName());
|
||||||
|
|
||||||
sender.sendMessage(formatList(requesters.toList()));
|
ctx.getSender().sendMessage(formatList(requesters.toList()));
|
||||||
return Results.success(new Object());
|
return Results.success(new Object());
|
||||||
}).toFuture();
|
}).toFuture();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,10 @@ import org.bukkit.command.CommandSender;
|
||||||
public class InstanceCommand {
|
public class InstanceCommand {
|
||||||
public static RootLiteral<CommandSender> create(InstanceCache instanceCache) {
|
public static RootLiteral<CommandSender> create(InstanceCache instanceCache) {
|
||||||
var style = new ScrowMessageStyle("server-manager", NamedTextColor.RED);
|
var style = new ScrowMessageStyle("server-manager", NamedTextColor.RED);
|
||||||
RootLiteral<CommandSender> rootLiteral = Literal.rootLiteral(style, "instance", "server-manager");
|
return Literal.<CommandSender>builder("instance", "server-manager")
|
||||||
rootLiteral.addLiteral(new InstanceListLiteral(style).getNode());
|
.withLiteral(new InstanceListLiteral(style).getLiteral())
|
||||||
rootLiteral.addLiteral(new InstanceDeployLiteral(style).getLiteral());
|
.withLiteral(new InstanceDeployLiteral(style).getLiteral())
|
||||||
rootLiteral.addLiteral(new InstanceDestroyLiteral(instanceCache, style).getLiteral());
|
.withLiteral(new InstanceDestroyLiteral(instanceCache, style).getLiteral())
|
||||||
return rootLiteral;
|
.asRootLiteral(style);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,9 @@ package de.kentoj.scrow.bukkit.command.instance;
|
||||||
|
|
||||||
import com.leakyabstractions.result.api.Result;
|
import com.leakyabstractions.result.api.Result;
|
||||||
import com.leakyabstractions.result.core.Results;
|
import com.leakyabstractions.result.core.Results;
|
||||||
import de.kentoj.kencommandapi.api.argument.CommandArgument;
|
import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec;
|
||||||
import de.kentoj.kencommandapi.api.argument.types.StringArgumentType;
|
import de.kentoj.kencommandapi.api.argument.types.StringArgumentType;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandExecutor;
|
|
||||||
import de.kentoj.kencommandapi.api.literal.Literal;
|
import de.kentoj.kencommandapi.api.literal.Literal;
|
||||||
import de.kentoj.scrow.bukkit.ScrowAPI;
|
import de.kentoj.scrow.bukkit.ScrowAPI;
|
||||||
import de.kentoj.scrow.bukkit.scheduler.Tasks;
|
import de.kentoj.scrow.bukkit.scheduler.Tasks;
|
||||||
|
|
@ -15,25 +14,25 @@ import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class InstanceDeployLiteral implements CommandExecutor<CommandSender> {
|
public class InstanceDeployLiteral {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Literal<CommandSender> literal;
|
private final Literal<CommandSender> literal;
|
||||||
private final CommandArgument<CommandSender, String> templateArg;
|
private final CommandArgumentSpec<CommandSender, String> templateArg;
|
||||||
private final ScrowMessageStyle style;
|
private final ScrowMessageStyle style;
|
||||||
|
|
||||||
public InstanceDeployLiteral(ScrowMessageStyle style) {
|
InstanceDeployLiteral(ScrowMessageStyle style) {
|
||||||
this.style = style;
|
this.style = style;
|
||||||
|
|
||||||
templateArg = CommandArgument.arg("template", new StringArgumentType<>());
|
templateArg = CommandArgumentSpec.builder("template", new StringArgumentType<CommandSender>())
|
||||||
|
.build();
|
||||||
literal = Literal.literal("deploy");
|
literal = Literal.<CommandSender>builder("deploy")
|
||||||
literal.addArgument(templateArg);
|
.withArgument(templateArg)
|
||||||
literal.setExecutor(this);
|
.withExecutor(this::deployInstance)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private CompletableFuture<Result<Object, String>> deployInstance(CommandContext<CommandSender> ctx) {
|
||||||
public CompletableFuture<Result<Object, String>> execute(CommandContext<CommandSender> ctx) {
|
|
||||||
var template = ctx.getArg(templateArg);
|
var template = ctx.getArg(templateArg);
|
||||||
ctx.getSender().sendMessage(style.ok("Deploying instance... this may take a while."));
|
ctx.getSender().sendMessage(style.ok("Deploying instance... this may take a while."));
|
||||||
return Tasks.supplyAsync(() ->
|
return Tasks.supplyAsync(() ->
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,9 @@ package de.kentoj.scrow.bukkit.command.instance;
|
||||||
|
|
||||||
import com.leakyabstractions.result.api.Result;
|
import com.leakyabstractions.result.api.Result;
|
||||||
import com.leakyabstractions.result.core.Results;
|
import com.leakyabstractions.result.core.Results;
|
||||||
import de.kentoj.kencommandapi.api.argument.CommandArgument;
|
import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec;
|
||||||
import de.kentoj.kencommandapi.api.argument.types.StringArgumentType;
|
import de.kentoj.kencommandapi.api.argument.types.StringArgumentType;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandExecutor;
|
|
||||||
import de.kentoj.kencommandapi.api.literal.Literal;
|
import de.kentoj.kencommandapi.api.literal.Literal;
|
||||||
import de.kentoj.scrow.bukkit.ScrowAPI;
|
import de.kentoj.scrow.bukkit.ScrowAPI;
|
||||||
import de.kentoj.scrow.bukkit.scheduler.Tasks;
|
import de.kentoj.scrow.bukkit.scheduler.Tasks;
|
||||||
|
|
@ -16,27 +15,29 @@ import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class InstanceDestroyLiteral implements CommandExecutor<CommandSender> {
|
public class InstanceDestroyLiteral {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Literal<CommandSender> literal;
|
private final Literal<CommandSender> literal;
|
||||||
private final CommandArgument<CommandSender, String> handleArg;
|
private final CommandArgumentSpec<CommandSender, String> handleArg;
|
||||||
private final ScrowMessageStyle style;
|
private final ScrowMessageStyle style;
|
||||||
|
|
||||||
public InstanceDestroyLiteral(InstanceCache cache, ScrowMessageStyle style) {
|
InstanceDestroyLiteral(InstanceCache cache, ScrowMessageStyle style) {
|
||||||
this.style = style;
|
this.style = style;
|
||||||
|
|
||||||
handleArg = CommandArgument.arg("handle", new StringArgumentType<>());
|
handleArg = CommandArgumentSpec.builder("handle", new StringArgumentType<CommandSender>())
|
||||||
handleArg.setSuggestionProvider(ctx -> cache.getInstances().stream()
|
.withSuggestionProvider(_ ->
|
||||||
.map(ServerInstance::getHandle)
|
cache.getInstances().stream()
|
||||||
.toList());
|
.map(ServerInstance::getHandle)
|
||||||
literal = Literal.literal("destroy");
|
.toList())
|
||||||
literal.addArgument(handleArg);
|
.build();
|
||||||
literal.setExecutor(this);
|
literal = Literal.<CommandSender>builder("destroy")
|
||||||
|
.withArgument(handleArg)
|
||||||
|
.withExecutor(this::destroyInstance)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private CompletableFuture<Result<Object, String>> destroyInstance(CommandContext<CommandSender> ctx) {
|
||||||
public CompletableFuture<Result<Object, String>> execute(CommandContext<CommandSender> ctx) {
|
|
||||||
var handle = ctx.getArg(handleArg);
|
var handle = ctx.getArg(handleArg);
|
||||||
return Tasks.supplyAsync(() -> ScrowAPI.getInstanceManager().destroyInstance(handle))
|
return Tasks.supplyAsync(() -> ScrowAPI.getInstanceManager().destroyInstance(handle))
|
||||||
.<Result<Object, String>>mapSync(found -> {
|
.<Result<Object, String>>mapSync(found -> {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ package de.kentoj.scrow.bukkit.command.instance;
|
||||||
import com.leakyabstractions.result.api.Result;
|
import com.leakyabstractions.result.api.Result;
|
||||||
import com.leakyabstractions.result.core.Results;
|
import com.leakyabstractions.result.core.Results;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandExecutor;
|
|
||||||
import de.kentoj.kencommandapi.api.literal.Literal;
|
import de.kentoj.kencommandapi.api.literal.Literal;
|
||||||
import de.kentoj.scrow.bukkit.ScrowAPI;
|
import de.kentoj.scrow.bukkit.ScrowAPI;
|
||||||
import de.kentoj.scrow.bukkit.scheduler.Tasks;
|
import de.kentoj.scrow.bukkit.scheduler.Tasks;
|
||||||
|
|
@ -14,20 +13,20 @@ import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class InstanceListLiteral implements CommandExecutor<CommandSender> {
|
public class InstanceListLiteral {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Literal<CommandSender> node;
|
private final Literal<CommandSender> literal;
|
||||||
private final ScrowMessageStyle style;
|
private final ScrowMessageStyle style;
|
||||||
|
|
||||||
public InstanceListLiteral(ScrowMessageStyle style) {
|
InstanceListLiteral(ScrowMessageStyle style) {
|
||||||
this.style = style;
|
this.style = style;
|
||||||
this.node = Literal.literal("list");
|
this.literal = Literal.<CommandSender>builder("list")
|
||||||
this.node.setExecutor(this);
|
.withExecutor(this::displayInstanceList)
|
||||||
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private CompletableFuture<Result<Object, String>> displayInstanceList(CommandContext<CommandSender> ctx) {
|
||||||
public CompletableFuture<Result<Object, String>> execute(CommandContext<CommandSender> ctx) {
|
|
||||||
return Tasks.supplyAsync(() ->
|
return Tasks.supplyAsync(() ->
|
||||||
ScrowAPI.getInstanceManager().getInstances())
|
ScrowAPI.getInstanceManager().getInstances())
|
||||||
.<Result<Object, String>>mapSync(instances -> {
|
.<Result<Object, String>>mapSync(instances -> {
|
||||||
|
|
|
||||||
|
|
@ -3,26 +3,22 @@ package de.kentoj.scrow.bukkit.command.instance;
|
||||||
import com.leakyabstractions.result.api.Result;
|
import com.leakyabstractions.result.api.Result;
|
||||||
import com.leakyabstractions.result.core.Results;
|
import com.leakyabstractions.result.core.Results;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
||||||
import de.kentoj.kencommandapi.api.invocation.SyncCommandExecutor;
|
|
||||||
import de.kentoj.kencommandapi.api.literal.Literal;
|
import de.kentoj.kencommandapi.api.literal.Literal;
|
||||||
import de.kentoj.kencommandapi.api.literal.RootLiteral;
|
import de.kentoj.kencommandapi.api.literal.RootLiteral;
|
||||||
import de.kentoj.kencommandapi.api.platform.MessageStyle;
|
import de.kentoj.scrowlib.convention.ScrowMessageStyle;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class LobbyCommand implements SyncCommandExecutor<CommandSender> {
|
public class LobbyCommand {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final RootLiteral<CommandSender> rootLiteral;
|
private final RootLiteral<Player> rootLiteral = Literal.<Player>builder("lobby", "l", "hub")
|
||||||
|
.withSyncExecutor(this::sendToLobby)
|
||||||
|
.asRootLiteral(ScrowMessageStyle.GENERIC);
|
||||||
|
|
||||||
public LobbyCommand() {
|
private Result<Object, String> sendToLobby(CommandContext<Player> ctx) {
|
||||||
this.rootLiteral = Literal.rootLiteral(MessageStyle.PLAIN, "lobby", "l", "hub");
|
|
||||||
this.rootLiteral.setExecutor(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Result<Object, String> executeSync(CommandContext<CommandSender> ctx) {
|
|
||||||
Bukkit.dispatchCommand(ctx.getSender(), "play lobby");
|
Bukkit.dispatchCommand(ctx.getSender(), "play lobby");
|
||||||
return Results.success(new Object());
|
return Results.success(new Object());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ package de.kentoj.scrow.bukkit.command.instance;
|
||||||
|
|
||||||
import com.leakyabstractions.result.api.Result;
|
import com.leakyabstractions.result.api.Result;
|
||||||
import com.leakyabstractions.result.core.Results;
|
import com.leakyabstractions.result.core.Results;
|
||||||
import de.kentoj.kencommandapi.api.argument.CommandArgument;
|
import de.kentoj.kencommandapi.api.argument.CommandArgumentSpec;
|
||||||
import de.kentoj.kencommandapi.api.argument.types.StringArgumentType;
|
import de.kentoj.kencommandapi.api.argument.types.StringArgumentType;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
import de.kentoj.kencommandapi.api.invocation.CommandContext;
|
||||||
import de.kentoj.kencommandapi.api.invocation.CommandExecutor;
|
import de.kentoj.kencommandapi.api.invocation.CommandExecutor;
|
||||||
|
|
@ -17,26 +17,23 @@ import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
public class PlayCommand implements CommandExecutor<CommandSender> {
|
public class PlayCommand {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final RootLiteral<CommandSender> rootLiteral;
|
private final RootLiteral<Player> rootLiteral;
|
||||||
private final CommandArgument<CommandSender, String> gamemodeArg;
|
private final CommandArgumentSpec<Player, String> gamemodeArg;
|
||||||
|
|
||||||
public PlayCommand() {
|
public PlayCommand() {
|
||||||
var style = ScrowMessageStyle.GENERIC;
|
var style = ScrowMessageStyle.GENERIC;
|
||||||
|
gamemodeArg = CommandArgumentSpec.builder("gamemode", new StringArgumentType<Player>()).build();
|
||||||
gamemodeArg = CommandArgument.arg("gamemode", new StringArgumentType<>());
|
rootLiteral = Literal.<Player>builder("play", "queue")
|
||||||
|
.withArgument(gamemodeArg)
|
||||||
rootLiteral = Literal.rootLiteral(style, "play", "queue");
|
.withExecutor(this::execute)
|
||||||
rootLiteral.addArgument(this.gamemodeArg);
|
.asRootLiteral(style);
|
||||||
rootLiteral.setExecutor(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private CompletableFuture<Result<Object, String>> execute(CommandContext<Player> ctx) {
|
||||||
public CompletableFuture<Result<Object, String>> execute(CommandContext<CommandSender> ctx) {
|
|
||||||
var gamemode = ctx.getArg(gamemodeArg);
|
var gamemode = ctx.getArg(gamemodeArg);
|
||||||
var player = (Player) ctx.getSender();
|
|
||||||
return Tasks.supplyAsync(() -> ScrowAPI.getInstanceManager().getInstances())
|
return Tasks.supplyAsync(() -> ScrowAPI.getInstanceManager().getInstances())
|
||||||
.mapAsync(instances -> {
|
.mapAsync(instances -> {
|
||||||
var instance = instances.stream()
|
var instance = instances.stream()
|
||||||
|
|
@ -47,7 +44,7 @@ public class PlayCommand implements CommandExecutor<CommandSender> {
|
||||||
return Results.failure("No instance for " + gamemode + " found.");
|
return Results.failure("No instance for " + gamemode + " found.");
|
||||||
|
|
||||||
return Results.ofCallable(() -> {
|
return Results.ofCallable(() -> {
|
||||||
ScrowAPI.getPlayer(player).sendToInstance(instance.getHandle());
|
ScrowAPI.getPlayer(ctx.getSender()).sendToInstance(instance.getHandle());
|
||||||
return new Object();
|
return new Object();
|
||||||
}).mapFailure(Exception::getMessage);
|
}).mapFailure(Exception::getMessage);
|
||||||
}).toFuture();
|
}).toFuture();
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
name: "CoreBukkit"
|
name: "CoreBukkit"
|
||||||
version: "${version}"
|
version: "${version}"
|
||||||
|
depend: [ "LuckPerms" ]
|
||||||
main: "de.kentoj.scrow.bukkit.CoreImplPlugin"
|
main: "de.kentoj.scrow.bukkit.CoreImplPlugin"
|
||||||
api-version: "1.21"
|
api-version: "1.21"
|
||||||
author: "Kento2"
|
author: "Kento2"
|
||||||
23
core-lib/BUILD
Normal file
23
core-lib/BUILD
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
load("@rules_jvm_external//:defs.bzl", "artifact")
|
||||||
|
load("@rules_java//java:java_library.bzl", "java_library")
|
||||||
|
|
||||||
|
shared_deps = [
|
||||||
|
"//third_party:common_deps",
|
||||||
|
artifact("de.kentoj.scrow:kencommandapi-core"),
|
||||||
|
artifact("net.kyori:adventure-api"),
|
||||||
|
artifact("net.kyori:adventure-text-minimessage"),
|
||||||
|
artifact("org.jdbi:jdbi3-core"),
|
||||||
|
artifact("org.mongodb:bson"),
|
||||||
|
]
|
||||||
|
|
||||||
|
java_library(
|
||||||
|
name = "core",
|
||||||
|
srcs = glob(["src/main/**/*.java"]),
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
deps = shared_deps + [
|
||||||
|
artifact("org.jdbi:jdbi3-postgres"),
|
||||||
|
artifact("io.nats:jnats"),
|
||||||
|
],
|
||||||
|
exports = shared_deps,
|
||||||
|
plugins = [ "//third_party:lombok_plugin" ],
|
||||||
|
)
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
package de.kentoj.scrowlib.instancemanager;
|
package de.kentoj.scrowlib.instancemanager;
|
||||||
|
|
||||||
import org.jspecify.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -14,12 +14,14 @@ public interface InstanceManager {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs blocking.
|
* Runs blocking.
|
||||||
|
*
|
||||||
* @return if the instance was found
|
* @return if the instance was found
|
||||||
*/
|
*/
|
||||||
boolean destroyInstance(String handle);
|
boolean destroyInstance(String handle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs blocking.
|
* Runs blocking.
|
||||||
|
*
|
||||||
* @return list of running instances
|
* @return list of running instances
|
||||||
*/
|
*/
|
||||||
List<ServerInstance> getInstances();
|
List<ServerInstance> getInstances();
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import de.kentoj.scrowlib.messaging.MessageBroker;
|
||||||
import de.kentoj.scrowlib.messaging.RemoteException;
|
import de.kentoj.scrowlib.messaging.RemoteException;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.jspecify.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,6 @@ import org.bson.Document;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
|
|
||||||
@FunctionalInterface
|
|
||||||
public interface SyncRequestHandler extends RequestHandler {
|
public interface SyncRequestHandler extends RequestHandler {
|
||||||
Document handleSync(Document doc);
|
Document handleSync(Document doc);
|
||||||
|
|
||||||
|
|
|
||||||
20
core-velocity-api/BUILD
Normal file
20
core-velocity-api/BUILD
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
load("@rules_jvm_external//:defs.bzl", "artifact")
|
||||||
|
load("@rules_java//java:java_library.bzl", "java_library")
|
||||||
|
|
||||||
|
java_library(
|
||||||
|
name = "core-velocity-api",
|
||||||
|
srcs = glob(["src/main/**/*.java"]),
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
deps = [
|
||||||
|
"//core-lib:core",
|
||||||
|
artifact("com.velocitypowered:velocity-api"),
|
||||||
|
artifact("org.projectlombok:lombok"),
|
||||||
|
artifact("de.kentoj.scrow:kencommandapi-velocity"),
|
||||||
|
],
|
||||||
|
exports = [
|
||||||
|
"//core-lib:core",
|
||||||
|
artifact("de.kentoj.scrow:kencommandapi-velocity"),
|
||||||
|
artifact("org.mongodb:bson"),
|
||||||
|
],
|
||||||
|
plugins = [ "//third_party:lombok_plugin" ],
|
||||||
|
)
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package de.kentoj.scrow.velocity;
|
package de.kentoj.scrow.velocity;
|
||||||
|
|
||||||
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import de.kentoj.kencommandapi.CommandAPI;
|
import de.kentoj.kencommandapi.CommandAPI;
|
||||||
import de.kentoj.scrowlib.instancemanager.InstanceManager;
|
import de.kentoj.scrowlib.instancemanager.InstanceManager;
|
||||||
|
|
@ -20,7 +21,9 @@ public class ScrowAPI {
|
||||||
@Getter
|
@Getter
|
||||||
private static Jdbi jdbi;
|
private static Jdbi jdbi;
|
||||||
@Getter
|
@Getter
|
||||||
private static CommandAPI commandApi;
|
private static CommandAPI<CommandSource> commands;
|
||||||
|
@Getter
|
||||||
|
private static CommandAPI<Player> playerCommands;
|
||||||
@Getter
|
@Getter
|
||||||
private static MessageBroker messageBroker;
|
private static MessageBroker messageBroker;
|
||||||
@Getter
|
@Getter
|
||||||
|
|
@ -35,12 +38,6 @@ public class ScrowAPI {
|
||||||
return playerFactory.create(uuid);
|
return playerFactory.create(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiStatus.Internal
|
|
||||||
public static void setCommandApi(CommandAPI commandApi) {
|
|
||||||
ScrowAPI.commandApi = commandApi;
|
|
||||||
}
|
|
||||||
|
|
||||||
@ApiStatus.Internal
|
@ApiStatus.Internal
|
||||||
public static void setMessageBroker(MessageBroker messageBroker) {
|
public static void setMessageBroker(MessageBroker messageBroker) {
|
||||||
ScrowAPI.messageBroker = messageBroker;
|
ScrowAPI.messageBroker = messageBroker;
|
||||||
|
|
@ -60,5 +57,15 @@ public class ScrowAPI {
|
||||||
public static void setPlayerFactory(NetworkPlayerFactory playerFactory) {
|
public static void setPlayerFactory(NetworkPlayerFactory playerFactory) {
|
||||||
ScrowAPI.playerFactory = playerFactory;
|
ScrowAPI.playerFactory = playerFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
|
public static void setPlayerCommands(CommandAPI<Player> playerCommands) {
|
||||||
|
ScrowAPI.playerCommands = playerCommands;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiStatus.Internal
|
||||||
|
public static void setCommands(CommandAPI<CommandSource> commands) {
|
||||||
|
ScrowAPI.commands = commands;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
15
core-velocity-impl/BUILD
Normal file
15
core-velocity-impl/BUILD
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
load("@rules_java//java:java_binary.bzl", "java_binary")
|
||||||
|
load("@rules_jvm_external//:defs.bzl", "artifact")
|
||||||
|
|
||||||
|
java_binary(
|
||||||
|
name = "core-velocity-impl",
|
||||||
|
srcs = glob(["src/main/**/*.java"]),
|
||||||
|
main_class = "none",
|
||||||
|
resources = glob(["src/main/resources/**"], allow_empty = True),
|
||||||
|
deps = [
|
||||||
|
"//core-velocity-api",
|
||||||
|
artifact("com.velocitypowered:velocity-api"),
|
||||||
|
artifact("io.nats:jnats"),
|
||||||
|
],
|
||||||
|
plugins = [ "//third_party:lombok_plugin" ],
|
||||||
|
)
|
||||||
|
|
@ -1,41 +0,0 @@
|
||||||
[versions]
|
|
||||||
shadow = "9.2.0"
|
|
||||||
scrow-commandapi = "0.33-SNAPSHOT"
|
|
||||||
postgress = "42.7.12"
|
|
||||||
nats = "2.25.2"
|
|
||||||
papermc = "1.21.11-rc3-R0.1-SNAPSHOT"
|
|
||||||
velocity = "3.5.0-SNAPSHOT"
|
|
||||||
bson = "5.8.0"
|
|
||||||
adventure = "5.2.0"
|
|
||||||
luckperms = "5.5"
|
|
||||||
|
|
||||||
[plugins]
|
|
||||||
shadow = { id = "com.gradleup.shadow", version.ref = "shadow" }
|
|
||||||
scrow-basedependencies = { id = "scrow.base-dependencies" }
|
|
||||||
scrow-javalibrary = { id = "scrow.java-library" }
|
|
||||||
scrow-database = { id = "scrow.database" }
|
|
||||||
scrow-publish = { id = "scrow.scrow-publish" }
|
|
||||||
scrow-runserver = { id = "scrow.run-server" }
|
|
||||||
|
|
||||||
[libraries]
|
|
||||||
# https://mvnrepository.com/artifact/org.postgresql/postgresql
|
|
||||||
postgres = { module = "org.postgresql:postgresql", version.ref = "postgress" }
|
|
||||||
# https://mvnrepository.com/artifact/org.mongodb/bson
|
|
||||||
bson = { module = "org.mongodb:bson", version.ref = "bson" }
|
|
||||||
# https://mvnrepository.com/artifact/io.nats/jnats
|
|
||||||
nats = { module = "io.nats:jnats", version.ref = "nats" }
|
|
||||||
# https://docs.papermc.io/paper/dev/project-setup/
|
|
||||||
papermc-api = { module = "io.papermc.paper:paper-api", version.ref = "papermc" }
|
|
||||||
# https://docs.papermc.io/velocity/dev/creating-your-first-plugin/
|
|
||||||
velocity-api = { module = "com.velocitypowered:velocity-api", version.ref = "velocity" }
|
|
||||||
adventure-api = { module = "net.kyori:adventure-api", version.ref = "adventure" }
|
|
||||||
adventure-minimessage = { module = "net.kyori:adventure-text-minimessage", version.ref = "adventure" }
|
|
||||||
# https://luckperms.net/wiki/Developer-API
|
|
||||||
luckperms = { module = "net.luckperms:api", version.ref = "luckperms" }
|
|
||||||
|
|
||||||
# http://forge.kentoj.de/scrow/-/packages/maven/de.kentoj.scrow:kencommandapi-core
|
|
||||||
scrow-commandapi-core = { module = "de.kentoj.scrow:kencommandapi-core", version.ref = "scrow-commandapi" }
|
|
||||||
# http://forge.kentoj.de/scrow/-/packages/maven/de.kentoj.scrow:kencommandapi-bukkit
|
|
||||||
scrow-commandapi-bukkit = { module = "de.kentoj.scrow:kencommandapi-bukkit", version.ref = "scrow-commandapi" }
|
|
||||||
# http://forge.kentoj.de/scrow/-/packages/maven/de.kentoj.scrow:kencommandapi-velocity
|
|
||||||
scrow-commandapi-velocity = { module = "de.kentoj.scrow:kencommandapi-velocity", version.ref = "scrow-commandapi" }
|
|
||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
7
gradle/wrapper/gradle-wrapper.properties
vendored
7
gradle/wrapper/gradle-wrapper.properties
vendored
|
|
@ -1,7 +0,0 @@
|
||||||
distributionBase=GRADLE_USER_HOME
|
|
||||||
distributionPath=wrapper/dists
|
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11-bin.zip
|
|
||||||
networkTimeout=10000
|
|
||||||
validateDistributionUrl=true
|
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
|
||||||
zipStorePath=wrapper/dists
|
|
||||||
252
gradlew
vendored
252
gradlew
vendored
|
|
@ -1,252 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
#
|
|
||||||
# Copyright © 2015-2021 the original authors.
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
# SPDX-License-Identifier: Apache-2.0
|
|
||||||
#
|
|
||||||
|
|
||||||
##############################################################################
|
|
||||||
#
|
|
||||||
# Gradle start up script for POSIX generated by Gradle.
|
|
||||||
#
|
|
||||||
# Important for running:
|
|
||||||
#
|
|
||||||
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
|
|
||||||
# noncompliant, but you have some other compliant shell such as ksh or
|
|
||||||
# bash, then to run this script, type that shell name before the whole
|
|
||||||
# command line, like:
|
|
||||||
#
|
|
||||||
# ksh Gradle
|
|
||||||
#
|
|
||||||
# Busybox and similar reduced shells will NOT work, because this script
|
|
||||||
# requires all of these POSIX shell features:
|
|
||||||
# * functions;
|
|
||||||
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
|
|
||||||
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
|
|
||||||
# * compound commands having a testable exit status, especially «case»;
|
|
||||||
# * various built-in commands including «command», «set», and «ulimit».
|
|
||||||
#
|
|
||||||
# Important for patching:
|
|
||||||
#
|
|
||||||
# (2) This script targets any POSIX shell, so it avoids extensions provided
|
|
||||||
# by Bash, Ksh, etc; in particular arrays are avoided.
|
|
||||||
#
|
|
||||||
# The "traditional" practice of packing multiple parameters into a
|
|
||||||
# space-separated string is a well documented source of bugs and security
|
|
||||||
# problems, so this is (mostly) avoided, by progressively accumulating
|
|
||||||
# options in "$@", and eventually passing that to Java.
|
|
||||||
#
|
|
||||||
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
|
|
||||||
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
|
|
||||||
# see the in-line comments for details.
|
|
||||||
#
|
|
||||||
# There are tweaks for specific operating systems such as AIX, CygWin,
|
|
||||||
# Darwin, MinGW, and NonStop.
|
|
||||||
#
|
|
||||||
# (3) This script is generated from the Groovy template
|
|
||||||
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
|
||||||
# within the Gradle project.
|
|
||||||
#
|
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
|
||||||
#
|
|
||||||
##############################################################################
|
|
||||||
|
|
||||||
# Attempt to set APP_HOME
|
|
||||||
|
|
||||||
# Resolve links: $0 may be a link
|
|
||||||
app_path=$0
|
|
||||||
|
|
||||||
# Need this for daisy-chained symlinks.
|
|
||||||
while
|
|
||||||
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
|
|
||||||
[ -h "$app_path" ]
|
|
||||||
do
|
|
||||||
ls=$( ls -ld "$app_path" )
|
|
||||||
link=${ls#*' -> '}
|
|
||||||
case $link in #(
|
|
||||||
/*) app_path=$link ;; #(
|
|
||||||
*) app_path=$APP_HOME$link ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# This is normally unused
|
|
||||||
# shellcheck disable=SC2034
|
|
||||||
APP_BASE_NAME=${0##*/}
|
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
|
||||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
|
||||||
' "$PWD" ) || exit
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
|
||||||
MAX_FD=maximum
|
|
||||||
|
|
||||||
warn () {
|
|
||||||
echo "$*"
|
|
||||||
} >&2
|
|
||||||
|
|
||||||
die () {
|
|
||||||
echo
|
|
||||||
echo "$*"
|
|
||||||
echo
|
|
||||||
exit 1
|
|
||||||
} >&2
|
|
||||||
|
|
||||||
# OS specific support (must be 'true' or 'false').
|
|
||||||
cygwin=false
|
|
||||||
msys=false
|
|
||||||
darwin=false
|
|
||||||
nonstop=false
|
|
||||||
case "$( uname )" in #(
|
|
||||||
CYGWIN* ) cygwin=true ;; #(
|
|
||||||
Darwin* ) darwin=true ;; #(
|
|
||||||
MSYS* | MINGW* ) msys=true ;; #(
|
|
||||||
NONSTOP* ) nonstop=true ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
|
||||||
if [ -n "$JAVA_HOME" ] ; then
|
|
||||||
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
|
|
||||||
# IBM's JDK on AIX uses strange locations for the executables
|
|
||||||
JAVACMD=$JAVA_HOME/jre/sh/java
|
|
||||||
else
|
|
||||||
JAVACMD=$JAVA_HOME/bin/java
|
|
||||||
fi
|
|
||||||
if [ ! -x "$JAVACMD" ] ; then
|
|
||||||
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
location of your Java installation."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
JAVACMD=java
|
|
||||||
if ! command -v java >/dev/null 2>&1
|
|
||||||
then
|
|
||||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
|
||||||
|
|
||||||
Please set the JAVA_HOME variable in your environment to match the
|
|
||||||
location of your Java installation."
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Increase the maximum file descriptors if we can.
|
|
||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
|
||||||
case $MAX_FD in #(
|
|
||||||
max*)
|
|
||||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
|
||||||
# shellcheck disable=SC2039,SC3045
|
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
|
||||||
warn "Could not query maximum file descriptor limit"
|
|
||||||
esac
|
|
||||||
case $MAX_FD in #(
|
|
||||||
'' | soft) :;; #(
|
|
||||||
*)
|
|
||||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
|
||||||
# shellcheck disable=SC2039,SC3045
|
|
||||||
ulimit -n "$MAX_FD" ||
|
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Collect all arguments for the java command, stacking in reverse order:
|
|
||||||
# * args from the command line
|
|
||||||
# * the main class name
|
|
||||||
# * -classpath
|
|
||||||
# * -D...appname settings
|
|
||||||
# * --module-path (only if needed)
|
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
|
|
||||||
|
|
||||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
|
||||||
if "$cygwin" || "$msys" ; then
|
|
||||||
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
|
|
||||||
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
|
|
||||||
|
|
||||||
JAVACMD=$( cygpath --unix "$JAVACMD" )
|
|
||||||
|
|
||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
|
||||||
for arg do
|
|
||||||
if
|
|
||||||
case $arg in #(
|
|
||||||
-*) false ;; # don't mess with options #(
|
|
||||||
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
|
|
||||||
[ -e "$t" ] ;; #(
|
|
||||||
*) false ;;
|
|
||||||
esac
|
|
||||||
then
|
|
||||||
arg=$( cygpath --path --ignore --mixed "$arg" )
|
|
||||||
fi
|
|
||||||
# Roll the args list around exactly as many times as the number of
|
|
||||||
# args, so each arg winds up back in the position where it started, but
|
|
||||||
# possibly modified.
|
|
||||||
#
|
|
||||||
# NB: a `for` loop captures its iteration list before it begins, so
|
|
||||||
# changing the positional parameters here affects neither the number of
|
|
||||||
# iterations, nor the values presented in `arg`.
|
|
||||||
shift # remove old arg
|
|
||||||
set -- "$@" "$arg" # push replacement arg
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|
||||||
|
|
||||||
# Collect all arguments for the java command:
|
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
|
||||||
# and any embedded shellness will be escaped.
|
|
||||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
|
||||||
# treated as '${Hostname}' itself on the command line.
|
|
||||||
|
|
||||||
set -- \
|
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
|
||||||
-classpath "$CLASSPATH" \
|
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
|
||||||
"$@"
|
|
||||||
|
|
||||||
# Stop when "xargs" is not available.
|
|
||||||
if ! command -v xargs >/dev/null 2>&1
|
|
||||||
then
|
|
||||||
die "xargs is not available"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Use "xargs" to parse quoted args.
|
|
||||||
#
|
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
|
||||||
#
|
|
||||||
# In Bash we could simply go:
|
|
||||||
#
|
|
||||||
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
|
|
||||||
# set -- "${ARGS[@]}" "$@"
|
|
||||||
#
|
|
||||||
# but POSIX shell has neither arrays nor command substitution, so instead we
|
|
||||||
# post-process each arg (as a line of input to sed) to backslash-escape any
|
|
||||||
# character that might be a shell metacharacter, then use eval to reverse
|
|
||||||
# that process (while maintaining the separation between arguments), and wrap
|
|
||||||
# the whole thing up as a single "set" statement.
|
|
||||||
#
|
|
||||||
# This will of course break if any of these variables contains a newline or
|
|
||||||
# an unmatched quote.
|
|
||||||
#
|
|
||||||
|
|
||||||
eval "set -- $(
|
|
||||||
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
|
|
||||||
xargs -n1 |
|
|
||||||
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
|
|
||||||
tr '\n' ' '
|
|
||||||
)" '"$@"'
|
|
||||||
|
|
||||||
exec "$JAVACMD" "$@"
|
|
||||||
94
gradlew.bat
vendored
94
gradlew.bat
vendored
|
|
@ -1,94 +0,0 @@
|
||||||
@rem
|
|
||||||
@rem Copyright 2015 the original author or authors.
|
|
||||||
@rem
|
|
||||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
@rem you may not use this file except in compliance with the License.
|
|
||||||
@rem You may obtain a copy of the License at
|
|
||||||
@rem
|
|
||||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
@rem
|
|
||||||
@rem Unless required by applicable law or agreed to in writing, software
|
|
||||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
@rem See the License for the specific language governing permissions and
|
|
||||||
@rem limitations under the License.
|
|
||||||
@rem
|
|
||||||
@rem SPDX-License-Identifier: Apache-2.0
|
|
||||||
@rem
|
|
||||||
|
|
||||||
@if "%DEBUG%"=="" @echo off
|
|
||||||
@rem ##########################################################################
|
|
||||||
@rem
|
|
||||||
@rem Gradle startup script for Windows
|
|
||||||
@rem
|
|
||||||
@rem ##########################################################################
|
|
||||||
|
|
||||||
@rem Set local scope for the variables with windows NT shell
|
|
||||||
if "%OS%"=="Windows_NT" setlocal
|
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
|
||||||
if "%DIRNAME%"=="" set DIRNAME=.
|
|
||||||
@rem This is normally unused
|
|
||||||
set APP_BASE_NAME=%~n0
|
|
||||||
set APP_HOME=%DIRNAME%
|
|
||||||
|
|
||||||
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
|
|
||||||
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
|
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
|
||||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
|
||||||
|
|
||||||
@rem Find java.exe
|
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
|
||||||
|
|
||||||
set JAVA_EXE=java.exe
|
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
|
||||||
if %ERRORLEVEL% equ 0 goto execute
|
|
||||||
|
|
||||||
echo. 1>&2
|
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
|
|
||||||
echo. 1>&2
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
|
||||||
echo location of your Java installation. 1>&2
|
|
||||||
|
|
||||||
goto fail
|
|
||||||
|
|
||||||
:findJavaFromJavaHome
|
|
||||||
set JAVA_HOME=%JAVA_HOME:"=%
|
|
||||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
|
||||||
|
|
||||||
if exist "%JAVA_EXE%" goto execute
|
|
||||||
|
|
||||||
echo. 1>&2
|
|
||||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
|
|
||||||
echo. 1>&2
|
|
||||||
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
|
|
||||||
echo location of your Java installation. 1>&2
|
|
||||||
|
|
||||||
goto fail
|
|
||||||
|
|
||||||
:execute
|
|
||||||
@rem Setup the command line
|
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
|
||||||
|
|
||||||
:end
|
|
||||||
@rem End local scope for the variables with windows NT shell
|
|
||||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
|
||||||
|
|
||||||
:fail
|
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
|
||||||
rem the _cmd.exe /c_ return code!
|
|
||||||
set EXIT_CODE=%ERRORLEVEL%
|
|
||||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
|
||||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
|
||||||
exit /b %EXIT_CODE%
|
|
||||||
|
|
||||||
:mainEnd
|
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
|
||||||
|
|
||||||
:omega
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
pluginManagement {
|
|
||||||
includeBuild("../build-logic")
|
|
||||||
}
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id("scrow.scrow-repository")
|
|
||||||
}
|
|
||||||
|
|
||||||
rootProject.name = "core"
|
|
||||||
|
|
||||||
include("core-bukkit-api")
|
|
||||||
include("core-bukkit-impl")
|
|
||||||
include("core-lib")
|
|
||||||
include("core-velocity-api")
|
|
||||||
include("core-velocity-impl")
|
|
||||||
22
third_party/BUILD
vendored
Normal file
22
third_party/BUILD
vendored
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
load("@rules_java//java:java_plugin.bzl", "java_plugin")
|
||||||
|
java_plugin(
|
||||||
|
name = "lombok_plugin",
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
deps = ["@maven//:org_projectlombok_lombok"],
|
||||||
|
processor_class = "lombok.launch.AnnotationProcessorHider$AnnotationProcessor",
|
||||||
|
)
|
||||||
|
|
||||||
|
load("@rules_java//java:java_library.bzl", "java_library")
|
||||||
|
load("@rules_jvm_external//:defs.bzl", "artifact")
|
||||||
|
java_library(
|
||||||
|
name = "common_deps",
|
||||||
|
exports = [
|
||||||
|
"@maven//:org_projectlombok_lombok",
|
||||||
|
"@maven//:com_leakyabstractions_result_api",
|
||||||
|
"@maven//:com_leakyabstractions_result",
|
||||||
|
"@maven//:org_jetbrains_annotations",
|
||||||
|
"@maven//:com_google_guava_guava",
|
||||||
|
"@maven//:org_slf4j_slf4j_api",
|
||||||
|
],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue