mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2025-12-21 07:49:16 +00:00
feat: Cloud commands & Folia support
This commit is contained in:
@@ -9,6 +9,7 @@ dependencies {
|
|||||||
testImplementation("com.github.seeseemelk:MockBukkit-v1.17:1.13.0")
|
testImplementation("com.github.seeseemelk:MockBukkit-v1.17:1.13.0")
|
||||||
testImplementation("org.reflections:reflections:0.10.2")
|
testImplementation("org.reflections:reflections:0.10.2")
|
||||||
|
|
||||||
|
compileOnly("org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT")
|
||||||
compileOnly("io.papermc:paperlib:1.0.4") // we include paperlib and relocate elsewhere
|
compileOnly("io.papermc:paperlib:1.0.4") // we include paperlib and relocate elsewhere
|
||||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7") // vault
|
compileOnly("com.github.MilkBowl:VaultAPI:1.7") // vault
|
||||||
compileOnly("me.clip:placeholderapi:2.10.4") // PAPI
|
compileOnly("me.clip:placeholderapi:2.10.4") // PAPI
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package net.islandearth.rpgregions.api;
|
|||||||
|
|
||||||
import com.convallyria.languagy.api.language.Translator;
|
import com.convallyria.languagy.api.language.Translator;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import net.islandearth.rpgregions.api.schedule.PlatformScheduler;
|
||||||
import net.islandearth.rpgregions.managers.IRPGRegionsManagers;
|
import net.islandearth.rpgregions.managers.IRPGRegionsManagers;
|
||||||
import org.bukkit.configuration.Configuration;
|
import org.bukkit.configuration.Configuration;
|
||||||
|
|
||||||
@@ -29,4 +30,10 @@ public interface IRPGRegionsAPI {
|
|||||||
void debug(String debug);
|
void debug(String debug);
|
||||||
|
|
||||||
boolean hasHeadDatabase();
|
boolean hasHeadDatabase();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the scheduler used for the current platform.
|
||||||
|
* @return the scheduler for this server platform
|
||||||
|
*/
|
||||||
|
PlatformScheduler<? extends IRPGRegionsAPI> getScheduler();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package net.islandearth.rpgregions.api.schedule;
|
||||||
|
|
||||||
|
import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
|
||||||
|
public abstract class PlatformScheduler<T extends IRPGRegionsAPI> {
|
||||||
|
|
||||||
|
protected final T api;
|
||||||
|
|
||||||
|
public PlatformScheduler(T api) {
|
||||||
|
this.api = api;
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract void executeOnMain(Runnable runnable);
|
||||||
|
|
||||||
|
public abstract void executeOnEntity(Entity entity, Runnable runnable);
|
||||||
|
|
||||||
|
public abstract RPGRegionsTask executeRepeating(Runnable runnable, long delay, long period);
|
||||||
|
|
||||||
|
public abstract void executeDelayed(Runnable runnable, long delay);
|
||||||
|
|
||||||
|
public abstract void executeAsync(Runnable runnable);
|
||||||
|
|
||||||
|
public abstract void registerInitTask(Runnable runnable);
|
||||||
|
|
||||||
|
@FunctionalInterface
|
||||||
|
public interface RPGRegionsTask {
|
||||||
|
void cancel();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("com.github.johnrengelman.shadow") version("7.1.2")
|
id("com.github.johnrengelman.shadow") version("8.1.1")
|
||||||
id("java")
|
id("java")
|
||||||
}
|
}
|
||||||
|
|
||||||
java.sourceCompatibility = JavaVersion.VERSION_16
|
|
||||||
java.targetCompatibility = JavaVersion.VERSION_16
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testImplementation("junit:junit:4.13.2")
|
testImplementation("junit:junit:4.13.2")
|
||||||
implementation(project(":rpgregions", "shadow"))
|
implementation(project(":rpgregions", "shadow"))
|
||||||
@@ -31,6 +28,10 @@ allprojects {
|
|||||||
apply(plugin = "com.github.johnrengelman.shadow")
|
apply(plugin = "com.github.johnrengelman.shadow")
|
||||||
apply(plugin = "java")
|
apply(plugin = "java")
|
||||||
|
|
||||||
|
java {
|
||||||
|
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||||
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
@@ -66,8 +67,7 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("com.convallyria.languagy:api:3.0.1")
|
implementation("com.convallyria.languagy:api:3.0.2")
|
||||||
compileOnly("org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks {
|
tasks {
|
||||||
@@ -99,6 +99,12 @@ allprojects {
|
|||||||
dependsOn(shadowJar)
|
dependsOn(shadowJar)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compileJava {
|
||||||
|
// Set the release flag. This configures what version bytecode the compiler will emit, as well as what JDK APIs are usable.
|
||||||
|
// See https://openjdk.java.net/jeps/247 for more information.
|
||||||
|
options.release.set(16)
|
||||||
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
filesMatching("plugin.yml") {
|
filesMatching("plugin.yml") {
|
||||||
expand("version" to project.version)
|
expand("version" to project.version)
|
||||||
|
|||||||
16
folia/build.gradle.kts
Normal file
16
folia/build.gradle.kts
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
java {
|
||||||
|
disableAutoTargetJvm()
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "papermc"
|
||||||
|
url = uri("https://repo.papermc.io/repository/maven-public/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly(project(":api"))
|
||||||
|
|
||||||
|
compileOnly("dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT")
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package net.islandearth.rpgregions.folia.schedule;
|
||||||
|
|
||||||
|
import io.papermc.paper.threadedregions.RegionizedServerInitEvent;
|
||||||
|
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||||
|
import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
||||||
|
import net.islandearth.rpgregions.api.schedule.PlatformScheduler;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class FoliaScheduler extends PlatformScheduler<IRPGRegionsAPI> implements Listener {
|
||||||
|
|
||||||
|
public static final boolean RUNNING_FOLIA;
|
||||||
|
|
||||||
|
static {
|
||||||
|
boolean found;
|
||||||
|
try {
|
||||||
|
Class.forName("io.papermc.paper.threadedregions.RegionizedServerInitEvent");
|
||||||
|
found = true;
|
||||||
|
} catch (final ReflectiveOperationException e) {
|
||||||
|
found = false;
|
||||||
|
}
|
||||||
|
RUNNING_FOLIA = found;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<Runnable> initTasks = new ArrayList<>();
|
||||||
|
|
||||||
|
public FoliaScheduler(IRPGRegionsAPI api) {
|
||||||
|
super(api);
|
||||||
|
Bukkit.getPluginManager().registerEvents(this, (Plugin) api);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onServerInit(RegionizedServerInitEvent event) {
|
||||||
|
for (final Runnable tasks : initTasks) {
|
||||||
|
tasks.run();
|
||||||
|
}
|
||||||
|
initTasks = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executeOnMain(Runnable runnable) {
|
||||||
|
Bukkit.getGlobalRegionScheduler().execute((Plugin) api, runnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executeOnEntity(Entity entity, Runnable runnable) {
|
||||||
|
entity.getScheduler().run((Plugin) api, (s) -> runnable.run(), () -> {});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RPGRegionsTask executeRepeating(Runnable runnable, long delay, long period) {
|
||||||
|
final ScheduledTask task = Bukkit.getGlobalRegionScheduler().runAtFixedRate((Plugin) api, (s) -> runnable.run(), delay, period);
|
||||||
|
return task::cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executeDelayed(Runnable runnable, long delay) {
|
||||||
|
Bukkit.getGlobalRegionScheduler().runDelayed((Plugin) api, (s) -> runnable.run(), delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executeAsync(Runnable runnable) {
|
||||||
|
Bukkit.getAsyncScheduler().runNow((Plugin) api, (s) -> runnable.run());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerInitTask(Runnable runnable) {
|
||||||
|
if (initTasks == null) {
|
||||||
|
throw new IllegalStateException("Server already initialised!");
|
||||||
|
}
|
||||||
|
initTasks.add(runnable);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,3 +2,6 @@ pluginGroup=net.islandearth
|
|||||||
pluginVersion=1.4.5
|
pluginVersion=1.4.5
|
||||||
# Set to false if you don't have access to the UltraRegions API jar to make the plugin compilable. The purchased plugin has support for it.
|
# Set to false if you don't have access to the UltraRegions API jar to make the plugin compilable. The purchased plugin has support for it.
|
||||||
ultraRegionsSupport=true
|
ultraRegionsSupport=true
|
||||||
|
|
||||||
|
# Dependency management
|
||||||
|
cloud_version = 1.8.3
|
||||||
|
|||||||
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
3
gradle/wrapper/gradle-wrapper.properties
vendored
3
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
|
||||||
|
networkTimeout=10000
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
|||||||
18
gradlew
vendored
18
gradlew
vendored
@@ -55,7 +55,7 @@
|
|||||||
# Darwin, MinGW, and NonStop.
|
# Darwin, MinGW, and NonStop.
|
||||||
#
|
#
|
||||||
# (3) This script is generated from the Groovy template
|
# (3) This script is generated from the Groovy template
|
||||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||||
# within the Gradle project.
|
# within the Gradle project.
|
||||||
#
|
#
|
||||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||||
@@ -80,10 +80,10 @@ do
|
|||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
# This is normally unused
|
||||||
|
# shellcheck disable=SC2034
|
||||||
APP_NAME="Gradle"
|
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
|
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# 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"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
@@ -143,12 +143,16 @@ fi
|
|||||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
max*)
|
max*)
|
||||||
|
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC3045
|
||||||
MAX_FD=$( ulimit -H -n ) ||
|
MAX_FD=$( ulimit -H -n ) ||
|
||||||
warn "Could not query maximum file descriptor limit"
|
warn "Could not query maximum file descriptor limit"
|
||||||
esac
|
esac
|
||||||
case $MAX_FD in #(
|
case $MAX_FD in #(
|
||||||
'' | soft) :;; #(
|
'' | soft) :;; #(
|
||||||
*)
|
*)
|
||||||
|
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||||
|
# shellcheck disable=SC3045
|
||||||
ulimit -n "$MAX_FD" ||
|
ulimit -n "$MAX_FD" ||
|
||||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||||
esac
|
esac
|
||||||
@@ -205,6 +209,12 @@ set -- \
|
|||||||
org.gradle.wrapper.GradleWrapperMain \
|
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.
|
# Use "xargs" to parse quoted args.
|
||||||
#
|
#
|
||||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||||
|
|||||||
15
gradlew.bat
vendored
15
gradlew.bat
vendored
@@ -14,7 +14,7 @@
|
|||||||
@rem limitations under the License.
|
@rem limitations under the License.
|
||||||
@rem
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%"=="" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@rem Gradle startup script for Windows
|
@rem Gradle startup script for Windows
|
||||||
@@ -25,7 +25,8 @@
|
|||||||
if "%OS%"=="Windows_NT" setlocal
|
if "%OS%"=="Windows_NT" setlocal
|
||||||
|
|
||||||
set DIRNAME=%~dp0
|
set DIRNAME=%~dp0
|
||||||
if "%DIRNAME%" == "" set DIRNAME=.
|
if "%DIRNAME%"=="" set DIRNAME=.
|
||||||
|
@rem This is normally unused
|
||||||
set APP_BASE_NAME=%~n0
|
set APP_BASE_NAME=%~n0
|
||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||||||
|
|
||||||
set JAVA_EXE=java.exe
|
set JAVA_EXE=java.exe
|
||||||
%JAVA_EXE% -version >NUL 2>&1
|
%JAVA_EXE% -version >NUL 2>&1
|
||||||
if "%ERRORLEVEL%" == "0" goto execute
|
if %ERRORLEVEL% equ 0 goto execute
|
||||||
|
|
||||||
echo.
|
echo.
|
||||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||||
@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||||
|
|
||||||
:fail
|
:fail
|
||||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||||
rem the _cmd.exe /c_ return code!
|
rem the _cmd.exe /c_ return code!
|
||||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
set EXIT_CODE=%ERRORLEVEL%
|
||||||
exit /b 1
|
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||||
|
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||||
|
exit /b %EXIT_CODE%
|
||||||
|
|
||||||
:mainEnd
|
:mainEnd
|
||||||
if "%OS%"=="Windows_NT" endlocal
|
if "%OS%"=="Windows_NT" endlocal
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ dependencies {
|
|||||||
|
|
||||||
testImplementation("junit:junit:4.13.2")
|
testImplementation("junit:junit:4.13.2")
|
||||||
|
|
||||||
|
compileOnly("org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT")
|
||||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.4-SNAPSHOT") {
|
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.4-SNAPSHOT") {
|
||||||
exclude("com.destroystokyo.paper")
|
exclude("com.destroystokyo.paper")
|
||||||
exclude("org.spigotmc")
|
exclude("org.spigotmc")
|
||||||
|
|||||||
@@ -4,19 +4,31 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":api"))
|
implementation(project(":api"))
|
||||||
|
implementation(project(":folia"))
|
||||||
|
|
||||||
testImplementation("junit:junit:4.13.2")
|
testImplementation("junit:junit:4.13.2")
|
||||||
testImplementation("com.github.seeseemelk:MockBukkit-v1.17:1.13.0")
|
testImplementation("com.github.seeseemelk:MockBukkit-v1.17:1.13.0")
|
||||||
testImplementation("org.reflections:reflections:0.10.2")
|
testImplementation("org.reflections:reflections:0.10.2")
|
||||||
|
|
||||||
|
implementation("cloud.commandframework:cloud-paper:${properties["cloud_version"]}") {
|
||||||
|
exclude("org.checkerframework")
|
||||||
|
}
|
||||||
|
implementation("cloud.commandframework:cloud-annotations:${properties["cloud_version"]}") {
|
||||||
|
exclude("org.checkerframework")
|
||||||
|
}
|
||||||
|
implementation("cloud.commandframework:cloud-minecraft-extras:${properties["cloud_version"]}") {
|
||||||
|
exclude("org.checkerframework")
|
||||||
|
exclude("net.kyori")
|
||||||
|
}
|
||||||
|
implementation("net.kyori:adventure-platform-bukkit:4.3.0")
|
||||||
implementation("org.apache.commons:commons-lang3:3.12.0")
|
implementation("org.apache.commons:commons-lang3:3.12.0")
|
||||||
implementation("net.wesjd:anvilgui:1.6.3-SNAPSHOT") // anvilgui
|
implementation("net.wesjd:anvilgui:1.6.3-SNAPSHOT") // anvilgui
|
||||||
implementation("com.github.stefvanschie.inventoryframework:IF:0.10.9") // inventory framework
|
implementation("com.github.stefvanschie.inventoryframework:IF:0.10.9") // inventory framework
|
||||||
implementation("co.aikar:acf-paper:0.5.1-SNAPSHOT") // commands
|
|
||||||
implementation("co.aikar:idb-core:1.0.0-SNAPSHOT") // database
|
implementation("co.aikar:idb-core:1.0.0-SNAPSHOT") // database
|
||||||
implementation("org.bstats:bstats-bukkit:3.0.1") // plugin stats
|
implementation("org.bstats:bstats-bukkit:3.0.1") // plugin stats
|
||||||
implementation("io.papermc:paperlib:1.0.7") // paperlib - async teleport on Paper
|
implementation("io.papermc:paperlib:1.0.7") // paperlib - async teleport on Paper
|
||||||
|
|
||||||
|
compileOnly("org.spigotmc:spigot-api:1.19.4-R0.1-SNAPSHOT")
|
||||||
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.4-SNAPSHOT") {
|
compileOnly("com.sk89q.worldguard:worldguard-bukkit:7.0.4-SNAPSHOT") {
|
||||||
exclude("com.destroystokyo.paper")
|
exclude("com.destroystokyo.paper")
|
||||||
exclude("org.spigotmc")
|
exclude("org.spigotmc")
|
||||||
@@ -60,8 +72,9 @@ tasks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
relocate("co.aikar.commands", "net.islandearth.rpgregions.libs.acf")
|
relocate("net.kyori.adventure", "net.islandearth.rpgregions.libs.adventure")
|
||||||
relocate("co.aikar.locales", "net.islandearth.rpgregions.libs.acf.locales")
|
relocate("cloud.commandframework", "net.islandearth.rpgregions.libs.commandframework")
|
||||||
|
relocate("io.leangen.geantyref", "net.islandearth.rpgregions.libs.typetoken")
|
||||||
relocate("co.aikar.idb", "net.islandearth.rpgregions.libs.idb")
|
relocate("co.aikar.idb", "net.islandearth.rpgregions.libs.idb")
|
||||||
relocate("com.github.stefvanschie.inventoryframework", "net.islandearth.rpgregions.libs.inventoryframework")
|
relocate("com.github.stefvanschie.inventoryframework", "net.islandearth.rpgregions.libs.inventoryframework")
|
||||||
relocate("org.bstats", "net.islandearth.rpgregions.libs.bstats")
|
relocate("org.bstats", "net.islandearth.rpgregions.libs.bstats")
|
||||||
|
|||||||
@@ -1,27 +1,23 @@
|
|||||||
package net.islandearth.rpgregions;
|
package net.islandearth.rpgregions;
|
||||||
|
|
||||||
import co.aikar.commands.InvalidCommandArgument;
|
|
||||||
import co.aikar.commands.PaperCommandManager;
|
|
||||||
import co.aikar.idb.DB;
|
import co.aikar.idb.DB;
|
||||||
import com.convallyria.languagy.api.language.Language;
|
import com.convallyria.languagy.api.language.Language;
|
||||||
import com.convallyria.languagy.api.language.Translator;
|
import com.convallyria.languagy.api.language.Translator;
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
||||||
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
||||||
import net.islandearth.rpgregions.api.integrations.rpgregions.RPGRegionsIntegration;
|
import net.islandearth.rpgregions.api.integrations.rpgregions.RPGRegionsIntegration;
|
||||||
import net.islandearth.rpgregions.api.integrations.rpgregions.region.RPGRegionsRegion;
|
import net.islandearth.rpgregions.api.integrations.rpgregions.region.RPGRegionsRegion;
|
||||||
import net.islandearth.rpgregions.commands.DiscoveriesCommand;
|
import net.islandearth.rpgregions.api.schedule.PlatformScheduler;
|
||||||
import net.islandearth.rpgregions.commands.RPGRegionsCommand;
|
import net.islandearth.rpgregions.commands.Commands;
|
||||||
import net.islandearth.rpgregions.commands.RPGRegionsDebugCommand;
|
|
||||||
import net.islandearth.rpgregions.commands.RPGRegionsExportCommand;
|
|
||||||
import net.islandearth.rpgregions.effects.FogEffect;
|
import net.islandearth.rpgregions.effects.FogEffect;
|
||||||
import net.islandearth.rpgregions.effects.PotionRegionEffect;
|
import net.islandearth.rpgregions.effects.PotionRegionEffect;
|
||||||
import net.islandearth.rpgregions.effects.RegionEffect;
|
import net.islandearth.rpgregions.effects.RegionEffect;
|
||||||
import net.islandearth.rpgregions.effects.RegionEffectRegistry;
|
import net.islandearth.rpgregions.effects.RegionEffectRegistry;
|
||||||
import net.islandearth.rpgregions.effects.VanishEffect;
|
import net.islandearth.rpgregions.effects.VanishEffect;
|
||||||
import net.islandearth.rpgregions.exception.CouldNotStartException;
|
import net.islandearth.rpgregions.exception.CouldNotStartException;
|
||||||
|
import net.islandearth.rpgregions.folia.schedule.FoliaScheduler;
|
||||||
import net.islandearth.rpgregions.gson.AbstractAdapter;
|
import net.islandearth.rpgregions.gson.AbstractAdapter;
|
||||||
import net.islandearth.rpgregions.gson.ItemStackAdapter;
|
import net.islandearth.rpgregions.gson.ItemStackAdapter;
|
||||||
import net.islandearth.rpgregions.gson.LocationAdapter;
|
import net.islandearth.rpgregions.gson.LocationAdapter;
|
||||||
@@ -32,7 +28,6 @@ import net.islandearth.rpgregions.listener.RegionListener;
|
|||||||
import net.islandearth.rpgregions.listener.ServerReloadListener;
|
import net.islandearth.rpgregions.listener.ServerReloadListener;
|
||||||
import net.islandearth.rpgregions.listener.external.CustomStructuresListener;
|
import net.islandearth.rpgregions.listener.external.CustomStructuresListener;
|
||||||
import net.islandearth.rpgregions.managers.RPGRegionsManagers;
|
import net.islandearth.rpgregions.managers.RPGRegionsManagers;
|
||||||
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
|
||||||
import net.islandearth.rpgregions.managers.registry.IRPGRegionsRegistry;
|
import net.islandearth.rpgregions.managers.registry.IRPGRegionsRegistry;
|
||||||
import net.islandearth.rpgregions.requirements.AlonsoLevelRequirement;
|
import net.islandearth.rpgregions.requirements.AlonsoLevelRequirement;
|
||||||
import net.islandearth.rpgregions.requirements.DependencyRequirement;
|
import net.islandearth.rpgregions.requirements.DependencyRequirement;
|
||||||
@@ -59,37 +54,39 @@ import net.islandearth.rpgregions.rewards.QuestReward;
|
|||||||
import net.islandearth.rpgregions.rewards.RegionDiscoverReward;
|
import net.islandearth.rpgregions.rewards.RegionDiscoverReward;
|
||||||
import net.islandearth.rpgregions.rewards.RegionRewardRegistry;
|
import net.islandearth.rpgregions.rewards.RegionRewardRegistry;
|
||||||
import net.islandearth.rpgregions.rewards.TeleportReward;
|
import net.islandearth.rpgregions.rewards.TeleportReward;
|
||||||
|
import net.islandearth.rpgregions.schedule.BukkitScheduler;
|
||||||
import net.islandearth.rpgregions.tasks.DynmapTask;
|
import net.islandearth.rpgregions.tasks.DynmapTask;
|
||||||
import net.islandearth.rpgregions.translation.Translations;
|
import net.islandearth.rpgregions.translation.Translations;
|
||||||
|
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bstats.charts.SimplePie;
|
import org.bstats.charts.SimplePie;
|
||||||
import org.bstats.charts.SingleLineChart;
|
import org.bstats.charts.SingleLineChart;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI {
|
public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI {
|
||||||
|
|
||||||
|
private BukkitAudiences adventure;
|
||||||
|
private PlatformScheduler<? extends IRPGRegionsAPI> scheduler;
|
||||||
private RPGRegionsManagers managers;
|
private RPGRegionsManagers managers;
|
||||||
private PaperCommandManager commandManager;
|
|
||||||
private Economy ecoProvider;
|
private Economy ecoProvider;
|
||||||
|
|
||||||
public PaperCommandManager getCommandManager() {
|
public @NonNull BukkitAudiences adventure() {
|
||||||
return commandManager;
|
if (this.adventure == null) {
|
||||||
|
throw new IllegalStateException("Tried to access Adventure when the plugin was disabled!");
|
||||||
|
}
|
||||||
|
return this.adventure;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -101,10 +98,11 @@ public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
this.adventure = BukkitAudiences.create(this);
|
||||||
|
this.scheduler = FoliaScheduler.RUNNING_FOLIA ? new FoliaScheduler(this) : new BukkitScheduler(this);
|
||||||
RPGRegionsAPI.setAPI(this);
|
RPGRegionsAPI.setAPI(this);
|
||||||
this.createConfig();
|
this.createConfig();
|
||||||
this.generateLang();
|
this.generateLang();
|
||||||
this.commandManager = new PaperCommandManager(this);
|
|
||||||
try {
|
try {
|
||||||
this.managers = new RPGRegionsManagers(this);
|
this.managers = new RPGRegionsManagers(this);
|
||||||
} catch (ReflectiveOperationException | IOException | CouldNotStartException e) {
|
} catch (ReflectiveOperationException | IOException | CouldNotStartException e) {
|
||||||
@@ -112,12 +110,12 @@ public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI {
|
|||||||
Bukkit.getPluginManager().disablePlugin(this);
|
Bukkit.getPluginManager().disablePlugin(this);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.registerCommands();
|
||||||
this.registerRewards();
|
this.registerRewards();
|
||||||
this.registerRequirements();
|
this.registerRequirements();
|
||||||
this.registerEffects();
|
this.registerEffects();
|
||||||
this.registerListeners();
|
this.registerListeners();
|
||||||
this.registerCommands();
|
this.translator = Translator.of(this, "lang", Language.BRITISH_ENGLISH, debug());
|
||||||
this.translator = Translator.of(this, "lang", Language.ENGLISH, debug());
|
|
||||||
this.registerTasks();
|
this.registerTasks();
|
||||||
this.registerMetrics();
|
this.registerMetrics();
|
||||||
this.setupEconomy();
|
this.setupEconomy();
|
||||||
@@ -155,6 +153,11 @@ public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI {
|
|||||||
managers.getRegionsCache().getConfiguredRegions().forEach((id, region) -> region.save(this));
|
managers.getRegionsCache().getConfiguredRegions().forEach((id, region) -> region.save(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.adventure != null) {
|
||||||
|
this.adventure.close();
|
||||||
|
this.adventure = null;
|
||||||
|
}
|
||||||
|
|
||||||
RPGRegionsAPI.setAPI(null);
|
RPGRegionsAPI.setAPI(null);
|
||||||
DB.close();
|
DB.close();
|
||||||
}
|
}
|
||||||
@@ -186,55 +189,7 @@ public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void registerCommands() {
|
private void registerCommands() {
|
||||||
final PaperCommandManager manager = commandManager;
|
new Commands(this);
|
||||||
manager.enableUnstableAPI("help");
|
|
||||||
manager.getCommandCompletions().registerAsyncCompletion("regions", context -> ImmutableList.copyOf(getManagers().getRegionsCache().getConfiguredRegions().keySet()));
|
|
||||||
manager.getCommandCompletions().registerAsyncCompletion("integration-regions", context -> ImmutableList.copyOf(this.getManagers().getIntegrationManager().getAllRegionNames(context.getPlayer().getWorld())));
|
|
||||||
manager.getCommandCompletions().registerAsyncCompletion("async", context -> ImmutableList.of("--async"));
|
|
||||||
manager.getCommandCompletions().registerAsyncCompletion("region-types", context -> ImmutableList.of("Cuboid", "Poly"));
|
|
||||||
manager.getCommandCompletions().registerAsyncCompletion("offline-players", context -> {
|
|
||||||
List<String> players = new ArrayList<>();
|
|
||||||
if (!getConfig().getBoolean("settings.server.tabcomplete.search-offline-players")) {
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
|
||||||
players.add(player.getName());
|
|
||||||
}
|
|
||||||
return ImmutableList.copyOf(players);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (OfflinePlayer offlinePlayer : Bukkit.getOfflinePlayers()) {
|
|
||||||
players.add(offlinePlayer.getName());
|
|
||||||
}
|
|
||||||
return ImmutableList.copyOf(players);
|
|
||||||
});
|
|
||||||
manager.getCommandCompletions().registerAsyncCompletion("schematics", context -> {
|
|
||||||
File schematicFolder = new File("plugins/WorldEdit/schematics/");
|
|
||||||
List<String> files = new ArrayList<>();
|
|
||||||
for (File file : schematicFolder.listFiles()) {
|
|
||||||
files.add(file.getName());
|
|
||||||
}
|
|
||||||
return files;
|
|
||||||
});
|
|
||||||
manager.getCommandCompletions().registerAsyncCompletion("templates", context -> {
|
|
||||||
File templates = new File(this.getDataFolder() + File.separator + "templates");
|
|
||||||
List<String> files = new ArrayList<>();
|
|
||||||
for (File file : templates.listFiles()) {
|
|
||||||
files.add(file.getName());
|
|
||||||
}
|
|
||||||
return files;
|
|
||||||
});
|
|
||||||
manager.getCommandContexts().registerContext(ConfiguredRegion.class, context -> {
|
|
||||||
String id = context.popFirstArg();
|
|
||||||
for (ConfiguredRegion region : managers.getRegionsCache().getConfiguredRegions().values()) {
|
|
||||||
if (region.getId().equals(id)) {
|
|
||||||
return region;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new InvalidCommandArgument("Could not find a region with that id.");
|
|
||||||
});
|
|
||||||
manager.registerCommand(new RPGRegionsCommand(this));
|
|
||||||
manager.registerCommand(new DiscoveriesCommand(this));
|
|
||||||
manager.registerCommand(new RPGRegionsDebugCommand(this));
|
|
||||||
manager.registerCommand(new RPGRegionsExportCommand(this));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerRewards() {
|
private void registerRewards() {
|
||||||
@@ -305,6 +260,11 @@ public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI {
|
|||||||
return Bukkit.getPluginManager().getPlugin("HeadDatabase") != null;
|
return Bukkit.getPluginManager().getPlugin("HeadDatabase") != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlatformScheduler<? extends IRPGRegionsAPI> getScheduler() {
|
||||||
|
return scheduler;
|
||||||
|
}
|
||||||
|
|
||||||
private void setupEconomy() {
|
private void setupEconomy() {
|
||||||
if (getServer().getPluginManager().getPlugin("Vault") == null) {
|
if (getServer().getPluginManager().getPlugin("Vault") == null) {
|
||||||
return;
|
return;
|
||||||
@@ -323,7 +283,7 @@ public final class RPGRegions extends JavaPlugin implements IRPGRegionsAPI {
|
|||||||
private void registerTasks() {
|
private void registerTasks() {
|
||||||
if (Bukkit.getPluginManager().getPlugin("Dynmap") != null
|
if (Bukkit.getPluginManager().getPlugin("Dynmap") != null
|
||||||
&& getConfig().getBoolean("settings.external.dynmap")) {
|
&& getConfig().getBoolean("settings.external.dynmap")) {
|
||||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new DynmapTask(this), 0L, 20L);
|
getScheduler().executeRepeating(new DynmapTask(this), 0L, 20L);
|
||||||
getLogger().info("Registered support for Dynmap.");
|
getLogger().info("Registered support for Dynmap.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
package net.islandearth.rpgregions.api.integrations.rpgregions;
|
package net.islandearth.rpgregions.api.integrations.rpgregions;
|
||||||
|
|
||||||
import co.aikar.commands.InvalidCommandArgument;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import net.islandearth.rpgregions.RPGRegions;
|
|
||||||
import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
import net.islandearth.rpgregions.api.IRPGRegionsAPI;
|
||||||
import net.islandearth.rpgregions.api.events.RegionsEnterEvent;
|
import net.islandearth.rpgregions.api.events.RegionsEnterEvent;
|
||||||
import net.islandearth.rpgregions.api.integrations.IntegrationManager;
|
import net.islandearth.rpgregions.api.integrations.IntegrationManager;
|
||||||
import net.islandearth.rpgregions.api.integrations.rpgregions.region.RPGRegionsRegion;
|
import net.islandearth.rpgregions.api.integrations.rpgregions.region.RPGRegionsRegion;
|
||||||
import net.islandearth.rpgregions.commands.RPGRegionsIntegrationCommand;
|
|
||||||
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -39,20 +36,6 @@ public class RPGRegionsIntegration implements IntegrationManager {
|
|||||||
public RPGRegionsIntegration(IRPGRegionsAPI plugin) {
|
public RPGRegionsIntegration(IRPGRegionsAPI plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.regions = new HashMap<>();
|
this.regions = new HashMap<>();
|
||||||
// Register command completions and command, it's here because we only want it to enable if enabled.
|
|
||||||
if (plugin instanceof RPGRegions rpgRegions) {
|
|
||||||
rpgRegions.getCommandManager().getCommandContexts().registerContext(RPGRegionsRegion.class, context -> {
|
|
||||||
String id = context.popFirstArg();
|
|
||||||
if (rpgRegions.getManagers().getIntegrationManager() instanceof RPGRegionsIntegration rpgRegionsIntegration) {
|
|
||||||
Optional<RPGRegionsRegion> region = rpgRegionsIntegration.getRegion(id);
|
|
||||||
if (region.isPresent()) {
|
|
||||||
return region.get();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new InvalidCommandArgument("Could not find a region with that id.");
|
|
||||||
});
|
|
||||||
rpgRegions.getCommandManager().registerCommand(new RPGRegionsIntegrationCommand(rpgRegions));
|
|
||||||
}
|
|
||||||
plugin.getLogger().info("RPGRegions region integration has been enabled.");
|
plugin.getLogger().info("RPGRegions region integration has been enabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,146 @@
|
|||||||
|
package net.islandearth.rpgregions.commands;
|
||||||
|
|
||||||
|
import cloud.commandframework.annotations.AnnotationParser;
|
||||||
|
import cloud.commandframework.arguments.parser.ParserParameters;
|
||||||
|
import cloud.commandframework.arguments.parser.ParserRegistry;
|
||||||
|
import cloud.commandframework.arguments.parser.StandardParameters;
|
||||||
|
import cloud.commandframework.bukkit.CloudBukkitCapabilities;
|
||||||
|
import cloud.commandframework.execution.CommandExecutionCoordinator;
|
||||||
|
import cloud.commandframework.extra.confirmation.CommandConfirmationManager;
|
||||||
|
import cloud.commandframework.meta.CommandMeta;
|
||||||
|
import cloud.commandframework.minecraft.extras.MinecraftExceptionHandler;
|
||||||
|
import cloud.commandframework.paper.PaperCommandManager;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import io.leangen.geantyref.TypeToken;
|
||||||
|
import net.islandearth.rpgregions.RPGRegions;
|
||||||
|
import net.islandearth.rpgregions.api.integrations.rpgregions.RPGRegionsIntegration;
|
||||||
|
import net.islandearth.rpgregions.api.integrations.rpgregions.region.RPGRegionsRegion;
|
||||||
|
import net.islandearth.rpgregions.commands.caption.RPGRegionsCaptionRegistry;
|
||||||
|
import net.islandearth.rpgregions.commands.caption.RPGRegionsCaptionRegistryFactory;
|
||||||
|
import net.islandearth.rpgregions.commands.parser.ConfiguredRegionArgument;
|
||||||
|
import net.islandearth.rpgregions.commands.parser.IntegrationRegionArgument;
|
||||||
|
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
public class Commands {
|
||||||
|
|
||||||
|
public Commands(RPGRegions plugin) {
|
||||||
|
|
||||||
|
// This function maps the command sender type of our choice to the bukkit command sender.
|
||||||
|
final Function<CommandSender, CommandSender> mapperFunction = Function.identity();
|
||||||
|
|
||||||
|
final PaperCommandManager<CommandSender> manager;
|
||||||
|
try {
|
||||||
|
manager = new PaperCommandManager<>(
|
||||||
|
plugin,
|
||||||
|
CommandExecutionCoordinator.simpleCoordinator(),
|
||||||
|
mapperFunction,
|
||||||
|
mapperFunction
|
||||||
|
);
|
||||||
|
} catch (Exception e) {
|
||||||
|
plugin.getLogger().severe("Failed to initialize the command manager");
|
||||||
|
e.printStackTrace();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register Brigadier mappings
|
||||||
|
if (manager.hasCapability(CloudBukkitCapabilities.BRIGADIER)) {
|
||||||
|
manager.registerBrigadier();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register asynchronous completions
|
||||||
|
if (manager.hasCapability(CloudBukkitCapabilities.ASYNCHRONOUS_COMPLETION)) {
|
||||||
|
manager.registerAsynchronousCompletions();
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create the confirmation manager. This allows us to require certain commands to be
|
||||||
|
* confirmed before they can be executed
|
||||||
|
*/
|
||||||
|
final CommandConfirmationManager<CommandSender> confirmationManager = new CommandConfirmationManager<>(30L, TimeUnit.SECONDS,
|
||||||
|
/* Action when confirmation is required */
|
||||||
|
context -> {
|
||||||
|
final String name = context.getCommand().getArguments().get(0).getName();
|
||||||
|
context.getCommandContext().getSender().sendMessage(
|
||||||
|
ChatColor.RED + "Confirmation required. Confirm using " + ChatColor.YELLOW + "/" + name + " confirm" + ChatColor.RED + ".");
|
||||||
|
},
|
||||||
|
/* Action when no confirmation is pending */ sender -> sender.sendMessage(
|
||||||
|
ChatColor.RED + "You don't have any pending commands.")
|
||||||
|
);
|
||||||
|
|
||||||
|
// Register the confirmation processor. This will enable confirmations for commands that require it
|
||||||
|
confirmationManager.registerConfirmationProcessor(manager);
|
||||||
|
|
||||||
|
// This will allow you to decorate commands with descriptions
|
||||||
|
final Function<ParserParameters, CommandMeta> commandMetaFunction = parserParameters ->
|
||||||
|
CommandMeta.simple()
|
||||||
|
.with(CommandMeta.DESCRIPTION, parserParameters.get(StandardParameters.DESCRIPTION, "No description"))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
// Override the default exception handlers
|
||||||
|
// todo: change some stuff lmao
|
||||||
|
new MinecraftExceptionHandler<CommandSender>()
|
||||||
|
.withInvalidSyntaxHandler()
|
||||||
|
.withInvalidSenderHandler()
|
||||||
|
.withNoPermissionHandler()
|
||||||
|
.withArgumentParsingHandler()
|
||||||
|
.apply(manager, player -> plugin.adventure().sender(player));
|
||||||
|
|
||||||
|
// Register our custom caption registry so we can define exception messages for parsers
|
||||||
|
final RPGRegionsCaptionRegistry<CommandSender> captionRegistry = new RPGRegionsCaptionRegistryFactory<CommandSender>().create();
|
||||||
|
manager.captionRegistry(captionRegistry);
|
||||||
|
|
||||||
|
// Register custom parsers
|
||||||
|
final ParserRegistry<CommandSender> parserRegistry = manager.parserRegistry();
|
||||||
|
parserRegistry.registerParserSupplier(TypeToken.get(ConfiguredRegion.class), parserParameters ->
|
||||||
|
new ConfiguredRegionArgument.ConfiguredRegionParser<>());
|
||||||
|
parserRegistry.registerParserSupplier(TypeToken.get(RPGRegionsRegion.class), parserParameters ->
|
||||||
|
new IntegrationRegionArgument.IntegrationRegionParser<>());
|
||||||
|
|
||||||
|
parserRegistry.registerSuggestionProvider("region-types", (context, arg) -> ImmutableList.of("Cuboid", "Poly"));
|
||||||
|
|
||||||
|
parserRegistry.registerSuggestionProvider("integration-regions", (context, arg) -> {
|
||||||
|
if (context.getSender() instanceof Player player) {
|
||||||
|
return ImmutableList.copyOf(plugin.getManagers().getIntegrationManager().getAllRegionNames(player.getWorld()));
|
||||||
|
}
|
||||||
|
return new ArrayList<>();
|
||||||
|
});
|
||||||
|
|
||||||
|
parserRegistry.registerSuggestionProvider("templates", (context, arg) -> {
|
||||||
|
File templates = new File(plugin.getDataFolder() + File.separator + "templates");
|
||||||
|
List<String> files = new ArrayList<>();
|
||||||
|
for (File file : templates.listFiles()) {
|
||||||
|
files.add(file.getName());
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
});
|
||||||
|
|
||||||
|
parserRegistry.registerSuggestionProvider("schematics", (context, arg) -> {
|
||||||
|
File schematicFolder = new File("plugins/WorldEdit/schematics/");
|
||||||
|
List<String> files = new ArrayList<>();
|
||||||
|
for (File file : schematicFolder.listFiles()) {
|
||||||
|
files.add(file.getName());
|
||||||
|
}
|
||||||
|
return files;
|
||||||
|
});
|
||||||
|
|
||||||
|
parserRegistry.registerSuggestionProvider("async", (context, arg) -> List.of("--async"));
|
||||||
|
|
||||||
|
final AnnotationParser<CommandSender> annotationParser = new AnnotationParser<>(manager, CommandSender.class, commandMetaFunction);
|
||||||
|
annotationParser.parse(new DiscoveriesCommand(plugin));
|
||||||
|
annotationParser.parse(new RPGRegionsCommand(plugin, manager));
|
||||||
|
annotationParser.parse(new RPGRegionsDebugCommand(plugin));
|
||||||
|
annotationParser.parse(new RPGRegionsExportCommand(plugin, manager));
|
||||||
|
if (plugin.getManagers().getIntegrationManager() instanceof RPGRegionsIntegration) {
|
||||||
|
annotationParser.parse(new RPGRegionsIntegrationCommand(plugin, manager));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,11 +1,9 @@
|
|||||||
package net.islandearth.rpgregions.commands;
|
package net.islandearth.rpgregions.commands;
|
||||||
|
|
||||||
import co.aikar.commands.BaseCommand;
|
import cloud.commandframework.annotations.Argument;
|
||||||
import co.aikar.commands.annotation.CommandAlias;
|
import cloud.commandframework.annotations.CommandDescription;
|
||||||
import co.aikar.commands.annotation.CommandCompletion;
|
import cloud.commandframework.annotations.CommandMethod;
|
||||||
import co.aikar.commands.annotation.CommandPermission;
|
import cloud.commandframework.annotations.CommandPermission;
|
||||||
import co.aikar.commands.annotation.Default;
|
|
||||||
import co.aikar.commands.annotation.Subcommand;
|
|
||||||
import net.islandearth.rpgregions.RPGRegions;
|
import net.islandearth.rpgregions.RPGRegions;
|
||||||
import net.islandearth.rpgregions.api.events.RegionDiscoverEvent;
|
import net.islandearth.rpgregions.api.events.RegionDiscoverEvent;
|
||||||
import net.islandearth.rpgregions.gui.DiscoveryGUI;
|
import net.islandearth.rpgregions.gui.DiscoveryGUI;
|
||||||
@@ -20,8 +18,7 @@ import org.bukkit.entity.Player;
|
|||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
|
||||||
@CommandAlias("discoveries|discovery")
|
public class DiscoveriesCommand {
|
||||||
public class DiscoveriesCommand extends BaseCommand {
|
|
||||||
|
|
||||||
private final RPGRegions plugin;
|
private final RPGRegions plugin;
|
||||||
|
|
||||||
@@ -29,16 +26,19 @@ public class DiscoveriesCommand extends BaseCommand {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Default
|
@CommandDescription("Opens the discovery GUI")
|
||||||
@CommandPermission("rpgregions.list")
|
@CommandPermission("rpgregions.list")
|
||||||
|
@CommandMethod("discoveries|discovery")
|
||||||
public void onDefault(Player player) {
|
public void onDefault(Player player) {
|
||||||
new DiscoveryGUI(plugin, player).open();
|
new DiscoveryGUI(plugin, player).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("discover")
|
@CommandDescription("Discovers a region for a player")
|
||||||
@CommandPermission("rpgregions.discover")
|
@CommandPermission("rpgregions.discover")
|
||||||
@CommandCompletion("@regions @offline-players")
|
@CommandMethod("discoveries|discovery discover <region> <player>")
|
||||||
public void onDiscover(CommandSender sender, ConfiguredRegion configuredRegion, OfflinePlayer target) {
|
public void onDiscover(CommandSender sender,
|
||||||
|
@Argument("region") ConfiguredRegion configuredRegion,
|
||||||
|
@Argument("player") OfflinePlayer target) {
|
||||||
plugin.getManagers().getStorageManager().getAccount(target.getUniqueId()).thenAccept(account -> {
|
plugin.getManagers().getStorageManager().getAccount(target.getUniqueId()).thenAccept(account -> {
|
||||||
LocalDateTime date = LocalDateTime.now();
|
LocalDateTime date = LocalDateTime.now();
|
||||||
DateTimeFormatter format = DateTimeFormatter.ofPattern(plugin.getConfig().getString("settings.server.discoveries.date.format"));
|
DateTimeFormatter format = DateTimeFormatter.ofPattern(plugin.getConfig().getString("settings.server.discoveries.date.format"));
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package net.islandearth.rpgregions.commands;
|
package net.islandearth.rpgregions.commands;
|
||||||
|
|
||||||
import co.aikar.commands.BaseCommand;
|
import cloud.commandframework.annotations.Argument;
|
||||||
import co.aikar.commands.CommandHelp;
|
import cloud.commandframework.annotations.CommandDescription;
|
||||||
import co.aikar.commands.annotation.CommandAlias;
|
import cloud.commandframework.annotations.CommandMethod;
|
||||||
import co.aikar.commands.annotation.CommandCompletion;
|
import cloud.commandframework.annotations.CommandPermission;
|
||||||
import co.aikar.commands.annotation.CommandPermission;
|
import cloud.commandframework.annotations.specifier.Greedy;
|
||||||
import co.aikar.commands.annotation.Default;
|
import cloud.commandframework.minecraft.extras.MinecraftHelp;
|
||||||
import co.aikar.commands.annotation.HelpCommand;
|
import cloud.commandframework.paper.PaperCommandManager;
|
||||||
import co.aikar.commands.annotation.Subcommand;
|
|
||||||
import net.islandearth.rpgregions.RPGRegions;
|
import net.islandearth.rpgregions.RPGRegions;
|
||||||
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
||||||
import net.islandearth.rpgregions.api.events.RPGRegionsReloadEvent;
|
import net.islandearth.rpgregions.api.events.RPGRegionsReloadEvent;
|
||||||
@@ -27,6 +26,7 @@ import org.bukkit.OfflinePlayer;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@@ -34,25 +34,30 @@ import java.io.File;
|
|||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
@CommandAlias("rpgregions|rpgr")
|
public class RPGRegionsCommand {
|
||||||
public class RPGRegionsCommand extends BaseCommand {
|
|
||||||
|
|
||||||
private final RPGRegions plugin;
|
private final RPGRegions plugin;
|
||||||
|
private final MinecraftHelp<CommandSender> help;
|
||||||
private final List<UUID> regenerateConfirm = new ArrayList<>();
|
private final List<UUID> regenerateConfirm = new ArrayList<>();
|
||||||
private static final String WARNING_MESSAGE = ChatColor.RED + "" + ChatColor.ITALIC + "" + ChatColor.BOLD
|
private static final String WARNING_MESSAGE = ChatColor.RED + "" + ChatColor.ITALIC + "" + ChatColor.BOLD
|
||||||
+ "The regenerate configuration is very dangerous and can delete world sections if used wrongly.";
|
+ "The regenerate configuration is very dangerous and can delete world sections if used wrongly.";
|
||||||
|
|
||||||
public RPGRegionsCommand(RPGRegions plugin) {
|
public RPGRegionsCommand(RPGRegions plugin, PaperCommandManager<CommandSender> manager) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.help = new MinecraftHelp<>(
|
||||||
|
"/rpgregions help",
|
||||||
|
player -> plugin.adventure().sender(player),
|
||||||
|
manager
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Default
|
@CommandDescription("The default RPGRegions command")
|
||||||
|
@CommandMethod("rpgregions|rpgr")
|
||||||
public void onDefault(CommandSender sender) {
|
public void onDefault(CommandSender sender) {
|
||||||
if (sender.hasPermission("rpgregions.noview") && !sender.isOp()) return;
|
if (sender.hasPermission("rpgregions.noview") && !sender.isOp()) return;
|
||||||
|
|
||||||
@@ -68,13 +73,13 @@ public class RPGRegionsCommand extends BaseCommand {
|
|||||||
+ " regions are loaded with " + rewards + " rewards.");
|
+ " regions are loaded with " + rewards + " rewards.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@HelpCommand
|
@CommandMethod("rpgregions|rpgr help [query]")
|
||||||
@Subcommand("help")
|
public void onHelp(final CommandSender sender, @Argument("query") @Greedy @Nullable String query) {
|
||||||
public void onHelp(final CommandHelp commandHelp) {
|
help.queryCommands(query == null ? "" : query, sender);
|
||||||
commandHelp.showHelp();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("about")
|
@CommandDescription("Debug information about the plugin")
|
||||||
|
@CommandMethod("rpgregions|rpgr about")
|
||||||
public void onAbout(CommandSender sender) {
|
public void onAbout(CommandSender sender) {
|
||||||
sender.sendMessage(StringUtils.colour("&eRPGRegions v" + plugin.getDescription().getVersion() + "."));
|
sender.sendMessage(StringUtils.colour("&eRPGRegions v" + plugin.getDescription().getVersion() + "."));
|
||||||
sender.sendMessage(StringUtils.colour("&eOwner: https://www.spigotmc.org/members/%%__USER__%%/"));
|
sender.sendMessage(StringUtils.colour("&eOwner: https://www.spigotmc.org/members/%%__USER__%%/"));
|
||||||
@@ -82,10 +87,13 @@ public class RPGRegionsCommand extends BaseCommand {
|
|||||||
sender.sendMessage(StringUtils.colour("&eIntegration: " + plugin.getManagers().getIntegrationManager().getClass().getName()));
|
sender.sendMessage(StringUtils.colour("&eIntegration: " + plugin.getManagers().getIntegrationManager().getClass().getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("add")
|
@CommandDescription("Creates a configured region from a region created in your integration")
|
||||||
@CommandPermission("rpgregions.add")
|
@CommandPermission("rpgregions.add")
|
||||||
@CommandCompletion("@integration-regions")
|
@CommandMethod("rpgregions|rpgr add <region> [world]")
|
||||||
public void onAdd(CommandSender sender, String region, @co.aikar.commands.annotation.Optional @Nullable String worldName) {
|
public void onAdd(CommandSender sender,
|
||||||
|
@Argument(value = "region", suggestions = "integration-regions") String region,
|
||||||
|
@Argument("world") @Nullable World world) {
|
||||||
|
|
||||||
if (plugin.getManagers().getRegionsCache().getConfiguredRegion(region).isPresent()) {
|
if (plugin.getManagers().getRegionsCache().getConfiguredRegion(region).isPresent()) {
|
||||||
sender.sendMessage(StringUtils.colour("&cThat region is already configured."));
|
sender.sendMessage(StringUtils.colour("&cThat region is already configured."));
|
||||||
return;
|
return;
|
||||||
@@ -96,7 +104,6 @@ public class RPGRegionsCommand extends BaseCommand {
|
|||||||
location = player.getLocation();
|
location = player.getLocation();
|
||||||
}
|
}
|
||||||
|
|
||||||
final World world = worldName == null ? null : Bukkit.getWorld(worldName);
|
|
||||||
if (world != null) {
|
if (world != null) {
|
||||||
if (location == null) location = new Location(world, 0, 100, 0);
|
if (location == null) location = new Location(world, 0, 100, 0);
|
||||||
else location.setWorld(world);
|
else location.setWorld(world);
|
||||||
@@ -127,59 +134,58 @@ public class RPGRegionsCommand extends BaseCommand {
|
|||||||
plugin.getManagers().getRegionsCache().addConfiguredRegion(configuredRegion);
|
plugin.getManagers().getRegionsCache().addConfiguredRegion(configuredRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("setname")
|
@CommandDescription("Sets the display name of a region")
|
||||||
@CommandPermission("rpgregions.setname")
|
@CommandPermission("rpgregions.setname")
|
||||||
@CommandCompletion("@regions")
|
@CommandMethod("rpgregions|rpgr setname <region> <name>")
|
||||||
public void onSetName(CommandSender sender, String region, String regionName) {
|
public void onSetName(CommandSender sender,
|
||||||
Optional<ConfiguredRegion> configuredRegion = plugin.getManagers().getRegionsCache().getConfiguredRegion(region);
|
@Argument("region") ConfiguredRegion region,
|
||||||
if (configuredRegion.isEmpty()) {
|
@Argument("name") String name) {
|
||||||
sender.sendMessage(StringUtils.colour("&cRegion '" + region + "' does not exist yet, create it first."));
|
region.setCustomName(name);
|
||||||
return;
|
sender.sendMessage(StringUtils.colour("&aSet name of region '" + region + "' to: " + name));
|
||||||
}
|
|
||||||
configuredRegion.get().setCustomName(regionName);
|
|
||||||
sender.sendMessage(StringUtils.colour("&aSet name of region '" + region + "' to: " + regionName));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("remove")
|
@CommandDescription("Removes a configured region. Does not delete it from your integration.")
|
||||||
@CommandPermission("rpgregions.remove")
|
@CommandPermission("rpgregions.remove")
|
||||||
@CommandCompletion("@regions")
|
@CommandMethod("rpgregions|rpgr remove <region>")
|
||||||
public void onRemove(CommandSender sender, ConfiguredRegion configuredRegion) {
|
public void onRemove(CommandSender sender, @Argument("region") ConfiguredRegion region) {
|
||||||
if (configuredRegion != null) {
|
if (region != null) {
|
||||||
configuredRegion.delete(plugin);
|
region.delete(plugin);
|
||||||
plugin.getManagers().getRegionsCache().removeConfiguredRegion(configuredRegion.getId());
|
plugin.getManagers().getRegionsCache().removeConfiguredRegion(region.getId());
|
||||||
sender.sendMessage(StringUtils.colour("&cRemoved configured region " + configuredRegion.getId() + "!"));
|
sender.sendMessage(StringUtils.colour("&cRemoved configured region " + region.getId() + "!"));
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(StringUtils.colour("&cA region by that name is not yet configured."));
|
sender.sendMessage(StringUtils.colour("&cA region by that name is not yet configured."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("edit")
|
@CommandDescription("Opens the editor GUI for a region")
|
||||||
@CommandPermission("rpgregions.edit")
|
@CommandPermission("rpgregions.edit")
|
||||||
@CommandCompletion("@regions")
|
@CommandMethod("rpgregions|rpgr edit <region>")
|
||||||
public void onEdit(Player player, ConfiguredRegion configuredRegion) {
|
public void onEdit(Player player, @Argument("region") ConfiguredRegion region) {
|
||||||
new RegionCreateGUI(plugin, player, configuredRegion).open();
|
new RegionCreateGUI(plugin, player, region).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("list|discoveries")
|
@CommandDescription("Opens the /discovery GUI")
|
||||||
@CommandPermission("rpgregions.list")
|
@CommandPermission("rpgregions.list")
|
||||||
|
@CommandMethod("rpgregions|rpgr list|discoveries")
|
||||||
public void onList(Player player) {
|
public void onList(Player player) {
|
||||||
new DiscoveryGUI(plugin, player).open();
|
new DiscoveryGUI(plugin, player).open();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("additem")
|
@CommandDescription("Adds an item reward to a region (util command)")
|
||||||
@CommandPermission("rpgregions.additem")
|
@CommandPermission("rpgregions.additem")
|
||||||
@CommandCompletion("@regions")
|
@CommandMethod("rpgregions|rpgr additem <region>")
|
||||||
public void onAddItem(Player player, ConfiguredRegion configuredRegion) {
|
public void onAddItem(Player player, @Argument("region") ConfiguredRegion region) {
|
||||||
if (configuredRegion != null) {
|
if (region != null) {
|
||||||
configuredRegion.getRewards().add(new ItemReward(plugin, player.getInventory().getItemInMainHand()));
|
region.getRewards().add(new ItemReward(plugin, player.getInventory().getItemInMainHand()));
|
||||||
player.sendMessage(ChatColor.GREEN + "Item added to configuration!");
|
player.sendMessage(ChatColor.GREEN + "Item added to configuration!");
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.RED + "No region exists by that name.");
|
player.sendMessage(ChatColor.RED + "No region exists by that name.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("reload")
|
@CommandDescription("Reloads configured regions from the `/plugins/RPGRegions/regions` folder.")
|
||||||
@CommandPermission("rpgregions.reload")
|
@CommandPermission("rpgregions.reload")
|
||||||
|
@CommandMethod("rpgregions|rpgr reload")
|
||||||
public void onReload(CommandSender sender) {
|
public void onReload(CommandSender sender) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "Reloading region files...");
|
sender.sendMessage(ChatColor.GREEN + "Reloading region files...");
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
@@ -208,11 +214,11 @@ public class RPGRegionsCommand extends BaseCommand {
|
|||||||
sender.sendMessage(ChatColor.GREEN + "Done! (" + totalTime + "ms)");
|
sender.sendMessage(ChatColor.GREEN + "Done! (" + totalTime + "ms)");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("save")
|
@CommandDescription("Saves configured regions to the `/plugins/RPGRegions/regions` folder. Also saves user data.")
|
||||||
@CommandPermission("rpgregions.save")
|
@CommandPermission("rpgregions.save")
|
||||||
@CommandCompletion("@async")
|
@CommandMethod("rpgregions|rpgr save [async]")
|
||||||
public void onSave(CommandSender sender, @co.aikar.commands.annotation.Optional String[] args) {
|
public void onSave(CommandSender sender, @Argument(value = "async", suggestions = "async") String asyncArg) {
|
||||||
boolean async = Arrays.asList(args).contains("--async");
|
boolean async = asyncArg.equals("--async");
|
||||||
sender.sendMessage(ChatColor.GREEN + "Saving data..." + (async ? ChatColor.GOLD + " (async)" : ""));
|
sender.sendMessage(ChatColor.GREEN + "Saving data..." + (async ? ChatColor.GOLD + " (async)" : ""));
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
|
|
||||||
@@ -236,28 +242,20 @@ public class RPGRegionsCommand extends BaseCommand {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("reset")
|
@CommandDescription("Resets the data of a player")
|
||||||
@CommandPermission("rpgregions.reset")
|
@CommandPermission("rpgregions.reset")
|
||||||
@CommandCompletion("@players @regions")
|
@CommandMethod("rpgregions|rpgr reset <player> [region]")
|
||||||
public void onReset(CommandSender sender, String[] args) {
|
public void onReset(CommandSender sender,
|
||||||
@SuppressWarnings({"deprecation"}) // We know what we're doing.
|
@Argument("player") @NonNull OfflinePlayer player,
|
||||||
OfflinePlayer player = Bukkit.getOfflinePlayer(args[0]);
|
@Argument("region") @Nullable ConfiguredRegion region) {
|
||||||
if (!player.hasPlayedBefore()) {
|
if (region == null) {
|
||||||
sender.sendMessage(ChatColor.RED + "That player cannot be found.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (args.length) {
|
|
||||||
case 1 -> {
|
|
||||||
plugin.getManagers().getStorageManager().clearDiscoveries(player.getUniqueId());
|
plugin.getManagers().getStorageManager().clearDiscoveries(player.getUniqueId());
|
||||||
if (!player.isOnline())
|
if (!player.isOnline())
|
||||||
plugin.getManagers().getStorageManager().removeCachedAccount(player.getUniqueId());
|
plugin.getManagers().getStorageManager().removeCachedAccount(player.getUniqueId());
|
||||||
sender.sendMessage(ChatColor.GREEN + "Players discoveries has been cleared.");
|
sender.sendMessage(ChatColor.GREEN + "Players discoveries has been cleared.");
|
||||||
}
|
} else {
|
||||||
case 2 -> {
|
if (plugin.getManagers().getRegionsCache().getConfiguredRegions().containsKey(region.getId())) {
|
||||||
String regionId = args[1];
|
plugin.getManagers().getStorageManager().clearDiscovery(player.getUniqueId(), region.getId());
|
||||||
if (plugin.getManagers().getRegionsCache().getConfiguredRegions().containsKey(regionId)) {
|
|
||||||
plugin.getManagers().getStorageManager().clearDiscovery(player.getUniqueId(), regionId);
|
|
||||||
if (!player.isOnline())
|
if (!player.isOnline())
|
||||||
plugin.getManagers().getStorageManager().removeCachedAccount(player.getUniqueId());
|
plugin.getManagers().getStorageManager().removeCachedAccount(player.getUniqueId());
|
||||||
sender.sendMessage(ChatColor.GREEN + "Discovery cleared.");
|
sender.sendMessage(ChatColor.GREEN + "Discovery cleared.");
|
||||||
@@ -265,39 +263,34 @@ public class RPGRegionsCommand extends BaseCommand {
|
|||||||
sender.sendMessage(ChatColor.RED + "Region does not exist or is not configured.");
|
sender.sendMessage(ChatColor.RED + "Region does not exist or is not configured.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
default -> sender.sendMessage(ChatColor.RED + "Usage: /rpgregions reset <player> [region_id]");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("delete")
|
|
||||||
|
@CommandDescription("Deletes user accounts from the database")
|
||||||
@CommandPermission("rpgregions.delete")
|
@CommandPermission("rpgregions.delete")
|
||||||
@CommandCompletion("@players")
|
@CommandMethod("rpgregions|rpgr delete <player>")
|
||||||
public void onDelete(CommandSender sender, Player player) {
|
public void onDelete(CommandSender sender,
|
||||||
if (player != null) {
|
@Argument("player") @NotNull OfflinePlayer player) {
|
||||||
plugin.getManagers().getStorageManager().deleteAccount(player.getUniqueId());
|
plugin.getManagers().getStorageManager().deleteAccount(player.getUniqueId());
|
||||||
sender.sendMessage(ChatColor.GREEN + "Deleted account of player.");
|
sender.sendMessage(ChatColor.GREEN + "Deleted account of player.");
|
||||||
} else {
|
|
||||||
sender.sendMessage(ChatColor.RED + "That player cannot be found.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("setlocation")
|
@CommandDescription("Sets the teleport location of a region")
|
||||||
@CommandPermission("rpgregions.setlocation")
|
@CommandPermission("rpgregions.setlocation")
|
||||||
@CommandCompletion("@regions")
|
@CommandMethod("rpgregions|rpgr setlocation <region>")
|
||||||
public void onSetLocation(Player player, ConfiguredRegion configuredRegion) {
|
public void onSetLocation(Player player,
|
||||||
if (configuredRegion != null) {
|
@Argument("region") ConfiguredRegion region) {
|
||||||
Location location = player.getLocation();
|
Location location = player.getLocation();
|
||||||
configuredRegion.setLocation(location);
|
region.setLocation(location);
|
||||||
player.sendMessage(ChatColor.GREEN + "Location has been updated.");
|
player.sendMessage(ChatColor.GREEN + "Location has been updated.");
|
||||||
} else {
|
|
||||||
player.sendMessage(StringUtils.colour("&cA region by that name is not yet configured."));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("regenerate|regen")
|
//TODO: use confirmation api
|
||||||
|
@CommandDescription("If configured, regenerates a region to the set schematic")
|
||||||
@CommandPermission("rpgregions.regenerate")
|
@CommandPermission("rpgregions.regenerate")
|
||||||
@CommandCompletion("@regions")
|
@CommandMethod("rpgregions|rpgr regenerate <region>")
|
||||||
public void onRegenerate(Player player, ConfiguredRegion configuredRegion) {
|
public void onRegenerate(Player player,
|
||||||
|
@Argument("region") ConfiguredRegion region) {
|
||||||
IntegrationType integrationType = IntegrationType.valueOf(plugin.getConfig().getString("settings.integration.name").toUpperCase());
|
IntegrationType integrationType = IntegrationType.valueOf(plugin.getConfig().getString("settings.integration.name").toUpperCase());
|
||||||
if (integrationType != IntegrationType.WORLDGUARD) {
|
if (integrationType != IntegrationType.WORLDGUARD) {
|
||||||
player.sendMessage(ChatColor.RED + "Regeneration only supports WorldGuard integrations.");
|
player.sendMessage(ChatColor.RED + "Regeneration only supports WorldGuard integrations.");
|
||||||
@@ -306,13 +299,13 @@ public class RPGRegionsCommand extends BaseCommand {
|
|||||||
|
|
||||||
if (!regenerateConfirm.contains(player.getUniqueId())) {
|
if (!regenerateConfirm.contains(player.getUniqueId())) {
|
||||||
regenerateConfirm.add(player.getUniqueId());
|
regenerateConfirm.add(player.getUniqueId());
|
||||||
player.sendMessage(ChatColor.YELLOW + "Run /rpgregions regenerate " + configuredRegion.getId() + " again to confirm. Only use if you know what you are doing!");
|
player.sendMessage(ChatColor.YELLOW + "Run /rpgregions regenerate " + region.getId() + " again to confirm. Only use if you know what you are doing!");
|
||||||
player.sendMessage(WARNING_MESSAGE);
|
player.sendMessage(WARNING_MESSAGE);
|
||||||
} else {
|
} else {
|
||||||
regenerateConfirm.remove(player.getUniqueId());
|
regenerateConfirm.remove(player.getUniqueId());
|
||||||
player.sendMessage(ChatColor.GREEN + "Regenerating region...");
|
player.sendMessage(ChatColor.GREEN + "Regenerating region...");
|
||||||
long startTime = System.currentTimeMillis();
|
long startTime = System.currentTimeMillis();
|
||||||
boolean done = RegenUtils.regenerate(configuredRegion);
|
boolean done = RegenUtils.regenerate(region);
|
||||||
if (!done) {
|
if (!done) {
|
||||||
player.sendMessage(ChatColor.RED + "Unable to regenerate region. Check console for details.");
|
player.sendMessage(ChatColor.RED + "Unable to regenerate region. Check console for details.");
|
||||||
}
|
}
|
||||||
@@ -322,28 +315,30 @@ public class RPGRegionsCommand extends BaseCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("setschematic")
|
@CommandDescription("Sets the regeneration schematic for a region")
|
||||||
@CommandPermission("rpgregions.setschematic")
|
@CommandPermission("rpgregions.setschematic")
|
||||||
@CommandCompletion("@regions @schematics @nothing")
|
@CommandMethod("rpgregions|rpgr setschematic <region> <schematicName>")
|
||||||
public void onAddSchematic(Player player, ConfiguredRegion configuredRegion, String schematicName) {
|
public void onAddSchematic(Player player,
|
||||||
|
@Argument("region") ConfiguredRegion region,
|
||||||
|
@Argument("schematicName") String schematicName) {
|
||||||
IntegrationType integrationType = IntegrationType.valueOf(plugin.getConfig().getString("settings.integration.name").toUpperCase());
|
IntegrationType integrationType = IntegrationType.valueOf(plugin.getConfig().getString("settings.integration.name").toUpperCase());
|
||||||
if (integrationType != IntegrationType.WORLDGUARD) {
|
if (integrationType != IntegrationType.WORLDGUARD) {
|
||||||
player.sendMessage(ChatColor.RED + "Regeneration only supports WorldGuard integrations.");
|
player.sendMessage(ChatColor.RED + "Regeneration only supports WorldGuard integrations.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (configuredRegion != null) {
|
if (region != null) {
|
||||||
if (!regenerateConfirm.contains(player.getUniqueId())) {
|
if (!regenerateConfirm.contains(player.getUniqueId())) {
|
||||||
regenerateConfirm.add(player.getUniqueId());
|
regenerateConfirm.add(player.getUniqueId());
|
||||||
player.sendMessage(ChatColor.YELLOW + "Run /rpgregions addschematic " + schematicName + " again to confirm. Only use if you know what you are doing!");
|
player.sendMessage(ChatColor.YELLOW + "Run /rpgregions addschematic " + schematicName + " again to confirm. Only use if you know what you are doing!");
|
||||||
player.sendMessage(ChatColor.RED + "MAKE SURE YOU ARE STANDING WHERE YOU CREATED THE SCHEMATIC ORIGINALLY (//copy, //schematic save), OTHERWISE IT WILL NOT PASTE CORRECTLY.");
|
player.sendMessage(ChatColor.RED + "MAKE SURE YOU ARE STANDING WHERE YOU CREATED THE SCHEMATIC ORIGINALLY (//copy, //schematic save), OTHERWISE IT WILL NOT PASTE CORRECTLY.");
|
||||||
} else {
|
} else {
|
||||||
regenerateConfirm.remove(player.getUniqueId());
|
regenerateConfirm.remove(player.getUniqueId());
|
||||||
Regenerate regenerate = configuredRegion.getRegenerate();
|
Regenerate regenerate = region.getRegenerate();
|
||||||
if (regenerate == null) regenerate = new Regenerate(Integer.MAX_VALUE, false, new ArrayList<>());
|
if (regenerate == null) regenerate = new Regenerate(Integer.MAX_VALUE, false, new ArrayList<>());
|
||||||
regenerate.setSchematicName(schematicName);
|
regenerate.setSchematicName(schematicName);
|
||||||
regenerate.setOrigin(player.getLocation());
|
regenerate.setOrigin(player.getLocation());
|
||||||
configuredRegion.setRegenerate(regenerate);
|
region.setRegenerate(regenerate);
|
||||||
player.sendMessage(ChatColor.GREEN + "This region has had a regenerate section added, and schematicName set to " + schematicName + " and origin set to " + player.getLocation() + ".");
|
player.sendMessage(ChatColor.GREEN + "This region has had a regenerate section added, and schematicName set to " + schematicName + " and origin set to " + player.getLocation() + ".");
|
||||||
player.sendMessage(ChatColor.YELLOW + "Run /rpgregions save and " + ChatColor.BOLD + "CONFIGURE BEFORE RELOADING OR RESTARTING THE SERVER.");
|
player.sendMessage(ChatColor.YELLOW + "Run /rpgregions save and " + ChatColor.BOLD + "CONFIGURE BEFORE RELOADING OR RESTARTING THE SERVER.");
|
||||||
}
|
}
|
||||||
@@ -351,8 +346,9 @@ public class RPGRegionsCommand extends BaseCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("forceupdateicons")
|
@CommandDescription("Resets the icons of all configured regions to the config default")
|
||||||
@CommandPermission("rpgregions.forceupdate")
|
@CommandPermission("rpgregions.forceupdate")
|
||||||
|
@CommandMethod("rpgregions|rpgr forceupdateicons")
|
||||||
public void onForceUpdateIcons(Player player) {
|
public void onForceUpdateIcons(Player player) {
|
||||||
Optional<Material> defaultIcon = Optional.of(Material.valueOf(RPGRegionsAPI.getAPI().getConfig().getString("settings.server.gui.default_region_icon")));
|
Optional<Material> defaultIcon = Optional.of(Material.valueOf(RPGRegionsAPI.getAPI().getConfig().getString("settings.server.gui.default_region_icon")));
|
||||||
defaultIcon.ifPresent(xMaterial -> {
|
defaultIcon.ifPresent(xMaterial -> {
|
||||||
|
|||||||
@@ -1,10 +1,8 @@
|
|||||||
package net.islandearth.rpgregions.commands;
|
package net.islandearth.rpgregions.commands;
|
||||||
|
|
||||||
import co.aikar.commands.BaseCommand;
|
import cloud.commandframework.annotations.Argument;
|
||||||
import co.aikar.commands.annotation.CommandAlias;
|
import cloud.commandframework.annotations.CommandMethod;
|
||||||
import co.aikar.commands.annotation.CommandPermission;
|
import cloud.commandframework.annotations.CommandPermission;
|
||||||
import co.aikar.commands.annotation.Default;
|
|
||||||
import co.aikar.commands.annotation.Subcommand;
|
|
||||||
import co.aikar.idb.DB;
|
import co.aikar.idb.DB;
|
||||||
import co.aikar.idb.Database;
|
import co.aikar.idb.Database;
|
||||||
import net.islandearth.rpgregions.RPGRegions;
|
import net.islandearth.rpgregions.RPGRegions;
|
||||||
@@ -15,14 +13,14 @@ import net.islandearth.rpgregions.rewards.DiscoveryReward;
|
|||||||
import net.islandearth.rpgregions.thread.Blocking;
|
import net.islandearth.rpgregions.thread.Blocking;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|
||||||
@CommandAlias("rpgregionsdebug|rpgrd")
|
|
||||||
@CommandPermission("rpgregions.debug")
|
@CommandPermission("rpgregions.debug")
|
||||||
public class RPGRegionsDebugCommand extends BaseCommand {
|
public class RPGRegionsDebugCommand {
|
||||||
|
|
||||||
private final RPGRegions plugin;
|
private final RPGRegions plugin;
|
||||||
|
|
||||||
@@ -30,7 +28,7 @@ public class RPGRegionsDebugCommand extends BaseCommand {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Default
|
@CommandMethod("rpgregionsdebug|rpgrd")
|
||||||
public void onDefault(CommandSender sender) throws SQLException {
|
public void onDefault(CommandSender sender) throws SQLException {
|
||||||
IStorageManager storageManager = plugin.getManagers().getStorageManager();
|
IStorageManager storageManager = plugin.getManagers().getStorageManager();
|
||||||
sender.sendMessage(ChatColor.GOLD + "Database status:");
|
sender.sendMessage(ChatColor.GOLD + "Database status:");
|
||||||
@@ -67,8 +65,7 @@ public class RPGRegionsDebugCommand extends BaseCommand {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@CommandMethod("rpgregionsdebug|rpgrd enable|disable|toggle")
|
||||||
@Subcommand("enable|disable")
|
|
||||||
public void onEnable(CommandSender sender) {
|
public void onEnable(CommandSender sender) {
|
||||||
final boolean newValue = !plugin.debug();
|
final boolean newValue = !plugin.debug();
|
||||||
plugin.getConfig().set("settings.dev.debug", newValue);
|
plugin.getConfig().set("settings.dev.debug", newValue);
|
||||||
@@ -76,7 +73,7 @@ public class RPGRegionsDebugCommand extends BaseCommand {
|
|||||||
else sender.sendMessage(ChatColor.RED + "Debug disabled.");
|
else sender.sendMessage(ChatColor.RED + "Debug disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("cache")
|
@CommandMethod("rpgregionsdebug|rpgrd cache")
|
||||||
public void onCache(CommandSender sender) {
|
public void onCache(CommandSender sender) {
|
||||||
IStorageManager storageManager = plugin.getManagers().getStorageManager();
|
IStorageManager storageManager = plugin.getManagers().getStorageManager();
|
||||||
sender.sendMessage(ChatColor.GOLD + "Database cache:");
|
sender.sendMessage(ChatColor.GOLD + "Database cache:");
|
||||||
@@ -84,4 +81,13 @@ public class RPGRegionsDebugCommand extends BaseCommand {
|
|||||||
sender.sendMessage(ChatColor.GRAY + " - " + uuid.toString());
|
sender.sendMessage(ChatColor.GRAY + " - " + uuid.toString());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@CommandMethod("rpgregionsdebug|rpgrd removecached <player>")
|
||||||
|
public void onRemoveCached(CommandSender sender, @Argument("player") OfflinePlayer player) {
|
||||||
|
IStorageManager storageManager = plugin.getManagers().getStorageManager();
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Removing from cache...");
|
||||||
|
storageManager.removeCachedAccount(player.getUniqueId()).thenAccept((a) -> {
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Successfully removed and saved " + player.getName() + "'s account from the cache.");
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,11 @@
|
|||||||
package net.islandearth.rpgregions.commands;
|
package net.islandearth.rpgregions.commands;
|
||||||
|
|
||||||
import co.aikar.commands.BaseCommand;
|
import cloud.commandframework.annotations.Argument;
|
||||||
import co.aikar.commands.CommandHelp;
|
import cloud.commandframework.annotations.CommandDescription;
|
||||||
import co.aikar.commands.annotation.CommandAlias;
|
import cloud.commandframework.annotations.CommandMethod;
|
||||||
import co.aikar.commands.annotation.CommandCompletion;
|
import cloud.commandframework.annotations.specifier.Greedy;
|
||||||
import co.aikar.commands.annotation.CommandPermission;
|
import cloud.commandframework.minecraft.extras.MinecraftHelp;
|
||||||
import co.aikar.commands.annotation.Default;
|
import cloud.commandframework.paper.PaperCommandManager;
|
||||||
import co.aikar.commands.annotation.HelpCommand;
|
|
||||||
import co.aikar.commands.annotation.Subcommand;
|
|
||||||
import net.islandearth.rpgregions.RPGRegions;
|
import net.islandearth.rpgregions.RPGRegions;
|
||||||
import net.islandearth.rpgregions.effects.RegionEffect;
|
import net.islandearth.rpgregions.effects.RegionEffect;
|
||||||
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
||||||
@@ -15,36 +13,42 @@ import net.islandearth.rpgregions.requirements.RegionRequirement;
|
|||||||
import net.islandearth.rpgregions.rewards.DiscoveryReward;
|
import net.islandearth.rpgregions.rewards.DiscoveryReward;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@CommandAlias("rpgre")
|
public class RPGRegionsExportCommand {
|
||||||
@CommandPermission("rpgregions.export")
|
|
||||||
public class RPGRegionsExportCommand extends BaseCommand {
|
|
||||||
|
|
||||||
private final RPGRegions plugin;
|
private final RPGRegions plugin;
|
||||||
|
private final MinecraftHelp<CommandSender> help;
|
||||||
|
|
||||||
public RPGRegionsExportCommand(RPGRegions plugin) {
|
public RPGRegionsExportCommand(RPGRegions plugin, PaperCommandManager<CommandSender> manager) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.help = new MinecraftHelp<>(
|
||||||
|
"/rpgre help",
|
||||||
|
player -> plugin.adventure().sender(player),
|
||||||
|
manager
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Default
|
@CommandDescription("The default RPGRegions export command.")
|
||||||
|
@CommandMethod("rpgre")
|
||||||
public void onDefault(CommandSender sender) {
|
public void onDefault(CommandSender sender) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "Use this command to export/import a region template.");
|
sender.sendMessage(ChatColor.GREEN + "Use this command to export/import a region template.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@HelpCommand
|
@CommandMethod("rpgre help [query]")
|
||||||
@Subcommand("help")
|
public void onHelp(final CommandSender sender, @Argument("query") @Greedy @Nullable String query) {
|
||||||
public void onHelp(final CommandHelp commandHelp) {
|
help.queryCommands(query == null ? "" : query, sender);
|
||||||
commandHelp.showHelp();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("export")
|
@CommandDescription("Exports a region to a template file (`plugins/RPGRegions/templates`).")
|
||||||
@CommandCompletion("@regions")
|
@CommandMethod("rpgre export <region>")
|
||||||
public void onExport(CommandSender sender, ConfiguredRegion region) {
|
public void onExport(CommandSender sender,
|
||||||
|
@Argument("region") ConfiguredRegion region) {
|
||||||
File templates = new File(plugin.getDataFolder() + File.separator + "templates");
|
File templates = new File(plugin.getDataFolder() + File.separator + "templates");
|
||||||
File target = new File(templates + File.separator + region.getId() + "_template.json");
|
File target = new File(templates + File.separator + region.getId() + "_template.json");
|
||||||
region.save(plugin, target);
|
region.save(plugin, target);
|
||||||
@@ -53,9 +57,13 @@ public class RPGRegionsExportCommand extends BaseCommand {
|
|||||||
sender.sendMessage(ChatColor.YELLOW + "You may use /rpgre import " + region.getId() + " <target> to import the requirements, rewards, etc. of this template to the target region.");
|
sender.sendMessage(ChatColor.YELLOW + "You may use /rpgre import " + region.getId() + " <target> to import the requirements, rewards, etc. of this template to the target region.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("import")
|
@CommandDescription("Imports a template region into an existing configured region")
|
||||||
@CommandCompletion("@templates @regions")
|
@CommandMethod("rpgre import <template> <region>")
|
||||||
public void onImport(CommandSender sender, String template, ConfiguredRegion region) {
|
public void onImport(CommandSender sender,
|
||||||
|
@Argument(value = "template",
|
||||||
|
suggestions = "templates",
|
||||||
|
description = "The name of the template file") String template,
|
||||||
|
@Argument("region") ConfiguredRegion region) {
|
||||||
File templateFile = new File(plugin.getDataFolder() + File.separator + "templates" + File.separator + template);
|
File templateFile = new File(plugin.getDataFolder() + File.separator + "templates" + File.separator + template);
|
||||||
if (!templateFile.exists()) {
|
if (!templateFile.exists()) {
|
||||||
sender.sendMessage(ChatColor.RED + "That template does not exist.");
|
sender.sendMessage(ChatColor.RED + "That template does not exist.");
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
package net.islandearth.rpgregions.commands;
|
package net.islandearth.rpgregions.commands;
|
||||||
|
|
||||||
import co.aikar.commands.BaseCommand;
|
import cloud.commandframework.annotations.Argument;
|
||||||
import co.aikar.commands.CommandHelp;
|
import cloud.commandframework.annotations.CommandDescription;
|
||||||
import co.aikar.commands.annotation.CommandAlias;
|
import cloud.commandframework.annotations.CommandMethod;
|
||||||
import co.aikar.commands.annotation.CommandCompletion;
|
import cloud.commandframework.annotations.CommandPermission;
|
||||||
import co.aikar.commands.annotation.CommandPermission;
|
import cloud.commandframework.annotations.specifier.Greedy;
|
||||||
import co.aikar.commands.annotation.Default;
|
import cloud.commandframework.minecraft.extras.MinecraftHelp;
|
||||||
import co.aikar.commands.annotation.HelpCommand;
|
import cloud.commandframework.paper.PaperCommandManager;
|
||||||
import co.aikar.commands.annotation.Subcommand;
|
|
||||||
import net.islandearth.rpgregions.RPGRegions;
|
import net.islandearth.rpgregions.RPGRegions;
|
||||||
import net.islandearth.rpgregions.api.integrations.rpgregions.RPGRegionsIntegration;
|
import net.islandearth.rpgregions.api.integrations.rpgregions.RPGRegionsIntegration;
|
||||||
import net.islandearth.rpgregions.api.integrations.rpgregions.region.CuboidRegion;
|
import net.islandearth.rpgregions.api.integrations.rpgregions.region.CuboidRegion;
|
||||||
@@ -24,63 +23,66 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
@CommandAlias("rpgri|rpgrintegration")
|
|
||||||
@CommandPermission("rpgregions.integration")
|
@CommandPermission("rpgregions.integration")
|
||||||
public class RPGRegionsIntegrationCommand extends BaseCommand {
|
public class RPGRegionsIntegrationCommand {
|
||||||
|
|
||||||
private final RPGRegions plugin;
|
private final RPGRegions plugin;
|
||||||
|
private final MinecraftHelp<CommandSender> help;
|
||||||
|
|
||||||
public RPGRegionsIntegrationCommand(final RPGRegions plugin) {
|
public RPGRegionsIntegrationCommand(final RPGRegions plugin, PaperCommandManager<CommandSender> manager) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
this.help = new MinecraftHelp<>(
|
||||||
|
"/rpgri help",
|
||||||
|
player -> plugin.adventure().sender(player),
|
||||||
|
manager
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Default
|
@CommandDescription("The default RPGRegions integration command.")
|
||||||
|
@CommandMethod("rpgri|rpgrintegration")
|
||||||
public void onDefault(CommandSender sender) {
|
public void onDefault(CommandSender sender) {
|
||||||
sender.sendMessage(ChatColor.GREEN + "RPGRegions region integration is enabled. Type /rpgri help for help.");
|
sender.sendMessage(ChatColor.GREEN + "RPGRegions region integration is enabled. Type /rpgri help for help.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@HelpCommand
|
@CommandMethod("rpgri|rpgrintegration help [query]")
|
||||||
@Subcommand("help")
|
public void onHelp(final CommandSender sender, @Argument("query") @Greedy @Nullable String query) {
|
||||||
public void onHelp(final CommandHelp commandHelp) {
|
help.queryCommands(query == null ? "" : query, sender);
|
||||||
commandHelp.showHelp();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("list")
|
@CommandDescription("Lists all existing regions in the integration")
|
||||||
|
@CommandMethod("rpgri|rpgrintegration list")
|
||||||
public void onList(final CommandSender sender) {
|
public void onList(final CommandSender sender) {
|
||||||
RPGRegionsIntegration integration = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
RPGRegionsIntegration integration = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
||||||
integration.getAllRegionNames(null).forEach(name -> sender.sendMessage(ChatColor.GREEN + "- " + name));
|
integration.getAllRegionNames(null).forEach(name -> sender.sendMessage(ChatColor.GREEN + "- " + name));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("info")
|
@CommandDescription("Shows information about a region")
|
||||||
@CommandCompletion("@integration-regions")
|
@CommandMethod("rpgri|rpgrintegration info <region>")
|
||||||
public void onInfo(final CommandSender sender, final String name) {
|
public void onInfo(final CommandSender sender,
|
||||||
RPGRegionsIntegration integration = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
@Argument(value = "region") final RPGRegionsRegion region) {
|
||||||
Optional<RPGRegionsRegion> region = integration.getRegion(name);
|
sender.sendMessage(ChatColor.GREEN + "Name: " + ChatColor.WHITE + region.getName());
|
||||||
if (region.isPresent()) {
|
sender.sendMessage(ChatColor.GREEN + "Priority: " + ChatColor.WHITE + region.getPriority());
|
||||||
sender.sendMessage(ChatColor.GREEN + "Name: " + ChatColor.WHITE + region.get().getName());
|
sender.sendMessage(ChatColor.GREEN + "Points for " + region.getName() + ":");
|
||||||
sender.sendMessage(ChatColor.GREEN + "Priority: " + ChatColor.WHITE + region.get().getPriority());
|
region.getPoints().forEach(point -> sender.sendMessage(" " + point.toString()));
|
||||||
sender.sendMessage(ChatColor.GREEN + "Points for " + region.get().getName() + ":");
|
|
||||||
region.get().getPoints().forEach(point -> sender.sendMessage(" " + point.toString()));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sender.sendMessage(ChatColor.RED + "Region " + name + " does not exist!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("save")
|
@CommandDescription("Saves all regions")
|
||||||
|
@CommandMethod("rpgri|rpgrintegration save")
|
||||||
public void onSave(final CommandSender sender) {
|
public void onSave(final CommandSender sender) {
|
||||||
RPGRegionsIntegration integration = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
RPGRegionsIntegration integration = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
||||||
integration.save();
|
integration.save();
|
||||||
sender.sendMessage(ChatColor.GREEN + "Regions saved.");
|
sender.sendMessage(ChatColor.GREEN + "Regions saved.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("create")
|
@CommandDescription("Creates a region of the specified name, type, and optionally the world it is in.")
|
||||||
@CommandCompletion("@integration-regions @region-types @worlds")
|
@CommandMethod("rpgri|rpgrintegration create <name> <type> <world>")
|
||||||
public void onCreate(final CommandSender sender, final String name, final String regionType,
|
public void onCreate(final CommandSender sender,
|
||||||
@co.aikar.commands.annotation.Optional @Nullable String worldName) {
|
@Argument("name") final String name,
|
||||||
|
@Argument(value = "type", suggestions = "region-types") final String regionType,
|
||||||
|
@Argument("world") @Nullable World argWorld) {
|
||||||
// If worldName is null, try to get from sender if they are a player, else overworld, else worldName world
|
// If worldName is null, try to get from sender if they are a player, else overworld, else worldName world
|
||||||
World world = worldName == null ? sender instanceof Player player ? player.getWorld() : Bukkit.getWorlds().get(0) : Bukkit.getWorld(worldName);
|
World world = argWorld == null ? sender instanceof Player player ? player.getWorld() : Bukkit.getWorlds().get(0) : argWorld;
|
||||||
RPGRegionsRegion region = switch (regionType.toLowerCase(Locale.ENGLISH)) {
|
RPGRegionsRegion region = switch (regionType.toLowerCase(Locale.ENGLISH)) {
|
||||||
case "cuboid" -> new CuboidRegion(name, world);
|
case "cuboid" -> new CuboidRegion(name, world);
|
||||||
case "poly" -> new PolyRegion(name, world);
|
case "poly" -> new PolyRegion(name, world);
|
||||||
@@ -92,7 +94,7 @@ public class RPGRegionsIntegrationCommand extends BaseCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (worldName == null && !(sender instanceof Player)) {
|
if (argWorld == null && !(sender instanceof Player)) {
|
||||||
sender.sendMessage(ChatColor.YELLOW + "WARNING: World name was not provided and you are not a player. Defaulted to '" + world.getName() + "'.");
|
sender.sendMessage(ChatColor.YELLOW + "WARNING: World name was not provided and you are not a player. Defaulted to '" + world.getName() + "'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -101,66 +103,63 @@ public class RPGRegionsIntegrationCommand extends BaseCommand {
|
|||||||
sender.sendMessage(ChatColor.GREEN + "Created region " + name + ".");
|
sender.sendMessage(ChatColor.GREEN + "Created region " + name + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("delete")
|
@CommandDescription("Deletes a region.")
|
||||||
@CommandCompletion("@integration-regions")
|
@CommandMethod("rpgri|rpgrintegration delete <region>")
|
||||||
public void onDelete(final CommandSender sender, final RPGRegionsRegion region) {
|
public void onDelete(final CommandSender sender,
|
||||||
|
@Argument("region") final RPGRegionsRegion region) {
|
||||||
RPGRegionsIntegration integration = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
RPGRegionsIntegration integration = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
||||||
integration.removeRegion(region);
|
integration.removeRegion(region);
|
||||||
sender.sendMessage(ChatColor.GREEN + "Region " + region.getName() + " has been removed.");
|
sender.sendMessage(ChatColor.GREEN + "Region " + region.getName() + " has been removed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("addpos")
|
@CommandDescription("Adds a position to a region. Cuboid regions require 2 points to form a cuboid. Poly regions may have any number.")
|
||||||
@CommandCompletion("@integration-regions")
|
@CommandMethod("rpgri|rpgrintegration addpos <region> [location]")
|
||||||
public void onAddPos(final CommandSender sender, final RPGRegionsRegion region,
|
public void onAddPos(final CommandSender sender,
|
||||||
@co.aikar.commands.annotation.Optional World world,
|
@Argument("region") final RPGRegionsRegion region,
|
||||||
@co.aikar.commands.annotation.Optional Double x,
|
@Argument("location") @Nullable Location location) {
|
||||||
@co.aikar.commands.annotation.Optional Double y,
|
if (sender instanceof Player player && location == null) {
|
||||||
@co.aikar.commands.annotation.Optional Double z) {
|
|
||||||
System.out.println("world: " + world + ", x:" + x + ", y:" + y + ", z:" + z);
|
|
||||||
if (sender instanceof Player player && x == null && y == null && z == null) {
|
|
||||||
if (!region.addPoint(player.getLocation())) {
|
if (!region.addPoint(player.getLocation())) {
|
||||||
player.sendMessage(ChatColor.RED + "Could not add a point to that region because it exceeds the size for its type.");
|
player.sendMessage(ChatColor.RED + "Could not add a point to that region because it exceeds the size for its type.");
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(ChatColor.GREEN + "Added point to " + region.getName() + ".");
|
player.sendMessage(ChatColor.GREEN + "Added point to " + region.getName() + ".");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (world == null || x == null || y == null || z == null) {
|
if (location == null) {
|
||||||
sender.sendMessage(ChatColor.RED + "You need to specify the world, x, y, z of the point.");
|
sender.sendMessage(ChatColor.RED + "You need to specify the world, x, y, z of the point.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location location = new Location(world, x, y, z);
|
|
||||||
region.addPoint(location);
|
region.addPoint(location);
|
||||||
sender.sendMessage(ChatColor.GREEN + "Added point to " + region.getName() + ".");
|
sender.sendMessage(ChatColor.GREEN + "Added point to " + region.getName() + ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("setpriority")
|
@CommandDescription("Sets the priority of a region. Higher priority regions override lower priority ones in the same location.")
|
||||||
@CommandCompletion("@integration-regions @range:20")
|
@CommandMethod("rpgri|rpgrintegration setpriority <region> <priority>")
|
||||||
public void onSetPriority(final Player player, final RPGRegionsRegion region, final int priority) {
|
public void onSetPriority(final Player player,
|
||||||
|
@Argument("region") final RPGRegionsRegion region,
|
||||||
|
@Argument("priority") final int priority) {
|
||||||
region.setPriority(priority);
|
region.setPriority(priority);
|
||||||
player.sendMessage(ChatColor.GREEN + "Set priority of " + region.getName() + " to " + priority + ".");
|
player.sendMessage(ChatColor.GREEN + "Set priority of " + region.getName() + " to " + priority + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("setworld")
|
@CommandDescription("Sets the world a region is in.")
|
||||||
@CommandCompletion("@integration-regions @worlds")
|
@CommandMethod("rpgri|rpgrintegration setworld <region> <world>")
|
||||||
public void onSetWorld(final CommandSender sender, final RPGRegionsRegion region, final String worldName) {
|
public void onSetWorld(final CommandSender sender,
|
||||||
final World world = Bukkit.getWorld(worldName);
|
@Argument("region") final RPGRegionsRegion region,
|
||||||
if (world == null) {
|
@Argument("world") final World world) {
|
||||||
sender.sendMessage(ChatColor.RED + "That world could not be found.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
region.setWorld(world.getUID());
|
region.setWorld(world.getUID());
|
||||||
sender.sendMessage(ChatColor.GREEN + "Set region '" + region.getName() + "' world to '" + world.getName() + "'.");
|
sender.sendMessage(ChatColor.GREEN + "Set region '" + region.getName() + "' world to '" + world.getName() + "'.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("visualise")
|
@CommandDescription("Visualises the boundaries of a region.")
|
||||||
@CommandCompletion("@integration-regions")
|
@CommandMethod("rpgri|rpgrintegration visualise <region>")
|
||||||
public void onVisualise(final Player sender, final RPGRegionsRegion region) {
|
public void onVisualise(final Player sender, @Argument("region") final RPGRegionsRegion region) {
|
||||||
region.visualise(sender);
|
region.visualise(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("whereami")
|
@CommandDescription("Tells you what region you are in.")
|
||||||
|
@CommandMethod("rpgri|rpgrintegration whereami")
|
||||||
public void onWhereAmI(final Player sender) {
|
public void onWhereAmI(final Player sender) {
|
||||||
final RPGRegionsIntegration manager = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
final RPGRegionsIntegration manager = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
||||||
List<RPGRegionsRegion> regions = new ArrayList<>();
|
List<RPGRegionsRegion> regions = new ArrayList<>();
|
||||||
@@ -180,20 +179,15 @@ public class RPGRegionsIntegrationCommand extends BaseCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("migrate")
|
@CommandDescription("Migrates all regions to a world.")
|
||||||
@CommandCompletion("@worlds")
|
@CommandMethod("rpgri|rpgrintegration migrate <world>")
|
||||||
public void onMigrate(final CommandSender sender, final String worldName) {
|
public void onMigrate(final CommandSender sender,
|
||||||
final World world = Bukkit.getWorld(worldName);
|
@Argument("world") final World world) {
|
||||||
if (world == null) {
|
|
||||||
sender.sendMessage(ChatColor.RED + "That world could not be found.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
RPGRegionsIntegration integration = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
RPGRegionsIntegration integration = (RPGRegionsIntegration) plugin.getManagers().getIntegrationManager();
|
||||||
for (RPGRegionsRegion region : integration.getRegions()) {
|
for (RPGRegionsRegion region : integration.getRegions()) {
|
||||||
region.setWorld(world.getUID());
|
region.setWorld(world.getUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
sender.sendMessage(ChatColor.GREEN + "Set all regions to world '" + worldName + "'.");
|
sender.sendMessage(ChatColor.GREEN + "Set all regions to world '" + world.getName() + "'.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package net.islandearth.rpgregions.commands.caption;
|
||||||
|
|
||||||
|
import cloud.commandframework.captions.Caption;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
public class RPGRegionsCaptionKeys {
|
||||||
|
|
||||||
|
private static final Collection<Caption> RECOGNIZED_CAPTIONS = new LinkedList<>();
|
||||||
|
|
||||||
|
public static final Caption ARGUMENT_PARSE_FAILURE_REGION_NOT_FOUND = of("argument.parse.failure.region_not_found");
|
||||||
|
|
||||||
|
private RPGRegionsCaptionKeys() { }
|
||||||
|
|
||||||
|
private static @NonNull Caption of(final @NonNull String key) {
|
||||||
|
final Caption caption = Caption.of(key);
|
||||||
|
RECOGNIZED_CAPTIONS.add(caption);
|
||||||
|
return caption;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get an immutable collection containing all standard caption keys
|
||||||
|
*
|
||||||
|
* @return Immutable collection of keys
|
||||||
|
*/
|
||||||
|
public static @NonNull Collection<@NonNull Caption> getStandardCaptionKeys() {
|
||||||
|
return Collections.unmodifiableCollection(RECOGNIZED_CAPTIONS);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package net.islandearth.rpgregions.commands.caption;
|
||||||
|
|
||||||
|
import cloud.commandframework.bukkit.BukkitCaptionRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Caption registry that uses bi-functions to produce messages
|
||||||
|
*
|
||||||
|
* @param <C> Command sender type
|
||||||
|
*/
|
||||||
|
public class RPGRegionsCaptionRegistry<C> extends BukkitCaptionRegistry<C> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Default caption for {@link RPGRegionsCaptionKeys#ARGUMENT_PARSE_FAILURE_REGION_NOT_FOUND}.
|
||||||
|
*/
|
||||||
|
public static final String ARGUMENT_PARSE_FAILURE_REGION_NOT_FOUND = "Could not find region '{input}'";
|
||||||
|
|
||||||
|
protected RPGRegionsCaptionRegistry() {
|
||||||
|
super();
|
||||||
|
this.registerMessageFactory(
|
||||||
|
RPGRegionsCaptionKeys.ARGUMENT_PARSE_FAILURE_REGION_NOT_FOUND,
|
||||||
|
(caption, sender) -> ARGUMENT_PARSE_FAILURE_REGION_NOT_FOUND
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package net.islandearth.rpgregions.commands.caption;
|
||||||
|
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
|
||||||
|
public final class RPGRegionsCaptionRegistryFactory<C> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new RPGRegions caption registry instance
|
||||||
|
*
|
||||||
|
* @return Created instance
|
||||||
|
*/
|
||||||
|
public @NonNull RPGRegionsCaptionRegistry<C> create() {
|
||||||
|
return new RPGRegionsCaptionRegistry<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
package net.islandearth.rpgregions.commands.parser;
|
||||||
|
|
||||||
|
import cloud.commandframework.arguments.CommandArgument;
|
||||||
|
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||||
|
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||||
|
import cloud.commandframework.captions.CaptionVariable;
|
||||||
|
import cloud.commandframework.context.CommandContext;
|
||||||
|
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||||
|
import cloud.commandframework.exceptions.parsing.ParserException;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
||||||
|
import net.islandearth.rpgregions.commands.caption.RPGRegionsCaptionKeys;
|
||||||
|
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
public final class ConfiguredRegionArgument<C> extends CommandArgument<C, ConfiguredRegion> {
|
||||||
|
|
||||||
|
public ConfiguredRegionArgument(
|
||||||
|
final boolean required,
|
||||||
|
final @NonNull String name,
|
||||||
|
final @NonNull String defaultValue,
|
||||||
|
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String, @NonNull List<@NonNull String>> suggestionsProvider) {
|
||||||
|
super(required, name, new ConfiguredRegionArgument.ConfiguredRegionParser<>(), defaultValue, ConfiguredRegion.class, suggestionsProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <C> ConfiguredRegionArgument.Builder<C> newBuilder(final @NonNull String name) {
|
||||||
|
return new ConfiguredRegionArgument.Builder<>(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder<C> extends CommandArgument.Builder<C, ConfiguredRegion> {
|
||||||
|
|
||||||
|
private Builder(final @NonNull String name) {
|
||||||
|
super(ConfiguredRegion.class, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull CommandArgument<C, ConfiguredRegion> build() {
|
||||||
|
return new ConfiguredRegionArgument<>(
|
||||||
|
this.isRequired(),
|
||||||
|
this.getName(),
|
||||||
|
this.getDefaultValue(),
|
||||||
|
this.getSuggestionsProvider()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class ConfiguredRegionParser<C> implements ArgumentParser<C, ConfiguredRegion> {
|
||||||
|
@Override
|
||||||
|
public @NonNull ArgumentParseResult<ConfiguredRegion> parse(
|
||||||
|
@NonNull CommandContext<@NonNull C> commandContext,
|
||||||
|
@NonNull Queue<@NonNull String> inputQueue) {
|
||||||
|
final String input = inputQueue.peek();
|
||||||
|
if (input == null) {
|
||||||
|
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||||
|
ConfiguredRegionArgument.class,
|
||||||
|
commandContext
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
final Optional<ConfiguredRegion> configuredRegion = RPGRegionsAPI.getAPI().getManagers().getRegionsCache().getConfiguredRegion(input);
|
||||||
|
if (configuredRegion.isPresent()) {
|
||||||
|
inputQueue.remove();
|
||||||
|
return ArgumentParseResult.success(configuredRegion.get());
|
||||||
|
}
|
||||||
|
return ArgumentParseResult.failure(new ConfiguredRegionParserException(input, commandContext));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull List<@NonNull String> suggestions(@NonNull CommandContext<C> commandContext, @NonNull String input) {
|
||||||
|
return ImmutableList.copyOf(RPGRegionsAPI.getAPI().getManagers().getRegionsCache().getConfiguredRegions().keySet());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class ConfiguredRegionParserException extends ParserException {
|
||||||
|
|
||||||
|
public ConfiguredRegionParserException(
|
||||||
|
final @NonNull String input,
|
||||||
|
final @NonNull CommandContext<?> context
|
||||||
|
) {
|
||||||
|
super(
|
||||||
|
ConfiguredRegionParser.class,
|
||||||
|
context,
|
||||||
|
RPGRegionsCaptionKeys.ARGUMENT_PARSE_FAILURE_REGION_NOT_FOUND,
|
||||||
|
CaptionVariable.of("input", input)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
package net.islandearth.rpgregions.commands.parser;
|
||||||
|
|
||||||
|
import cloud.commandframework.arguments.CommandArgument;
|
||||||
|
import cloud.commandframework.arguments.parser.ArgumentParseResult;
|
||||||
|
import cloud.commandframework.arguments.parser.ArgumentParser;
|
||||||
|
import cloud.commandframework.captions.CaptionVariable;
|
||||||
|
import cloud.commandframework.context.CommandContext;
|
||||||
|
import cloud.commandframework.exceptions.parsing.NoInputProvidedException;
|
||||||
|
import cloud.commandframework.exceptions.parsing.ParserException;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import net.islandearth.rpgregions.api.RPGRegionsAPI;
|
||||||
|
import net.islandearth.rpgregions.api.integrations.rpgregions.RPGRegionsIntegration;
|
||||||
|
import net.islandearth.rpgregions.api.integrations.rpgregions.region.RPGRegionsRegion;
|
||||||
|
import net.islandearth.rpgregions.commands.caption.RPGRegionsCaptionKeys;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.function.BiFunction;
|
||||||
|
|
||||||
|
public final class IntegrationRegionArgument<C> extends CommandArgument<C, RPGRegionsRegion> {
|
||||||
|
|
||||||
|
public IntegrationRegionArgument(
|
||||||
|
final boolean required,
|
||||||
|
final @NonNull String name,
|
||||||
|
final @NonNull String defaultValue,
|
||||||
|
final @Nullable BiFunction<@NonNull CommandContext<C>, @NonNull String, @NonNull List<@NonNull String>> suggestionsProvider) {
|
||||||
|
super(required, name, new IntegrationRegionArgument.IntegrationRegionParser<>(), defaultValue, RPGRegionsRegion.class, suggestionsProvider);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <C> IntegrationRegionArgument.Builder<C> newBuilder(final @NonNull String name) {
|
||||||
|
return new IntegrationRegionArgument.Builder<>(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class Builder<C> extends CommandArgument.Builder<C, RPGRegionsRegion> {
|
||||||
|
|
||||||
|
private Builder(final @NonNull String name) {
|
||||||
|
super(RPGRegionsRegion.class, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull CommandArgument<C, RPGRegionsRegion> build() {
|
||||||
|
return new IntegrationRegionArgument<>(
|
||||||
|
this.isRequired(),
|
||||||
|
this.getName(),
|
||||||
|
this.getDefaultValue(),
|
||||||
|
this.getSuggestionsProvider()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class IntegrationRegionParser<C> implements ArgumentParser<C, RPGRegionsRegion> {
|
||||||
|
@Override
|
||||||
|
public @NonNull ArgumentParseResult<RPGRegionsRegion> parse(
|
||||||
|
@NonNull CommandContext<@NonNull C> commandContext,
|
||||||
|
@NonNull Queue<@NonNull String> inputQueue) {
|
||||||
|
final String input = inputQueue.peek();
|
||||||
|
if (input == null) {
|
||||||
|
return ArgumentParseResult.failure(new NoInputProvidedException(
|
||||||
|
IntegrationRegionArgument.class,
|
||||||
|
commandContext
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RPGRegionsAPI.getAPI().getManagers().getIntegrationManager() instanceof RPGRegionsIntegration rpgRegionsIntegration) {
|
||||||
|
Optional<RPGRegionsRegion> region = rpgRegionsIntegration.getRegion(input);
|
||||||
|
if (region.isPresent()) {
|
||||||
|
inputQueue.remove();
|
||||||
|
return ArgumentParseResult.success(region.get());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ArgumentParseResult.failure(new IntegrationRegionParserException(input, commandContext));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public @NonNull List<@NonNull String> suggestions(@NonNull CommandContext<C> commandContext, @NonNull String input) {
|
||||||
|
if (commandContext.getSender() instanceof Player player) {
|
||||||
|
return ImmutableList.copyOf(RPGRegionsAPI.getAPI().getManagers().getIntegrationManager().getAllRegionNames(player.getWorld()));
|
||||||
|
}
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final class IntegrationRegionParserException extends ParserException {
|
||||||
|
|
||||||
|
public IntegrationRegionParserException(
|
||||||
|
final @NonNull String input,
|
||||||
|
final @NonNull CommandContext<?> context
|
||||||
|
) {
|
||||||
|
super(
|
||||||
|
RPGRegionsRegion.class,
|
||||||
|
context,
|
||||||
|
RPGRegionsCaptionKeys.ARGUMENT_PARSE_FAILURE_REGION_NOT_FOUND,
|
||||||
|
CaptionVariable.of("input", input)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,7 +19,6 @@ import net.islandearth.rpgregions.translation.Translations;
|
|||||||
import net.islandearth.rpgregions.utils.ItemStackBuilder;
|
import net.islandearth.rpgregions.utils.ItemStackBuilder;
|
||||||
import net.islandearth.rpgregions.utils.StringUtils;
|
import net.islandearth.rpgregions.utils.StringUtils;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -272,8 +271,9 @@ public class DiscoveryGUI extends RPGRegionsGUI {
|
|||||||
} else player.sendMessage(ChatColor.RED + "Unable to find teleport location.");
|
} else player.sendMessage(ChatColor.RED + "Unable to find teleport location.");
|
||||||
if (configuredRegion.getTeleportCooldown() != 0) {
|
if (configuredRegion.getTeleportCooldown() != 0) {
|
||||||
account.getCooldowns().add(RPGRegionsAccount.AccountCooldown.TELEPORT);
|
account.getCooldowns().add(RPGRegionsAccount.AccountCooldown.TELEPORT);
|
||||||
Bukkit.getScheduler().runTaskLater(plugin,
|
plugin.getScheduler().executeDelayed(() -> {
|
||||||
() -> account.getCooldowns().remove(RPGRegionsAccount.AccountCooldown.TELEPORT), configuredRegion.getTeleportCooldown());
|
account.getCooldowns().remove(RPGRegionsAccount.AccountCooldown.TELEPORT);
|
||||||
|
}, configuredRegion.getTeleportCooldown());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -299,7 +299,9 @@ public class DiscoveryGUI extends RPGRegionsGUI {
|
|||||||
|
|
||||||
if (iconCommand.getCooldown() != 0) {
|
if (iconCommand.getCooldown() != 0) {
|
||||||
account.getCooldowns().add(RPGRegionsAccount.AccountCooldown.ICON_COMMAND);
|
account.getCooldowns().add(RPGRegionsAccount.AccountCooldown.ICON_COMMAND);
|
||||||
Bukkit.getScheduler().runTaskLater(plugin, () -> account.getCooldowns().remove(RPGRegionsAccount.AccountCooldown.ICON_COMMAND), iconCommand.getCooldown());
|
plugin.getScheduler().executeDelayed(() -> {
|
||||||
|
account.getCooldowns().remove(RPGRegionsAccount.AccountCooldown.ICON_COMMAND);
|
||||||
|
}, iconCommand.getCooldown());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import net.islandearth.rpgregions.translation.Translations;
|
|||||||
import net.islandearth.rpgregions.utils.ItemStackBuilder;
|
import net.islandearth.rpgregions.utils.ItemStackBuilder;
|
||||||
import net.islandearth.rpgregions.utils.ReflectionUtils;
|
import net.islandearth.rpgregions.utils.ReflectionUtils;
|
||||||
import net.wesjd.anvilgui.AnvilGUI;
|
import net.wesjd.anvilgui.AnvilGUI;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
@@ -142,7 +141,7 @@ public class EditGuiElementGUI extends RPGRegionsGUI {
|
|||||||
items.add(guiItem);
|
items.add(guiItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.getScheduler().runTask(plugin, () -> { // GUI updates must be sync.
|
plugin.getScheduler().executeOnMain(() -> { // GUI updates must be sync.
|
||||||
pane.populateWithGuiItems(items);
|
pane.populateWithGuiItems(items);
|
||||||
gui.setTitle(region.getId());
|
gui.setTitle(region.getId());
|
||||||
gui.update();
|
gui.update();
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class RegionListener implements Listener {
|
|||||||
plugin.debug("Has the player discovered this region? " + has);
|
plugin.debug("Has the player discovered this region? " + has);
|
||||||
plugin.debug("Is this the prioritised region? " + prioritised);
|
plugin.debug("Is this the prioritised region? " + prioritised);
|
||||||
|
|
||||||
Bukkit.getScheduler().runTask(plugin, () -> this.checkEffects(configuredRegion, player));
|
plugin.getScheduler().executeOnEntity(player, () -> this.checkEffects(configuredRegion, player));
|
||||||
|
|
||||||
if (configuredRegion.alwaysShowTitles() && event.hasChanged() && has && prioritised) {
|
if (configuredRegion.alwaysShowTitles() && event.hasChanged() && has && prioritised) {
|
||||||
this.sendTitles(player, configuredRegion, false);
|
this.sendTitles(player, configuredRegion, false);
|
||||||
@@ -170,10 +170,10 @@ public class RegionListener implements Listener {
|
|||||||
|
|
||||||
plugin.debug("Added to title cooldown");
|
plugin.debug("Added to title cooldown");
|
||||||
titleCooldown.add(player.getUniqueId());
|
titleCooldown.add(player.getUniqueId());
|
||||||
Bukkit.getScheduler().runTaskLater(plugin, () -> {
|
plugin.getScheduler().executeDelayed(() -> {
|
||||||
plugin.debug("Removed from title cooldown");
|
plugin.debug("Removed from title cooldown");
|
||||||
titleCooldown.remove(player.getUniqueId());
|
titleCooldown.remove(player.getUniqueId());
|
||||||
}, plugin.getConfig().getInt("settings.server.discoveries.discovered.title.cooldown"));
|
}, plugin.getConfig().getLong("settings.server.discoveries.discovered.title.cooldown"));
|
||||||
if (!discovered) {
|
if (!discovered) {
|
||||||
List<String> discoveredTitle = configuredRegion.getDiscoveredTitle(player);
|
List<String> discoveredTitle = configuredRegion.getDiscoveredTitle(player);
|
||||||
List<String> discoveredSubtitle = configuredRegion.getDiscoveredSubtitle(player);
|
List<String> discoveredSubtitle = configuredRegion.getDiscoveredSubtitle(player);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package net.islandearth.rpgregions.managers.data;
|
|||||||
|
|
||||||
import net.islandearth.rpgregions.RPGRegions;
|
import net.islandearth.rpgregions.RPGRegions;
|
||||||
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
@@ -47,7 +46,7 @@ public class RPGRegionsCache implements IRPGRegionsCache {
|
|||||||
public CompletableFuture<Boolean> saveAll(boolean async) {
|
public CompletableFuture<Boolean> saveAll(boolean async) {
|
||||||
CompletableFuture<Boolean> future = new CompletableFuture<>();
|
CompletableFuture<Boolean> future = new CompletableFuture<>();
|
||||||
if (async) {
|
if (async) {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
|
plugin.getScheduler().executeAsync(() -> {
|
||||||
configuredRegions.forEach((id, region) -> region.save(plugin));
|
configuredRegions.forEach((id, region) -> region.save(plugin));
|
||||||
future.complete(true);
|
future.complete(true);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package net.islandearth.rpgregions.managers.regeneration;
|
package net.islandearth.rpgregions.managers.regeneration;
|
||||||
|
|
||||||
import net.islandearth.rpgregions.RPGRegions;
|
import net.islandearth.rpgregions.RPGRegions;
|
||||||
|
import net.islandearth.rpgregions.api.schedule.PlatformScheduler;
|
||||||
import net.islandearth.rpgregions.managers.IRegenerationManager;
|
import net.islandearth.rpgregions.managers.IRegenerationManager;
|
||||||
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
import net.islandearth.rpgregions.managers.data.region.ConfiguredRegion;
|
||||||
import net.islandearth.rpgregions.regenerate.Regenerate;
|
import net.islandearth.rpgregions.regenerate.Regenerate;
|
||||||
import net.islandearth.rpgregions.tasks.RegenerationTask;
|
import net.islandearth.rpgregions.tasks.RegenerationTask;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -13,7 +13,7 @@ import java.util.List;
|
|||||||
public class RegenerationManager implements IRegenerationManager {
|
public class RegenerationManager implements IRegenerationManager {
|
||||||
|
|
||||||
private final RPGRegions plugin;
|
private final RPGRegions plugin;
|
||||||
private final List<Integer> tasks;
|
private final List<PlatformScheduler.RPGRegionsTask> tasks;
|
||||||
|
|
||||||
public RegenerationManager(RPGRegions plugin) {
|
public RegenerationManager(RPGRegions plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@@ -22,14 +22,14 @@ public class RegenerationManager implements IRegenerationManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void reload() {
|
public void reload() {
|
||||||
tasks.forEach(task -> Bukkit.getScheduler().cancelTask(task));
|
tasks.forEach(PlatformScheduler.RPGRegionsTask::cancel);
|
||||||
tasks.clear();
|
tasks.clear();
|
||||||
for (ConfiguredRegion configuredRegion1 : plugin.getManagers().getRegionsCache().getConfiguredRegions().values()) {
|
for (ConfiguredRegion configuredRegion1 : plugin.getManagers().getRegionsCache().getConfiguredRegions().values()) {
|
||||||
if (configuredRegion1.getRegenerate() != null) {
|
if (configuredRegion1.getRegenerate() != null) {
|
||||||
Regenerate regenerate = configuredRegion1.getRegenerate();
|
Regenerate regenerate = configuredRegion1.getRegenerate();
|
||||||
if (regenerate.isOnDiscover()) continue;
|
if (regenerate.isOnDiscover()) continue;
|
||||||
if (regenerate.getRegenerateInterval() < 5000) plugin.getLogger().warning("Region " + configuredRegion1.getId() + " has a very low regenerate interval! This may lag your server.");
|
if (regenerate.getRegenerateInterval() < 5000) plugin.getLogger().warning("Region " + configuredRegion1.getId() + " has a very low regenerate interval! This may lag your server.");
|
||||||
tasks.add(Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new RegenerationTask(plugin, configuredRegion1), 0L, regenerate.getRegenerateInterval()));
|
tasks.add(plugin.getScheduler().executeRepeating(new RegenerationTask(plugin, configuredRegion1), 0L, regenerate.getRegenerateInterval()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
package net.islandearth.rpgregions.schedule;
|
||||||
|
|
||||||
|
import net.islandearth.rpgregions.RPGRegions;
|
||||||
|
import net.islandearth.rpgregions.api.schedule.PlatformScheduler;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
public class BukkitScheduler extends PlatformScheduler<RPGRegions> {
|
||||||
|
|
||||||
|
public BukkitScheduler(RPGRegions api) {
|
||||||
|
super(api);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executeOnMain(Runnable runnable) {
|
||||||
|
Bukkit.getScheduler().runTask(api, runnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executeOnEntity(Entity entity, Runnable runnable) {
|
||||||
|
executeOnMain(runnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public RPGRegionsTask executeRepeating(Runnable runnable, long delay, long period) {
|
||||||
|
final BukkitTask task = Bukkit.getScheduler().runTaskTimer(api, runnable, delay, period);
|
||||||
|
return task::cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executeDelayed(Runnable runnable, long delay) {
|
||||||
|
Bukkit.getScheduler().runTaskLater(api, runnable, delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void executeAsync(Runnable runnable) {
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(api, runnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerInitTask(Runnable runnable) {
|
||||||
|
executeOnMain(runnable);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,3 +8,4 @@ softdepend: [Hyperverse, Multiverse, UltraRegions, WorldGuard, PlaceholderAPI, H
|
|||||||
authors: [SamB440]
|
authors: [SamB440]
|
||||||
description: Discoverable regions
|
description: Discoverable regions
|
||||||
website: https://fortitude.islandearth.net
|
website: https://fortitude.islandearth.net
|
||||||
|
folia-supported: true
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
include("rpgregions")
|
include("rpgregions")
|
||||||
include("modern")
|
include("modern")
|
||||||
include("api")
|
include("api")
|
||||||
|
include("folia")
|
||||||
|
|||||||
Reference in New Issue
Block a user