mirror of
https://github.com/plexusorg/Plex.git
synced 2025-07-04 16:56:40 +00:00
Compare commits
64 Commits
velocity-4
...
server
Author | SHA1 | Date | |
---|---|---|---|
5a1436afae | |||
e066d9b3a1 | |||
9e974ae737 | |||
23611e218b | |||
5f12a1532f | |||
fff35ad34c | |||
83ec997125 | |||
2ed88da151 | |||
c5b356e45a | |||
58fe304118 | |||
50d969975c | |||
52cc738d4d | |||
fd19d8417c | |||
efcb9b45df | |||
a5d77036a9 | |||
5c609b3d8f | |||
7383e0d9bb | |||
f1680174ae | |||
c0966a0f5e | |||
fa1a8a91ba | |||
129ef7b6bf | |||
d7ad94d270 | |||
a0471e63f6 | |||
e2b3488aa7 | |||
5b3a37835a | |||
344df2b225 | |||
6e5f0d7beb | |||
0c7b280aef | |||
647f17b5bd | |||
773f320cb6 | |||
8f55be369f | |||
5a7a2c1835 | |||
bc163aa51a | |||
5040c76dc6 | |||
7d94717de5 | |||
0add60322e | |||
068dd28fd4 | |||
357683a0f6 | |||
315e16488b | |||
85605774cf | |||
54015f668a | |||
532e82472b | |||
6ce4843829 | |||
7298c8669a | |||
6b7c076c41 | |||
7b56bd70e9 | |||
fbd36161d4 | |||
912dff0ec9 | |||
aab5083f78 | |||
adb0d070a4 | |||
e22f079062 | |||
8f713fd30c | |||
72467de5ce | |||
c9d954d1c0 | |||
b168029df1 | |||
f34df4f296 | |||
79206d9354 | |||
7bca348587 | |||
b35bf63ba4 | |||
8c5c058292 | |||
3d70100119 | |||
6a8228947b | |||
187226ff45 | |||
6d80d5f4e3 |
1
Jenkinsfile
vendored
1
Jenkinsfile
vendored
@ -14,6 +14,7 @@ pipeline {
|
||||
archiveArtifacts artifacts: "build/libs/*.jar", fingerprint: true
|
||||
javadoc javadocDir: "server/build/docs/javadoc", keepAll: false
|
||||
discordSend description: "**Build:** ${env.BUILD_NUMBER}\n**Status:** ${currentBuild.currentResult}", enableArtifactsList: true, footer: "Built with Jenkins", link: env.BUILD_URL, result: currentBuild.currentResult, scmWebUrl: "https://github.com/plexusorg/Plex", showChangeset: true, title: env.JOB_NAME, webhookURL: env.WEBHOOK_URL
|
||||
discordSend description: "**Build:** ${env.BUILD_NUMBER}\n**Status:** ${currentBuild.currentResult}", enableArtifactsList: true, footer: "Built with Jenkins", link: env.BUILD_URL, result: currentBuild.currentResult, scmWebUrl: "https://github.com/plexusorg/Plex", showChangeset: true, title: env.JOB_NAME, webhookURL: env.TF_WEBHOOK_URL
|
||||
cleanWs()
|
||||
}
|
||||
}
|
||||
|
72
build.gradle
72
build.gradle
@ -1,72 +0,0 @@
|
||||
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')
|
||||
}
|
91
build.gradle.kts
Normal file
91
build.gradle.kts
Normal file
@ -0,0 +1,91 @@
|
||||
plugins {
|
||||
id("java")
|
||||
id("maven-publish")
|
||||
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.8"
|
||||
id("net.kyori.blossom") version "2.1.0"
|
||||
id("io.github.goooler.shadow") version "8.1.7"
|
||||
}
|
||||
|
||||
group = "dev.plex"
|
||||
version = "1.4"
|
||||
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 = "io.github.goooler.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")
|
||||
includeGroup("com.github.LeonMangler")
|
||||
}
|
||||
}
|
||||
|
||||
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"))
|
||||
}
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
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.4-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
@ -1,7 +1,3 @@
|
||||
plugins {
|
||||
id("net.kyori.blossom") version "1.3.1"
|
||||
}
|
||||
|
||||
group = rootProject.group
|
||||
version = rootProject.version
|
||||
description = "Plex-Velocity"
|
||||
@ -24,8 +20,14 @@ tasks {
|
||||
}
|
||||
}
|
||||
|
||||
blossom {
|
||||
replaceToken("@version@", rootProject.version)
|
||||
sourceSets {
|
||||
main {
|
||||
blossom {
|
||||
javaSources {
|
||||
property("version", project.version.toString())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
@ -37,9 +39,9 @@ publishing {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("org.projectlombok:lombok:1.18.30")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.30")
|
||||
compileOnly("org.json:json:20231013")
|
||||
compileOnly("org.projectlombok:lombok:1.18.32")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.32")
|
||||
compileOnly("org.json:json:20240303")
|
||||
compileOnly("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT")
|
||||
annotationProcessor("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT")
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package dev.plex;
|
||||
|
||||
class BuildParameters {
|
||||
public static final String VERSION = "{{ version }}";
|
||||
}
|
@ -28,7 +28,7 @@ import java.util.logging.Logger;
|
||||
@Plugin(
|
||||
name = "Plex",
|
||||
id = "plex",
|
||||
version = "@version@",
|
||||
version = BuildParameters.VERSION,
|
||||
url = "https://plex.us.org",
|
||||
description = "Plex provides a new experience for freedom servers.",
|
||||
authors = {"Telesphoreo", "Taah"}
|
||||
|
@ -1,154 +0,0 @@
|
||||
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]
|
||||
}
|
||||
}
|
||||
}
|
168
server/build.gradle.kts
Normal file
168
server/build.gradle.kts
Normal file
@ -0,0 +1,168 @@
|
||||
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.32")
|
||||
library("org.json:json:20240303")
|
||||
library("commons-io:commons-io:2.16.1")
|
||||
library("redis.clients:jedis:5.1.3")
|
||||
library("org.mariadb.jdbc:mariadb-java-client:3.4.0")
|
||||
library("com.zaxxer:HikariCP:5.1.0")
|
||||
library("org.apache.maven.resolver:maven-resolver-transport-http:1.9.20")
|
||||
library("org.jetbrains:annotations:24.1.0")
|
||||
|
||||
compileOnly("dev.folia:folia-api:1.20.4-R0.1-SNAPSHOT")
|
||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1") {
|
||||
exclude("org.bukkit", "bukkit")
|
||||
}
|
||||
compileOnly("net.coreprotect:coreprotect:22.4")
|
||||
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")
|
||||
|
||||
implementation("com.github.LeonMangler:SuperVanish:6.2.18-3")
|
||||
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.32")
|
||||
}
|
||||
|
||||
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("PremiumVanish") {
|
||||
required = false
|
||||
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
||||
}
|
||||
register("SlimeWorldManager") {
|
||||
required = false
|
||||
load = PaperPluginDescription.RelativeLoadOrder.AFTER
|
||||
}
|
||||
register("SuperVanish") {
|
||||
required = false
|
||||
load = PaperPluginDescription.RelativeLoadOrder.BEFORE
|
||||
}
|
||||
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,11 +1,12 @@
|
||||
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;
|
||||
@ -16,22 +17,23 @@ 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.*;
|
||||
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.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
|
||||
@ -46,7 +48,6 @@ 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;
|
||||
@ -63,6 +64,9 @@ public class Plex extends JavaPlugin
|
||||
private Permission permissions;
|
||||
private Chat chat;
|
||||
|
||||
private CoreProtectHook coreProtectHook;
|
||||
private PrismHook prismHook;
|
||||
|
||||
public static Plex get()
|
||||
{
|
||||
return plugin;
|
||||
@ -105,7 +109,6 @@ public class Plex extends JavaPlugin
|
||||
commands.load(false);
|
||||
|
||||
sqlConnection = new SQLConnection();
|
||||
// mongoConnection = new MongoConnection();
|
||||
redisConnection = new RedisConnection();
|
||||
|
||||
playerCache = new PlayerCache();
|
||||
@ -124,12 +127,38 @@ public class Plex extends JavaPlugin
|
||||
|
||||
if (!getServer().getPluginManager().isPluginEnabled("Vault"))
|
||||
{
|
||||
throw new RuntimeException("Vault is required to run on the server if you use permissions alongside a permissions plugin, we recommend LuckPerms!");
|
||||
throw new RuntimeException("Vault is required to run on the server 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");
|
||||
}
|
||||
|
||||
if (PlexUtils.hasVanishPlugin())
|
||||
{
|
||||
PlexLog.log("Hooked into SuperVanish / PremiumVanish!");
|
||||
} else {
|
||||
PlexLog.debug("Not hooking into SuperVanish / PremiumVanish");
|
||||
}
|
||||
|
||||
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.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));
|
||||
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));
|
||||
}
|
||||
classpathBuilder.addLibrary(resolver);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
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;
|
||||
@ -14,14 +15,15 @@ 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;
|
||||
|
||||
/**
|
||||
@ -61,6 +63,7 @@ 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)
|
||||
{
|
||||
@ -74,7 +77,8 @@ 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());
|
||||
@ -166,6 +170,17 @@ 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
|
||||
*
|
||||
@ -283,47 +298,6 @@ 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,6 +1,5 @@
|
||||
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;
|
||||
@ -12,8 +11,6 @@ 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;
|
||||
@ -21,6 +18,8 @@ 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)
|
||||
@ -58,4 +57,10 @@ 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,6 +12,9 @@ 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
|
||||
@ -29,4 +32,10 @@ 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> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (silentCheckPermission(sender, "plex.gamemode.adventure.others"))
|
||||
{
|
||||
|
@ -1,7 +1,5 @@
|
||||
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;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
@ -11,7 +9,10 @@ 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.*;
|
||||
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;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -22,9 +23,10 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandParameters(name = "ban", usage = "/<command> <player> [reason]", aliases = "offlineban,gtfo", description = "Bans a player, offline or online")
|
||||
@CommandParameters(name = "ban", usage = "/<command> <player> [reason] [-rb]", aliases = "offlineban,gtfo", description = "Bans a player, offline or online")
|
||||
@CommandPermissions(permission = "plex.ban", source = RequiredCommandSource.ANY)
|
||||
|
||||
public class BanCMD extends PlexCommand
|
||||
@ -56,27 +58,27 @@ public class BanCMD extends PlexCommand
|
||||
String reason;
|
||||
Punishment punishment = new Punishment(plexPlayer.getUuid(), getUUID(sender));
|
||||
punishment.setType(PunishmentType.BAN);
|
||||
boolean rollBack = false;
|
||||
if (args.length > 1)
|
||||
{
|
||||
reason = StringUtils.join(args, " ", 1, args.length);
|
||||
punishment.setReason(reason);
|
||||
String newReason = StringUtils.normalizeSpace(reason.replace("-rb", ""));
|
||||
punishment.setReason(newReason.trim().isEmpty() ? messageString("noReasonProvided") : newReason);
|
||||
rollBack = reason.startsWith("-rb") || reason.endsWith("-rb");
|
||||
}
|
||||
else
|
||||
{
|
||||
punishment.setReason("No reason provided.");
|
||||
punishment.setReason(messageString("noReasonProvided"));
|
||||
}
|
||||
punishment.setPunishedUsername(plexPlayer.getName());
|
||||
ZonedDateTime date = ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE));
|
||||
punishment.setEndDate(date.plusDays(1));
|
||||
punishment.setCustomTime(false);
|
||||
punishment.setActive(true);
|
||||
if (player != null)
|
||||
{
|
||||
punishment.setIp(player.getAddress().getAddress().getHostAddress().trim());
|
||||
}
|
||||
punishment.setIp(player != null ? player.getAddress().getAddress().getHostAddress().trim() : plexPlayer.getIps().get(plexPlayer.getIps().size() - 1));
|
||||
plugin.getPunishmentManager().punish(plexPlayer, punishment);
|
||||
PlexUtils.broadcast(messageComponent("banningPlayer", sender.getName(), plexPlayer.getName()));
|
||||
Bukkit.getScheduler().runTask(Plex.get(), () ->
|
||||
Bukkit.getGlobalRegionScheduler().execute(plugin, () ->
|
||||
{
|
||||
if (player != null)
|
||||
{
|
||||
@ -84,14 +86,59 @@ public class BanCMD extends PlexCommand
|
||||
}
|
||||
});
|
||||
PlexLog.debug("(From /ban command) PunishedPlayer UUID: " + plexPlayer.getUuid());
|
||||
|
||||
if (rollBack)
|
||||
{
|
||||
/*if (plugin.getPrismHook() != null && 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() != null && plugin.getCoreProtectHook().hasCoreProtect())
|
||||
{
|
||||
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> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender, "plex.ban") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
if (args.length == 1 && silentCheckPermission(sender, this.getPermission()))
|
||||
{
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
if (args.length > 1 && silentCheckPermission(sender, this.getPermission()))
|
||||
{
|
||||
return Collections.singletonList("-rb");
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
61
server/src/main/java/dev/plex/command/impl/BanListCommand.java
Executable file
61
server/src/main/java/dev/plex/command/impl/BanListCommand.java
Executable file
@ -0,0 +1,61 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@CommandParameters(name = "banlist", description = "Manages the banlist", usage = "/<command> [purge]")
|
||||
@CommandPermissions(permission = "plex.banlist")
|
||||
public class BanListCommand extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player player, @NotNull String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
plugin.getPunishmentManager().getActiveBans().whenComplete((punishments, throwable) ->
|
||||
{
|
||||
send(sender, mmString("<gold>Active Bans (" + punishments.size() + "): <yellow>" + StringUtils.join(punishments.stream().map(Punishment::getPunishedUsername).collect(Collectors.toList()), ", ")));
|
||||
});
|
||||
return null;
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("purge") || args[0].equalsIgnoreCase("clear"))
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
return messageComponent("noPermissionInGame");
|
||||
}
|
||||
if (!sender.getName().equalsIgnoreCase("console"))
|
||||
{
|
||||
if (!checkPermission(sender, "plex.banlist.clear"))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
plugin.getPunishmentManager().getActiveBans().whenComplete((punishments, throwable) ->
|
||||
{
|
||||
punishments.forEach(plugin.getPunishmentManager()::unban);
|
||||
send(sender, mmString("<gold>Unbanned " + punishments.size() + " players."));
|
||||
});
|
||||
}
|
||||
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, "plex.banlist.clear") ? List.of("purge", "clear") : ImmutableList.of();
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
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.exception.PlayerNotFoundException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.meta.PlayerMeta;
|
||||
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.broadcastloginmessage", source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(name = "bcastloginmessage", usage = "/<command> <player>", description = "Broadcast your login message (for vanish support)", aliases = "bcastlm")
|
||||
public class BcastLoginMessageCMD extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
return usage();
|
||||
}
|
||||
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(args[0]);
|
||||
|
||||
if (plexPlayer == null)
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
|
||||
String loginMessage = PlayerMeta.getLoginMessage(plexPlayer);
|
||||
if (!loginMessage.isEmpty())
|
||||
{
|
||||
PlexUtils.broadcast(PlexUtils.stringToComponent(loginMessage));
|
||||
PlexUtils.broadcast(messageComponent("loginMessage", plexPlayer.getName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
return mmString("<red>This player does not have a login message.");
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
@ -12,6 +12,11 @@ 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
|
||||
@ -94,4 +99,20 @@ 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,6 +12,9 @@ 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
|
||||
@ -30,4 +33,10 @@ 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,6 +12,9 @@ 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
|
||||
@ -27,4 +30,10 @@ 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> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (silentCheckPermission(sender, "plex.gamemode.creative.others"))
|
||||
{
|
||||
|
@ -21,7 +21,6 @@ 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")
|
||||
@ -42,9 +41,9 @@ public class DebugCMD extends PlexCommand
|
||||
if (plugin.getRedisConnection().getJedis().exists(player.getUniqueId().toString()))
|
||||
{
|
||||
plugin.getRedisConnection().getJedis().del(player.getUniqueId().toString());
|
||||
return componentFromString("Successfully reset " + player.getName() + "'s Redis punishments!").color(NamedTextColor.YELLOW);
|
||||
return messageComponent("redisResetSuccessful", player.getName());
|
||||
}
|
||||
return componentFromString("Couldn't find player in Redis punishments.");
|
||||
return messageComponent("redisResetPlayerNotFound");
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("gamerules"))
|
||||
@ -63,7 +62,7 @@ public class DebugCMD extends PlexCommand
|
||||
PlexLog.log("Set specific gamerules for world: " + world.toLowerCase(Locale.ROOT));
|
||||
}
|
||||
}
|
||||
return mmString("<aqua>Re-applied game all the game rules!");
|
||||
return messageComponent("reappliedGamerules");
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("aliases"))
|
||||
{
|
||||
@ -73,9 +72,9 @@ public class DebugCMD extends PlexCommand
|
||||
Command command = plugin.getServer().getCommandMap().getCommand(commandName);
|
||||
if (command == null)
|
||||
{
|
||||
return mmString("<red>That command could not be found!");
|
||||
return messageComponent("commandNotFound");
|
||||
}
|
||||
return mmString("<aqua>Aliases for " + commandName + " are: " + Arrays.toString(command.getAliases().toArray(new String[0])));
|
||||
return messageComponent("commandAliases", commandName, Arrays.toString(command.getAliases().toArray(new String[0])));
|
||||
}
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("pagination"))
|
||||
@ -91,8 +90,8 @@ public class DebugCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
@ -106,20 +106,24 @@ public class EntityWipeCMD extends PlexCommand
|
||||
return null;
|
||||
}
|
||||
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
List<String> entities = new ArrayList<>();
|
||||
for (World world : Bukkit.getWorlds())
|
||||
if (silentCheckPermission(sender, this.getPermission()))
|
||||
{
|
||||
for (Entity entity : world.getEntities())
|
||||
List<String> entities = new ArrayList<>();
|
||||
for (World world : Bukkit.getWorlds())
|
||||
{
|
||||
if (entity.getType() != EntityType.PLAYER)
|
||||
for (Entity entity : world.getEntities())
|
||||
{
|
||||
entities.add(entity.getType().name());
|
||||
if (entity.getType() != EntityType.PLAYER)
|
||||
{
|
||||
entities.add(entity.getType().name());
|
||||
}
|
||||
}
|
||||
}
|
||||
return entities.stream().toList();
|
||||
}
|
||||
return entities.stream().toList();
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
private Integer parseInt(CommandSender sender, String string)
|
||||
@ -130,7 +134,7 @@ public class EntityWipeCMD extends PlexCommand
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
sender.sendMessage(mmString("<red>" + string + "<red> is not a valid number!"));
|
||||
sender.sendMessage(messageComponent("notANumber", string));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ 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;
|
||||
@ -13,6 +12,9 @@ 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
|
||||
@ -29,4 +31,10 @@ 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,7 +7,6 @@ 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;
|
||||
@ -42,11 +41,12 @@ public class FreezeCMD extends PlexCommand
|
||||
Punishment punishment = new Punishment(punishedPlayer.getUuid(), getUUID(sender));
|
||||
punishment.setCustomTime(false);
|
||||
ZonedDateTime date = ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE));
|
||||
punishment.setEndDate(date.plusMinutes(5));
|
||||
punishment.setEndDate(date.plusSeconds(plugin.config.getInt("punishments.freeze-timer", 300)));
|
||||
punishment.setType(PunishmentType.FREEZE);
|
||||
punishment.setPunishedUsername(player.getName());
|
||||
punishment.setIp(player.getAddress().getAddress().getHostAddress().trim());
|
||||
punishment.setReason("");
|
||||
punishment.setActive(true);
|
||||
|
||||
plugin.getPunishmentManager().punish(punishedPlayer, punishment);
|
||||
PlexUtils.broadcast(messageComponent("frozePlayer", sender.getName(), player.getName()));
|
||||
@ -54,8 +54,8 @@ public class FreezeCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender, "plex.freeze") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
@ -88,7 +88,7 @@ public class GamemodeCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
@ -96,7 +96,10 @@ public class GamemodeCMD extends PlexCommand
|
||||
}
|
||||
if (args.length == 2)
|
||||
{
|
||||
return PlexUtils.getPlayerNameList();
|
||||
if (silentCheckPermission(sender, "plex.gamemode.others"))
|
||||
{
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
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;
|
||||
@ -9,7 +10,6 @@ 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,6 +23,7 @@ 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)
|
||||
@ -37,7 +38,7 @@ public class KickCMD extends PlexCommand
|
||||
}
|
||||
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(args[0]);
|
||||
String reason = "No reason provided";
|
||||
String reason = messageString("noReasonProvided");
|
||||
|
||||
if (plexPlayer == null)
|
||||
{
|
||||
@ -67,4 +68,10 @@ 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();
|
||||
}
|
||||
}
|
@ -2,9 +2,11 @@ package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.hook.VaultHook;
|
||||
import dev.plex.meta.PlayerMeta;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -16,7 +18,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandParameters(name = "list", description = "Show a list of all online players", usage = "/<command> [-d]", aliases = "lsit,who,playerlist,online")
|
||||
@CommandParameters(name = "list", description = "Show a list of all online players", usage = "/<command> [-d | -v]", aliases = "lsit,who,playerlist,online")
|
||||
@CommandPermissions(permission = "plex.list")
|
||||
public class ListCMD extends PlexCommand
|
||||
{
|
||||
@ -24,18 +26,17 @@ public class ListCMD extends PlexCommand
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||
{
|
||||
List<Player> players = Lists.newArrayList(Bukkit.getOnlinePlayers());
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("-v"))
|
||||
{
|
||||
checkPermission(sender, "plex.list.vanished");
|
||||
players.removeIf(player -> !PlayerMeta.isVanished(player));
|
||||
}
|
||||
else
|
||||
{
|
||||
players.removeIf(PlayerMeta::isVanished);
|
||||
}
|
||||
Component list = Component.empty();
|
||||
Component header = Component.text("There " + (players.size() == 1 ? "is" : "are") + " currently").color(NamedTextColor.GRAY)
|
||||
.append(Component.space())
|
||||
.append(Component.text(players.size()).color(NamedTextColor.YELLOW))
|
||||
.append(Component.space())
|
||||
.append(Component.text(players.size() == 1 ? "player" : "players").color(NamedTextColor.GRAY))
|
||||
.append(Component.space())
|
||||
.append(Component.text("online out of").color(NamedTextColor.GRAY))
|
||||
.append(Component.space())
|
||||
.append(Component.text(Bukkit.getMaxPlayers()).color(NamedTextColor.YELLOW))
|
||||
.append(Component.space())
|
||||
.append(Component.text(Bukkit.getMaxPlayers() == 1 ? "player." : "players.").color(NamedTextColor.GRAY));
|
||||
Component header = PlexUtils.messageComponent(players.size() == 1 ? "listHeader" : "listHeaderPlural", players.size(), Bukkit.getMaxPlayers());
|
||||
send(sender, header);
|
||||
if (players.isEmpty())
|
||||
{
|
||||
@ -65,11 +66,11 @@ public class ListCMD extends PlexCommand
|
||||
return list;
|
||||
}
|
||||
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (args.length == 1)
|
||||
if (args.length == 1 && silentCheckPermission(sender, this.getPermission()))
|
||||
{
|
||||
return Collections.singletonList("-d");
|
||||
return List.of("-d", "-v");
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
@ -11,6 +11,9 @@ 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
|
||||
@ -22,4 +25,10 @@ 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,7 +5,6 @@ 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;
|
||||
@ -39,8 +38,8 @@ public class LockupCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender, "plex.lockup") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
@ -13,6 +13,9 @@ 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
|
||||
@ -30,4 +33,10 @@ 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();
|
||||
}
|
||||
}
|
||||
|
96
server/src/main/java/dev/plex/command/impl/MobLimitCMD.java
Normal file
96
server/src/main/java/dev/plex/command/impl/MobLimitCMD.java
Normal file
@ -0,0 +1,96 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
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.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandParameters(name = "moblimit", usage = "/<command> [on | off | setmax <limit>]", aliases = "entitylimit", description = "Manages the mob limit per chunk.")
|
||||
@CommandPermissions(permission = "plex.moblimit", source = RequiredCommandSource.ANY)
|
||||
public class MobLimitCMD extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
Chunk chunk = playerSender != null ? playerSender.getLocation().getChunk() : Bukkit.getWorlds().get(0).getChunkAt(0, 0);
|
||||
|
||||
int currentLimit = plugin.config.getInt("entity_limit.max_mobs_per_chunk");
|
||||
int currentMobCount = (int) Arrays.stream(chunk.getEntities())
|
||||
.filter(entity -> entity instanceof LivingEntity && !(entity instanceof Player))
|
||||
.count();
|
||||
|
||||
String status = plugin.config.getBoolean("entity_limit.mob_limit_enabled") ? "<green>Enabled" : "<red>Disabled";
|
||||
return PlexUtils.messageComponent("mobLimitStatus", status, currentMobCount, currentLimit, chunk.getX(), chunk.getZ());
|
||||
}
|
||||
|
||||
switch (args[0].toLowerCase())
|
||||
{
|
||||
case "on":
|
||||
plugin.config.set("entity_limit.mob_limit_enabled", true);
|
||||
plugin.config.save();
|
||||
return PlexUtils.messageComponent("mobLimitToggle", "enabled");
|
||||
case "off":
|
||||
plugin.config.set("entity_limit.mob_limit_enabled", false);
|
||||
plugin.config.save();
|
||||
return PlexUtils.messageComponent("mobLimitToggle", "disabled");
|
||||
case "setmax":
|
||||
try
|
||||
{
|
||||
if (args.length != 2) return usage();
|
||||
|
||||
int newLimit = Integer.parseInt(args[1]);
|
||||
if (newLimit < 0) throw new NumberFormatException();
|
||||
|
||||
int limitCeiling = plugin.config.getInt("entity_limit.mob_limit_ceiling");
|
||||
if (newLimit > limitCeiling)
|
||||
{
|
||||
newLimit = limitCeiling;
|
||||
sender.sendMessage(PlexUtils.messageComponent("mobLimitCeiling"));
|
||||
}
|
||||
|
||||
plugin.config.set("entity_limit.max_mobs_per_chunk", newLimit);
|
||||
plugin.config.save();
|
||||
return PlexUtils.messageComponent("mobLimitSet", newLimit);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return PlexUtils.messageComponent("unableToParseNumber", args[1]);
|
||||
}
|
||||
default:
|
||||
return usage();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (silentCheckPermission(sender, this.getPermission()))
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
return Arrays.asList("on", "off", "setmax");
|
||||
}
|
||||
if (args.length == 2 && args[0].equals("setmax"))
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
@ -4,50 +4,119 @@ 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.Mob;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@CommandPermissions(permission = "plex.mobpurge", source = RequiredCommandSource.ANY)
|
||||
@CommandParameters(name = "mobpurge", description = "Purge all mobs.", usage = "/<command>", aliases = "mp")
|
||||
@CommandParameters(name = "mobpurge", description = "Purge all mobs.", usage = "/<command> [mob]", 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)
|
||||
{
|
||||
HashMap<String, Integer> entityCounts = new HashMap<>();
|
||||
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;
|
||||
}
|
||||
|
||||
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.getEntities())
|
||||
for (Entity entity : world.getLivingEntities())
|
||||
{
|
||||
if (entity instanceof Mob)
|
||||
if (entity instanceof LivingEntity && !(entity instanceof Player))
|
||||
{
|
||||
String type = entity.getType().name();
|
||||
if (type != null && !entity.getType().equals(type))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
entity.remove();
|
||||
|
||||
entityCounts.put(type, entityCounts.getOrDefault(type, 0) + 1);
|
||||
removed++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
|
||||
int entityCount = entityCounts.values().stream().mapToInt(a -> a).sum();
|
||||
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;
|
||||
}
|
||||
|
||||
PlexUtils.broadcast(messageComponent("removedMobs", sender.getName(), entityCount));
|
||||
|
||||
/*entityCounts.forEach((entityName, numRemoved) -> {
|
||||
sender.sendMessage(messageComponent("removedEntitiesOfType", sender.getName(), numRemoved, entityName));
|
||||
});*/
|
||||
return null;
|
||||
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();
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ 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;
|
||||
@ -39,7 +38,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;
|
||||
@ -48,11 +47,12 @@ public class MuteCMD extends PlexCommand
|
||||
Punishment punishment = new Punishment(punishedPlayer.getUuid(), getUUID(sender));
|
||||
punishment.setCustomTime(false);
|
||||
ZonedDateTime date = ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE));
|
||||
punishment.setEndDate(date.plusMinutes(5));
|
||||
punishment.setEndDate(date.plusSeconds(plugin.config.getInt("punishments.mute-timer", 300)));
|
||||
punishment.setType(PunishmentType.MUTE);
|
||||
punishment.setPunishedUsername(player.getName());
|
||||
punishment.setIp(player.getAddress().getAddress().getHostAddress().trim());
|
||||
punishment.setReason("");
|
||||
punishment.setActive(true);
|
||||
|
||||
plugin.getPunishmentManager().punish(punishedPlayer, punishment);
|
||||
PlexUtils.broadcast(messageComponent("mutedPlayer", sender.getName(), player.getName()));
|
||||
@ -60,8 +60,8 @@ public class MuteCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender,"plex.mute") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ 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;
|
||||
@ -125,11 +124,11 @@ public class NotesCMD extends PlexCommand
|
||||
|
||||
private void readNotes(@NotNull CommandSender sender, PlexPlayer plexPlayer, List<Note> notes)
|
||||
{
|
||||
AtomicReference<Component> noteList = new AtomicReference<>(Component.text("Player notes for: " + plexPlayer.getName()).color(NamedTextColor.GREEN));
|
||||
AtomicReference<Component> noteList = new AtomicReference<>(messageComponent("notesHeader", plexPlayer.getName()));
|
||||
for (Note note : notes)
|
||||
{
|
||||
Component noteLine = mmString("<gold><!italic>" + note.getId() + " - Written by: " + DataUtils.getPlayer(note.getWrittenBy()).getName() + " on " + TimeUtils.useTimezone(note.getTimestamp()));
|
||||
noteLine = noteLine.append(mmString("<newline><yellow># " + note.getNote()));
|
||||
Component noteLine = messageComponent("notePrefix", note.getId(), DataUtils.getPlayer(note.getWrittenBy()).getName(), TimeUtils.useTimezone(note.getTimestamp()));
|
||||
noteLine = noteLine.append(messageComponent("noteLine", note.getNote()));
|
||||
noteList.set(noteList.get().append(Component.newline()));
|
||||
noteList.set(noteList.get().append(noteLine));
|
||||
}
|
||||
@ -137,15 +136,19 @@ public class NotesCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (args.length == 1)
|
||||
if (silentCheckPermission(sender, this.getPermission()))
|
||||
{
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
if (args.length == 2)
|
||||
{
|
||||
return Arrays.asList("list", "add", "remove", "clear");
|
||||
if (args.length == 1)
|
||||
{
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
if (args.length == 2)
|
||||
{
|
||||
return Arrays.asList("list", "add", "remove", "clear");
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
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.getHead()));
|
||||
send(sender, mmString("<light_purple>Plugin version: <gold>" + plugin.getDescription().getVersion() + " #" + BuildInfo.getNumber() + " <light_purple>Git: <gold>" + BuildInfo.getCommit()));
|
||||
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> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
|
@ -7,7 +7,6 @@ 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;
|
||||
@ -50,8 +49,8 @@ public class PunishmentsCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,9 @@ 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
|
||||
@ -28,4 +31,10 @@ 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,17 +1,21 @@
|
||||
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
|
||||
@ -51,4 +55,17 @@ 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,7 +4,6 @@ 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;
|
||||
@ -13,6 +12,9 @@ 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
|
||||
@ -28,4 +30,10 @@ 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,5 +1,6 @@
|
||||
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,12 +11,15 @@ 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
|
||||
@ -53,20 +57,18 @@ public class SetLoginMessageCMD extends PlexCommand
|
||||
validateMessage(message);
|
||||
plexPlayer.setLoginMessage(message);
|
||||
return messageComponent("setOtherPlayersLoginMessage", plexPlayer.getName(),
|
||||
message.replace("%player%", plexPlayer.getName()));
|
||||
MiniMessage.miniMessage().serialize(PlexUtils.stringToComponent(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);
|
||||
message = message.replace(plexPlayer.getName(), "%player%");
|
||||
message = PlexUtils.legacyToMiniString(message);
|
||||
String message = StringUtils.join(args, " ", 0, args.length)
|
||||
.replace(plexPlayer.getName(), "%player%");
|
||||
validateMessage(message);
|
||||
plexPlayer.setLoginMessage(message);
|
||||
return messageComponent("setOwnLoginMessage",
|
||||
message.replace("%player%", plexPlayer.getName()));
|
||||
return messageComponent("setOwnLoginMessage", PlexUtils.stringToComponent(message.replace("%player%", plexPlayer.getName())));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@ -79,4 +81,17 @@ 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,7 +7,6 @@ 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;
|
||||
@ -79,21 +78,16 @@ public class SmiteCMD extends PlexCommand
|
||||
final Player player = getNonNullPlayer(args[0]);
|
||||
final PlexPlayer plexPlayer = getPlexPlayer(player);
|
||||
|
||||
Title title = Title.title(Component.text("You've been smitten.").color(NamedTextColor.RED), Component.text("Be sure to follow the rules!").color(NamedTextColor.YELLOW));
|
||||
Title title = Title.title(messageComponent("smiteTitleHeader"), messageComponent("smiteTitleMessage", reason, sender.getName()));
|
||||
player.showTitle(title);
|
||||
|
||||
if (!silent)
|
||||
{
|
||||
PlexUtils.broadcast(mmString("<red>" + player.getName() + " has been a naughty, naughty boy."));
|
||||
if (reason != null)
|
||||
{
|
||||
PlexUtils.broadcast(mmString(" <red>Reason: " + "<yellow>" + reason));
|
||||
}
|
||||
PlexUtils.broadcast(mmString(" <red>Smitten by: " + "<yellow>" + sender.getName()));
|
||||
PlexUtils.broadcast(messageComponent("smiteBroadcast", player.getName(), reason != null ? reason : messageString("noReasonProvided"), sender.getName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
send(sender, "Smitten " + player.getName() + " quietly.");
|
||||
send(sender, messageComponent("smittenQuietly", player.getName()));
|
||||
}
|
||||
|
||||
// Set gamemode to survival
|
||||
@ -130,15 +124,15 @@ public class SmiteCMD extends PlexCommand
|
||||
if (reason != null)
|
||||
{
|
||||
punishment.setReason(reason);
|
||||
send(player, mmString("<red>You've been smitten. Reason: <yellow>" + reason));
|
||||
}
|
||||
send(player, messageComponent("smitten", reason != null ? reason : messageString("noReasonProvided")));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (silentCheckPermission(sender,"plex.smite") && args.length == 1)
|
||||
if (silentCheckPermission(sender, this.getPermission()) && args.length == 1)
|
||||
{
|
||||
return PlexUtils.getPlayerNameList();
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class SpectatorCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@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> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (silentCheckPermission(sender,"plex.gamemode.survival.others"))
|
||||
{
|
||||
|
@ -6,7 +6,6 @@ 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;
|
||||
@ -19,6 +18,10 @@ import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@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
|
||||
@ -47,16 +50,15 @@ public class TagCMD extends PlexCommand
|
||||
{
|
||||
return usage("/tag set <prefix>");
|
||||
}
|
||||
String prefix = PlexUtils.legacyToMiniString(StringUtils.join(args, " ", 1, args.length));
|
||||
|
||||
Component convertedComponent = SafeMiniMessage.mmDeserializeWithoutEvents(prefix);
|
||||
Component convertedComponent = PlexUtils.stringToComponent(StringUtils.join(args, " ", 1, args.length));
|
||||
|
||||
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(prefix);
|
||||
player.setPrefix(MiniMessage.miniMessage().serialize(convertedComponent));
|
||||
DataUtils.update(player);
|
||||
return messageComponent("prefixSetTo", MiniMessage.miniMessage().serialize(convertedComponent));
|
||||
}
|
||||
@ -80,7 +82,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);
|
||||
@ -89,6 +91,26 @@ 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,9 +22,10 @@ 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")
|
||||
@CommandParameters(name = "tempban", usage = "/<command> <player> <time> [reason] [-rb]", description = "Temporarily ban a player")
|
||||
@CommandPermissions(permission = "plex.tempban", source = RequiredCommandSource.ANY)
|
||||
|
||||
public class TempbanCMD extends PlexCommand
|
||||
@ -52,14 +53,17 @@ public class TempbanCMD extends PlexCommand
|
||||
}
|
||||
Punishment punishment = new Punishment(target.getUuid(), getUUID(sender));
|
||||
punishment.setType(PunishmentType.TEMPBAN);
|
||||
boolean rollBack = false;
|
||||
if (args.length > 2)
|
||||
{
|
||||
reason = StringUtils.join(args, " ", 2, args.length);
|
||||
punishment.setReason(reason);
|
||||
String newReason = StringUtils.normalizeSpace(reason.replace("-nrb", ""));
|
||||
punishment.setReason(newReason.trim().isEmpty() ? messageString("noReasonProvided") : newReason);
|
||||
rollBack = reason.startsWith("-rb") || reason.endsWith("-rb");
|
||||
}
|
||||
else
|
||||
{
|
||||
punishment.setReason("No reason provided.");
|
||||
punishment.setReason(messageString("noReasonProvided"));
|
||||
}
|
||||
punishment.setPunishedUsername(target.getName());
|
||||
punishment.setEndDate(TimeUtils.createDate(args[1]));
|
||||
@ -75,12 +79,46 @@ 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() != null && 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> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender,"plex.tempban") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
92
server/src/main/java/dev/plex/command/impl/TempmuteCMD.java
Normal file
92
server/src/main/java/dev/plex/command/impl/TempmuteCMD.java
Normal file
@ -0,0 +1,92 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
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.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils; // Import your TimeUtils
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@CommandParameters(name = "tempmute", description = "Temporarily mute a player on the server",
|
||||
usage = "/<command> <player> <time> [reason]", aliases = "tmute")
|
||||
@CommandPermissions(permission = "plex.tempmute")
|
||||
public class TempmuteCMD extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
return usage();
|
||||
}
|
||||
|
||||
Player player = getNonNullPlayer(args[0]);
|
||||
PlexPlayer punishedPlayer = getOfflinePlexPlayer(player.getUniqueId());
|
||||
|
||||
if (punishedPlayer.isMuted())
|
||||
{
|
||||
return messageComponent("playerMuted");
|
||||
}
|
||||
|
||||
if (silentCheckPermission(player, "plex.tempmute"))
|
||||
{
|
||||
send(sender, messageComponent("higherRankThanYou"));
|
||||
return null;
|
||||
}
|
||||
|
||||
ZonedDateTime endDate;
|
||||
try
|
||||
{
|
||||
endDate = TimeUtils.createDate(args[1]);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return messageComponent("invalidTimeFormat");
|
||||
}
|
||||
|
||||
if (endDate.isBefore(ZonedDateTime.now()))
|
||||
{
|
||||
return messageComponent("timeMustBeFuture");
|
||||
}
|
||||
|
||||
ZonedDateTime oneWeekFromNow = ZonedDateTime.now().plusWeeks(1);
|
||||
if (endDate.isAfter(oneWeekFromNow))
|
||||
{
|
||||
return messageComponent("maxTimeExceeded");
|
||||
}
|
||||
|
||||
final String reason = args.length >= 3 ? String.join(" ", Arrays.copyOfRange(args, 2, args.length))
|
||||
: messageString("noReasonProvided");
|
||||
|
||||
Punishment punishment = new Punishment(punishedPlayer.getUuid(), getUUID(sender));
|
||||
punishment.setCustomTime(true);
|
||||
punishment.setEndDate(endDate);
|
||||
punishment.setType(PunishmentType.MUTE);
|
||||
punishment.setPunishedUsername(player.getName());
|
||||
punishment.setIp(player.getAddress().getAddress().getHostAddress().trim());
|
||||
punishment.setReason(reason);
|
||||
punishment.setActive(true);
|
||||
|
||||
plugin.getPunishmentManager().punish(punishedPlayer, punishment);
|
||||
PlexUtils.broadcast(messageComponent("tempMutedPlayer", sender.getName(), player.getName(), TimeUtils.formatRelativeTime(endDate)));
|
||||
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();
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ 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;
|
||||
@ -33,6 +32,8 @@ public class ToggleCMD extends PlexCommand
|
||||
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Fluidspread" + status("fluidspread")));
|
||||
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Drops" + status("drops")));
|
||||
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Redstone" + status("redstone")));
|
||||
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - PVP" + status("pvp")));
|
||||
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Chat" + status("chat")));
|
||||
return null;
|
||||
}
|
||||
switch (args[0].toLowerCase())
|
||||
@ -53,6 +54,15 @@ public class ToggleCMD extends PlexCommand
|
||||
{
|
||||
return toggle("redstone");
|
||||
}
|
||||
case "pvp" ->
|
||||
{
|
||||
return toggle("pvp");
|
||||
}
|
||||
case "chat" ->
|
||||
{
|
||||
PlexUtils.broadcast(PlexUtils.messageComponent("chatToggled", sender.getName(), plugin.toggles.getBoolean("chat") ? "off" : "on"));
|
||||
return toggle("chat");
|
||||
}
|
||||
default ->
|
||||
{
|
||||
return messageComponent("invalidToggle");
|
||||
@ -64,9 +74,9 @@ public class ToggleCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
|
||||
private String status(String toggle)
|
||||
|
@ -9,7 +9,6 @@ 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;
|
||||
@ -56,8 +55,8 @@ public class UnbanCMD extends PlexCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender,"plex.unban") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,14 @@
|
||||
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.exception.CommandFailException;
|
||||
import dev.plex.command.exception.PlayerNotFoundException;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -27,20 +29,28 @@ public class UnfreezeCMD extends PlexCommand
|
||||
{
|
||||
return usage();
|
||||
}
|
||||
Player player = getNonNullPlayer(args[0]);
|
||||
PlexPlayer punishedPlayer = getOfflinePlexPlayer(player.getUniqueId());
|
||||
PlexPlayer punishedPlayer = DataUtils.getPlayer(args[0]);
|
||||
if (punishedPlayer == null)
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
|
||||
if (!punishedPlayer.isFrozen())
|
||||
{
|
||||
throw new CommandFailException(PlexUtils.messageString("playerNotFrozen"));
|
||||
}
|
||||
punishedPlayer.setFrozen(false);
|
||||
PlexUtils.broadcast(messageComponent("unfrozePlayer", sender.getName(), player.getName()));
|
||||
punishedPlayer.getPunishments().stream().filter(punishment -> punishment.getType() == PunishmentType.FREEZE && punishment.isActive()).forEach(punishment -> {
|
||||
punishment.setActive(false);
|
||||
plugin.getSqlPunishment().updatePunishment(punishment.getType(), false, punishment.getPunished());
|
||||
});
|
||||
PlexUtils.broadcast(messageComponent("unfrozePlayer", sender.getName(), punishedPlayer.getName()));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender,"plex.unfreeze") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,14 @@
|
||||
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.exception.CommandFailException;
|
||||
import dev.plex.command.exception.PlayerNotFoundException;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -27,20 +29,28 @@ public class UnmuteCMD extends PlexCommand
|
||||
{
|
||||
return usage();
|
||||
}
|
||||
Player player = getNonNullPlayer(args[0]);
|
||||
PlexPlayer punishedPlayer = getOfflinePlexPlayer(player.getUniqueId());
|
||||
PlexPlayer punishedPlayer = DataUtils.getPlayer(args[0]);
|
||||
if (punishedPlayer == null)
|
||||
{
|
||||
throw new PlayerNotFoundException();
|
||||
}
|
||||
|
||||
if (!punishedPlayer.isMuted())
|
||||
{
|
||||
throw new CommandFailException(PlexUtils.messageString("playerNotMuted"));
|
||||
}
|
||||
punishedPlayer.setMuted(false);
|
||||
PlexUtils.broadcast(messageComponent("unmutedPlayer", sender.getName(), player.getName()));
|
||||
punishedPlayer.getPunishments().stream().filter(punishment -> punishment.getType() == PunishmentType.MUTE && punishment.isActive()).forEach(punishment -> {
|
||||
punishment.setActive(false);
|
||||
plugin.getSqlPunishment().updatePunishment(punishment.getType(), false, punishment.getPunished());
|
||||
});
|
||||
PlexUtils.broadcast(messageComponent("unmutedPlayer", sender.getName(), punishedPlayer.getName()));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender,"plex.unfreeze") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
|
||||
@CommandPermissions(permission = "plex.whohas")
|
||||
@CommandParameters(name = "whohas", description = "Returns a list of players with a specific item in their inventory.", usage = "/<command> <material>", aliases = "wh")
|
||||
@ -36,17 +37,43 @@ public class WhoHasCMD extends PlexCommand
|
||||
return messageComponent("materialNotFound", args[0]);
|
||||
}
|
||||
|
||||
final List<TextComponent> players = Bukkit.getOnlinePlayers().stream().filter(player ->
|
||||
player.getInventory().contains(material)).map(player -> Component.text(player.getName())).toList();
|
||||
boolean clearInventory = args.length > 1 && args[1].equalsIgnoreCase("clear");
|
||||
|
||||
return players.isEmpty() ? messageComponent("nobodyHasThatMaterial") :
|
||||
messageComponent("playersWithMaterial", Component.text(material.name()),
|
||||
Component.join(JoinConfiguration.commas(true), players));
|
||||
if (clearInventory && !sender.hasPermission("plex.whohas.clear"))
|
||||
{
|
||||
return messageComponent("noPermissionNode", "plex.whohas.clear");
|
||||
}
|
||||
|
||||
List<TextComponent> players = Bukkit.getOnlinePlayers().stream().filter(player ->
|
||||
player.getInventory().contains(material)).map(player -> {
|
||||
if (clearInventory)
|
||||
{
|
||||
player.getInventory().remove(material);
|
||||
player.updateInventory();
|
||||
}
|
||||
return Component.text(player.getName());
|
||||
}).toList();
|
||||
|
||||
return players.isEmpty() ?
|
||||
messageComponent("nobodyHasThatMaterial") :
|
||||
(clearInventory ?
|
||||
messageComponent("playersMaterialCleared", Component.text(material.name()),
|
||||
Component.join(JoinConfiguration.commas(true), players)) :
|
||||
messageComponent("playersWithMaterial", Component.text(material.name()),
|
||||
Component.join(JoinConfiguration.commas(true), players)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return args.length == 1 && silentCheckPermission(sender, "plex.whohas") ? Arrays.stream(Material.values()).map(Enum::name).toList() : ImmutableList.of();
|
||||
if (args.length == 1 && silentCheckPermission(sender, this.getPermission()))
|
||||
{
|
||||
return Arrays.stream(Material.values()).map(Enum::name).toList();
|
||||
}
|
||||
else if (args.length == 2 && silentCheckPermission(sender, "plex.whohas.clear"))
|
||||
{
|
||||
return Collections.singletonList("clear");
|
||||
}
|
||||
return ImmutableList.of();
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ 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;
|
||||
@ -38,19 +37,18 @@ 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> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
public @NotNull List<String> smartTabComplete(@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)
|
||||
if (args.length == 1 && silentCheckPermission(sender, this.getPermission()))
|
||||
{
|
||||
@NotNull List<World> worlds = Bukkit.getWorlds();
|
||||
for (World world : worlds)
|
||||
@ -60,7 +58,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);
|
||||
}
|
||||
|
63
server/src/main/java/dev/plex/hook/CoreProtectHook.java
Normal file
63
server/src/main/java/dev/plex/hook/CoreProtectHook.java
Normal file
@ -0,0 +1,63 @@
|
||||
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;
|
||||
}
|
||||
}
|
34
server/src/main/java/dev/plex/hook/PrismHook.java
Normal file
34
server/src/main/java/dev/plex/hook/PrismHook.java
Normal file
@ -0,0 +1,34 @@
|
||||
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}", PlexUtils.legacyToMiniString(vaultPrefix).replace("<", "\\<"));
|
||||
return SafeMiniMessage.mmDeserializeWithoutEvents(PlexUtils.legacyToMiniString(vaultPrefix));
|
||||
PlexLog.debug("prefix: {0}", SafeMiniMessage.mmSerializeWithoutEvents(PlexUtils.stringToComponent(vaultPrefix)).replace("<", "\\<"));
|
||||
return PlexUtils.stringToComponent(vaultPrefix);
|
||||
}
|
||||
|
||||
public static Permission getPermission()
|
||||
|
@ -1,6 +1,7 @@
|
||||
package dev.plex.listener.impl;
|
||||
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.services.impl.TimingService;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@ -19,7 +20,7 @@ public class AntiNukerListener extends PlexListener
|
||||
if (getCount(event.getPlayer().getUniqueId()) > 200L)
|
||||
{
|
||||
TimingService.strikes.merge(event.getPlayer().getUniqueId(), 1L, Long::sum);
|
||||
event.getPlayer().kick(Component.text("Please turn off your nuker!"));
|
||||
event.getPlayer().kick(PlexUtils.messageComponent("nukerKickMessage"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -31,7 +32,7 @@ public class AntiNukerListener extends PlexListener
|
||||
if (getCount(event.getPlayer().getUniqueId()) > 200L)
|
||||
{
|
||||
TimingService.strikes.merge(event.getPlayer().getUniqueId(), 1L, Long::sum);
|
||||
event.getPlayer().kick(Component.text("Please turn off your nuker!"));
|
||||
event.getPlayer().kick(PlexUtils.messageComponent("nukerKickMessage"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package dev.plex.listener.impl;
|
||||
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.services.impl.TimingService;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -19,7 +20,7 @@ public class AntiSpamListener extends PlexListener
|
||||
TimingService.spamCooldown.merge(event.getPlayer().getUniqueId(), 1L, Long::sum);
|
||||
if (getCount(event.getPlayer().getUniqueId()) > 8L)
|
||||
{
|
||||
event.getPlayer().sendMessage(Component.text("Please refrain from spamming messages.").color(NamedTextColor.GRAY));
|
||||
event.getPlayer().sendMessage(PlexUtils.messageComponent("antiSpamMessage"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
@ -30,7 +31,7 @@ public class AntiSpamListener extends PlexListener
|
||||
TimingService.spamCooldown.merge(event.getPlayer().getUniqueId(), 1L, Long::sum);
|
||||
if (getCount(event.getPlayer().getUniqueId()) > 8L)
|
||||
{
|
||||
event.getPlayer().sendMessage(Component.text("Please refrain from spamming commands.").color(NamedTextColor.GRAY));
|
||||
event.getPlayer().sendMessage(PlexUtils.messageComponent("antiSpamMessage"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ 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;
|
||||
@ -43,11 +45,26 @@ 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,7 +12,6 @@ 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;
|
||||
@ -47,7 +46,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, PlexUtils.legacyToMiniString(SafeMiniMessage.mmSerializeWithoutEvents(event.message()))).replaceText(URL_REPLACEMENT_CONFIG));
|
||||
plugin.getServer().getConsoleSender().sendMessage(PlexUtils.messageComponent("adminChatFormat", event.getPlayer().getName(), prefix, SafeMiniMessage.mmSerialize(event.message().replaceText(URL_REPLACEMENT_CONFIG))));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
@ -105,7 +104,7 @@ public class ChatListener extends PlexListener
|
||||
|
||||
private static void defaultChatProcessing(AsyncChatEvent event, PlexPlayer plexPlayer)
|
||||
{
|
||||
String text = PlexUtils.legacyToMiniString(PlexUtils.getTextFromComponent(event.message()));
|
||||
event.message(SafeMiniMessage.mmDeserializeWithoutEvents(text));
|
||||
String text = PlexUtils.getTextFromComponent(event.message());
|
||||
event.message(PlexUtils.stringToComponent(text));
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package dev.plex.listener.impl;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.BlockUtils;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
@ -11,6 +12,7 @@ import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -70,6 +72,17 @@ public class MobListener extends PlexListener
|
||||
Collection<Player> coll = location.getNearbyEntitiesByType(Player.class, 10);
|
||||
PlexUtils.disabledEffectMultiple(coll.toArray(new Player[coll.size()]), location); // dont let intellij auto correct toArray to an empty array (for efficiency)
|
||||
}
|
||||
|
||||
if (plugin.config.getBoolean("entity_limit.mob_limit_enabled"))
|
||||
{
|
||||
Location location = event.getLocation();
|
||||
Chunk chunk = location.getChunk();
|
||||
|
||||
if (isEntityLimitReached(chunk, plugin.config.getInt("entity_limit.max_mobs_per_chunk")))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@ -135,4 +148,11 @@ public class MobListener extends PlexListener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isEntityLimitReached(Chunk chunk, int limit)
|
||||
{
|
||||
return Arrays.stream(chunk.getEntities())
|
||||
.filter(entity -> entity instanceof LivingEntity && !(entity instanceof Player))
|
||||
.count() >= limit;
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import dev.plex.meta.PlayerMeta;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
@ -18,9 +19,7 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PlayerListener<T> extends PlexListener
|
||||
public class PlayerListener extends PlexListener
|
||||
{
|
||||
// setting up a player's data
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
@ -63,20 +62,18 @@ public class PlayerListener<T> extends PlexListener
|
||||
}
|
||||
|
||||
String loginMessage = PlayerMeta.getLoginMessage(plexPlayer);
|
||||
if (!loginMessage.isEmpty())
|
||||
if (!loginMessage.isEmpty() && !PlayerMeta.isVanished(player))
|
||||
{
|
||||
PlexUtils.broadcast(loginMessage);
|
||||
PlexUtils.broadcast(PlexUtils.stringToComponent(loginMessage));
|
||||
}
|
||||
|
||||
plexPlayer.loadNotes();
|
||||
|
||||
plugin.getSqlNotes().getNotes(plexPlayer.getUuid()).whenComplete((notes, ex) ->
|
||||
{
|
||||
String plural = notes.size() == 1 ? "note." : "notes.";
|
||||
if (!notes.isEmpty())
|
||||
{
|
||||
PlexUtils.broadcastToAdmins(Component.text(plexPlayer.getName() + " has " + notes.size() + " " + plural).color(NamedTextColor.GOLD), "plex.notes.notify");
|
||||
PlexUtils.broadcastToAdmins(Component.text("Click to view their " + plural).clickEvent(ClickEvent.runCommand("/notes " + plexPlayer.getName() + " list")).color(NamedTextColor.GOLD), "plex.notes.notify");
|
||||
PlexUtils.broadcastToAdmins(PlexUtils.messageComponent(notes.size() == 1 ? "playerNoteAlert" : "playerNoteAlertPlural", plexPlayer.getName(), notes.size()), "plex.notes.notify");
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -96,7 +93,7 @@ public class PlayerListener<T> extends PlexListener
|
||||
PlexPlayer player = DataUtils.getPlayer(event.getPlayer().getUniqueId());
|
||||
if (player.isLockedUp())
|
||||
{
|
||||
Bukkit.getScheduler().runTaskLater(plugin, () -> event.getPlayer().openInventory(event.getInventory()), 1L);
|
||||
Bukkit.getGlobalRegionScheduler().runDelayed(plugin, (scheduledTask) -> event.getPlayer().openInventory(event.getInventory()), 1L);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,22 +0,0 @@
|
||||
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))));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,16 +1,29 @@
|
||||
package dev.plex.listener.impl;
|
||||
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import io.papermc.paper.event.player.PrePlayerAttackEntityEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.ThrownPotion;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockExplodeEvent;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.projectiles.ProjectileSource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TogglesListener extends PlexListener
|
||||
{
|
||||
List<String> commands = plugin.commands.getStringList("block_on_mute");
|
||||
|
||||
@EventHandler
|
||||
public void onExplosionPrime(ExplosionPrimeEvent event)
|
||||
{
|
||||
@ -22,7 +35,8 @@ public class TogglesListener extends PlexListener
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockExplode(BlockExplodeEvent event) {
|
||||
public void onBlockExplode(BlockExplodeEvent event)
|
||||
{
|
||||
if (!plugin.toggles.getBoolean("explosions"))
|
||||
{
|
||||
event.getBlock().breakNaturally();
|
||||
@ -58,6 +72,100 @@ public class TogglesListener extends PlexListener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChat(AsyncChatEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if (!plugin.toggles.getBoolean("chat") && !Plex.get().getPermissions().has(player, "plex.mute.bypass"))
|
||||
{
|
||||
event.getPlayer().sendMessage(PlexUtils.messageComponent("chatIsOff"));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onCommand(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
if (!plugin.toggles.getBoolean("chat") && !Plex.get().getPermissions().has(player, "plex.mute.bypass"))
|
||||
{
|
||||
String message = event.getMessage();
|
||||
message = message.replaceAll("\\s.*", "").replaceFirst("/", "");
|
||||
if (commands.contains(message.toLowerCase()))
|
||||
{
|
||||
event.getPlayer().sendMessage(PlexUtils.messageComponent("chatIsOff"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
for (String command : commands)
|
||||
{
|
||||
Command cmd = Bukkit.getCommandMap().getCommand(command);
|
||||
if (cmd == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (cmd.getAliases().contains(message.toLowerCase()))
|
||||
{
|
||||
event.getPlayer().sendMessage(PlexUtils.messageComponent("chatIsOff"));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerAttack(PrePlayerAttackEntityEvent event)
|
||||
{
|
||||
if (!plugin.toggles.getBoolean("pvp"))
|
||||
{
|
||||
if (event.getAttacked() instanceof Player)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
event.getPlayer().sendMessage(PlexUtils.messageComponent("pvpDisabled"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPotionSplash(PotionSplashEvent event)
|
||||
{
|
||||
if (!plugin.toggles.getBoolean("pvp"))
|
||||
{
|
||||
ProjectileSource shooter = event.getEntity().getShooter();
|
||||
if (shooter instanceof Player)
|
||||
{
|
||||
ThrownPotion potion = event.getPotion();
|
||||
if (potion.getEffects().stream().anyMatch(effect -> effect.getType().getName().startsWith("HARM") ||
|
||||
effect.getType().getName().startsWith("POISON")) &&
|
||||
event.getAffectedEntities().stream().anyMatch(entity -> entity instanceof Player))
|
||||
{
|
||||
|
||||
event.setCancelled(true);
|
||||
((Player) shooter).sendMessage(PlexUtils.messageComponent("pvpDisabled"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProjectileHit(ProjectileHitEvent event)
|
||||
{
|
||||
if (!plugin.toggles.getBoolean("pvp"))
|
||||
{
|
||||
ProjectileSource shooter = event.getEntity().getShooter();
|
||||
if (shooter instanceof Player && event.getHitEntity() instanceof Player)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
||||
((Player) shooter).sendMessage(PlexUtils.messageComponent("pvpDisabled"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* I have no idea if this is the best way to do this
|
||||
There is a very weird bug where if you try to create a loop using two repeaters and a lever, after disabling
|
||||
and re-enabling redstone, you are unable to recreate the loop with a lever. Using a redstone torch works fine.
|
||||
|
@ -0,0 +1,32 @@
|
||||
package dev.plex.listener.impl;
|
||||
|
||||
import de.myzelyam.api.vanish.PlayerShowEvent;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.meta.PlayerMeta;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
public class VanishListener extends PlexListener
|
||||
{
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerUnvanish(PlayerShowEvent event)
|
||||
{
|
||||
if (!PlexUtils.hasVanishPlugin())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event.isSilent())
|
||||
{
|
||||
return;
|
||||
}
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(event.getPlayer().getUniqueId());
|
||||
String loginMessage = PlayerMeta.getLoginMessage(plexPlayer);
|
||||
if (!loginMessage.isEmpty())
|
||||
{
|
||||
PlexUtils.broadcast(PlexUtils.stringToComponent(loginMessage));
|
||||
}
|
||||
}
|
||||
}
|
@ -112,7 +112,8 @@ public class WorldListener extends PlexListener
|
||||
boolean isFaweCommand = command instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) command).getPlugin().equals(Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit"));
|
||||
if (isWeCommand || isFaweCommand || EDIT_COMMANDS.contains(message.toLowerCase()))
|
||||
{
|
||||
event.getPlayer().sendMessage(Component.text("You do not have permission to use that command in this world.").color(NamedTextColor.RED));
|
||||
String noEdit = plugin.config.getString("worlds." + event.getPlayer().getWorld().getName().toLowerCase() + ".modification.message");
|
||||
event.getPlayer().sendMessage(MiniMessage.miniMessage().deserialize(noEdit));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class PunishedPlayerMenu extends PageableMenu<Punishment>
|
||||
@Override
|
||||
protected ItemStack toItem(Punishment object)
|
||||
{
|
||||
return new ItemBuilder(Material.PAPER).displayName("<!italic><red>" + object.getType().name()).lore("<!italic><red>By: <gold>" + (object.getPunisher() == null ? "CONSOLE" : Plex.get().getSqlPlayerData().getNameByUUID(object.getPunished())), "<!italic><red>Expire(d/s): <gold>" + TimeUtils.useTimezone(object.getEndDate()), "<!italic><red>Reason: <gold>" + object.getReason()).build();
|
||||
return new ItemBuilder(Material.PAPER).displayName("<!italic><red>" + object.getType().name()).lore("<!italic><red>By: <gold>" + (object.getPunisher() == null ? "CONSOLE" : Plex.get().getSqlPlayerData().getNameByUUID(object.getPunisher())), "<!italic><red>Expire(d/s): <gold>" + TimeUtils.useTimezone(object.getEndDate()), "<!italic><red>Reason: <gold>" + object.getReason()).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
@ -24,6 +25,8 @@ public class ToggleMenu extends AbstractMenu
|
||||
resetFluidspreadItem(this.inventory());
|
||||
resetDropsItem(this.inventory());
|
||||
resetRedstoneItem(this.inventory());
|
||||
resetPVPItem(this.inventory());
|
||||
resetChatItem(this.inventory());
|
||||
}
|
||||
|
||||
private void resetExplosionItem(Inventory inventory)
|
||||
@ -66,6 +69,27 @@ public class ToggleMenu extends AbstractMenu
|
||||
inventory.setItem(3, redstone);
|
||||
}
|
||||
|
||||
private void resetPVPItem(Inventory inventory)
|
||||
{
|
||||
ItemStack pvp = new ItemStack(Material.IRON_SWORD);
|
||||
ItemMeta pvpItemMeta = pvp.getItemMeta();
|
||||
pvpItemMeta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
|
||||
pvpItemMeta.displayName(PlexUtils.mmDeserialize("<!italic><light_purple>PVP"));
|
||||
pvpItemMeta.lore(List.of(PlexUtils.mmDeserialize("<!italic><yellow>PVP is " + (plugin.toggles.getBoolean("pvp") ? "<green>enabled" : "<red>disabled"))));
|
||||
pvp.setItemMeta(pvpItemMeta);
|
||||
inventory.setItem(4, pvp);
|
||||
}
|
||||
|
||||
private void resetChatItem(Inventory inventory)
|
||||
{
|
||||
ItemStack chat = new ItemStack(Material.OAK_SIGN);
|
||||
ItemMeta chatItemMeta = chat.getItemMeta();
|
||||
chatItemMeta.displayName(PlexUtils.mmDeserialize("<!italic><light_purple>Toggle chat"));
|
||||
chatItemMeta.lore(List.of(PlexUtils.mmDeserialize("<!italic><yellow>Chat is currently " + (plugin.toggles.getBoolean("chat") ? "<green>on" : "<red>off"))));
|
||||
chat.setItemMeta(chatItemMeta);
|
||||
inventory.setItem(5, chat);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onClick(InventoryView view, Inventory inventory, Player player, ItemStack clicked)
|
||||
{
|
||||
@ -93,6 +117,19 @@ public class ToggleMenu extends AbstractMenu
|
||||
resetRedstoneItem(inventory);
|
||||
player.sendMessage(PlexUtils.mmDeserialize("<gray>Toggled redstone."));
|
||||
}
|
||||
if (clicked.getType() == Material.IRON_SWORD)
|
||||
{
|
||||
plugin.toggles.set("pvp", !plugin.toggles.getBoolean("pvp"));
|
||||
resetPVPItem(inventory);
|
||||
player.sendMessage(PlexUtils.mmDeserialize("<gray>Toggled PVP"));
|
||||
}
|
||||
if (clicked.getType() == Material.OAK_SIGN)
|
||||
{
|
||||
plugin.toggles.set("chat", !plugin.toggles.getBoolean("chat"));
|
||||
PlexUtils.broadcast(PlexUtils.messageComponent("chatToggled", player.getName(), plugin.toggles.getBoolean("chat") ? "on" : "off"));
|
||||
resetChatItem(inventory);
|
||||
player.sendMessage(PlexUtils.mmDeserialize("<gray>Toggled chat."));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -10,9 +10,27 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
|
||||
public class PlayerMeta
|
||||
{
|
||||
public static boolean isVanished(Player player)
|
||||
{
|
||||
for (MetadataValue meta : player.getMetadata("vanished"))
|
||||
{
|
||||
if (meta.asBoolean())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isVanished(PlexPlayer player)
|
||||
{
|
||||
return isVanished(player.getPlayer());
|
||||
}
|
||||
|
||||
public static Component getPrefix(PlexPlayer plexPlayer)
|
||||
{
|
||||
|
@ -4,6 +4,7 @@ import com.google.common.collect.Lists;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.punishment.extra.Note;
|
||||
import dev.plex.storage.annotation.MapObjectList;
|
||||
import dev.plex.storage.annotation.PrimaryKey;
|
||||
@ -79,6 +80,7 @@ public class PlexPlayer
|
||||
if (loadPunishments)
|
||||
{
|
||||
this.loadPunishments();
|
||||
this.checkMutesAndFreeze();
|
||||
// this.permissions.addAll(Plex.get().getSqlPermissions().getPermissions(this.uuid));
|
||||
}
|
||||
}
|
||||
@ -93,6 +95,12 @@ public class PlexPlayer
|
||||
return PlainTextComponentSerializer.plainText().serialize(getPlayer().displayName());
|
||||
}
|
||||
|
||||
public void checkMutesAndFreeze() {
|
||||
final ZonedDateTime now = ZonedDateTime.now();
|
||||
this.muted = this.punishments.stream().filter(punishment -> punishment.getType() == PunishmentType.MUTE).anyMatch(punishment -> punishment.isActive() && now.isBefore(punishment.getEndDate()));
|
||||
this.frozen = this.punishments.stream().filter(punishment -> punishment.getType() == PunishmentType.FREEZE).anyMatch(punishment -> punishment.isActive() && now.isBefore(punishment.getEndDate()));
|
||||
}
|
||||
|
||||
public void loadPunishments()
|
||||
{
|
||||
this.setPunishments(Plex.get().getSqlPunishment().getPunishments(this.getUuid()));
|
||||
|
@ -3,21 +3,14 @@ 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;
|
||||
@ -28,7 +21,17 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
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;
|
||||
|
||||
public class PunishmentManager implements PlexBase
|
||||
{
|
||||
@ -135,7 +138,6 @@ 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;
|
||||
@ -143,6 +145,11 @@ 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)
|
||||
{
|
||||
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());
|
||||
@ -172,6 +179,11 @@ public class PunishmentManager implements PlexBase
|
||||
return Plex.get().getSqlPunishment().removeBan(uuid);
|
||||
}
|
||||
|
||||
public void updateOutdatedPunishments(PlexPlayer player)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void doPunishment(PlexPlayer player, Punishment punishment)
|
||||
{
|
||||
if (punishment.getType() == PunishmentType.FREEZE)
|
||||
@ -185,13 +197,18 @@ public class PunishmentManager implements PlexBase
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (!player.isFrozen())
|
||||
PlexPlayer afterPlayer = DataUtils.getPlayer(player.getUuid());
|
||||
if (!afterPlayer.isFrozen())
|
||||
{
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
player.setFrozen(false);
|
||||
Bukkit.broadcast(PlexUtils.messageComponent("unfrozePlayer", "Plex", Bukkit.getOfflinePlayer(player.getUuid()).getName()));
|
||||
afterPlayer.setFrozen(false);
|
||||
punishment.setActive(false);
|
||||
plugin.getSqlPunishment().updatePunishment(punishment.getType(), false, punishment.getPunished());
|
||||
|
||||
DataUtils.update(afterPlayer);
|
||||
Bukkit.broadcast(PlexUtils.messageComponent("unfrozePlayer", "Plex", Bukkit.getOfflinePlayer(afterPlayer.getUuid()).getName()));
|
||||
}
|
||||
}.runTaskLater(Plex.get(), 20 * seconds);
|
||||
}
|
||||
@ -206,13 +223,17 @@ public class PunishmentManager implements PlexBase
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
if (!player.isMuted())
|
||||
PlexPlayer afterPlayer = DataUtils.getPlayer(player.getUuid());
|
||||
if (!afterPlayer.isMuted())
|
||||
{
|
||||
this.cancel();
|
||||
return;
|
||||
}
|
||||
player.setMuted(false);
|
||||
Bukkit.broadcast(PlexUtils.messageComponent("unmutedPlayer", "Plex", Bukkit.getOfflinePlayer(player.getUuid()).getName()));
|
||||
afterPlayer.setMuted(false);
|
||||
punishment.setActive(false);
|
||||
plugin.getSqlPunishment().updatePunishment(punishment.getType(), false, punishment.getPunished());
|
||||
|
||||
Bukkit.broadcast(PlexUtils.messageComponent("unmutedPlayer", "Plex", Bukkit.getOfflinePlayer(afterPlayer.getUuid()).getName()));
|
||||
}
|
||||
}.runTaskLater(Plex.get(), 20 * seconds);
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package dev.plex.services.impl;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.services.AbstractService;
|
||||
import dev.plex.util.TimeUtils;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -27,7 +28,7 @@ public class BanService extends AbstractService
|
||||
if (ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE)).isAfter(punishment.getEndDate()))
|
||||
{
|
||||
Plex.get().getPunishmentManager().unban(punishment);
|
||||
Bukkit.broadcast(Component.text("Plex - Unbanned " + Bukkit.getOfflinePlayer(punishment.getPunished()).getName()));
|
||||
Bukkit.broadcast(PlexUtils.messageComponent("banExpiredBroadcast", Bukkit.getOfflinePlayer(punishment.getPunished()).getName()));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -21,10 +21,11 @@ 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(?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||
private static final String UPDATE_BAN = "UPDATE `punishments` SET active=? WHERE active=? AND punished=? AND type=?";
|
||||
private static final String UPDATE_PUNISHMENT = "UPDATE `punishments` SET active=? WHERE punished=? AND type=?";
|
||||
|
||||
public CompletableFuture<List<Punishment>> getPunishments()
|
||||
{
|
||||
@ -84,6 +85,33 @@ 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)
|
||||
{
|
||||
@ -117,17 +145,16 @@ public class SQLPunishment
|
||||
{
|
||||
try (Connection con = Plex.get().getSqlConnection().getCon())
|
||||
{
|
||||
PreparedStatement statement = con.prepareStatement(UPDATE_BAN);
|
||||
PreparedStatement statement = con.prepareStatement(UPDATE_PUNISHMENT);
|
||||
statement.setBoolean(1, false);
|
||||
statement.setBoolean(2, true);
|
||||
statement.setString(3, uuid.toString());
|
||||
statement.setString(4, PunishmentType.BAN.name());
|
||||
statement.setString(2, uuid.toString());
|
||||
statement.setString(3, PunishmentType.BAN.name());
|
||||
statement.executeUpdate();
|
||||
|
||||
PreparedStatement statement1 = con.prepareStatement(UPDATE_BAN);
|
||||
PreparedStatement statement1 = con.prepareStatement(UPDATE_PUNISHMENT);
|
||||
statement1.setBoolean(1, false);
|
||||
statement1.setBoolean(2, true);
|
||||
statement1.setString(3, uuid.toString());
|
||||
statement1.setString(4, PunishmentType.TEMPBAN.name());
|
||||
statement1.setString(2, uuid.toString());
|
||||
statement1.setString(3, PunishmentType.TEMPBAN.name());
|
||||
statement1.executeUpdate();
|
||||
}
|
||||
catch (SQLException e)
|
||||
@ -136,24 +163,41 @@ public class SQLPunishment
|
||||
}
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> updatePunishment(PunishmentType type, boolean active, UUID punished)
|
||||
{
|
||||
return CompletableFuture.runAsync(() ->
|
||||
{
|
||||
try (Connection con = Plex.get().getSqlConnection().getCon())
|
||||
{
|
||||
PreparedStatement statement = con.prepareStatement(UPDATE_PUNISHMENT);
|
||||
statement.setBoolean(1, active);
|
||||
statement.setString(2, punished.toString());
|
||||
statement.setString(3, type.name());
|
||||
statement.executeUpdate();
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public CompletableFuture<Void> removeBan(UUID uuid)
|
||||
{
|
||||
return CompletableFuture.runAsync(() ->
|
||||
{
|
||||
try (Connection con = Plex.get().getSqlConnection().getCon())
|
||||
{
|
||||
PreparedStatement statement = con.prepareStatement(UPDATE_BAN);
|
||||
PreparedStatement statement = con.prepareStatement(UPDATE_PUNISHMENT);
|
||||
statement.setBoolean(1, false);
|
||||
statement.setBoolean(2, true);
|
||||
statement.setString(3, uuid.toString());
|
||||
statement.setString(4, PunishmentType.BAN.name());
|
||||
statement.setString(2, uuid.toString());
|
||||
statement.setString(3, PunishmentType.BAN.name());
|
||||
statement.executeUpdate();
|
||||
|
||||
PreparedStatement statement1 = con.prepareStatement(UPDATE_BAN);
|
||||
PreparedStatement statement1 = con.prepareStatement(UPDATE_PUNISHMENT);
|
||||
statement1.setBoolean(1, false);
|
||||
statement1.setBoolean(2, true);
|
||||
statement1.setString(3, uuid.toString());
|
||||
statement1.setString(4, PunishmentType.TEMPBAN.name());
|
||||
statement1.setString(2, uuid.toString());
|
||||
statement1.setString(3, PunishmentType.TEMPBAN.name());
|
||||
statement1.executeUpdate();
|
||||
}
|
||||
catch (SQLException e)
|
||||
@ -162,4 +206,5 @@ public class SQLPunishment
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -8,30 +8,30 @@ import java.util.Properties;
|
||||
|
||||
public class BuildInfo
|
||||
{
|
||||
@Getter
|
||||
public static String number;
|
||||
@Getter
|
||||
public static String author;
|
||||
@Getter
|
||||
public static String commit;
|
||||
@Getter
|
||||
public static String date;
|
||||
@Getter
|
||||
public static String head;
|
||||
public static String number;
|
||||
|
||||
public void load(Plex plugin)
|
||||
{
|
||||
try
|
||||
{
|
||||
Properties props;
|
||||
try (InputStream in = plugin.getResource("build.properties"))
|
||||
try (InputStream in = plugin.getResource("build-vars.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,16 +6,21 @@ 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.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.PluginCommandYamlParser;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
@ -28,6 +33,7 @@ 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
|
||||
@ -43,6 +49,8 @@ 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);
|
||||
@ -112,6 +120,15 @@ public class PlexUtils implements PlexBase
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean hasVanishPlugin()
|
||||
{
|
||||
if (Bukkit.getPluginManager().isPluginEnabled("SuperVanish") || Bukkit.getPluginManager().isPluginEnabled("PremiumVanish"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isPluginCMD(String cmd, String pluginName)
|
||||
{
|
||||
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginName);
|
||||
@ -145,6 +162,17 @@ 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>")
|
||||
|
@ -7,6 +7,7 @@ import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@ -79,4 +80,41 @@ public class TimeUtils
|
||||
}
|
||||
return DATE_FORMAT.withZone(ZoneId.of(TIMEZONE)).format(date);
|
||||
}
|
||||
|
||||
public static String formatRelativeTime(ZonedDateTime date)
|
||||
{
|
||||
long seconds = ChronoUnit.SECONDS.between(ZonedDateTime.now(), date);
|
||||
|
||||
if (seconds <= 0)
|
||||
{
|
||||
return "now";
|
||||
}
|
||||
|
||||
long minute = seconds / 60;
|
||||
long hour = minute / 60;
|
||||
long day = hour / 24;
|
||||
long week = day / 7;
|
||||
|
||||
if (week > 0)
|
||||
{
|
||||
return week + " week" + (week > 1 ? "s" : "");
|
||||
}
|
||||
else if (day > 0)
|
||||
{
|
||||
return day + " day" + (day > 1 ? "s" : "");
|
||||
}
|
||||
else if (hour > 0)
|
||||
{
|
||||
return hour + " hour" + (hour > 1 ? "s" : "");
|
||||
}
|
||||
else if (minute > 0)
|
||||
{
|
||||
return minute + " minute" + (minute > 1 ? "s" : "");
|
||||
}
|
||||
else
|
||||
{
|
||||
return seconds + " second" + (seconds > 1 ? "s" : "");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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.getHead());
|
||||
distance = fetchDistanceFromGitHub(REPO, BRANCH, BuildInfo.getCommit());
|
||||
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.getHead());
|
||||
distance = fetchDistanceFromGitHub(REPO, BRANCH, BuildInfo.getCommit());
|
||||
PlexLog.debug("We have checked for updates before, but this request was not asked to be cached.");
|
||||
}
|
||||
else
|
||||
|
@ -2,6 +2,7 @@ package dev.plex.util.sql;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import dev.plex.punishment.PunishmentType;
|
||||
import dev.plex.storage.annotation.*;
|
||||
import dev.plex.util.PlexLog;
|
||||
@ -13,10 +14,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -25,7 +23,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class SQLUtil
|
||||
{
|
||||
public static final List<Table> TABLES = Lists.newArrayList();
|
||||
public static final Map<String, Table> TABLES = Maps.newHashMap();
|
||||
|
||||
public static List<String> createTable(List<String> result, Class<?> clazz)
|
||||
{
|
||||
@ -83,7 +81,7 @@ public class SQLUtil
|
||||
mainResult.append(");");
|
||||
result.add(mainResult.toString());
|
||||
|
||||
TABLES.add(table);
|
||||
TABLES.put(table.name(), table);
|
||||
|
||||
if (primaryKey == null && !collectionFields.isEmpty())
|
||||
{
|
||||
@ -113,11 +111,22 @@ public class SQLUtil
|
||||
writeFieldToSQL(listTable, sql, Mapper.getByClass(finalPrimaryKey.getType()), finalPrimaryKey);
|
||||
sql.append(");");
|
||||
result.add(sql.toString());
|
||||
table.mappedTables().add(listTable);
|
||||
table.mappedTables().put(field, listTable);
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
public static void update(String tableName, Object object)
|
||||
{
|
||||
final Table table = TABLES.get(tableName);
|
||||
if (table == null)
|
||||
{
|
||||
PlexLog.error("Table {0} was not found", tableName);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static void writeFieldToSQL(Table table, StringBuilder sb, Mapper mapped, Field field)
|
||||
{
|
||||
|
||||
|
@ -5,6 +5,7 @@ import com.google.common.collect.Maps;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -19,5 +20,5 @@ public class Table
|
||||
{
|
||||
private final String name;
|
||||
private final Map<String, SQLUtil.Mapper> columns = Maps.newHashMap();
|
||||
private final List<Table> mappedTables = Lists.newArrayList();
|
||||
private final Map<Field, Table> mappedTables = Maps.newHashMap();
|
||||
}
|
||||
|
7
server/src/main/resource-templates/build-vars.properties
Normal file
7
server/src/main/resource-templates/build-vars.properties
Normal file
@ -0,0 +1,7 @@
|
||||
author={{ author | default("unknown") }}
|
||||
|
||||
buildNumber={{ buildNumber | default("unknown") }}
|
||||
|
||||
date={{ date }}
|
||||
|
||||
gitCommit={{ gitCommit | default("unknown") }}
|
@ -54,7 +54,7 @@ commands:
|
||||
- "r:a:^(co|core|coreprotect) (rb|rollback|l|lookup|rl|reload):_"
|
||||
- "r:e:^[A-z]*:[A-z]*::<gray>Plugin specific commands are disabled."
|
||||
|
||||
# These commands will be blocked when a player is muted
|
||||
# These commands will be blocked when a player is muted or when chat is toggled off.
|
||||
block_on_mute:
|
||||
- me
|
||||
- say
|
||||
|
@ -14,6 +14,10 @@ server:
|
||||
banning:
|
||||
ban_url: "https://forum.plex.us.org"
|
||||
|
||||
punishments:
|
||||
mute-timer: 300
|
||||
freeze-timer: 300
|
||||
|
||||
chat:
|
||||
# Should the server use Plex's chat system? It is recommended to keep this on if you are using ranks.
|
||||
# If you are using permissions, you should turn this off and use Vault to handle prefixes with a different chat plugin
|
||||
@ -152,6 +156,15 @@ blocked_entities:
|
||||
- "ENDER_DRAGON"
|
||||
- "MINECART_TNT"
|
||||
|
||||
# Limit entities per chunk
|
||||
entity_limit:
|
||||
# Is the mob limit enabled?
|
||||
mob_limit_enabled: true
|
||||
# The maximum number of mobs allowed in a chunk
|
||||
max_mobs_per_chunk: 50
|
||||
# The available ceiling for the maximum number of mobs
|
||||
mob_limit_ceiling: 500
|
||||
|
||||
# See https://docs.plex.us.org/docs/customization/config#worlds for documentation
|
||||
# These gamerules apply to all worlds on the server
|
||||
global_gamerules:
|
||||
|
@ -27,6 +27,8 @@ indefBanMessageReason: "<red>Your {0} is indefinitely banned! You may appeal at
|
||||
playerNotFound: "<red>Player not found!"
|
||||
specifyPlayer: "<red>You must specify a player!"
|
||||
worldNotFound: "<red>World not found!"
|
||||
# This will always be used for punishments where the sanctioning administrator has not provided a reason. Will ignore MiniMessage tags.
|
||||
noReasonProvided: "No reason provided."
|
||||
# 0 - The world you have been teleported to
|
||||
playerWorldTeleport: "<aqua>You have been teleported to {0}."
|
||||
# 0 - The person who is freezing
|
||||
@ -41,6 +43,13 @@ mutedPlayer: "<red>{0} - Muted {1}"
|
||||
# 0 - The command sender
|
||||
# 1 - The person who has been unmuted
|
||||
unmutedPlayer: "<aqua>{0} - Unmuted {1}"
|
||||
invalidTimeFormat: "<red>Invalid time format. Use s, m, h, d, w, mo, or y (e.g., 1h30m)."
|
||||
timeMustBeFuture: "<red>The specified time must be in the future."
|
||||
# 0 - The command sender
|
||||
# 1 - The person who has been muted
|
||||
# 2 - The time that the person is muted for
|
||||
tempMutedPlayer: "<red>{0} - Muted {1} for {2}"
|
||||
maxTimeExceeded: "<red>The specified time must be under a week."
|
||||
# 0 - The person who is locking up
|
||||
# 1 - The person who has been locked up
|
||||
lockedUpPlayer: "<aqua>{0} - Locking up {1}"
|
||||
@ -110,6 +119,11 @@ playerFrozen: "<red>That player is already frozen!"
|
||||
playerMuted: "<red>That player is already muted!"
|
||||
playerLockedUp: "<red>That player is already locked up!"
|
||||
muted: "<red>You are currently muted - STFU!"
|
||||
pvpDisabled: "<red>PVP has been disabled!"
|
||||
chatIsOff: "<red>Chat is currently toggled off!"
|
||||
# 0 - The command sender
|
||||
# 1 - The set value of the chat toggle
|
||||
chatToggled: "<red>{0} - Toggled chat {1}"
|
||||
# 0 - The command sender
|
||||
# 1 - The player
|
||||
kickedPlayer: "<red>{0} - Kicking {1}"
|
||||
@ -160,10 +174,27 @@ 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"
|
||||
autoWipeDisabled: "<gray>Item wiping is currently disabled in the config!"
|
||||
# 0 - The boolean for whether the limit is enabled or disabled
|
||||
mobLimitToggle: "<gray>The mob limit has been {0}"
|
||||
# 0 - The amount that the mob limit has been set to
|
||||
mobLimitSet: "<gray>The mob limit has been set to: <em><white>{0}"
|
||||
# 0 - The boolean for whether the limit is enabled or disabled
|
||||
# 1 - The current amount of mobs in the world
|
||||
# 2 - The current set mob limit
|
||||
# 3 - Chunk x value
|
||||
# 4 - Chunk z value
|
||||
mobLimitStatus: "<gray>({0}<gray>) <em><white>{1} <reset><gray>/ <em><white>{2} <reset><gray>per chunk (<em><white>Chunk<gray>: <reset>{3}, {4}<gray>)"
|
||||
# 0 - The max set limit in config
|
||||
mobLimitCeiling: "<gray>The limit you have entered is too high. Defaulting to the ceiling value from config"
|
||||
commandBlocked: "<gray>That command is blocked."
|
||||
# 0 - The command sender
|
||||
# 1 - The message being said
|
||||
@ -195,6 +226,57 @@ rankRequired: "<red>Policy requires that you must state your rank in your login
|
||||
# 0 - The material name
|
||||
# 1 - The players who have the material in their inventory
|
||||
playersWithMaterial: "<gray>Players with {0} in their inventory: {1}"
|
||||
# 0 - The material name
|
||||
# 1 - The players who have the material in their inventory
|
||||
playersMaterialCleared: "<gray>{0} has been removed from the following players: {1}"
|
||||
nobodyHasThatMaterial: "<gray>No one online has that in their inventory."
|
||||
# 0 - The attempted material name
|
||||
materialNotFound: "<red>{0} is not a valid item/block name."
|
||||
# 0 - The players name
|
||||
loginMessage: "<yellow>{0} joined the game"
|
||||
# 0 - The string that wasn't a valid integer
|
||||
notANumber: "<red>{0} is not a valid number!"
|
||||
# 0 - Players currently online
|
||||
# 1 - Max players
|
||||
listHeader: "<gray>There is currently <yellow>{0}<gray> player online out of <yellow>{1}<gray> players."
|
||||
# 0 - Players currently online
|
||||
# 1 - Max players
|
||||
listHeaderPlural: "<gray>There are currently <yellow>{0}<gray> players online out of <yellow>{1}<gray> players."
|
||||
# 0 - Player who is having their notes fetched
|
||||
notesHeader: "Player notes for: <green>{0}"
|
||||
# 0 - Note ID
|
||||
# 1 - Author of the note
|
||||
# 2 - Timestamp
|
||||
notePrefix: "<gold><!italic>{0} - Written by: {1} on {2}"
|
||||
# 0 - The content of the note
|
||||
noteLine: "<newline><yellow># {0}"
|
||||
# 0 - The player
|
||||
# 1 - The number of notes logged for said player
|
||||
playerNoteAlert: "<gold>{0} has {1} note. <click:run_command:/notes {0} list><underlined>Click here to view their note."
|
||||
# 0 - The player
|
||||
# 1 - The number of notes logged for said player
|
||||
playerNoteAlertPlural: "<gold>{0} has {1} notes. <click:run_command:/notes {0} list><underlined>Click here to view their notes."
|
||||
smiteTitleHeader: "<red>You've been smitten."
|
||||
# 0 - The reason for the smite. Will default to noReasonProvided if no reason is specified.
|
||||
# 1 - The admin / staff member
|
||||
smiteTitleMessage: "<yellow>Be sure to follow the rules!"
|
||||
# 0 - The player
|
||||
# 1 - The reason for the smite. Will default to noReasonProvided if no reason is specified.
|
||||
# 2 - The admin / staff member
|
||||
smiteBroadcast: "<red>{0} has been a naughty, naughty boy.<newline><red> - Reason: <yellow>{1}<newline><red> - Smitten by: <yellow>{2}"
|
||||
# 0 - The player
|
||||
smittenQuietly: "<gray>Smitten {0} quietly."
|
||||
# 0 - The reason for being smitten
|
||||
smitten: "<red>You've been smitten. Reason: <yellow>{0}"
|
||||
nukerKickMessage: "Please turn off your nuker!"
|
||||
antiSpamMessage: "<gray>Please refrain from spamming messages."
|
||||
# 0 - The player
|
||||
banExpiredBroadcast: "Plex - Automatically unbanning {0}"
|
||||
# 0 - The player
|
||||
redisResetSuccessful: "<yellow>Successfuly reset {0}'s Redis punishments!"
|
||||
redisResetPlayerNotFound: "Couldn't find player in Redis punishments."
|
||||
reappliedGamerules: "<aqua>All game rules have been re-applied!"
|
||||
commandNotFound: "<red>That command could not be found!"
|
||||
# 0 - The command
|
||||
# 1 - A list of aliases found
|
||||
commandAliases: "<aqua>Aliases for {0} are: {1}"
|
@ -11,3 +11,9 @@ drops: true
|
||||
|
||||
# Should redstone be enabled?
|
||||
redstone: true
|
||||
|
||||
# Is chat enabled?
|
||||
chat: true
|
||||
|
||||
# Is PVP enabled?
|
||||
pvp: true
|
||||
|
@ -1,4 +0,0 @@
|
||||
rootProject.name = "Plex"
|
||||
include 'server'
|
||||
include 'proxy'
|
||||
|
2
settings.gradle.kts
Normal file
2
settings.gradle.kts
Normal file
@ -0,0 +1,2 @@
|
||||
rootProject.name = "Plex"
|
||||
include("server", "proxy")
|
Reference in New Issue
Block a user