28 Commits

Author SHA1 Message Date
ecbd9c02da Release Plex v1.3 2023-07-22 20:00:25 -05:00
77dc95ae29 Add Folia support minus world generation 2023-07-21 20:01:59 -05:00
91a1b1cfff Remove publishing block 2023-07-10 22:58:51 -05:00
0c6091f06a Convert Plex to a paper plugin 2023-07-10 21:43:21 -05:00
ffbad7928a Update dependencies 2023-06-08 15:25:25 -05:00
7caa89539d Update Gradle and dependencies 2023-04-29 15:06:46 -05:00
ceb9a83eda Update Gradle and dependencies 2023-03-15 21:45:34 -05:00
a62bdef5b4 Add response HTTP status code check to update checker to improve efficiency 2023-03-09 17:16:14 +11:00
37649f1fdc Closes #55 2023-03-08 19:29:30 -06:00
ea512487ac Reformat 2023-03-08 14:26:10 -06:00
41b0076f8f Make the list command work with the permission system 2023-03-08 14:23:10 -06:00
00b6473e4d Let's actually remove these files 2023-03-08 22:48:51 +11:00
77be23faf0 Minor clean up 2023-03-08 22:45:47 +11:00
e39f882ea7 Fix out of bounds exception - closes #54 2023-03-08 21:46:27 +11:00
344d890877 Block translate tag 2023-03-08 00:45:41 -06:00
2c8c6353c1 Update build.gradle 2023-03-08 00:29:14 -06:00
8fa05e3838 Update dependencies and Gradle 2023-03-02 23:06:37 -06:00
158ce52320 Fix links 2022-12-26 23:39:47 -06:00
1cc431621b Update README.md 2022-12-26 23:34:26 -06:00
b9c873beb3 Update dependencies 2022-11-27 22:14:27 -06:00
6e1fa15a6c Remove redundant <red> 2022-11-27 16:40:55 -06:00
c216bdc5a4 Add permission check for the -o flag on the login message commands 2022-11-26 04:31:43 -06:00
ed638679b2 Use cache for toggling commandspy 2022-11-26 04:24:52 -06:00
76952e33b8 Use PlexCommand instead of PlexUtils 2022-11-26 04:24:38 -06:00
f3f7daaafb Add customizable login messages 2022-11-26 04:24:12 -06:00
dbbaf4ab70 Update Gradle 2022-11-26 02:25:05 -06:00
1a10fdd481 Update Gradle 2022-09-13 02:08:35 -05:00
7565bb6fcf Back to snapshot 2022-08-25 21:18:53 -05:00
147 changed files with 988 additions and 960 deletions

View File

@ -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
View File

@ -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 {

View File

@ -1,4 +1,4 @@
# Plex [![Build Status](https://ci.plex.us.org/job/Plex/job/master/badge/icon)](https://ci.plex.us.org/job/Plex/job/master/) ![CodeQL](https://github.com/plexusorg/Plex/workflows/CodeQL/badge.svg)
# Plex [![Build Status](https://ci.plex.us.org/job/Plex/job/master/badge/icon)](https://ci.plex.us.org/job/Plex/job/master/) [![License](https://img.shields.io/github/license/plexusorg/Plex)](https://github.com/plexusorg/Plex/blob/master/LICENSE.md) [![Discord](https://img.shields.io/discord/927737516864446495)](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 doesnt have. For example, there is full support for using a

View File

@ -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 {

Binary file not shown.

View File

@ -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
View File

@ -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.

11
gradlew.bat vendored
View File

@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@ -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

View File

@ -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")
}

View File

@ -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

View File

@ -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
{
/**

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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
{

View File

@ -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
{

View File

@ -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

View File

@ -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
{

View File

@ -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

View File

@ -1,6 +1,7 @@
package dev.plex.toml;
import java.util.Collection;
import static dev.plex.toml.ValueWriters.WRITERS;
class TableArrayValueWriter extends ArrayValueWriter

View File

@ -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>
*

View File

@ -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;
/**

View File

@ -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;

View File

@ -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()

View File

@ -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;

View File

@ -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() {

View File

@ -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");

View 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());
}
}
}

View File

@ -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
*/

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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
*/

View File

@ -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;

View File

@ -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
{

View File

@ -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")

View File

@ -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()));

View File

@ -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;

View File

@ -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)

