mirror of
https://github.com/plexusorg/Plex.git
synced 2025-07-04 16:56:40 +00:00
Compare commits
33 Commits
Author | SHA1 | Date | |
---|---|---|---|
39055270e2 | |||
67816f2785 | |||
91a1b1cfff | |||
0cdd4ca6a7 | |||
7477fa3f7a | |||
c39a758aea | |||
4b2a6916e4 | |||
0c6091f06a | |||
33195260a1 | |||
ffbad7928a | |||
7caa89539d | |||
ceb9a83eda | |||
a62bdef5b4 | |||
37649f1fdc | |||
ea512487ac | |||
41b0076f8f | |||
00b6473e4d | |||
77be23faf0 | |||
e39f882ea7 | |||
344d890877 | |||
2c8c6353c1 | |||
8fa05e3838 | |||
158ce52320 | |||
1cc431621b | |||
b9c873beb3 | |||
6e1fa15a6c | |||
c216bdc5a4 | |||
ed638679b2 | |||
76952e33b8 | |||
f3f7daaafb | |||
dbbaf4ab70 | |||
1a10fdd481 | |||
7565bb6fcf |
2
.github/workflows/codeql-analysis.yml
vendored
2
.github/workflows/codeql-analysis.yml
vendored
@ -22,7 +22,7 @@ jobs:
|
|||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
language: [ 'java' ]
|
language: [ 'java' ]
|
||||||
java: [17]
|
java: [ 17 ]
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
|
44
.github/workflows/gradle.yml
vendored
44
.github/workflows/gradle.yml
vendored
@ -1,26 +1,26 @@
|
|||||||
# Adapted from Paper's build script
|
# Adapted from Paper's build script
|
||||||
name: Build
|
name: Build
|
||||||
on: [push, pull_request]
|
on: [ push, pull_request ]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
# Only run on PRs if the source branch is on someone else's repo
|
# Only run on PRs if the source branch is on someone else's repo
|
||||||
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
|
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
java: [17]
|
java: [ 17 ]
|
||||||
fail-fast: true
|
fail-fast: true
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: JDK ${{ matrix.java }}
|
- name: JDK ${{ matrix.java }}
|
||||||
uses: actions/setup-java@v3
|
uses: actions/setup-java@v3
|
||||||
with:
|
with:
|
||||||
java-version: ${{ matrix.java }}
|
java-version: ${{ matrix.java }}
|
||||||
cache: 'gradle'
|
cache: 'gradle'
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
- name: Build
|
- name: Build
|
||||||
run: |
|
run: |
|
||||||
git config --global user.email "no-reply@github.com"
|
git config --global user.email "no-reply@github.com"
|
||||||
git config --global user.name "Github Actions"
|
git config --global user.name "Github Actions"
|
||||||
./gradlew build --stacktrace
|
./gradlew build --stacktrace
|
||||||
|
35
.idea/codeStyles/Plexus_Code_Style.xml
generated
35
.idea/codeStyles/Plexus_Code_Style.xml
generated
@ -1,33 +1,8 @@
|
|||||||
<component name="ProjectCodeStyleConfiguration">
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
<code_scheme name="Plexus Code Style" version="1">
|
<code_scheme name="Plexus Code Style" version="173">
|
||||||
<JavaCodeStyleSettings>
|
|
||||||
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="20" />
|
|
||||||
<option name="IMPORT_LAYOUT_TABLE">
|
|
||||||
<value>
|
|
||||||
<package name="" withSubpackages="true" static="false" />
|
|
||||||
<package name="" withSubpackages="true" static="true" />
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
</JavaCodeStyleSettings>
|
|
||||||
<JetCodeStyleSettings>
|
|
||||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
|
||||||
<value>
|
|
||||||
<package name="java.util" alias="false" withSubpackages="false" />
|
|
||||||
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
|
||||||
<package name="io.ktor" alias="false" withSubpackages="true" />
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
<option name="PACKAGES_IMPORT_LAYOUT">
|
|
||||||
<value>
|
|
||||||
<package name="" alias="false" withSubpackages="true" />
|
|
||||||
<package name="java" alias="false" withSubpackages="true" />
|
|
||||||
<package name="javax" alias="false" withSubpackages="true" />
|
|
||||||
<package name="kotlin" alias="false" withSubpackages="true" />
|
|
||||||
<package name="" alias="true" withSubpackages="true" />
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
</JetCodeStyleSettings>
|
|
||||||
<codeStyleSettings language="JAVA">
|
<codeStyleSettings language="JAVA">
|
||||||
|
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
||||||
|
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
|
||||||
<option name="BRACE_STYLE" value="2" />
|
<option name="BRACE_STYLE" value="2" />
|
||||||
<option name="CLASS_BRACE_STYLE" value="2" />
|
<option name="CLASS_BRACE_STYLE" value="2" />
|
||||||
<option name="METHOD_BRACE_STYLE" value="2" />
|
<option name="METHOD_BRACE_STYLE" value="2" />
|
||||||
@ -36,14 +11,10 @@
|
|||||||
<option name="WHILE_ON_NEW_LINE" value="true" />
|
<option name="WHILE_ON_NEW_LINE" value="true" />
|
||||||
<option name="CATCH_ON_NEW_LINE" value="true" />
|
<option name="CATCH_ON_NEW_LINE" value="true" />
|
||||||
<option name="FINALLY_ON_NEW_LINE" value="true" />
|
<option name="FINALLY_ON_NEW_LINE" value="true" />
|
||||||
<option name="SPACE_AFTER_TYPE_CAST" value="true" />
|
|
||||||
<option name="IF_BRACE_FORCE" value="3" />
|
<option name="IF_BRACE_FORCE" value="3" />
|
||||||
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
||||||
<option name="WHILE_BRACE_FORCE" value="3" />
|
<option name="WHILE_BRACE_FORCE" value="3" />
|
||||||
<option name="FOR_BRACE_FORCE" value="3" />
|
<option name="FOR_BRACE_FORCE" value="3" />
|
||||||
<option name="BLANK_LINES_AFTER_CLASS_HEADER" value="0" />
|
|
||||||
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
|
|
||||||
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
|
||||||
</codeStyleSettings>
|
</codeStyleSettings>
|
||||||
</code_scheme>
|
</code_scheme>
|
||||||
</component>
|
</component>
|
12
Jenkinsfile
vendored
12
Jenkinsfile
vendored
@ -8,18 +8,6 @@ pipeline {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stage("publish") {
|
|
||||||
when {
|
|
||||||
branch "master"
|
|
||||||
}
|
|
||||||
steps {
|
|
||||||
withCredentials([usernamePassword(credentialsId: '85b7099f-2e65-461e-b2ce-124edec41ed6', passwordVariable: 'plexPassword', usernameVariable: 'plexUser')]) {
|
|
||||||
withGradle {
|
|
||||||
sh "./gradlew publish --no-daemon"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
always {
|
always {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# Plex [](https://ci.plex.us.org/job/Plex/job/master/) 
|
# Plex [](https://ci.plex.us.org/job/Plex/job/master/) [](https://github.com/plexusorg/Plex/blob/master/LICENSE.md) [](https://discord.plex.us.org)
|
||||||
|
|
||||||
Plex is a new freedom plugin. It is an alternative to TotalFreedomMod. It has many of the features that make a freedom
|
Plex is a new freedom plugin. It is an alternative to TotalFreedomMod. It has many of the features that make a freedom
|
||||||
server unique, but also many features that TotalFreedomMod doesn’t have. For example, there is full support for using a
|
server unique, but also many features that TotalFreedomMod doesn’t have. For example, there is full support for using a
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "java"
|
id "java"
|
||||||
id "maven-publish"
|
id "maven-publish"
|
||||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
id "com.github.johnrengelman.shadow" version "8.1.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "dev.plex"
|
group = "dev.plex"
|
||||||
version = "1.2"
|
version = "1.3-SNAPSHOT"
|
||||||
description = "Plex"
|
description = "Plex"
|
||||||
|
|
||||||
subprojects {
|
subprojects {
|
||||||
@ -33,6 +33,11 @@ subprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maven {
|
||||||
|
url = uri("https://libraries.minecraft.net")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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-snapshots/gradle-7.6-20220825090952+0000-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-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
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id("net.kyori.blossom") version "1.3.0"
|
id("net.kyori.blossom") version "1.3.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = rootProject.group
|
group = rootProject.group
|
||||||
@ -7,7 +7,7 @@ version = rootProject.version
|
|||||||
description = "Plex-Velocity"
|
description = "Plex-Velocity"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven { url = uri("https://papermc.io/repo/repository/maven-public/") }
|
maven { url = uri("https://repo.papermc.io/repository/maven-public/") }
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.getByName<Jar>("jar") {
|
tasks.getByName<Jar>("jar") {
|
||||||
@ -37,9 +37,9 @@ publishing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("org.projectlombok:lombok:1.18.24")
|
compileOnly("org.projectlombok:lombok:1.18.28")
|
||||||
annotationProcessor("org.projectlombok:lombok:1.18.24")
|
annotationProcessor("org.projectlombok:lombok:1.18.28")
|
||||||
compileOnly("org.json:json:20220320")
|
compileOnly("org.json:json:20230227")
|
||||||
compileOnly("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
|
compileOnly("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT")
|
||||||
annotationProcessor("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
|
annotationProcessor("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT")
|
||||||
}
|
}
|
@ -10,10 +10,11 @@ import dev.plex.config.TomlConfig;
|
|||||||
import dev.plex.handlers.ListenerHandler;
|
import dev.plex.handlers.ListenerHandler;
|
||||||
import dev.plex.settings.ServerSettings;
|
import dev.plex.settings.ServerSettings;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Credits for TOML library go to https://github.com/mwanji/toml4j
|
* Credits for TOML library go to https://github.com/mwanji/toml4j
|
||||||
|
@ -9,12 +9,13 @@ import dev.plex.Plex;
|
|||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import java.util.Arrays;
|
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public abstract class PlexCommand implements SimpleCommand
|
public abstract class PlexCommand implements SimpleCommand
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package dev.plex.command.annotation;
|
package dev.plex.command.annotation;
|
||||||
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
|
@ -3,12 +3,13 @@ package dev.plex.config;
|
|||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.toml.Toml;
|
import dev.plex.toml.Toml;
|
||||||
import dev.plex.toml.TomlWriter;
|
import dev.plex.toml.TomlWriter;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class TomlConfig
|
public class TomlConfig
|
||||||
|
@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
|
|||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import dev.plex.util.ReflectionsUtil;
|
import dev.plex.util.ReflectionsUtil;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -7,13 +7,14 @@ import com.velocitypowered.api.proxy.server.ServerPing;
|
|||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.settings.ServerSettings;
|
import dev.plex.settings.ServerSettings;
|
||||||
import dev.plex.util.RandomUtil;
|
import dev.plex.util.RandomUtil;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
|
|
||||||
public class ServerListener extends PlexListener
|
public class ServerListener extends PlexListener
|
||||||
{
|
{
|
||||||
|
@ -2,10 +2,11 @@ package dev.plex.settings;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
import java.util.List;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class ServerSettings
|
public class ServerSettings
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,7 @@ package dev.plex.toml;
|
|||||||
import java.lang.reflect.Array;
|
import java.lang.reflect.Array;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import static dev.plex.toml.ValueWriters.WRITERS;
|
import static dev.plex.toml.ValueWriters.WRITERS;
|
||||||
|
|
||||||
public abstract class ArrayValueWriter implements dev.plex.toml.ValueWriter
|
public abstract class ArrayValueWriter implements dev.plex.toml.ValueWriter
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
package dev.plex.toml;
|
package dev.plex.toml;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
import com.google.gson.annotations.SerializedName;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
class ObjectValueWriter implements ValueWriter
|
class ObjectValueWriter implements ValueWriter
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,6 @@
|
|||||||
package dev.plex.toml;
|
package dev.plex.toml;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.*;
|
||||||
import java.util.Deque;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
class Results
|
class Results
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package dev.plex.toml;
|
package dev.plex.toml;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
import static dev.plex.toml.ValueWriters.WRITERS;
|
import static dev.plex.toml.ValueWriters.WRITERS;
|
||||||
|
|
||||||
class TableArrayValueWriter extends ArrayValueWriter
|
class TableArrayValueWriter extends ArrayValueWriter
|
||||||
|
@ -2,23 +2,12 @@ package dev.plex.toml;
|
|||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedHashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Provides access to the keys and tables in a TOML data source.</p>
|
* <p>Provides access to the keys and tables in a TOML data source.</p>
|
||||||
*
|
*
|
||||||
|
@ -1,17 +1,13 @@
|
|||||||
package dev.plex.toml;
|
package dev.plex.toml;
|
||||||
|
|
||||||
import java.io.File;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import java.io.FileOutputStream;
|
|
||||||
import java.io.IOException;
|
import java.io.*;
|
||||||
import java.io.OutputStream;
|
|
||||||
import java.io.OutputStreamWriter;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.io.Writer;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
import static dev.plex.toml.ValueWriters.WRITERS;
|
import static dev.plex.toml.ValueWriters.WRITERS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package dev.plex.toml;
|
package dev.plex.toml;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
import static dev.plex.toml.ArrayValueReader.ARRAY_VALUE_READER;
|
import static dev.plex.toml.ArrayValueReader.ARRAY_VALUE_READER;
|
||||||
import static dev.plex.toml.BooleanValueReaderWriter.BOOLEAN_VALUE_READER_WRITER;
|
import static dev.plex.toml.BooleanValueReaderWriter.BOOLEAN_VALUE_READER_WRITER;
|
||||||
import static dev.plex.toml.DateValueReaderWriter.DATE_VALUE_READER_WRITER;
|
import static dev.plex.toml.DateValueReaderWriter.DATE_VALUE_READER_WRITER;
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
package dev.plex.util;
|
package dev.plex.util;
|
||||||
|
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
|
||||||
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
public class RandomUtil
|
public class RandomUtil
|
||||||
{
|
{
|
||||||
public static NamedTextColor getRandomColor()
|
public static NamedTextColor getRandomColor()
|
||||||
|
@ -3,6 +3,7 @@ package dev.plex.util;
|
|||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.common.reflect.ClassPath;
|
import com.google.common.reflect.ClassPath;
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -6,26 +6,26 @@
|
|||||||
#############################
|
#############################
|
||||||
|
|
||||||
[server]
|
[server]
|
||||||
name = "Plexus"
|
name = "Plexus"
|
||||||
|
|
||||||
# Placeholders
|
# Placeholders
|
||||||
# %mcversion% - The Velocity Version (i.e. 3.1.2-SNAPSHOT)
|
# %mcversion% - The Velocity Version (i.e. 3.1.2-SNAPSHOT)
|
||||||
# %servername% - The name provided above
|
# %servername% - The name provided above
|
||||||
# %randomgradient% - Creates a random gradient every ping of two random colors for the whole string
|
# %randomgradient% - Creates a random gradient every ping of two random colors for the whole string
|
||||||
# Supports MiniMessage strings, no legacy & and §
|
# Supports MiniMessage strings, no legacy & and §
|
||||||
motd = ["%randomgradient%%servername% - %mcversion%", "Another motd"]
|
motd = ["%randomgradient%%servername% - %mcversion%", "Another motd"]
|
||||||
colorizeMotd = false
|
colorizeMotd = false
|
||||||
|
|
||||||
# Enables debug messages
|
# Enables debug messages
|
||||||
debug = false
|
debug = false
|
||||||
|
|
||||||
# Due to game code only supporting legacy color codes for
|
# Due to game code only supporting legacy color codes for
|
||||||
# player samples and not components, you may only use § or & here
|
# player samples and not components, you may only use § or & here
|
||||||
# for colors.
|
# for colors.
|
||||||
sample = ["example", "example"]
|
sample = ["example", "example"]
|
||||||
|
|
||||||
# Adds this amount to the current player count
|
# Adds this amount to the current player count
|
||||||
add-player-count = 0
|
add-player-count = 0
|
||||||
|
|
||||||
# The max player count will always display as +1 more than the player count
|
# The max player count will always display as +1 more than the player count
|
||||||
plus-one-max-count = true
|
plus-one-max-count = true
|
@ -1,33 +1,25 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "net.minecrell.plugin-yml.bukkit" version "0.5.2"
|
id "net.minecrell.plugin-yml.paper" version "0.6.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
library "org.projectlombok:lombok:1.18.24"
|
library "org.projectlombok:lombok:1.18.28"
|
||||||
annotationProcessor "org.projectlombok:lombok:1.18.24"
|
annotationProcessor "org.projectlombok:lombok:1.18.28"
|
||||||
library "org.json:json:20220320"
|
library "org.json:json:20230618"
|
||||||
library "commons-io:commons-io:2.11.0"
|
library "commons-io:commons-io:2.13.0"
|
||||||
library "dev.morphia.morphia:morphia-core:2.2.7"
|
library "dev.morphia.morphia:morphia-core:2.3.5"
|
||||||
library "redis.clients:jedis:4.2.3"
|
library "redis.clients:jedis:5.0.0-beta2"
|
||||||
library "org.mariadb.jdbc:mariadb-java-client:3.0.6"
|
library "org.mariadb.jdbc:mariadb-java-client:3.1.4"
|
||||||
library "com.zaxxer:HikariCP:5.0.1"
|
library "com.zaxxer:HikariCP:5.0.1"
|
||||||
library "org.apache.httpcomponents.client5:httpclient5:5.2-beta1"
|
library "org.apache.maven.resolver:maven-resolver-transport-http:1.9.13"
|
||||||
library "org.apache.commons:commons-lang3:3.12.0"
|
compileOnly "io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT"
|
||||||
library "org.apache.maven.resolver:maven-resolver-api:1.8.2"
|
compileOnly "io.papermc.paper:paper-mojangapi:1.20.1-R0.1-SNAPSHOT"
|
||||||
library "org.apache.maven.resolver:maven-resolver-impl:1.8.2"
|
|
||||||
library "org.apache.maven.resolver:maven-resolver-connector-basic:1.8.2"
|
|
||||||
library "org.apache.maven.resolver:maven-resolver-transport-http:1.8.2"
|
|
||||||
library "org.apache.maven:maven-resolver-provider:3.8.5"
|
|
||||||
library "org.eclipse.jetty:jetty-server:11.0.11"
|
|
||||||
library "org.eclipse.jetty:jetty-servlet:11.0.11"
|
|
||||||
library "org.eclipse.jetty:jetty-proxy:11.0.11"
|
|
||||||
library "com.google.code.gson:gson:2.9.0"
|
|
||||||
compileOnly "io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT"
|
|
||||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1") {
|
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1") {
|
||||||
exclude group: "org.bukkit", module: "bukkit"
|
exclude group: "org.bukkit", module: "bukkit"
|
||||||
}
|
}
|
||||||
implementation "org.bstats:bstats-base:3.0.0"
|
compileOnly "com.mojang:brigadier:1.0.18"
|
||||||
implementation "org.bstats:bstats-bukkit:3.0.0"
|
implementation "org.bstats:bstats-base:3.0.2"
|
||||||
|
implementation "org.bstats:bstats-bukkit:3.0.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = rootProject.group
|
group = rootProject.group
|
||||||
@ -40,15 +32,31 @@ shadowJar {
|
|||||||
relocate "org.bstats", "dev.plex"
|
relocate "org.bstats", "dev.plex"
|
||||||
}
|
}
|
||||||
|
|
||||||
bukkit {
|
paper {
|
||||||
name = "Plex"
|
name = "Plex"
|
||||||
version = project.version
|
version = project.version
|
||||||
description = "Plex provides a new experience for freedom servers."
|
description = "Plex provides a new experience for freedom servers."
|
||||||
main = "dev.plex.Plex"
|
main = "dev.plex.Plex"
|
||||||
|
loader = "dev.plex.PlexLibraryManager"
|
||||||
website = "https://plex.us.org"
|
website = "https://plex.us.org"
|
||||||
authors = ["Telesphoreo", "taahanis", "supernt"]
|
authors = ["Telesphoreo", "taahanis", "supernt"]
|
||||||
softDepend = ["Vault"]
|
// Load BukkitTelnet and LibsDisguises before Plex so the modules register properly
|
||||||
apiVersion = "1.18"
|
apiVersion = "1.19"
|
||||||
|
generateLibrariesJson = true
|
||||||
|
serverDependencies {
|
||||||
|
'BukkitTelnet' {
|
||||||
|
required = false
|
||||||
|
load = 'BEFORE'
|
||||||
|
}
|
||||||
|
'LibsDisguises' {
|
||||||
|
required = false
|
||||||
|
load = 'BEFORE'
|
||||||
|
}
|
||||||
|
'Vault' {
|
||||||
|
required = false
|
||||||
|
load = 'BEFORE'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String getGitHash() {
|
String getGitHash() {
|
||||||
|
@ -4,6 +4,8 @@ import dev.plex.admin.Admin;
|
|||||||
import dev.plex.admin.AdminList;
|
import dev.plex.admin.AdminList;
|
||||||
import dev.plex.cache.DataUtils;
|
import dev.plex.cache.DataUtils;
|
||||||
import dev.plex.cache.PlayerCache;
|
import dev.plex.cache.PlayerCache;
|
||||||
|
import dev.plex.command.PlexBrigadierCommand;
|
||||||
|
import dev.plex.command.impl.brigadier.PlexBrigadierCMD;
|
||||||
import dev.plex.config.Config;
|
import dev.plex.config.Config;
|
||||||
import dev.plex.handlers.CommandHandler;
|
import dev.plex.handlers.CommandHandler;
|
||||||
import dev.plex.handlers.ListenerHandler;
|
import dev.plex.handlers.ListenerHandler;
|
||||||
@ -21,14 +23,9 @@ import dev.plex.storage.player.MongoPlayerData;
|
|||||||
import dev.plex.storage.player.SQLPlayerData;
|
import dev.plex.storage.player.SQLPlayerData;
|
||||||
import dev.plex.storage.punishment.SQLNotes;
|
import dev.plex.storage.punishment.SQLNotes;
|
||||||
import dev.plex.storage.punishment.SQLPunishment;
|
import dev.plex.storage.punishment.SQLPunishment;
|
||||||
import dev.plex.util.BuildInfo;
|
import dev.plex.util.*;
|
||||||
import dev.plex.util.BungeeUtil;
|
|
||||||
import dev.plex.util.PlexLog;
|
|
||||||
import dev.plex.util.PlexUtils;
|
|
||||||
import dev.plex.util.UpdateChecker;
|
|
||||||
import dev.plex.util.redis.MessageUtil;
|
import dev.plex.util.redis.MessageUtil;
|
||||||
import dev.plex.world.CustomWorld;
|
import dev.plex.world.CustomWorld;
|
||||||
import java.io.File;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import net.milkbowl.vault.chat.Chat;
|
import net.milkbowl.vault.chat.Chat;
|
||||||
@ -38,6 +35,8 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class Plex extends JavaPlugin
|
public class Plex extends JavaPlugin
|
||||||
@ -76,7 +75,6 @@ public class Plex extends JavaPlugin
|
|||||||
private Permission permissions;
|
private Permission permissions;
|
||||||
private Chat chat;
|
private Chat chat;
|
||||||
|
|
||||||
|
|
||||||
public static Plex get()
|
public static Plex get()
|
||||||
{
|
{
|
||||||
return plugin;
|
return plugin;
|
||||||
@ -182,6 +180,7 @@ public class Plex extends JavaPlugin
|
|||||||
|
|
||||||
new ListenerHandler();
|
new ListenerHandler();
|
||||||
new CommandHandler();
|
new CommandHandler();
|
||||||
|
new PlexBrigadierCMD();
|
||||||
|
|
||||||
rankManager = new RankManager();
|
rankManager = new RankManager();
|
||||||
rankManager.generateDefaultRanks();
|
rankManager.generateDefaultRanks();
|
||||||
|
66
server/src/main/java/dev/plex/PlexLibraryManager.java
Normal file
66
server/src/main/java/dev/plex/PlexLibraryManager.java
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
package dev.plex;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import io.papermc.paper.plugin.loader.PluginClasspathBuilder;
|
||||||
|
import io.papermc.paper.plugin.loader.PluginLoader;
|
||||||
|
import io.papermc.paper.plugin.loader.library.impl.MavenLibraryResolver;
|
||||||
|
import org.eclipse.aether.artifact.DefaultArtifact;
|
||||||
|
import org.eclipse.aether.graph.Dependency;
|
||||||
|
import org.eclipse.aether.repository.RemoteRepository;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
public class PlexLibraryManager implements PluginLoader
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void classloader(@NotNull PluginClasspathBuilder classpathBuilder)
|
||||||
|
{
|
||||||
|
|
||||||
|
MavenLibraryResolver resolver = new MavenLibraryResolver();
|
||||||
|
PluginLibraries pluginLibraries = load();
|
||||||
|
pluginLibraries.asDependencies().forEach(resolver::addDependency);
|
||||||
|
pluginLibraries.asRepositories().forEach(resolver::addRepository);
|
||||||
|
// The plugin is null, a hacky way to check whether to load Jetty or not
|
||||||
|
if (new File("plugins/Plex/modules/Plex-HTTPD.jar").isFile())
|
||||||
|
{
|
||||||
|
resolver.addDependency(new Dependency(new DefaultArtifact("org.eclipse.jetty:jetty-server:11.0.15"), null));
|
||||||
|
resolver.addDependency(new Dependency(new DefaultArtifact("org.eclipse.jetty:jetty-servlet:11.0.15"), null));
|
||||||
|
resolver.addDependency(new Dependency(new DefaultArtifact("org.eclipse.jetty:jetty-proxy:11.0.15"), null));
|
||||||
|
}
|
||||||
|
classpathBuilder.addLibrary(resolver);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PluginLibraries load()
|
||||||
|
{
|
||||||
|
try (var in = getClass().getResourceAsStream("/paper-libraries.json"))
|
||||||
|
{
|
||||||
|
return new Gson().fromJson(new InputStreamReader(in, StandardCharsets.UTF_8), PluginLibraries.class);
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private record PluginLibraries(Map<String, String> repositories, List<String> dependencies)
|
||||||
|
{
|
||||||
|
public Stream<Dependency> asDependencies()
|
||||||
|
{
|
||||||
|
return dependencies.stream()
|
||||||
|
.map(d -> new Dependency(new DefaultArtifact(d), null));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Stream<RemoteRepository> asRepositories()
|
||||||
|
{
|
||||||
|
return repositories.entrySet().stream()
|
||||||
|
.map(e -> new RemoteRepository.Builder(e.getKey(), "default", e.getValue()).build());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,12 @@
|
|||||||
package dev.plex.admin;
|
package dev.plex.admin;
|
||||||
|
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import java.util.UUID;
|
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Admin object to handle cached admins
|
* Admin object to handle cached admins
|
||||||
*/
|
*/
|
||||||
|
@ -10,6 +10,7 @@ import dev.plex.PlexBase;
|
|||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.storage.StorageType;
|
import dev.plex.storage.StorageType;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
|
@ -3,6 +3,7 @@ package dev.plex.cache;
|
|||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.storage.StorageType;
|
import dev.plex.storage.StorageType;
|
||||||
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package dev.plex.cache;
|
|||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
|
571
server/src/main/java/dev/plex/command/PlexBrigadierCommand.java
Normal file
571
server/src/main/java/dev/plex/command/PlexBrigadierCommand.java
Normal file
@ -0,0 +1,571 @@
|
|||||||
|
package dev.plex.command;
|
||||||
|
|
||||||
|
import com.destroystokyo.paper.brigadier.BukkitBrigadierCommandSource;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.mojang.brigadier.CommandDispatcher;
|
||||||
|
import com.mojang.brigadier.arguments.*;
|
||||||
|
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||||
|
import com.mojang.brigadier.builder.RequiredArgumentBuilder;
|
||||||
|
import com.mojang.brigadier.context.CommandContext;
|
||||||
|
import com.mojang.brigadier.tree.CommandNode;
|
||||||
|
import com.mojang.brigadier.tree.LiteralCommandNode;
|
||||||
|
import dev.plex.Plex;
|
||||||
|
import dev.plex.cache.DataUtils;
|
||||||
|
import dev.plex.command.annotation.*;
|
||||||
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
|
import dev.plex.player.PlexPlayer;
|
||||||
|
import dev.plex.util.PlexLog;
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
|
import dev.plex.util.ReflectionsUtil;
|
||||||
|
import net.kyori.adventure.audience.Audience;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.lang.System;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Parameter;
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Taah
|
||||||
|
* @since 2:27 PM [07-07-2023]
|
||||||
|
*/
|
||||||
|
public abstract class PlexBrigadierCommand
|
||||||
|
{
|
||||||
|
protected final Plex plugin;
|
||||||
|
private CommandDispatcher<BukkitBrigadierCommandSource> commandDispatcher;
|
||||||
|
|
||||||
|
public PlexBrigadierCommand()
|
||||||
|
{
|
||||||
|
this.plugin = Plex.get();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Object dedicatedServer = ReflectionsUtil.callFunction(getCraftServer(), "getServer");
|
||||||
|
final Object minecraftServer = Class.forName("net.minecraft.server.MinecraftServer").cast(dedicatedServer);
|
||||||
|
final Object serverFunctionsManager = ReflectionsUtil.callFunction(minecraftServer, "aA");
|
||||||
|
this.commandDispatcher = ReflectionsUtil.callFunction(serverFunctionsManager, "b");
|
||||||
|
}
|
||||||
|
catch (ClassNotFoundException e)
|
||||||
|
{
|
||||||
|
this.commandDispatcher = null;
|
||||||
|
PlexLog.error("Disabling commands as brigadier could not properly be located.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.getClass().isAnnotationPresent(CommandName.class))
|
||||||
|
{
|
||||||
|
if (this.commandDispatcher != null)
|
||||||
|
{
|
||||||
|
this.commandDispatcher.register(execute());
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] commandName = this.getClass().getAnnotation(CommandName.class).value();
|
||||||
|
|
||||||
|
final HashMap<String, Method> subcommands = Maps.newHashMap();
|
||||||
|
|
||||||
|
Method defaultMethod = null;
|
||||||
|
for (Method declaredMethod : this.getClass().getDeclaredMethods())
|
||||||
|
{
|
||||||
|
if (declaredMethod.isAnnotationPresent(SubCommand.class))
|
||||||
|
{
|
||||||
|
String subcommand = declaredMethod.getAnnotation(SubCommand.class).value();
|
||||||
|
subcommands.put(subcommand.toLowerCase(), declaredMethod);
|
||||||
|
}
|
||||||
|
if (declaredMethod.isAnnotationPresent(Default.class))
|
||||||
|
{
|
||||||
|
if (defaultMethod != null)
|
||||||
|
{
|
||||||
|
PlexLog.error("There cannot be more than one default execution.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
defaultMethod = declaredMethod;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.commandDispatcher != null)
|
||||||
|
{
|
||||||
|
for (String name : commandName)
|
||||||
|
{
|
||||||
|
LiteralArgumentBuilder<BukkitBrigadierCommandSource> builder = LiteralArgumentBuilder.literal(name.toLowerCase());
|
||||||
|
|
||||||
|
for (Map.Entry<String, Method> stringMethodEntry : subcommands.entrySet())
|
||||||
|
{
|
||||||
|
String[] subCommandArgs = stringMethodEntry.getKey().split(" ");
|
||||||
|
LinkedList<LiteralArgumentBuilder<BukkitBrigadierCommandSource>> builders = new LinkedList<>();
|
||||||
|
for (int i = 0; i < subCommandArgs.length; i++)
|
||||||
|
{
|
||||||
|
LiteralArgumentBuilder<BukkitBrigadierCommandSource> newNode = LiteralArgumentBuilder.literal(subCommandArgs[i]);
|
||||||
|
builders.addLast(newNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (builders.size() == 1)
|
||||||
|
{
|
||||||
|
LiteralArgumentBuilder<BukkitBrigadierCommandSource> parent = builders.removeFirst();
|
||||||
|
LinkedList<RequiredArgumentBuilder<BukkitBrigadierCommandSource, ?>> argumentBuilders = new LinkedList<>();
|
||||||
|
|
||||||
|
LinkedHashMap<Parameter, RequiredArgumentBuilder<BukkitBrigadierCommandSource, ?>> arguments = getArguments(stringMethodEntry.getValue());
|
||||||
|
for (Map.Entry<Parameter, RequiredArgumentBuilder<BukkitBrigadierCommandSource, ?>> parameterArgumentBuilderEntry : arguments.entrySet())
|
||||||
|
{
|
||||||
|
argumentBuilders.addLast(parameterArgumentBuilderEntry.getValue());
|
||||||
|
}
|
||||||
|
boolean setExecution = false;
|
||||||
|
CommandNode<BukkitBrigadierCommandSource> parentArg = null;
|
||||||
|
CommandNode<BukkitBrigadierCommandSource> currArg = null;
|
||||||
|
while (!argumentBuilders.isEmpty())
|
||||||
|
{
|
||||||
|
if (parentArg == null)
|
||||||
|
{
|
||||||
|
RequiredArgumentBuilder<BukkitBrigadierCommandSource, ?> newParent = argumentBuilders.removeFirst();
|
||||||
|
if (argumentBuilders.isEmpty())
|
||||||
|
{
|
||||||
|
newParent.executes(context -> execute(stringMethodEntry.getValue(), context, arguments.keySet()));
|
||||||
|
setExecution = true;
|
||||||
|
}
|
||||||
|
parentArg = newParent.build();
|
||||||
|
parent.then(parentArg);
|
||||||
|
currArg = parentArg;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RequiredArgumentBuilder<BukkitBrigadierCommandSource, ?> newCurr = argumentBuilders.removeFirst();
|
||||||
|
if (argumentBuilders.isEmpty())
|
||||||
|
{
|
||||||
|
newCurr.executes(context -> execute(stringMethodEntry.getValue(), context, arguments.keySet()));
|
||||||
|
setExecution = true;
|
||||||
|
}
|
||||||
|
CommandNode<BukkitBrigadierCommandSource> newCurrNode = newCurr.build();
|
||||||
|
currArg.addChild(newCurrNode);
|
||||||
|
currArg = newCurrNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!setExecution)
|
||||||
|
{
|
||||||
|
parent.executes(context -> execute(stringMethodEntry.getValue(), context, arguments.keySet()));
|
||||||
|
}
|
||||||
|
builder.then(parent);
|
||||||
|
}
|
||||||
|
else if (builders.size() > 1)
|
||||||
|
{
|
||||||
|
LiteralCommandNode<BukkitBrigadierCommandSource> parent = builders.removeFirst().build();
|
||||||
|
LiteralCommandNode<BukkitBrigadierCommandSource> curr = null;
|
||||||
|
while (!builders.isEmpty())
|
||||||
|
{
|
||||||
|
LiteralArgumentBuilder<BukkitBrigadierCommandSource> newCurr = builders.removeFirst();
|
||||||
|
PlexLog.debug("Adding subcommand " + newCurr.getLiteral());
|
||||||
|
if (builders.isEmpty())
|
||||||
|
{
|
||||||
|
LinkedList<RequiredArgumentBuilder<BukkitBrigadierCommandSource, ?>> argumentBuilders = new LinkedList<>();
|
||||||
|
LinkedHashMap<Parameter, RequiredArgumentBuilder<BukkitBrigadierCommandSource, ?>> arguments = getArguments(stringMethodEntry.getValue());
|
||||||
|
for (Map.Entry<Parameter, RequiredArgumentBuilder<BukkitBrigadierCommandSource, ?>> parameterArgumentBuilderEntry : arguments.entrySet())
|
||||||
|
{
|
||||||
|
argumentBuilders.addLast(parameterArgumentBuilderEntry.getValue());
|
||||||
|
}
|
||||||
|
boolean setExecution = false;
|
||||||
|
CommandNode<BukkitBrigadierCommandSource> parentArg = null;
|
||||||
|
CommandNode<BukkitBrigadierCommandSource> currArg = null;
|
||||||
|
while (!argumentBuilders.isEmpty())
|
||||||
|
{
|
||||||
|
if (parentArg == null)
|
||||||
|
{
|
||||||
|
RequiredArgumentBuilder<BukkitBrigadierCommandSource, ?> newParent = argumentBuilders.removeFirst();
|
||||||
|
if (argumentBuilders.isEmpty())
|
||||||
|
{
|
||||||
|
newParent.executes(context -> execute(stringMethodEntry.getValue(), context, arguments.keySet()));
|
||||||
|
setExecution = true;
|
||||||
|
}
|
||||||
|
parentArg = newParent.build();
|
||||||
|
newCurr.then(parentArg);
|
||||||
|
currArg = parentArg;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RequiredArgumentBuilder<BukkitBrigadierCommandSource, ?> newCurrArg = argumentBuilders.removeFirst();
|
||||||
|
if (argumentBuilders.isEmpty())
|
||||||
|
{
|
||||||
|
newCurrArg.executes(context -> execute(stringMethodEntry.getValue(), context, arguments.keySet()));
|
||||||
|
setExecution = true;
|
||||||
|
}
|
||||||
|
CommandNode<BukkitBrigadierCommandSource> newCurrNode = newCurrArg.build();
|
||||||
|
currArg.addChild(newCurrNode);
|
||||||
|
currArg = newCurrNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!setExecution)
|
||||||
|
{
|
||||||
|
newCurr.executes(context -> execute(stringMethodEntry.getValue(), context, arguments.keySet()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (curr == null)
|
||||||
|
{
|
||||||
|
LiteralCommandNode<BukkitBrigadierCommandSource> temp = newCurr.build();
|
||||||
|
parent.addChild(temp);
|
||||||
|
curr = temp;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LiteralCommandNode<BukkitBrigadierCommandSource> temp = newCurr.build();
|
||||||
|
curr.addChild(temp);
|
||||||
|
curr = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
builder.then(parent);
|
||||||
|
}
|
||||||
|
PlexLog.debug("Overall Builder: " + new GsonBuilder().setPrettyPrinting().disableHtmlEscaping().create().toJson(builder));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defaultMethod != null)
|
||||||
|
{
|
||||||
|
LinkedList<RequiredArgumentBuilder<BukkitBrigadierCommandSource, ?>> argumentBuilders = new LinkedList<>();
|
||||||
|
LinkedHashMap<Parameter, RequiredArgumentBuilder<BukkitBrigadierCommandSource, ?>> arguments = getArguments(defaultMethod);
|
||||||
|
for (Map.Entry<Parameter, RequiredArgumentBuilder<BukkitBrigadierCommandSource, ?>> parameterArgumentBuilderEntry : arguments.entrySet())
|
||||||
|
{
|
||||||
|
argumentBuilders.addLast(parameterArgumentBuilderEntry.getValue());
|
||||||
|
}
|
||||||
|
boolean setExecution = false;
|
||||||
|
CommandNode<BukkitBrigadierCommandSource> parentArg = null;
|
||||||
|
CommandNode<BukkitBrigadierCommandSource> currArg = null;
|
||||||
|
while (!argumentBuilders.isEmpty())
|
||||||
|
{
|
||||||
|
if (parentArg == null)
|
||||||
|
{
|
||||||
|
RequiredArgumentBuilder<BukkitBrigadierCommandSource, ?> newParent = argumentBuilders.removeFirst();
|
||||||
|
if (argumentBuilders.isEmpty())
|
||||||
|
{
|
||||||
|
Method finalDefaultMethod = defaultMethod;
|
||||||
|
newParent.executes(context -> execute(finalDefaultMethod, context, arguments.keySet()));
|
||||||
|
setExecution = true;
|
||||||
|
}
|
||||||
|
parentArg = newParent.build();
|
||||||
|
builder.then(parentArg);
|
||||||
|
currArg = parentArg;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
RequiredArgumentBuilder<BukkitBrigadierCommandSource, ?> newCurrArg = argumentBuilders.removeFirst();
|
||||||
|
if (argumentBuilders.isEmpty())
|
||||||
|
{
|
||||||
|
Method finalDefaultMethod1 = defaultMethod;
|
||||||
|
newCurrArg.executes(context -> execute(finalDefaultMethod1, context, arguments.keySet()));
|
||||||
|
setExecution = true;
|
||||||
|
}
|
||||||
|
CommandNode<BukkitBrigadierCommandSource> newCurrNode = newCurrArg.build();
|
||||||
|
currArg.addChild(newCurrNode);
|
||||||
|
currArg = newCurrNode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!setExecution)
|
||||||
|
{
|
||||||
|
Method finalDefaultMethod2 = defaultMethod;
|
||||||
|
builder.executes(context -> execute(finalDefaultMethod2, context, arguments.keySet()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.commandDispatcher.register(builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.commandDispatcher.register(LiteralArgumentBuilder.<BukkitBrigadierCommandSource>literal("testing")
|
||||||
|
.then(RequiredArgumentBuilder.<BukkitBrigadierCommandSource, Integer>argument("test0", IntegerArgumentType.integer())
|
||||||
|
.then(RequiredArgumentBuilder.<BukkitBrigadierCommandSource, String>argument("test", StringArgumentType.word())
|
||||||
|
.then(RequiredArgumentBuilder.<BukkitBrigadierCommandSource, String>argument("test1", StringArgumentType.word())
|
||||||
|
.executes(context ->
|
||||||
|
{
|
||||||
|
send(context, context.getArgument("test", String.class));
|
||||||
|
send(context, context.getArgument("test1", String.class));
|
||||||
|
return 1;
|
||||||
|
})))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public LiteralArgumentBuilder<BukkitBrigadierCommandSource> execute()
|
||||||
|
{
|
||||||
|
return LiteralArgumentBuilder.literal(this.getClass().getName().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a PlexPlayer from Player object
|
||||||
|
*
|
||||||
|
* @param player The player object
|
||||||
|
* @return PlexPlayer Object
|
||||||
|
* @see PlexPlayer
|
||||||
|
*/
|
||||||
|
protected PlexPlayer getPlexPlayer(@NotNull Player player)
|
||||||
|
{
|
||||||
|
return DataUtils.getPlayer(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void send(Audience audience, Component component)
|
||||||
|
{
|
||||||
|
audience.sendMessage(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a message to an Audience
|
||||||
|
*
|
||||||
|
* @param audience The Audience to send the message to
|
||||||
|
* @param s The message to send
|
||||||
|
*/
|
||||||
|
protected void send(Audience audience, String s)
|
||||||
|
{
|
||||||
|
audience.sendMessage(componentFromString(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a message to a CommandSender
|
||||||
|
*
|
||||||
|
* @param context The Command Context's sender to send the message to
|
||||||
|
* @param s The message to send
|
||||||
|
*/
|
||||||
|
protected void send(CommandContext<BukkitBrigadierCommandSource> context, String s)
|
||||||
|
{
|
||||||
|
context.getSource().getBukkitSender().sendMessage(componentFromString(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends a message to a CommandSender
|
||||||
|
*
|
||||||
|
* @param context The Command Context's sender to send the message to
|
||||||
|
* @param component The Component to send
|
||||||
|
*/
|
||||||
|
protected void send(CommandContext<BukkitBrigadierCommandSource> context, Component component)
|
||||||
|
{
|
||||||
|
context.getSource().getBukkitSender().sendMessage(component);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a String to a MiniMessage Component
|
||||||
|
*
|
||||||
|
* @param s The String to convert
|
||||||
|
* @return A Kyori Component
|
||||||
|
*/
|
||||||
|
protected Component mmString(String s)
|
||||||
|
{
|
||||||
|
return PlexUtils.mmDeserialize(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a String to a legacy Kyori Component
|
||||||
|
*
|
||||||
|
* @param s The String to convert
|
||||||
|
* @return A Kyori component
|
||||||
|
*/
|
||||||
|
protected Component componentFromString(String s)
|
||||||
|
{
|
||||||
|
return LegacyComponentSerializer.legacyAmpersand().deserialize(s).colorIfAbsent(NamedTextColor.GRAY);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a player is an admin
|
||||||
|
*
|
||||||
|
* @param plexPlayer The PlexPlayer object
|
||||||
|
* @return true if the player is an admin
|
||||||
|
* @see PlexPlayer
|
||||||
|
*/
|
||||||
|
protected boolean isAdmin(PlexPlayer plexPlayer)
|
||||||
|
{
|
||||||
|
return Plex.get().getRankManager().isAdmin(plexPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a sender is an admin
|
||||||
|
*
|
||||||
|
* @param sender A command sender
|
||||||
|
* @return true if the sender is an admin or if console
|
||||||
|
*/
|
||||||
|
protected boolean isAdmin(CommandSender sender)
|
||||||
|
{
|
||||||
|
if (!(sender instanceof Player player))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
PlexPlayer plexPlayer = getPlexPlayer(player);
|
||||||
|
return plugin.getRankManager().isAdmin(plexPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a username is an admin
|
||||||
|
*
|
||||||
|
* @param name The username
|
||||||
|
* @return true if the username is an admin
|
||||||
|
*/
|
||||||
|
protected boolean isAdmin(String name)
|
||||||
|
{
|
||||||
|
PlexPlayer plexPlayer = DataUtils.getPlayer(name);
|
||||||
|
return plugin.getRankManager().isAdmin(plexPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if a sender is a senior admin
|
||||||
|
*
|
||||||
|
* @param sender A command sender
|
||||||
|
* @return true if the sender is a senior admin or if console
|
||||||
|
*/
|
||||||
|
protected boolean isSeniorAdmin(CommandSender sender)
|
||||||
|
{
|
||||||
|
if (!(sender instanceof Player player))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
PlexPlayer plexPlayer = getPlexPlayer(player);
|
||||||
|
return plugin.getRankManager().isSeniorAdmin(plexPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the UUID of the sender
|
||||||
|
*
|
||||||
|
* @param sender A command sender
|
||||||
|
* @return A unique ID or null if the sender is console
|
||||||
|
* @see UUID
|
||||||
|
*/
|
||||||
|
protected UUID getUUID(CommandSender sender)
|
||||||
|
{
|
||||||
|
if (!(sender instanceof Player player))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return player.getUniqueId();
|
||||||
|
}
|
||||||
|
|
||||||
|
private LinkedHashMap<Parameter, RequiredArgumentBuilder<BukkitBrigadierCommandSource, ?>> getArguments(Method method)
|
||||||
|
{
|
||||||
|
LinkedHashMap<Parameter, RequiredArgumentBuilder<BukkitBrigadierCommandSource, ?>> result = new LinkedHashMap<>();
|
||||||
|
if (!method.canAccess(this))
|
||||||
|
{
|
||||||
|
method.setAccessible(true);
|
||||||
|
}
|
||||||
|
for (Parameter parameter : method.getParameters())
|
||||||
|
{
|
||||||
|
if (parameter.isAnnotationPresent(Argument.class))
|
||||||
|
{
|
||||||
|
Argument argument = parameter.getAnnotation(Argument.class);
|
||||||
|
if (String.class.isAssignableFrom(parameter.getType()))
|
||||||
|
{
|
||||||
|
result.put(parameter, RequiredArgumentBuilder.argument(argument.value(), argument.argumentType() == StringArgumentType.StringType.SINGLE_WORD ? StringArgumentType.word() : StringArgumentType.greedyString()));
|
||||||
|
}
|
||||||
|
else if (int.class.isAssignableFrom(parameter.getType()))
|
||||||
|
{
|
||||||
|
result.put(parameter, RequiredArgumentBuilder.argument(argument.value(), IntegerArgumentType.integer(argument.min() == Double.MIN_VALUE ? Integer.MIN_VALUE : (int) argument.min(), argument.max() == Double.MAX_VALUE ? Integer.MAX_VALUE : (int) argument.max())));
|
||||||
|
}
|
||||||
|
else if (double.class.isAssignableFrom(parameter.getType()))
|
||||||
|
{
|
||||||
|
result.put(parameter, RequiredArgumentBuilder.argument(argument.value(), DoubleArgumentType.doubleArg(argument.min(), argument.max())));
|
||||||
|
}
|
||||||
|
else if (float.class.isAssignableFrom(parameter.getType()))
|
||||||
|
{
|
||||||
|
result.put(parameter, RequiredArgumentBuilder.argument(argument.value(), FloatArgumentType.floatArg(argument.min() == Double.MIN_VALUE ? Float.MIN_VALUE : (int) argument.min(), argument.max() == Double.MAX_VALUE ? Float.MAX_VALUE : (int) argument.max())));
|
||||||
|
}
|
||||||
|
else if (boolean.class.isAssignableFrom(parameter.getType()))
|
||||||
|
{
|
||||||
|
result.put(parameter, RequiredArgumentBuilder.argument(argument.value(), BoolArgumentType.bool()));
|
||||||
|
}
|
||||||
|
else if (long.class.isAssignableFrom(parameter.getType()))
|
||||||
|
{
|
||||||
|
result.put(parameter, RequiredArgumentBuilder.argument(argument.value(), LongArgumentType.longArg(argument.min() == Double.MIN_VALUE ? Long.MIN_VALUE : (int) argument.min(), argument.max() == Double.MAX_VALUE ? Long.MAX_VALUE : (int) argument.max())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getArgument(Class<?> clazz, CommandContext<BukkitBrigadierCommandSource> context, String name)
|
||||||
|
{
|
||||||
|
if (String.class.isAssignableFrom(clazz))
|
||||||
|
{
|
||||||
|
return StringArgumentType.getString(context, name);
|
||||||
|
}
|
||||||
|
else if (int.class.isAssignableFrom(clazz))
|
||||||
|
{
|
||||||
|
return IntegerArgumentType.getInteger(context, name);
|
||||||
|
}
|
||||||
|
else if (double.class.isAssignableFrom(clazz))
|
||||||
|
{
|
||||||
|
return DoubleArgumentType.getDouble(context, name);
|
||||||
|
}
|
||||||
|
else if (float.class.isAssignableFrom(clazz))
|
||||||
|
{
|
||||||
|
return FloatArgumentType.getFloat(context, name);
|
||||||
|
}
|
||||||
|
else if (boolean.class.isAssignableFrom(clazz))
|
||||||
|
{
|
||||||
|
return BoolArgumentType.getBool(context, name);
|
||||||
|
}
|
||||||
|
else if (long.class.isAssignableFrom(clazz))
|
||||||
|
{
|
||||||
|
return LongArgumentType.getLong(context, name);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int execute(Method method, CommandContext<BukkitBrigadierCommandSource> context, Set<Parameter> arguments)
|
||||||
|
{
|
||||||
|
if (method.isAnnotationPresent(CommandPermission.class))
|
||||||
|
{
|
||||||
|
String permission = method.getAnnotation(CommandPermission.class).value();
|
||||||
|
if (!context.getSource().getBukkitSender().hasPermission(permission))
|
||||||
|
{
|
||||||
|
send(context, PlexUtils.messageComponent("noPermissionNode", permission));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<Object> params = arguments
|
||||||
|
.stream().map(bukkitBrigadierCommandSourceArgumentBuilder -> getArgument(bukkitBrigadierCommandSourceArgumentBuilder.getType(), context, bukkitBrigadierCommandSourceArgumentBuilder.getAnnotation(Argument.class).value())).toList();
|
||||||
|
LinkedList<Object> parameters = new LinkedList<>(params);
|
||||||
|
// parameters.addFirst(context.getSource().getBukkitSender());
|
||||||
|
if (method.isAnnotationPresent(CommandSource.class)) {
|
||||||
|
RequiredCommandSource commandSource = method.getAnnotation(CommandSource.class).value();
|
||||||
|
if (commandSource == RequiredCommandSource.IN_GAME) {
|
||||||
|
if (!(context.getSource().getBukkitSender() instanceof Player player)) {
|
||||||
|
send(context, PlexUtils.messageComponent("noPermissionConsole"));
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
parameters.addFirst(player);
|
||||||
|
}
|
||||||
|
} else if (commandSource == RequiredCommandSource.CONSOLE) {
|
||||||
|
if (context.getSource().getBukkitSender() instanceof Player) {
|
||||||
|
send(context, PlexUtils.messageComponent("noPermissionInGame"));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
parameters.addFirst(context.getSource().getBukkitSender());
|
||||||
|
} else {
|
||||||
|
parameters.addFirst(context.getSource().getBukkitSender());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println(Arrays.toString(parameters.stream().map(Object::getClass).map(Class::getName).toArray()));
|
||||||
|
System.out.println(Arrays.toString(Arrays.stream(method.getParameterTypes()).map(Class::getName).toArray()));
|
||||||
|
method.invoke(this, parameters.toArray());
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
PlexLog.error(e.getMessage());
|
||||||
|
for (StackTraceElement stackTraceElement : e.getStackTrace())
|
||||||
|
{
|
||||||
|
PlexLog.error(stackTraceElement.toString());
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object getCraftServer()
|
||||||
|
{
|
||||||
|
String nmsVersion = Bukkit.getServer().getClass().getPackage().getName();
|
||||||
|
nmsVersion = nmsVersion.substring(nmsVersion.lastIndexOf('.') + 1);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Class<?> craftServer = Class.forName("org.bukkit.craftbukkit." + nmsVersion + ".CraftServer");
|
||||||
|
return craftServer.cast(Bukkit.getServer());
|
||||||
|
}
|
||||||
|
catch (ClassNotFoundException e)
|
||||||
|
{
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,18 +4,12 @@ import dev.plex.Plex;
|
|||||||
import dev.plex.cache.DataUtils;
|
import dev.plex.cache.DataUtils;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.exception.CommandFailException;
|
import dev.plex.command.exception.*;
|
||||||
import dev.plex.command.exception.ConsoleMustDefinePlayerException;
|
|
||||||
import dev.plex.command.exception.ConsoleOnlyException;
|
|
||||||
import dev.plex.command.exception.PlayerNotBannedException;
|
|
||||||
import dev.plex.command.exception.PlayerNotFoundException;
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.UUID;
|
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
@ -23,15 +17,14 @@ import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.*;
|
||||||
import org.bukkit.command.CommandMap;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
|
||||||
import org.bukkit.command.PluginIdentifiableCommand;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Superclass for all commands
|
* Superclass for all commands
|
||||||
*/
|
*/
|
||||||
@ -206,7 +199,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Component component = this.execute(sender, isConsole(sender) ? null : (Player)sender, args);
|
Component component = this.execute(sender, isConsole(sender) ? null : (Player) sender, args);
|
||||||
if (component != null)
|
if (component != null)
|
||||||
{
|
{
|
||||||
send(sender, component);
|
send(sender, component);
|
||||||
@ -292,7 +285,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
{
|
{
|
||||||
if (!isConsole(sender))
|
if (!isConsole(sender))
|
||||||
{
|
{
|
||||||
return checkRank((Player)sender, rank, permission);
|
return checkRank((Player) sender, rank, permission);
|
||||||
}
|
}
|
||||||
if (!sender.getName().equalsIgnoreCase("console"))
|
if (!sender.getName().equalsIgnoreCase("console"))
|
||||||
{
|
{
|
||||||
@ -387,7 +380,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
{
|
{
|
||||||
if (!isConsole(sender))
|
if (!isConsole(sender))
|
||||||
{
|
{
|
||||||
return checkTab((Player)sender, rank, permission);
|
return checkTab((Player) sender, rank, permission);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package dev.plex.command.annotation;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Taah
|
||||||
|
* @since 4:31 AM [08-07-2023]
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.PARAMETER)
|
||||||
|
public @interface Argument
|
||||||
|
{
|
||||||
|
String value();
|
||||||
|
|
||||||
|
StringArgumentType.StringType argumentType() default StringArgumentType.StringType.SINGLE_WORD;
|
||||||
|
|
||||||
|
double min() default Double.MIN_VALUE;
|
||||||
|
double max() default Double.MAX_VALUE;
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package dev.plex.command.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Taah
|
||||||
|
* @since 4:54 PM [07-07-2023]
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
public @interface CommandName
|
||||||
|
{
|
||||||
|
String[] value();
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package dev.plex.command.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Taah
|
||||||
|
* @since 4:54 PM [07-07-2023]
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
public @interface CommandPermission
|
||||||
|
{
|
||||||
|
String value();
|
||||||
|
}
|
@ -2,6 +2,7 @@ package dev.plex.command.annotation;
|
|||||||
|
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
package dev.plex.command.annotation;
|
||||||
|
|
||||||
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Taah
|
||||||
|
* @since 7:08 AM [09-07-2023]
|
||||||
|
*/
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
public @interface CommandSource
|
||||||
|
{
|
||||||
|
RequiredCommandSource value() default RequiredCommandSource.ANY;
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package dev.plex.command.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Taah
|
||||||
|
* @since 4:54 PM [07-07-2023]
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
public @interface Default
|
||||||
|
{
|
||||||
|
}
|
@ -0,0 +1,18 @@
|
|||||||
|
package dev.plex.command.annotation;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Taah
|
||||||
|
* @since 4:46 PM [07-07-2023]
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
public @interface SubCommand
|
||||||
|
{
|
||||||
|
String value();
|
||||||
|
}
|
@ -1,10 +1,11 @@
|
|||||||
package dev.plex.command.blocking;
|
package dev.plex.command.blocking;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import java.util.List;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class BlockedCommand
|
public class BlockedCommand
|
||||||
{
|
{
|
||||||
|
@ -15,8 +15,6 @@ import dev.plex.event.AdminSetRankEvent;
|
|||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -25,6 +23,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "admin", usage = "/<command> <add <player> | remove <player> | setrank <player> <rank> | list>", aliases = "saconfig,slconfig,adminconfig,adminmanage", description = "Manage all admins")
|
@CommandParameters(name = "admin", usage = "/<command> <add <player> | remove <player> | setrank <player> <rank> | list>", aliases = "saconfig,slconfig,adminconfig,adminmanage", description = "Manage all admins")
|
||||||
@System(value = "ranks")
|
@System(value = "ranks")
|
||||||
|
@ -10,7 +10,6 @@ import dev.plex.rank.enums.Rank;
|
|||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||||
import dev.plex.util.redis.MessageUtil;
|
import dev.plex.util.redis.MessageUtil;
|
||||||
import java.util.UUID;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -19,6 +18,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.adminchat", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.adminchat", source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "adminchat", description = "Talk privately with other admins", usage = "/<command> <message>", aliases = "o,ac,sc,staffchat")
|
@CommandParameters(name = "adminchat", description = "Talk privately with other admins", usage = "/<command> <message>", aliases = "o,ac,sc,staffchat")
|
||||||
public class AdminChatCMD extends PlexCommand
|
public class AdminChatCMD extends PlexCommand
|
||||||
@ -28,7 +29,8 @@ public class AdminChatCMD extends PlexCommand
|
|||||||
{
|
{
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
if (playerSender != null) {
|
if (playerSender != null)
|
||||||
|
{
|
||||||
PlexPlayer player = DataUtils.getPlayer(playerSender.getUniqueId());
|
PlexPlayer player = DataUtils.getPlayer(playerSender.getUniqueId());
|
||||||
player.setStaffChat(!player.isStaffChat());
|
player.setStaffChat(!player.isStaffChat());
|
||||||
return messageComponent("adminChatToggled", BooleanUtils.toStringOnOff(player.isStaffChat()));
|
return messageComponent("adminChatToggled", BooleanUtils.toStringOnOff(player.isStaffChat()));
|
||||||
|
@ -9,7 +9,6 @@ import dev.plex.command.source.RequiredCommandSource;
|
|||||||
import dev.plex.event.GameModeUpdateEvent;
|
import dev.plex.event.GameModeUpdateEvent;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -18,6 +17,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, permission = "plex.gamemode.adventure", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.OP, permission = "plex.gamemode.adventure", source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "adventure", aliases = "gma,egma,eadventure,adventuremode,eadventuremode", description = "Set your own or another player's gamemode to adventure mode")
|
@CommandParameters(name = "adventure", aliases = "gma,egma,eadventure,adventuremode,eadventuremode", description = "Set your own or another player's gamemode to adventure mode")
|
||||||
public class AdventureCMD extends PlexCommand
|
public class AdventureCMD extends PlexCommand
|
||||||
@ -29,7 +30,7 @@ public class AdventureCMD extends PlexCommand
|
|||||||
{
|
{
|
||||||
if (isConsole(sender))
|
if (isConsole(sender))
|
||||||
{
|
{
|
||||||
throw new CommandFailException(PlexUtils.messageString("consoleMustDefinePlayer"));
|
throw new CommandFailException(messageString("consoleMustDefinePlayer"));
|
||||||
}
|
}
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new GameModeUpdateEvent(sender, playerSender, GameMode.ADVENTURE));
|
Bukkit.getServer().getPluginManager().callEvent(new GameModeUpdateEvent(sender, playerSender, GameMode.ADVENTURE));
|
||||||
return null;
|
return null;
|
||||||
|
@ -12,15 +12,7 @@ import dev.plex.player.PlexPlayer;
|
|||||||
import dev.plex.punishment.Punishment;
|
import dev.plex.punishment.Punishment;
|
||||||
import dev.plex.punishment.PunishmentType;
|
import dev.plex.punishment.PunishmentType;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.BungeeUtil;
|
import dev.plex.util.*;
|
||||||
import dev.plex.util.PlexLog;
|
|
||||||
import dev.plex.util.PlexUtils;
|
|
||||||
import dev.plex.util.TimeUtils;
|
|
||||||
import dev.plex.util.WebUtils;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -29,6 +21,11 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@CommandParameters(name = "ban", usage = "/<command> <player> [reason]", aliases = "offlineban,gtfo", description = "Bans a player, offline or online")
|
@CommandParameters(name = "ban", usage = "/<command> <player> [reason]", aliases = "offlineban,gtfo", description = "Bans a player, offline or online")
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.ban", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.ban", source = RequiredCommandSource.ANY)
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ public class CommandSpyCMD extends PlexCommand
|
|||||||
{
|
{
|
||||||
if (playerSender != null)
|
if (playerSender != null)
|
||||||
{
|
{
|
||||||
PlexPlayer plexPlayer = DataUtils.getPlayer(playerSender.getUniqueId());
|
PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayer(playerSender.getUniqueId());
|
||||||
plexPlayer.setCommandSpy(!plexPlayer.isCommandSpy());
|
plexPlayer.setCommandSpy(!plexPlayer.isCommandSpy());
|
||||||
DataUtils.update(plexPlayer);
|
DataUtils.update(plexPlayer);
|
||||||
send(sender, messageComponent("toggleCommandSpy")
|
send(sender, messageComponent("toggleCommandSpy")
|
||||||
|
@ -9,7 +9,6 @@ import dev.plex.command.source.RequiredCommandSource;
|
|||||||
import dev.plex.event.GameModeUpdateEvent;
|
import dev.plex.event.GameModeUpdateEvent;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -18,6 +17,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, permission = "plex.gamemode.creative", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.OP, permission = "plex.gamemode.creative", source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "creative", aliases = "gmc,egmc,ecreative,eecreative,creativemode,ecreativemode", description = "Set your own or another player's gamemode to creative mode")
|
@CommandParameters(name = "creative", aliases = "gmc,egmc,ecreative,eecreative,creativemode,ecreativemode", description = "Set your own or another player's gamemode to creative mode")
|
||||||
public class CreativeCMD extends PlexCommand
|
public class CreativeCMD extends PlexCommand
|
||||||
@ -29,7 +30,7 @@ public class CreativeCMD extends PlexCommand
|
|||||||
{
|
{
|
||||||
if (isConsole(sender))
|
if (isConsole(sender))
|
||||||
{
|
{
|
||||||
throw new CommandFailException(PlexUtils.messageString("consoleMustDefinePlayer"));
|
throw new CommandFailException(messageString("consoleMustDefinePlayer"));
|
||||||
}
|
}
|
||||||
if (!(playerSender == null))
|
if (!(playerSender == null))
|
||||||
{
|
{
|
||||||
|
@ -9,9 +9,6 @@ import dev.plex.rank.enums.Rank;
|
|||||||
import dev.plex.util.GameRuleUtil;
|
import dev.plex.util.GameRuleUtil;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -22,6 +19,10 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
@CommandParameters(name = "pdebug", description = "Plex's debug command", usage = "/<command> <aliases <command> | redis-reset <player> | gamerules>")
|
@CommandParameters(name = "pdebug", description = "Plex's debug command", usage = "/<command> <aliases <command> | redis-reset <player> | gamerules>")
|
||||||
@CommandPermissions(level = Rank.EXECUTIVE, permission = "plex.debug")
|
@CommandPermissions(level = Rank.EXECUTIVE, permission = "plex.debug")
|
||||||
@System(debug = true)
|
@System(debug = true)
|
||||||
@ -36,13 +37,16 @@ public class DebugCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("redis-reset"))
|
if (args[0].equalsIgnoreCase("redis-reset"))
|
||||||
{
|
{
|
||||||
Player player = getNonNullPlayer(args[1]);
|
if (args.length == 2)
|
||||||
if (plugin.getRedisConnection().getJedis().exists(player.getUniqueId().toString()))
|
|
||||||
{
|
{
|
||||||
plugin.getRedisConnection().getJedis().del(player.getUniqueId().toString());
|
Player player = getNonNullPlayer(args[1]);
|
||||||
return componentFromString("Successfully reset " + player.getName() + "'s Redis punishments!").color(NamedTextColor.YELLOW);
|
if (plugin.getRedisConnection().getJedis().exists(player.getUniqueId().toString()))
|
||||||
|
{
|
||||||
|
plugin.getRedisConnection().getJedis().del(player.getUniqueId().toString());
|
||||||
|
return componentFromString("Successfully reset " + player.getName() + "'s Redis punishments!").color(NamedTextColor.YELLOW);
|
||||||
|
}
|
||||||
|
return componentFromString("Couldn't find player in Redis punishments.");
|
||||||
}
|
}
|
||||||
return componentFromString("Couldn't find player in Redis punishments.");
|
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("gamerules"))
|
if (args[0].equalsIgnoreCase("gamerules"))
|
||||||
{
|
{
|
||||||
@ -64,15 +68,18 @@ public class DebugCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("aliases"))
|
if (args[0].equalsIgnoreCase("aliases"))
|
||||||
{
|
{
|
||||||
String commandName = args[1];
|
if (args.length == 2)
|
||||||
Command command = plugin.getServer().getCommandMap().getCommand(commandName);
|
|
||||||
if (command == null)
|
|
||||||
{
|
{
|
||||||
return mmString("<red>That command could not be found!");
|
String commandName = args[1];
|
||||||
|
Command command = plugin.getServer().getCommandMap().getCommand(commandName);
|
||||||
|
if (command == null)
|
||||||
|
{
|
||||||
|
return mmString("<red>That command could not be found!");
|
||||||
|
}
|
||||||
|
return mmString("<aqua>Aliases for " + commandName + " are: " + Arrays.toString(command.getAliases().toArray(new String[0])));
|
||||||
}
|
}
|
||||||
return mmString("<aqua>Aliases for " + commandName + " are: " + Arrays.toString(command.getAliases().toArray(new String[0])));
|
|
||||||
}
|
}
|
||||||
return null;
|
return usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -7,13 +7,14 @@ import dev.plex.command.annotation.CommandPermissions;
|
|||||||
import dev.plex.command.annotation.System;
|
import dev.plex.command.annotation.System;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandParameters(name = "deop", description = "Deop a player on the server", usage = "/<command> <player>")
|
@CommandParameters(name = "deop", description = "Deop a player on the server", usage = "/<command> <player>")
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.deop")
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.deop")
|
||||||
@System(value = "ranks")
|
@System(value = "ranks")
|
||||||
|
@ -6,11 +6,6 @@ import dev.plex.command.annotation.CommandPermissions;
|
|||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -21,6 +16,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.entitywipe", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.entitywipe", source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "entitywipe", description = "Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.", usage = "/<command> [name]", aliases = "ew,rd")
|
@CommandParameters(name = "entitywipe", description = "Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.", usage = "/<command> [name]", aliases = "ew,rd")
|
||||||
public class EntityWipeCMD extends PlexCommand
|
public class EntityWipeCMD extends PlexCommand
|
||||||
|
@ -10,15 +10,16 @@ import dev.plex.punishment.PunishmentType;
|
|||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.TimeUtils;
|
import dev.plex.util.TimeUtils;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandParameters(name = "freeze", description = "Freeze a player on the server", usage = "/<command> <player>", aliases = "fr")
|
@CommandParameters(name = "freeze", description = "Freeze a player on the server", usage = "/<command> <player>", aliases = "fr")
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.freeze")
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.freeze")
|
||||||
public class FreezeCMD extends PlexCommand
|
public class FreezeCMD extends PlexCommand
|
||||||
|
@ -8,9 +8,6 @@ import dev.plex.command.source.RequiredCommandSource;
|
|||||||
import dev.plex.event.GameModeUpdateEvent;
|
import dev.plex.event.GameModeUpdateEvent;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -19,6 +16,10 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandParameters(name = "gamemode", usage = "/<command> <creative | survival | adventure | default | spectator> [player]", description = "Change your gamemode", aliases = "gm,egamemode,gmt,egmt")
|
@CommandParameters(name = "gamemode", usage = "/<command> <creative | survival | adventure | default | spectator> [player]", description = "Change your gamemode", aliases = "gm,egamemode,gmt,egmt")
|
||||||
@CommandPermissions(level = Rank.OP, permission = "plex.gamemode", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.OP, permission = "plex.gamemode", source = RequiredCommandSource.ANY)
|
||||||
public class GamemodeCMD extends PlexCommand
|
public class GamemodeCMD extends PlexCommand
|
||||||
|
@ -14,9 +14,6 @@ import dev.plex.util.BungeeUtil;
|
|||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.TimeUtils;
|
import dev.plex.util.TimeUtils;
|
||||||
import dev.plex.util.WebUtils;
|
import dev.plex.util.WebUtils;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.util.UUID;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -25,6 +22,10 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@CommandParameters(name = "kick", description = "Kicks a player", usage = "/<command> <player>")
|
@CommandParameters(name = "kick", description = "Kicks a player", usage = "/<command> <player>")
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.kick", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.kick", source = RequiredCommandSource.ANY)
|
||||||
public class KickCMD extends PlexCommand
|
public class KickCMD extends PlexCommand
|
||||||
@ -56,9 +57,9 @@ public class KickCMD extends PlexCommand
|
|||||||
if (args.length > 1)
|
if (args.length > 1)
|
||||||
{
|
{
|
||||||
reason = StringUtils.join(args, " ", 1, args.length);
|
reason = StringUtils.join(args, " ", 1, args.length);
|
||||||
punishment.setReason(reason);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
punishment.setReason(reason);
|
||||||
punishment.setPunishedUsername(plexPlayer.getName());
|
punishment.setPunishedUsername(plexPlayer.getName());
|
||||||
punishment.setEndDate(ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE)));
|
punishment.setEndDate(ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE)));
|
||||||
punishment.setCustomTime(false);
|
punishment.setCustomTime(false);
|
||||||
|
@ -4,9 +4,8 @@ import com.google.common.collect.Lists;
|
|||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.annotation.System;
|
import dev.plex.hook.VaultHook;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -15,9 +14,10 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@CommandParameters(name = "list", description = "Show a list of all online players", aliases = "lsit")
|
import java.util.List;
|
||||||
|
|
||||||
|
@CommandParameters(name = "list", description = "Show a list of all online players", aliases = "lsit,who,playerlist,online")
|
||||||
@CommandPermissions(level = Rank.OP, permission = "plex.list")
|
@CommandPermissions(level = Rank.OP, permission = "plex.list")
|
||||||
@System(value = "ranks")
|
|
||||||
public class ListCMD extends PlexCommand
|
public class ListCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
@ -44,7 +44,14 @@ public class ListCMD extends PlexCommand
|
|||||||
for (int i = 0; i < players.size(); i++)
|
for (int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
Player player = players.get(i);
|
Player player = players.get(i);
|
||||||
list = list.append(getPlexPlayer(player).getRankFromString().getPrefix()).append(Component.space()).append(Component.text(player.getName()).color(NamedTextColor.WHITE));
|
if (plugin.getSystem().equals("ranks"))
|
||||||
|
{
|
||||||
|
list = list.append(getPlexPlayer(player).getRankFromString().getPrefix()).append(Component.space()).append(Component.text(player.getName()).color(NamedTextColor.WHITE));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list = list.append(VaultHook.getPrefix(getPlexPlayer(player))).append(Component.space()).append(Component.text(player.getName()).color(NamedTextColor.WHITE));
|
||||||
|
}
|
||||||
if (i != players.size() - 1)
|
if (i != players.size() - 1)
|
||||||
{
|
{
|
||||||
list = list.append(Component.text(",")).append(Component.space());
|
list = list.append(Component.text(",")).append(Component.space());
|
||||||
|
@ -7,13 +7,14 @@ import dev.plex.command.annotation.CommandPermissions;
|
|||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandParameters(name = "lockup", description = "Lockup a player on the server", usage = "/<command> <player>")
|
@CommandParameters(name = "lockup", description = "Lockup a player on the server", usage = "/<command> <player>")
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.lockup")
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.lockup")
|
||||||
public class LockupCMD extends PlexCommand
|
public class LockupCMD extends PlexCommand
|
||||||
|
@ -6,7 +6,6 @@ import dev.plex.command.annotation.CommandPermissions;
|
|||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.HashMap;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -17,6 +16,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.mobpurge", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.mobpurge", source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "mobpurge", description = "Purge all mobs.", usage = "/<command>", aliases = "mp")
|
@CommandParameters(name = "mobpurge", description = "Purge all mobs.", usage = "/<command>", aliases = "mp")
|
||||||
public class MobPurgeCMD extends PlexCommand
|
public class MobPurgeCMD extends PlexCommand
|
||||||
|
@ -10,15 +10,16 @@ import dev.plex.punishment.PunishmentType;
|
|||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.TimeUtils;
|
import dev.plex.util.TimeUtils;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandParameters(name = "mute", description = "Mute a player on the server", usage = "/<command> <player>", aliases = "stfu")
|
@CommandParameters(name = "mute", description = "Mute a player on the server", usage = "/<command> <player>", aliases = "stfu")
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.mute")
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.mute")
|
||||||
public class MuteCMD extends PlexCommand
|
public class MuteCMD extends PlexCommand
|
||||||
|
@ -6,13 +6,7 @@ import dev.plex.command.PlexCommand;
|
|||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.AshconInfo;
|
import dev.plex.util.*;
|
||||||
import dev.plex.util.MojangUtils;
|
|
||||||
import dev.plex.util.PlexLog;
|
|
||||||
import dev.plex.util.PlexUtils;
|
|
||||||
import dev.plex.util.TimeUtils;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -20,6 +14,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandParameters(name = "namehistory", description = "Get the name history of a player", usage = "/<command> <player>", aliases = "nh")
|
@CommandParameters(name = "namehistory", description = "Get the name history of a player", usage = "/<command> <player>", aliases = "nh")
|
||||||
@CommandPermissions(level = Rank.OP, permission = "plex.namehistory")
|
@CommandPermissions(level = Rank.OP, permission = "plex.namehistory")
|
||||||
public class NameHistoryCMD extends PlexCommand
|
public class NameHistoryCMD extends PlexCommand
|
||||||
|
@ -10,12 +10,6 @@ import dev.plex.rank.enums.Rank;
|
|||||||
import dev.plex.storage.StorageType;
|
import dev.plex.storage.StorageType;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.TimeUtils;
|
import dev.plex.util.TimeUtils;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
@ -25,6 +19,13 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
@CommandParameters(name = "notes", description = "Manage notes for a player", usage = "/<command> <player> <list | add <note> | remove <id> | clear>")
|
@CommandParameters(name = "notes", description = "Manage notes for a player", usage = "/<command> <player> <list | add <note> | remove <id> | clear>")
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.notes")
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.notes")
|
||||||
public class NotesCMD extends PlexCommand
|
public class NotesCMD extends PlexCommand
|
||||||
|
@ -7,13 +7,14 @@ import dev.plex.command.annotation.CommandPermissions;
|
|||||||
import dev.plex.command.annotation.System;
|
import dev.plex.command.annotation.System;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandParameters(name = "op", description = "Op a player on the server", usage = "/<command> <player>")
|
@CommandParameters(name = "op", description = "Op a player on the server", usage = "/<command> <player>")
|
||||||
@CommandPermissions(level = Rank.OP)
|
@CommandPermissions(level = Rank.OP)
|
||||||
@System(value = "ranks")
|
@System(value = "ranks")
|
||||||
|
@ -11,10 +11,6 @@ import dev.plex.rank.enums.Rank;
|
|||||||
import dev.plex.util.BuildInfo;
|
import dev.plex.util.BuildInfo;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.TimeUtils;
|
import dev.plex.util.TimeUtils;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -24,10 +20,18 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.IMPOSTOR, source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.IMPOSTOR, source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "plex", usage = "/<command> [reload | redis | modules [reload]]", description = "Show information about Plex or reload it")
|
@CommandParameters(name = "plex", usage = "/<command> [reload | redis | modules [reload]]", description = "Show information about Plex or reload it")
|
||||||
public class PlexCMD extends PlexCommand
|
public class PlexCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
|
public PlexCMD() {
|
||||||
|
super(false);
|
||||||
|
}
|
||||||
// Don't modify this command
|
// Don't modify this command
|
||||||
@Override
|
@Override
|
||||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||||
@ -72,14 +76,7 @@ public class PlexCMD extends PlexCommand
|
|||||||
else if (args[0].equalsIgnoreCase("redis"))
|
else if (args[0].equalsIgnoreCase("redis"))
|
||||||
{
|
{
|
||||||
checkRank(sender, Rank.SENIOR_ADMIN, "plex.redis");
|
checkRank(sender, Rank.SENIOR_ADMIN, "plex.redis");
|
||||||
if (!plugin.getRedisConnection().isEnabled())
|
|
||||||
{
|
|
||||||
throw new CommandFailException("&cRedis is not enabled.");
|
|
||||||
}
|
|
||||||
plugin.getRedisConnection().getJedis().set("test", "123");
|
|
||||||
send(sender, "Set test to 123. Now outputting key test...");
|
|
||||||
send(sender, plugin.getRedisConnection().getJedis().get("test"));
|
|
||||||
plugin.getRedisConnection().getJedis().close();
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("modules"))
|
else if (args[0].equalsIgnoreCase("modules"))
|
||||||
|
@ -8,13 +8,14 @@ import dev.plex.command.source.RequiredCommandSource;
|
|||||||
import dev.plex.menu.PunishmentMenu;
|
import dev.plex.menu.PunishmentMenu;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandParameters(name = "punishments", usage = "/<command> [player]", description = "Opens the Punishments GUI", aliases = "punishlist,punishes")
|
@CommandParameters(name = "punishments", usage = "/<command> [player]", description = "Opens the Punishments GUI", aliases = "punishlist,punishes")
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.punishments", source = RequiredCommandSource.IN_GAME)
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.punishments", source = RequiredCommandSource.IN_GAME)
|
||||||
public class PunishmentsCMD extends PlexCommand
|
public class PunishmentsCMD extends PlexCommand
|
||||||
|
@ -8,14 +8,15 @@ import dev.plex.command.exception.CommandFailException;
|
|||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, permission = "plex.rank", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.OP, permission = "plex.rank", source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "rank", description = "Displays your rank")
|
@CommandParameters(name = "rank", description = "Displays your rank")
|
||||||
@System(value = "ranks")
|
@System(value = "ranks")
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package dev.plex.command.impl;
|
||||||
|
|
||||||
|
import dev.plex.cache.DataUtils;
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
|
import dev.plex.player.PlexPlayer;
|
||||||
|
import dev.plex.rank.enums.Rank;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.removeloginmessage", source = RequiredCommandSource.ANY)
|
||||||
|
@CommandParameters(name = "removeloginmessage", usage = "/<command> [-o <player>]", description = "Remove your own (or someone else's) login message", aliases = "rlm,removeloginmsg")
|
||||||
|
public class RemoveLoginMessageCMD extends PlexCommand
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length == 0 && !isConsole(sender))
|
||||||
|
{
|
||||||
|
if (playerSender != null)
|
||||||
|
{
|
||||||
|
PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayer(playerSender.getUniqueId());
|
||||||
|
plexPlayer.setLoginMessage("");
|
||||||
|
return messageComponent("removedOwnLoginMessage");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("-o"))
|
||||||
|
{
|
||||||
|
checkRank(sender, Rank.SENIOR_ADMIN, "plex.removeloginmessage.others");
|
||||||
|
|
||||||
|
if (args.length < 2)
|
||||||
|
{
|
||||||
|
return messageComponent("specifyPlayer");
|
||||||
|
}
|
||||||
|
|
||||||
|
PlexPlayer plexPlayer = DataUtils.getPlayer(args[1]);
|
||||||
|
if (plexPlayer == null)
|
||||||
|
{
|
||||||
|
return messageComponent("playerNotFound");
|
||||||
|
}
|
||||||
|
plexPlayer.setLoginMessage("");
|
||||||
|
return messageComponent("removedOtherLoginMessage", plexPlayer.getName());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return messageComponent("noPermissionConsole");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,89 @@
|
|||||||
|
package dev.plex.command.impl;
|
||||||
|
|
||||||
|
import dev.plex.cache.DataUtils;
|
||||||
|
import dev.plex.command.PlexCommand;
|
||||||
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
|
import dev.plex.command.exception.CommandFailException;
|
||||||
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
|
import dev.plex.player.PlexPlayer;
|
||||||
|
import dev.plex.rank.enums.Rank;
|
||||||
|
import dev.plex.util.PlexLog;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.setloginmessage", source = RequiredCommandSource.ANY)
|
||||||
|
@CommandParameters(name = "setloginmessage", usage = "/<command> [-o <player>] <message>", description = "Sets your (or someone else's) login message", aliases = "slm,setloginmsg")
|
||||||
|
public class SetLoginMessageCMD extends PlexCommand
|
||||||
|
{
|
||||||
|
private final boolean nameRequired = plugin.getConfig().getBoolean("loginmessages.name");
|
||||||
|
private final boolean rankRequired = plugin.getConfig().getBoolean("loginmessages.rank");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return usage();
|
||||||
|
}
|
||||||
|
if (playerSender != null)
|
||||||
|
{
|
||||||
|
if (args[0].equals("-o"))
|
||||||
|
{
|
||||||
|
checkRank(sender, Rank.SENIOR_ADMIN, "plex.setloginmessage.others");
|
||||||
|
|
||||||
|
if (args.length < 2)
|
||||||
|
{
|
||||||
|
return messageComponent("specifyPlayer");
|
||||||
|
}
|
||||||
|
if (args.length < 3)
|
||||||
|
{
|
||||||
|
return messageComponent("specifyLoginMessage");
|
||||||
|
}
|
||||||
|
PlexPlayer plexPlayer = DataUtils.getPlayer(args[1]);
|
||||||
|
if (plexPlayer == null)
|
||||||
|
{
|
||||||
|
return messageComponent("playerNotFound");
|
||||||
|
}
|
||||||
|
String message = StringUtils.join(args, " ", 2, args.length);
|
||||||
|
message = message.replace(plexPlayer.getName(), "%player%");
|
||||||
|
validateMessage(message);
|
||||||
|
plexPlayer.setLoginMessage(message);
|
||||||
|
return messageComponent("setOtherPlayersLoginMessage", plexPlayer.getName(),
|
||||||
|
message.replace("%player%", plexPlayer.getName())
|
||||||
|
.replace("%rank%", plexPlayer.getRank()));
|
||||||
|
}
|
||||||
|
if (isConsole(sender))
|
||||||
|
{
|
||||||
|
return messageComponent("noPermissionConsole");
|
||||||
|
}
|
||||||
|
PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayer(playerSender.getUniqueId());
|
||||||
|
String message = StringUtils.join(args, " ", 0, args.length);
|
||||||
|
message = message.replace(plexPlayer.getName(), "%player%");
|
||||||
|
validateMessage(message);
|
||||||
|
plexPlayer.setLoginMessage(message);
|
||||||
|
return messageComponent("setOwnLoginMessage",
|
||||||
|
message.replace("%player%", plexPlayer.getName())
|
||||||
|
.replace("%rank%", plexPlayer.getRank()));
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateMessage(String message)
|
||||||
|
{
|
||||||
|
if (nameRequired && !message.contains("%player%"))
|
||||||
|
{
|
||||||
|
PlexLog.debug("Validating login message has a valid name in it");
|
||||||
|
throw new CommandFailException(messageString("nameRequired"));
|
||||||
|
}
|
||||||
|
if (plugin.getSystem().equalsIgnoreCase("ranks") && rankRequired && !message.contains("%rank%"))
|
||||||
|
{
|
||||||
|
PlexLog.debug("Validating login message has a valid rank in it");
|
||||||
|
throw new CommandFailException(messageString("rankRequired"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -10,10 +10,6 @@ import dev.plex.punishment.PunishmentType;
|
|||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.TimeUtils;
|
import dev.plex.util.TimeUtils;
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.time.ZonedDateTime;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.title.Title;
|
import net.kyori.adventure.title.Title;
|
||||||
@ -27,6 +23,11 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.ZonedDateTime;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.smite", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.smite", source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "smite", usage = "/<command> <player> [reason] [-ci | -q]", description = "Someone being a little bitch? Smite them down...")
|
@CommandParameters(name = "smite", usage = "/<command> <player> [reason] [-ci | -q]", description = "Someone being a little bitch? Smite them down...")
|
||||||
public class SmiteCMD extends PlexCommand
|
public class SmiteCMD extends PlexCommand
|
||||||
|
@ -9,7 +9,6 @@ import dev.plex.command.source.RequiredCommandSource;
|
|||||||
import dev.plex.event.GameModeUpdateEvent;
|
import dev.plex.event.GameModeUpdateEvent;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -18,6 +17,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.gamemode.spectator", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.gamemode.spectator", source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "spectator", aliases = "gmsp,egmsp,spec", description = "Set your own or another player's gamemode to spectator mode")
|
@CommandParameters(name = "spectator", aliases = "gmsp,egmsp,spec", description = "Set your own or another player's gamemode to spectator mode")
|
||||||
public class SpectatorCMD extends PlexCommand
|
public class SpectatorCMD extends PlexCommand
|
||||||
@ -29,7 +30,7 @@ public class SpectatorCMD extends PlexCommand
|
|||||||
{
|
{
|
||||||
if (isConsole(sender))
|
if (isConsole(sender))
|
||||||
{
|
{
|
||||||
throw new CommandFailException(PlexUtils.messageString("consoleMustDefinePlayer"));
|
throw new CommandFailException(messageString("consoleMustDefinePlayer"));
|
||||||
}
|
}
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new GameModeUpdateEvent(sender, playerSender, GameMode.SPECTATOR));
|
Bukkit.getServer().getPluginManager().callEvent(new GameModeUpdateEvent(sender, playerSender, GameMode.SPECTATOR));
|
||||||
return null;
|
return null;
|
||||||
|
@ -9,7 +9,6 @@ import dev.plex.command.source.RequiredCommandSource;
|
|||||||
import dev.plex.event.GameModeUpdateEvent;
|
import dev.plex.event.GameModeUpdateEvent;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -18,6 +17,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, permission = "plex.gamemode.survival", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.OP, permission = "plex.gamemode.survival", source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "survival", aliases = "gms,egms,esurvival,survivalmode,esurvivalmode", description = "Set your own or another player's gamemode to survival mode")
|
@CommandParameters(name = "survival", aliases = "gms,egms,esurvival,survivalmode,esurvivalmode", description = "Set your own or another player's gamemode to survival mode")
|
||||||
public class SurvivalCMD extends PlexCommand
|
public class SurvivalCMD extends PlexCommand
|
||||||
@ -29,7 +30,7 @@ public class SurvivalCMD extends PlexCommand
|
|||||||
{
|
{
|
||||||
if (isConsole(sender))
|
if (isConsole(sender))
|
||||||
{
|
{
|
||||||
throw new CommandFailException(PlexUtils.messageString("consoleMustDefinePlayer"));
|
throw new CommandFailException(messageString("consoleMustDefinePlayer"));
|
||||||
}
|
}
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new GameModeUpdateEvent(sender, playerSender, GameMode.SURVIVAL));
|
Bukkit.getServer().getPluginManager().callEvent(new GameModeUpdateEvent(sender, playerSender, GameMode.SURVIVAL));
|
||||||
return null;
|
return null;
|
||||||
|
@ -7,8 +7,6 @@ import dev.plex.command.annotation.CommandPermissions;
|
|||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.inventory.Book;
|
import net.kyori.adventure.inventory.Book;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -16,6 +14,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandParameters(name = "totalfreedommod", description = "You can't simpy do that.", aliases = "tfm")
|
@CommandParameters(name = "totalfreedommod", description = "You can't simpy do that.", aliases = "tfm")
|
||||||
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.OP, source = RequiredCommandSource.ANY)
|
||||||
|
|
||||||
|
@ -15,8 +15,6 @@ import dev.plex.util.BungeeUtil;
|
|||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.TimeUtils;
|
import dev.plex.util.TimeUtils;
|
||||||
import dev.plex.util.WebUtils;
|
import dev.plex.util.WebUtils;
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -25,6 +23,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@CommandParameters(name = "tempban", usage = "/<command> <player> <time> [reason]", description = "Temporarily ban a player")
|
@CommandParameters(name = "tempban", usage = "/<command> <player> <time> [reason]", description = "Temporarily ban a player")
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.tempban", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.tempban", source = RequiredCommandSource.ANY)
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import dev.plex.command.source.RequiredCommandSource;
|
|||||||
import dev.plex.menu.ToggleMenu;
|
import dev.plex.menu.ToggleMenu;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -16,6 +15,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandParameters(name = "toggle", description = "Allows toggling various server aspects through a GUI", aliases = "toggles")
|
@CommandParameters(name = "toggle", description = "Allows toggling various server aspects through a GUI", aliases = "toggles")
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.toggle", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.toggle", source = RequiredCommandSource.ANY)
|
||||||
public class ToggleCMD extends PlexCommand
|
public class ToggleCMD extends PlexCommand
|
||||||
|
@ -12,14 +12,15 @@ import dev.plex.player.PlexPlayer;
|
|||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.WebUtils;
|
import dev.plex.util.WebUtils;
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
@CommandParameters(name = "unban", usage = "/<command> <player>", description = "Unbans a player, offline or online")
|
@CommandParameters(name = "unban", usage = "/<command> <player>", description = "Unbans a player, offline or online")
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.ban", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.ban", source = RequiredCommandSource.ANY)
|
||||||
|
|
||||||
|
@ -8,13 +8,14 @@ import dev.plex.command.exception.CommandFailException;
|
|||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.unfreeze")
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.unfreeze")
|
||||||
@CommandParameters(name = "unfreeze", description = "Unfreeze a player", usage = "/<command> <player>")
|
@CommandParameters(name = "unfreeze", description = "Unfreeze a player", usage = "/<command> <player>")
|
||||||
public class UnfreezeCMD extends PlexCommand
|
public class UnfreezeCMD extends PlexCommand
|
||||||
|
@ -8,13 +8,14 @@ import dev.plex.command.exception.CommandFailException;
|
|||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.unmute")
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.unmute")
|
||||||
@CommandParameters(name = "unmute", description = "Unmute a player", usage = "/<command> <player>")
|
@CommandParameters(name = "unmute", description = "Unmute a player", usage = "/<command> <player>")
|
||||||
public class UnmuteCMD extends PlexCommand
|
public class UnmuteCMD extends PlexCommand
|
||||||
|
@ -6,8 +6,6 @@ import dev.plex.command.annotation.CommandParameters;
|
|||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -17,6 +15,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, permission = "plex.world", source = RequiredCommandSource.IN_GAME)
|
@CommandPermissions(level = Rank.OP, permission = "plex.world", source = RequiredCommandSource.IN_GAME)
|
||||||
@CommandParameters(name = "world", description = "Teleport to a world.", usage = "/<command> <world>")
|
@CommandParameters(name = "world", description = "Teleport to a world.", usage = "/<command> <world>")
|
||||||
public class WorldCMD extends PlexCommand
|
public class WorldCMD extends PlexCommand
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package dev.plex.command.impl.brigadier;
|
||||||
|
|
||||||
|
import dev.plex.cache.DataUtils;
|
||||||
|
import dev.plex.command.PlexBrigadierCommand;
|
||||||
|
import dev.plex.command.annotation.CommandName;
|
||||||
|
import dev.plex.command.annotation.CommandPermission;
|
||||||
|
import dev.plex.command.annotation.CommandSource;
|
||||||
|
import dev.plex.command.annotation.Default;
|
||||||
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
|
import dev.plex.player.PlexPlayer;
|
||||||
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import static dev.plex.util.PlexUtils.messageComponent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Taah
|
||||||
|
* @since 6:54 AM [09-07-2023]
|
||||||
|
*/
|
||||||
|
@CommandName({"adminchat", "o", "sc", "ac", "staffchat"})
|
||||||
|
public class AdminChatCMD extends PlexBrigadierCommand
|
||||||
|
{
|
||||||
|
@Default
|
||||||
|
@CommandPermission("plex.adminchat")
|
||||||
|
@CommandSource(RequiredCommandSource.IN_GAME)
|
||||||
|
public void toggle(Player sender) {
|
||||||
|
PlexPlayer player = DataUtils.getPlayer(sender.getUniqueId());
|
||||||
|
player.setStaffChat(!player.isStaffChat());
|
||||||
|
send(sender, messageComponent("adminChatToggled", BooleanUtils.toStringOnOff(player.isStaffChat())));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
package dev.plex.command.impl.brigadier;
|
||||||
|
|
||||||
|
import com.mojang.brigadier.arguments.StringArgumentType;
|
||||||
|
import dev.plex.command.PlexBrigadierCommand;
|
||||||
|
import dev.plex.command.annotation.*;
|
||||||
|
import dev.plex.command.exception.CommandFailException;
|
||||||
|
import dev.plex.module.PlexModule;
|
||||||
|
import dev.plex.module.PlexModuleFile;
|
||||||
|
import dev.plex.util.BuildInfo;
|
||||||
|
import dev.plex.util.TimeUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Taah
|
||||||
|
* @since 3:46 PM [07-07-2023]
|
||||||
|
*/
|
||||||
|
@CommandName({"plex", "pplexx"})
|
||||||
|
public class PlexBrigadierCMD extends PlexBrigadierCommand
|
||||||
|
{
|
||||||
|
@SubCommand("reload")
|
||||||
|
@CommandPermission("plex.reload")
|
||||||
|
public void reloadPlex(CommandSender sender)
|
||||||
|
{
|
||||||
|
plugin.config.load();
|
||||||
|
send(sender, "Reloaded config file");
|
||||||
|
plugin.messages.load();
|
||||||
|
send(sender, "Reloaded messages file");
|
||||||
|
plugin.indefBans.load(false);
|
||||||
|
plugin.getPunishmentManager().mergeIndefiniteBans();
|
||||||
|
send(sender, "Reloaded indefinite bans");
|
||||||
|
plugin.commands.load();
|
||||||
|
send(sender, "Reloaded blocked commands file");
|
||||||
|
plugin.getRankManager().importDefaultRanks();
|
||||||
|
send(sender, "Imported ranks");
|
||||||
|
plugin.setSystem(plugin.config.getString("system"));
|
||||||
|
if (plugin.getSystem().equalsIgnoreCase("permissions") && !plugin.getServer().getPluginManager().isPluginEnabled("Vault"))
|
||||||
|
{
|
||||||
|
throw new RuntimeException("Vault is required to run on the server if you use permissions!");
|
||||||
|
}
|
||||||
|
plugin.getServiceManager().endServices();
|
||||||
|
plugin.getServiceManager().startServices();
|
||||||
|
send(sender, "Restarted services.");
|
||||||
|
TimeUtils.TIMEZONE = plugin.config.getString("server.timezone");
|
||||||
|
send(sender, "Set timezone to: " + TimeUtils.TIMEZONE);
|
||||||
|
send(sender, "Plex successfully reloaded.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubCommand("redis")
|
||||||
|
@CommandPermission("plex.redis")
|
||||||
|
public void testRedis(CommandSender sender)
|
||||||
|
{
|
||||||
|
if (!plugin.getRedisConnection().isEnabled())
|
||||||
|
{
|
||||||
|
throw new CommandFailException("&cRedis is not enabled.");
|
||||||
|
}
|
||||||
|
plugin.getRedisConnection().getJedis().set("test", "123");
|
||||||
|
send(sender, "Set test to 123. Now outputting key test...");
|
||||||
|
send(sender, plugin.getRedisConnection().getJedis().get("test"));
|
||||||
|
plugin.getRedisConnection().getJedis().close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubCommand("modules")
|
||||||
|
@CommandPermission("plex.modules")
|
||||||
|
public void viewModules(CommandSender sender)
|
||||||
|
{
|
||||||
|
send(sender, mmString("<gold>Modules (" + plugin.getModuleManager().getModules().size() + "): <yellow>" + StringUtils.join(plugin.getModuleManager().getModules().stream().map(PlexModule::getPlexModuleFile).map(PlexModuleFile::getName).collect(Collectors.toList()), ", ")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@SubCommand("modules reload")
|
||||||
|
@CommandPermission("plex.modules.reload")
|
||||||
|
public void reloadModules(CommandSender sender)
|
||||||
|
{
|
||||||
|
plugin.getModuleManager().reloadModules();
|
||||||
|
send(sender, mmString("<green>All modules reloaded!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Default
|
||||||
|
public void defaultCommand(CommandSender sender)
|
||||||
|
{
|
||||||
|
send(sender, mmString("<light_purple>Plex - A new freedom plugin."));
|
||||||
|
send(sender, mmString("<light_purple>Plugin version: <gold>" + plugin.getPluginMeta().getVersion() + " #" + BuildInfo.getNumber() + " <light_purple>Git: <gold>" + BuildInfo.getHead()));
|
||||||
|
send(sender, mmString("<light_purple>Authors: <gold>Telesphoreo, Taahh"));
|
||||||
|
send(sender, mmString("<light_purple>Built by: <gold>" + BuildInfo.getAuthor() + " <light_purple>on <gold>" + BuildInfo.getDate()));
|
||||||
|
send(sender, mmString("<light_purple>Run <gold>/plex modules <light_purple>to see a list of modules."));
|
||||||
|
plugin.getUpdateChecker().getUpdateStatusMessage(sender, true, 2);
|
||||||
|
}
|
||||||
|
}
|
@ -2,10 +2,11 @@ package dev.plex.config;
|
|||||||
|
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a custom Config object
|
* Creates a custom Config object
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package dev.plex.config;
|
package dev.plex.config;
|
||||||
|
|
||||||
import dev.plex.module.PlexModule;
|
import dev.plex.module.PlexModule;
|
||||||
|
import org.bukkit.configuration.InvalidConfigurationException;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import org.bukkit.configuration.InvalidConfigurationException;
|
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a custom Config object
|
* Creates a custom Config object
|
||||||
|
@ -6,6 +6,7 @@ import dev.plex.command.PlexCommand;
|
|||||||
import dev.plex.command.annotation.System;
|
import dev.plex.command.annotation.System;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import dev.plex.util.ReflectionsUtil;
|
import dev.plex.util.ReflectionsUtil;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -6,6 +6,7 @@ import dev.plex.listener.PlexListener;
|
|||||||
import dev.plex.listener.annotation.Toggleable;
|
import dev.plex.listener.annotation.Toggleable;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import dev.plex.util.ReflectionsUtil;
|
import dev.plex.util.ReflectionsUtil;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
package dev.plex.hook;
|
package dev.plex.hook;
|
||||||
|
|
||||||
|
import dev.plex.Plex;
|
||||||
|
import dev.plex.player.PlexPlayer;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import net.milkbowl.vault.chat.Chat;
|
import net.milkbowl.vault.chat.Chat;
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
|
||||||
public class VaultHook
|
public class VaultHook
|
||||||
@ -46,6 +51,22 @@ public class VaultHook
|
|||||||
return PERMISSIONS;
|
return PERMISSIONS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Component getPrefix(PlexPlayer plexPlayer)
|
||||||
|
{
|
||||||
|
if (VaultHook.getChat() == null || VaultHook.getPermission() == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (Plex.get().getRankManager().getConfigPrefixes(plexPlayer) != null)
|
||||||
|
{
|
||||||
|
return Plex.get().getRankManager().getConfigPrefixes(plexPlayer);
|
||||||
|
}
|
||||||
|
Player bukkitPlayer = Bukkit.getPlayer(plexPlayer.getUuid());
|
||||||
|
String group = VaultHook.getPermission().getPrimaryGroup(bukkitPlayer);
|
||||||
|
String vaultPrefix = VaultHook.getChat().getGroupPrefix(bukkitPlayer.getWorld(), group);
|
||||||
|
return LegacyComponentSerializer.legacyAmpersand().deserialize(vaultPrefix);
|
||||||
|
}
|
||||||
|
|
||||||
public static Permission getPermission()
|
public static Permission getPermission()
|
||||||
{
|
{
|
||||||
return PERMISSIONS;
|
return PERMISSIONS;
|
||||||
|
@ -9,6 +9,7 @@ import dev.plex.player.PlexPlayer;
|
|||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
import static dev.plex.util.PlexUtils.messageComponent;
|
import static dev.plex.util.PlexUtils.messageComponent;
|
||||||
|
|
||||||
public class AdminListener extends PlexListener
|
public class AdminListener extends PlexListener
|
||||||
@ -17,7 +18,7 @@ public class AdminListener extends PlexListener
|
|||||||
public void onAdminAdd(AdminAddEvent event)
|
public void onAdminAdd(AdminAddEvent event)
|
||||||
{
|
{
|
||||||
String userSender = event.getSender().getName();
|
String userSender = event.getSender().getName();
|
||||||
PlexPlayer target = (PlexPlayer)event.getPlexPlayer();
|
PlexPlayer target = event.getPlexPlayer();
|
||||||
if (target.getRankFromString().isAtLeast(Rank.ADMIN))
|
if (target.getRankFromString().isAtLeast(Rank.ADMIN))
|
||||||
{
|
{
|
||||||
PlexUtils.broadcast(messageComponent("adminReadded", userSender, target.getName(), target.getRankFromString().getReadable()));
|
PlexUtils.broadcast(messageComponent("adminReadded", userSender, target.getName(), target.getRankFromString().getReadable()));
|
||||||
@ -35,7 +36,7 @@ public class AdminListener extends PlexListener
|
|||||||
public void onAdminRemove(AdminRemoveEvent event)
|
public void onAdminRemove(AdminRemoveEvent event)
|
||||||
{
|
{
|
||||||
String userSender = event.getSender().getName();
|
String userSender = event.getSender().getName();
|
||||||
PlexPlayer target = (PlexPlayer)event.getPlexPlayer();
|
PlexPlayer target = event.getPlexPlayer();
|
||||||
target.setAdminActive(false);
|
target.setAdminActive(false);
|
||||||
DataUtils.update(target);
|
DataUtils.update(target);
|
||||||
PlexUtils.broadcast(messageComponent("adminRemoved", userSender, target.getName()));
|
PlexUtils.broadcast(messageComponent("adminRemoved", userSender, target.getName()));
|
||||||
@ -45,8 +46,8 @@ public class AdminListener extends PlexListener
|
|||||||
public void onAdminSetRank(AdminSetRankEvent event)
|
public void onAdminSetRank(AdminSetRankEvent event)
|
||||||
{
|
{
|
||||||
String userSender = event.getSender().getName();
|
String userSender = event.getSender().getName();
|
||||||
PlexPlayer target = (PlexPlayer)event.getPlexPlayer();
|
PlexPlayer target = event.getPlexPlayer();
|
||||||
Rank newRank = (Rank)event.getRank();
|
Rank newRank = event.getRank();
|
||||||
target.setRank(newRank.name().toLowerCase());
|
target.setRank(newRank.name().toLowerCase());
|
||||||
DataUtils.update(target);
|
DataUtils.update(target);
|
||||||
PlexUtils.broadcast(messageComponent("adminSetRank", userSender, target.getName(), newRank.getReadable()));
|
PlexUtils.broadcast(messageComponent("adminSetRank", userSender, target.getName(), newRank.getReadable()));
|
||||||
|
@ -2,13 +2,14 @@ package dev.plex.listener.impl;
|
|||||||
|
|
||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.services.impl.TimingService;
|
import dev.plex.services.impl.TimingService;
|
||||||
import java.util.UUID;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class AntiNukerListener extends PlexListener
|
public class AntiNukerListener extends PlexListener
|
||||||
{
|
{
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
@ -3,13 +3,14 @@ package dev.plex.listener.impl;
|
|||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.services.impl.TimingService;
|
import dev.plex.services.impl.TimingService;
|
||||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||||
import java.util.UUID;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class AntiSpamListener extends PlexListener
|
public class AntiSpamListener extends PlexListener
|
||||||
{
|
{
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
@ -2,9 +2,6 @@ package dev.plex.listener.impl;
|
|||||||
|
|
||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -14,6 +11,10 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class BlockListener extends PlexListener
|
public class BlockListener extends PlexListener
|
||||||
{
|
{
|
||||||
private static final List<Material> blockedBlocks = new ArrayList<>();
|
private static final List<Material> blockedBlocks = new ArrayList<>();
|
||||||
@ -57,7 +58,7 @@ public class BlockListener extends PlexListener
|
|||||||
|
|
||||||
if (SIGNS.contains(block.getType()))
|
if (SIGNS.contains(block.getType()))
|
||||||
{
|
{
|
||||||
Sign sign = (Sign)block.getState();
|
Sign sign = (Sign) block.getState();
|
||||||
boolean anythingChanged = false;
|
boolean anythingChanged = false;
|
||||||
for (int i = 0; i < sign.lines().size(); i++)
|
for (int i = 0; i < sign.lines().size(); i++)
|
||||||
{
|
{
|
||||||
@ -86,7 +87,6 @@ public class BlockListener extends PlexListener
|
|||||||
if (blockedPlayers.contains(event.getPlayer().getName()))
|
if (blockedPlayers.contains(event.getPlayer().getName()))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,14 +3,15 @@ package dev.plex.listener.impl;
|
|||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.PlayerEditBookEvent;
|
import org.bukkit.event.player.PlayerEditBookEvent;
|
||||||
import org.bukkit.inventory.meta.BookMeta;
|
import org.bukkit.inventory.meta.BookMeta;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class BookListener extends PlexListener
|
public class BookListener extends PlexListener
|
||||||
{
|
{
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
@ -24,6 +25,6 @@ public class BookListener extends PlexListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
event.setNewBookMeta((BookMeta)event.getNewBookMeta().pages(pages));
|
event.setNewBookMeta((BookMeta) event.getNewBookMeta().pages(pages));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,8 +8,6 @@ import dev.plex.util.minimessage.SafeMiniMessage;
|
|||||||
import dev.plex.util.redis.MessageUtil;
|
import dev.plex.util.redis.MessageUtil;
|
||||||
import io.papermc.paper.chat.ChatRenderer;
|
import io.papermc.paper.chat.ChatRenderer;
|
||||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextReplacementConfig;
|
import net.kyori.adventure.text.TextReplacementConfig;
|
||||||
@ -19,6 +17,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
@Toggleable("chat.enabled")
|
@Toggleable("chat.enabled")
|
||||||
public class ChatListener extends PlexListener
|
public class ChatListener extends PlexListener
|
||||||
{
|
{
|
||||||
@ -37,7 +38,8 @@ public class ChatListener extends PlexListener
|
|||||||
public void onChat(AsyncChatEvent event)
|
public void onChat(AsyncChatEvent event)
|
||||||
{
|
{
|
||||||
PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayerMap().get(event.getPlayer().getUniqueId());
|
PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayerMap().get(event.getPlayer().getUniqueId());
|
||||||
if (plexPlayer.isStaffChat()) {
|
if (plexPlayer.isStaffChat())
|
||||||
|
{
|
||||||
MessageUtil.sendStaffChat(event.getPlayer(), event.message(), PlexUtils.adminChat(event.getPlayer().getName(), SafeMiniMessage.mmSerialize(event.message())).toArray(UUID[]::new));
|
MessageUtil.sendStaffChat(event.getPlayer(), event.message(), PlexUtils.adminChat(event.getPlayer().getName(), SafeMiniMessage.mmSerialize(event.message())).toArray(UUID[]::new));
|
||||||
plugin.getServer().getConsoleSender().sendMessage(PlexUtils.messageComponent("adminChatFormat", event.getPlayer().getName(), SafeMiniMessage.mmSerialize(event.message())).replaceText(URL_REPLACEMENT_CONFIG));
|
plugin.getServer().getConsoleSender().sendMessage(PlexUtils.messageComponent("adminChatFormat", event.getPlayer().getName(), SafeMiniMessage.mmSerialize(event.message())).replaceText(URL_REPLACEMENT_CONFIG));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
@ -7,10 +7,6 @@ import dev.plex.player.PlexPlayer;
|
|||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.services.impl.CommandBlockerService;
|
import dev.plex.services.impl.CommandBlockerService;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -20,12 +16,18 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class CommandListener extends PlexListener
|
public class CommandListener extends PlexListener
|
||||||
{
|
{
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||||
{
|
{
|
||||||
Bukkit.getOnlinePlayers().stream().filter(pl -> {
|
Bukkit.getOnlinePlayers().stream().filter(pl ->
|
||||||
|
{
|
||||||
PlexPlayer player = plugin.getPlayerCache().getPlexPlayer(pl.getUniqueId());
|
PlexPlayer player = plugin.getPlayerCache().getPlexPlayer(pl.getUniqueId());
|
||||||
return player.isCommandSpy() && hasCommandSpy(plugin.getPlayerCache().getPlexPlayer(pl.getUniqueId()));
|
return player.isCommandSpy() && hasCommandSpy(plugin.getPlayerCache().getPlexPlayer(pl.getUniqueId()));
|
||||||
}).forEach(pl ->
|
}).forEach(pl ->
|
||||||
|
@ -3,9 +3,6 @@ package dev.plex.listener.impl;
|
|||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.util.BlockUtils;
|
import dev.plex.util.BlockUtils;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -24,6 +21,10 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
|||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class MobListener extends PlexListener
|
public class MobListener extends PlexListener
|
||||||
{
|
{
|
||||||
private static final List<Material> SPAWN_EGGS = Arrays.stream(Material.values()).filter((mat) -> mat.name().endsWith("_SPAWN_EGG")).toList();
|
private static final List<Material> SPAWN_EGGS = Arrays.stream(Material.values()).filter((mat) -> mat.name().endsWith("_SPAWN_EGG")).toList();
|
||||||
@ -77,7 +78,7 @@ public class MobListener extends PlexListener
|
|||||||
if (SPAWN_EGGS.contains(itemType))
|
if (SPAWN_EGGS.contains(itemType))
|
||||||
{
|
{
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location blockLoc = BlockUtils.relative(block.getLocation(), ((Directional)block.getBlockData()).getFacing()).add(.5, 0, .5);
|
Location blockLoc = BlockUtils.relative(block.getLocation(), ((Directional) block.getBlockData()).getFacing()).add(.5, 0, .5);
|
||||||
EntityType eggType = spawnEggToEntityType(itemType);
|
EntityType eggType = spawnEggToEntityType(itemType);
|
||||||
if (eggType != null)
|
if (eggType != null)
|
||||||
{
|
{
|
||||||
@ -125,7 +126,6 @@ public class MobListener extends PlexListener
|
|||||||
{
|
{
|
||||||
clickedBlock.getWorld().spawnEntity(clickedBlock.getLocation().add(event.getBlockFace().getDirection().multiply(0.8)).add(0.5, 0.5, 0.5), eggType);
|
clickedBlock.getWorld().spawnEntity(clickedBlock.getLocation().add(event.getBlockFace().getDirection().multiply(0.8)).add(0.5, 0.5, 0.5), eggType);
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,14 @@ import dev.plex.listener.PlexListener;
|
|||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||||
import java.util.List;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class MuteListener extends PlexListener
|
public class MuteListener extends PlexListener
|
||||||
{
|
{
|
||||||
List<String> commands = plugin.commands.getStringList("block_on_mute");
|
List<String> commands = plugin.commands.getStringList("block_on_mute");
|
||||||
|
@ -7,8 +7,6 @@ import dev.plex.storage.StorageType;
|
|||||||
import dev.plex.util.PermissionsUtil;
|
import dev.plex.util.PermissionsUtil;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
@ -21,6 +19,8 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class PlayerListener<T> extends PlexListener
|
public class PlayerListener<T> extends PlexListener
|
||||||
{
|
{
|
||||||
// setting up a player's data
|
// setting up a player's data
|
||||||
@ -46,7 +46,7 @@ public class PlayerListener<T> extends PlexListener
|
|||||||
PlexLog.log("A player with this name has not joined the server before, creating new entry.");
|
PlexLog.log("A player with this name has not joined the server before, creating new entry.");
|
||||||
plexPlayer = new PlexPlayer(player.getUniqueId()); // it doesn't! okay so now create the object
|
plexPlayer = new PlexPlayer(player.getUniqueId()); // it doesn't! okay so now create the object
|
||||||
plexPlayer.setName(player.getName()); // set the name of the player
|
plexPlayer.setName(player.getName()); // set the name of the player
|
||||||
plexPlayer.setIps(Arrays.asList(player.getAddress().getAddress().getHostAddress().trim())); // set the arraylist of ips
|
plexPlayer.setIps(List.of(player.getAddress().getAddress().getHostAddress().trim())); // set the arraylist of ips
|
||||||
DataUtils.insert(plexPlayer); // insert data in some wack db
|
DataUtils.insert(plexPlayer); // insert data in some wack db
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -77,7 +77,7 @@ public class PlayerListener<T> extends PlexListener
|
|||||||
String loginMessage = plugin.getRankManager().getLoginMessage(plexPlayer);
|
String loginMessage = plugin.getRankManager().getLoginMessage(plexPlayer);
|
||||||
if (!loginMessage.isEmpty())
|
if (!loginMessage.isEmpty())
|
||||||
{
|
{
|
||||||
PlexUtils.broadcast(PlexUtils.mmDeserialize("<aqua>" + player.getName() + " is " + loginMessage));
|
PlexUtils.broadcast(loginMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
PermissionsUtil.setupPermissions(player);
|
PermissionsUtil.setupPermissions(player);
|
||||||
|
@ -4,13 +4,13 @@ import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
|||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.RandomUtil;
|
import dev.plex.util.RandomUtil;
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
public class ServerListener extends PlexListener
|
public class ServerListener extends PlexListener
|
||||||
{
|
{
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -40,7 +40,7 @@ public class ServerListener extends PlexListener
|
|||||||
if (!samples.isEmpty())
|
if (!samples.isEmpty())
|
||||||
{
|
{
|
||||||
event.getPlayerSample().clear();
|
event.getPlayerSample().clear();
|
||||||
event.getPlayerSample().addAll(samples.stream().map(string -> string.replace("&", "§")).map(Bukkit::createProfile).collect(Collectors.toList()));
|
event.getPlayerSample().addAll(samples.stream().map(string -> string.replace("&", "§")).map(Bukkit::createProfile).toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,7 @@ public class TabListener extends PlexListener
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onAdminAdd(AdminAddEvent event)
|
public void onAdminAdd(AdminAddEvent event)
|
||||||
{
|
{
|
||||||
PlexPlayer plexPlayer = (PlexPlayer)event.getPlexPlayer();
|
PlexPlayer plexPlayer = event.getPlexPlayer();
|
||||||
Player player = event.getPlexPlayer().getPlayer();
|
Player player = event.getPlexPlayer().getPlayer();
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
@ -37,7 +37,7 @@ public class TabListener extends PlexListener
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onAdminRemove(AdminRemoveEvent event)
|
public void onAdminRemove(AdminRemoveEvent event)
|
||||||
{
|
{
|
||||||
PlexPlayer plexPlayer = (PlexPlayer)event.getPlexPlayer();
|
PlexPlayer plexPlayer = event.getPlexPlayer();
|
||||||
Player player = event.getPlexPlayer().getPlayer();
|
Player player = event.getPlexPlayer().getPlayer();
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
@ -49,7 +49,7 @@ public class TabListener extends PlexListener
|
|||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onAdminSetRank(AdminSetRankEvent event)
|
public void onAdminSetRank(AdminSetRankEvent event)
|
||||||
{
|
{
|
||||||
PlexPlayer plexPlayer = (PlexPlayer)event.getPlexPlayer();
|
PlexPlayer plexPlayer = event.getPlexPlayer();
|
||||||
Player player = event.getPlexPlayer().getPlayer();
|
Player player = event.getPlexPlayer().getPlayer();
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
|
@ -7,9 +7,6 @@ import dev.plex.rank.enums.Rank;
|
|||||||
import dev.plex.rank.enums.Title;
|
import dev.plex.rank.enums.Title;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
@ -28,6 +25,10 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
public class WorldListener extends PlexListener
|
public class WorldListener extends PlexListener
|
||||||
{
|
{
|
||||||
private final List<String> EDIT_COMMANDS = Arrays.asList("bigtree", "ebigtree", "largetree", "elargetree", "break", "ebreak", "antioch", "nuke", "editsign", "tree", "etree");
|
private final List<String> EDIT_COMMANDS = Arrays.asList("bigtree", "ebigtree", "largetree", "elargetree", "break", "ebreak", "antioch", "nuke", "editsign", "tree", "etree");
|
||||||
@ -76,8 +77,8 @@ public class WorldListener extends PlexListener
|
|||||||
if (command != null)
|
if (command != null)
|
||||||
{
|
{
|
||||||
// This does check for aliases
|
// This does check for aliases
|
||||||
boolean isWeCommand = command instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand)command).getPlugin().equals(Bukkit.getPluginManager().getPlugin("WorldEdit"));
|
boolean isWeCommand = command instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) command).getPlugin().equals(Bukkit.getPluginManager().getPlugin("WorldEdit"));
|
||||||
boolean isFaweCommand = command instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand)command).getPlugin().equals(Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit"));
|
boolean isFaweCommand = command instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) command).getPlugin().equals(Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit"));
|
||||||
if (isWeCommand || isFaweCommand || EDIT_COMMANDS.contains(message.toLowerCase()))
|
if (isWeCommand || isFaweCommand || EDIT_COMMANDS.contains(message.toLowerCase()))
|
||||||
{
|
{
|
||||||
event.getPlayer().sendMessage(Component.text("You do not have permission to use that command in this world.").color(NamedTextColor.RED));
|
event.getPlayer().sendMessage(Component.text("You do not have permission to use that command in this world.").color(NamedTextColor.RED));
|
||||||
|
@ -7,8 +7,6 @@ import dev.plex.player.PlexPlayer;
|
|||||||
import dev.plex.punishment.Punishment;
|
import dev.plex.punishment.Punishment;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.menu.AbstractMenu;
|
import dev.plex.util.menu.AbstractMenu;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -22,6 +20,9 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.inventory.meta.SkullMeta;
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class PunishedPlayerMenu extends AbstractMenu
|
public class PunishedPlayerMenu extends AbstractMenu
|
||||||
{
|
{
|
||||||
private final PlexPlayer punishedPlayer;
|
private final PlexPlayer punishedPlayer;
|
||||||
@ -133,7 +134,7 @@ public class PunishedPlayerMenu extends AbstractMenu
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
openInv((Player)event.getWhoClicked(), getCurrentInventoryIndex(inv) + 1);
|
openInv((Player) event.getWhoClicked(), getCurrentInventoryIndex(inv) + 1);
|
||||||
}
|
}
|
||||||
else if (item.getItemMeta().displayName().equals(Component.text("Previous Page").color(NamedTextColor.LIGHT_PURPLE)))
|
else if (item.getItemMeta().displayName().equals(Component.text("Previous Page").color(NamedTextColor.LIGHT_PURPLE)))
|
||||||
{
|
{
|
||||||
@ -149,17 +150,17 @@ public class PunishedPlayerMenu extends AbstractMenu
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
openInv((Player)event.getWhoClicked(), getCurrentInventoryIndex(inv) - 1);
|
openInv((Player) event.getWhoClicked(), getCurrentInventoryIndex(inv) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (item.getType() == Material.BARRIER)
|
else if (item.getType() == Material.BARRIER)
|
||||||
{
|
{
|
||||||
new PunishmentMenu().openInv((Player)event.getWhoClicked(), 0);
|
new PunishmentMenu().openInv((Player) event.getWhoClicked(), 0);
|
||||||
}
|
}
|
||||||
else if (item.getType() == Material.PLAYER_HEAD)
|
else if (item.getType() == Material.PLAYER_HEAD)
|
||||||
{
|
{
|
||||||
SkullMeta meta = (SkullMeta)item.getItemMeta();
|
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||||
OfflinePlayer player = meta.getOwningPlayer();
|
OfflinePlayer player = meta.getOwningPlayer();
|
||||||
assert player != null;
|
assert player != null;
|
||||||
PlexPlayer punishedPlayer = DataUtils.getPlayer(player.getUniqueId()) == null ? null : Plex.get().getPlayerCache().getPlexPlayer(player.getUniqueId());
|
PlexPlayer punishedPlayer = DataUtils.getPlayer(player.getUniqueId()) == null ? null : Plex.get().getPlayerCache().getPlexPlayer(player.getUniqueId());
|
||||||
@ -167,9 +168,7 @@ public class PunishedPlayerMenu extends AbstractMenu
|
|||||||
{
|
{
|
||||||
event.getWhoClicked().sendMessage(Component.text("This player does not exist. Try doing /punishments <player> instead.").color(NamedTextColor.RED));
|
event.getWhoClicked().sendMessage(Component.text("This player does not exist. Try doing /punishments <player> instead.").color(NamedTextColor.RED));
|
||||||
event.getWhoClicked().closeInventory();
|
event.getWhoClicked().closeInventory();
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user