mirror of
https://github.com/plexusorg/Plex.git
synced 2025-07-04 16:56:40 +00:00
Compare commits
28 Commits
Author | SHA1 | Date | |
---|---|---|---|
ecbd9c02da | |||
77dc95ae29 | |||
91a1b1cfff | |||
0c6091f06a | |||
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
|
||||
matrix:
|
||||
language: [ 'java' ]
|
||||
java: [17]
|
||||
java: [ 17 ]
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
|
4
.github/workflows/gradle.yml
vendored
4
.github/workflows/gradle.yml
vendored
@ -1,6 +1,6 @@
|
||||
# Adapted from Paper's build script
|
||||
name: Build
|
||||
on: [push, pull_request]
|
||||
on: [ push, pull_request ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@ -9,7 +9,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
java: [17]
|
||||
java: [ 17 ]
|
||||
fail-fast: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
35
.idea/codeStyles/Plexus_Code_Style.xml
generated
35
.idea/codeStyles/Plexus_Code_Style.xml
generated
@ -1,33 +1,8 @@
|
||||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Plexus Code Style" version="1">
|
||||
<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>
|
||||
<code_scheme name="Plexus Code Style" version="173">
|
||||
<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="CLASS_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="CATCH_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="DOWHILE_BRACE_FORCE" value="3" />
|
||||
<option name="WHILE_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>
|
||||
</code_scheme>
|
||||
</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 {
|
||||
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
|
||||
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 {
|
||||
id "java"
|
||||
id "maven-publish"
|
||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
||||
id "com.github.johnrengelman.shadow" version "8.1.1"
|
||||
}
|
||||
|
||||
group = "dev.plex"
|
||||
version = "1.2"
|
||||
version = "1.3"
|
||||
description = "Plex"
|
||||
|
||||
subprojects {
|
||||
|
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
|
||||
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
|
||||
zipStorePath=wrapper/dists
|
||||
|
18
gradlew
vendored
18
gradlew
vendored
@ -55,7 +55,7 @@
|
||||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
@ -80,10 +80,10 @@ do
|
||||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
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.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
@ -143,12 +143,16 @@ fi
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
@ -205,6 +209,12 @@ set -- \
|
||||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
|
15
gradlew.bat
vendored
15
gradlew.bat
vendored
@ -14,7 +14,7 @@
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@ -25,7 +25,8 @@
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
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
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id("net.kyori.blossom") version "1.3.0"
|
||||
id("net.kyori.blossom") version "1.3.1"
|
||||
}
|
||||
|
||||
group = rootProject.group
|
||||
@ -7,7 +7,7 @@ version = rootProject.version
|
||||
description = "Plex-Velocity"
|
||||
|
||||
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") {
|
||||
@ -37,9 +37,9 @@ publishing {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("org.projectlombok:lombok:1.18.24")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.24")
|
||||
compileOnly("org.json:json:20220320")
|
||||
compileOnly("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
|
||||
annotationProcessor("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
|
||||
compileOnly("org.projectlombok:lombok:1.18.28")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.28")
|
||||
compileOnly("org.json:json:20230618")
|
||||
compileOnly("com.velocitypowered:velocity-api:3.2.0-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.settings.ServerSettings;
|
||||
import dev.plex.util.PlexLog;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.logging.Logger;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 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.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import java.util.Arrays;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public abstract class PlexCommand implements SimpleCommand
|
||||
{
|
||||
/**
|
||||
|
@ -1,6 +1,7 @@
|
||||
package dev.plex.command.annotation;
|
||||
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
|
@ -3,12 +3,13 @@ package dev.plex.config;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.toml.Toml;
|
||||
import dev.plex.toml.TomlWriter;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.function.Consumer;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
public class TomlConfig
|
||||
|
@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.ReflectionsUtil;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -7,13 +7,14 @@ import com.velocitypowered.api.proxy.server.ServerPing;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.settings.ServerSettings;
|
||||
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.concurrent.ThreadLocalRandom;
|
||||
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.minimessage.MiniMessage;
|
||||
|
||||
public class ServerListener extends PlexListener
|
||||
{
|
||||
|
@ -2,10 +2,11 @@ package dev.plex.settings;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
public class ServerSettings
|
||||
{
|
||||
|
@ -4,6 +4,7 @@ package dev.plex.toml;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import static dev.plex.toml.ValueWriters.WRITERS;
|
||||
|
||||
public abstract class ArrayValueWriter implements dev.plex.toml.ValueWriter
|
||||
|
@ -1,14 +1,10 @@
|
||||
package dev.plex.toml;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
class ObjectValueWriter implements ValueWriter
|
||||
{
|
||||
|
@ -1,11 +1,6 @@
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.Deque;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
class Results
|
||||
|
@ -1,6 +1,7 @@
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import static dev.plex.toml.ValueWriters.WRITERS;
|
||||
|
||||
class TableArrayValueWriter extends ArrayValueWriter
|
||||
|
@ -2,23 +2,12 @@ package dev.plex.toml;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
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 java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>Provides access to the keys and tables in a TOML data source.</p>
|
||||
*
|
||||
|
@ -1,17 +1,13 @@
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TimeZone;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import static dev.plex.toml.ValueWriters.WRITERS;
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,7 @@
|
||||
package dev.plex.toml;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import static dev.plex.toml.ArrayValueReader.ARRAY_VALUE_READER;
|
||||
import static dev.plex.toml.BooleanValueReaderWriter.BOOLEAN_VALUE_READER_WRITER;
|
||||
import static dev.plex.toml.DateValueReaderWriter.DATE_VALUE_READER_WRITER;
|
||||
|
@ -1,8 +1,9 @@
|
||||
package dev.plex.util;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class RandomUtil
|
||||
{
|
||||
public static NamedTextColor getRandomColor()
|
||||
|
@ -3,6 +3,7 @@ package dev.plex.util;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.reflect.ClassPath;
|
||||
import dev.plex.Plex;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -6,26 +6,26 @@
|
||||
#############################
|
||||
|
||||
[server]
|
||||
name = "Plexus"
|
||||
name = "Plexus"
|
||||
|
||||
# Placeholders
|
||||
# %mcversion% - The Velocity Version (i.e. 3.1.2-SNAPSHOT)
|
||||
# %servername% - The name provided above
|
||||
# %randomgradient% - Creates a random gradient every ping of two random colors for the whole string
|
||||
# Supports MiniMessage strings, no legacy & and §
|
||||
motd = ["%randomgradient%%servername% - %mcversion%", "Another motd"]
|
||||
colorizeMotd = false
|
||||
# Placeholders
|
||||
# %mcversion% - The Velocity Version (i.e. 3.1.2-SNAPSHOT)
|
||||
# %servername% - The name provided above
|
||||
# %randomgradient% - Creates a random gradient every ping of two random colors for the whole string
|
||||
# Supports MiniMessage strings, no legacy & and §
|
||||
motd = ["%randomgradient%%servername% - %mcversion%", "Another motd"]
|
||||
colorizeMotd = false
|
||||
|
||||
# Enables debug messages
|
||||
debug = false
|
||||
# Enables debug messages
|
||||
debug = false
|
||||
|
||||
# Due to game code only supporting legacy color codes for
|
||||
# player samples and not components, you may only use § or & here
|
||||
# for colors.
|
||||
sample = ["example", "example"]
|
||||
# Due to game code only supporting legacy color codes for
|
||||
# player samples and not components, you may only use § or & here
|
||||
# for colors.
|
||||
sample = ["example", "example"]
|
||||
|
||||
# Adds this amount to the current player count
|
||||
add-player-count = 0
|
||||
# Adds this amount to the current player count
|
||||
add-player-count = 0
|
||||
|
||||
# The max player count will always display as +1 more than the player count
|
||||
plus-one-max-count = true
|
||||
# The max player count will always display as +1 more than the player count
|
||||
plus-one-max-count = true
|
@ -1,33 +1,23 @@
|
||||
plugins {
|
||||
id "net.minecrell.plugin-yml.bukkit" version "0.5.2"
|
||||
id "net.minecrell.plugin-yml.paper" version "0.6.0"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
library "org.projectlombok:lombok:1.18.24"
|
||||
annotationProcessor "org.projectlombok:lombok:1.18.24"
|
||||
library "org.json:json:20220320"
|
||||
library "commons-io:commons-io:2.11.0"
|
||||
library "dev.morphia.morphia:morphia-core:2.2.7"
|
||||
library "redis.clients:jedis:4.2.3"
|
||||
library "org.mariadb.jdbc:mariadb-java-client:3.0.6"
|
||||
library "org.projectlombok:lombok:1.18.28"
|
||||
annotationProcessor "org.projectlombok:lombok:1.18.28"
|
||||
library "org.json:json:20230618"
|
||||
library "commons-io:commons-io:2.13.0"
|
||||
library "dev.morphia.morphia:morphia-core:2.3.5"
|
||||
library "redis.clients:jedis:5.0.0-beta2"
|
||||
library "org.mariadb.jdbc:mariadb-java-client:3.1.4"
|
||||
library "com.zaxxer:HikariCP:5.0.1"
|
||||
library "org.apache.httpcomponents.client5:httpclient5:5.2-beta1"
|
||||
library "org.apache.commons:commons-lang3:3.12.0"
|
||||
library "org.apache.maven.resolver:maven-resolver-api:1.8.2"
|
||||
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"
|
||||
library "org.apache.maven.resolver:maven-resolver-transport-http:1.9.13"
|
||||
compileOnly "dev.folia:folia-api:1.20.1-R0.1-SNAPSHOT"
|
||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1") {
|
||||
exclude group: "org.bukkit", module: "bukkit"
|
||||
}
|
||||
implementation "org.bstats:bstats-base:3.0.0"
|
||||
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
|
||||
@ -40,15 +30,32 @@ shadowJar {
|
||||
relocate "org.bstats", "dev.plex"
|
||||
}
|
||||
|
||||
bukkit {
|
||||
paper {
|
||||
name = "Plex"
|
||||
version = project.version
|
||||
description = "Plex provides a new experience for freedom servers."
|
||||
main = "dev.plex.Plex"
|
||||
loader = "dev.plex.PlexLibraryManager"
|
||||
website = "https://plex.us.org"
|
||||
authors = ["Telesphoreo", "taahanis", "supernt"]
|
||||
softDepend = ["Vault"]
|
||||
apiVersion = "1.18"
|
||||
apiVersion = "1.19"
|
||||
foliaSupported = true
|
||||
generateLibrariesJson = true
|
||||
// Load BukkitTelnet and LibsDisguises before Plex so the modules register properly
|
||||
serverDependencies {
|
||||
'BukkitTelnet' {
|
||||
required = false
|
||||
load = 'BEFORE'
|
||||
}
|
||||
'LibsDisguises' {
|
||||
required = false
|
||||
load = 'BEFORE'
|
||||
}
|
||||
'Vault' {
|
||||
required = false
|
||||
load = 'BEFORE'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String getGitHash() {
|
||||
|
@ -76,7 +76,6 @@ public class Plex extends JavaPlugin
|
||||
private Permission permissions;
|
||||
private Chat chat;
|
||||
|
||||
|
||||
public static Plex get()
|
||||
{
|
||||
return plugin;
|
||||
@ -193,7 +192,11 @@ public class Plex extends JavaPlugin
|
||||
punishmentManager.mergeIndefiniteBans();
|
||||
PlexLog.log("Punishment System initialized");
|
||||
|
||||
if (!PlexUtils.isFolia())
|
||||
{
|
||||
// World generation is not supported on Folia yet
|
||||
generateWorlds();
|
||||
}
|
||||
|
||||
serviceManager = new ServiceManager();
|
||||
PlexLog.log("Service Manager initialized");
|
||||
|
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;
|
||||
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import java.util.UUID;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Admin object to handle cached admins
|
||||
*/
|
||||
|
@ -10,6 +10,7 @@ import dev.plex.PlexBase;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.storage.StorageType;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
@ -3,6 +3,7 @@ package dev.plex.cache;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.storage.StorageType;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -2,6 +2,7 @@ package dev.plex.cache;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -4,18 +4,12 @@ import dev.plex.Plex;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.exception.CommandFailException;
|
||||
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.exception.*;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
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.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandMap;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.command.PluginIdentifiableCommand;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Superclass for all commands
|
||||
*/
|
||||
@ -206,7 +199,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
}
|
||||
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)
|
||||
{
|
||||
send(sender, component);
|
||||
@ -292,7 +285,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
{
|
||||
if (!isConsole(sender))
|
||||
{
|
||||
return checkRank((Player)sender, rank, permission);
|
||||
return checkRank((Player) sender, rank, permission);
|
||||
}
|
||||
if (!sender.getName().equalsIgnoreCase("console"))
|
||||
{
|
||||
@ -387,7 +380,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
{
|
||||
if (!isConsole(sender))
|
||||
{
|
||||
return checkTab((Player)sender, rank, permission);
|
||||
return checkTab((Player) sender, rank, permission);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package dev.plex.command.annotation;
|
||||
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
package dev.plex.command.blocking;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import net.kyori.adventure.text.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class BlockedCommand
|
||||
{
|
||||
|
@ -15,8 +15,6 @@ import dev.plex.event.AdminSetRankEvent;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -25,6 +23,9 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@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")
|
||||
@System(value = "ranks")
|
||||
|
@ -10,7 +10,6 @@ import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
import dev.plex.util.redis.MessageUtil;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -19,6 +18,8 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@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")
|
||||
public class AdminChatCMD extends PlexCommand
|
||||
@ -28,7 +29,8 @@ public class AdminChatCMD extends PlexCommand
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
if (playerSender != null) {
|
||||
if (playerSender != null)
|
||||
{
|
||||
PlexPlayer player = DataUtils.getPlayer(playerSender.getUniqueId());
|
||||
player.setStaffChat(!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.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@ -18,6 +17,8 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@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")
|
||||
public class AdventureCMD extends PlexCommand
|
||||
@ -29,7 +30,7 @@ public class AdventureCMD extends PlexCommand
|
||||
{
|
||||
if (isConsole(sender))
|
||||
{
|
||||
throw new CommandFailException(PlexUtils.messageString("consoleMustDefinePlayer"));
|
||||
throw new CommandFailException(messageString("consoleMustDefinePlayer"));
|
||||
}
|
||||
Bukkit.getServer().getPluginManager().callEvent(new GameModeUpdateEvent(sender, playerSender, GameMode.ADVENTURE));
|
||||
return null;
|
||||
|
@ -12,15 +12,7 @@ import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.BungeeUtil;
|
||||
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 dev.plex.util.*;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -29,6 +21,11 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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")
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.ban", source = RequiredCommandSource.ANY)
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class CommandSpyCMD extends PlexCommand
|
||||
{
|
||||
if (playerSender != null)
|
||||
{
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(playerSender.getUniqueId());
|
||||
PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayer(playerSender.getUniqueId());
|
||||
plexPlayer.setCommandSpy(!plexPlayer.isCommandSpy());
|
||||
DataUtils.update(plexPlayer);
|
||||
send(sender, messageComponent("toggleCommandSpy")
|
||||
|
@ -9,7 +9,6 @@ import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.event.GameModeUpdateEvent;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@ -18,6 +17,8 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@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")
|
||||
public class CreativeCMD extends PlexCommand
|
||||
@ -29,7 +30,7 @@ public class CreativeCMD extends PlexCommand
|
||||
{
|
||||
if (isConsole(sender))
|
||||
{
|
||||
throw new CommandFailException(PlexUtils.messageString("consoleMustDefinePlayer"));
|
||||
throw new CommandFailException(messageString("consoleMustDefinePlayer"));
|
||||
}
|
||||
if (!(playerSender == null))
|
||||
{
|
||||
|
@ -9,9 +9,6 @@ import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.GameRuleUtil;
|
||||
import dev.plex.util.PlexLog;
|
||||
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.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -22,6 +19,10 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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>")
|
||||
@CommandPermissions(level = Rank.EXECUTIVE, permission = "plex.debug")
|
||||
@System(debug = true)
|
||||
@ -35,6 +36,8 @@ public class DebugCMD extends PlexCommand
|
||||
return usage();
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("redis-reset"))
|
||||
{
|
||||
if (args.length == 2)
|
||||
{
|
||||
Player player = getNonNullPlayer(args[1]);
|
||||
if (plugin.getRedisConnection().getJedis().exists(player.getUniqueId().toString()))
|
||||
@ -44,6 +47,7 @@ public class DebugCMD extends PlexCommand
|
||||
}
|
||||
return componentFromString("Couldn't find player in Redis punishments.");
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("gamerules"))
|
||||
{
|
||||
for (World world : Bukkit.getWorlds())
|
||||
@ -63,6 +67,8 @@ public class DebugCMD extends PlexCommand
|
||||
return mmString("<aqua>Re-applied game all the game rules!");
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("aliases"))
|
||||
{
|
||||
if (args.length == 2)
|
||||
{
|
||||
String commandName = args[1];
|
||||
Command command = plugin.getServer().getCommandMap().getCommand(commandName);
|
||||
@ -72,7 +78,8 @@ public class DebugCMD extends PlexCommand
|
||||
}
|
||||
return mmString("<aqua>Aliases for " + commandName + " are: " + Arrays.toString(command.getAliases().toArray(new String[0])));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
return usage();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,13 +7,14 @@ import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.annotation.System;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandParameters(name = "deop", description = "Deop a player on the server", usage = "/<command> <player>")
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.deop")
|
||||
@System(value = "ranks")
|
||||
|
@ -6,11 +6,6 @@ import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
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 org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
@ -21,6 +16,8 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@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")
|
||||
public class EntityWipeCMD extends PlexCommand
|
||||
|
@ -10,15 +10,16 @@ import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
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;
|
||||
|
||||
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")
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.freeze")
|
||||
public class FreezeCMD extends PlexCommand
|
||||
|
@ -8,9 +8,6 @@ import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.event.GameModeUpdateEvent;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@ -19,6 +16,10 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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")
|
||||
@CommandPermissions(level = Rank.OP, permission = "plex.gamemode", source = RequiredCommandSource.ANY)
|
||||
public class GamemodeCMD extends PlexCommand
|
||||
|
@ -14,9 +14,6 @@ import dev.plex.util.BungeeUtil;
|
||||
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.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -25,6 +22,10 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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>")
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.kick", source = RequiredCommandSource.ANY)
|
||||
public class KickCMD extends PlexCommand
|
||||
@ -56,9 +57,9 @@ public class KickCMD extends PlexCommand
|
||||
if (args.length > 1)
|
||||
{
|
||||
reason = StringUtils.join(args, " ", 1, args.length);
|
||||
punishment.setReason(reason);
|
||||
}
|
||||
|
||||
punishment.setReason(reason);
|
||||
punishment.setPunishedUsername(plexPlayer.getName());
|
||||
punishment.setEndDate(ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE)));
|
||||
punishment.setCustomTime(false);
|
||||
|
@ -4,9 +4,8 @@ import com.google.common.collect.Lists;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.annotation.System;
|
||||
import dev.plex.hook.VaultHook;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -15,9 +14,10 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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")
|
||||
@System(value = "ranks")
|
||||
public class ListCMD extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
@ -44,7 +44,14 @@ public class ListCMD extends PlexCommand
|
||||
for (int i = 0; i < players.size(); i++)
|
||||
{
|
||||
Player player = players.get(i);
|
||||
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)
|
||||
{
|
||||
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.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandParameters(name = "lockup", description = "Lockup a player on the server", usage = "/<command> <player>")
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.lockup")
|
||||
public class LockupCMD extends PlexCommand
|
||||
|
@ -6,7 +6,6 @@ import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.HashMap;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
@ -17,6 +16,8 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.mobpurge", source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(name = "mobpurge", description = "Purge all mobs.", usage = "/<command>", aliases = "mp")
|
||||
public class MobPurgeCMD extends PlexCommand
|
||||
|
@ -10,15 +10,16 @@ import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
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;
|
||||
|
||||
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")
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.mute")
|
||||
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.CommandPermissions;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.AshconInfo;
|
||||
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 dev.plex.util.*;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -20,6 +14,9 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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")
|
||||
@CommandPermissions(level = Rank.OP, permission = "plex.namehistory")
|
||||
public class NameHistoryCMD extends PlexCommand
|
||||
|
@ -10,12 +10,6 @@ import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.storage.StorageType;
|
||||
import dev.plex.util.PlexUtils;
|
||||
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.format.NamedTextColor;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
@ -25,6 +19,13 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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>")
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.notes")
|
||||
public class NotesCMD extends PlexCommand
|
||||
|
@ -7,13 +7,14 @@ import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.annotation.System;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandParameters(name = "op", description = "Op a player on the server", usage = "/<command> <player>")
|
||||
@CommandPermissions(level = Rank.OP)
|
||||
@System(value = "ranks")
|
||||
|
@ -11,10 +11,6 @@ import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.BuildInfo;
|
||||
import dev.plex.util.PlexUtils;
|
||||
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 org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -24,6 +20,11 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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)
|
||||
@CommandParameters(name = "plex", usage = "/<command> [reload | redis | modules [reload]]", description = "Show information about Plex or reload it")
|
||||
public class PlexCMD extends PlexCommand
|
||||
|
@ -8,13 +8,14 @@ import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.menu.PunishmentMenu;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@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)
|
||||
public class PunishmentsCMD extends PlexCommand
|
||||
|
@ -8,14 +8,15 @@ import dev.plex.command.exception.CommandFailException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
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;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(level = Rank.OP, permission = "plex.rank", source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(name = "rank", description = "Displays your rank")
|
||||
@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.util.PlexUtils;
|
||||
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.format.NamedTextColor;
|
||||
import net.kyori.adventure.title.Title;
|
||||
@ -27,6 +23,11 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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)
|
||||
@CommandParameters(name = "smite", usage = "/<command> <player> [reason] [-ci | -q]", description = "Someone being a little bitch? Smite them down...")
|
||||
public class SmiteCMD extends PlexCommand
|
||||
|
@ -9,7 +9,6 @@ import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.event.GameModeUpdateEvent;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@ -18,6 +17,8 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@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")
|
||||
public class SpectatorCMD extends PlexCommand
|
||||
@ -29,7 +30,7 @@ public class SpectatorCMD extends PlexCommand
|
||||
{
|
||||
if (isConsole(sender))
|
||||
{
|
||||
throw new CommandFailException(PlexUtils.messageString("consoleMustDefinePlayer"));
|
||||
throw new CommandFailException(messageString("consoleMustDefinePlayer"));
|
||||
}
|
||||
Bukkit.getServer().getPluginManager().callEvent(new GameModeUpdateEvent(sender, playerSender, GameMode.SPECTATOR));
|
||||
return null;
|
||||
|
@ -9,7 +9,6 @@ import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.event.GameModeUpdateEvent;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
@ -18,6 +17,8 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@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")
|
||||
public class SurvivalCMD extends PlexCommand
|
||||
@ -29,7 +30,7 @@ public class SurvivalCMD extends PlexCommand
|
||||
{
|
||||
if (isConsole(sender))
|
||||
{
|
||||
throw new CommandFailException(PlexUtils.messageString("consoleMustDefinePlayer"));
|
||||
throw new CommandFailException(messageString("consoleMustDefinePlayer"));
|
||||
}
|
||||
Bukkit.getServer().getPluginManager().callEvent(new GameModeUpdateEvent(sender, playerSender, GameMode.SURVIVAL));
|
||||
return null;
|
||||
|
@ -7,8 +7,6 @@ import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.inventory.Book;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -16,6 +14,9 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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")
|
||||
@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.TimeUtils;
|
||||
import dev.plex.util.WebUtils;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -25,6 +23,9 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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")
|
||||
@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.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -16,6 +15,8 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandParameters(name = "toggle", description = "Allows toggling various server aspects through a GUI", aliases = "toggles")
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.toggle", source = RequiredCommandSource.ANY)
|
||||
public class ToggleCMD extends PlexCommand
|
||||
|
@ -12,14 +12,15 @@ import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.WebUtils;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandParameters(name = "unban", usage = "/<command> <player>", description = "Unbans a player, offline or online")
|
||||
@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.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.unfreeze")
|
||||
@CommandParameters(name = "unfreeze", description = "Unfreeze a player", usage = "/<command> <player>")
|
||||
public class UnfreezeCMD extends PlexCommand
|
||||
|
@ -8,13 +8,14 @@ import dev.plex.command.exception.CommandFailException;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.unmute")
|
||||
@CommandParameters(name = "unmute", description = "Unmute a player", usage = "/<command> <player>")
|
||||
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.source.RequiredCommandSource;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -17,6 +15,9 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
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)
|
||||
@CommandParameters(name = "world", description = "Teleport to a world.", usage = "/<command> <world>")
|
||||
public class WorldCMD extends PlexCommand
|
||||
|
@ -2,10 +2,11 @@ package dev.plex.config;
|
||||
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.util.PlexLog;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
/**
|
||||
* Creates a custom Config object
|
||||
|
@ -1,11 +1,12 @@
|
||||
package dev.plex.config;
|
||||
|
||||
import dev.plex.module.PlexModule;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
/**
|
||||
* Creates a custom Config object
|
||||
|
@ -6,6 +6,7 @@ import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.System;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.ReflectionsUtil;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -6,6 +6,7 @@ import dev.plex.listener.PlexListener;
|
||||
import dev.plex.listener.annotation.Toggleable;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.ReflectionsUtil;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
@ -1,8 +1,13 @@
|
||||
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.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
public class VaultHook
|
||||
@ -46,6 +51,22 @@ public class VaultHook
|
||||
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()
|
||||
{
|
||||
return PERMISSIONS;
|
||||
|
@ -9,6 +9,7 @@ import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import static dev.plex.util.PlexUtils.messageComponent;
|
||||
|
||||
public class AdminListener extends PlexListener
|
||||
@ -17,7 +18,7 @@ public class AdminListener extends PlexListener
|
||||
public void onAdminAdd(AdminAddEvent event)
|
||||
{
|
||||
String userSender = event.getSender().getName();
|
||||
PlexPlayer target = (PlexPlayer)event.getPlexPlayer();
|
||||
PlexPlayer target = event.getPlexPlayer();
|
||||
if (target.getRankFromString().isAtLeast(Rank.ADMIN))
|
||||
{
|
||||
PlexUtils.broadcast(messageComponent("adminReadded", userSender, target.getName(), target.getRankFromString().getReadable()));
|
||||
@ -35,7 +36,7 @@ public class AdminListener extends PlexListener
|
||||
public void onAdminRemove(AdminRemoveEvent event)
|
||||
{
|
||||
String userSender = event.getSender().getName();
|
||||
PlexPlayer target = (PlexPlayer)event.getPlexPlayer();
|
||||
PlexPlayer target = event.getPlexPlayer();
|
||||
target.setAdminActive(false);
|
||||
DataUtils.update(target);
|
||||
PlexUtils.broadcast(messageComponent("adminRemoved", userSender, target.getName()));
|
||||
@ -45,8 +46,8 @@ public class AdminListener extends PlexListener
|
||||
public void onAdminSetRank(AdminSetRankEvent event)
|
||||
{
|
||||
String userSender = event.getSender().getName();
|
||||
PlexPlayer target = (PlexPlayer)event.getPlexPlayer();
|
||||
Rank newRank = (Rank)event.getRank();
|
||||
PlexPlayer target = event.getPlexPlayer();
|
||||
Rank newRank = event.getRank();
|
||||
target.setRank(newRank.name().toLowerCase());
|
||||
DataUtils.update(target);
|
||||
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.services.impl.TimingService;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class AntiNukerListener extends PlexListener
|
||||
{
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
|
@ -3,13 +3,14 @@ package dev.plex.listener.impl;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.services.impl.TimingService;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class AntiSpamListener extends PlexListener
|
||||
{
|
||||
@EventHandler
|
||||
|
@ -2,9 +2,6 @@ package dev.plex.listener.impl;
|
||||
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Material;
|
||||
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.BlockPlaceEvent;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class BlockListener extends PlexListener
|
||||
{
|
||||
private static final List<Material> blockedBlocks = new ArrayList<>();
|
||||
@ -57,7 +58,7 @@ public class BlockListener extends PlexListener
|
||||
|
||||
if (SIGNS.contains(block.getType()))
|
||||
{
|
||||
Sign sign = (Sign)block.getState();
|
||||
Sign sign = (Sign) block.getState();
|
||||
boolean anythingChanged = false;
|
||||
for (int i = 0; i < sign.lines().size(); i++)
|
||||
{
|
||||
@ -86,7 +87,6 @@ public class BlockListener extends PlexListener
|
||||
if (blockedPlayers.contains(event.getPlayer().getName()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,14 +3,15 @@ package dev.plex.listener.impl;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerEditBookEvent;
|
||||
import org.bukkit.inventory.meta.BookMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BookListener extends PlexListener
|
||||
{
|
||||
@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 io.papermc.paper.chat.ChatRenderer;
|
||||
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.text.Component;
|
||||
import net.kyori.adventure.text.TextReplacementConfig;
|
||||
@ -19,6 +17,9 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@Toggleable("chat.enabled")
|
||||
public class ChatListener extends PlexListener
|
||||
{
|
||||
@ -37,7 +38,8 @@ public class ChatListener extends PlexListener
|
||||
public void onChat(AsyncChatEvent event)
|
||||
{
|
||||
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));
|
||||
plugin.getServer().getConsoleSender().sendMessage(PlexUtils.messageComponent("adminChatFormat", event.getPlayer().getName(), SafeMiniMessage.mmSerialize(event.message())).replaceText(URL_REPLACEMENT_CONFIG));
|
||||
event.setCancelled(true);
|
||||
|
@ -7,10 +7,6 @@ import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.services.impl.CommandBlockerService;
|
||||
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.format.NamedTextColor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -20,12 +16,18 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
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
|
||||
{
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
Bukkit.getOnlinePlayers().stream().filter(pl -> {
|
||||
Bukkit.getOnlinePlayers().stream().filter(pl ->
|
||||
{
|
||||
PlexPlayer player = plugin.getPlayerCache().getPlexPlayer(pl.getUniqueId());
|
||||
return player.isCommandSpy() && hasCommandSpy(plugin.getPlayerCache().getPlexPlayer(pl.getUniqueId()));
|
||||
}).forEach(pl ->
|
||||
|
@ -3,9 +3,6 @@ package dev.plex.listener.impl;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.BlockUtils;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -24,6 +21,10 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public class MobListener extends PlexListener
|
||||
{
|
||||
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))
|
||||
{
|
||||
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);
|
||||
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);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,14 @@ import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MuteListener extends PlexListener
|
||||
{
|
||||
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.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
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.PlayerQuitEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerListener<T> extends PlexListener
|
||||
{
|
||||
// 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.");
|
||||
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.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
|
||||
}
|
||||
else
|
||||
@ -77,7 +77,7 @@ public class PlayerListener<T> extends PlexListener
|
||||
String loginMessage = plugin.getRankManager().getLoginMessage(plexPlayer);
|
||||
if (!loginMessage.isEmpty())
|
||||
{
|
||||
PlexUtils.broadcast(PlexUtils.mmDeserialize("<aqua>" + player.getName() + " is " + loginMessage));
|
||||
PlexUtils.broadcast(loginMessage);
|
||||
}
|
||||
|
||||
PermissionsUtil.setupPermissions(player);
|
||||
|
@ -4,13 +4,13 @@ import com.destroystokyo.paper.event.server.PaperServerListPingEvent;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.PlexUtils;
|
||||
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 org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
public class ServerListener extends PlexListener
|
||||
{
|
||||
@EventHandler
|
||||
@ -40,7 +40,7 @@ public class ServerListener extends PlexListener
|
||||
if (!samples.isEmpty())
|
||||
{
|
||||
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)
|
||||
public void onAdminAdd(AdminAddEvent event)
|
||||
{
|
||||
PlexPlayer plexPlayer = (PlexPlayer)event.getPlexPlayer();
|
||||
PlexPlayer plexPlayer = event.getPlexPlayer();
|
||||
Player player = event.getPlexPlayer().getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
@ -37,7 +37,7 @@ public class TabListener extends PlexListener
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onAdminRemove(AdminRemoveEvent event)
|
||||
{
|
||||
PlexPlayer plexPlayer = (PlexPlayer)event.getPlexPlayer();
|
||||
PlexPlayer plexPlayer = event.getPlexPlayer();
|
||||
Player player = event.getPlexPlayer().getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
@ -49,7 +49,7 @@ public class TabListener extends PlexListener
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onAdminSetRank(AdminSetRankEvent event)
|
||||
{
|
||||
PlexPlayer plexPlayer = (PlexPlayer)event.getPlexPlayer();
|
||||
PlexPlayer plexPlayer = event.getPlexPlayer();
|
||||
Player player = event.getPlexPlayer().getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
|
@ -7,9 +7,6 @@ import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.rank.enums.Title;
|
||||
import dev.plex.util.PlexLog;
|
||||
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.format.NamedTextColor;
|
||||
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.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
public class WorldListener extends PlexListener
|
||||
{
|
||||
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)
|
||||
{
|
||||
// This does check for aliases
|
||||
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 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"));
|
||||
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));
|
||||
|
@ -7,8 +7,6 @@ import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.util.PlexUtils;
|
||||
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.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -22,6 +20,9 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class PunishedPlayerMenu extends AbstractMenu
|
||||
{
|
||||
private final PlexPlayer punishedPlayer;
|
||||
@ -133,7 +134,7 @@ public class PunishedPlayerMenu extends AbstractMenu
|
||||
{
|
||||
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)))
|
||||
{
|
||||
@ -149,17 +150,17 @@ public class PunishedPlayerMenu extends AbstractMenu
|
||||
{
|
||||
return;
|
||||
}
|
||||
openInv((Player)event.getWhoClicked(), getCurrentInventoryIndex(inv) - 1);
|
||||
openInv((Player) event.getWhoClicked(), getCurrentInventoryIndex(inv) - 1);
|
||||
}
|
||||
|
||||
}
|
||||
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)
|
||||
{
|
||||
SkullMeta meta = (SkullMeta)item.getItemMeta();
|
||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||
OfflinePlayer player = meta.getOwningPlayer();
|
||||
assert player != null;
|
||||
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().closeInventory();
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import dev.plex.cache.DataUtils;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.menu.AbstractMenu;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -19,6 +18,8 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PunishmentMenu extends AbstractMenu
|
||||
{
|
||||
|
||||
@ -72,7 +73,7 @@ public class PunishmentMenu extends AbstractMenu
|
||||
|
||||
|
||||
ItemStack item = new ItemStack(Material.PLAYER_HEAD);
|
||||
SkullMeta meta = (SkullMeta)item.getItemMeta();
|
||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||
meta.setOwningPlayer(players);
|
||||
meta.displayName(PlexUtils.mmDeserialize("<!italic><yellow>" + players.getName()));
|
||||
item.setItemMeta(meta);
|
||||
@ -122,7 +123,7 @@ public class PunishmentMenu extends AbstractMenu
|
||||
{
|
||||
return;
|
||||
}
|
||||
openInv((Player)event.getWhoClicked(), getCurrentInventoryIndex(inv) + 1);
|
||||
openInv((Player) event.getWhoClicked(), getCurrentInventoryIndex(inv) + 1);
|
||||
}
|
||||
else if (item.getItemMeta().displayName().equals(PlexUtils.mmDeserialize("<light_purple>Previous Page")))
|
||||
{
|
||||
@ -138,13 +139,13 @@ public class PunishmentMenu extends AbstractMenu
|
||||
{
|
||||
return;
|
||||
}
|
||||
openInv((Player)event.getWhoClicked(), getCurrentInventoryIndex(inv) - 1);
|
||||
openInv((Player) event.getWhoClicked(), getCurrentInventoryIndex(inv) - 1);
|
||||
}
|
||||
|
||||
}
|
||||
else if (item.getType() == Material.PLAYER_HEAD)
|
||||
{
|
||||
SkullMeta meta = (SkullMeta)item.getItemMeta();
|
||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||
OfflinePlayer player = meta.getOwningPlayer();
|
||||
assert player != null;
|
||||
PlexPlayer punishedPlayer = DataUtils.getPlayer(player.getUniqueId());
|
||||
@ -154,7 +155,7 @@ public class PunishmentMenu extends AbstractMenu
|
||||
event.getWhoClicked().closeInventory();
|
||||
return;
|
||||
}
|
||||
new PunishedPlayerMenu(punishedPlayer).openInv((Player)event.getWhoClicked(), 0);
|
||||
new PunishedPlayerMenu(punishedPlayer).openInv((Player) event.getWhoClicked(), 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import com.google.common.collect.Lists;
|
||||
import dev.plex.PlexBase;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.menu.AbstractMenu;
|
||||
import java.util.List;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -14,6 +13,8 @@ import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ToggleMenu extends AbstractMenu implements PlexBase
|
||||
{
|
||||
private final List<Inventory> inventories = Lists.newArrayList();
|
||||
|
@ -3,8 +3,11 @@ package dev.plex.module;
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.module.exception.ModuleLoadException;
|
||||
import dev.plex.module.loader.LibraryLoader;
|
||||
import dev.plex.util.PlexLog;
|
||||
import lombok.Getter;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
@ -15,19 +18,14 @@ import java.net.URLClassLoader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
@Getter
|
||||
public class ModuleManager
|
||||
{
|
||||
private final List<PlexModule> modules = Lists.newArrayList();
|
||||
private final LibraryLoader libraryLoader;
|
||||
|
||||
public ModuleManager()
|
||||
{
|
||||
this.libraryLoader = new LibraryLoader(Plex.get().getLogger());
|
||||
}
|
||||
|
||||
public void loadAllModules()
|
||||
@ -66,7 +64,7 @@ public class ModuleManager
|
||||
|
||||
PlexModuleFile plexModuleFile = new PlexModuleFile(name, main, description, version);
|
||||
plexModuleFile.setLibraries(libraries);
|
||||
Class<? extends PlexModule> module = (Class<? extends PlexModule>)Class.forName(main, true, loader);
|
||||
Class<? extends PlexModule> module = (Class<? extends PlexModule>) Class.forName(main, true, loader);
|
||||
|
||||
PlexModule plexModule = module.getConstructor().newInstance();
|
||||
plexModule.setPlex(Plex.get());
|
||||
@ -141,7 +139,7 @@ public class ModuleManager
|
||||
{
|
||||
try
|
||||
{
|
||||
((URLClassLoader)module.getClass().getClassLoader()).close();
|
||||
((URLClassLoader) module.getClass().getClassLoader()).close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
|
@ -5,6 +5,14 @@ import dev.plex.Plex;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.PlexLog;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -13,13 +21,6 @@ import java.net.URLConnection;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Getter
|
||||
@Setter(AccessLevel.MODULE)
|
||||
|
@ -1,9 +1,10 @@
|
||||
package dev.plex.module;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class PlexModuleFile
|
||||
{
|
||||
|
@ -6,5 +6,4 @@ public class ModuleLoadException extends RuntimeException
|
||||
{
|
||||
super(s);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,70 +0,0 @@
|
||||
package dev.plex.module.loader;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
public class CustomClassLoader extends URLClassLoader
|
||||
{
|
||||
/*public CustomClassLoader(URL[] urls, ClassLoader parent) {
|
||||
super(urls, parent);
|
||||
for (URL url : urls) {
|
||||
super.addURL(url);
|
||||
}
|
||||
}*/
|
||||
|
||||
public CustomClassLoader(URL jarInJar, ClassLoader parent)
|
||||
{
|
||||
super(new URL[]{extractJar(jarInJar)}, parent);
|
||||
addURL(jarInJar);
|
||||
}
|
||||
|
||||
|
||||
static URL extractJar(URL jarInJar) throws RuntimeException
|
||||
{
|
||||
// get the jar-in-jar resource
|
||||
if (jarInJar == null)
|
||||
{
|
||||
throw new RuntimeException("Could not locate jar-in-jar");
|
||||
}
|
||||
|
||||
// create a temporary file
|
||||
// on posix systems by default this is only read/writable by the process owner
|
||||
Path path;
|
||||
try
|
||||
{
|
||||
path = Files.createTempFile("plex-jarinjar", ".jar.tmp");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException("Unable to create a temporary file", e);
|
||||
}
|
||||
|
||||
// mark that the file should be deleted on exit
|
||||
path.toFile().deleteOnExit();
|
||||
|
||||
// copy the jar-in-jar to the temporary file path
|
||||
try (InputStream in = jarInJar.openStream())
|
||||
{
|
||||
Files.copy(in, path, StandardCopyOption.REPLACE_EXISTING);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new RuntimeException("Unable to copy jar-in-jar to temporary path", e);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return path.toUri().toURL();
|
||||
}
|
||||
catch (MalformedURLException e)
|
||||
{
|
||||
throw new RuntimeException("Unable to get URL from path", e);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,265 +0,0 @@
|
||||
package dev.plex.module.loader;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.module.PlexModule;
|
||||
import dev.plex.module.PlexModuleFile;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.JarURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.jar.JarEntry;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
|
||||
import org.eclipse.aether.DefaultRepositorySystemSession;
|
||||
import org.eclipse.aether.RepositorySystem;
|
||||
import org.eclipse.aether.artifact.Artifact;
|
||||
import org.eclipse.aether.artifact.DefaultArtifact;
|
||||
import org.eclipse.aether.collection.CollectRequest;
|
||||
import org.eclipse.aether.connector.basic.BasicRepositoryConnectorFactory;
|
||||
import org.eclipse.aether.graph.Dependency;
|
||||
import org.eclipse.aether.impl.DefaultServiceLocator;
|
||||
import org.eclipse.aether.repository.LocalRepository;
|
||||
import org.eclipse.aether.repository.RemoteRepository;
|
||||
import org.eclipse.aether.repository.RepositoryPolicy;
|
||||
import org.eclipse.aether.resolution.ArtifactResult;
|
||||
import org.eclipse.aether.resolution.DependencyRequest;
|
||||
import org.eclipse.aether.resolution.DependencyResolutionException;
|
||||
import org.eclipse.aether.resolution.DependencyResult;
|
||||
import org.eclipse.aether.spi.connector.RepositoryConnectorFactory;
|
||||
import org.eclipse.aether.spi.connector.transport.TransporterFactory;
|
||||
import org.eclipse.aether.transfer.AbstractTransferListener;
|
||||
import org.eclipse.aether.transfer.TransferCancelledException;
|
||||
import org.eclipse.aether.transfer.TransferEvent;
|
||||
import org.eclipse.aether.transport.http.HttpTransporterFactory;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
//TODO: doesn't work
|
||||
|
||||
public class LibraryLoader
|
||||
{
|
||||
private final Logger logger;
|
||||
private final RepositorySystem repository;
|
||||
private final DefaultRepositorySystemSession session;
|
||||
private final List<RemoteRepository> repositories;
|
||||
|
||||
public LibraryLoader(@NotNull Logger logger)
|
||||
{
|
||||
this.logger = logger;
|
||||
|
||||
DefaultServiceLocator locator = MavenRepositorySystemUtils.newServiceLocator();
|
||||
locator.addService(RepositoryConnectorFactory.class, BasicRepositoryConnectorFactory.class);
|
||||
locator.addService(TransporterFactory.class, HttpTransporterFactory.class);
|
||||
|
||||
this.repository = locator.getService(RepositorySystem.class);
|
||||
this.session = MavenRepositorySystemUtils.newSession();
|
||||
|
||||
session.setChecksumPolicy(RepositoryPolicy.CHECKSUM_POLICY_FAIL);
|
||||
session.setLocalRepositoryManager(repository.newLocalRepositoryManager(session, new LocalRepository("libraries")));
|
||||
session.setTransferListener(new AbstractTransferListener()
|
||||
{
|
||||
@Override
|
||||
public void transferStarted(@NotNull TransferEvent event) throws TransferCancelledException
|
||||
{
|
||||
logger.log(Level.INFO, "Downloading {0}", event.getResource().getRepositoryUrl() + event.getResource().getResourceName());
|
||||
}
|
||||
});
|
||||
session.setReadOnly();
|
||||
|
||||
this.repositories = repository.newResolutionRepositories(session, Arrays.asList(new RemoteRepository.Builder("central", "default", "https://repo.maven.apache.org/maven2").build()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ClassLoader createLoader(@NotNull PlexModule module, @NotNull PlexModuleFile moduleFile)
|
||||
{
|
||||
if (moduleFile.getLibraries().isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
logger.log(Level.INFO, "Loading libraries for {0}", new Object[]{moduleFile.getName()});
|
||||
logger.log(Level.INFO, "[{0}] Loading {1} libraries... please wait", new Object[]
|
||||
{
|
||||
moduleFile.getName(), moduleFile.getLibraries().size()
|
||||
});
|
||||
|
||||
List<Dependency> dependencies = new ArrayList<>();
|
||||
List<Class<?>> classes = Lists.newArrayList();
|
||||
List<File> files = Lists.newArrayList();
|
||||
for (String library : moduleFile.getLibraries())
|
||||
{
|
||||
Artifact artifact = new DefaultArtifact(library);
|
||||
Dependency dependency = new Dependency(artifact, null);
|
||||
|
||||
dependencies.add(dependency);
|
||||
}
|
||||
|
||||
DependencyResult result;
|
||||
try
|
||||
{
|
||||
result = repository.resolveDependencies(session, new DependencyRequest(new CollectRequest((Dependency)null, dependencies, repositories), null));
|
||||
}
|
||||
catch (DependencyResolutionException ex)
|
||||
{
|
||||
throw new RuntimeException("Error resolving libraries", ex);
|
||||
}
|
||||
|
||||
List<URL> jarFiles = new ArrayList<>();
|
||||
for (ArtifactResult artifact : result.getArtifactResults())
|
||||
{
|
||||
File file = artifact.getArtifact().getFile();
|
||||
files.add(file);
|
||||
URL url;
|
||||
try
|
||||
{
|
||||
url = file.toURI().toURL();
|
||||
}
|
||||
catch (MalformedURLException ex)
|
||||
{
|
||||
throw new AssertionError(ex);
|
||||
}
|
||||
|
||||
jarFiles.add(url);
|
||||
logger.log(Level.INFO, "[{0}] Loaded library {1}", new Object[]
|
||||
{
|
||||
moduleFile.getName(), file
|
||||
});
|
||||
}
|
||||
|
||||
/*List<URL> jarFiles = Lists.newArrayList();
|
||||
List<Artifact> artifacts = Lists.newArrayList();
|
||||
|
||||
|
||||
List<Class<?>> classes = new ArrayList<>();
|
||||
|
||||
for (String library : moduleFile.getLibraries()) {
|
||||
Artifact artifact = new DefaultArtifact(library);
|
||||
ArtifactRequest request = new ArtifactRequest();
|
||||
request.setArtifact(artifact);
|
||||
request.addRepository(this.repositories.get(0));
|
||||
try {
|
||||
ArtifactResult result = this.repository.resolveArtifact(this.session, request);
|
||||
artifact = result.getArtifact();
|
||||
jarFiles.add(artifact.getFile().toURI().toURL());
|
||||
logger.log(Level.INFO, "Loaded library {0} for {1}", new Object[]{
|
||||
artifact.getFile().toURI().toURL().toString(),
|
||||
moduleFile.getName()
|
||||
});
|
||||
artifacts.add(artifact);
|
||||
} catch (ArtifactResolutionException | MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}*/
|
||||
logger.log(Level.INFO, "Loaded {0} libraries for {1}", new Object[]{jarFiles.size(), moduleFile.getName()});
|
||||
|
||||
// jarFiles.forEach(jar -> new CustomClassLoader(jar, Plex.class.getClassLoader()));
|
||||
// jarFiles.forEach(jar -> new CustomClassLoader(jar, Plex.class.getClassLoader()));
|
||||
|
||||
/*URLClassLoader loader = new URLClassLoader(jarFiles.toArray(URL[]::new), Plex.class.getClassLoader());
|
||||
|
||||
dependencies.forEach(artifact -> {
|
||||
ArrayList<String> classNames;
|
||||
try {
|
||||
classNames = getClassNamesFromJar(new JarFile(artifact.getArtifact().getFile()));
|
||||
for (String className : classNames) {
|
||||
Class<?> classToLoad = Class.forName(className, true, loader);
|
||||
classes.add(classToLoad);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
|
||||
classes.forEach(clazz -> logger.log(Level.INFO, "Loading class {0}", new Object[]{clazz.getName()}));*/
|
||||
jarFiles.forEach(url ->
|
||||
{
|
||||
JarURLConnection connection;
|
||||
try
|
||||
{
|
||||
URL url2 = new URL("jar:" + url.toString() + "!/");
|
||||
/*
|
||||
connection = (JarURLConnection) url2.openConnection();
|
||||
logger.log(Level.INFO, "Jar File: " + connection.getJarFileURL().toString());*/
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
return new URLClassLoader(files.stream().map(File::toURI).map(uri ->
|
||||
{
|
||||
try
|
||||
{
|
||||
return uri.toURL();
|
||||
}
|
||||
catch (MalformedURLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}).toList().toArray(URL[]::new)/*jarFiles.stream().map(url -> {
|
||||
try {
|
||||
return new URL("jar:" + url.toString() + "!/");
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}).toList().toArray(URL[]::new)*/, Plex.class.getClassLoader())/*new CustomClassLoader(jarFiles.toArray(URL[]::new), Plex.class.getClassLoader())*/;
|
||||
}
|
||||
|
||||
/*public List<Class<?>> loadDependency(List<Path> paths) throws Exception {
|
||||
|
||||
List<Class<?>> classes = new ArrayList<>();
|
||||
|
||||
for (Path path : paths) {
|
||||
|
||||
URL url = path.toUri().toURL();
|
||||
URLClassLoader child = new URLClassLoader(new URL[]{url}, this.getClass().getClassLoader());
|
||||
|
||||
ArrayList<String> classNames = getClassNamesFromJar(path.toString());
|
||||
|
||||
for (String className : classNames) {
|
||||
Class classToLoad = Class.forName(className, true, child);
|
||||
classes.add(classToLoad);
|
||||
}
|
||||
}
|
||||
|
||||
return classes;
|
||||
}*/
|
||||
|
||||
|
||||
private ArrayList<String> getClassNamesFromJar(JarFile file) throws Exception
|
||||
{
|
||||
ArrayList<String> classNames = new ArrayList<>();
|
||||
try
|
||||
{
|
||||
//Iterate through the contents of the jar file
|
||||
Enumeration<JarEntry> entries = file.entries();
|
||||
while (entries.hasMoreElements())
|
||||
{
|
||||
JarEntry entry = entries.nextElement();
|
||||
//Pick file that has the extension of .class
|
||||
if ((entry.getName().endsWith(".class")))
|
||||
{
|
||||
String className = entry.getName().replaceAll("/", "\\.");
|
||||
String myClass = className.substring(0, className.lastIndexOf('.'));
|
||||
classNames.add(myClass);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
throw new Exception("Error while getting class names from jar", e);
|
||||
}
|
||||
return classNames;
|
||||
}
|
||||
}
|
@ -1,9 +1,10 @@
|
||||
package dev.plex.permission;
|
||||
|
||||
import dev.morphia.annotations.Entity;
|
||||
import java.util.UUID;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
public class Permission
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user