View File

@ -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")

View File

@ -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))
{

View File

@ -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

View File

@ -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")

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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());

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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")

View File

@ -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

View File

@ -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

View File

@ -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")

View File

@ -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;
}
}

View File

@ -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"));
}
}
}

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -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()));

View File

@ -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)

View File

@ -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

View File

@ -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<>();
@ -86,7 +87,6 @@ public class BlockListener extends PlexListener
if (blockedPlayers.contains(event.getPlayer().getName()))
{
event.setCancelled(true);
return;
}
}
}

View File

@ -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)

View File

@ -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);

View File

@ -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 ->

View File

@ -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();
@ -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;
}
}
}

View File

@ -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");

View File

@ -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);

View File

@ -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());
}
}
}

View File

@ -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)
{

View File

@ -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");

View File

@ -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;
@ -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;
}
}
}

View File

@ -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
{

View File

@ -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();

View File

@ -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()

View File

@ -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)

View File

@ -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
{

View File

@ -6,5 +6,4 @@ public class ModuleLoadException extends RuntimeException
{
super(s);
}
}

View File

@ -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);
}
}
}

View File

@ -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;
}
}

View File

@ -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

View File

@ -12,11 +12,7 @@ import dev.plex.punishment.Punishment;
import dev.plex.punishment.extra.Note;
import dev.plex.rank.enums.Rank;
import dev.plex.storage.StorageType;
import dev.plex.util.adapter.ZonedDateTimeSerializer;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import dev.plex.util.adapter.ZonedDateTimeAdapter;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;
@ -26,6 +22,10 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionAttachment;
import java.time.ZonedDateTime;
import java.util.List;
import java.util.UUID;
@Getter
@Setter
@Entity(value = "players", useDiscriminator = false)
@ -136,21 +136,21 @@ public class PlexPlayer
}
}
public CompletableFuture<List<Note>> loadNotes()
public void loadNotes()
{
if (Plex.get().getStorageType() != StorageType.MONGODB)
{
return Plex.get().getSqlNotes().getNotes(this.getUuid());
Plex.get().getSqlNotes().getNotes(this.getUuid());
}
return null;
}
public String toJSON()
{
return new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeSerializer()).create().toJson(this);
return new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeAdapter()).create().toJson(this);
}
public Player getPlayer() {
public Player getPlayer()
{
return Bukkit.getPlayer(this.uuid);
}
}

View File

@ -1,24 +1,26 @@
package dev.plex.punishment;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import dev.morphia.annotations.Entity;
import dev.plex.Plex;
import dev.plex.util.MojangUtils;
import dev.plex.util.PlexUtils;
import dev.plex.util.TimeUtils;
import dev.plex.util.adapter.ZonedDateTimeDeserializer;
import dev.plex.util.adapter.ZonedDateTimeSerializer;
import java.time.ZonedDateTime;
import java.util.UUID;
import dev.plex.util.adapter.ZonedDateTimeAdapter;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.text.Component;
import java.time.ZonedDateTime;
import java.util.UUID;
@Getter
@Setter
@Entity
public class Punishment
{
private static final Gson gson = new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeAdapter()).create();
private static final String banUrl = Plex.get().config.getString("banning.ban_url");
private final UUID punished;
private final UUID punisher;
@ -54,11 +56,11 @@ public class Punishment
public static Punishment fromJson(String json)
{
return new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeDeserializer()).create().fromJson(json, Punishment.class);
return gson.fromJson(json, Punishment.class);
}
public String toJSON()
{
return new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeSerializer()).create().toJson(this);
return gson.toJson(this);
}
}

View File

@ -11,6 +11,12 @@ import dev.plex.storage.StorageType;
import dev.plex.util.PlexLog;
import dev.plex.util.PlexUtils;
import dev.plex.util.TimeUtils;
import lombok.Data;
import lombok.Getter;
import org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitRunnable;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@ -22,11 +28,6 @@ import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
import lombok.Data;
import lombok.Getter;
import org.apache.commons.io.FileUtils;
import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitRunnable;
public class PunishmentManager implements PlexBase
{

Some files were not shown because too many files have changed in this diff Show More