mirror of
https://github.com/plexusorg/Plex.git
synced 2025-07-04 16:56:40 +00:00
Compare commits
1 Commits
6b7c076c41
...
velocity-4
Author | SHA1 | Date | |
---|---|---|---|
60b32b05f1 |
72
build.gradle
Normal file
72
build.gradle
Normal file
@ -0,0 +1,72 @@
|
||||
plugins {
|
||||
id "java"
|
||||
id "maven-publish"
|
||||
id "com.github.johnrengelman.shadow" version "8.1.1"
|
||||
}
|
||||
|
||||
group = "dev.plex"
|
||||
version = "1.4-SNAPSHOT"
|
||||
description = "Plex"
|
||||
|
||||
subprojects {
|
||||
apply plugin: "java"
|
||||
apply plugin: "maven-publish"
|
||||
apply plugin: "com.github.johnrengelman.shadow"
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url = uri("https://repo.papermc.io/repository/maven-public/")
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri("https://repository.apache.org/content/repositories/snapshots/")
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri("https://repo.maven.apache.org/maven2/")
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri("https://jitpack.io")
|
||||
content {
|
||||
includeGroup("com.github.MilkBowl")
|
||||
}
|
||||
}
|
||||
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
def releasesRepoUrl = uri("https://nexus.telesphoreo.me/repository/plex-releases/")
|
||||
def snapshotsRepoUrl = uri("https://nexus.telesphoreo.me/repository/plex-snapshots/")
|
||||
url = rootProject.version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
|
||||
credentials {
|
||||
username = System.getenv("plexUser")
|
||||
password = System.getenv("plexPassword")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
clean {
|
||||
dependsOn(":server:clean")
|
||||
dependsOn(":proxy:clean")
|
||||
}
|
||||
|
||||
task copyJars(type: Copy, dependsOn: subprojects.jar) {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
from(subprojects.jar)
|
||||
from(subprojects.shadowJar)
|
||||
into project.file('build/libs')
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
plugins {
|
||||
id("java")
|
||||
id("maven-publish")
|
||||
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7"
|
||||
id("net.kyori.blossom") version "2.1.0"
|
||||
id("com.github.johnrengelman.shadow") version "8.1.1"
|
||||
}
|
||||
|
||||
group = "dev.plex"
|
||||
version = "1.4-SNAPSHOT"
|
||||
description = "Plex"
|
||||
|
||||
subprojects {
|
||||
apply(plugin = "java")
|
||||
apply(plugin = "maven-publish")
|
||||
apply(plugin = "org.jetbrains.gradle.plugin.idea-ext")
|
||||
apply(plugin = "net.kyori.blossom")
|
||||
apply(plugin = "com.github.johnrengelman.shadow")
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url = uri("https://repo.papermc.io/repository/maven-public/")
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri("https://repository.apache.org/content/repositories/snapshots/")
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri("https://repo.maven.apache.org/maven2/")
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri("https://jitpack.io")
|
||||
content {
|
||||
includeGroup("com.github.MilkBowl")
|
||||
}
|
||||
}
|
||||
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
|
||||
tasks {
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
}
|
||||
javadoc {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
}
|
||||
processResources {
|
||||
filteringCharset = Charsets.UTF_8.name()
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
val releasesRepoUrl = uri("https://nexus.telesphoreo.me/repository/plex-releases/")
|
||||
val snapshotsRepoUrl = uri("https://nexus.telesphoreo.me/repository/plex-snapshots/")
|
||||
url = if (rootProject.version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
|
||||
credentials {
|
||||
username = System.getenv("plexUser")
|
||||
password = System.getenv("plexPassword")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.clean {
|
||||
dependsOn(subprojects.map {
|
||||
it.project.tasks.clean
|
||||
})
|
||||
}
|
||||
|
||||
tasks.create<Copy>("copyJars") {
|
||||
dependsOn(tasks.jar)
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
from(subprojects.map {
|
||||
it.project.tasks.shadowJar
|
||||
})
|
||||
from(subprojects.map {
|
||||
it.project.tasks.jar
|
||||
})
|
||||
into(file("build/libs"))
|
||||
}
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
@ -1,3 +1,8 @@
|
||||
plugins {
|
||||
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7"
|
||||
id("net.kyori.blossom") version "2.1.0"
|
||||
}
|
||||
|
||||
group = rootProject.group
|
||||
version = rootProject.version
|
||||
description = "Plex-Velocity"
|
||||
@ -42,6 +47,7 @@ dependencies {
|
||||
compileOnly("org.projectlombok:lombok:1.18.30")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.30")
|
||||
compileOnly("org.json:json:20231013")
|
||||
compileOnly("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT")
|
||||
annotationProcessor("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT")
|
||||
implementation("net.kyori:adventure-text-minimessage:4.14.0")
|
||||
compileOnly("com.velocitypowered:velocity-api:4.0.0-SNAPSHOT")
|
||||
annotationProcessor("com.velocitypowered:velocity-api:4.0.0-SNAPSHOT")
|
||||
}
|
@ -2,7 +2,7 @@ package dev.plex;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.event.lifecycle.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
@ -28,7 +28,7 @@ import java.util.logging.Logger;
|
||||
@Plugin(
|
||||
name = "Plex",
|
||||
id = "plex",
|
||||
version = BuildParameters.VERSION,
|
||||
version = "{{ version }}",
|
||||
url = "https://plex.us.org",
|
||||
description = "Plex provides a new experience for freedom servers.",
|
||||
authors = {"Telesphoreo", "Taah"}
|
||||
|
@ -2,9 +2,9 @@ package dev.plex.command;
|
||||
|
||||
import com.velocitypowered.api.command.CommandMeta;
|
||||
import com.velocitypowered.api.command.CommandSource;
|
||||
import com.velocitypowered.api.command.ConsoleCommandSource;
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
import com.velocitypowered.api.proxy.ConsoleCommandSource;
|
||||
import com.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.connection.Player;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
@ -43,10 +43,9 @@ public abstract class PlexCommand implements SimpleCommand
|
||||
this.perms = getClass().getAnnotation(CommandPermissions.class);
|
||||
this.commandSource = this.perms.source();
|
||||
|
||||
CommandMeta.Builder meta = plugin.getServer().getCommandManager().metaBuilder(this.params.name());
|
||||
CommandMeta.Builder meta = plugin.getServer().commandManager().createMetaBuilder(this.params.name());
|
||||
meta.aliases(this.params.aliases());
|
||||
meta.plugin(Plex.get());
|
||||
plugin.getServer().getCommandManager().register(meta.build(), this);
|
||||
plugin.getServer().commandManager().register(meta.build(), this);
|
||||
}
|
||||
|
||||
protected abstract Component execute(@NotNull CommandSource source, @Nullable Player player, @NotNull String[] args);
|
||||
|
@ -8,6 +8,6 @@ public class PlexListener
|
||||
|
||||
public PlexListener()
|
||||
{
|
||||
Plex.get().getServer().getEventManager().register(Plex.get(), this);
|
||||
Plex.get().getServer().eventManager().register(Plex.get(), this);
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package dev.plex.listener.impl;
|
||||
|
||||
import com.velocitypowered.api.event.PostOrder;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
||||
import com.velocitypowered.api.event.player.DisconnectEvent;
|
||||
import com.velocitypowered.api.event.player.ServerConnectedEvent;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.listener.PlexListener;
|
||||
@ -14,27 +14,27 @@ public class ConnectionListener extends PlexListener
|
||||
@Subscribe(order = PostOrder.FIRST)
|
||||
public void onPlayerJoin(ServerConnectedEvent event)
|
||||
{
|
||||
if (event.getPreviousServer().isPresent())
|
||||
if (event.previousServer() != null)
|
||||
{
|
||||
Plex.get().server.sendMessage(miniMessage("<dark_gray>[<#ffbf00>o<dark_gray>] <yellow>"
|
||||
+ event.getPlayer().getUsername() + " switched from " + event.getPreviousServer().get().getServerInfo().getName()
|
||||
+ " to " + event.getServer().getServerInfo().getName()));
|
||||
+ event.player().username() + " switched from " + event.previousServer().serverInfo().name()
|
||||
+ " to " + event.target().serverInfo().name()));
|
||||
}
|
||||
else
|
||||
{
|
||||
Plex.get().server.sendMessage(miniMessage("<dark_gray>[<green>+<dark_gray>] <yellow>"
|
||||
+ event.getPlayer().getUsername() + " joined server " + event.getServer().getServerInfo().getName()));
|
||||
+ event.player().username() + " joined server " + event.target().serverInfo().name()));
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe(order = PostOrder.FIRST)
|
||||
public void onPlayerLeave(DisconnectEvent event)
|
||||
{
|
||||
if (event.getPlayer().getCurrentServer().isPresent())
|
||||
if (event.player().connectedServer() != null)
|
||||
{
|
||||
Plex.get().server.sendMessage(miniMessage("<dark_gray>[<red>-<dark_gray>] <yellow>"
|
||||
+ event.getPlayer().getUsername() + " left server " +
|
||||
event.getPlayer().getCurrentServer().get().getServerInfo().getName()));
|
||||
+ event.player().username() + " left server " +
|
||||
event.player().connectedServer().serverInfo().name()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package dev.plex.listener.impl;
|
||||
|
||||
import com.velocitypowered.api.event.PostOrder;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyPingEvent;
|
||||
import com.velocitypowered.api.event.connection.ProxyPingEvent;
|
||||
import com.velocitypowered.api.proxy.server.ServerPing;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.settings.ServerSettings;
|
||||
@ -24,10 +24,10 @@ public class ServerListener extends PlexListener
|
||||
String baseMotd = plugin.getConfig().as(ServerSettings.class).getServer().getMotd().get(ThreadLocalRandom.current().nextInt(plugin.getConfig().as(ServerSettings.class).getServer().getMotd().size()));
|
||||
baseMotd = baseMotd.replace("\\n", "\n");
|
||||
baseMotd = baseMotd.replace("%servername%", plugin.getConfig().as(ServerSettings.class).getServer().getName());
|
||||
baseMotd = baseMotd.replace("%mcversion%", plugin.getServer().getVersion().getVersion().split(" ")[0]);
|
||||
baseMotd = baseMotd.replace("%mcversion%", plugin.getServer().version().version().split(" ")[0]);
|
||||
baseMotd = baseMotd.replace("%randomgradient%", "<gradient:" + RandomUtil.getRandomColor().toString() + ":" + RandomUtil.getRandomColor().toString() + ">");
|
||||
|
||||
ServerPing.Builder builder = event.getPing().asBuilder();
|
||||
ServerPing.Builder builder = event.ping().asBuilder();
|
||||
|
||||
if (plugin.getConfig().as(ServerSettings.class).getServer().isColorizeMotd())
|
||||
{
|
||||
@ -45,7 +45,7 @@ public class ServerListener extends PlexListener
|
||||
}
|
||||
|
||||
builder.samplePlayers(plugin.getConfig().as(ServerSettings.class).getServer().getSample().stream().map(s -> new ServerPing.SamplePlayer(convertColorCodes(s), UUID.randomUUID())).toArray(ServerPing.SamplePlayer[]::new));
|
||||
builder.onlinePlayers(plugin.getServer().getPlayerCount() + plugin.getConfig().as(ServerSettings.class).getServer().getAddPlayerCount());
|
||||
builder.onlinePlayers(plugin.getServer().countConnectedPlayers() + plugin.getConfig().as(ServerSettings.class).getServer().getAddPlayerCount());
|
||||
if (plugin.getConfig().as(ServerSettings.class).getServer().isPlusOneMaxPlayer())
|
||||
{
|
||||
builder.maximumPlayers(builder.getOnlinePlayers() + 1);
|
||||
|
@ -17,12 +17,12 @@ public class PlexLog
|
||||
message = message.replace("{" + i + "}", strings[i].toString());
|
||||
}
|
||||
}
|
||||
Plex.get().getServer().getConsoleCommandSource().sendMessage(MiniMessage.miniMessage().deserialize("<yellow>[Plex] <gray>" + message));
|
||||
Plex.get().getServer().consoleCommandSource().sendMessage(MiniMessage.miniMessage().deserialize("<yellow>[Plex] <gray>" + message));
|
||||
}
|
||||
|
||||
public static void log(Component component)
|
||||
{
|
||||
Plex.get().getServer().getConsoleCommandSource().sendMessage(Component.text("[Plex] ").color(NamedTextColor.YELLOW).append(component).colorIfAbsent(NamedTextColor.GRAY));
|
||||
Plex.get().getServer().consoleCommandSource().sendMessage(Component.text("[Plex] ").color(NamedTextColor.YELLOW).append(component).colorIfAbsent(NamedTextColor.GRAY));
|
||||
}
|
||||
|
||||
public static void error(String message, Object... strings)
|
||||
@ -34,7 +34,7 @@ public class PlexLog
|
||||
message = message.replace("{" + i + "}", strings[i].toString());
|
||||
}
|
||||
}
|
||||
Plex.get().getServer().getConsoleCommandSource().sendMessage(MiniMessage.miniMessage().deserialize("<red>[Plex Error] <gold>" + message));
|
||||
Plex.get().getServer().consoleCommandSource().sendMessage(MiniMessage.miniMessage().deserialize("<red>[Plex Error] <gold>" + message));
|
||||
}
|
||||
|
||||
public static void warn(String message, Object... strings)
|
||||
@ -46,7 +46,7 @@ public class PlexLog
|
||||
message = message.replace("{" + i + "}", strings[i].toString());
|
||||
}
|
||||
}
|
||||
Plex.get().getServer().getConsoleCommandSource().sendMessage(MiniMessage.miniMessage().deserialize("<#eb7c0e>[Plex Warning] <gold>" + message));
|
||||
Plex.get().getServer().consoleCommandSource().sendMessage(MiniMessage.miniMessage().deserialize("<#eb7c0e>[Plex Warning] <gold>" + message));
|
||||
}
|
||||
|
||||
public static void debug(String message, Object... strings)
|
||||
@ -60,7 +60,7 @@ public class PlexLog
|
||||
}
|
||||
if (Plex.get().getConfig().as(ServerSettings.class).getServer().isDebug())
|
||||
{
|
||||
Plex.get().getServer().getConsoleCommandSource().sendMessage(MiniMessage.miniMessage().deserialize("<dark_purple>[Plex Debug] <gold>" + message));
|
||||
Plex.get().getServer().consoleCommandSource().sendMessage(MiniMessage.miniMessage().deserialize("<dark_purple>[Plex Debug] <gold>" + message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
154
server/build.gradle
Normal file
154
server/build.gradle
Normal file
@ -0,0 +1,154 @@
|
||||
plugins {
|
||||
id "net.minecrell.plugin-yml.paper" version "0.6.0"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
library "org.projectlombok:lombok:1.18.30"
|
||||
annotationProcessor "org.projectlombok:lombok:1.18.30"
|
||||
library "org.json:json:20231013"
|
||||
library "commons-io:commons-io:2.15.0"
|
||||
library "redis.clients:jedis:5.0.2"
|
||||
library "org.mariadb.jdbc:mariadb-java-client:3.2.0"
|
||||
library "com.zaxxer:HikariCP:5.0.1"
|
||||
library "org.apache.maven.resolver:maven-resolver-transport-http:1.9.16"
|
||||
library "org.jetbrains:annotations:24.0.1"
|
||||
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.2"
|
||||
implementation "org.bstats:bstats-bukkit:3.0.2"
|
||||
}
|
||||
|
||||
group = rootProject.group
|
||||
version = rootProject.version
|
||||
description = "Plex-Server"
|
||||
|
||||
shadowJar {
|
||||
archiveBaseName.set("Plex")
|
||||
archiveClassifier.set("")
|
||||
relocate "org.bstats", "dev.plex"
|
||||
}
|
||||
|
||||
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"]
|
||||
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'
|
||||
}
|
||||
'Essentials' {
|
||||
required = false
|
||||
load = 'BEFORE'
|
||||
}
|
||||
'SlimeWorldManager' {
|
||||
required = false
|
||||
load = 'AFTER'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String getGitHash() {
|
||||
def stdout = new ByteArrayOutputStream()
|
||||
try {
|
||||
exec {
|
||||
commandLine "git", "rev-parse", "--short", "HEAD"
|
||||
standardOutput = stdout
|
||||
ignoreExitValue = true
|
||||
}
|
||||
} catch (GradleException e) {
|
||||
logger.error("Couldn't determine Git head because Git is not installed. " + e.getMessage())
|
||||
}
|
||||
return stdout.size() > 0 ? stdout.toString().trim() : "unknown"
|
||||
}
|
||||
|
||||
String getBuildNumber() {
|
||||
def stdout = new ByteArrayOutputStream()
|
||||
try {
|
||||
exec {
|
||||
commandLine "git", "rev-list", "HEAD", "--count"
|
||||
standardOutput = stdout
|
||||
ignoreExitValue = true
|
||||
}
|
||||
} catch (GradleException e) {
|
||||
logger.error("Couldn't determine build number because Git is not installed. " + e.getMessage())
|
||||
}
|
||||
return stdout.size() ? stdout.toString().trim() + " (local)" : "unknown"
|
||||
}
|
||||
|
||||
static def getDate() {
|
||||
return new Date().format("MM/dd/yyyy '<light_purple>at<gold>' hh:mm:ss a z")
|
||||
}
|
||||
|
||||
task buildProperties {
|
||||
ant.propertyfile(file: "$project.projectDir/src/main/resources/build.properties") {
|
||||
entry(key: "buildAuthor", default: System.getenv("JENKINS_URL") != null ? "jenkins" : "unknown")
|
||||
entry(key: "buildNumber", value: System.getenv("JENKINS_URL") != null ? System.getenv("BUILD_NUMBER") + " (Jenkins)" : getBuildNumber())
|
||||
entry(key: "buildDate", value: getDate())
|
||||
entry(key: "buildHead", value: getGitHash())
|
||||
}
|
||||
}
|
||||
|
||||
tasks {
|
||||
build {
|
||||
dependsOn(shadowJar)
|
||||
finalizedBy(buildProperties)
|
||||
}
|
||||
|
||||
jar {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
finalizedBy(rootProject.tasks.copyJars)
|
||||
}
|
||||
|
||||
javadoc {
|
||||
options.memberLevel = JavadocMemberLevel.PRIVATE
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
pom.withXml {
|
||||
def dependenciesNode = asNode().appendNode("dependencies")
|
||||
configurations.getByName("library").getAllDependencies().each { dependency ->
|
||||
dependenciesNode.appendNode("dependency").with {
|
||||
it.appendNode("groupId", dependency.group)
|
||||
it.appendNode("artifactId", dependency.name)
|
||||
it.appendNode("version", dependency.version)
|
||||
it.appendNode("scope", "provided")
|
||||
}
|
||||
}
|
||||
configurations.getByName("implementation").getAllDependencies().each { dependency ->
|
||||
dependenciesNode.appendNode("dependency").with {
|
||||
it.appendNode("groupId", dependency.group)
|
||||
it.appendNode("artifactId", dependency.name)
|
||||
it.appendNode("version", dependency.version)
|
||||
it.appendNode("scope", "runtime")
|
||||
}
|
||||
}
|
||||
}
|
||||
artifacts = [shadowJar]
|
||||
}
|
||||
}
|
||||
}
|
@ -1,158 +0,0 @@
|
||||
import net.minecrell.pluginyml.paper.PaperPluginDescription
|
||||
import java.io.ByteArrayOutputStream
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
|
||||
plugins {
|
||||
id("net.kyori.indra.git") version "3.1.3"
|
||||
id("net.minecrell.plugin-yml.paper") version "0.6.0"
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven(url = uri("https://maven.playpro.com"))
|
||||
maven(url = uri("https://nexus.telesphoreo.me/repository/plex-modules/"))
|
||||
}
|
||||
|
||||
dependencies {
|
||||
library("org.projectlombok:lombok:1.18.30")
|
||||
library("org.json:json:20231013")
|
||||
library("commons-io:commons-io:2.15.1")
|
||||
library("redis.clients:jedis:5.1.0")
|
||||
library("org.mariadb.jdbc:mariadb-java-client:3.3.1")
|
||||
library("com.zaxxer:HikariCP:5.1.0")
|
||||
library("org.apache.maven.resolver:maven-resolver-transport-http:1.9.18")
|
||||
library("org.jetbrains:annotations:24.1.0")
|
||||
|
||||
compileOnly("dev.folia:folia-api:1.20.2-R0.1-SNAPSHOT")
|
||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1") {
|
||||
exclude("org.bukkit", "bukkit")
|
||||
}
|
||||
compileOnly("net.coreprotect:coreprotect:22.2")
|
||||
compileOnly("network.darkhelmet.prism:Prism-Api:1.0.0")
|
||||
|
||||
implementation("org.bstats:bstats-base:3.0.2")
|
||||
implementation("org.bstats:bstats-bukkit:3.0.2")
|
||||
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.30")
|
||||
}
|
||||
|
||||
group = rootProject.group
|
||||
version = rootProject.version
|
||||
description = "Plex-Server"
|
||||
|
||||
paper {
|
||||
name = "Plex"
|
||||
version = rootProject.version.toString()
|
||||
description = "Plex provides a new experience for freedom servers."
|
||||
main = "dev.plex.Plex"
|
||||
loader = "dev.plex.PlexLibraryManager"
|
||||
website = "https://plex.us.org"
|
||||
authors = listOf("Telesphoreo", "taahanis", "supernt")
|
||||
apiVersion = "1.19"
|
||||
foliaSupported = true
|
||||
generateLibrariesJson = true
|
||||
// Load BukkitTelnet and LibsDisguises before Plex so the modules register properly
|
||||
serverDependencies {
|
||||
register("BukkitTelnet") {
|
||||
required = false
|
||||
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
||||
}
|
||||
register("Essentials") {
|
||||
required = false
|
||||
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
||||
}
|
||||
register("LibsDisguises") {
|
||||
required = false
|
||||
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
||||
}
|
||||
register("Prism") {
|
||||
required = false
|
||||
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
||||
}
|
||||
register("CoreProtect") {
|
||||
required = false
|
||||
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
||||
}
|
||||
register("SlimeWorldManager") {
|
||||
required = false
|
||||
load = PaperPluginDescription.RelativeLoadOrder.AFTER
|
||||
}
|
||||
register("Vault") {
|
||||
required = false
|
||||
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getBuildNumber(): String {
|
||||
val stdout = ByteArrayOutputStream()
|
||||
try {
|
||||
exec {
|
||||
commandLine("git", "rev-list", "HEAD", "--count")
|
||||
standardOutput = stdout
|
||||
isIgnoreExitValue = true
|
||||
}
|
||||
} catch (e: GradleException) {
|
||||
logger.error("Couldn't determine build number because Git is not installed. " + e.message)
|
||||
}
|
||||
return if (stdout.size() > 0) stdout.toString().trim() else "unknown"
|
||||
}
|
||||
|
||||
tasks {
|
||||
build {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
|
||||
jar {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
blossom {
|
||||
resources {
|
||||
property("author", if (System.getenv("JENKINS_URL") != null) "jenkins" else System.getProperty("user.name"))
|
||||
property("buildNumber", if (System.getenv("BUILD_NUMBER") != null) System.getenv("BUILD_NUMBER") else getBuildNumber())
|
||||
property("date", SimpleDateFormat("MM/dd/yyyy '<light_purple>at<gold>' hh:mm:ss a z").format(Date()))
|
||||
property("gitCommit", indraGit.commit()?.name?.take(7))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
archiveBaseName.set("Plex")
|
||||
archiveClassifier.set("")
|
||||
relocate("org.bstats", "dev.plex")
|
||||
finalizedBy(rootProject.tasks["copyJars"])
|
||||
}
|
||||
|
||||
javadoc {
|
||||
options.memberLevel = JavadocMemberLevel.PRIVATE
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
pom.withXml {
|
||||
val dependenciesNode = asNode().appendNode("dependencies")
|
||||
configurations.getByName("library").allDependencies.configureEach {
|
||||
dependenciesNode.appendNode("dependency")
|
||||
.appendNode("groupId", group).parent()
|
||||
.appendNode("artifactId", name).parent()
|
||||
.appendNode("version", version).parent()
|
||||
.appendNode("scope", "provided").parent()
|
||||
}
|
||||
configurations.getByName("implementation").allDependencies.configureEach {
|
||||
dependenciesNode.appendNode("dependency")
|
||||
.appendNode("groupId", group).parent()
|
||||
.appendNode("artifactId", name).parent()
|
||||
.appendNode("version", version).parent()
|
||||
.appendNode("scope", "provided").parent()
|
||||
}
|
||||
}
|
||||
artifacts.artifact(tasks.shadowJar)
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,11 @@
|
||||
package dev.plex;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.cache.PlayerCache;
|
||||
import dev.plex.config.Config;
|
||||
import dev.plex.handlers.CommandHandler;
|
||||
import dev.plex.handlers.ListenerHandler;
|
||||
import dev.plex.hook.CoreProtectHook;
|
||||
import dev.plex.hook.PrismHook;
|
||||
import dev.plex.module.ModuleManager;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.PunishmentManager;
|
||||
@ -17,23 +16,22 @@ import dev.plex.storage.StorageType;
|
||||
import dev.plex.storage.player.SQLPlayerData;
|
||||
import dev.plex.storage.punishment.SQLNotes;
|
||||
import dev.plex.storage.punishment.SQLPunishment;
|
||||
import dev.plex.util.BuildInfo;
|
||||
import dev.plex.util.BungeeUtil;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.UpdateChecker;
|
||||
import dev.plex.util.*;
|
||||
import dev.plex.util.redis.MessageUtil;
|
||||
import dev.plex.util.sql.SQLUtil;
|
||||
import dev.plex.world.CustomWorld;
|
||||
import java.io.File;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class Plex extends JavaPlugin
|
||||
@ -48,6 +46,7 @@ public class Plex extends JavaPlugin
|
||||
public File modulesFolder;
|
||||
private StorageType storageType = StorageType.SQLITE;
|
||||
private SQLConnection sqlConnection;
|
||||
// private MongoConnection mongoConnection;
|
||||
private RedisConnection redisConnection;
|
||||
|
||||
private PlayerCache playerCache;
|
||||
@ -64,9 +63,6 @@ public class Plex extends JavaPlugin
|
||||
private Permission permissions;
|
||||
private Chat chat;
|
||||
|
||||
private CoreProtectHook coreProtectHook;
|
||||
private PrismHook prismHook;
|
||||
|
||||
public static Plex get()
|
||||
{
|
||||
return plugin;
|
||||
@ -128,31 +124,12 @@ public class Plex extends JavaPlugin
|
||||
|
||||
if (!getServer().getPluginManager().isPluginEnabled("Vault"))
|
||||
{
|
||||
throw new RuntimeException("Vault is required to run on the server alongside a permissions plugin, we recommend LuckPerms!");
|
||||
throw new RuntimeException("Vault is required to run on the server if you use permissions alongside a permissions plugin, we recommend LuckPerms!");
|
||||
}
|
||||
|
||||
permissions = setupPermissions();
|
||||
chat = setupChat();
|
||||
|
||||
if (plugin.getServer().getPluginManager().isPluginEnabled("CoreProtect"))
|
||||
{
|
||||
PlexLog.log("Hooked into CoreProtect!");
|
||||
coreProtectHook = new CoreProtectHook(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlexLog.debug("Not hooking into CoreProtect");
|
||||
}
|
||||
if (plugin.getServer().getPluginManager().isPluginEnabled("Prism"))
|
||||
{
|
||||
PlexLog.log("Hooked into Prism!");
|
||||
prismHook = new PrismHook(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlexLog.debug("Not hooking into Prism");
|
||||
}
|
||||
|
||||
updateChecker = new UpdateChecker();
|
||||
PlexLog.log("Update checking enabled");
|
||||
|
||||
|
@ -29,9 +29,9 @@ public class PlexLibraryManager implements PluginLoader
|
||||
// The plugin is null, a hacky way to check whether to load Jetty or not
|
||||
if (new File("plugins/Plex/modules/Module-HTTPD.jar").isFile())
|
||||
{
|
||||
resolver.addDependency(new Dependency(new DefaultArtifact("org.eclipse.jetty:jetty-server:11.0.19"), null));
|
||||
resolver.addDependency(new Dependency(new DefaultArtifact("org.eclipse.jetty:jetty-servlet:11.0.19"), null));
|
||||
resolver.addDependency(new Dependency(new DefaultArtifact("org.eclipse.jetty:jetty-proxy:11.0.19"), null));
|
||||
resolver.addDependency(new Dependency(new DefaultArtifact("org.eclipse.jetty:jetty-server:11.0.18"), null));
|
||||
resolver.addDependency(new Dependency(new DefaultArtifact("org.eclipse.jetty:jetty-servlet:11.0.18"), null));
|
||||
resolver.addDependency(new Dependency(new DefaultArtifact("org.eclipse.jetty:jetty-proxy:11.0.18"), null));
|
||||
}
|
||||
classpathBuilder.addLibrary(resolver);
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package dev.plex.command;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
@ -15,15 +14,14 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.*;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.util.StringUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
@ -63,7 +61,6 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
setName(this.params.name());
|
||||
setLabel(this.params.name());
|
||||
setDescription(params.description());
|
||||
setPermission(this.perms.permission());
|
||||
setUsage(params.usage().replace("<command>", this.params.name()));
|
||||
if (params.aliases().split(",").length > 0)
|
||||
{
|
||||
@ -77,8 +74,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
{
|
||||
getMap().getKnownCommands().remove(this.getName().toLowerCase());
|
||||
}
|
||||
this.getAliases().forEach(s ->
|
||||
{
|
||||
this.getAliases().forEach(s -> {
|
||||
if (getMap().getKnownCommands().containsKey(s.toLowerCase()))
|
||||
{
|
||||
getMap().getKnownCommands().remove(s.toLowerCase());
|
||||
@ -170,17 +166,6 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException;
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
List<String> list = smartTabComplete(sender, alias, args);
|
||||
return StringUtil.copyPartialMatches(args[args.length - 1], list, Lists.newArrayList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the String given is a matching command
|
||||
*
|
||||
@ -298,6 +283,47 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
return !permission.isEmpty() && player.hasPermission(permission);
|
||||
}
|
||||
|
||||
/* *//**
|
||||
* Checks whether a sender has enough permissions or is high enough a rank
|
||||
*
|
||||
* @param sender The player object
|
||||
* @param rank The rank to check (if the server is using ranks)
|
||||
* @param permission The permission to check (if the server is using permissions)
|
||||
* @return true if the sender has enough permissions
|
||||
* @see Rank
|
||||
*//*
|
||||
protected boolean silentCheckPermission(CommandSender sender, Rank rank, String permission)
|
||||
{
|
||||
if (!isConsole(sender))
|
||||
{
|
||||
return silentCheckPermission((Player) sender, rank, permission);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
*//**
|
||||
* Checks whether a player has enough permissions or is high enough a rank
|
||||
*
|
||||
* @param player The player object
|
||||
* @param rank The rank to check (if the server is using ranks)
|
||||
* @param permission The permission to check (if the server is using permissions)
|
||||
* @return true if the sender has enough permissions
|
||||
* @see Rank
|
||||
*//*
|
||||
protected boolean silentCheckPermission(Player player, Rank rank, String permission)
|
||||
{
|
||||
PlexPlayer plexPlayer = getPlexPlayer(player);
|
||||
if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||
{
|
||||
return rank.isAtLeast(Rank.ADMIN) ? plexPlayer.isAdminActive() && plexPlayer.getRankFromString().isAtLeast(rank) : plexPlayer.getRankFromString().isAtLeast(rank);
|
||||
}
|
||||
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
return !permission.isEmpty() && player.hasPermission(permission);
|
||||
}
|
||||
return true;
|
||||
}*/
|
||||
|
||||
/**
|
||||
* Gets the UUID of the sender
|
||||
*
|
||||
|
@ -1,5 +1,6 @@
|
||||
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;
|
||||
@ -11,6 +12,8 @@ import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
import dev.plex.util.redis.MessageUtil;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -18,8 +21,6 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandPermissions(permission = "plex.adminchat", source = RequiredCommandSource.ANY)
|
||||
@ -57,10 +58,4 @@ public class AdminChatCMD extends PlexCommand
|
||||
MessageUtil.sendStaffChat(sender, SafeMiniMessage.mmDeserialize(message), PlexUtils.adminChat(sender.getName(), prefix, message).toArray(UUID[]::new));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,6 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(permission = "plex.adminworld", source = RequiredCommandSource.IN_GAME)
|
||||
@CommandParameters(name = "adminworld", aliases = "aw", description = "Teleport to the adminworld")
|
||||
public class AdminworldCMD extends PlexCommand
|
||||
@ -32,10 +29,4 @@ public class AdminworldCMD extends PlexCommand
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ public class AdventureCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (silentCheckPermission(sender, "plex.gamemode.adventure.others"))
|
||||
{
|
||||
|
@ -1,5 +1,6 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.command.PlexCommand;
|
||||
@ -10,21 +11,8 @@ import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.util.BungeeUtil;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import dev.plex.util.*;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import network.darkhelmet.prism.api.PrismParameters;
|
||||
import network.darkhelmet.prism.api.Result;
|
||||
import network.darkhelmet.prism.api.actions.PrismProcessType;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -32,7 +20,11 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "ban", usage = "/<command> <player> [-nrb] [reason] [-nrb]", aliases = "offlineban,gtfo", description = "Bans a player, offline or online")
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@CommandParameters(name = "ban", usage = "/<command> <player> [reason]", aliases = "offlineban,gtfo", description = "Bans a player, offline or online")
|
||||
@CommandPermissions(permission = "plex.ban", source = RequiredCommandSource.ANY)
|
||||
|
||||
public class BanCMD extends PlexCommand
|
||||
@ -64,13 +56,10 @@ public class BanCMD extends PlexCommand
|
||||
String reason;
|
||||
Punishment punishment = new Punishment(plexPlayer.getUuid(), getUUID(sender));
|
||||
punishment.setType(PunishmentType.BAN);
|
||||
boolean rollBack = true;
|
||||
if (args.length > 1)
|
||||
{
|
||||
reason = StringUtils.join(args, " ", 1, args.length);
|
||||
String newReason = StringUtils.normalizeSpace(reason.replace("-nrb", ""));
|
||||
punishment.setReason(newReason.trim().isEmpty() ? "No reason provided." : newReason);
|
||||
rollBack = !reason.startsWith("-nrb") && !reason.endsWith("-nrb");
|
||||
punishment.setReason(reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -81,7 +70,10 @@ public class BanCMD extends PlexCommand
|
||||
punishment.setEndDate(date.plusDays(1));
|
||||
punishment.setCustomTime(false);
|
||||
punishment.setActive(true);
|
||||
punishment.setIp(player != null ? player.getAddress().getAddress().getHostAddress().trim() : plexPlayer.getIps().get(plexPlayer.getIps().size() - 1));
|
||||
if (player != null)
|
||||
{
|
||||
punishment.setIp(player.getAddress().getAddress().getHostAddress().trim());
|
||||
}
|
||||
plugin.getPunishmentManager().punish(plexPlayer, punishment);
|
||||
PlexUtils.broadcast(messageComponent("banningPlayer", sender.getName(), plexPlayer.getName()));
|
||||
Bukkit.getScheduler().runTask(Plex.get(), () ->
|
||||
@ -92,59 +84,14 @@ public class BanCMD extends PlexCommand
|
||||
}
|
||||
});
|
||||
PlexLog.debug("(From /ban command) PunishedPlayer UUID: " + plexPlayer.getUuid());
|
||||
|
||||
if (rollBack)
|
||||
{
|
||||
if (plugin.getPrismHook().hasPrism())
|
||||
{
|
||||
PrismParameters parameters = plugin.getPrismHook().prismApi().createParameters();
|
||||
parameters.addActionType("block-place");
|
||||
parameters.addActionType("block-break");
|
||||
parameters.addActionType("block-burn");
|
||||
parameters.addActionType("entity-spawn");
|
||||
parameters.addActionType("entity-kill");
|
||||
parameters.addActionType("entity-explode");
|
||||
parameters.addPlayerName(plexPlayer.getName());
|
||||
parameters.setBeforeTime(Instant.now().toEpochMilli());
|
||||
parameters.setProcessType(PrismProcessType.ROLLBACK);
|
||||
final Future<Result> result = plugin.getPrismHook().prismApi().performLookup(parameters, sender);
|
||||
Bukkit.getAsyncScheduler().runNow(plugin, scheduledTask ->
|
||||
{
|
||||
try
|
||||
{
|
||||
final Result done = result.get();
|
||||
}
|
||||
catch (InterruptedException | ExecutionException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (plugin.getCoreProtectHook().hasCoreProtect())
|
||||
{
|
||||
PlexLog.debug("Testing coreprotect");
|
||||
Bukkit.getAsyncScheduler().runNow(plugin, scheduledTask ->
|
||||
{
|
||||
plugin.getCoreProtectHook().coreProtectAPI().performRollback(86400, Collections.singletonList(plexPlayer.getName()), null, null, null, null, 0, null);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (args.length == 1 && silentCheckPermission(sender, this.getPermission()))
|
||||
{
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
if (args.length != 1 && silentCheckPermission(sender, this.getPermission()))
|
||||
{
|
||||
return Collections.singletonList("-nrb");
|
||||
}
|
||||
return Collections.emptyList();
|
||||
return args.length == 1 && silentCheckPermission(sender, "plex.ban") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
@ -12,11 +12,6 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(permission = "plex.blockedit")
|
||||
@CommandParameters(name = "blockedit", usage = "/<command> [list | purge | all | <player>]", aliases = "bedit", description = "Prevent players from modifying blocks")
|
||||
public class BlockEditCMD extends PlexCommand
|
||||
@ -99,20 +94,4 @@ public class BlockEditCMD extends PlexCommand
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (silentCheckPermission(sender, this.getPermission()))
|
||||
{
|
||||
List<String> options = new ArrayList<>();
|
||||
if (args.length == 1)
|
||||
{
|
||||
options.addAll(Arrays.asList("list", "purge", "all"));
|
||||
options.addAll(PlexUtils.getPlayerNameList());
|
||||
return options;
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,6 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(permission = "plex.commandspy", source = RequiredCommandSource.IN_GAME)
|
||||
@CommandParameters(name = "commandspy", aliases = "cmdspy", description = "Spy on other player's commands")
|
||||
public class CommandSpyCMD extends PlexCommand
|
||||
@ -33,10 +30,4 @@ public class CommandSpyCMD extends PlexCommand
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,6 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(permission = "plex.consolesay", source = RequiredCommandSource.CONSOLE)
|
||||
@CommandParameters(name = "consolesay", usage = "/<command> <message>", description = "Displays a message to everyone", aliases = "csay")
|
||||
public class ConsoleSayCMD extends PlexCommand
|
||||
@ -30,10 +27,4 @@ public class ConsoleSayCMD extends PlexCommand
|
||||
PlexUtils.broadcast(PlexUtils.messageComponent("consoleSayMessage", sender.getName(), PlexUtils.mmStripColor(StringUtils.join(args, " "))));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
@ -56,7 +56,7 @@ public class CreativeCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (silentCheckPermission(sender, "plex.gamemode.creative.others"))
|
||||
{
|
||||
|
@ -21,6 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@CommandParameters(name = "pdebug", description = "Plex's debug command", usage = "/<command> <aliases <command> | redis-reset <player> | gamerules>")
|
||||
@CommandPermissions(permission = "plex.debug")
|
||||
@ -90,8 +91,8 @@ public class DebugCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
@ -106,24 +106,20 @@ public class EntityWipeCMD extends PlexCommand
|
||||
return null;
|
||||
}
|
||||
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (silentCheckPermission(sender, this.getPermission()))
|
||||
List<String> entities = new ArrayList<>();
|
||||
for (World world : Bukkit.getWorlds())
|
||||
{
|
||||
List<String> entities = new ArrayList<>();
|
||||
for (World world : Bukkit.getWorlds())
|
||||
for (Entity entity : world.getEntities())
|
||||
{
|
||||
for (Entity entity : world.getEntities())
|
||||
if (entity.getType() != EntityType.PLAYER)
|
||||
{
|
||||
if (entity.getType() != EntityType.PLAYER)
|
||||
{
|
||||
entities.add(entity.getType().name());
|
||||
}
|
||||
entities.add(entity.getType().name());
|
||||
}
|
||||
}
|
||||
return entities.stream().toList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
return entities.stream().toList();
|
||||
}
|
||||
|
||||
private Integer parseInt(CommandSender sender, String string)
|
||||
|
@ -4,6 +4,7 @@ import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -12,9 +13,6 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(permission = "plex.flatlands", source = RequiredCommandSource.IN_GAME)
|
||||
@CommandParameters(name = "flatlands", description = "Teleport to the flatlands")
|
||||
public class FlatlandsCMD extends PlexCommand
|
||||
@ -31,10 +29,4 @@ public class FlatlandsCMD extends PlexCommand
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -53,8 +54,8 @@ public class FreezeCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 && silentCheckPermission(sender, "plex.freeze") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
@ -88,7 +88,7 @@ public class GamemodeCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
@ -96,10 +96,7 @@ public class GamemodeCMD extends PlexCommand
|
||||
}
|
||||
if (args.length == 2)
|
||||
{
|
||||
if (silentCheckPermission(sender, "plex.gamemode.others"))
|
||||
{
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
@ -10,6 +9,7 @@ import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
|
||||
import dev.plex.util.BungeeUtil;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
@ -23,7 +23,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@CommandParameters(name = "kick", description = "Kicks a player", usage = "/<command> <player>")
|
||||
@CommandPermissions(permission = "plex.kick", source = RequiredCommandSource.ANY)
|
||||
@ -68,10 +67,4 @@ public class KickCMD extends PlexCommand
|
||||
BungeeUtil.kickPlayer(player, Punishment.generateKickMessage(punishment));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
@ -65,9 +65,9 @@ public class ListCMD extends PlexCommand
|
||||
return list;
|
||||
}
|
||||
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (args.length == 1 && silentCheckPermission(sender, this.getPermission()))
|
||||
if (args.length == 1)
|
||||
{
|
||||
return Collections.singletonList("-d");
|
||||
}
|
||||
|
@ -11,9 +11,6 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandParameters(name = "localspawn", description = "Teleport to the spawnpoint of the world you are in")
|
||||
@CommandPermissions(permission = "plex.localspawn", source = RequiredCommandSource.IN_GAME)
|
||||
public class LocalSpawnCMD extends PlexCommand
|
||||
@ -25,10 +22,4 @@ public class LocalSpawnCMD extends PlexCommand
|
||||
playerSender.teleportAsync(playerSender.getWorld().getSpawnLocation());
|
||||
return messageComponent("teleportedToWorldSpawn");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -38,8 +39,8 @@ public class LockupCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 && silentCheckPermission(sender, "plex.lockup") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
@ -13,9 +13,6 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(permission = "plex.masterbuilderworld", source = RequiredCommandSource.IN_GAME)
|
||||
@CommandParameters(name = "masterbuilderworld", aliases = "mbw", description = "Teleport to the Master Builder world")
|
||||
public class MasterbuilderworldCMD extends PlexCommand
|
||||
@ -33,10 +30,4 @@ public class MasterbuilderworldCMD extends PlexCommand
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
@ -4,119 +4,50 @@ 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.util.PlexLog;
|
||||
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.text.WordUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Mob;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.HashMap;
|
||||
|
||||
@CommandPermissions(permission = "plex.mobpurge", source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(name = "mobpurge", description = "Purge all mobs.", usage = "/<command> [mob]", aliases = "mp")
|
||||
@CommandParameters(name = "mobpurge", description = "Purge all mobs.", usage = "/<command>", aliases = "mp")
|
||||
public class MobPurgeCMD extends PlexCommand
|
||||
{
|
||||
private final List<EntityType> MOB_TYPES = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, @NotNull String[] args)
|
||||
{
|
||||
EntityType type = null;
|
||||
String mobName = null;
|
||||
if (args.length > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
type = EntityType.valueOf(args[0].toUpperCase());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PlexLog.debug("A genius tried and failed removing the following invalid mob: " + args[0].toUpperCase());
|
||||
send(sender, messageComponent("notAValidMob"));
|
||||
return null;
|
||||
}
|
||||
if (!MOB_TYPES.contains(type))
|
||||
{
|
||||
PlexLog.debug(Arrays.deepToString(MOB_TYPES.toArray()));
|
||||
PlexLog.debug("A genius tried to remove a mob that doesn't exist: " + args[0].toUpperCase());
|
||||
sender.sendMessage(messageComponent("notAValidMobButValidEntity"));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (type != null)
|
||||
{
|
||||
mobName = WordUtils.capitalizeFully(type.name().replace("_", " "));
|
||||
PlexLog.debug("The args aren't null so the mob is: " + mobName);
|
||||
}
|
||||
int count = purgeMobs(type);
|
||||
if (type != null)
|
||||
{
|
||||
PlexUtils.broadcast(messageComponent("removedEntitiesOfTypes", sender.getName(), count, mobName));
|
||||
PlexLog.debug("All " + count + " of " + mobName + " were removed");
|
||||
}
|
||||
else
|
||||
{
|
||||
PlexUtils.broadcast(messageComponent("removedMobs", sender.getName(), count));
|
||||
PlexLog.debug("All " + count + " valid mobs were removed");
|
||||
}
|
||||
sender.sendMessage(messageComponent("amountOfMobsRemoved", count, (type != null ? mobName : "mob") + multipleS(count)));
|
||||
return null;
|
||||
}
|
||||
HashMap<String, Integer> entityCounts = new HashMap<>();
|
||||
|
||||
private String multipleS(int count)
|
||||
{
|
||||
return (count == 1 ? "" : "s");
|
||||
}
|
||||
|
||||
private int purgeMobs(EntityType type)
|
||||
{
|
||||
int removed = 0;
|
||||
for (World world : Bukkit.getWorlds())
|
||||
{
|
||||
for (Entity entity : world.getLivingEntities())
|
||||
for (Entity entity : world.getEntities())
|
||||
{
|
||||
if (entity instanceof LivingEntity && !(entity instanceof Player))
|
||||
if (entity instanceof Mob)
|
||||
{
|
||||
if (type != null && !entity.getType().equals(type))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String type = entity.getType().name();
|
||||
entity.remove();
|
||||
removed++;
|
||||
|
||||
entityCounts.put(type, entityCounts.getOrDefault(type, 0) + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
private List<String> getAllMobs()
|
||||
{
|
||||
List<String> mobs = new ArrayList<>();
|
||||
Arrays.stream(EntityType.values()).filter(EntityType::isAlive).filter(EntityType::isSpawnable).forEach(MOB_TYPES::add);
|
||||
for (EntityType entityType : MOB_TYPES)
|
||||
{
|
||||
mobs.add(entityType.name());
|
||||
}
|
||||
return mobs;
|
||||
}
|
||||
int entityCount = entityCounts.values().stream().mapToInt(a -> a).sum();
|
||||
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (args.length == 1 && silentCheckPermission(sender, this.getPermission()))
|
||||
{
|
||||
return getAllMobs();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
PlexUtils.broadcast(messageComponent("removedMobs", sender.getName(), entityCount));
|
||||
|
||||
/*entityCounts.forEach((entityName, numRemoved) -> {
|
||||
sender.sendMessage(messageComponent("removedEntitiesOfType", sender.getName(), numRemoved, entityName));
|
||||
});*/
|
||||
return null;
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -38,7 +39,7 @@ public class MuteCMD extends PlexCommand
|
||||
return messageComponent("playerMuted");
|
||||
}
|
||||
|
||||
if (silentCheckPermission(player, "plex.mute"))
|
||||
if (silentCheckPermission(player,"plex.mute"))
|
||||
{
|
||||
send(sender, messageComponent("higherRankThanYou"));
|
||||
return null;
|
||||
@ -59,8 +60,8 @@ public class MuteCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 && silentCheckPermission(sender,"plex.mute") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
@ -6,6 +6,7 @@ import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.extra.Note;
|
||||
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -136,19 +137,15 @@ public class NotesCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (silentCheckPermission(sender, this.getPermission()))
|
||||
if (args.length == 1)
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
if (args.length == 2)
|
||||
{
|
||||
return Arrays.asList("list", "add", "remove", "clear");
|
||||
}
|
||||
return Collections.emptyList();
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
if (args.length == 2)
|
||||
{
|
||||
return Arrays.asList("list", "add", "remove", "clear");
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ public class PlexCMD extends PlexCommand
|
||||
if (args.length == 0)
|
||||
{
|
||||
send(sender, mmString("<light_purple>Plex - A new freedom plugin."));
|
||||
send(sender, mmString("<light_purple>Plugin version: <gold>" + plugin.getDescription().getVersion() + " #" + BuildInfo.getNumber() + " <light_purple>Git: <gold>" + BuildInfo.getCommit()));
|
||||
send(sender, mmString("<light_purple>Plugin version: <gold>" + plugin.getDescription().getVersion() + " #" + BuildInfo.getNumber() + " <light_purple>Git: <gold>" + BuildInfo.getHead()));
|
||||
send(sender, mmString("<light_purple>Authors: <gold>Telesphoreo, Taahh"));
|
||||
send(sender, mmString("<light_purple>Built by: <gold>" + BuildInfo.getAuthor() + " <light_purple>on <gold>" + BuildInfo.getDate()));
|
||||
send(sender, mmString("<light_purple>Run <gold>/plex modules <light_purple>to see a list of modules."));
|
||||
@ -126,7 +126,7 @@ public class PlexCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
|
@ -7,6 +7,7 @@ import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.exception.PlayerNotFoundException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
|
||||
import dev.plex.menu.impl.PunishedPlayerMenu;
|
||||
import dev.plex.menu.impl.PunishmentMenu;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
@ -49,8 +50,8 @@ public class PunishmentsCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,6 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(permission = "plex.rawsay", source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(name = "rawsay", usage = "/<command> <message>", description = "Displays a raw message to everyone")
|
||||
public class RawSayCMD extends PlexCommand
|
||||
@ -31,10 +28,4 @@ public class RawSayCMD extends PlexCommand
|
||||
PlexUtils.broadcast(StringUtils.join(args, " "));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
@ -1,21 +1,17 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
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.util.PlexUtils;
|
||||
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(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
|
||||
@ -55,17 +51,4 @@ public class RemoveLoginMessageCMD extends PlexCommand
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
if (silentCheckPermission(sender, "plex.removeloginmessage.others"))
|
||||
{
|
||||
return List.of("-o");
|
||||
}
|
||||
}
|
||||
return args.length == 2 && silentCheckPermission(sender, "plex.removeloginmessage.others") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ 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.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@ -12,9 +13,6 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(permission = "plex.say", source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(name = "say", usage = "/<command> <message>", description = "Displays a message to everyone")
|
||||
public class SayCMD extends PlexCommand
|
||||
@ -30,10 +28,4 @@ public class SayCMD extends PlexCommand
|
||||
PlexUtils.broadcast(PlexUtils.messageComponent("sayMessage", sender.getName(), PlexUtils.mmStripColor(StringUtils.join(args, " "))));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
@ -11,15 +10,12 @@ import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(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
|
||||
@ -57,18 +53,20 @@ public class SetLoginMessageCMD extends PlexCommand
|
||||
validateMessage(message);
|
||||
plexPlayer.setLoginMessage(message);
|
||||
return messageComponent("setOtherPlayersLoginMessage", plexPlayer.getName(),
|
||||
MiniMessage.miniMessage().serialize(PlexUtils.stringToComponent(message.replace("%player%", plexPlayer.getName()))));
|
||||
message.replace("%player%", plexPlayer.getName()));
|
||||
}
|
||||
if (isConsole(sender))
|
||||
{
|
||||
return messageComponent("noPermissionConsole");
|
||||
}
|
||||
PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayer(playerSender.getUniqueId());
|
||||
String message = StringUtils.join(args, " ", 0, args.length)
|
||||
.replace(plexPlayer.getName(), "%player%");
|
||||
String message = StringUtils.join(args, " ", 0, args.length);
|
||||
message = message.replace(plexPlayer.getName(), "%player%");
|
||||
message = PlexUtils.legacyToMiniString(message);
|
||||
validateMessage(message);
|
||||
plexPlayer.setLoginMessage(message);
|
||||
return messageComponent("setOwnLoginMessage", PlexUtils.stringToComponent(message.replace("%player%", plexPlayer.getName())));
|
||||
return messageComponent("setOwnLoginMessage",
|
||||
message.replace("%player%", plexPlayer.getName()));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -81,17 +79,4 @@ public class SetLoginMessageCMD extends PlexCommand
|
||||
throw new CommandFailException(messageString("nameRequired"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
if (silentCheckPermission(sender, "plex.setloginmessage"))
|
||||
{
|
||||
return List.of("-o");
|
||||
}
|
||||
}
|
||||
return args.length == 2 && args[0].equalsIgnoreCase("-o") && silentCheckPermission(sender, "plex.setloginmessage") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -135,9 +136,9 @@ public class SmiteCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (silentCheckPermission(sender, this.getPermission()) && args.length == 1)
|
||||
if (silentCheckPermission(sender,"plex.smite") && args.length == 1)
|
||||
{
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class SpectatorCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (silentCheckPermission(sender,"plex.gamemode.spectator.others"))
|
||||
{
|
||||
|
@ -57,7 +57,7 @@ public class SurvivalCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (silentCheckPermission(sender,"plex.gamemode.survival.others"))
|
||||
{
|
||||
|
@ -6,6 +6,7 @@ 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.util.PlexUtils;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -18,10 +19,6 @@ 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;
|
||||
|
||||
@CommandPermissions(permission = "plex.tag", source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(name = "tag", aliases = "prefix", description = "Set or clear your prefix", usage = "/<command> <set <prefix> | clear <player>>")
|
||||
public class TagCMD extends PlexCommand
|
||||
@ -50,15 +47,16 @@ public class TagCMD extends PlexCommand
|
||||
{
|
||||
return usage("/tag set <prefix>");
|
||||
}
|
||||
String prefix = PlexUtils.legacyToMiniString(StringUtils.join(args, " ", 1, args.length));
|
||||
|
||||
Component convertedComponent = PlexUtils.stringToComponent(StringUtils.join(args, " ", 1, args.length));
|
||||
Component convertedComponent = SafeMiniMessage.mmDeserializeWithoutEvents(prefix);
|
||||
|
||||
if (PlainTextComponentSerializer.plainText().serialize(convertedComponent).length() > plugin.config.getInt("chat.max-tag-length", 16))
|
||||
{
|
||||
return messageComponent("maximumPrefixLength", plugin.config.getInt("chat.max-tag-length", 16));
|
||||
}
|
||||
|
||||
player.setPrefix(MiniMessage.miniMessage().serialize(convertedComponent));
|
||||
player.setPrefix(prefix);
|
||||
DataUtils.update(player);
|
||||
return messageComponent("prefixSetTo", MiniMessage.miniMessage().serialize(convertedComponent));
|
||||
}
|
||||
@ -82,7 +80,7 @@ public class TagCMD extends PlexCommand
|
||||
DataUtils.update(player);
|
||||
return messageComponent("prefixCleared");
|
||||
}
|
||||
checkPermission(sender, "plex.tag.clear.others");
|
||||
checkPermission(sender,"plex.tag.clear.others");
|
||||
Player target = getNonNullPlayer(args[1]);
|
||||
PlexPlayer plexTarget = DataUtils.getPlayer(target.getUniqueId());
|
||||
plexTarget.setPrefix(null);
|
||||
@ -91,26 +89,6 @@ public class TagCMD extends PlexCommand
|
||||
}
|
||||
return usage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
return Arrays.asList("set", "clear");
|
||||
}
|
||||
if (args.length == 2)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase("clear"))
|
||||
{
|
||||
if (silentCheckPermission(sender, "plex.tag.clear.others"))
|
||||
{
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -10,8 +10,8 @@ import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
|
||||
import dev.plex.util.BungeeUtil;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -22,7 +22,6 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandParameters(name = "tempban", usage = "/<command> <player> <time> [reason]", description = "Temporarily ban a player")
|
||||
@ -53,13 +52,10 @@ public class TempbanCMD extends PlexCommand
|
||||
}
|
||||
Punishment punishment = new Punishment(target.getUuid(), getUUID(sender));
|
||||
punishment.setType(PunishmentType.TEMPBAN);
|
||||
boolean rollBack = true;
|
||||
if (args.length > 2)
|
||||
{
|
||||
reason = StringUtils.join(args, " ", 2, args.length);
|
||||
String newReason = StringUtils.normalizeSpace(reason.replace("-nrb", ""));
|
||||
punishment.setReason(newReason.trim().isEmpty() ? "No reason provided." : newReason);
|
||||
rollBack = !reason.startsWith("-nrb") && !reason.endsWith("-nrb");
|
||||
punishment.setReason(reason);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -79,46 +75,12 @@ public class TempbanCMD extends PlexCommand
|
||||
{
|
||||
BungeeUtil.kickPlayer(player, Punishment.generateBanMessage(punishment));
|
||||
}
|
||||
if (rollBack)
|
||||
{
|
||||
/*if (plugin.getPrismHook().hasPrism()) {
|
||||
PrismParameters parameters = plugin.getPrismHook().prismApi().createParameters();
|
||||
parameters.addActionType("block-place");
|
||||
parameters.addActionType("block-break");
|
||||
parameters.addActionType("block-burn");
|
||||
parameters.addActionType("entity-spawn");
|
||||
parameters.addActionType("entity-kill");
|
||||
parameters.addActionType("entity-explode");
|
||||
parameters.addPlayerName(plexPlayer.getName());
|
||||
parameters.setBeforeTime(Instant.now().toEpochMilli());
|
||||
parameters.setProcessType(PrismProcessType.ROLLBACK);
|
||||
final Future<Result> result = plugin.getPrismHook().prismApi().performLookup(parameters, sender);
|
||||
Bukkit.getAsyncScheduler().runNow(plugin, scheduledTask -> {
|
||||
try
|
||||
{
|
||||
final Result done = result.get();
|
||||
} catch (InterruptedException | ExecutionException e)
|
||||
{
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
else */
|
||||
if (plugin.getCoreProtectHook().hasCoreProtect())
|
||||
{
|
||||
PlexLog.debug("Testing coreprotect");
|
||||
Bukkit.getAsyncScheduler().runNow(plugin, scheduledTask ->
|
||||
{
|
||||
plugin.getCoreProtectHook().coreProtectAPI().performRollback(86400, Collections.singletonList(target.getName()), null, null, null, null, 0, null);
|
||||
});
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 && silentCheckPermission(sender,"plex.tempban") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.menu.impl.ToggleMenu;
|
||||
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
@ -63,9 +64,9 @@ public class ToggleCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
|
||||
private String status(String toggle)
|
||||
|
@ -9,6 +9,7 @@ import dev.plex.command.exception.PlayerNotBannedException;
|
||||
import dev.plex.command.exception.PlayerNotFoundException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -55,8 +56,8 @@ public class UnbanCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 && silentCheckPermission(sender,"plex.unban") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.exception.CommandFailException;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -38,8 +39,8 @@ public class UnfreezeCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 && silentCheckPermission(sender,"plex.unfreeze") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.exception.CommandFailException;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -38,8 +39,8 @@ public class UnmuteCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 && silentCheckPermission(sender,"plex.unfreeze") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
@ -45,8 +45,8 @@ public class WhoHasCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? Arrays.stream(Material.values()).map(Enum::name).toList() : ImmutableList.of();
|
||||
return args.length == 1 && silentCheckPermission(sender, "plex.whohas") ? Arrays.stream(Material.values()).map(Enum::name).toList() : ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
@ -37,18 +38,19 @@ public class WorldCMD extends PlexCommand
|
||||
boolean playerWorld = args[0].matches("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}");
|
||||
if (playerWorld && Plex.get().getModuleManager().getModules().stream().anyMatch(plexModule -> plexModule.getPlexModuleFile().getName().equalsIgnoreCase("Module-TFMExtras")))
|
||||
{
|
||||
checkPermission(playerSender, "plex.world.playerworlds");
|
||||
checkPermission(playerSender,"plex.world.playerworlds");
|
||||
}
|
||||
playerSender.teleportAsync(world.getSpawnLocation());
|
||||
return messageComponent("playerWorldTeleport", world.getName());
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
final List<String> completions = Lists.newArrayList();
|
||||
final Player player = (Player) sender;
|
||||
if (args.length == 1 && silentCheckPermission(sender, this.getPermission()))
|
||||
if (args.length == 1)
|
||||
{
|
||||
@NotNull List<World> worlds = Bukkit.getWorlds();
|
||||
for (World world : worlds)
|
||||
@ -58,7 +60,7 @@ public class WorldCMD extends PlexCommand
|
||||
try
|
||||
{
|
||||
final UUID uuid = UUID.fromString(worldName);
|
||||
if (uuid.equals(player.getUniqueId()) || silentCheckPermission(player, "plex.world.playerworlds"))
|
||||
if (uuid.equals(player.getUniqueId()) || silentCheckPermission(player,"plex.world.playerworlds"))
|
||||
{
|
||||
completions.add(worldName);
|
||||
}
|
||||
|
@ -1,63 +0,0 @@
|
||||
package dev.plex.hook;
|
||||
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
import net.coreprotect.CoreProtect;
|
||||
import net.coreprotect.CoreProtectAPI;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class CoreProtectHook
|
||||
{
|
||||
private CoreProtectAPI coreProtectAPI;
|
||||
private boolean hasApi;
|
||||
|
||||
public CoreProtectHook(Plex plex)
|
||||
{
|
||||
Plugin plugin = plex.getServer().getPluginManager().getPlugin("CoreProtect");
|
||||
|
||||
// Check that CoreProtect is loaded
|
||||
if (!(plugin instanceof CoreProtect))
|
||||
{
|
||||
PlexLog.debug("Plugin was not CoreProtect.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that the API is enabled
|
||||
CoreProtectAPI coreProtectAPI = ((CoreProtect) plugin).getAPI();
|
||||
this.hasApi = coreProtectAPI.isEnabled();
|
||||
if (!hasApi)
|
||||
{
|
||||
PlexLog.debug("CoreProtect API was disabled.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that a compatible version of the API is loaded
|
||||
if (coreProtectAPI.APIVersion() < 9)
|
||||
{
|
||||
PlexLog.debug("CoreProtect API version is: {0}", coreProtectAPI.APIVersion());
|
||||
return;
|
||||
}
|
||||
this.coreProtectAPI = coreProtectAPI;
|
||||
this.coreProtectAPI.testAPI();
|
||||
}
|
||||
|
||||
public boolean hasCoreProtect() {
|
||||
return hasApi;
|
||||
}
|
||||
|
||||
public CoreProtectAPI coreProtectAPI()
|
||||
{
|
||||
return coreProtectAPI;
|
||||
}
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
package dev.plex.hook;
|
||||
|
||||
import dev.plex.Plex;
|
||||
import network.darkhelmet.prism.api.PrismApi;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class PrismHook
|
||||
{
|
||||
private PrismApi prismApi;
|
||||
|
||||
public PrismHook(Plex plex)
|
||||
{
|
||||
Plugin plugin = plex.getServer().getPluginManager().getPlugin("Prism");
|
||||
|
||||
// Check that Prism is loaded
|
||||
if (!plugin.isEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Check that the API is enabled
|
||||
this.prismApi = (PrismApi) plugin;
|
||||
}
|
||||
|
||||
public boolean hasPrism() {
|
||||
return prismApi != null;
|
||||
}
|
||||
|
||||
public PrismApi prismApi()
|
||||
{
|
||||
return prismApi;
|
||||
}
|
||||
}
|
||||
|
@ -82,8 +82,8 @@ public class VaultHook
|
||||
if (vaultPrefix == null || vaultPrefix.isEmpty()) {
|
||||
return Component.empty();
|
||||
}
|
||||
PlexLog.debug("prefix: {0}", SafeMiniMessage.mmSerializeWithoutEvents(PlexUtils.stringToComponent(vaultPrefix)).replace("<", "\\<"));
|
||||
return PlexUtils.stringToComponent(vaultPrefix);
|
||||
PlexLog.debug("prefix: {0}", PlexUtils.legacyToMiniString(vaultPrefix).replace("<", "\\<"));
|
||||
return SafeMiniMessage.mmDeserializeWithoutEvents(PlexUtils.legacyToMiniString(vaultPrefix));
|
||||
}
|
||||
|
||||
public static Permission getPermission()
|
||||
|
@ -7,8 +7,6 @@ import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentManager;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.util.PlexLog;
|
||||
import it.unimi.dsi.fastutil.Pair;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
@ -45,26 +43,11 @@ public class BanListener extends PlexListener
|
||||
|
||||
if (plugin.getPunishmentManager().isBanned(event.getUniqueId()))
|
||||
{
|
||||
if (Plex.get().getPermissions() != null && Plex.get().getPermissions().playerHas(null, Bukkit.getOfflinePlayer(event.getUniqueId()), "plex.ban.bypass"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Plex.get().getPermissions() != null && Plex.get().getPermissions().playerHas(null, Bukkit.getOfflinePlayer(event.getUniqueId()), "plex.ban.bypass")) return;
|
||||
PlexPlayer player = DataUtils.getPlayer(event.getUniqueId());
|
||||
player.getPunishments().stream().filter(punishment -> (punishment.getType() == PunishmentType.BAN || punishment.getType() == PunishmentType.TEMPBAN) && punishment.isActive()).findFirst().ifPresent(punishment ->
|
||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED,
|
||||
Punishment.generateBanMessage(punishment)));
|
||||
return;
|
||||
}
|
||||
Punishment ipBannedPunishment = plugin.getPunishmentManager().getBanByIP(event.getAddress().getHostAddress());
|
||||
if (ipBannedPunishment != null)
|
||||
{
|
||||
// Don't check if the other account that's banned has bypass abilities, check if current has only
|
||||
if (Plex.get().getPermissions() != null && Plex.get().getPermissions().playerHas(null, Bukkit.getOfflinePlayer(event.getUniqueId()), "plex.ban.bypass"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED,
|
||||
Punishment.generateBanMessage(ipBannedPunishment));
|
||||
}
|
||||
}
|
||||
}
|
@ -12,6 +12,7 @@ import io.papermc.paper.chat.ChatRenderer;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.TextReplacementConfig;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
@ -46,7 +47,7 @@ public class ChatListener extends PlexListener
|
||||
{
|
||||
String prefix = PlexUtils.mmSerialize(VaultHook.getPrefix(event.getPlayer())); // Don't use PlexPlayer#getPrefix because that returns their custom set prefix and not their group's
|
||||
MessageUtil.sendStaffChat(event.getPlayer(), event.message(), PlexUtils.adminChat(event.getPlayer().getName(), prefix, SafeMiniMessage.mmSerialize(event.message())).toArray(UUID[]::new));
|
||||
plugin.getServer().getConsoleSender().sendMessage(PlexUtils.messageComponent("adminChatFormat", event.getPlayer().getName(), prefix, SafeMiniMessage.mmSerialize(event.message().replaceText(URL_REPLACEMENT_CONFIG))));
|
||||
plugin.getServer().getConsoleSender().sendMessage(PlexUtils.messageComponent("adminChatFormat", event.getPlayer().getName(), prefix, PlexUtils.legacyToMiniString(SafeMiniMessage.mmSerializeWithoutEvents(event.message()))).replaceText(URL_REPLACEMENT_CONFIG));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -104,7 +105,7 @@ public class ChatListener extends PlexListener
|
||||
|
||||
private static void defaultChatProcessing(AsyncChatEvent event, PlexPlayer plexPlayer)
|
||||
{
|
||||
String text = PlexUtils.getTextFromComponent(event.message());
|
||||
event.message(PlexUtils.stringToComponent(text));
|
||||
String text = PlexUtils.legacyToMiniString(PlexUtils.getTextFromComponent(event.message()));
|
||||
event.message(SafeMiniMessage.mmDeserializeWithoutEvents(text));
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public class PlayerListener<T> extends PlexListener
|
||||
String loginMessage = PlayerMeta.getLoginMessage(plexPlayer);
|
||||
if (!loginMessage.isEmpty())
|
||||
{
|
||||
PlexUtils.broadcast(PlexUtils.stringToComponent(loginMessage));
|
||||
PlexUtils.broadcast(loginMessage);
|
||||
}
|
||||
|
||||
plexPlayer.loadNotes();
|
||||
|
@ -0,0 +1,22 @@
|
||||
package dev.plex.listener.impl;
|
||||
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
|
||||
public class SignListener extends PlexListener
|
||||
{
|
||||
private static final LegacyComponentSerializer LEGACY_COMPONENT_SERIALIZER = LegacyComponentSerializer.legacyAmpersand();
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onSignEdit(SignChangeEvent event)
|
||||
{
|
||||
for (int i = 0; i < event.lines().size(); i++)
|
||||
{
|
||||
event.line(i, LEGACY_COMPONENT_SERIALIZER.deserialize(PlexUtils.getTextFromComponent(event.line(i))));
|
||||
}
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ import org.bukkit.Bukkit;
|
||||
|
||||
public class PlayerMeta
|
||||
{
|
||||
|
||||
public static Component getPrefix(PlexPlayer plexPlayer)
|
||||
{
|
||||
if (plexPlayer.getPrefix() != null && !plexPlayer.getPrefix().isEmpty())
|
||||
|
@ -3,14 +3,21 @@ package dev.plex.punishment;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.PlexBase;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
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 org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@ -21,17 +28,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import dev.plex.util.adapter.ZonedDateTimeAdapter;
|
||||
import it.unimi.dsi.fastutil.Pair;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PunishmentManager implements PlexBase
|
||||
{
|
||||
@ -138,6 +135,7 @@ public class PunishmentManager implements PlexBase
|
||||
|
||||
public boolean isBanned(UUID uuid)
|
||||
{
|
||||
// TODO: If a person is using MongoDB, this will error out because it is checking for bans on a player that doesn't exist yet
|
||||
if (!DataUtils.hasPlayedBefore(uuid))
|
||||
{
|
||||
return false;
|
||||
@ -145,12 +143,6 @@ public class PunishmentManager implements PlexBase
|
||||
return DataUtils.getPlayer(uuid).getPunishments().stream().anyMatch(punishment -> (punishment.getType() == PunishmentType.BAN || punishment.getType() == PunishmentType.TEMPBAN) && punishment.isActive());
|
||||
}
|
||||
|
||||
public Punishment getBanByIP(String ip)
|
||||
{
|
||||
final Gson gson = new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeAdapter()).setPrettyPrinting().create();
|
||||
return plugin.getSqlPunishment().getPunishments(ip).stream().filter(punishment -> punishment.getType() == PunishmentType.TEMPBAN || punishment.getType() == PunishmentType.BAN).filter(Punishment::isActive).filter(punishment -> punishment.getIp().equals(ip)).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public boolean isBanned(PlexPlayer player)
|
||||
{
|
||||
return isBanned(player.getUuid());
|
||||
|
@ -21,7 +21,6 @@ import java.util.concurrent.CompletableFuture;
|
||||
public class SQLPunishment
|
||||
{
|
||||
private static final String SELECT = "SELECT * FROM `punishments` WHERE punished=?";
|
||||
private static final String SELECT_BY_IP = "SELECT * FROM `punishments` WHERE ip=?";
|
||||
private static final String SELECT_BY = "SELECT * FROM `punishments` WHERE punisher=?";
|
||||
|
||||
private static final String INSERT = "INSERT INTO `punishments` (`punished`, `punisher`, `punishedUsername`, `ip`, `type`, `reason`, `customTime`, `active`, `endDate`) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
@ -85,33 +84,6 @@ public class SQLPunishment
|
||||
}
|
||||
return punishments;
|
||||
}
|
||||
public List<Punishment> getPunishments(String ip)
|
||||
{
|
||||
List<Punishment> punishments = Lists.newArrayList();
|
||||
try (Connection con = Plex.get().getSqlConnection().getCon())
|
||||
{
|
||||
PreparedStatement statement = con.prepareStatement(SELECT_BY_IP);
|
||||
statement.setString(1, ip);
|
||||
ResultSet set = statement.executeQuery();
|
||||
while (set.next())
|
||||
{
|
||||
Punishment punishment = new Punishment(UUID.fromString(set.getString("punished")), set.getString("punisher") == null ? null : UUID.fromString(set.getString("punisher")));
|
||||
punishment.setActive(set.getBoolean("active"));
|
||||
punishment.setType(PunishmentType.valueOf(set.getString("type")));
|
||||
punishment.setCustomTime(set.getBoolean("customTime"));
|
||||
punishment.setPunishedUsername(set.getString("punishedUsername"));
|
||||
punishment.setEndDate(ZonedDateTime.ofInstant(Instant.ofEpochMilli(set.getLong("endDate")), ZoneId.of(TimeUtils.TIMEZONE)));
|
||||
punishment.setReason(set.getString("reason"));
|
||||
punishment.setIp(set.getString("ip"));
|
||||
punishments.add(punishment);
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
return punishments;
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> insertPunishment(Punishment punishment)
|
||||
{
|
||||
|
@ -9,29 +9,29 @@ import java.util.Properties;
|
||||
public class BuildInfo
|
||||
{
|
||||
@Getter
|
||||
public static String author;
|
||||
public static String number;
|
||||
@Getter
|
||||
public static String commit;
|
||||
public static String author;
|
||||
@Getter
|
||||
public static String date;
|
||||
@Getter
|
||||
public static String number;
|
||||
public static String head;
|
||||
|
||||
public void load(Plex plugin)
|
||||
{
|
||||
try
|
||||
{
|
||||
Properties props;
|
||||
try (InputStream in = plugin.getResource("build-vars.properties"))
|
||||
try (InputStream in = plugin.getResource("build.properties"))
|
||||
{
|
||||
props = new Properties();
|
||||
props.load(in);
|
||||
}
|
||||
|
||||
author = props.getProperty("author", "unknown");
|
||||
commit = props.getProperty("gitCommit", "unknown");
|
||||
date = props.getProperty("date", "unknown");
|
||||
number = props.getProperty("buildNumber", "unknown");
|
||||
author = props.getProperty("buildAuthor", "unknown");
|
||||
date = props.getProperty("buildDate", "unknown");
|
||||
head = props.getProperty("buildHead", "unknown");
|
||||
}
|
||||
catch (Exception ignored)
|
||||
{
|
||||
|
@ -6,13 +6,10 @@ import dev.plex.Plex;
|
||||
import dev.plex.PlexBase;
|
||||
import dev.plex.listener.impl.ChatListener;
|
||||
import dev.plex.storage.StorageType;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
@ -31,7 +28,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class PlexUtils implements PlexBase
|
||||
@ -47,8 +43,6 @@ public class PlexUtils implements PlexBase
|
||||
"a52f1f08-a398-400a-bca4-2b74b81feae6" // Allink
|
||||
);
|
||||
|
||||
private static final Pattern LEGACY_FORMATTING_PATTERN = Pattern.compile(".*(?i)(([§&])((#[a-f0-9]{3,6})|([0-9a-fklmnor]))).*");
|
||||
|
||||
public static <T> T addToArrayList(List<T> list, T object)
|
||||
{
|
||||
list.add(object);
|
||||
@ -151,17 +145,6 @@ public class PlexUtils implements PlexBase
|
||||
return component;
|
||||
}
|
||||
|
||||
public static Component stringToComponent(String input)
|
||||
{
|
||||
input = cleanString(input);
|
||||
|
||||
return LEGACY_FORMATTING_PATTERN.matcher(input).find() ?
|
||||
LegacyComponentSerializer.legacyAmpersand().deserialize(input.replaceAll("([§&]+)(k+)", "") // Ugly hack, but it tries to prevent &k and any attempts to bypass it.
|
||||
).decoration(TextDecoration.OBFUSCATED, TextDecoration.State.FALSE) :
|
||||
SafeMiniMessage.mmDeserializeWithoutEvents(input);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String legacyToMiniString(String input)
|
||||
{
|
||||
return cleanString(input.replace("&a", "<green>")
|
||||
|
@ -96,7 +96,7 @@ public class UpdateChecker implements PlexBase
|
||||
// If it's -4, it hasn't checked for updates yet
|
||||
if (distance == -4)
|
||||
{
|
||||
distance = fetchDistanceFromGitHub(REPO, BRANCH, BuildInfo.getCommit());
|
||||
distance = fetchDistanceFromGitHub(REPO, BRANCH, BuildInfo.getHead());
|
||||
PlexLog.debug("Never checked for updates, checking now...");
|
||||
}
|
||||
else
|
||||
@ -104,7 +104,7 @@ public class UpdateChecker implements PlexBase
|
||||
// If the request isn't asked to be cached, fetch it
|
||||
if (!cached)
|
||||
{
|
||||
distance = fetchDistanceFromGitHub(REPO, BRANCH, BuildInfo.getCommit());
|
||||
distance = fetchDistanceFromGitHub(REPO, BRANCH, BuildInfo.getHead());
|
||||
PlexLog.debug("We have checked for updates before, but this request was not asked to be cached.");
|
||||
}
|
||||
else
|
||||
|
@ -1,7 +0,0 @@
|
||||
author={{ author | default("unknown") }}
|
||||
|
||||
buildNumber={{ buildNumber | default("unknown") }}
|
||||
|
||||
date={{ date }}
|
||||
|
||||
gitCommit={{ gitCommit | default("unknown") }}
|
@ -160,11 +160,6 @@ removedEntitiesOfType: "<gray>Removed {1} {2}"
|
||||
# 0 - Entity type that is invalid
|
||||
invalidEntityType: "<gray>Notice: Entity type {0} is invalid!"
|
||||
noRemovedEntities: "<gray>No entities were removed."
|
||||
# 0 - Number of mobs removed
|
||||
# 1 - Type of mob removed
|
||||
amountOfMobsRemoved: "<gray>{0} {1} removed."
|
||||
notAValidMob: "<red>That is not a valid mob."
|
||||
notAValidMobButValidEntity: "<red>That is a valid entity, but is not a valid mob."
|
||||
# 0 - The command sender
|
||||
# 1 - Number of mobs removed
|
||||
removedMobs: "<red>{0} - Removed {1} mobs"
|
||||
|
4
settings.gradle
Normal file
4
settings.gradle
Normal file
@ -0,0 +1,4 @@
|
||||
rootProject.name = "Plex"
|
||||
include 'server'
|
||||
include 'proxy'
|
||||
|
@ -1,2 +0,0 @@
|
||||
rootProject.name = "Plex"
|
||||
include("server", "proxy")
|
Reference in New Issue
Block a user