mirror of
https://github.com/plexusorg/Plex.git
synced 2025-07-05 00:56:42 +00:00
Compare commits
1 Commits
server
...
velocity-4
Author | SHA1 | Date | |
---|---|---|---|
60b32b05f1 |
1
Jenkinsfile
vendored
1
Jenkinsfile
vendored
@ -14,7 +14,6 @@ pipeline {
|
|||||||
archiveArtifacts artifacts: "build/libs/*.jar", fingerprint: true
|
archiveArtifacts artifacts: "build/libs/*.jar", fingerprint: true
|
||||||
javadoc javadocDir: "server/build/docs/javadoc", keepAll: false
|
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.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()
|
cleanWs()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
72
build.gradle
Normal file
72
build.gradle
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
plugins {
|
||||||
|
id "java"
|
||||||
|
id "maven-publish"
|
||||||
|
id "com.github.johnrengelman.shadow" version "8.1.1"
|
||||||
|
}
|
||||||
|
|
||||||
|
group = "dev.plex"
|
||||||
|
version = "1.4-SNAPSHOT"
|
||||||
|
description = "Plex"
|
||||||
|
|
||||||
|
subprojects {
|
||||||
|
apply plugin: "java"
|
||||||
|
apply plugin: "maven-publish"
|
||||||
|
apply plugin: "com.github.johnrengelman.shadow"
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
url = uri("https://repo.papermc.io/repository/maven-public/")
|
||||||
|
}
|
||||||
|
|
||||||
|
maven {
|
||||||
|
url = uri("https://repository.apache.org/content/repositories/snapshots/")
|
||||||
|
}
|
||||||
|
|
||||||
|
maven {
|
||||||
|
url = uri("https://repo.maven.apache.org/maven2/")
|
||||||
|
}
|
||||||
|
|
||||||
|
maven {
|
||||||
|
url = uri("https://jitpack.io")
|
||||||
|
content {
|
||||||
|
includeGroup("com.github.MilkBowl")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile) {
|
||||||
|
options.encoding = "UTF-8"
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
def releasesRepoUrl = uri("https://nexus.telesphoreo.me/repository/plex-releases/")
|
||||||
|
def snapshotsRepoUrl = uri("https://nexus.telesphoreo.me/repository/plex-snapshots/")
|
||||||
|
url = rootProject.version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
|
||||||
|
credentials {
|
||||||
|
username = System.getenv("plexUser")
|
||||||
|
password = System.getenv("plexPassword")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
clean {
|
||||||
|
dependsOn(":server:clean")
|
||||||
|
dependsOn(":proxy:clean")
|
||||||
|
}
|
||||||
|
|
||||||
|
task copyJars(type: Copy, dependsOn: subprojects.jar) {
|
||||||
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||||
|
from(subprojects.jar)
|
||||||
|
from(subprojects.shadowJar)
|
||||||
|
into project.file('build/libs')
|
||||||
|
}
|
@ -1,91 +0,0 @@
|
|||||||
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
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
|
plugins {
|
||||||
|
id("org.jetbrains.gradle.plugin.idea-ext") version "1.1.7"
|
||||||
|
id("net.kyori.blossom") version "2.1.0"
|
||||||
|
}
|
||||||
|
|
||||||
group = rootProject.group
|
group = rootProject.group
|
||||||
version = rootProject.version
|
version = rootProject.version
|
||||||
description = "Plex-Velocity"
|
description = "Plex-Velocity"
|
||||||
@ -39,9 +44,10 @@ publishing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("org.projectlombok:lombok:1.18.32")
|
compileOnly("org.projectlombok:lombok:1.18.30")
|
||||||
annotationProcessor("org.projectlombok:lombok:1.18.32")
|
annotationProcessor("org.projectlombok:lombok:1.18.30")
|
||||||
compileOnly("org.json:json:20240303")
|
compileOnly("org.json:json:20231013")
|
||||||
compileOnly("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT")
|
implementation("net.kyori:adventure-text-minimessage:4.14.0")
|
||||||
annotationProcessor("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT")
|
compileOnly("com.velocitypowered:velocity-api:4.0.0-SNAPSHOT")
|
||||||
|
annotationProcessor("com.velocitypowered:velocity-api:4.0.0-SNAPSHOT")
|
||||||
}
|
}
|
@ -2,7 +2,7 @@ package dev.plex;
|
|||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
import com.velocitypowered.api.event.lifecycle.ProxyInitializeEvent;
|
||||||
import com.velocitypowered.api.plugin.Plugin;
|
import com.velocitypowered.api.plugin.Plugin;
|
||||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
@ -28,7 +28,7 @@ import java.util.logging.Logger;
|
|||||||
@Plugin(
|
@Plugin(
|
||||||
name = "Plex",
|
name = "Plex",
|
||||||
id = "plex",
|
id = "plex",
|
||||||
version = BuildParameters.VERSION,
|
version = "{{ version }}",
|
||||||
url = "https://plex.us.org",
|
url = "https://plex.us.org",
|
||||||
description = "Plex provides a new experience for freedom servers.",
|
description = "Plex provides a new experience for freedom servers.",
|
||||||
authors = {"Telesphoreo", "Taah"}
|
authors = {"Telesphoreo", "Taah"}
|
||||||
|
@ -2,9 +2,9 @@ package dev.plex.command;
|
|||||||
|
|
||||||
import com.velocitypowered.api.command.CommandMeta;
|
import com.velocitypowered.api.command.CommandMeta;
|
||||||
import com.velocitypowered.api.command.CommandSource;
|
import com.velocitypowered.api.command.CommandSource;
|
||||||
|
import com.velocitypowered.api.command.ConsoleCommandSource;
|
||||||
import com.velocitypowered.api.command.SimpleCommand;
|
import com.velocitypowered.api.command.SimpleCommand;
|
||||||
import com.velocitypowered.api.proxy.ConsoleCommandSource;
|
import com.velocitypowered.api.proxy.connection.Player;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
@ -43,10 +43,9 @@ public abstract class PlexCommand implements SimpleCommand
|
|||||||
this.perms = getClass().getAnnotation(CommandPermissions.class);
|
this.perms = getClass().getAnnotation(CommandPermissions.class);
|
||||||
this.commandSource = this.perms.source();
|
this.commandSource = this.perms.source();
|
||||||
|
|
||||||
CommandMeta.Builder meta = plugin.getServer().getCommandManager().metaBuilder(this.params.name());
|
CommandMeta.Builder meta = plugin.getServer().commandManager().createMetaBuilder(this.params.name());
|
||||||
meta.aliases(this.params.aliases());
|
meta.aliases(this.params.aliases());
|
||||||
meta.plugin(Plex.get());
|
plugin.getServer().commandManager().register(meta.build(), this);
|
||||||
plugin.getServer().getCommandManager().register(meta.build(), this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract Component execute(@NotNull CommandSource source, @Nullable Player player, @NotNull String[] args);
|
protected abstract Component execute(@NotNull CommandSource source, @Nullable Player player, @NotNull String[] args);
|
||||||
|
@ -8,6 +8,6 @@ public class PlexListener
|
|||||||
|
|
||||||
public PlexListener()
|
public PlexListener()
|
||||||
{
|
{
|
||||||
Plex.get().getServer().getEventManager().register(Plex.get(), this);
|
Plex.get().getServer().eventManager().register(Plex.get(), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package dev.plex.listener.impl;
|
|||||||
|
|
||||||
import com.velocitypowered.api.event.PostOrder;
|
import com.velocitypowered.api.event.PostOrder;
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
import com.velocitypowered.api.event.connection.DisconnectEvent;
|
import com.velocitypowered.api.event.player.DisconnectEvent;
|
||||||
import com.velocitypowered.api.event.player.ServerConnectedEvent;
|
import com.velocitypowered.api.event.player.ServerConnectedEvent;
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
@ -14,27 +14,27 @@ public class ConnectionListener extends PlexListener
|
|||||||
@Subscribe(order = PostOrder.FIRST)
|
@Subscribe(order = PostOrder.FIRST)
|
||||||
public void onPlayerJoin(ServerConnectedEvent event)
|
public void onPlayerJoin(ServerConnectedEvent event)
|
||||||
{
|
{
|
||||||
if (event.getPreviousServer().isPresent())
|
if (event.previousServer() != null)
|
||||||
{
|
{
|
||||||
Plex.get().server.sendMessage(miniMessage("<dark_gray>[<#ffbf00>o<dark_gray>] <yellow>"
|
Plex.get().server.sendMessage(miniMessage("<dark_gray>[<#ffbf00>o<dark_gray>] <yellow>"
|
||||||
+ event.getPlayer().getUsername() + " switched from " + event.getPreviousServer().get().getServerInfo().getName()
|
+ event.player().username() + " switched from " + event.previousServer().serverInfo().name()
|
||||||
+ " to " + event.getServer().getServerInfo().getName()));
|
+ " to " + event.target().serverInfo().name()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Plex.get().server.sendMessage(miniMessage("<dark_gray>[<green>+<dark_gray>] <yellow>"
|
Plex.get().server.sendMessage(miniMessage("<dark_gray>[<green>+<dark_gray>] <yellow>"
|
||||||
+ event.getPlayer().getUsername() + " joined server " + event.getServer().getServerInfo().getName()));
|
+ event.player().username() + " joined server " + event.target().serverInfo().name()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(order = PostOrder.FIRST)
|
@Subscribe(order = PostOrder.FIRST)
|
||||||
public void onPlayerLeave(DisconnectEvent event)
|
public void onPlayerLeave(DisconnectEvent event)
|
||||||
{
|
{
|
||||||
if (event.getPlayer().getCurrentServer().isPresent())
|
if (event.player().connectedServer() != null)
|
||||||
{
|
{
|
||||||
Plex.get().server.sendMessage(miniMessage("<dark_gray>[<red>-<dark_gray>] <yellow>"
|
Plex.get().server.sendMessage(miniMessage("<dark_gray>[<red>-<dark_gray>] <yellow>"
|
||||||
+ event.getPlayer().getUsername() + " left server " +
|
+ event.player().username() + " left server " +
|
||||||
event.getPlayer().getCurrentServer().get().getServerInfo().getName()));
|
event.player().connectedServer().serverInfo().name()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package dev.plex.listener.impl;
|
|||||||
|
|
||||||
import com.velocitypowered.api.event.PostOrder;
|
import com.velocitypowered.api.event.PostOrder;
|
||||||
import com.velocitypowered.api.event.Subscribe;
|
import com.velocitypowered.api.event.Subscribe;
|
||||||
import com.velocitypowered.api.event.proxy.ProxyPingEvent;
|
import com.velocitypowered.api.event.connection.ProxyPingEvent;
|
||||||
import com.velocitypowered.api.proxy.server.ServerPing;
|
import com.velocitypowered.api.proxy.server.ServerPing;
|
||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.settings.ServerSettings;
|
import dev.plex.settings.ServerSettings;
|
||||||
@ -24,10 +24,10 @@ public class ServerListener extends PlexListener
|
|||||||
String baseMotd = plugin.getConfig().as(ServerSettings.class).getServer().getMotd().get(ThreadLocalRandom.current().nextInt(plugin.getConfig().as(ServerSettings.class).getServer().getMotd().size()));
|
String baseMotd = plugin.getConfig().as(ServerSettings.class).getServer().getMotd().get(ThreadLocalRandom.current().nextInt(plugin.getConfig().as(ServerSettings.class).getServer().getMotd().size()));
|
||||||
baseMotd = baseMotd.replace("\\n", "\n");
|
baseMotd = baseMotd.replace("\\n", "\n");
|
||||||
baseMotd = baseMotd.replace("%servername%", plugin.getConfig().as(ServerSettings.class).getServer().getName());
|
baseMotd = baseMotd.replace("%servername%", plugin.getConfig().as(ServerSettings.class).getServer().getName());
|
||||||
baseMotd = baseMotd.replace("%mcversion%", plugin.getServer().getVersion().getVersion().split(" ")[0]);
|
baseMotd = baseMotd.replace("%mcversion%", plugin.getServer().version().version().split(" ")[0]);
|
||||||
baseMotd = baseMotd.replace("%randomgradient%", "<gradient:" + RandomUtil.getRandomColor().toString() + ":" + RandomUtil.getRandomColor().toString() + ">");
|
baseMotd = baseMotd.replace("%randomgradient%", "<gradient:" + RandomUtil.getRandomColor().toString() + ":" + RandomUtil.getRandomColor().toString() + ">");
|
||||||
|
|
||||||
ServerPing.Builder builder = event.getPing().asBuilder();
|
ServerPing.Builder builder = event.ping().asBuilder();
|
||||||
|
|
||||||
if (plugin.getConfig().as(ServerSettings.class).getServer().isColorizeMotd())
|
if (plugin.getConfig().as(ServerSettings.class).getServer().isColorizeMotd())
|
||||||
{
|
{
|
||||||
@ -45,7 +45,7 @@ public class ServerListener extends PlexListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
builder.samplePlayers(plugin.getConfig().as(ServerSettings.class).getServer().getSample().stream().map(s -> new ServerPing.SamplePlayer(convertColorCodes(s), UUID.randomUUID())).toArray(ServerPing.SamplePlayer[]::new));
|
builder.samplePlayers(plugin.getConfig().as(ServerSettings.class).getServer().getSample().stream().map(s -> new ServerPing.SamplePlayer(convertColorCodes(s), UUID.randomUUID())).toArray(ServerPing.SamplePlayer[]::new));
|
||||||
builder.onlinePlayers(plugin.getServer().getPlayerCount() + plugin.getConfig().as(ServerSettings.class).getServer().getAddPlayerCount());
|
builder.onlinePlayers(plugin.getServer().countConnectedPlayers() + plugin.getConfig().as(ServerSettings.class).getServer().getAddPlayerCount());
|
||||||
if (plugin.getConfig().as(ServerSettings.class).getServer().isPlusOneMaxPlayer())
|
if (plugin.getConfig().as(ServerSettings.class).getServer().isPlusOneMaxPlayer())
|
||||||
{
|
{
|
||||||
builder.maximumPlayers(builder.getOnlinePlayers() + 1);
|
builder.maximumPlayers(builder.getOnlinePlayers() + 1);
|
||||||
|
@ -17,12 +17,12 @@ public class PlexLog
|
|||||||
message = message.replace("{" + i + "}", strings[i].toString());
|
message = message.replace("{" + i + "}", strings[i].toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Plex.get().getServer().getConsoleCommandSource().sendMessage(MiniMessage.miniMessage().deserialize("<yellow>[Plex] <gray>" + message));
|
Plex.get().getServer().consoleCommandSource().sendMessage(MiniMessage.miniMessage().deserialize("<yellow>[Plex] <gray>" + message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(Component component)
|
public static void log(Component component)
|
||||||
{
|
{
|
||||||
Plex.get().getServer().getConsoleCommandSource().sendMessage(Component.text("[Plex] ").color(NamedTextColor.YELLOW).append(component).colorIfAbsent(NamedTextColor.GRAY));
|
Plex.get().getServer().consoleCommandSource().sendMessage(Component.text("[Plex] ").color(NamedTextColor.YELLOW).append(component).colorIfAbsent(NamedTextColor.GRAY));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void error(String message, Object... strings)
|
public static void error(String message, Object... strings)
|
||||||
@ -34,7 +34,7 @@ public class PlexLog
|
|||||||
message = message.replace("{" + i + "}", strings[i].toString());
|
message = message.replace("{" + i + "}", strings[i].toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Plex.get().getServer().getConsoleCommandSource().sendMessage(MiniMessage.miniMessage().deserialize("<red>[Plex Error] <gold>" + message));
|
Plex.get().getServer().consoleCommandSource().sendMessage(MiniMessage.miniMessage().deserialize("<red>[Plex Error] <gold>" + message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void warn(String message, Object... strings)
|
public static void warn(String message, Object... strings)
|
||||||
@ -46,7 +46,7 @@ public class PlexLog
|
|||||||
message = message.replace("{" + i + "}", strings[i].toString());
|
message = message.replace("{" + i + "}", strings[i].toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Plex.get().getServer().getConsoleCommandSource().sendMessage(MiniMessage.miniMessage().deserialize("<#eb7c0e>[Plex Warning] <gold>" + message));
|
Plex.get().getServer().consoleCommandSource().sendMessage(MiniMessage.miniMessage().deserialize("<#eb7c0e>[Plex Warning] <gold>" + message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void debug(String message, Object... strings)
|
public static void debug(String message, Object... strings)
|
||||||
@ -60,7 +60,7 @@ public class PlexLog
|
|||||||
}
|
}
|
||||||
if (Plex.get().getConfig().as(ServerSettings.class).getServer().isDebug())
|
if (Plex.get().getConfig().as(ServerSettings.class).getServer().isDebug())
|
||||||
{
|
{
|
||||||
Plex.get().getServer().getConsoleCommandSource().sendMessage(MiniMessage.miniMessage().deserialize("<dark_purple>[Plex Debug] <gold>" + message));
|
Plex.get().getServer().consoleCommandSource().sendMessage(MiniMessage.miniMessage().deserialize("<dark_purple>[Plex Debug] <gold>" + message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
154
server/build.gradle
Normal file
154
server/build.gradle
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
plugins {
|
||||||
|
id "net.minecrell.plugin-yml.paper" version "0.6.0"
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
library "org.projectlombok:lombok:1.18.30"
|
||||||
|
annotationProcessor "org.projectlombok:lombok:1.18.30"
|
||||||
|
library "org.json:json:20231013"
|
||||||
|
library "commons-io:commons-io:2.15.0"
|
||||||
|
library "redis.clients:jedis:5.0.2"
|
||||||
|
library "org.mariadb.jdbc:mariadb-java-client:3.2.0"
|
||||||
|
library "com.zaxxer:HikariCP:5.0.1"
|
||||||
|
library "org.apache.maven.resolver:maven-resolver-transport-http:1.9.16"
|
||||||
|
library "org.jetbrains:annotations:24.0.1"
|
||||||
|
compileOnly "dev.folia:folia-api:1.20.1-R0.1-SNAPSHOT"
|
||||||
|
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1") {
|
||||||
|
exclude group: "org.bukkit", module: "bukkit"
|
||||||
|
}
|
||||||
|
implementation "org.bstats:bstats-base:3.0.2"
|
||||||
|
implementation "org.bstats:bstats-bukkit:3.0.2"
|
||||||
|
}
|
||||||
|
|
||||||
|
group = rootProject.group
|
||||||
|
version = rootProject.version
|
||||||
|
description = "Plex-Server"
|
||||||
|
|
||||||
|
shadowJar {
|
||||||
|
archiveBaseName.set("Plex")
|
||||||
|
archiveClassifier.set("")
|
||||||
|
relocate "org.bstats", "dev.plex"
|
||||||
|
}
|
||||||
|
|
||||||
|
paper {
|
||||||
|
name = "Plex"
|
||||||
|
version = project.version
|
||||||
|
description = "Plex provides a new experience for freedom servers."
|
||||||
|
main = "dev.plex.Plex"
|
||||||
|
loader = "dev.plex.PlexLibraryManager"
|
||||||
|
website = "https://plex.us.org"
|
||||||
|
authors = ["Telesphoreo", "taahanis", "supernt"]
|
||||||
|
apiVersion = "1.19"
|
||||||
|
foliaSupported = true
|
||||||
|
generateLibrariesJson = true
|
||||||
|
// Load BukkitTelnet and LibsDisguises before Plex so the modules register properly
|
||||||
|
serverDependencies {
|
||||||
|
'BukkitTelnet' {
|
||||||
|
required = false
|
||||||
|
load = 'BEFORE'
|
||||||
|
}
|
||||||
|
'LibsDisguises' {
|
||||||
|
required = false
|
||||||
|
load = 'BEFORE'
|
||||||
|
}
|
||||||
|
'Vault' {
|
||||||
|
required = false
|
||||||
|
load = 'BEFORE'
|
||||||
|
}
|
||||||
|
'Essentials' {
|
||||||
|
required = false
|
||||||
|
load = 'BEFORE'
|
||||||
|
}
|
||||||
|
'SlimeWorldManager' {
|
||||||
|
required = false
|
||||||
|
load = 'AFTER'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String getGitHash() {
|
||||||
|
def stdout = new ByteArrayOutputStream()
|
||||||
|
try {
|
||||||
|
exec {
|
||||||
|
commandLine "git", "rev-parse", "--short", "HEAD"
|
||||||
|
standardOutput = stdout
|
||||||
|
ignoreExitValue = true
|
||||||
|
}
|
||||||
|
} catch (GradleException e) {
|
||||||
|
logger.error("Couldn't determine Git head because Git is not installed. " + e.getMessage())
|
||||||
|
}
|
||||||
|
return stdout.size() > 0 ? stdout.toString().trim() : "unknown"
|
||||||
|
}
|
||||||
|
|
||||||
|
String getBuildNumber() {
|
||||||
|
def stdout = new ByteArrayOutputStream()
|
||||||
|
try {
|
||||||
|
exec {
|
||||||
|
commandLine "git", "rev-list", "HEAD", "--count"
|
||||||
|
standardOutput = stdout
|
||||||
|
ignoreExitValue = true
|
||||||
|
}
|
||||||
|
} catch (GradleException e) {
|
||||||
|
logger.error("Couldn't determine build number because Git is not installed. " + e.getMessage())
|
||||||
|
}
|
||||||
|
return stdout.size() ? stdout.toString().trim() + " (local)" : "unknown"
|
||||||
|
}
|
||||||
|
|
||||||
|
static def getDate() {
|
||||||
|
return new Date().format("MM/dd/yyyy '<light_purple>at<gold>' hh:mm:ss a z")
|
||||||
|
}
|
||||||
|
|
||||||
|
task buildProperties {
|
||||||
|
ant.propertyfile(file: "$project.projectDir/src/main/resources/build.properties") {
|
||||||
|
entry(key: "buildAuthor", default: System.getenv("JENKINS_URL") != null ? "jenkins" : "unknown")
|
||||||
|
entry(key: "buildNumber", value: System.getenv("JENKINS_URL") != null ? System.getenv("BUILD_NUMBER") + " (Jenkins)" : getBuildNumber())
|
||||||
|
entry(key: "buildDate", value: getDate())
|
||||||
|
entry(key: "buildHead", value: getGitHash())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks {
|
||||||
|
build {
|
||||||
|
dependsOn(shadowJar)
|
||||||
|
finalizedBy(buildProperties)
|
||||||
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
enabled = false
|
||||||
|
}
|
||||||
|
|
||||||
|
shadowJar {
|
||||||
|
finalizedBy(rootProject.tasks.copyJars)
|
||||||
|
}
|
||||||
|
|
||||||
|
javadoc {
|
||||||
|
options.memberLevel = JavadocMemberLevel.PRIVATE
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
maven(MavenPublication) {
|
||||||
|
pom.withXml {
|
||||||
|
def dependenciesNode = asNode().appendNode("dependencies")
|
||||||
|
configurations.getByName("library").getAllDependencies().each { dependency ->
|
||||||
|
dependenciesNode.appendNode("dependency").with {
|
||||||
|
it.appendNode("groupId", dependency.group)
|
||||||
|
it.appendNode("artifactId", dependency.name)
|
||||||
|
it.appendNode("version", dependency.version)
|
||||||
|
it.appendNode("scope", "provided")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
configurations.getByName("implementation").getAllDependencies().each { dependency ->
|
||||||
|
dependenciesNode.appendNode("dependency").with {
|
||||||
|
it.appendNode("groupId", dependency.group)
|
||||||
|
it.appendNode("artifactId", dependency.name)
|
||||||
|
it.appendNode("version", dependency.version)
|
||||||
|
it.appendNode("scope", "runtime")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
artifacts = [shadowJar]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,168 +0,0 @@
|
|||||||
import net.minecrell.pluginyml.paper.PaperPluginDescription
|
|
||||||
import java.io.ByteArrayOutputStream
|
|
||||||
import java.text.SimpleDateFormat
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
id("net.kyori.indra.git") version "3.1.3"
|
|
||||||
id("net.minecrell.plugin-yml.paper") version "0.6.0"
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
maven(url = uri("https://maven.playpro.com"))
|
|
||||||
maven(url = uri("https://nexus.telesphoreo.me/repository/plex-modules/"))
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
library("org.projectlombok:lombok:1.18.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,12 +1,11 @@
|
|||||||
package dev.plex;
|
package dev.plex;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
import dev.plex.cache.DataUtils;
|
import dev.plex.cache.DataUtils;
|
||||||
import dev.plex.cache.PlayerCache;
|
import dev.plex.cache.PlayerCache;
|
||||||
import dev.plex.config.Config;
|
import dev.plex.config.Config;
|
||||||
import dev.plex.handlers.CommandHandler;
|
import dev.plex.handlers.CommandHandler;
|
||||||
import dev.plex.handlers.ListenerHandler;
|
import dev.plex.handlers.ListenerHandler;
|
||||||
import dev.plex.hook.CoreProtectHook;
|
|
||||||
import dev.plex.hook.PrismHook;
|
|
||||||
import dev.plex.module.ModuleManager;
|
import dev.plex.module.ModuleManager;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.punishment.PunishmentManager;
|
import dev.plex.punishment.PunishmentManager;
|
||||||
@ -17,23 +16,22 @@ import dev.plex.storage.StorageType;
|
|||||||
import dev.plex.storage.player.SQLPlayerData;
|
import dev.plex.storage.player.SQLPlayerData;
|
||||||
import dev.plex.storage.punishment.SQLNotes;
|
import dev.plex.storage.punishment.SQLNotes;
|
||||||
import dev.plex.storage.punishment.SQLPunishment;
|
import dev.plex.storage.punishment.SQLPunishment;
|
||||||
import dev.plex.util.BuildInfo;
|
import dev.plex.util.*;
|
||||||
import dev.plex.util.BungeeUtil;
|
|
||||||
import dev.plex.util.PlexLog;
|
|
||||||
import dev.plex.util.PlexUtils;
|
|
||||||
import dev.plex.util.UpdateChecker;
|
|
||||||
import dev.plex.util.redis.MessageUtil;
|
import dev.plex.util.redis.MessageUtil;
|
||||||
|
import dev.plex.util.sql.SQLUtil;
|
||||||
import dev.plex.world.CustomWorld;
|
import dev.plex.world.CustomWorld;
|
||||||
import java.io.File;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import net.milkbowl.vault.chat.Chat;
|
import net.milkbowl.vault.chat.Chat;
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bstats.bukkit.Metrics;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
public class Plex extends JavaPlugin
|
public class Plex extends JavaPlugin
|
||||||
@ -48,6 +46,7 @@ public class Plex extends JavaPlugin
|
|||||||
public File modulesFolder;
|
public File modulesFolder;
|
||||||
private StorageType storageType = StorageType.SQLITE;
|
private StorageType storageType = StorageType.SQLITE;
|
||||||
private SQLConnection sqlConnection;
|
private SQLConnection sqlConnection;
|
||||||
|
// private MongoConnection mongoConnection;
|
||||||
private RedisConnection redisConnection;
|
private RedisConnection redisConnection;
|
||||||
|
|
||||||
private PlayerCache playerCache;
|
private PlayerCache playerCache;
|
||||||
@ -64,9 +63,6 @@ public class Plex extends JavaPlugin
|
|||||||
private Permission permissions;
|
private Permission permissions;
|
||||||
private Chat chat;
|
private Chat chat;
|
||||||
|
|
||||||
private CoreProtectHook coreProtectHook;
|
|
||||||
private PrismHook prismHook;
|
|
||||||
|
|
||||||
public static Plex get()
|
public static Plex get()
|
||||||
{
|
{
|
||||||
return plugin;
|
return plugin;
|
||||||
@ -109,6 +105,7 @@ public class Plex extends JavaPlugin
|
|||||||
commands.load(false);
|
commands.load(false);
|
||||||
|
|
||||||
sqlConnection = new SQLConnection();
|
sqlConnection = new SQLConnection();
|
||||||
|
// mongoConnection = new MongoConnection();
|
||||||
redisConnection = new RedisConnection();
|
redisConnection = new RedisConnection();
|
||||||
|
|
||||||
playerCache = new PlayerCache();
|
playerCache = new PlayerCache();
|
||||||
@ -127,38 +124,12 @@ public class Plex extends JavaPlugin
|
|||||||
|
|
||||||
if (!getServer().getPluginManager().isPluginEnabled("Vault"))
|
if (!getServer().getPluginManager().isPluginEnabled("Vault"))
|
||||||
{
|
{
|
||||||
throw new RuntimeException("Vault is required to run on the server alongside a permissions plugin, we recommend LuckPerms!");
|
throw new RuntimeException("Vault is required to run on the server if you use permissions alongside a permissions plugin, we recommend LuckPerms!");
|
||||||
}
|
}
|
||||||
|
|
||||||
permissions = setupPermissions();
|
permissions = setupPermissions();
|
||||||
chat = setupChat();
|
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();
|
updateChecker = new UpdateChecker();
|
||||||
PlexLog.log("Update checking enabled");
|
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
|
// 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())
|
if (new File("plugins/Plex/modules/Module-HTTPD.jar").isFile())
|
||||||
{
|
{
|
||||||
resolver.addDependency(new Dependency(new DefaultArtifact("org.eclipse.jetty:jetty-server:11.0.19"), null));
|
resolver.addDependency(new Dependency(new DefaultArtifact("org.eclipse.jetty:jetty-server:11.0.18"), 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-servlet:11.0.18"), null));
|
||||||
resolver.addDependency(new Dependency(new DefaultArtifact("org.eclipse.jetty:jetty-proxy:11.0.19"), null));
|
resolver.addDependency(new Dependency(new DefaultArtifact("org.eclipse.jetty:jetty-proxy:11.0.18"), null));
|
||||||
}
|
}
|
||||||
classpathBuilder.addLibrary(resolver);
|
classpathBuilder.addLibrary(resolver);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package dev.plex.command;
|
package dev.plex.command;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.cache.DataUtils;
|
import dev.plex.cache.DataUtils;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
@ -15,15 +14,14 @@ import net.kyori.adventure.text.Component;
|
|||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.*;
|
import org.bukkit.command.*;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.util.StringUtil;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,7 +61,6 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
setName(this.params.name());
|
setName(this.params.name());
|
||||||
setLabel(this.params.name());
|
setLabel(this.params.name());
|
||||||
setDescription(params.description());
|
setDescription(params.description());
|
||||||
setPermission(this.perms.permission());
|
|
||||||
setUsage(params.usage().replace("<command>", this.params.name()));
|
setUsage(params.usage().replace("<command>", this.params.name()));
|
||||||
if (params.aliases().split(",").length > 0)
|
if (params.aliases().split(",").length > 0)
|
||||||
{
|
{
|
||||||
@ -77,8 +74,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
{
|
{
|
||||||
getMap().getKnownCommands().remove(this.getName().toLowerCase());
|
getMap().getKnownCommands().remove(this.getName().toLowerCase());
|
||||||
}
|
}
|
||||||
this.getAliases().forEach(s ->
|
this.getAliases().forEach(s -> {
|
||||||
{
|
|
||||||
if (getMap().getKnownCommands().containsKey(s.toLowerCase()))
|
if (getMap().getKnownCommands().containsKey(s.toLowerCase()))
|
||||||
{
|
{
|
||||||
getMap().getKnownCommands().remove(s.toLowerCase());
|
getMap().getKnownCommands().remove(s.toLowerCase());
|
||||||
@ -170,17 +166,6 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
return true;
|
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
|
* Checks if the String given is a matching command
|
||||||
*
|
*
|
||||||
@ -298,6 +283,47 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
return !permission.isEmpty() && player.hasPermission(permission);
|
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
|
* Gets the UUID of the sender
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package dev.plex.command.impl;
|
package dev.plex.command.impl;
|
||||||
|
|
||||||
|
import dev.plex.cache.DataUtils;
|
||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
@ -11,6 +12,8 @@ import dev.plex.util.PlexUtils;
|
|||||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||||
import dev.plex.util.redis.MessageUtil;
|
import dev.plex.util.redis.MessageUtil;
|
||||||
import net.kyori.adventure.text.Component;
|
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.BooleanUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -18,8 +21,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@CommandPermissions(permission = "plex.adminchat", source = RequiredCommandSource.ANY)
|
@CommandPermissions(permission = "plex.adminchat", source = RequiredCommandSource.ANY)
|
||||||
@ -57,10 +58,4 @@ public class AdminChatCMD extends PlexCommand
|
|||||||
MessageUtil.sendStaffChat(sender, SafeMiniMessage.mmDeserialize(message), PlexUtils.adminChat(sender.getName(), prefix, message).toArray(UUID[]::new));
|
MessageUtil.sendStaffChat(sender, SafeMiniMessage.mmDeserialize(message), PlexUtils.adminChat(sender.getName(), prefix, message).toArray(UUID[]::new));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
|
||||||
{
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@CommandPermissions(permission = "plex.adminworld", source = RequiredCommandSource.IN_GAME)
|
@CommandPermissions(permission = "plex.adminworld", source = RequiredCommandSource.IN_GAME)
|
||||||
@CommandParameters(name = "adminworld", aliases = "aw", description = "Teleport to the adminworld")
|
@CommandParameters(name = "adminworld", aliases = "aw", description = "Teleport to the adminworld")
|
||||||
public class AdminworldCMD extends PlexCommand
|
public class AdminworldCMD extends PlexCommand
|
||||||
@ -32,10 +29,4 @@ public class AdminworldCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
return null;
|
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
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if (silentCheckPermission(sender, "plex.gamemode.adventure.others"))
|
if (silentCheckPermission(sender, "plex.gamemode.adventure.others"))
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package dev.plex.command.impl;
|
package dev.plex.command.impl;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import dev.plex.Plex;
|
||||||
import dev.plex.cache.DataUtils;
|
import dev.plex.cache.DataUtils;
|
||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
@ -9,10 +11,7 @@ import dev.plex.command.source.RequiredCommandSource;
|
|||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.punishment.Punishment;
|
import dev.plex.punishment.Punishment;
|
||||||
import dev.plex.punishment.PunishmentType;
|
import dev.plex.punishment.PunishmentType;
|
||||||
import dev.plex.util.BungeeUtil;
|
import dev.plex.util.*;
|
||||||
import dev.plex.util.PlexLog;
|
|
||||||
import dev.plex.util.PlexUtils;
|
|
||||||
import dev.plex.util.TimeUtils;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -23,10 +22,9 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@CommandParameters(name = "ban", usage = "/<command> <player> [reason] [-rb]", aliases = "offlineban,gtfo", description = "Bans a player, offline or online")
|
@CommandParameters(name = "ban", usage = "/<command> <player> [reason]", aliases = "offlineban,gtfo", description = "Bans a player, offline or online")
|
||||||
@CommandPermissions(permission = "plex.ban", source = RequiredCommandSource.ANY)
|
@CommandPermissions(permission = "plex.ban", source = RequiredCommandSource.ANY)
|
||||||
|
|
||||||
public class BanCMD extends PlexCommand
|
public class BanCMD extends PlexCommand
|
||||||
@ -58,27 +56,27 @@ public class BanCMD extends PlexCommand
|
|||||||
String reason;
|
String reason;
|
||||||
Punishment punishment = new Punishment(plexPlayer.getUuid(), getUUID(sender));
|
Punishment punishment = new Punishment(plexPlayer.getUuid(), getUUID(sender));
|
||||||
punishment.setType(PunishmentType.BAN);
|
punishment.setType(PunishmentType.BAN);
|
||||||
boolean rollBack = false;
|
|
||||||
if (args.length > 1)
|
if (args.length > 1)
|
||||||
{
|
{
|
||||||
reason = StringUtils.join(args, " ", 1, args.length);
|
reason = StringUtils.join(args, " ", 1, args.length);
|
||||||
String newReason = StringUtils.normalizeSpace(reason.replace("-rb", ""));
|
punishment.setReason(reason);
|
||||||
punishment.setReason(newReason.trim().isEmpty() ? messageString("noReasonProvided") : newReason);
|
|
||||||
rollBack = reason.startsWith("-rb") || reason.endsWith("-rb");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
punishment.setReason(messageString("noReasonProvided"));
|
punishment.setReason("No reason provided.");
|
||||||
}
|
}
|
||||||
punishment.setPunishedUsername(plexPlayer.getName());
|
punishment.setPunishedUsername(plexPlayer.getName());
|
||||||
ZonedDateTime date = ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE));
|
ZonedDateTime date = ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE));
|
||||||
punishment.setEndDate(date.plusDays(1));
|
punishment.setEndDate(date.plusDays(1));
|
||||||
punishment.setCustomTime(false);
|
punishment.setCustomTime(false);
|
||||||
punishment.setActive(true);
|
punishment.setActive(true);
|
||||||
punishment.setIp(player != null ? player.getAddress().getAddress().getHostAddress().trim() : plexPlayer.getIps().get(plexPlayer.getIps().size() - 1));
|
if (player != null)
|
||||||
|
{
|
||||||
|
punishment.setIp(player.getAddress().getAddress().getHostAddress().trim());
|
||||||
|
}
|
||||||
plugin.getPunishmentManager().punish(plexPlayer, punishment);
|
plugin.getPunishmentManager().punish(plexPlayer, punishment);
|
||||||
PlexUtils.broadcast(messageComponent("banningPlayer", sender.getName(), plexPlayer.getName()));
|
PlexUtils.broadcast(messageComponent("banningPlayer", sender.getName(), plexPlayer.getName()));
|
||||||
Bukkit.getGlobalRegionScheduler().execute(plugin, () ->
|
Bukkit.getScheduler().runTask(Plex.get(), () ->
|
||||||
{
|
{
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
@ -86,59 +84,14 @@ public class BanCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
PlexLog.debug("(From /ban command) PunishedPlayer UUID: " + plexPlayer.getUuid());
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if (args.length == 1 && silentCheckPermission(sender, this.getPermission()))
|
return args.length == 1 && silentCheckPermission(sender, "plex.ban") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||||
{
|
|
||||||
return PlexUtils.getPlayerNameList();
|
|
||||||
}
|
|
||||||
if (args.length > 1 && silentCheckPermission(sender, this.getPermission()))
|
|
||||||
{
|
|
||||||
return Collections.singletonList("-rb");
|
|
||||||
}
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,61 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,59 +0,0 @@
|
|||||||
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,11 +12,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@CommandPermissions(permission = "plex.blockedit")
|
@CommandPermissions(permission = "plex.blockedit")
|
||||||
@CommandParameters(name = "blockedit", usage = "/<command> [list | purge | all | <player>]", aliases = "bedit", description = "Prevent players from modifying blocks")
|
@CommandParameters(name = "blockedit", usage = "/<command> [list | purge | all | <player>]", aliases = "bedit", description = "Prevent players from modifying blocks")
|
||||||
public class BlockEditCMD extends PlexCommand
|
public class BlockEditCMD extends PlexCommand
|
||||||
@ -99,20 +94,4 @@ public class BlockEditCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
|
||||||
{
|
|
||||||
if (silentCheckPermission(sender, this.getPermission()))
|
|
||||||
{
|
|
||||||
List<String> options = new ArrayList<>();
|
|
||||||
if (args.length == 1)
|
|
||||||
{
|
|
||||||
options.addAll(Arrays.asList("list", "purge", "all"));
|
|
||||||
options.addAll(PlexUtils.getPlayerNameList());
|
|
||||||
return options;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@CommandPermissions(permission = "plex.commandspy", source = RequiredCommandSource.IN_GAME)
|
@CommandPermissions(permission = "plex.commandspy", source = RequiredCommandSource.IN_GAME)
|
||||||
@CommandParameters(name = "commandspy", aliases = "cmdspy", description = "Spy on other player's commands")
|
@CommandParameters(name = "commandspy", aliases = "cmdspy", description = "Spy on other player's commands")
|
||||||
public class CommandSpyCMD extends PlexCommand
|
public class CommandSpyCMD extends PlexCommand
|
||||||
@ -33,10 +30,4 @@ public class CommandSpyCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
|
||||||
{
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -12,9 +12,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@CommandPermissions(permission = "plex.consolesay", source = RequiredCommandSource.CONSOLE)
|
@CommandPermissions(permission = "plex.consolesay", source = RequiredCommandSource.CONSOLE)
|
||||||
@CommandParameters(name = "consolesay", usage = "/<command> <message>", description = "Displays a message to everyone", aliases = "csay")
|
@CommandParameters(name = "consolesay", usage = "/<command> <message>", description = "Displays a message to everyone", aliases = "csay")
|
||||||
public class ConsoleSayCMD extends PlexCommand
|
public class ConsoleSayCMD extends PlexCommand
|
||||||
@ -30,10 +27,4 @@ public class ConsoleSayCMD extends PlexCommand
|
|||||||
PlexUtils.broadcast(PlexUtils.messageComponent("consoleSayMessage", sender.getName(), PlexUtils.mmStripColor(StringUtils.join(args, " "))));
|
PlexUtils.broadcast(PlexUtils.messageComponent("consoleSayMessage", sender.getName(), PlexUtils.mmStripColor(StringUtils.join(args, " "))));
|
||||||
return null;
|
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
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if (silentCheckPermission(sender, "plex.gamemode.creative.others"))
|
if (silentCheckPermission(sender, "plex.gamemode.creative.others"))
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
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>")
|
@CommandParameters(name = "pdebug", description = "Plex's debug command", usage = "/<command> <aliases <command> | redis-reset <player> | gamerules>")
|
||||||
@CommandPermissions(permission = "plex.debug")
|
@CommandPermissions(permission = "plex.debug")
|
||||||
@ -41,9 +42,9 @@ public class DebugCMD extends PlexCommand
|
|||||||
if (plugin.getRedisConnection().getJedis().exists(player.getUniqueId().toString()))
|
if (plugin.getRedisConnection().getJedis().exists(player.getUniqueId().toString()))
|
||||||
{
|
{
|
||||||
plugin.getRedisConnection().getJedis().del(player.getUniqueId().toString());
|
plugin.getRedisConnection().getJedis().del(player.getUniqueId().toString());
|
||||||
return messageComponent("redisResetSuccessful", player.getName());
|
return componentFromString("Successfully reset " + player.getName() + "'s Redis punishments!").color(NamedTextColor.YELLOW);
|
||||||
}
|
}
|
||||||
return messageComponent("redisResetPlayerNotFound");
|
return componentFromString("Couldn't find player in Redis punishments.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("gamerules"))
|
if (args[0].equalsIgnoreCase("gamerules"))
|
||||||
@ -62,7 +63,7 @@ public class DebugCMD extends PlexCommand
|
|||||||
PlexLog.log("Set specific gamerules for world: " + world.toLowerCase(Locale.ROOT));
|
PlexLog.log("Set specific gamerules for world: " + world.toLowerCase(Locale.ROOT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return messageComponent("reappliedGamerules");
|
return mmString("<aqua>Re-applied game all the game rules!");
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("aliases"))
|
if (args[0].equalsIgnoreCase("aliases"))
|
||||||
{
|
{
|
||||||
@ -72,9 +73,9 @@ public class DebugCMD extends PlexCommand
|
|||||||
Command command = plugin.getServer().getCommandMap().getCommand(commandName);
|
Command command = plugin.getServer().getCommandMap().getCommand(commandName);
|
||||||
if (command == null)
|
if (command == null)
|
||||||
{
|
{
|
||||||
return messageComponent("commandNotFound");
|
return mmString("<red>That command could not be found!");
|
||||||
}
|
}
|
||||||
return messageComponent("commandAliases", commandName, Arrays.toString(command.getAliases().toArray(new String[0])));
|
return mmString("<aqua>Aliases for " + commandName + " are: " + Arrays.toString(command.getAliases().toArray(new String[0])));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (args[0].equalsIgnoreCase("pagination"))
|
if (args[0].equalsIgnoreCase("pagination"))
|
||||||
@ -90,8 +91,8 @@ public class DebugCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -106,24 +106,20 @@ public class EntityWipeCMD extends PlexCommand
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if (silentCheckPermission(sender, this.getPermission()))
|
List<String> entities = new ArrayList<>();
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
{
|
{
|
||||||
List<String> entities = new ArrayList<>();
|
for (Entity entity : world.getEntities())
|
||||||
for (World world : Bukkit.getWorlds())
|
|
||||||
{
|
{
|
||||||
for (Entity entity : world.getEntities())
|
if (entity.getType() != EntityType.PLAYER)
|
||||||
{
|
{
|
||||||
if (entity.getType() != EntityType.PLAYER)
|
entities.add(entity.getType().name());
|
||||||
{
|
|
||||||
entities.add(entity.getType().name());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return entities.stream().toList();
|
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return entities.stream().toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Integer parseInt(CommandSender sender, String string)
|
private Integer parseInt(CommandSender sender, String string)
|
||||||
@ -134,7 +130,7 @@ public class EntityWipeCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
catch (NumberFormatException ex)
|
catch (NumberFormatException ex)
|
||||||
{
|
{
|
||||||
sender.sendMessage(messageComponent("notANumber", string));
|
sender.sendMessage(mmString("<red>" + string + "<red> is not a valid number!"));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import dev.plex.command.PlexCommand;
|
|||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -12,9 +13,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@CommandPermissions(permission = "plex.flatlands", source = RequiredCommandSource.IN_GAME)
|
@CommandPermissions(permission = "plex.flatlands", source = RequiredCommandSource.IN_GAME)
|
||||||
@CommandParameters(name = "flatlands", description = "Teleport to the flatlands")
|
@CommandParameters(name = "flatlands", description = "Teleport to the flatlands")
|
||||||
public class FlatlandsCMD extends PlexCommand
|
public class FlatlandsCMD extends PlexCommand
|
||||||
@ -31,10 +29,4 @@ public class FlatlandsCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
|
||||||
{
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -7,6 +7,7 @@ import dev.plex.command.annotation.CommandPermissions;
|
|||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.punishment.Punishment;
|
import dev.plex.punishment.Punishment;
|
||||||
import dev.plex.punishment.PunishmentType;
|
import dev.plex.punishment.PunishmentType;
|
||||||
|
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.TimeUtils;
|
import dev.plex.util.TimeUtils;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -41,12 +42,11 @@ public class FreezeCMD extends PlexCommand
|
|||||||
Punishment punishment = new Punishment(punishedPlayer.getUuid(), getUUID(sender));
|
Punishment punishment = new Punishment(punishedPlayer.getUuid(), getUUID(sender));
|
||||||
punishment.setCustomTime(false);
|
punishment.setCustomTime(false);
|
||||||
ZonedDateTime date = ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE));
|
ZonedDateTime date = ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE));
|
||||||
punishment.setEndDate(date.plusSeconds(plugin.config.getInt("punishments.freeze-timer", 300)));
|
punishment.setEndDate(date.plusMinutes(5));
|
||||||
punishment.setType(PunishmentType.FREEZE);
|
punishment.setType(PunishmentType.FREEZE);
|
||||||
punishment.setPunishedUsername(player.getName());
|
punishment.setPunishedUsername(player.getName());
|
||||||
punishment.setIp(player.getAddress().getAddress().getHostAddress().trim());
|
punishment.setIp(player.getAddress().getAddress().getHostAddress().trim());
|
||||||
punishment.setReason("");
|
punishment.setReason("");
|
||||||
punishment.setActive(true);
|
|
||||||
|
|
||||||
plugin.getPunishmentManager().punish(punishedPlayer, punishment);
|
plugin.getPunishmentManager().punish(punishedPlayer, punishment);
|
||||||
PlexUtils.broadcast(messageComponent("frozePlayer", sender.getName(), player.getName()));
|
PlexUtils.broadcast(messageComponent("frozePlayer", sender.getName(), player.getName()));
|
||||||
@ -54,8 +54,8 @@ public class FreezeCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
return args.length == 1 && silentCheckPermission(sender, "plex.freeze") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -88,7 +88,7 @@ public class GamemodeCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
@ -96,10 +96,7 @@ public class GamemodeCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
if (args.length == 2)
|
if (args.length == 2)
|
||||||
{
|
{
|
||||||
if (silentCheckPermission(sender, "plex.gamemode.others"))
|
return PlexUtils.getPlayerNameList();
|
||||||
{
|
|
||||||
return PlexUtils.getPlayerNameList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package dev.plex.command.impl;
|
package dev.plex.command.impl;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import dev.plex.cache.DataUtils;
|
import dev.plex.cache.DataUtils;
|
||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
@ -10,6 +9,7 @@ import dev.plex.command.source.RequiredCommandSource;
|
|||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.punishment.Punishment;
|
import dev.plex.punishment.Punishment;
|
||||||
import dev.plex.punishment.PunishmentType;
|
import dev.plex.punishment.PunishmentType;
|
||||||
|
|
||||||
import dev.plex.util.BungeeUtil;
|
import dev.plex.util.BungeeUtil;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.TimeUtils;
|
import dev.plex.util.TimeUtils;
|
||||||
@ -23,7 +23,6 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@CommandParameters(name = "kick", description = "Kicks a player", usage = "/<command> <player>")
|
@CommandParameters(name = "kick", description = "Kicks a player", usage = "/<command> <player>")
|
||||||
@CommandPermissions(permission = "plex.kick", source = RequiredCommandSource.ANY)
|
@CommandPermissions(permission = "plex.kick", source = RequiredCommandSource.ANY)
|
||||||
@ -38,7 +37,7 @@ public class KickCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlexPlayer plexPlayer = DataUtils.getPlayer(args[0]);
|
PlexPlayer plexPlayer = DataUtils.getPlayer(args[0]);
|
||||||
String reason = messageString("noReasonProvided");
|
String reason = "No reason provided";
|
||||||
|
|
||||||
if (plexPlayer == null)
|
if (plexPlayer == null)
|
||||||
{
|
{
|
||||||
@ -68,10 +67,4 @@ public class KickCMD extends PlexCommand
|
|||||||
BungeeUtil.kickPlayer(player, Punishment.generateKickMessage(punishment));
|
BungeeUtil.kickPlayer(player, Punishment.generateKickMessage(punishment));
|
||||||
return null;
|
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,11 +2,9 @@ package dev.plex.command.impl;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.util.PlexUtils;
|
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.hook.VaultHook;
|
import dev.plex.hook.VaultHook;
|
||||||
import dev.plex.meta.PlayerMeta;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -18,7 +16,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@CommandParameters(name = "list", description = "Show a list of all online players", usage = "/<command> [-d | -v]", aliases = "lsit,who,playerlist,online")
|
@CommandParameters(name = "list", description = "Show a list of all online players", usage = "/<command> [-d]", aliases = "lsit,who,playerlist,online")
|
||||||
@CommandPermissions(permission = "plex.list")
|
@CommandPermissions(permission = "plex.list")
|
||||||
public class ListCMD extends PlexCommand
|
public class ListCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
@ -26,17 +24,18 @@ public class ListCMD extends PlexCommand
|
|||||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||||
{
|
{
|
||||||
List<Player> players = Lists.newArrayList(Bukkit.getOnlinePlayers());
|
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 list = Component.empty();
|
||||||
Component header = PlexUtils.messageComponent(players.size() == 1 ? "listHeader" : "listHeaderPlural", players.size(), Bukkit.getMaxPlayers());
|
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));
|
||||||
send(sender, header);
|
send(sender, header);
|
||||||
if (players.isEmpty())
|
if (players.isEmpty())
|
||||||
{
|
{
|
||||||
@ -66,11 +65,11 @@ public class ListCMD extends PlexCommand
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if (args.length == 1 && silentCheckPermission(sender, this.getPermission()))
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
return List.of("-d", "-v");
|
return Collections.singletonList("-d");
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@CommandParameters(name = "localspawn", description = "Teleport to the spawnpoint of the world you are in")
|
@CommandParameters(name = "localspawn", description = "Teleport to the spawnpoint of the world you are in")
|
||||||
@CommandPermissions(permission = "plex.localspawn", source = RequiredCommandSource.IN_GAME)
|
@CommandPermissions(permission = "plex.localspawn", source = RequiredCommandSource.IN_GAME)
|
||||||
public class LocalSpawnCMD extends PlexCommand
|
public class LocalSpawnCMD extends PlexCommand
|
||||||
@ -25,10 +22,4 @@ public class LocalSpawnCMD extends PlexCommand
|
|||||||
playerSender.teleportAsync(playerSender.getWorld().getSpawnLocation());
|
playerSender.teleportAsync(playerSender.getWorld().getSpawnLocation());
|
||||||
return messageComponent("teleportedToWorldSpawn");
|
return messageComponent("teleportedToWorldSpawn");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
|
||||||
{
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -5,6 +5,7 @@ import dev.plex.command.PlexCommand;
|
|||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
|
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -38,8 +39,8 @@ public class LockupCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
return args.length == 1 && silentCheckPermission(sender, "plex.lockup") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -13,9 +13,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@CommandPermissions(permission = "plex.masterbuilderworld", source = RequiredCommandSource.IN_GAME)
|
@CommandPermissions(permission = "plex.masterbuilderworld", source = RequiredCommandSource.IN_GAME)
|
||||||
@CommandParameters(name = "masterbuilderworld", aliases = "mbw", description = "Teleport to the Master Builder world")
|
@CommandParameters(name = "masterbuilderworld", aliases = "mbw", description = "Teleport to the Master Builder world")
|
||||||
public class MasterbuilderworldCMD extends PlexCommand
|
public class MasterbuilderworldCMD extends PlexCommand
|
||||||
@ -33,10 +30,4 @@ public class MasterbuilderworldCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
|
||||||
{
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,96 +0,0 @@
|
|||||||
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,119 +4,50 @@ import dev.plex.command.PlexCommand;
|
|||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.util.PlexLog;
|
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.apache.commons.lang3.text.WordUtils;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.Mob;
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.HashMap;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@CommandPermissions(permission = "plex.mobpurge", source = RequiredCommandSource.ANY)
|
@CommandPermissions(permission = "plex.mobpurge", source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "mobpurge", description = "Purge all mobs.", usage = "/<command> [mob]", aliases = "mp")
|
@CommandParameters(name = "mobpurge", description = "Purge all mobs.", usage = "/<command>", aliases = "mp")
|
||||||
public class MobPurgeCMD extends PlexCommand
|
public class MobPurgeCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
private final List<EntityType> MOB_TYPES = new ArrayList<>();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, @NotNull String[] args)
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, @NotNull String[] args)
|
||||||
{
|
{
|
||||||
EntityType type = null;
|
HashMap<String, Integer> entityCounts = new HashMap<>();
|
||||||
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 (World world : Bukkit.getWorlds())
|
||||||
{
|
{
|
||||||
for (Entity entity : world.getLivingEntities())
|
for (Entity entity : world.getEntities())
|
||||||
{
|
{
|
||||||
if (entity instanceof LivingEntity && !(entity instanceof Player))
|
if (entity instanceof Mob)
|
||||||
{
|
{
|
||||||
if (type != null && !entity.getType().equals(type))
|
String type = entity.getType().name();
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
entity.remove();
|
entity.remove();
|
||||||
removed++;
|
|
||||||
|
entityCounts.put(type, entityCounts.getOrDefault(type, 0) + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return removed;
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> getAllMobs()
|
int entityCount = entityCounts.values().stream().mapToInt(a -> a).sum();
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
PlexUtils.broadcast(messageComponent("removedMobs", sender.getName(), entityCount));
|
||||||
{
|
|
||||||
if (args.length == 1 && silentCheckPermission(sender, this.getPermission()))
|
/*entityCounts.forEach((entityName, numRemoved) -> {
|
||||||
{
|
sender.sendMessage(messageComponent("removedEntitiesOfType", sender.getName(), numRemoved, entityName));
|
||||||
return getAllMobs();
|
});*/
|
||||||
}
|
return null;
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -7,6 +7,7 @@ import dev.plex.command.annotation.CommandPermissions;
|
|||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.punishment.Punishment;
|
import dev.plex.punishment.Punishment;
|
||||||
import dev.plex.punishment.PunishmentType;
|
import dev.plex.punishment.PunishmentType;
|
||||||
|
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.TimeUtils;
|
import dev.plex.util.TimeUtils;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -38,7 +39,7 @@ public class MuteCMD extends PlexCommand
|
|||||||
return messageComponent("playerMuted");
|
return messageComponent("playerMuted");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (silentCheckPermission(player, "plex.mute"))
|
if (silentCheckPermission(player,"plex.mute"))
|
||||||
{
|
{
|
||||||
send(sender, messageComponent("higherRankThanYou"));
|
send(sender, messageComponent("higherRankThanYou"));
|
||||||
return null;
|
return null;
|
||||||
@ -47,12 +48,11 @@ public class MuteCMD extends PlexCommand
|
|||||||
Punishment punishment = new Punishment(punishedPlayer.getUuid(), getUUID(sender));
|
Punishment punishment = new Punishment(punishedPlayer.getUuid(), getUUID(sender));
|
||||||
punishment.setCustomTime(false);
|
punishment.setCustomTime(false);
|
||||||
ZonedDateTime date = ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE));
|
ZonedDateTime date = ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE));
|
||||||
punishment.setEndDate(date.plusSeconds(plugin.config.getInt("punishments.mute-timer", 300)));
|
punishment.setEndDate(date.plusMinutes(5));
|
||||||
punishment.setType(PunishmentType.MUTE);
|
punishment.setType(PunishmentType.MUTE);
|
||||||
punishment.setPunishedUsername(player.getName());
|
punishment.setPunishedUsername(player.getName());
|
||||||
punishment.setIp(player.getAddress().getAddress().getHostAddress().trim());
|
punishment.setIp(player.getAddress().getAddress().getHostAddress().trim());
|
||||||
punishment.setReason("");
|
punishment.setReason("");
|
||||||
punishment.setActive(true);
|
|
||||||
|
|
||||||
plugin.getPunishmentManager().punish(punishedPlayer, punishment);
|
plugin.getPunishmentManager().punish(punishedPlayer, punishment);
|
||||||
PlexUtils.broadcast(messageComponent("mutedPlayer", sender.getName(), player.getName()));
|
PlexUtils.broadcast(messageComponent("mutedPlayer", sender.getName(), player.getName()));
|
||||||
@ -60,8 +60,8 @@ public class MuteCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
return args.length == 1 && silentCheckPermission(sender,"plex.mute") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,6 +6,7 @@ import dev.plex.command.annotation.CommandParameters;
|
|||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.punishment.extra.Note;
|
import dev.plex.punishment.extra.Note;
|
||||||
|
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.TimeUtils;
|
import dev.plex.util.TimeUtils;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -124,11 +125,11 @@ public class NotesCMD extends PlexCommand
|
|||||||
|
|
||||||
private void readNotes(@NotNull CommandSender sender, PlexPlayer plexPlayer, List<Note> notes)
|
private void readNotes(@NotNull CommandSender sender, PlexPlayer plexPlayer, List<Note> notes)
|
||||||
{
|
{
|
||||||
AtomicReference<Component> noteList = new AtomicReference<>(messageComponent("notesHeader", plexPlayer.getName()));
|
AtomicReference<Component> noteList = new AtomicReference<>(Component.text("Player notes for: " + plexPlayer.getName()).color(NamedTextColor.GREEN));
|
||||||
for (Note note : notes)
|
for (Note note : notes)
|
||||||
{
|
{
|
||||||
Component noteLine = messageComponent("notePrefix", note.getId(), DataUtils.getPlayer(note.getWrittenBy()).getName(), TimeUtils.useTimezone(note.getTimestamp()));
|
Component noteLine = mmString("<gold><!italic>" + note.getId() + " - Written by: " + DataUtils.getPlayer(note.getWrittenBy()).getName() + " on " + TimeUtils.useTimezone(note.getTimestamp()));
|
||||||
noteLine = noteLine.append(messageComponent("noteLine", note.getNote()));
|
noteLine = noteLine.append(mmString("<newline><yellow># " + note.getNote()));
|
||||||
noteList.set(noteList.get().append(Component.newline()));
|
noteList.set(noteList.get().append(Component.newline()));
|
||||||
noteList.set(noteList.get().append(noteLine));
|
noteList.set(noteList.get().append(noteLine));
|
||||||
}
|
}
|
||||||
@ -136,19 +137,15 @@ public class NotesCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if (silentCheckPermission(sender, this.getPermission()))
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
if (args.length == 1)
|
return PlexUtils.getPlayerNameList();
|
||||||
{
|
}
|
||||||
return PlexUtils.getPlayerNameList();
|
if (args.length == 2)
|
||||||
}
|
{
|
||||||
if (args.length == 2)
|
return Arrays.asList("list", "add", "remove", "clear");
|
||||||
{
|
|
||||||
return Arrays.asList("list", "add", "remove", "clear");
|
|
||||||
}
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
}
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ public class PlexCMD extends PlexCommand
|
|||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
send(sender, mmString("<light_purple>Plex - A new freedom plugin."));
|
send(sender, mmString("<light_purple>Plex - A new freedom plugin."));
|
||||||
send(sender, mmString("<light_purple>Plugin version: <gold>" + plugin.getDescription().getVersion() + " #" + BuildInfo.getNumber() + " <light_purple>Git: <gold>" + BuildInfo.getCommit()));
|
send(sender, mmString("<light_purple>Plugin version: <gold>" + plugin.getDescription().getVersion() + " #" + BuildInfo.getNumber() + " <light_purple>Git: <gold>" + BuildInfo.getHead()));
|
||||||
send(sender, mmString("<light_purple>Authors: <gold>Telesphoreo, Taahh"));
|
send(sender, mmString("<light_purple>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>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."));
|
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
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
|
@ -7,6 +7,7 @@ import dev.plex.command.annotation.CommandParameters;
|
|||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.exception.PlayerNotFoundException;
|
import dev.plex.command.exception.PlayerNotFoundException;
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
|
|
||||||
import dev.plex.menu.impl.PunishedPlayerMenu;
|
import dev.plex.menu.impl.PunishedPlayerMenu;
|
||||||
import dev.plex.menu.impl.PunishmentMenu;
|
import dev.plex.menu.impl.PunishmentMenu;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
@ -49,8 +50,8 @@ public class PunishmentsCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,9 +13,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@CommandPermissions(permission = "plex.rawsay", source = RequiredCommandSource.ANY)
|
@CommandPermissions(permission = "plex.rawsay", source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "rawsay", usage = "/<command> <message>", description = "Displays a raw message to everyone")
|
@CommandParameters(name = "rawsay", usage = "/<command> <message>", description = "Displays a raw message to everyone")
|
||||||
public class RawSayCMD extends PlexCommand
|
public class RawSayCMD extends PlexCommand
|
||||||
@ -31,10 +28,4 @@ public class RawSayCMD extends PlexCommand
|
|||||||
PlexUtils.broadcast(StringUtils.join(args, " "));
|
PlexUtils.broadcast(StringUtils.join(args, " "));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
|
||||||
{
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,21 +1,17 @@
|
|||||||
package dev.plex.command.impl;
|
package dev.plex.command.impl;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import dev.plex.cache.DataUtils;
|
import dev.plex.cache.DataUtils;
|
||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.util.PlexUtils;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@CommandPermissions(permission = "plex.removeloginmessage", source = RequiredCommandSource.ANY)
|
@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")
|
@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
|
public class RemoveLoginMessageCMD extends PlexCommand
|
||||||
@ -55,17 +51,4 @@ public class RemoveLoginMessageCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
|
||||||
{
|
|
||||||
if (args.length == 1)
|
|
||||||
{
|
|
||||||
if (silentCheckPermission(sender, "plex.removeloginmessage.others"))
|
|
||||||
{
|
|
||||||
return List.of("-o");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return args.length == 2 && silentCheckPermission(sender, "plex.removeloginmessage.others") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -4,6 +4,7 @@ import dev.plex.command.PlexCommand;
|
|||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
|
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
@ -12,9 +13,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@CommandPermissions(permission = "plex.say", source = RequiredCommandSource.ANY)
|
@CommandPermissions(permission = "plex.say", source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "say", usage = "/<command> <message>", description = "Displays a message to everyone")
|
@CommandParameters(name = "say", usage = "/<command> <message>", description = "Displays a message to everyone")
|
||||||
public class SayCMD extends PlexCommand
|
public class SayCMD extends PlexCommand
|
||||||
@ -30,10 +28,4 @@ public class SayCMD extends PlexCommand
|
|||||||
PlexUtils.broadcast(PlexUtils.messageComponent("sayMessage", sender.getName(), PlexUtils.mmStripColor(StringUtils.join(args, " "))));
|
PlexUtils.broadcast(PlexUtils.messageComponent("sayMessage", sender.getName(), PlexUtils.mmStripColor(StringUtils.join(args, " "))));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
|
||||||
{
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,6 +1,5 @@
|
|||||||
package dev.plex.command.impl;
|
package dev.plex.command.impl;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
import dev.plex.cache.DataUtils;
|
import dev.plex.cache.DataUtils;
|
||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
@ -11,15 +10,12 @@ import dev.plex.player.PlexPlayer;
|
|||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@CommandPermissions(permission = "plex.setloginmessage", source = RequiredCommandSource.ANY)
|
@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")
|
@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
|
public class SetLoginMessageCMD extends PlexCommand
|
||||||
@ -57,18 +53,20 @@ public class SetLoginMessageCMD extends PlexCommand
|
|||||||
validateMessage(message);
|
validateMessage(message);
|
||||||
plexPlayer.setLoginMessage(message);
|
plexPlayer.setLoginMessage(message);
|
||||||
return messageComponent("setOtherPlayersLoginMessage", plexPlayer.getName(),
|
return messageComponent("setOtherPlayersLoginMessage", plexPlayer.getName(),
|
||||||
MiniMessage.miniMessage().serialize(PlexUtils.stringToComponent(message.replace("%player%", plexPlayer.getName()))));
|
message.replace("%player%", plexPlayer.getName()));
|
||||||
}
|
}
|
||||||
if (isConsole(sender))
|
if (isConsole(sender))
|
||||||
{
|
{
|
||||||
return messageComponent("noPermissionConsole");
|
return messageComponent("noPermissionConsole");
|
||||||
}
|
}
|
||||||
PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayer(playerSender.getUniqueId());
|
PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayer(playerSender.getUniqueId());
|
||||||
String message = StringUtils.join(args, " ", 0, args.length)
|
String message = StringUtils.join(args, " ", 0, args.length);
|
||||||
.replace(plexPlayer.getName(), "%player%");
|
message = message.replace(plexPlayer.getName(), "%player%");
|
||||||
|
message = PlexUtils.legacyToMiniString(message);
|
||||||
validateMessage(message);
|
validateMessage(message);
|
||||||
plexPlayer.setLoginMessage(message);
|
plexPlayer.setLoginMessage(message);
|
||||||
return messageComponent("setOwnLoginMessage", PlexUtils.stringToComponent(message.replace("%player%", plexPlayer.getName())));
|
return messageComponent("setOwnLoginMessage",
|
||||||
|
message.replace("%player%", plexPlayer.getName()));
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -81,17 +79,4 @@ public class SetLoginMessageCMD extends PlexCommand
|
|||||||
throw new CommandFailException(messageString("nameRequired"));
|
throw new CommandFailException(messageString("nameRequired"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
|
||||||
{
|
|
||||||
if (args.length == 1)
|
|
||||||
{
|
|
||||||
if (silentCheckPermission(sender, "plex.setloginmessage"))
|
|
||||||
{
|
|
||||||
return List.of("-o");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return args.length == 2 && args[0].equalsIgnoreCase("-o") && silentCheckPermission(sender, "plex.setloginmessage") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -7,6 +7,7 @@ import dev.plex.command.source.RequiredCommandSource;
|
|||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.punishment.Punishment;
|
import dev.plex.punishment.Punishment;
|
||||||
import dev.plex.punishment.PunishmentType;
|
import dev.plex.punishment.PunishmentType;
|
||||||
|
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.TimeUtils;
|
import dev.plex.util.TimeUtils;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -78,16 +79,21 @@ public class SmiteCMD extends PlexCommand
|
|||||||
final Player player = getNonNullPlayer(args[0]);
|
final Player player = getNonNullPlayer(args[0]);
|
||||||
final PlexPlayer plexPlayer = getPlexPlayer(player);
|
final PlexPlayer plexPlayer = getPlexPlayer(player);
|
||||||
|
|
||||||
Title title = Title.title(messageComponent("smiteTitleHeader"), messageComponent("smiteTitleMessage", reason, sender.getName()));
|
Title title = Title.title(Component.text("You've been smitten.").color(NamedTextColor.RED), Component.text("Be sure to follow the rules!").color(NamedTextColor.YELLOW));
|
||||||
player.showTitle(title);
|
player.showTitle(title);
|
||||||
|
|
||||||
if (!silent)
|
if (!silent)
|
||||||
{
|
{
|
||||||
PlexUtils.broadcast(messageComponent("smiteBroadcast", player.getName(), reason != null ? reason : messageString("noReasonProvided"), sender.getName()));
|
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()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
send(sender, messageComponent("smittenQuietly", player.getName()));
|
send(sender, "Smitten " + player.getName() + " quietly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set gamemode to survival
|
// Set gamemode to survival
|
||||||
@ -124,15 +130,15 @@ public class SmiteCMD extends PlexCommand
|
|||||||
if (reason != null)
|
if (reason != null)
|
||||||
{
|
{
|
||||||
punishment.setReason(reason);
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if (silentCheckPermission(sender, this.getPermission()) && args.length == 1)
|
if (silentCheckPermission(sender,"plex.smite") && args.length == 1)
|
||||||
{
|
{
|
||||||
return PlexUtils.getPlayerNameList();
|
return PlexUtils.getPlayerNameList();
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public class SpectatorCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if (silentCheckPermission(sender,"plex.gamemode.spectator.others"))
|
if (silentCheckPermission(sender,"plex.gamemode.spectator.others"))
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,7 @@ public class SurvivalCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if (silentCheckPermission(sender,"plex.gamemode.survival.others"))
|
if (silentCheckPermission(sender,"plex.gamemode.survival.others"))
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,7 @@ import dev.plex.command.annotation.CommandParameters;
|
|||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
|
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -18,10 +19,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@CommandPermissions(permission = "plex.tag", source = RequiredCommandSource.ANY)
|
@CommandPermissions(permission = "plex.tag", source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "tag", aliases = "prefix", description = "Set or clear your prefix", usage = "/<command> <set <prefix> | clear <player>>")
|
@CommandParameters(name = "tag", aliases = "prefix", description = "Set or clear your prefix", usage = "/<command> <set <prefix> | clear <player>>")
|
||||||
public class TagCMD extends PlexCommand
|
public class TagCMD extends PlexCommand
|
||||||
@ -50,15 +47,16 @@ public class TagCMD extends PlexCommand
|
|||||||
{
|
{
|
||||||
return usage("/tag set <prefix>");
|
return usage("/tag set <prefix>");
|
||||||
}
|
}
|
||||||
|
String prefix = PlexUtils.legacyToMiniString(StringUtils.join(args, " ", 1, args.length));
|
||||||
|
|
||||||
Component convertedComponent = PlexUtils.stringToComponent(StringUtils.join(args, " ", 1, args.length));
|
Component convertedComponent = SafeMiniMessage.mmDeserializeWithoutEvents(prefix);
|
||||||
|
|
||||||
if (PlainTextComponentSerializer.plainText().serialize(convertedComponent).length() > plugin.config.getInt("chat.max-tag-length", 16))
|
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));
|
return messageComponent("maximumPrefixLength", plugin.config.getInt("chat.max-tag-length", 16));
|
||||||
}
|
}
|
||||||
|
|
||||||
player.setPrefix(MiniMessage.miniMessage().serialize(convertedComponent));
|
player.setPrefix(prefix);
|
||||||
DataUtils.update(player);
|
DataUtils.update(player);
|
||||||
return messageComponent("prefixSetTo", MiniMessage.miniMessage().serialize(convertedComponent));
|
return messageComponent("prefixSetTo", MiniMessage.miniMessage().serialize(convertedComponent));
|
||||||
}
|
}
|
||||||
@ -82,7 +80,7 @@ public class TagCMD extends PlexCommand
|
|||||||
DataUtils.update(player);
|
DataUtils.update(player);
|
||||||
return messageComponent("prefixCleared");
|
return messageComponent("prefixCleared");
|
||||||
}
|
}
|
||||||
checkPermission(sender, "plex.tag.clear.others");
|
checkPermission(sender,"plex.tag.clear.others");
|
||||||
Player target = getNonNullPlayer(args[1]);
|
Player target = getNonNullPlayer(args[1]);
|
||||||
PlexPlayer plexTarget = DataUtils.getPlayer(target.getUniqueId());
|
PlexPlayer plexTarget = DataUtils.getPlayer(target.getUniqueId());
|
||||||
plexTarget.setPrefix(null);
|
plexTarget.setPrefix(null);
|
||||||
@ -91,26 +89,6 @@ public class TagCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
return usage();
|
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.player.PlexPlayer;
|
||||||
import dev.plex.punishment.Punishment;
|
import dev.plex.punishment.Punishment;
|
||||||
import dev.plex.punishment.PunishmentType;
|
import dev.plex.punishment.PunishmentType;
|
||||||
|
|
||||||
import dev.plex.util.BungeeUtil;
|
import dev.plex.util.BungeeUtil;
|
||||||
import dev.plex.util.PlexLog;
|
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.TimeUtils;
|
import dev.plex.util.TimeUtils;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -22,10 +22,9 @@ import org.bukkit.entity.Player;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@CommandParameters(name = "tempban", usage = "/<command> <player> <time> [reason] [-rb]", description = "Temporarily ban a player")
|
@CommandParameters(name = "tempban", usage = "/<command> <player> <time> [reason]", description = "Temporarily ban a player")
|
||||||
@CommandPermissions(permission = "plex.tempban", source = RequiredCommandSource.ANY)
|
@CommandPermissions(permission = "plex.tempban", source = RequiredCommandSource.ANY)
|
||||||
|
|
||||||
public class TempbanCMD extends PlexCommand
|
public class TempbanCMD extends PlexCommand
|
||||||
@ -53,17 +52,14 @@ public class TempbanCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
Punishment punishment = new Punishment(target.getUuid(), getUUID(sender));
|
Punishment punishment = new Punishment(target.getUuid(), getUUID(sender));
|
||||||
punishment.setType(PunishmentType.TEMPBAN);
|
punishment.setType(PunishmentType.TEMPBAN);
|
||||||
boolean rollBack = false;
|
|
||||||
if (args.length > 2)
|
if (args.length > 2)
|
||||||
{
|
{
|
||||||
reason = StringUtils.join(args, " ", 2, args.length);
|
reason = StringUtils.join(args, " ", 2, args.length);
|
||||||
String newReason = StringUtils.normalizeSpace(reason.replace("-nrb", ""));
|
punishment.setReason(reason);
|
||||||
punishment.setReason(newReason.trim().isEmpty() ? messageString("noReasonProvided") : newReason);
|
|
||||||
rollBack = reason.startsWith("-rb") || reason.endsWith("-rb");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
punishment.setReason(messageString("noReasonProvided"));
|
punishment.setReason("No reason provided.");
|
||||||
}
|
}
|
||||||
punishment.setPunishedUsername(target.getName());
|
punishment.setPunishedUsername(target.getName());
|
||||||
punishment.setEndDate(TimeUtils.createDate(args[1]));
|
punishment.setEndDate(TimeUtils.createDate(args[1]));
|
||||||
@ -79,46 +75,12 @@ public class TempbanCMD extends PlexCommand
|
|||||||
{
|
{
|
||||||
BungeeUtil.kickPlayer(player, Punishment.generateBanMessage(punishment));
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
return args.length == 1 && silentCheckPermission(sender,"plex.tempban") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,92 +0,0 @@
|
|||||||
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,6 +6,7 @@ import dev.plex.command.annotation.CommandParameters;
|
|||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.menu.impl.ToggleMenu;
|
import dev.plex.menu.impl.ToggleMenu;
|
||||||
|
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
@ -32,8 +33,6 @@ public class ToggleCMD extends PlexCommand
|
|||||||
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Fluidspread" + status("fluidspread")));
|
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Fluidspread" + status("fluidspread")));
|
||||||
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Drops" + status("drops")));
|
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Drops" + status("drops")));
|
||||||
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Redstone" + status("redstone")));
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
switch (args[0].toLowerCase())
|
switch (args[0].toLowerCase())
|
||||||
@ -54,15 +53,6 @@ public class ToggleCMD extends PlexCommand
|
|||||||
{
|
{
|
||||||
return toggle("redstone");
|
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 ->
|
default ->
|
||||||
{
|
{
|
||||||
return messageComponent("invalidToggle");
|
return messageComponent("invalidToggle");
|
||||||
@ -74,9 +64,9 @@ public class ToggleCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
return args.length == 1 ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
private String status(String toggle)
|
private String status(String toggle)
|
||||||
|
@ -9,6 +9,7 @@ import dev.plex.command.exception.PlayerNotBannedException;
|
|||||||
import dev.plex.command.exception.PlayerNotFoundException;
|
import dev.plex.command.exception.PlayerNotFoundException;
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
|
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -55,8 +56,8 @@ public class UnbanCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
return args.length == 1 && silentCheckPermission(sender,"plex.unban") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package dev.plex.command.impl;
|
package dev.plex.command.impl;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import dev.plex.cache.DataUtils;
|
|
||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.exception.CommandFailException;
|
import dev.plex.command.exception.CommandFailException;
|
||||||
import dev.plex.command.exception.PlayerNotFoundException;
|
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.punishment.PunishmentType;
|
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -29,28 +27,20 @@ public class UnfreezeCMD extends PlexCommand
|
|||||||
{
|
{
|
||||||
return usage();
|
return usage();
|
||||||
}
|
}
|
||||||
PlexPlayer punishedPlayer = DataUtils.getPlayer(args[0]);
|
Player player = getNonNullPlayer(args[0]);
|
||||||
if (punishedPlayer == null)
|
PlexPlayer punishedPlayer = getOfflinePlexPlayer(player.getUniqueId());
|
||||||
{
|
|
||||||
throw new PlayerNotFoundException();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!punishedPlayer.isFrozen())
|
if (!punishedPlayer.isFrozen())
|
||||||
{
|
{
|
||||||
throw new CommandFailException(PlexUtils.messageString("playerNotFrozen"));
|
throw new CommandFailException(PlexUtils.messageString("playerNotFrozen"));
|
||||||
}
|
}
|
||||||
punishedPlayer.setFrozen(false);
|
punishedPlayer.setFrozen(false);
|
||||||
punishedPlayer.getPunishments().stream().filter(punishment -> punishment.getType() == PunishmentType.FREEZE && punishment.isActive()).forEach(punishment -> {
|
PlexUtils.broadcast(messageComponent("unfrozePlayer", sender.getName(), player.getName()));
|
||||||
punishment.setActive(false);
|
|
||||||
plugin.getSqlPunishment().updatePunishment(punishment.getType(), false, punishment.getPunished());
|
|
||||||
});
|
|
||||||
PlexUtils.broadcast(messageComponent("unfrozePlayer", sender.getName(), punishedPlayer.getName()));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
return args.length == 1 && silentCheckPermission(sender,"plex.unfreeze") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,12 @@
|
|||||||
package dev.plex.command.impl;
|
package dev.plex.command.impl;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import dev.plex.cache.DataUtils;
|
|
||||||
import dev.plex.command.PlexCommand;
|
import dev.plex.command.PlexCommand;
|
||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.exception.CommandFailException;
|
import dev.plex.command.exception.CommandFailException;
|
||||||
import dev.plex.command.exception.PlayerNotFoundException;
|
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.punishment.PunishmentType;
|
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -29,28 +27,20 @@ public class UnmuteCMD extends PlexCommand
|
|||||||
{
|
{
|
||||||
return usage();
|
return usage();
|
||||||
}
|
}
|
||||||
PlexPlayer punishedPlayer = DataUtils.getPlayer(args[0]);
|
Player player = getNonNullPlayer(args[0]);
|
||||||
if (punishedPlayer == null)
|
PlexPlayer punishedPlayer = getOfflinePlexPlayer(player.getUniqueId());
|
||||||
{
|
|
||||||
throw new PlayerNotFoundException();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!punishedPlayer.isMuted())
|
if (!punishedPlayer.isMuted())
|
||||||
{
|
{
|
||||||
throw new CommandFailException(PlexUtils.messageString("playerNotMuted"));
|
throw new CommandFailException(PlexUtils.messageString("playerNotMuted"));
|
||||||
}
|
}
|
||||||
punishedPlayer.setMuted(false);
|
punishedPlayer.setMuted(false);
|
||||||
punishedPlayer.getPunishments().stream().filter(punishment -> punishment.getType() == PunishmentType.MUTE && punishment.isActive()).forEach(punishment -> {
|
PlexUtils.broadcast(messageComponent("unmutedPlayer", sender.getName(), player.getName()));
|
||||||
punishment.setActive(false);
|
|
||||||
plugin.getSqlPunishment().updatePunishment(punishment.getType(), false, punishment.getPunished());
|
|
||||||
});
|
|
||||||
PlexUtils.broadcast(messageComponent("unmutedPlayer", sender.getName(), punishedPlayer.getName()));
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
return args.length == 1 && silentCheckPermission(sender, this.getPermission()) ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
return args.length == 1 && silentCheckPermission(sender,"plex.unfreeze") ? PlexUtils.getPlayerNameList() : ImmutableList.of();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Collections;
|
|
||||||
|
|
||||||
@CommandPermissions(permission = "plex.whohas")
|
@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")
|
@CommandParameters(name = "whohas", description = "Returns a list of players with a specific item in their inventory.", usage = "/<command> <material>", aliases = "wh")
|
||||||
@ -37,43 +36,17 @@ public class WhoHasCMD extends PlexCommand
|
|||||||
return messageComponent("materialNotFound", args[0]);
|
return messageComponent("materialNotFound", args[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean clearInventory = args.length > 1 && args[1].equalsIgnoreCase("clear");
|
final List<TextComponent> players = Bukkit.getOnlinePlayers().stream().filter(player ->
|
||||||
|
player.getInventory().contains(material)).map(player -> Component.text(player.getName())).toList();
|
||||||
|
|
||||||
if (clearInventory && !sender.hasPermission("plex.whohas.clear"))
|
return players.isEmpty() ? messageComponent("nobodyHasThatMaterial") :
|
||||||
{
|
messageComponent("playersWithMaterial", Component.text(material.name()),
|
||||||
return messageComponent("noPermissionNode", "plex.whohas.clear");
|
Component.join(JoinConfiguration.commas(true), players));
|
||||||
}
|
|
||||||
|
|
||||||
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
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
if (args.length == 1 && silentCheckPermission(sender, this.getPermission()))
|
return args.length == 1 && silentCheckPermission(sender, "plex.whohas") ? Arrays.stream(Material.values()).map(Enum::name).toList() : ImmutableList.of();
|
||||||
{
|
|
||||||
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,6 +6,7 @@ import dev.plex.command.PlexCommand;
|
|||||||
import dev.plex.command.annotation.CommandParameters;
|
import dev.plex.command.annotation.CommandParameters;
|
||||||
import dev.plex.command.annotation.CommandPermissions;
|
import dev.plex.command.annotation.CommandPermissions;
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -37,18 +38,19 @@ public class WorldCMD extends PlexCommand
|
|||||||
boolean playerWorld = args[0].matches("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}");
|
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")))
|
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());
|
playerSender.teleportAsync(world.getSpawnLocation());
|
||||||
return messageComponent("playerWorldTeleport", world.getName());
|
return messageComponent("playerWorldTeleport", world.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
public @NotNull List<String> tabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||||
{
|
{
|
||||||
final List<String> completions = Lists.newArrayList();
|
final List<String> completions = Lists.newArrayList();
|
||||||
final Player player = (Player) sender;
|
final Player player = (Player) sender;
|
||||||
if (args.length == 1 && silentCheckPermission(sender, this.getPermission()))
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
@NotNull List<World> worlds = Bukkit.getWorlds();
|
@NotNull List<World> worlds = Bukkit.getWorlds();
|
||||||
for (World world : worlds)
|
for (World world : worlds)
|
||||||
@ -58,7 +60,7 @@ public class WorldCMD extends PlexCommand
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final UUID uuid = UUID.fromString(worldName);
|
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);
|
completions.add(worldName);
|
||||||
}
|
}
|
||||||
|
@ -1,63 +0,0 @@
|
|||||||
package dev.plex.hook;
|
|
||||||
|
|
||||||
import dev.plex.Plex;
|
|
||||||
import dev.plex.player.PlexPlayer;
|
|
||||||
import dev.plex.util.PlexLog;
|
|
||||||
import dev.plex.util.PlexUtils;
|
|
||||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
|
||||||
import net.coreprotect.CoreProtect;
|
|
||||||
import net.coreprotect.CoreProtectAPI;
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.milkbowl.vault.chat.Chat;
|
|
||||||
import net.milkbowl.vault.permission.Permission;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.OfflinePlayer;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class CoreProtectHook
|
|
||||||
{
|
|
||||||
private CoreProtectAPI coreProtectAPI;
|
|
||||||
private boolean hasApi;
|
|
||||||
|
|
||||||
public CoreProtectHook(Plex plex)
|
|
||||||
{
|
|
||||||
Plugin plugin = plex.getServer().getPluginManager().getPlugin("CoreProtect");
|
|
||||||
|
|
||||||
// Check that CoreProtect is loaded
|
|
||||||
if (!(plugin instanceof CoreProtect))
|
|
||||||
{
|
|
||||||
PlexLog.debug("Plugin was not CoreProtect.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that the API is enabled
|
|
||||||
CoreProtectAPI coreProtectAPI = ((CoreProtect) plugin).getAPI();
|
|
||||||
this.hasApi = coreProtectAPI.isEnabled();
|
|
||||||
if (!hasApi)
|
|
||||||
{
|
|
||||||
PlexLog.debug("CoreProtect API was disabled.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that a compatible version of the API is loaded
|
|
||||||
if (coreProtectAPI.APIVersion() < 9)
|
|
||||||
{
|
|
||||||
PlexLog.debug("CoreProtect API version is: {0}", coreProtectAPI.APIVersion());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this.coreProtectAPI = coreProtectAPI;
|
|
||||||
this.coreProtectAPI.testAPI();
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasCoreProtect() {
|
|
||||||
return hasApi;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CoreProtectAPI coreProtectAPI()
|
|
||||||
{
|
|
||||||
return coreProtectAPI;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
package dev.plex.hook;
|
|
||||||
|
|
||||||
import dev.plex.Plex;
|
|
||||||
import network.darkhelmet.prism.api.PrismApi;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
public class PrismHook
|
|
||||||
{
|
|
||||||
private PrismApi prismApi;
|
|
||||||
|
|
||||||
public PrismHook(Plex plex)
|
|
||||||
{
|
|
||||||
Plugin plugin = plex.getServer().getPluginManager().getPlugin("Prism");
|
|
||||||
|
|
||||||
// Check that Prism is loaded
|
|
||||||
if (!plugin.isEnabled())
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check that the API is enabled
|
|
||||||
this.prismApi = (PrismApi) plugin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasPrism() {
|
|
||||||
return prismApi != null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PrismApi prismApi()
|
|
||||||
{
|
|
||||||
return prismApi;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -82,8 +82,8 @@ public class VaultHook
|
|||||||
if (vaultPrefix == null || vaultPrefix.isEmpty()) {
|
if (vaultPrefix == null || vaultPrefix.isEmpty()) {
|
||||||
return Component.empty();
|
return Component.empty();
|
||||||
}
|
}
|
||||||
PlexLog.debug("prefix: {0}", SafeMiniMessage.mmSerializeWithoutEvents(PlexUtils.stringToComponent(vaultPrefix)).replace("<", "\\<"));
|
PlexLog.debug("prefix: {0}", PlexUtils.legacyToMiniString(vaultPrefix).replace("<", "\\<"));
|
||||||
return PlexUtils.stringToComponent(vaultPrefix);
|
return SafeMiniMessage.mmDeserializeWithoutEvents(PlexUtils.legacyToMiniString(vaultPrefix));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Permission getPermission()
|
public static Permission getPermission()
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package dev.plex.listener.impl;
|
package dev.plex.listener.impl;
|
||||||
|
|
||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.util.PlexUtils;
|
|
||||||
import dev.plex.services.impl.TimingService;
|
import dev.plex.services.impl.TimingService;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -20,7 +19,7 @@ public class AntiNukerListener extends PlexListener
|
|||||||
if (getCount(event.getPlayer().getUniqueId()) > 200L)
|
if (getCount(event.getPlayer().getUniqueId()) > 200L)
|
||||||
{
|
{
|
||||||
TimingService.strikes.merge(event.getPlayer().getUniqueId(), 1L, Long::sum);
|
TimingService.strikes.merge(event.getPlayer().getUniqueId(), 1L, Long::sum);
|
||||||
event.getPlayer().kick(PlexUtils.messageComponent("nukerKickMessage"));
|
event.getPlayer().kick(Component.text("Please turn off your nuker!"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,7 +31,7 @@ public class AntiNukerListener extends PlexListener
|
|||||||
if (getCount(event.getPlayer().getUniqueId()) > 200L)
|
if (getCount(event.getPlayer().getUniqueId()) > 200L)
|
||||||
{
|
{
|
||||||
TimingService.strikes.merge(event.getPlayer().getUniqueId(), 1L, Long::sum);
|
TimingService.strikes.merge(event.getPlayer().getUniqueId(), 1L, Long::sum);
|
||||||
event.getPlayer().kick(PlexUtils.messageComponent("nukerKickMessage"));
|
event.getPlayer().kick(Component.text("Please turn off your nuker!"));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package dev.plex.listener.impl;
|
package dev.plex.listener.impl;
|
||||||
|
|
||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.util.PlexUtils;
|
|
||||||
import dev.plex.services.impl.TimingService;
|
import dev.plex.services.impl.TimingService;
|
||||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -20,7 +19,7 @@ public class AntiSpamListener extends PlexListener
|
|||||||
TimingService.spamCooldown.merge(event.getPlayer().getUniqueId(), 1L, Long::sum);
|
TimingService.spamCooldown.merge(event.getPlayer().getUniqueId(), 1L, Long::sum);
|
||||||
if (getCount(event.getPlayer().getUniqueId()) > 8L)
|
if (getCount(event.getPlayer().getUniqueId()) > 8L)
|
||||||
{
|
{
|
||||||
event.getPlayer().sendMessage(PlexUtils.messageComponent("antiSpamMessage"));
|
event.getPlayer().sendMessage(Component.text("Please refrain from spamming messages.").color(NamedTextColor.GRAY));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -31,7 +30,7 @@ public class AntiSpamListener extends PlexListener
|
|||||||
TimingService.spamCooldown.merge(event.getPlayer().getUniqueId(), 1L, Long::sum);
|
TimingService.spamCooldown.merge(event.getPlayer().getUniqueId(), 1L, Long::sum);
|
||||||
if (getCount(event.getPlayer().getUniqueId()) > 8L)
|
if (getCount(event.getPlayer().getUniqueId()) > 8L)
|
||||||
{
|
{
|
||||||
event.getPlayer().sendMessage(PlexUtils.messageComponent("antiSpamMessage"));
|
event.getPlayer().sendMessage(Component.text("Please refrain from spamming commands.").color(NamedTextColor.GRAY));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,8 +7,6 @@ import dev.plex.player.PlexPlayer;
|
|||||||
import dev.plex.punishment.Punishment;
|
import dev.plex.punishment.Punishment;
|
||||||
import dev.plex.punishment.PunishmentManager;
|
import dev.plex.punishment.PunishmentManager;
|
||||||
import dev.plex.punishment.PunishmentType;
|
import dev.plex.punishment.PunishmentType;
|
||||||
import dev.plex.util.PlexLog;
|
|
||||||
import it.unimi.dsi.fastutil.Pair;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||||
@ -45,26 +43,11 @@ public class BanListener extends PlexListener
|
|||||||
|
|
||||||
if (plugin.getPunishmentManager().isBanned(event.getUniqueId()))
|
if (plugin.getPunishmentManager().isBanned(event.getUniqueId()))
|
||||||
{
|
{
|
||||||
if (Plex.get().getPermissions() != null && Plex.get().getPermissions().playerHas(null, Bukkit.getOfflinePlayer(event.getUniqueId()), "plex.ban.bypass"))
|
if (Plex.get().getPermissions() != null && Plex.get().getPermissions().playerHas(null, Bukkit.getOfflinePlayer(event.getUniqueId()), "plex.ban.bypass")) return;
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PlexPlayer player = DataUtils.getPlayer(event.getUniqueId());
|
PlexPlayer player = DataUtils.getPlayer(event.getUniqueId());
|
||||||
player.getPunishments().stream().filter(punishment -> (punishment.getType() == PunishmentType.BAN || punishment.getType() == PunishmentType.TEMPBAN) && punishment.isActive()).findFirst().ifPresent(punishment ->
|
player.getPunishments().stream().filter(punishment -> (punishment.getType() == PunishmentType.BAN || punishment.getType() == PunishmentType.TEMPBAN) && punishment.isActive()).findFirst().ifPresent(punishment ->
|
||||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED,
|
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED,
|
||||||
Punishment.generateBanMessage(punishment)));
|
Punishment.generateBanMessage(punishment)));
|
||||||
return;
|
|
||||||
}
|
|
||||||
Punishment ipBannedPunishment = plugin.getPunishmentManager().getBanByIP(event.getAddress().getHostAddress());
|
|
||||||
if (ipBannedPunishment != null)
|
|
||||||
{
|
|
||||||
// Don't check if the other account that's banned has bypass abilities, check if current has only
|
|
||||||
if (Plex.get().getPermissions() != null && Plex.get().getPermissions().playerHas(null, Bukkit.getOfflinePlayer(event.getUniqueId()), "plex.ban.bypass"))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_BANNED,
|
|
||||||
Punishment.generateBanMessage(ipBannedPunishment));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -12,6 +12,7 @@ import io.papermc.paper.chat.ChatRenderer;
|
|||||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||||
import net.kyori.adventure.audience.Audience;
|
import net.kyori.adventure.audience.Audience;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
import net.kyori.adventure.text.TextReplacementConfig;
|
import net.kyori.adventure.text.TextReplacementConfig;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
@ -46,7 +47,7 @@ public class ChatListener extends PlexListener
|
|||||||
{
|
{
|
||||||
String prefix = PlexUtils.mmSerialize(VaultHook.getPrefix(event.getPlayer())); // Don't use PlexPlayer#getPrefix because that returns their custom set prefix and not their group's
|
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));
|
MessageUtil.sendStaffChat(event.getPlayer(), event.message(), PlexUtils.adminChat(event.getPlayer().getName(), prefix, SafeMiniMessage.mmSerialize(event.message())).toArray(UUID[]::new));
|
||||||
plugin.getServer().getConsoleSender().sendMessage(PlexUtils.messageComponent("adminChatFormat", event.getPlayer().getName(), prefix, SafeMiniMessage.mmSerialize(event.message().replaceText(URL_REPLACEMENT_CONFIG))));
|
plugin.getServer().getConsoleSender().sendMessage(PlexUtils.messageComponent("adminChatFormat", event.getPlayer().getName(), prefix, PlexUtils.legacyToMiniString(SafeMiniMessage.mmSerializeWithoutEvents(event.message()))).replaceText(URL_REPLACEMENT_CONFIG));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -104,7 +105,7 @@ public class ChatListener extends PlexListener
|
|||||||
|
|
||||||
private static void defaultChatProcessing(AsyncChatEvent event, PlexPlayer plexPlayer)
|
private static void defaultChatProcessing(AsyncChatEvent event, PlexPlayer plexPlayer)
|
||||||
{
|
{
|
||||||
String text = PlexUtils.getTextFromComponent(event.message());
|
String text = PlexUtils.legacyToMiniString(PlexUtils.getTextFromComponent(event.message()));
|
||||||
event.message(PlexUtils.stringToComponent(text));
|
event.message(SafeMiniMessage.mmDeserializeWithoutEvents(text));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package dev.plex.listener.impl;
|
|||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.util.BlockUtils;
|
import dev.plex.util.BlockUtils;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -12,7 +11,6 @@ import org.bukkit.entity.Ageable;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -72,17 +70,6 @@ public class MobListener extends PlexListener
|
|||||||
Collection<Player> coll = location.getNearbyEntitiesByType(Player.class, 10);
|
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)
|
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
|
@EventHandler
|
||||||
@ -148,11 +135,4 @@ 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,7 +6,6 @@ import dev.plex.meta.PlayerMeta;
|
|||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.List;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.event.ClickEvent;
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
@ -19,7 +18,9 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
public class PlayerListener extends PlexListener
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PlayerListener<T> extends PlexListener
|
||||||
{
|
{
|
||||||
// setting up a player's data
|
// setting up a player's data
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
@ -62,18 +63,20 @@ public class PlayerListener extends PlexListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
String loginMessage = PlayerMeta.getLoginMessage(plexPlayer);
|
String loginMessage = PlayerMeta.getLoginMessage(plexPlayer);
|
||||||
if (!loginMessage.isEmpty() && !PlayerMeta.isVanished(player))
|
if (!loginMessage.isEmpty())
|
||||||
{
|
{
|
||||||
PlexUtils.broadcast(PlexUtils.stringToComponent(loginMessage));
|
PlexUtils.broadcast(loginMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
plexPlayer.loadNotes();
|
plexPlayer.loadNotes();
|
||||||
|
|
||||||
plugin.getSqlNotes().getNotes(plexPlayer.getUuid()).whenComplete((notes, ex) ->
|
plugin.getSqlNotes().getNotes(plexPlayer.getUuid()).whenComplete((notes, ex) ->
|
||||||
{
|
{
|
||||||
|
String plural = notes.size() == 1 ? "note." : "notes.";
|
||||||
if (!notes.isEmpty())
|
if (!notes.isEmpty())
|
||||||
{
|
{
|
||||||
PlexUtils.broadcastToAdmins(PlexUtils.messageComponent(notes.size() == 1 ? "playerNoteAlert" : "playerNoteAlertPlural", plexPlayer.getName(), notes.size()), "plex.notes.notify");
|
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");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -93,7 +96,7 @@ public class PlayerListener extends PlexListener
|
|||||||
PlexPlayer player = DataUtils.getPlayer(event.getPlayer().getUniqueId());
|
PlexPlayer player = DataUtils.getPlayer(event.getPlayer().getUniqueId());
|
||||||
if (player.isLockedUp())
|
if (player.isLockedUp())
|
||||||
{
|
{
|
||||||
Bukkit.getGlobalRegionScheduler().runDelayed(plugin, (scheduledTask) -> event.getPlayer().openInventory(event.getInventory()), 1L);
|
Bukkit.getScheduler().runTaskLater(plugin, () -> event.getPlayer().openInventory(event.getInventory()), 1L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package dev.plex.listener.impl;
|
||||||
|
|
||||||
|
import dev.plex.listener.PlexListener;
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.SignChangeEvent;
|
||||||
|
|
||||||
|
public class SignListener extends PlexListener
|
||||||
|
{
|
||||||
|
private static final LegacyComponentSerializer LEGACY_COMPONENT_SERIALIZER = LegacyComponentSerializer.legacyAmpersand();
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onSignEdit(SignChangeEvent event)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < event.lines().size(); i++)
|
||||||
|
{
|
||||||
|
event.line(i, LEGACY_COMPONENT_SERIALIZER.deserialize(PlexUtils.getTextFromComponent(event.line(i))));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,29 +1,16 @@
|
|||||||
package dev.plex.listener.impl;
|
package dev.plex.listener.impl;
|
||||||
|
|
||||||
import dev.plex.Plex;
|
|
||||||
import dev.plex.listener.PlexListener;
|
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.EventHandler;
|
||||||
import org.bukkit.event.block.BlockExplodeEvent;
|
import org.bukkit.event.block.BlockExplodeEvent;
|
||||||
import org.bukkit.event.block.BlockFromToEvent;
|
import org.bukkit.event.block.BlockFromToEvent;
|
||||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||||
import org.bukkit.event.entity.*;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
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
|
public class TogglesListener extends PlexListener
|
||||||
{
|
{
|
||||||
List<String> commands = plugin.commands.getStringList("block_on_mute");
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onExplosionPrime(ExplosionPrimeEvent event)
|
public void onExplosionPrime(ExplosionPrimeEvent event)
|
||||||
{
|
{
|
||||||
@ -35,8 +22,7 @@ public class TogglesListener extends PlexListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onBlockExplode(BlockExplodeEvent event)
|
public void onBlockExplode(BlockExplodeEvent event) {
|
||||||
{
|
|
||||||
if (!plugin.toggles.getBoolean("explosions"))
|
if (!plugin.toggles.getBoolean("explosions"))
|
||||||
{
|
{
|
||||||
event.getBlock().breakNaturally();
|
event.getBlock().breakNaturally();
|
||||||
@ -72,100 +58,6 @@ 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
|
/* 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
|
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.
|
and re-enabling redstone, you are unable to recreate the loop with a lever. Using a redstone torch works fine.
|
||||||
|
@ -1,32 +0,0 @@
|
|||||||
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,8 +112,7 @@ public class WorldListener extends PlexListener
|
|||||||
boolean isFaweCommand = command instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) command).getPlugin().equals(Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit"));
|
boolean isFaweCommand = command instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) command).getPlugin().equals(Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit"));
|
||||||
if (isWeCommand || isFaweCommand || EDIT_COMMANDS.contains(message.toLowerCase()))
|
if (isWeCommand || isFaweCommand || EDIT_COMMANDS.contains(message.toLowerCase()))
|
||||||
{
|
{
|
||||||
String noEdit = plugin.config.getString("worlds." + event.getPlayer().getWorld().getName().toLowerCase() + ".modification.message");
|
event.getPlayer().sendMessage(Component.text("You do not have permission to use that command in this world.").color(NamedTextColor.RED));
|
||||||
event.getPlayer().sendMessage(MiniMessage.miniMessage().deserialize(noEdit));
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public class PunishedPlayerMenu extends PageableMenu<Punishment>
|
|||||||
@Override
|
@Override
|
||||||
protected ItemStack toItem(Punishment object)
|
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.getPunisher())), "<!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.getPunished())), "<!italic><red>Expire(d/s): <gold>" + TimeUtils.useTimezone(object.getEndDate()), "<!italic><red>Reason: <gold>" + object.getReason()).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -7,7 +7,6 @@ import org.bukkit.Material;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.InventoryView;
|
import org.bukkit.inventory.InventoryView;
|
||||||
import org.bukkit.inventory.ItemFlag;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
@ -25,8 +24,6 @@ public class ToggleMenu extends AbstractMenu
|
|||||||
resetFluidspreadItem(this.inventory());
|
resetFluidspreadItem(this.inventory());
|
||||||
resetDropsItem(this.inventory());
|
resetDropsItem(this.inventory());
|
||||||
resetRedstoneItem(this.inventory());
|
resetRedstoneItem(this.inventory());
|
||||||
resetPVPItem(this.inventory());
|
|
||||||
resetChatItem(this.inventory());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetExplosionItem(Inventory inventory)
|
private void resetExplosionItem(Inventory inventory)
|
||||||
@ -69,27 +66,6 @@ public class ToggleMenu extends AbstractMenu
|
|||||||
inventory.setItem(3, redstone);
|
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
|
@Override
|
||||||
public boolean onClick(InventoryView view, Inventory inventory, Player player, ItemStack clicked)
|
public boolean onClick(InventoryView view, Inventory inventory, Player player, ItemStack clicked)
|
||||||
{
|
{
|
||||||
@ -117,19 +93,6 @@ public class ToggleMenu extends AbstractMenu
|
|||||||
resetRedstoneItem(inventory);
|
resetRedstoneItem(inventory);
|
||||||
player.sendMessage(PlexUtils.mmDeserialize("<gray>Toggled redstone."));
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,27 +10,9 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
|||||||
import net.kyori.adventure.text.format.TextColor;
|
import net.kyori.adventure.text.format.TextColor;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.metadata.MetadataValue;
|
|
||||||
|
|
||||||
public class PlayerMeta
|
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)
|
public static Component getPrefix(PlexPlayer plexPlayer)
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,6 @@ import com.google.common.collect.Lists;
|
|||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.punishment.Punishment;
|
import dev.plex.punishment.Punishment;
|
||||||
import dev.plex.punishment.PunishmentType;
|
|
||||||
import dev.plex.punishment.extra.Note;
|
import dev.plex.punishment.extra.Note;
|
||||||
import dev.plex.storage.annotation.MapObjectList;
|
import dev.plex.storage.annotation.MapObjectList;
|
||||||
import dev.plex.storage.annotation.PrimaryKey;
|
import dev.plex.storage.annotation.PrimaryKey;
|
||||||
@ -80,7 +79,6 @@ public class PlexPlayer
|
|||||||
if (loadPunishments)
|
if (loadPunishments)
|
||||||
{
|
{
|
||||||
this.loadPunishments();
|
this.loadPunishments();
|
||||||
this.checkMutesAndFreeze();
|
|
||||||
// this.permissions.addAll(Plex.get().getSqlPermissions().getPermissions(this.uuid));
|
// this.permissions.addAll(Plex.get().getSqlPermissions().getPermissions(this.uuid));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,12 +93,6 @@ public class PlexPlayer
|
|||||||
return PlainTextComponentSerializer.plainText().serialize(getPlayer().displayName());
|
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()
|
public void loadPunishments()
|
||||||
{
|
{
|
||||||
this.setPunishments(Plex.get().getSqlPunishment().getPunishments(this.getUuid()));
|
this.setPunishments(Plex.get().getSqlPunishment().getPunishments(this.getUuid()));
|
||||||
|
@ -3,14 +3,21 @@ package dev.plex.punishment;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.PlexBase;
|
import dev.plex.PlexBase;
|
||||||
import dev.plex.cache.DataUtils;
|
import dev.plex.cache.DataUtils;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
|
import dev.plex.storage.StorageType;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.TimeUtils;
|
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.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
@ -21,17 +28,7 @@ import java.util.Collection;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.stream.Collectors;
|
||||||
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
|
public class PunishmentManager implements PlexBase
|
||||||
{
|
{
|
||||||
@ -138,6 +135,7 @@ public class PunishmentManager implements PlexBase
|
|||||||
|
|
||||||
public boolean isBanned(UUID uuid)
|
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))
|
if (!DataUtils.hasPlayedBefore(uuid))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -145,11 +143,6 @@ public class PunishmentManager implements PlexBase
|
|||||||
return DataUtils.getPlayer(uuid).getPunishments().stream().anyMatch(punishment -> (punishment.getType() == PunishmentType.BAN || punishment.getType() == PunishmentType.TEMPBAN) && punishment.isActive());
|
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)
|
public boolean isBanned(PlexPlayer player)
|
||||||
{
|
{
|
||||||
return isBanned(player.getUuid());
|
return isBanned(player.getUuid());
|
||||||
@ -179,11 +172,6 @@ public class PunishmentManager implements PlexBase
|
|||||||
return Plex.get().getSqlPunishment().removeBan(uuid);
|
return Plex.get().getSqlPunishment().removeBan(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateOutdatedPunishments(PlexPlayer player)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void doPunishment(PlexPlayer player, Punishment punishment)
|
private void doPunishment(PlexPlayer player, Punishment punishment)
|
||||||
{
|
{
|
||||||
if (punishment.getType() == PunishmentType.FREEZE)
|
if (punishment.getType() == PunishmentType.FREEZE)
|
||||||
@ -197,18 +185,13 @@ public class PunishmentManager implements PlexBase
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
PlexPlayer afterPlayer = DataUtils.getPlayer(player.getUuid());
|
if (!player.isFrozen())
|
||||||
if (!afterPlayer.isFrozen())
|
|
||||||
{
|
{
|
||||||
this.cancel();
|
this.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
afterPlayer.setFrozen(false);
|
player.setFrozen(false);
|
||||||
punishment.setActive(false);
|
Bukkit.broadcast(PlexUtils.messageComponent("unfrozePlayer", "Plex", Bukkit.getOfflinePlayer(player.getUuid()).getName()));
|
||||||
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);
|
}.runTaskLater(Plex.get(), 20 * seconds);
|
||||||
}
|
}
|
||||||
@ -223,17 +206,13 @@ public class PunishmentManager implements PlexBase
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
PlexPlayer afterPlayer = DataUtils.getPlayer(player.getUuid());
|
if (!player.isMuted())
|
||||||
if (!afterPlayer.isMuted())
|
|
||||||
{
|
{
|
||||||
this.cancel();
|
this.cancel();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
afterPlayer.setMuted(false);
|
player.setMuted(false);
|
||||||
punishment.setActive(false);
|
Bukkit.broadcast(PlexUtils.messageComponent("unmutedPlayer", "Plex", Bukkit.getOfflinePlayer(player.getUuid()).getName()));
|
||||||
plugin.getSqlPunishment().updatePunishment(punishment.getType(), false, punishment.getPunished());
|
|
||||||
|
|
||||||
Bukkit.broadcast(PlexUtils.messageComponent("unmutedPlayer", "Plex", Bukkit.getOfflinePlayer(afterPlayer.getUuid()).getName()));
|
|
||||||
}
|
}
|
||||||
}.runTaskLater(Plex.get(), 20 * seconds);
|
}.runTaskLater(Plex.get(), 20 * seconds);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package dev.plex.services.impl;
|
|||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.services.AbstractService;
|
import dev.plex.services.AbstractService;
|
||||||
import dev.plex.util.TimeUtils;
|
import dev.plex.util.TimeUtils;
|
||||||
import dev.plex.util.PlexUtils;
|
|
||||||
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -28,7 +27,7 @@ public class BanService extends AbstractService
|
|||||||
if (ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE)).isAfter(punishment.getEndDate()))
|
if (ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE)).isAfter(punishment.getEndDate()))
|
||||||
{
|
{
|
||||||
Plex.get().getPunishmentManager().unban(punishment);
|
Plex.get().getPunishmentManager().unban(punishment);
|
||||||
Bukkit.broadcast(PlexUtils.messageComponent("banExpiredBroadcast", Bukkit.getOfflinePlayer(punishment.getPunished()).getName()));
|
Bukkit.broadcast(Component.text("Plex - Unbanned " + Bukkit.getOfflinePlayer(punishment.getPunished()).getName()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -21,11 +21,10 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
public class SQLPunishment
|
public class SQLPunishment
|
||||||
{
|
{
|
||||||
private static final String SELECT = "SELECT * FROM `punishments` WHERE punished=?";
|
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 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 INSERT = "INSERT INTO `punishments` (`punished`, `punisher`, `punishedUsername`, `ip`, `type`, `reason`, `customTime`, `active`, `endDate`) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?)";
|
||||||
private static final String UPDATE_PUNISHMENT = "UPDATE `punishments` SET active=? WHERE punished=? AND type=?";
|
private static final String UPDATE_BAN = "UPDATE `punishments` SET active=? WHERE active=? AND punished=? AND type=?";
|
||||||
|
|
||||||
public CompletableFuture<List<Punishment>> getPunishments()
|
public CompletableFuture<List<Punishment>> getPunishments()
|
||||||
{
|
{
|
||||||
@ -85,33 +84,6 @@ public class SQLPunishment
|
|||||||
}
|
}
|
||||||
return punishments;
|
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)
|
public CompletableFuture<Void> insertPunishment(Punishment punishment)
|
||||||
{
|
{
|
||||||
@ -145,16 +117,17 @@ public class SQLPunishment
|
|||||||
{
|
{
|
||||||
try (Connection con = Plex.get().getSqlConnection().getCon())
|
try (Connection con = Plex.get().getSqlConnection().getCon())
|
||||||
{
|
{
|
||||||
PreparedStatement statement = con.prepareStatement(UPDATE_PUNISHMENT);
|
PreparedStatement statement = con.prepareStatement(UPDATE_BAN);
|
||||||
statement.setBoolean(1, false);
|
statement.setBoolean(1, false);
|
||||||
statement.setString(2, uuid.toString());
|
statement.setBoolean(2, true);
|
||||||
statement.setString(3, PunishmentType.BAN.name());
|
statement.setString(3, uuid.toString());
|
||||||
statement.executeUpdate();
|
statement.setString(4, PunishmentType.BAN.name());
|
||||||
|
|
||||||
PreparedStatement statement1 = con.prepareStatement(UPDATE_PUNISHMENT);
|
PreparedStatement statement1 = con.prepareStatement(UPDATE_BAN);
|
||||||
statement1.setBoolean(1, false);
|
statement1.setBoolean(1, false);
|
||||||
statement1.setString(2, uuid.toString());
|
statement1.setBoolean(2, true);
|
||||||
statement1.setString(3, PunishmentType.TEMPBAN.name());
|
statement1.setString(3, uuid.toString());
|
||||||
|
statement1.setString(4, PunishmentType.TEMPBAN.name());
|
||||||
statement1.executeUpdate();
|
statement1.executeUpdate();
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
@ -163,41 +136,24 @@ 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)
|
public CompletableFuture<Void> removeBan(UUID uuid)
|
||||||
{
|
{
|
||||||
return CompletableFuture.runAsync(() ->
|
return CompletableFuture.runAsync(() ->
|
||||||
{
|
{
|
||||||
try (Connection con = Plex.get().getSqlConnection().getCon())
|
try (Connection con = Plex.get().getSqlConnection().getCon())
|
||||||
{
|
{
|
||||||
PreparedStatement statement = con.prepareStatement(UPDATE_PUNISHMENT);
|
PreparedStatement statement = con.prepareStatement(UPDATE_BAN);
|
||||||
statement.setBoolean(1, false);
|
statement.setBoolean(1, false);
|
||||||
statement.setString(2, uuid.toString());
|
statement.setBoolean(2, true);
|
||||||
statement.setString(3, PunishmentType.BAN.name());
|
statement.setString(3, uuid.toString());
|
||||||
|
statement.setString(4, PunishmentType.BAN.name());
|
||||||
statement.executeUpdate();
|
statement.executeUpdate();
|
||||||
|
|
||||||
PreparedStatement statement1 = con.prepareStatement(UPDATE_PUNISHMENT);
|
PreparedStatement statement1 = con.prepareStatement(UPDATE_BAN);
|
||||||
statement1.setBoolean(1, false);
|
statement1.setBoolean(1, false);
|
||||||
statement1.setString(2, uuid.toString());
|
statement1.setBoolean(2, true);
|
||||||
statement1.setString(3, PunishmentType.TEMPBAN.name());
|
statement1.setString(3, uuid.toString());
|
||||||
|
statement1.setString(4, PunishmentType.TEMPBAN.name());
|
||||||
statement1.executeUpdate();
|
statement1.executeUpdate();
|
||||||
}
|
}
|
||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
@ -206,5 +162,4 @@ public class SQLPunishment
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,29 +9,29 @@ import java.util.Properties;
|
|||||||
public class BuildInfo
|
public class BuildInfo
|
||||||
{
|
{
|
||||||
@Getter
|
@Getter
|
||||||
public static String author;
|
public static String number;
|
||||||
@Getter
|
@Getter
|
||||||
public static String commit;
|
public static String author;
|
||||||
@Getter
|
@Getter
|
||||||
public static String date;
|
public static String date;
|
||||||
@Getter
|
@Getter
|
||||||
public static String number;
|
public static String head;
|
||||||
|
|
||||||
public void load(Plex plugin)
|
public void load(Plex plugin)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Properties props;
|
Properties props;
|
||||||
try (InputStream in = plugin.getResource("build-vars.properties"))
|
try (InputStream in = plugin.getResource("build.properties"))
|
||||||
{
|
{
|
||||||
props = new Properties();
|
props = new Properties();
|
||||||
props.load(in);
|
props.load(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
author = props.getProperty("author", "unknown");
|
|
||||||
commit = props.getProperty("gitCommit", "unknown");
|
|
||||||
date = props.getProperty("date", "unknown");
|
|
||||||
number = props.getProperty("buildNumber", "unknown");
|
number = props.getProperty("buildNumber", "unknown");
|
||||||
|
author = props.getProperty("buildAuthor", "unknown");
|
||||||
|
date = props.getProperty("buildDate", "unknown");
|
||||||
|
head = props.getProperty("buildHead", "unknown");
|
||||||
}
|
}
|
||||||
catch (Exception ignored)
|
catch (Exception ignored)
|
||||||
{
|
{
|
||||||
|
@ -6,21 +6,16 @@ import dev.plex.Plex;
|
|||||||
import dev.plex.PlexBase;
|
import dev.plex.PlexBase;
|
||||||
import dev.plex.listener.impl.ChatListener;
|
import dev.plex.listener.impl.ChatListener;
|
||||||
import dev.plex.storage.StorageType;
|
import dev.plex.storage.StorageType;
|
||||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.TextComponent;
|
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.MiniMessage;
|
||||||
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
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 net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.PluginCommandYamlParser;
|
import org.bukkit.command.PluginCommandYamlParser;
|
||||||
import org.bukkit.entity.LivingEntity;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
@ -33,7 +28,6 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class PlexUtils implements PlexBase
|
public class PlexUtils implements PlexBase
|
||||||
@ -49,8 +43,6 @@ public class PlexUtils implements PlexBase
|
|||||||
"a52f1f08-a398-400a-bca4-2b74b81feae6" // Allink
|
"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)
|
public static <T> T addToArrayList(List<T> list, T object)
|
||||||
{
|
{
|
||||||
list.add(object);
|
list.add(object);
|
||||||
@ -120,15 +112,6 @@ public class PlexUtils implements PlexBase
|
|||||||
return true;
|
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)
|
public static boolean isPluginCMD(String cmd, String pluginName)
|
||||||
{
|
{
|
||||||
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginName);
|
Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin(pluginName);
|
||||||
@ -162,17 +145,6 @@ public class PlexUtils implements PlexBase
|
|||||||
return component;
|
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)
|
public static String legacyToMiniString(String input)
|
||||||
{
|
{
|
||||||
return cleanString(input.replace("&a", "<green>")
|
return cleanString(input.replace("&a", "<green>")
|
||||||
|
@ -7,7 +7,6 @@ import java.time.LocalDateTime;
|
|||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.time.temporal.ChronoUnit;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -80,41 +79,4 @@ public class TimeUtils
|
|||||||
}
|
}
|
||||||
return DATE_FORMAT.withZone(ZoneId.of(TIMEZONE)).format(date);
|
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 it's -4, it hasn't checked for updates yet
|
||||||
if (distance == -4)
|
if (distance == -4)
|
||||||
{
|
{
|
||||||
distance = fetchDistanceFromGitHub(REPO, BRANCH, BuildInfo.getCommit());
|
distance = fetchDistanceFromGitHub(REPO, BRANCH, BuildInfo.getHead());
|
||||||
PlexLog.debug("Never checked for updates, checking now...");
|
PlexLog.debug("Never checked for updates, checking now...");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -104,7 +104,7 @@ public class UpdateChecker implements PlexBase
|
|||||||
// If the request isn't asked to be cached, fetch it
|
// If the request isn't asked to be cached, fetch it
|
||||||
if (!cached)
|
if (!cached)
|
||||||
{
|
{
|
||||||
distance = fetchDistanceFromGitHub(REPO, BRANCH, BuildInfo.getCommit());
|
distance = fetchDistanceFromGitHub(REPO, BRANCH, BuildInfo.getHead());
|
||||||
PlexLog.debug("We have checked for updates before, but this request was not asked to be cached.");
|
PlexLog.debug("We have checked for updates before, but this request was not asked to be cached.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -2,7 +2,6 @@ package dev.plex.util.sql;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
|
||||||
import dev.plex.punishment.PunishmentType;
|
import dev.plex.punishment.PunishmentType;
|
||||||
import dev.plex.storage.annotation.*;
|
import dev.plex.storage.annotation.*;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
@ -14,7 +13,10 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.time.ZonedDateTime;
|
import java.time.ZonedDateTime;
|
||||||
import java.util.*;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -23,7 +25,7 @@ import java.util.stream.Collectors;
|
|||||||
*/
|
*/
|
||||||
public class SQLUtil
|
public class SQLUtil
|
||||||
{
|
{
|
||||||
public static final Map<String, Table> TABLES = Maps.newHashMap();
|
public static final List<Table> TABLES = Lists.newArrayList();
|
||||||
|
|
||||||
public static List<String> createTable(List<String> result, Class<?> clazz)
|
public static List<String> createTable(List<String> result, Class<?> clazz)
|
||||||
{
|
{
|
||||||
@ -81,7 +83,7 @@ public class SQLUtil
|
|||||||
mainResult.append(");");
|
mainResult.append(");");
|
||||||
result.add(mainResult.toString());
|
result.add(mainResult.toString());
|
||||||
|
|
||||||
TABLES.put(table.name(), table);
|
TABLES.add(table);
|
||||||
|
|
||||||
if (primaryKey == null && !collectionFields.isEmpty())
|
if (primaryKey == null && !collectionFields.isEmpty())
|
||||||
{
|
{
|
||||||
@ -111,22 +113,11 @@ public class SQLUtil
|
|||||||
writeFieldToSQL(listTable, sql, Mapper.getByClass(finalPrimaryKey.getType()), finalPrimaryKey);
|
writeFieldToSQL(listTable, sql, Mapper.getByClass(finalPrimaryKey.getType()), finalPrimaryKey);
|
||||||
sql.append(");");
|
sql.append(");");
|
||||||
result.add(sql.toString());
|
result.add(sql.toString());
|
||||||
table.mappedTables().put(field, listTable);
|
table.mappedTables().add(listTable);
|
||||||
});
|
});
|
||||||
return result;
|
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)
|
private static void writeFieldToSQL(Table table, StringBuilder sb, Mapper mapped, Field field)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -5,7 +5,6 @@ import com.google.common.collect.Maps;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -20,5 +19,5 @@ public class Table
|
|||||||
{
|
{
|
||||||
private final String name;
|
private final String name;
|
||||||
private final Map<String, SQLUtil.Mapper> columns = Maps.newHashMap();
|
private final Map<String, SQLUtil.Mapper> columns = Maps.newHashMap();
|
||||||
private final Map<Field, Table> mappedTables = Maps.newHashMap();
|
private final List<Table> mappedTables = Lists.newArrayList();
|
||||||
}
|
}
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
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:a:^(co|core|coreprotect) (rb|rollback|l|lookup|rl|reload):_"
|
||||||
- "r:e:^[A-z]*:[A-z]*::<gray>Plugin specific commands are disabled."
|
- "r:e:^[A-z]*:[A-z]*::<gray>Plugin specific commands are disabled."
|
||||||
|
|
||||||
# These commands will be blocked when a player is muted or when chat is toggled off.
|
# These commands will be blocked when a player is muted
|
||||||
block_on_mute:
|
block_on_mute:
|
||||||
- me
|
- me
|
||||||
- say
|
- say
|
||||||
|
@ -14,10 +14,6 @@ server:
|
|||||||
banning:
|
banning:
|
||||||
ban_url: "https://forum.plex.us.org"
|
ban_url: "https://forum.plex.us.org"
|
||||||
|
|
||||||
punishments:
|
|
||||||
mute-timer: 300
|
|
||||||
freeze-timer: 300
|
|
||||||
|
|
||||||
chat:
|
chat:
|
||||||
# Should the server use Plex's chat system? It is recommended to keep this on if you are using ranks.
|
# 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
|
# If you are using permissions, you should turn this off and use Vault to handle prefixes with a different chat plugin
|
||||||
@ -156,15 +152,6 @@ blocked_entities:
|
|||||||
- "ENDER_DRAGON"
|
- "ENDER_DRAGON"
|
||||||
- "MINECART_TNT"
|
- "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
|
# See https://docs.plex.us.org/docs/customization/config#worlds for documentation
|
||||||
# These gamerules apply to all worlds on the server
|
# These gamerules apply to all worlds on the server
|
||||||
global_gamerules:
|
global_gamerules:
|
||||||
|
@ -27,8 +27,6 @@ indefBanMessageReason: "<red>Your {0} is indefinitely banned! You may appeal at
|
|||||||
playerNotFound: "<red>Player not found!"
|
playerNotFound: "<red>Player not found!"
|
||||||
specifyPlayer: "<red>You must specify a player!"
|
specifyPlayer: "<red>You must specify a player!"
|
||||||
worldNotFound: "<red>World not found!"
|
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
|
# 0 - The world you have been teleported to
|
||||||
playerWorldTeleport: "<aqua>You have been teleported to {0}."
|
playerWorldTeleport: "<aqua>You have been teleported to {0}."
|
||||||
# 0 - The person who is freezing
|
# 0 - The person who is freezing
|
||||||
@ -43,13 +41,6 @@ mutedPlayer: "<red>{0} - Muted {1}"
|
|||||||
# 0 - The command sender
|
# 0 - The command sender
|
||||||
# 1 - The person who has been unmuted
|
# 1 - The person who has been unmuted
|
||||||
unmutedPlayer: "<aqua>{0} - Unmuted {1}"
|
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
|
# 0 - The person who is locking up
|
||||||
# 1 - The person who has been locked up
|
# 1 - The person who has been locked up
|
||||||
lockedUpPlayer: "<aqua>{0} - Locking up {1}"
|
lockedUpPlayer: "<aqua>{0} - Locking up {1}"
|
||||||
@ -119,11 +110,6 @@ playerFrozen: "<red>That player is already frozen!"
|
|||||||
playerMuted: "<red>That player is already muted!"
|
playerMuted: "<red>That player is already muted!"
|
||||||
playerLockedUp: "<red>That player is already locked up!"
|
playerLockedUp: "<red>That player is already locked up!"
|
||||||
muted: "<red>You are currently muted - STFU!"
|
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
|
# 0 - The command sender
|
||||||
# 1 - The player
|
# 1 - The player
|
||||||
kickedPlayer: "<red>{0} - Kicking {1}"
|
kickedPlayer: "<red>{0} - Kicking {1}"
|
||||||
@ -174,27 +160,10 @@ removedEntitiesOfType: "<gray>Removed {1} {2}"
|
|||||||
# 0 - Entity type that is invalid
|
# 0 - Entity type that is invalid
|
||||||
invalidEntityType: "<gray>Notice: Entity type {0} is invalid!"
|
invalidEntityType: "<gray>Notice: Entity type {0} is invalid!"
|
||||||
noRemovedEntities: "<gray>No entities were removed."
|
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
|
# 0 - The command sender
|
||||||
# 1 - Number of mobs removed
|
# 1 - Number of mobs removed
|
||||||
removedMobs: "<red>{0} - Removed {1} mobs"
|
removedMobs: "<red>{0} - Removed {1} mobs"
|
||||||
autoWipeDisabled: "<gray>Item wiping is currently disabled in the config!"
|
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."
|
commandBlocked: "<gray>That command is blocked."
|
||||||
# 0 - The command sender
|
# 0 - The command sender
|
||||||
# 1 - The message being said
|
# 1 - The message being said
|
||||||
@ -226,57 +195,6 @@ rankRequired: "<red>Policy requires that you must state your rank in your login
|
|||||||
# 0 - The material name
|
# 0 - The material name
|
||||||
# 1 - The players who have the material in their inventory
|
# 1 - The players who have the material in their inventory
|
||||||
playersWithMaterial: "<gray>Players with {0} in their inventory: {1}"
|
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."
|
nobodyHasThatMaterial: "<gray>No one online has that in their inventory."
|
||||||
# 0 - The attempted material name
|
# 0 - The attempted material name
|
||||||
materialNotFound: "<red>{0} is not a valid item/block 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,9 +11,3 @@ drops: true
|
|||||||
|
|
||||||
# Should redstone be enabled?
|
# Should redstone be enabled?
|
||||||
redstone: true
|
redstone: true
|
||||||
|
|
||||||
# Is chat enabled?
|
|
||||||
chat: true
|
|
||||||
|
|
||||||
# Is PVP enabled?
|
|
||||||
pvp: true
|
|
||||||
|
4
settings.gradle
Normal file
4
settings.gradle
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
rootProject.name = "Plex"
|
||||||
|
include 'server'
|
||||||
|
include 'proxy'
|
||||||
|
|
@ -1,2 +0,0 @@
|
|||||||
rootProject.name = "Plex"
|
|
||||||
include("server", "proxy")
|
|
Reference in New Issue
Block a user