diff --git a/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock b/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock
new file mode 100644
index 0000000..41324e6
Binary files /dev/null and b/.gradle/7.2/dependencies-accessors/dependencies-accessors.lock differ
diff --git a/.gradle/7.2/dependencies-accessors/gc.properties b/.gradle/7.2/dependencies-accessors/gc.properties
new file mode 100644
index 0000000..e69de29
diff --git a/.gradle/7.2/executionHistory/executionHistory.bin b/.gradle/7.2/executionHistory/executionHistory.bin
new file mode 100644
index 0000000..7284949
Binary files /dev/null and b/.gradle/7.2/executionHistory/executionHistory.bin differ
diff --git a/.gradle/7.2/executionHistory/executionHistory.lock b/.gradle/7.2/executionHistory/executionHistory.lock
new file mode 100644
index 0000000..63b1f11
Binary files /dev/null and b/.gradle/7.2/executionHistory/executionHistory.lock differ
diff --git a/.gradle/7.2/fileChanges/last-build.bin b/.gradle/7.2/fileChanges/last-build.bin
new file mode 100644
index 0000000..f76dd23
Binary files /dev/null and b/.gradle/7.2/fileChanges/last-build.bin differ
diff --git a/.gradle/7.2/fileHashes/fileHashes.bin b/.gradle/7.2/fileHashes/fileHashes.bin
new file mode 100644
index 0000000..c9a7de0
Binary files /dev/null and b/.gradle/7.2/fileHashes/fileHashes.bin differ
diff --git a/.gradle/7.2/fileHashes/fileHashes.lock b/.gradle/7.2/fileHashes/fileHashes.lock
new file mode 100644
index 0000000..b83ae0a
Binary files /dev/null and b/.gradle/7.2/fileHashes/fileHashes.lock differ
diff --git a/.gradle/7.2/fileHashes/resourceHashesCache.bin b/.gradle/7.2/fileHashes/resourceHashesCache.bin
new file mode 100644
index 0000000..7a17eab
Binary files /dev/null and b/.gradle/7.2/fileHashes/resourceHashesCache.bin differ
diff --git a/.gradle/7.2/gc.properties b/.gradle/7.2/gc.properties
new file mode 100644
index 0000000..e69de29
diff --git a/.gradle/buildOutputCleanup/buildOutputCleanup.lock b/.gradle/buildOutputCleanup/buildOutputCleanup.lock
new file mode 100644
index 0000000..4e5616a
Binary files /dev/null and b/.gradle/buildOutputCleanup/buildOutputCleanup.lock differ
diff --git a/.gradle/buildOutputCleanup/cache.properties b/.gradle/buildOutputCleanup/cache.properties
new file mode 100644
index 0000000..2704283
--- /dev/null
+++ b/.gradle/buildOutputCleanup/cache.properties
@@ -0,0 +1,2 @@
+#Sat Feb 05 19:33:20 CST 2022
+gradle.version=7.2
diff --git a/.gradle/buildOutputCleanup/outputFiles.bin b/.gradle/buildOutputCleanup/outputFiles.bin
new file mode 100644
index 0000000..2d8f3a8
Binary files /dev/null and b/.gradle/buildOutputCleanup/outputFiles.bin differ
diff --git a/.gradle/checksums/checksums.lock b/.gradle/checksums/checksums.lock
new file mode 100644
index 0000000..602018d
Binary files /dev/null and b/.gradle/checksums/checksums.lock differ
diff --git a/.gradle/checksums/md5-checksums.bin b/.gradle/checksums/md5-checksums.bin
new file mode 100644
index 0000000..c951867
Binary files /dev/null and b/.gradle/checksums/md5-checksums.bin differ
diff --git a/.gradle/checksums/sha1-checksums.bin b/.gradle/checksums/sha1-checksums.bin
new file mode 100644
index 0000000..9e4e330
Binary files /dev/null and b/.gradle/checksums/sha1-checksums.bin differ
diff --git a/.gradle/vcs-1/gc.properties b/.gradle/vcs-1/gc.properties
new file mode 100644
index 0000000..e69de29
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
index 9aef4a2..b589d56 100644
--- a/.idea/compiler.xml
+++ b/.idea/compiler.xml
@@ -1,16 +1,6 @@
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..611e7c8
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 4f3d965..30bc6f8 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -26,5 +26,15 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index f8e9e22..d93202f 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -5,13 +5,7 @@
-
-
-
-
-
-
-
+
diff --git a/.idea/modules.xml b/.idea/modules.xml
deleted file mode 100644
index 0496a72..0000000
--- a/.idea/modules.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/modules/SimplexCL.main.iml b/.idea/modules/SimplexCL.main.iml
new file mode 100644
index 0000000..f5de878
--- /dev/null
+++ b/.idea/modules/SimplexCL.main.iml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+ PAPER
+ ADVENTURE
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
new file mode 100644
index 0000000..ef5c84c
--- /dev/null
+++ b/build.gradle
@@ -0,0 +1,48 @@
+/*
+ * This file was generated by the Gradle 'init' task.
+ */
+
+plugins {
+ id 'java'
+ id 'maven-publish'
+ id 'com.github.johnrengelman.shadow' version '7.1.2'
+}
+
+apply plugin: 'com.github.johnrengelman.shadow'
+apply plugin: 'java'
+
+tasks {
+ build {
+ dependsOn(shadowJar)
+ }
+}
+
+repositories {
+ mavenLocal()
+ maven {
+ url = uri('https://papermc.io/repo/repository/maven-public/')
+ }
+
+ maven {
+ url = uri('https://oss.sonatype.org/content/groups/public/')
+ }
+
+ maven {
+ url = uri('https://repo.maven.apache.org/maven2/')
+ }
+ mavenCentral()
+}
+
+dependencies {
+ shadow 'org.reflections:reflections:0.10.2'
+ compileOnly 'io.papermc.paper:paper-api:1.18.1-R0.1-SNAPSHOT'
+}
+
+group = 'io.github.simplex'
+version = '1.0.0'
+description = 'SimplexCL'
+java.sourceCompatibility = JavaVersion.VERSION_17
+
+tasks.withType(JavaCompile) {
+ options.encoding = 'UTF-8'
+}
diff --git a/build/resources/main/plugin.yml b/build/resources/main/plugin.yml
new file mode 100644
index 0000000..f09dcc2
--- /dev/null
+++ b/build/resources/main/plugin.yml
@@ -0,0 +1,8 @@
+name: SimplexCL
+version: '${project.version}'
+main: io.github.simplex.SimplexCL
+api-version: 1.18
+prefix: CommandLoader
+authors: [ SimplexDevelopment ]
+description: A Command Loader for Paper
+website: https://simplexdev.app
diff --git a/build/tmp/compileJava/previous-compilation-data.bin b/build/tmp/compileJava/previous-compilation-data.bin
new file mode 100644
index 0000000..6e51dbf
Binary files /dev/null and b/build/tmp/compileJava/previous-compilation-data.bin differ
diff --git a/build/tmp/jar/MANIFEST.MF b/build/tmp/jar/MANIFEST.MF
new file mode 100644
index 0000000..59499bc
--- /dev/null
+++ b/build/tmp/jar/MANIFEST.MF
@@ -0,0 +1,2 @@
+Manifest-Version: 1.0
+
diff --git a/build/tmp/shadowJar/MANIFEST.MF b/build/tmp/shadowJar/MANIFEST.MF
new file mode 100644
index 0000000..972ef8d
--- /dev/null
+++ b/build/tmp/shadowJar/MANIFEST.MF
@@ -0,0 +1,4 @@
+Manifest-Version: 1.0
+Class-Path: reflections-0.10.2.jar javassist-3.28.0-GA.jar jsr305-3.0.2.
+ jar slf4j-api-1.7.32.jar
+
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..ffed3a2
--- /dev/null
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/gradlew b/gradlew
new file mode 100644
index 0000000..c53aefa
--- /dev/null
+++ b/gradlew
@@ -0,0 +1,234 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
+
+APP_NAME="Gradle"
+APP_BASE_NAME=${0##*/}
+
+# 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"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+# Collect all arguments for the java command;
+# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
+# shell script including quotes and variable substitutions, so put them in
+# double quotes to make sure that they get re-expanded; and
+# * put everything else in single quotes, so that it's not re-expanded.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
new file mode 100644
index 0000000..107acd3
--- /dev/null
+++ b/gradlew.bat
@@ -0,0 +1,89 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/settings.gradle b/settings.gradle
new file mode 100644
index 0000000..9ce20d6
--- /dev/null
+++ b/settings.gradle
@@ -0,0 +1,5 @@
+/*
+ * This file was generated by the Gradle 'init' task.
+ */
+
+rootProject.name = 'SimplexCL'
diff --git a/src/main/java/io/github/simplex/CommandBase.java b/src/main/java/io/github/simplex/CommandBase.java
index 8db7615..b5996cc 100644
--- a/src/main/java/io/github/simplex/CommandBase.java
+++ b/src/main/java/io/github/simplex/CommandBase.java
@@ -1,26 +1,29 @@
package io.github.simplex;
import io.github.simplex.api.ICommand;
-import io.github.simplex.api.annotations.Permission;
+import io.github.simplex.api.annotations.SubCommand;
import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.TextComponent;
import net.kyori.adventure.text.format.TextColor;
-import net.kyori.adventure.util.RGBLike;
+import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
-import org.bukkit.command.defaults.BukkitCommand;
-import org.bukkit.plugin.Plugin;
+import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
public abstract class CommandBase extends Permissible implements ICommand {
- private final Plugin plugin;
-
- public CommandBase(Plugin plugin, String permission, String permissionMessage) {
- super(permission, permissionMessage);
- this.plugin = plugin;
+ public CommandBase(String permission, String permissionMessage, boolean allowConsole) {
+ super(permission, permissionMessage, allowConsole);
}
- public CommandBase(Plugin plugin, String permission) {
- this(plugin, permission, "You do not have permission to use this command.");
+ public CommandBase(String permission, String permissionMessage) {
+ this(permission, permissionMessage, true);
}
@Override
@@ -32,7 +35,21 @@ public abstract class CommandBase extends Permissible implements ICommand {
.color(TextColor.color(255, 3, 62)));
return true;
}
- execute();
+
+ if (!(sender instanceof Player) && !allowConsole()) {
+ sender.sendMessage(Component.empty().content("This command may only be run in game."));
+ }
+
+ execute(sender, args, allowConsole());
return true;
}
+
+ @Override
+ public @Nullable List onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
+ return new ArrayList<>();
+ }
+
+ public TextComponent msg(String text) {
+ return Component.empty().content(text);
+ }
}
diff --git a/src/main/java/io/github/simplex/CommandLoader.java b/src/main/java/io/github/simplex/CommandLoader.java
index 866ff60..b215d24 100644
--- a/src/main/java/io/github/simplex/CommandLoader.java
+++ b/src/main/java/io/github/simplex/CommandLoader.java
@@ -2,68 +2,44 @@ package io.github.simplex;
import io.github.simplex.api.annotations.*;
import org.bukkit.Bukkit;
-import org.bukkit.command.CommandMap;
import org.bukkit.plugin.Plugin;
import org.reflections.Reflections;
-
-import java.lang.annotation.AnnotationTypeMismatchException;
-import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Set;
-public class CommandLoader {
+public class CommandLoader {
private final Plugin plugin;
public CommandLoader(Plugin plugin) {
this.plugin = plugin;
}
- public Plugin getPlugin() {
- return plugin;
- }
-
- public void registerCommands(Class target) {
+ public void registerCommands(Class target) {
Reflections reflections = new Reflections(target);
if (target.getDeclaredAnnotation(Info.class) != null) {
Set> classSet = reflections.getTypesAnnotatedWith(Info.class);
classSet.forEach(cmd -> {
Info info = cmd.getDeclaredAnnotation(Info.class);
- try {
- CommandBase base = (CommandBase) cmd.getConstructor(Plugin.class, String.class, String.class).newInstance(plugin, info.permission(), info.permissionMessage());
- DummyCommand dummy = new DummyCommand(base, info.name(), info.description(), info.usage(), Arrays.asList(info.aliases().split(",")));
- Field f = Bukkit.getServer().getClass().getDeclaredField("commandMap");
- f.setAccessible(true);
- CommandMap commandMap = (CommandMap) f.get(Bukkit.getServer());
- commandMap.register(info.name(), dummy);
- } catch (NoSuchMethodException
- | InvocationTargetException
- | IllegalAccessException
- | InstantiationException
- | NoSuchFieldException e) {
- plugin.getLogger().severe(e.getMessage() + "\n\n\n" + e.getCause());
- }
- });
- } else if (target.getDeclaredAnnotation(Name.class) != null) {
- Set> classSet = reflections.getTypesAnnotatedWith(Name.class);
- classSet.forEach(cmd -> {
- Name name = cmd.getDeclaredAnnotation(Name.class);
- Description description = cmd.getDeclaredAnnotation(Description.class);
- Usage usage = cmd.getDeclaredAnnotation(Usage.class);
- Aliases aliases = cmd.getDeclaredAnnotation(Aliases.class);
Permission permission = cmd.getDeclaredAnnotation(Permission.class);
try {
- CommandBase base = (CommandBase) cmd.getConstructor(Plugin.class, String.class, String.class).newInstance(plugin, permission.permission(), permission.permissionMessage());
- DummyCommand dummy = new DummyCommand(base, name.name(), description.description(), usage.usage(), Arrays.asList(aliases.aliases().split(",")));
- Field f = Bukkit.getServer().getClass().getDeclaredField("commandMap");
- f.setAccessible(true);
- CommandMap commandMap = (CommandMap) f.get(Bukkit.getServer());
- commandMap.register(name.name(), dummy);
+ CommandBase base = (CommandBase) cmd.getConstructor(String.class,
+ String.class,
+ Boolean.class)
+ .newInstance(permission.permission(),
+ permission.permissionMessage(),
+ permission.allowConsole());
+ DummyCommand dummy = new DummyCommand(plugin,
+ base,
+ info.name(),
+ info.description(),
+ info.usage(),
+ Arrays.asList(info.aliases().split(",")));
+ Bukkit.getCommandMap().register(info.name(), "SimplexCL", dummy);
} catch (NoSuchMethodException
| InvocationTargetException
| IllegalAccessException
- | InstantiationException
- | NoSuchFieldException e) {
+ | InstantiationException e) {
plugin.getLogger().severe(e.getMessage() + "\n\n\n" + e.getCause());
}
});
diff --git a/src/main/java/io/github/simplex/DummyCommand.java b/src/main/java/io/github/simplex/DummyCommand.java
index a754043..901cc44 100644
--- a/src/main/java/io/github/simplex/DummyCommand.java
+++ b/src/main/java/io/github/simplex/DummyCommand.java
@@ -1,15 +1,18 @@
package io.github.simplex;
+import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
-import org.bukkit.command.defaults.BukkitCommand;
+import org.bukkit.command.PluginIdentifiableCommand;
+import org.bukkit.plugin.Plugin;
import org.jetbrains.annotations.NotNull;
import java.util.List;
-public class DummyCommand extends BukkitCommand {
+public final class DummyCommand extends Command implements PluginIdentifiableCommand {
private final CommandBase base;
+ private final Plugin plugin;
- protected DummyCommand(@NotNull CommandBase base, @NotNull String name, @NotNull String description, @NotNull String usageMessage, @NotNull List aliases) {
+ DummyCommand(@NotNull Plugin plugin, @NotNull CommandBase base, @NotNull String name, @NotNull String description, @NotNull String usageMessage, @NotNull List aliases) {
super(name, description, usageMessage, aliases);
this.setName(name);
this.setDescription(description);
@@ -17,6 +20,7 @@ public class DummyCommand extends BukkitCommand {
this.setAliases(aliases);
this.setPermission(base.getPermission());
this.base = base;
+ this.plugin = plugin;
}
@Override
@@ -24,4 +28,9 @@ public class DummyCommand extends BukkitCommand {
base.onCommand(sender, this, commandLabel, args);
return true;
}
+
+ @Override
+ public @NotNull Plugin getPlugin() {
+ return plugin;
+ }
}
diff --git a/src/main/java/io/github/simplex/Permissible.java b/src/main/java/io/github/simplex/Permissible.java
index 4a1e41f..993a17b 100644
--- a/src/main/java/io/github/simplex/Permissible.java
+++ b/src/main/java/io/github/simplex/Permissible.java
@@ -5,14 +5,12 @@ import org.bukkit.command.CommandSender;
public abstract class Permissible {
private final String permission;
private final String permissionMessage;
+ private final boolean allowConsole;
- public Permissible(String permission, String permissionMessage) {
+ public Permissible(String permission, String permissionMessage, boolean allowConsole) {
this.permission = permission;
this.permissionMessage = permissionMessage;
- }
-
- public Permissible(String permission) {
- this(permission, "You do not have permission to use this command.");
+ this.allowConsole = allowConsole;
}
public String getPermission() {
@@ -26,4 +24,8 @@ public abstract class Permissible {
public boolean hasPermission(CommandSender sender) {
return sender.hasPermission(getPermission());
}
+
+ public boolean allowConsole() {
+ return allowConsole;
+ }
}
diff --git a/src/main/java/io/github/simplex/SubCommandBase.java b/src/main/java/io/github/simplex/SubCommandBase.java
new file mode 100644
index 0000000..aef8375
--- /dev/null
+++ b/src/main/java/io/github/simplex/SubCommandBase.java
@@ -0,0 +1,15 @@
+package io.github.simplex;
+
+/*
+ * This class is intended to be used as a nested class inside your main command class.
+ * For example:
+ */
+public abstract class SubCommandBase extends CommandBase {
+ public SubCommandBase(String permission, String permissionMessage, boolean allowConsole) {
+ super(permission, permissionMessage, allowConsole);
+ }
+
+ public SubCommandBase(String permission, String permissionMessage) {
+ this(permission, permissionMessage, true);
+ }
+}
diff --git a/src/main/java/io/github/simplex/api/ICommand.java b/src/main/java/io/github/simplex/api/ICommand.java
index fe54d09..9fe1557 100644
--- a/src/main/java/io/github/simplex/api/ICommand.java
+++ b/src/main/java/io/github/simplex/api/ICommand.java
@@ -1,8 +1,9 @@
package io.github.simplex.api;
import org.bukkit.command.CommandExecutor;
+import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
public interface ICommand extends CommandExecutor, TabCompleter {
- boolean execute();
+ void execute(CommandSender sender, String[] args, boolean allowConsole);
}
diff --git a/src/main/java/io/github/simplex/api/annotations/Aliases.java b/src/main/java/io/github/simplex/api/annotations/Aliases.java
deleted file mode 100644
index 12a9edd..0000000
--- a/src/main/java/io/github/simplex/api/annotations/Aliases.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package io.github.simplex.api.annotations;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Aliases {
- String aliases();
-}
diff --git a/src/main/java/io/github/simplex/api/annotations/Description.java b/src/main/java/io/github/simplex/api/annotations/Description.java
deleted file mode 100644
index 3d59d28..0000000
--- a/src/main/java/io/github/simplex/api/annotations/Description.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package io.github.simplex.api.annotations;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Description {
- String description();
-}
diff --git a/src/main/java/io/github/simplex/api/annotations/Info.java b/src/main/java/io/github/simplex/api/annotations/Info.java
index 8d413d2..c2f2bed 100644
--- a/src/main/java/io/github/simplex/api/annotations/Info.java
+++ b/src/main/java/io/github/simplex/api/annotations/Info.java
@@ -11,7 +11,5 @@ public @interface Info {
String name();
String description();
String usage();
- String permission();
String aliases() default "";
- String permissionMessage() default "You do not have permission to use this command.";
}
diff --git a/src/main/java/io/github/simplex/api/annotations/Name.java b/src/main/java/io/github/simplex/api/annotations/Name.java
deleted file mode 100644
index 99bbcbf..0000000
--- a/src/main/java/io/github/simplex/api/annotations/Name.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package io.github.simplex.api.annotations;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Name {
- String name();
-}
diff --git a/src/main/java/io/github/simplex/api/annotations/Permission.java b/src/main/java/io/github/simplex/api/annotations/Permission.java
index ff88016..43066a3 100644
--- a/src/main/java/io/github/simplex/api/annotations/Permission.java
+++ b/src/main/java/io/github/simplex/api/annotations/Permission.java
@@ -10,4 +10,5 @@ import java.lang.annotation.Target;
public @interface Permission {
String permission();
String permissionMessage() default "You do not have permission to use this command!";
+ boolean allowConsole() default true;
}
diff --git a/src/main/java/io/github/simplex/api/annotations/SubCommand.java b/src/main/java/io/github/simplex/api/annotations/SubCommand.java
index 0b9367c..7f090ad 100644
--- a/src/main/java/io/github/simplex/api/annotations/SubCommand.java
+++ b/src/main/java/io/github/simplex/api/annotations/SubCommand.java
@@ -5,7 +5,8 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
public @interface SubCommand {
+ String name();
}
diff --git a/src/main/java/io/github/simplex/api/annotations/Usage.java b/src/main/java/io/github/simplex/api/annotations/Usage.java
deleted file mode 100644
index 68d0dce..0000000
--- a/src/main/java/io/github/simplex/api/annotations/Usage.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package io.github.simplex.api.annotations;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Usage {
- String usage();
-}
diff --git a/src/main/java/io/github/simplex/impl/ExampleCommand.java b/src/main/java/io/github/simplex/impl/ExampleCommand.java
new file mode 100644
index 0000000..ee2efb7
--- /dev/null
+++ b/src/main/java/io/github/simplex/impl/ExampleCommand.java
@@ -0,0 +1,39 @@
+package io.github.simplex.impl;
+
+import io.github.simplex.CommandBase;
+import io.github.simplex.SubCommandBase;
+import io.github.simplex.api.annotations.Info;
+import io.github.simplex.api.annotations.Permission;
+import io.github.simplex.api.annotations.SubCommand;
+import net.kyori.adventure.text.Component;
+import net.kyori.adventure.text.TextComponent;
+import org.bukkit.command.CommandSender;
+
+@Info(name = "example", description = "An example command implementation to see how this works.", usage = "/example [info]", aliases = "ex, impl")
+@Permission(permission = "simplexcl.example", permissionMessage = "You cannot use this command!")
+public final class ExampleCommand extends CommandBase {
+ public ExampleCommand(String permission, String permissionMessage, boolean allowConsole) {
+ super(permission, permissionMessage, allowConsole);
+ }
+
+ @Override
+ public void execute(CommandSender sender, String[] args, boolean allowConsole) {
+
+ }
+
+ @SubCommand(name = "info")
+ @Permission(permission = "simplexcl.example.info")
+ public class InfoSubCommand extends SubCommandBase {
+ public InfoSubCommand(String permission, String permissionMessage, boolean allowConsole) {
+ super(permission, permissionMessage, allowConsole);
+ }
+
+ @Override
+ public void execute(CommandSender sender, String[] args, boolean allowConsole) {
+ TextComponent message = Component.empty();
+ message = message.append(msg("SimplexCL was created by SimplexDevelopment!"))
+ .append(msg("https://github.com/SimplexDevelopment/"));
+ sender.sendMessage(message);
+ }
+ }
+}