mirror of
https://github.com/plexusorg/Plex.git
synced 2025-07-04 16:56:40 +00:00
Compare commits
68 Commits
Author | SHA1 | Date | |
---|---|---|---|
eb788f02dd | |||
096bb1bb24 | |||
223eaf30b3 | |||
6763878d74 | |||
81c656c86e | |||
6c09905a8d | |||
f0c646688e | |||
336f17b1cf | |||
583f502cee | |||
c071195aaf | |||
f62b084bbc | |||
c92a4bbdb9 | |||
9b0b7537c2 | |||
f8d25491d5 | |||
1dc0e05715 | |||
ffe8993ee1 | |||
90ef0a2121 | |||
7457e9e454 | |||
dc65187381 | |||
b449d732b0 | |||
8dfaaf7a8c | |||
6b7bfacbfd | |||
16186bdfbb | |||
4bbb73d1ff | |||
aa9f306586 | |||
08a004d65f | |||
d798904394 | |||
f78edc55d4 | |||
8866f44aa2 | |||
0fc2aa68b0 | |||
391677596a | |||
5988eba06b | |||
81d3cc8dde | |||
7b13ca0248 | |||
06fcf531af | |||
9f7ac310d9 | |||
09bc47f3fb | |||
8544775be2 | |||
c8c8fc9c59 | |||
14095fdebb | |||
dcecebdc8d | |||
f73c63f1e7 | |||
067094130f | |||
d16aa6de4c | |||
6086f761eb | |||
b2f1f7e055 | |||
3c20213c0d | |||
3500cae2da | |||
c4be024619 | |||
9849003ecc | |||
f274e20f84 | |||
f180eec44a | |||
b1ef89dae9 | |||
de20747d45 | |||
c801feed6f | |||
5fdc5826b7 | |||
a87a9241af | |||
8fb64b8499 | |||
10dd546c09 | |||
5a352b2ca0 | |||
333f38fb64 | |||
d55eaf0d3d | |||
e35d70bc3c | |||
e421867f63 | |||
ec7d814467 | |||
9c5a557316 | |||
38e79fd917 | |||
10e63f5e86 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,8 +1,7 @@
|
|||||||
/.idea/
|
/.idea/
|
||||||
/.idea/codeStyles/codeStyleConfig.xml
|
|
||||||
*.iml
|
*.iml
|
||||||
/target/
|
/target/
|
||||||
/src/main/resources/build.properties
|
src/main/resources/build.properties
|
||||||
|
|
||||||
# OS
|
# OS
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@ -23,7 +23,7 @@ pipeline {
|
|||||||
}
|
}
|
||||||
post {
|
post {
|
||||||
always {
|
always {
|
||||||
archiveArtifacts artifacts: "build/libs/*.jar", fingerprint: true
|
archiveArtifacts artifacts: "build/libs/Plex.jar", fingerprint: true
|
||||||
javadoc javadocDir: "build/docs/javadoc", keepAll: false
|
javadoc javadocDir: "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.PLEX_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.PLEX_WEBHOOK_URL
|
||||||
cleanWs()
|
cleanWs()
|
||||||
|
@ -1,3 +1,8 @@
|
|||||||
# Plex
|
# Plex [](https://ci.plex.us.org/job/Plex/job/master/)
|
||||||
|
|
||||||
A new freedom plugin.
|
Plex is a new freedom plugin. It is an alternative to TotalFreedomMod. It has many of the features that make a freedom
|
||||||
|
server unique, but also many features that TotalFreedomMod doesn’t have. For example, there is full support for using a
|
||||||
|
permissions plugin instead of ranks. It is also much more performance oriented. You can use Redis to store indefinite
|
||||||
|
bans and store player data in MongoDB, MariaDB, or SQLite. Plex is also fully customizable as you can change almost all
|
||||||
|
of the messages within the plugin. Plex also has a module system which can be used to add additional functionality. Plex
|
||||||
|
is not a rewrite, "debloat", or related to TotalFreedomMod. Plex is an entirely new experience.
|
||||||
|
46
build.gradle
46
build.gradle
@ -1,7 +1,7 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id "java"
|
id "java"
|
||||||
id "maven-publish"
|
id "maven-publish"
|
||||||
id "net.minecrell.plugin-yml.bukkit" version "0.5.1"
|
id "net.minecrell.plugin-yml.bukkit" version "0.6.1-SNAPSHOT"
|
||||||
id "com.github.johnrengelman.shadow" version "7.1.2"
|
id "com.github.johnrengelman.shadow" version "7.1.2"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19,6 +19,13 @@ repositories {
|
|||||||
url = uri("https://repo.maven.apache.org/maven2/")
|
url = uri("https://repo.maven.apache.org/maven2/")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
maven {
|
||||||
|
url = uri("https://jitpack.io")
|
||||||
|
content {
|
||||||
|
includeGroup("com.github.MilkBowl")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,19 +50,30 @@ dependencies {
|
|||||||
library "org.eclipse.jetty:jetty-proxy:11.0.9"
|
library "org.eclipse.jetty:jetty-proxy:11.0.9"
|
||||||
library "com.google.code.gson:gson:2.9.0"
|
library "com.google.code.gson:gson:2.9.0"
|
||||||
compileOnly "io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT"
|
compileOnly "io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT"
|
||||||
|
compileOnly("com.github.MilkBowl:VaultAPI:1.7") {
|
||||||
|
exclude group: "org.bukkit", module: "bukkit"
|
||||||
|
}
|
||||||
implementation "org.bstats:bstats-base:3.0.0"
|
implementation "org.bstats:bstats-base:3.0.0"
|
||||||
implementation "org.bstats:bstats-bukkit:3.0.0"
|
implementation "org.bstats:bstats-bukkit:3.0.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "dev.plex"
|
group = "dev.plex"
|
||||||
version = "1.0"
|
version = "1.0.1"
|
||||||
description = "Plex"
|
description = "Plex"
|
||||||
|
|
||||||
shadowJar {
|
shadowJar {
|
||||||
|
archiveBaseName.set("Plex")
|
||||||
archiveClassifier.set("")
|
archiveClassifier.set("")
|
||||||
|
archiveVersion.set("")
|
||||||
relocate "org.bstats", "dev.plex"
|
relocate "org.bstats", "dev.plex"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tasks.jar {
|
||||||
|
archiveBaseName.set("Plex")
|
||||||
|
archiveClassifier.set("notshaded")
|
||||||
|
archiveVersion.set("")
|
||||||
|
}
|
||||||
|
|
||||||
bukkit {
|
bukkit {
|
||||||
name = "Plex"
|
name = "Plex"
|
||||||
version = rootProject.version
|
version = rootProject.version
|
||||||
@ -63,6 +81,7 @@ bukkit {
|
|||||||
main = "dev.plex.Plex"
|
main = "dev.plex.Plex"
|
||||||
website = "https://plex.us.org"
|
website = "https://plex.us.org"
|
||||||
authors = ["Telesphoreo", "taahanis", "super"]
|
authors = ["Telesphoreo", "taahanis", "super"]
|
||||||
|
softDepend = ["Vault"]
|
||||||
apiVersion = "1.18"
|
apiVersion = "1.18"
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +114,7 @@ String getBuildNumber() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static def getDate() {
|
static def getDate() {
|
||||||
return new Date().format("MM/dd/yyyy '<light_purple>at<gold>' hh:mm:ss a")
|
return new Date().format("MM/dd/yyyy '<light_purple>at<gold>' hh:mm:ss a z")
|
||||||
}
|
}
|
||||||
|
|
||||||
task buildProperties {
|
task buildProperties {
|
||||||
@ -114,7 +133,26 @@ java {
|
|||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
maven(MavenPublication) {
|
maven(MavenPublication) {
|
||||||
from(components.java)
|
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]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
@ -1 +1,7 @@
|
|||||||
rootProject.name = 'Plex'
|
pluginManagement {
|
||||||
|
repositories {
|
||||||
|
maven { url = uri("https://nexus.telesphoreo.me/repository/gradle-plugins/") }
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rootProject.name = "Plex"
|
||||||
|
@ -3,12 +3,7 @@ package dev.plex;
|
|||||||
import dev.plex.admin.Admin;
|
import dev.plex.admin.Admin;
|
||||||
import dev.plex.admin.AdminList;
|
import dev.plex.admin.AdminList;
|
||||||
import dev.plex.cache.DataUtils;
|
import dev.plex.cache.DataUtils;
|
||||||
import dev.plex.cache.player.MongoPlayerData;
|
import dev.plex.cache.PlayerCache;
|
||||||
import dev.plex.cache.player.PlayerCache;
|
|
||||||
import dev.plex.cache.player.SQLPlayerData;
|
|
||||||
import dev.plex.cache.sql.SQLNotes;
|
|
||||||
import dev.plex.cache.sql.SQLPunishment;
|
|
||||||
import dev.plex.command.blocker.CommandBlockerManager;
|
|
||||||
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;
|
||||||
@ -21,19 +16,25 @@ import dev.plex.storage.MongoConnection;
|
|||||||
import dev.plex.storage.RedisConnection;
|
import dev.plex.storage.RedisConnection;
|
||||||
import dev.plex.storage.SQLConnection;
|
import dev.plex.storage.SQLConnection;
|
||||||
import dev.plex.storage.StorageType;
|
import dev.plex.storage.StorageType;
|
||||||
|
import dev.plex.storage.permission.SQLPermissions;
|
||||||
|
import dev.plex.storage.player.MongoPlayerData;
|
||||||
|
import dev.plex.storage.player.SQLPlayerData;
|
||||||
|
import dev.plex.storage.punishment.SQLNotes;
|
||||||
|
import dev.plex.storage.punishment.SQLPunishment;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.UpdateChecker;
|
import dev.plex.util.UpdateChecker;
|
||||||
import dev.plex.world.CustomWorld;
|
import dev.plex.world.CustomWorld;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
import org.bstats.bukkit.Metrics;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import net.milkbowl.vault.permission.Permission;
|
||||||
|
import org.bstats.bukkit.Metrics;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ -45,7 +46,7 @@ public class Plex extends JavaPlugin
|
|||||||
public Config config;
|
public Config config;
|
||||||
public Config messages;
|
public Config messages;
|
||||||
public Config indefBans;
|
public Config indefBans;
|
||||||
public Config blockedCommands;
|
public Config commands;
|
||||||
|
|
||||||
public File modulesFolder;
|
public File modulesFolder;
|
||||||
private StorageType storageType = StorageType.SQLITE;
|
private StorageType storageType = StorageType.SQLITE;
|
||||||
@ -59,17 +60,19 @@ public class Plex extends JavaPlugin
|
|||||||
|
|
||||||
private SQLPunishment sqlPunishment;
|
private SQLPunishment sqlPunishment;
|
||||||
private SQLNotes sqlNotes;
|
private SQLNotes sqlNotes;
|
||||||
|
private SQLPermissions sqlPermissions;
|
||||||
|
|
||||||
private ModuleManager moduleManager;
|
private ModuleManager moduleManager;
|
||||||
private RankManager rankManager;
|
private RankManager rankManager;
|
||||||
private ServiceManager serviceManager;
|
private ServiceManager serviceManager;
|
||||||
private PunishmentManager punishmentManager;
|
private PunishmentManager punishmentManager;
|
||||||
private CommandBlockerManager commandBlockerManager;
|
|
||||||
|
|
||||||
private AdminList adminList;
|
private AdminList adminList;
|
||||||
private UpdateChecker updateChecker;
|
private UpdateChecker updateChecker;
|
||||||
private String system;
|
private String system;
|
||||||
|
|
||||||
|
private Permission permissions;
|
||||||
|
|
||||||
public static Plex get()
|
public static Plex get()
|
||||||
{
|
{
|
||||||
return plugin;
|
return plugin;
|
||||||
@ -82,7 +85,7 @@ public class Plex extends JavaPlugin
|
|||||||
config = new Config(this, "config.yml");
|
config = new Config(this, "config.yml");
|
||||||
messages = new Config(this, "messages.yml");
|
messages = new Config(this, "messages.yml");
|
||||||
indefBans = new Config(this, "indefbans.yml");
|
indefBans = new Config(this, "indefbans.yml");
|
||||||
blockedCommands = new Config(this, "commands.yml");
|
commands = new Config(this, "commands.yml");
|
||||||
build.load(this);
|
build.load(this);
|
||||||
|
|
||||||
modulesFolder = new File(this.getDataFolder() + File.separator + "modules");
|
modulesFolder = new File(this.getDataFolder() + File.separator + "modules");
|
||||||
@ -103,7 +106,7 @@ public class Plex extends JavaPlugin
|
|||||||
messages.load();
|
messages.load();
|
||||||
// Don't add default entries to indefinite ban file
|
// Don't add default entries to indefinite ban file
|
||||||
indefBans.load(false);
|
indefBans.load(false);
|
||||||
blockedCommands.load();
|
commands.load(false);
|
||||||
|
|
||||||
sqlConnection = new SQLConnection();
|
sqlConnection = new SQLConnection();
|
||||||
mongoConnection = new MongoConnection();
|
mongoConnection = new MongoConnection();
|
||||||
@ -118,12 +121,18 @@ public class Plex extends JavaPlugin
|
|||||||
{
|
{
|
||||||
PlexUtils.testConnections();
|
PlexUtils.testConnections();
|
||||||
PlexLog.log("Connected to " + storageType.name().toUpperCase());
|
PlexLog.log("Connected to " + storageType.name().toUpperCase());
|
||||||
} catch (Exception e)
|
}
|
||||||
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
PlexLog.error("Failed to connect to " + storageType.name().toUpperCase());
|
PlexLog.error("Failed to connect to " + storageType.name().toUpperCase());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!setupPermissions() && system.equalsIgnoreCase("permissions") && !getServer().getPluginManager().isPluginEnabled("Vault"))
|
||||||
|
{
|
||||||
|
throw new RuntimeException("Vault is required to run on the server if you use permissions!");
|
||||||
|
}
|
||||||
|
|
||||||
updateChecker = new UpdateChecker();
|
updateChecker = new UpdateChecker();
|
||||||
PlexLog.log("Update checking enabled");
|
PlexLog.log("Update checking enabled");
|
||||||
|
|
||||||
@ -135,7 +144,8 @@ public class Plex extends JavaPlugin
|
|||||||
{
|
{
|
||||||
redisConnection.getJedis();
|
redisConnection.getJedis();
|
||||||
PlexLog.log("Connected to Redis!");
|
PlexLog.log("Connected to Redis!");
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
PlexLog.log("Redis is disabled in the configuration file, not connecting.");
|
PlexLog.log("Redis is disabled in the configuration file, not connecting.");
|
||||||
}
|
}
|
||||||
@ -143,11 +153,13 @@ public class Plex extends JavaPlugin
|
|||||||
if (storageType == StorageType.MONGODB)
|
if (storageType == StorageType.MONGODB)
|
||||||
{
|
{
|
||||||
mongoPlayerData = new MongoPlayerData();
|
mongoPlayerData = new MongoPlayerData();
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
sqlPlayerData = new SQLPlayerData();
|
sqlPlayerData = new SQLPlayerData();
|
||||||
sqlPunishment = new SQLPunishment();
|
sqlPunishment = new SQLPunishment();
|
||||||
sqlNotes = new SQLNotes();
|
sqlNotes = new SQLNotes();
|
||||||
|
sqlPermissions = new SQLPermissions();
|
||||||
}
|
}
|
||||||
|
|
||||||
new ListenerHandler();
|
new ListenerHandler();
|
||||||
@ -163,9 +175,6 @@ public class Plex extends JavaPlugin
|
|||||||
punishmentManager.mergeIndefiniteBans();
|
punishmentManager.mergeIndefiniteBans();
|
||||||
PlexLog.log("Punishment System initialized");
|
PlexLog.log("Punishment System initialized");
|
||||||
|
|
||||||
commandBlockerManager = new CommandBlockerManager();
|
|
||||||
PlexLog.log("Command Blocker initialized");
|
|
||||||
|
|
||||||
generateWorlds();
|
generateWorlds();
|
||||||
|
|
||||||
serviceManager = new ServiceManager();
|
serviceManager = new ServiceManager();
|
||||||
@ -191,7 +200,8 @@ public class Plex extends JavaPlugin
|
|||||||
if (mongoPlayerData != null) //back to mongo checking
|
if (mongoPlayerData != null) //back to mongo checking
|
||||||
{
|
{
|
||||||
mongoPlayerData.update(plexPlayer); //update the player's document
|
mongoPlayerData.update(plexPlayer); //update the player's document
|
||||||
} else if (sqlPlayerData != null) //sql checking
|
}
|
||||||
|
else if (sqlPlayerData != null) //sql checking
|
||||||
{
|
{
|
||||||
sqlPlayerData.update(plexPlayer);
|
sqlPlayerData.update(plexPlayer);
|
||||||
}
|
}
|
||||||
@ -254,10 +264,18 @@ public class Plex extends JavaPlugin
|
|||||||
author = props.getProperty("buildAuthor", "unknown");
|
author = props.getProperty("buildAuthor", "unknown");
|
||||||
date = props.getProperty("buildDate", "unknown");
|
date = props.getProperty("buildDate", "unknown");
|
||||||
head = props.getProperty("buildHead", "unknown");
|
head = props.getProperty("buildHead", "unknown");
|
||||||
} catch (Exception ex)
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
PlexLog.error("Could not load build properties! Did you compile with NetBeans/Maven?");
|
PlexLog.error("Could not load build properties! Did you compile with NetBeans/Maven?");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean setupPermissions()
|
||||||
|
{
|
||||||
|
RegisteredServiceProvider<Permission> rsp = Bukkit.getServicesManager().getRegistration(Permission.class);
|
||||||
|
permissions = rsp.getProvider();
|
||||||
|
return permissions != null;
|
||||||
|
}
|
||||||
}
|
}
|
@ -54,7 +54,7 @@ public class AdminList extends PlexBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gathers every admin's username (cached and in the database)
|
* Gathers every admins username (cached and in the database)
|
||||||
*
|
*
|
||||||
* @return An array list of the names of every admin
|
* @return An array list of the names of every admin
|
||||||
*/
|
*/
|
||||||
|
14
src/main/java/dev/plex/cache/DataUtils.java
vendored
14
src/main/java/dev/plex/cache/DataUtils.java
vendored
@ -1,11 +1,9 @@
|
|||||||
package dev.plex.cache;
|
package dev.plex.cache;
|
||||||
|
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.cache.player.PlayerCache;
|
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.storage.StorageType;
|
import dev.plex.storage.StorageType;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parent cache class
|
* Parent cache class
|
||||||
@ -30,6 +28,18 @@ public class DataUtils
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean hasPlayedBefore(String username)
|
||||||
|
{
|
||||||
|
if (Plex.get().getStorageType() == StorageType.MONGODB)
|
||||||
|
{
|
||||||
|
return Plex.get().getMongoPlayerData().exists(username);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Plex.get().getSqlPlayerData().exists(username);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a player from cache or from the database
|
* Gets a player from cache or from the database
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package dev.plex.cache.player;
|
package dev.plex.cache;
|
||||||
|
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
@ -1,44 +0,0 @@
|
|||||||
package dev.plex.cache.notes;
|
|
||||||
|
|
||||||
import com.google.common.reflect.TypeToken;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import dev.plex.Plex;
|
|
||||||
import dev.plex.cache.player.PlayerCache;
|
|
||||||
import dev.plex.player.PlexPlayer;
|
|
||||||
import java.sql.Connection;
|
|
||||||
import java.sql.PreparedStatement;
|
|
||||||
import java.sql.ResultSet;
|
|
||||||
import java.sql.SQLException;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
public class PlayerNotes
|
|
||||||
{
|
|
||||||
private final String SELECT = "SELECT * FROM `notes` WHERE uuid=?";
|
|
||||||
//private final String UPDATE = "UPDATE `notes` SET name=?, written_by=?, note=? WHERE uuid=?";
|
|
||||||
private final String INSERT = "INSERT INTO `notes` (`uuid`, `name`, `written_by`, `note`) VALUES (?, ?, ?, ?);";
|
|
||||||
|
|
||||||
public PlexPlayer getByUUID(UUID uuid)
|
|
||||||
{
|
|
||||||
try (Connection con = Plex.get().getSqlConnection().getCon())
|
|
||||||
{
|
|
||||||
PreparedStatement statement = con.prepareStatement(SELECT);
|
|
||||||
statement.setString(1, uuid.toString());
|
|
||||||
ResultSet set = statement.executeQuery();
|
|
||||||
PlexPlayer plexPlayer = new PlexPlayer(uuid);
|
|
||||||
while (set.next())
|
|
||||||
{
|
|
||||||
String name = set.getString("name");
|
|
||||||
String writtenBy = set.getString("written_by");
|
|
||||||
String note = set.getString("note");
|
|
||||||
|
|
||||||
}
|
|
||||||
return plexPlayer;
|
|
||||||
}
|
|
||||||
catch (SQLException throwables)
|
|
||||||
{
|
|
||||||
throwables.printStackTrace();
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,31 +2,37 @@ package dev.plex.command;
|
|||||||
|
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.cache.DataUtils;
|
import dev.plex.cache.DataUtils;
|
||||||
import dev.plex.cache.player.PlayerCache;
|
import dev.plex.cache.PlayerCache;
|
||||||
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.*;
|
import dev.plex.command.exception.CommandFailException;
|
||||||
|
import dev.plex.command.exception.ConsoleMustDefinePlayerException;
|
||||||
|
import dev.plex.command.exception.ConsoleOnlyException;
|
||||||
|
import dev.plex.command.exception.PlayerNotBannedException;
|
||||||
|
import dev.plex.command.exception.PlayerNotFoundException;
|
||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.UUID;
|
||||||
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.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
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.ChatColor;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.*;
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandMap;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.bukkit.command.PluginIdentifiableCommand;
|
||||||
import org.bukkit.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.Arrays;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Superclass for all commands
|
* Superclass for all commands
|
||||||
*/
|
*/
|
||||||
@ -125,7 +131,8 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
{
|
{
|
||||||
send(sender, messageComponent("noPermissionRank", ChatColor.stripColor(getLevel().getLoginMessage())));
|
send(sender, messageComponent("noPermissionRank", ChatColor.stripColor(getLevel().getLoginMessage())));
|
||||||
return true;
|
return true;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
if (getLevel().isAtLeast(Rank.ADMIN) && !plexPlayer.isAdminActive())
|
if (getLevel().isAtLeast(Rank.ADMIN) && !plexPlayer.isAdminActive())
|
||||||
{
|
{
|
||||||
@ -133,14 +140,52 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
}
|
||||||
|
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||||
{
|
{
|
||||||
if (!player.hasPermission(perms.permission()))
|
if (!player.hasPermission(perms.permission()))
|
||||||
{
|
{
|
||||||
send(sender, messageComponent("noPermissionNode", perms.permission()));
|
send(sender, messageComponent("noPermissionNode", perms.permission()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PlexLog.error("Neither permissions or ranks were selected to be used in the configuration file!");
|
||||||
|
send(sender, "There is a server misconfiguration. Please alert a developer or the owner");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sender instanceof ConsoleCommandSender && !sender.getName().equalsIgnoreCase("console")) //telnet
|
||||||
|
{
|
||||||
|
PlexPlayer plexPlayer = DataUtils.getPlayer(sender.getName());
|
||||||
|
|
||||||
|
if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||||
|
{
|
||||||
|
if (!plexPlayer.getRankFromString().isAtLeast(getLevel()))
|
||||||
|
{
|
||||||
|
send(sender, messageComponent("noPermissionRank", ChatColor.stripColor(getLevel().getLoginMessage())));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (getLevel().isAtLeast(Rank.ADMIN) && !plexPlayer.isAdminActive())
|
||||||
|
{
|
||||||
|
send(sender, messageComponent("noPermissionRank", ChatColor.stripColor(getLevel().getLoginMessage())));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||||
|
{
|
||||||
|
if (!plugin.getPermissions().playerHas(null, Bukkit.getOfflinePlayer(plexPlayer.getUuid()), perms.permission()))
|
||||||
|
{
|
||||||
|
send(sender, messageComponent("noPermissionNode", perms.permission()));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
PlexLog.error("Neither permissions or ranks were selected to be used in the configuration file!");
|
PlexLog.error("Neither permissions or ranks were selected to be used in the configuration file!");
|
||||||
send(sender, "There is a server misconfiguration. Please alert a developer or the owner");
|
send(sender, "There is a server misconfiguration. Please alert a developer or the owner");
|
||||||
@ -149,14 +194,16 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Component component = this.execute(sender, isConsole(sender) ? null : (Player) sender, args);
|
Component component = this.execute(sender, isConsole(sender) ? null : (Player)sender, args);
|
||||||
if (component != null)
|
if (component != null)
|
||||||
{
|
{
|
||||||
send(sender, component);
|
send(sender, component);
|
||||||
}
|
}
|
||||||
} catch (PlayerNotFoundException | CommandFailException | ConsoleOnlyException | ConsoleMustDefinePlayerException | PlayerNotBannedException ex)
|
}
|
||||||
|
catch (PlayerNotFoundException | CommandFailException | ConsoleOnlyException |
|
||||||
|
ConsoleMustDefinePlayerException | PlayerNotBannedException ex)
|
||||||
{
|
{
|
||||||
send(sender, MiniMessage.miniMessage().deserialize(ex.getMessage()));
|
send(sender, PlexUtils.mmDeserialize(ex.getMessage()));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -178,7 +225,8 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (params.aliases().split(",").length < 1)
|
}
|
||||||
|
else if (params.aliases().split(",").length < 1)
|
||||||
{
|
{
|
||||||
return getName().equalsIgnoreCase(label);
|
return getName().equalsIgnoreCase(label);
|
||||||
}
|
}
|
||||||
@ -232,7 +280,29 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
{
|
{
|
||||||
if (!isConsole(sender))
|
if (!isConsole(sender))
|
||||||
{
|
{
|
||||||
return checkRank((Player) sender, rank, permission);
|
return checkRank((Player)sender, rank, permission);
|
||||||
|
}
|
||||||
|
if (!sender.getName().equalsIgnoreCase("console"))
|
||||||
|
{
|
||||||
|
PlexPlayer plexPlayer = DataUtils.getPlayer(sender.getName());
|
||||||
|
if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||||
|
{
|
||||||
|
if (!plexPlayer.getRankFromString().isAtLeast(rank))
|
||||||
|
{
|
||||||
|
throw new CommandFailException(PlexUtils.messageString("noPermissionRank", ChatColor.stripColor(rank.getLoginMessage())));
|
||||||
|
}
|
||||||
|
if (rank.isAtLeast(Rank.ADMIN) && !plexPlayer.isAdminActive())
|
||||||
|
{
|
||||||
|
throw new CommandFailException(PlexUtils.messageString("noPermissionRank", ChatColor.stripColor(rank.getLoginMessage())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||||
|
{
|
||||||
|
if (!plugin.getPermissions().playerHas(null, Bukkit.getOfflinePlayer(plexPlayer.getUuid()), permission))
|
||||||
|
{
|
||||||
|
throw new CommandFailException(PlexUtils.messageString("noPermissionNode", permission));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -263,7 +333,8 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
{
|
{
|
||||||
throw new CommandFailException(PlexUtils.messageString("noPermissionRank", ChatColor.stripColor(rank.getLoginMessage())));
|
throw new CommandFailException(PlexUtils.messageString("noPermissionRank", ChatColor.stripColor(rank.getLoginMessage())));
|
||||||
}
|
}
|
||||||
} else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
}
|
||||||
|
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||||
{
|
{
|
||||||
if (!player.hasPermission(permission))
|
if (!player.hasPermission(permission))
|
||||||
{
|
{
|
||||||
@ -283,7 +354,8 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||||
{
|
{
|
||||||
return rank.isAtLeast(Rank.ADMIN) ? plexPlayer.isAdminActive() && plexPlayer.getRankFromString().isAtLeast(rank) : plexPlayer.getRankFromString().isAtLeast(rank);
|
return rank.isAtLeast(Rank.ADMIN) ? plexPlayer.isAdminActive() && plexPlayer.getRankFromString().isAtLeast(rank) : plexPlayer.getRankFromString().isAtLeast(rank);
|
||||||
} else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
}
|
||||||
|
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||||
{
|
{
|
||||||
return player.hasPermission(permission);
|
return player.hasPermission(permission);
|
||||||
}
|
}
|
||||||
@ -303,7 +375,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
{
|
{
|
||||||
if (!isConsole(sender))
|
if (!isConsole(sender))
|
||||||
{
|
{
|
||||||
return checkTab((Player) sender, rank, permission);
|
return checkTab((Player)sender, rank, permission);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -323,7 +395,8 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||||
{
|
{
|
||||||
return rank.isAtLeast(Rank.ADMIN) ? plexPlayer.isAdminActive() && plexPlayer.getRankFromString().isAtLeast(rank) : plexPlayer.getRankFromString().isAtLeast(rank);
|
return rank.isAtLeast(Rank.ADMIN) ? plexPlayer.isAdminActive() && plexPlayer.getRankFromString().isAtLeast(rank) : plexPlayer.getRankFromString().isAtLeast(rank);
|
||||||
} else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
}
|
||||||
|
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||||
{
|
{
|
||||||
return player.hasPermission(permission);
|
return player.hasPermission(permission);
|
||||||
}
|
}
|
||||||
@ -536,7 +609,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
|||||||
*/
|
*/
|
||||||
protected Component mmString(String s)
|
protected Component mmString(String s)
|
||||||
{
|
{
|
||||||
return MiniMessage.miniMessage().deserialize(s);
|
return PlexUtils.mmDeserialize(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rank getLevel()
|
public Rank getLevel()
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
package dev.plex.command.blocker;
|
|
||||||
|
|
||||||
import dev.plex.rank.enums.Rank;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class BaseCommand
|
|
||||||
{
|
|
||||||
private final Rank rank;
|
|
||||||
private final String message;
|
|
||||||
|
|
||||||
public BaseCommand(Rank r, String m)
|
|
||||||
{
|
|
||||||
rank = r;
|
|
||||||
message = m;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "BaseCommand (Rank: " + (rank == null ? "ALL" : rank.name()) + ", Message: " + message + ")";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,108 +0,0 @@
|
|||||||
package dev.plex.command.blocker;
|
|
||||||
|
|
||||||
import dev.plex.Plex;
|
|
||||||
import dev.plex.PlexBase;
|
|
||||||
import dev.plex.rank.enums.Rank;
|
|
||||||
import dev.plex.util.PlexLog;
|
|
||||||
import dev.plex.util.PlexUtils;
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.PluginCommand;
|
|
||||||
import org.bukkit.command.PluginCommandYamlParser;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class CommandBlockerManager extends PlexBase
|
|
||||||
{
|
|
||||||
private List<BaseCommand> blockedCommands = new ArrayList<>();
|
|
||||||
|
|
||||||
public boolean loadedYet;
|
|
||||||
|
|
||||||
public void syncCommands()
|
|
||||||
{
|
|
||||||
loadedYet = false;
|
|
||||||
blockedCommands.clear();
|
|
||||||
|
|
||||||
List<String> raw = plugin.blockedCommands.getStringList("blockedCommands");
|
|
||||||
|
|
||||||
for (String cmd : raw)
|
|
||||||
{
|
|
||||||
int lastDelim = cmd.lastIndexOf(':');
|
|
||||||
|
|
||||||
String cmdWithoutMsg = cmd.substring(0, lastDelim);
|
|
||||||
String[] rawPieces = cmdWithoutMsg.split(":", 3);
|
|
||||||
|
|
||||||
String rawType = rawPieces[0].toLowerCase();
|
|
||||||
String rawRank = rawPieces[1].toLowerCase();
|
|
||||||
String regexOrMatch = rawPieces[2];
|
|
||||||
String message = cmd.substring(lastDelim + 1);
|
|
||||||
|
|
||||||
if (message.equals("_"))
|
|
||||||
{
|
|
||||||
message = PlexUtils.messageString("commandBlocked");
|
|
||||||
}
|
|
||||||
|
|
||||||
Rank rank = switch (rawRank)
|
|
||||||
{
|
|
||||||
case "e" -> null;
|
|
||||||
case "a" -> Rank.ADMIN;
|
|
||||||
case "s" -> Rank.SENIOR_ADMIN;
|
|
||||||
default -> null;
|
|
||||||
};
|
|
||||||
|
|
||||||
if (rawType.equals("r"))
|
|
||||||
{
|
|
||||||
blockedCommands.add(new RegexCommand(Pattern.compile(regexOrMatch, Pattern.CASE_INSENSITIVE), rank, message));
|
|
||||||
}
|
|
||||||
else if (rawType.equals("m"))
|
|
||||||
{
|
|
||||||
int ind = regexOrMatch.indexOf(' ');
|
|
||||||
if (ind == -1 && regexOrMatch.endsWith(":"))
|
|
||||||
{
|
|
||||||
String pluginName = regexOrMatch.substring(0, regexOrMatch.length() - 1);
|
|
||||||
Plugin plugin = Arrays.stream(Bukkit.getServer().getPluginManager().getPlugins()).filter(pl -> pl.getName().equalsIgnoreCase(pluginName)).findAny().orElse(null);
|
|
||||||
if (plugin != null)
|
|
||||||
{
|
|
||||||
List<Command> commandList = PluginCommandYamlParser.parse(plugin);
|
|
||||||
for (Command command : commandList)
|
|
||||||
{
|
|
||||||
blockedCommands.add(new MatchCommand(command.getName(), rank, message));
|
|
||||||
blockedCommands.add(new MatchCommand(pluginName + ":" + command.getName(), rank, message));
|
|
||||||
for (String alias : command.getAliases())
|
|
||||||
{
|
|
||||||
blockedCommands.add(new MatchCommand(alias, rank, message));
|
|
||||||
blockedCommands.add(new MatchCommand(pluginName + ":" + alias, rank, message));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String blockedArgs = ind == -1 ? "" : regexOrMatch.substring(ind + 1);
|
|
||||||
if (!blockedArgs.isEmpty())
|
|
||||||
{
|
|
||||||
blockedArgs = " " + blockedArgs; // necessary in case no args
|
|
||||||
}
|
|
||||||
PluginCommand pluginCommand = Plex.get().getServer().getPluginCommand(ind == -1 ? regexOrMatch : regexOrMatch.substring(0, ind));
|
|
||||||
if (pluginCommand != null)
|
|
||||||
{
|
|
||||||
String pluginName = pluginCommand.getPlugin().getName();
|
|
||||||
blockedCommands.add(new MatchCommand(pluginCommand.getName() + blockedArgs, rank, message));
|
|
||||||
blockedCommands.add(new MatchCommand(pluginName + ":" + pluginCommand.getName() + blockedArgs, rank, message));
|
|
||||||
List<String> aliases = pluginCommand.getAliases();
|
|
||||||
for (String alias : aliases)
|
|
||||||
{
|
|
||||||
blockedCommands.add(new MatchCommand(alias + blockedArgs, rank, message));
|
|
||||||
blockedCommands.add(new MatchCommand(pluginName + ":" + alias + blockedArgs, rank, message));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
loadedYet = true;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,21 +0,0 @@
|
|||||||
package dev.plex.command.blocker;
|
|
||||||
|
|
||||||
import dev.plex.rank.enums.Rank;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class MatchCommand extends BaseCommand
|
|
||||||
{
|
|
||||||
private final String match;
|
|
||||||
|
|
||||||
public MatchCommand(String r1, Rank r2, String m1)
|
|
||||||
{
|
|
||||||
super(r2, m1);
|
|
||||||
match = r1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "MatchCommand (Rank: " + (getRank() == null ? "ALL" : getRank().name()) + ", Match: " + match + ", Message: " + getMessage() + ")";
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +0,0 @@
|
|||||||
package dev.plex.command.blocker;
|
|
||||||
|
|
||||||
import dev.plex.rank.enums.Rank;
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
public class RegexCommand extends BaseCommand
|
|
||||||
{
|
|
||||||
private final Pattern regex;
|
|
||||||
|
|
||||||
public RegexCommand(Pattern r1, Rank r2, String m1)
|
|
||||||
{
|
|
||||||
super(r2, m1);
|
|
||||||
regex = r1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "RegexCommand (Rank: " + (getRank() == null ? "ALL" : getRank().name()) + ", Regex: " + regex.toString() + ", Message: " + getMessage() + ")";
|
|
||||||
}
|
|
||||||
}
|
|
16
src/main/java/dev/plex/command/blocking/BlockedCommand.java
Normal file
16
src/main/java/dev/plex/command/blocking/BlockedCommand.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package dev.plex.command.blocking;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Data;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class BlockedCommand
|
||||||
|
{
|
||||||
|
private Component message;
|
||||||
|
private String requiredLevel;
|
||||||
|
private String regex;
|
||||||
|
private String command;
|
||||||
|
private List<String> commandAliases = Lists.newArrayList();
|
||||||
|
}
|
@ -14,11 +14,9 @@ import dev.plex.event.AdminRemoveEvent;
|
|||||||
import dev.plex.event.AdminSetRankEvent;
|
import dev.plex.event.AdminSetRankEvent;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexLog;
|
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -54,18 +52,18 @@ public class AdminCMD extends PlexCommand
|
|||||||
throw new ConsoleOnlyException();
|
throw new ConsoleOnlyException();
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID targetUUID = PlexUtils.getFromName(args[1]);
|
/*UUID targetUUID = PlexUtils.getFromName(args[1]);
|
||||||
|
|
||||||
if (targetUUID != null)
|
if (targetUUID != null)
|
||||||
{
|
{
|
||||||
PlexLog.debug("Admin Adding UUID: " + targetUUID);
|
PlexLog.debug("Admin Adding UUID: " + targetUUID);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (targetUUID == null || !DataUtils.hasPlayedBefore(targetUUID))
|
if (!DataUtils.hasPlayedBefore(args[1]))
|
||||||
{
|
{
|
||||||
throw new PlayerNotFoundException();
|
throw new PlayerNotFoundException();
|
||||||
}
|
}
|
||||||
PlexPlayer plexPlayer = DataUtils.getPlayer(targetUUID);
|
PlexPlayer plexPlayer = DataUtils.getPlayer(args[1]);
|
||||||
|
|
||||||
if (isAdmin(plexPlayer))
|
if (isAdmin(plexPlayer))
|
||||||
{
|
{
|
||||||
@ -87,13 +85,13 @@ public class AdminCMD extends PlexCommand
|
|||||||
throw new ConsoleOnlyException();
|
throw new ConsoleOnlyException();
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID targetUUID = PlexUtils.getFromName(args[1]);
|
// UUID targetUUID = PlexUtils.getFromName(args[1]);
|
||||||
|
|
||||||
if (targetUUID == null || !DataUtils.hasPlayedBefore(targetUUID))
|
if (!DataUtils.hasPlayedBefore(args[1]))
|
||||||
{
|
{
|
||||||
throw new PlayerNotFoundException();
|
throw new PlayerNotFoundException();
|
||||||
}
|
}
|
||||||
PlexPlayer plexPlayer = DataUtils.getPlayer(targetUUID);
|
PlexPlayer plexPlayer = DataUtils.getPlayer(args[1]);
|
||||||
|
|
||||||
if (!isAdmin(plexPlayer))
|
if (!isAdmin(plexPlayer))
|
||||||
{
|
{
|
||||||
@ -116,9 +114,9 @@ public class AdminCMD extends PlexCommand
|
|||||||
throw new ConsoleOnlyException();
|
throw new ConsoleOnlyException();
|
||||||
}
|
}
|
||||||
|
|
||||||
UUID targetUUID = PlexUtils.getFromName(args[1]);
|
// UUID targetUUID = PlexUtils.getFromName(args[1]);
|
||||||
|
|
||||||
if (targetUUID == null || !DataUtils.hasPlayedBefore(targetUUID))
|
if (!DataUtils.hasPlayedBefore(args[1]))
|
||||||
{
|
{
|
||||||
throw new PlayerNotFoundException();
|
throw new PlayerNotFoundException();
|
||||||
}
|
}
|
||||||
@ -135,7 +133,7 @@ public class AdminCMD extends PlexCommand
|
|||||||
return messageComponent("rankMustBeHigherThanAdmin");
|
return messageComponent("rankMustBeHigherThanAdmin");
|
||||||
}
|
}
|
||||||
|
|
||||||
PlexPlayer plexPlayer = DataUtils.getPlayer(targetUUID);
|
PlexPlayer plexPlayer = DataUtils.getPlayer(args[1]);
|
||||||
|
|
||||||
if (!isAdmin(plexPlayer))
|
if (!isAdmin(plexPlayer))
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package dev.plex.command.impl;
|
package dev.plex.command.impl;
|
||||||
|
|
||||||
import dev.plex.cache.player.PlayerCache;
|
import dev.plex.cache.PlayerCache;
|
||||||
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;
|
||||||
|
@ -47,6 +47,8 @@ public class BanCMD extends PlexCommand
|
|||||||
PlexPlayer plexPlayer = DataUtils.getPlayer(targetUUID);
|
PlexPlayer plexPlayer = DataUtils.getPlayer(targetUUID);
|
||||||
Player player = Bukkit.getPlayer(targetUUID);
|
Player player = Bukkit.getPlayer(targetUUID);
|
||||||
|
|
||||||
|
if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||||
|
{
|
||||||
if (isAdmin(plexPlayer))
|
if (isAdmin(plexPlayer))
|
||||||
{
|
{
|
||||||
if (!isConsole(sender))
|
if (!isConsole(sender))
|
||||||
@ -59,6 +61,7 @@ public class BanCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
plugin.getPunishmentManager().isAsyncBanned(targetUUID).whenComplete((aBoolean, throwable) ->
|
plugin.getPunishmentManager().isAsyncBanned(targetUUID).whenComplete((aBoolean, throwable) ->
|
||||||
{
|
{
|
||||||
|
@ -7,9 +7,7 @@ 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.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
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 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;
|
||||||
|
31
src/main/java/dev/plex/command/impl/ConsoleSayCommand.java
Normal file
31
src/main/java/dev/plex/command/impl/ConsoleSayCommand.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
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.rank.enums.Rank;
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.consolesay", source = RequiredCommandSource.CONSOLE)
|
||||||
|
@CommandParameters(name = "consolesay", usage = "/<command> <message>", description = "Displays a message to everyone", aliases = "csay")
|
||||||
|
public class ConsoleSayCommand extends PlexCommand
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return usage();
|
||||||
|
}
|
||||||
|
|
||||||
|
PlexUtils.broadcast(PlexUtils.messageComponent("consoleSayMessage", sender.getName(), PlexUtils.mmStripColor(StringUtils.join(args, " "))));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -8,18 +8,20 @@ import dev.plex.command.annotation.System;
|
|||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
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;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
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;
|
||||||
|
|
||||||
@CommandParameters(name = "pdebug", description = "Plex's debug command", usage = "/<command> <redis-reset <player> | gamerules>")
|
@CommandParameters(name = "pdebug", description = "Plex's debug command", usage = "/<command> <aliases <command> | redis-reset <player> | gamerules>")
|
||||||
@CommandPermissions(level = Rank.EXECUTIVE, permission = "plex.debug")
|
@CommandPermissions(level = Rank.EXECUTIVE, permission = "plex.debug")
|
||||||
@System(debug = true)
|
@System(debug = true)
|
||||||
public class DebugCMD extends PlexCommand
|
public class DebugCMD extends PlexCommand
|
||||||
@ -59,6 +61,16 @@ public class DebugCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
return mmString("<aqua>Re-applied game all the game rules!");
|
return mmString("<aqua>Re-applied game all the game rules!");
|
||||||
}
|
}
|
||||||
|
if (args[0].equalsIgnoreCase("aliases"))
|
||||||
|
{
|
||||||
|
String commandName = args[1];
|
||||||
|
Command command = plugin.getServer().getCommandMap().getCommand(commandName);
|
||||||
|
if (command == null)
|
||||||
|
{
|
||||||
|
return mmString("<red>That command could not be found!");
|
||||||
|
}
|
||||||
|
return mmString("<aqua>Aliases for " + commandName + " are: " + Arrays.toString(command.getAliases().toArray(new String[0])));
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package dev.plex.command.impl;
|
package dev.plex.command.impl;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
|
||||||
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;
|
||||||
@ -8,10 +7,12 @@ import dev.plex.command.source.RequiredCommandSource;
|
|||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
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.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;
|
||||||
@ -20,11 +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.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.entitywipe", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.entitywipe", source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "entitywipe", description = "Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.", usage = "/<command> [name]", aliases = "ew,rd")
|
@CommandParameters(name = "entitywipe", description = "Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.", usage = "/<command> [name]", aliases = "ew,rd")
|
||||||
public class EntityWipeCMD extends PlexCommand
|
public class EntityWipeCMD extends PlexCommand
|
||||||
@ -57,7 +53,7 @@ public class EntityWipeCMD extends PlexCommand
|
|||||||
{
|
{
|
||||||
if (entity.getType() != EntityType.PLAYER)
|
if (entity.getType() != EntityType.PLAYER)
|
||||||
{
|
{
|
||||||
String type = entity.getName();
|
String type = entity.getType().name();
|
||||||
|
|
||||||
if (useBlacklist ? entityBlacklist.stream().noneMatch(entityName -> entityName.equalsIgnoreCase(type)) : entityWhitelist.stream().anyMatch(entityName -> entityName.equalsIgnoreCase(type)))
|
if (useBlacklist ? entityBlacklist.stream().noneMatch(entityName -> entityName.equalsIgnoreCase(type)) : entityWhitelist.stream().anyMatch(entityName -> entityName.equalsIgnoreCase(type)))
|
||||||
{
|
{
|
||||||
@ -102,7 +98,7 @@ public class EntityWipeCMD extends PlexCommand
|
|||||||
{
|
{
|
||||||
if (entity.getType() != EntityType.PLAYER)
|
if (entity.getType() != EntityType.PLAYER)
|
||||||
{
|
{
|
||||||
entities.add(entity.getName());
|
entities.add(entity.getType().name());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,6 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
@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
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||||
{
|
{
|
||||||
|
@ -9,15 +9,14 @@ import dev.plex.punishment.Punishment;
|
|||||||
import dev.plex.punishment.PunishmentType;
|
import dev.plex.punishment.PunishmentType;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
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.time.LocalDateTime;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@CommandParameters(name = "freeze", description = "Freeze a player on the server", usage = "/<command> <player>", aliases = "fr")
|
@CommandParameters(name = "freeze", description = "Freeze a player on the server", usage = "/<command> <player>", aliases = "fr")
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.freeze")
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.freeze")
|
||||||
public class FreezeCMD extends PlexCommand
|
public class FreezeCMD extends PlexCommand
|
||||||
|
@ -37,6 +37,10 @@ public class ListCMD extends PlexCommand
|
|||||||
.append(Component.space())
|
.append(Component.space())
|
||||||
.append(Component.text(Bukkit.getMaxPlayers() == 1 ? "player." : "players.").color(NamedTextColor.GRAY));
|
.append(Component.text(Bukkit.getMaxPlayers() == 1 ? "player." : "players.").color(NamedTextColor.GRAY));
|
||||||
send(sender, header);
|
send(sender, header);
|
||||||
|
if (players.size() == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
for (int i = 0; i < players.size(); i++)
|
for (int i = 0; i < players.size(); i++)
|
||||||
{
|
{
|
||||||
Player player = players.get(i);
|
Player player = players.get(i);
|
||||||
|
@ -17,7 +17,6 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
@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
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||||
{
|
{
|
||||||
|
@ -6,16 +6,17 @@ import dev.plex.command.annotation.CommandPermissions;
|
|||||||
import dev.plex.command.source.RequiredCommandSource;
|
import dev.plex.command.source.RequiredCommandSource;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
|
import java.util.HashMap;
|
||||||
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;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Mob;
|
||||||
|
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.HashMap;
|
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.mobpurge", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.mobpurge", source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "mobpurge", description = "Purge all mobs.", usage = "/<command>", aliases = "mp")
|
@CommandParameters(name = "mobpurge", description = "Purge all mobs.", usage = "/<command>", aliases = "mp")
|
||||||
public class MobPurgeCMD extends PlexCommand
|
public class MobPurgeCMD extends PlexCommand
|
||||||
|
@ -11,7 +11,6 @@ import dev.plex.rank.enums.Rank;
|
|||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
|
||||||
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;
|
||||||
|
@ -10,7 +10,6 @@ import dev.plex.util.AshconInfo;
|
|||||||
import dev.plex.util.MojangUtils;
|
import dev.plex.util.MojangUtils;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -24,8 +23,6 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
@CommandPermissions(level = Rank.OP, permission = "plex.namehistory")
|
@CommandPermissions(level = Rank.OP, permission = "plex.namehistory")
|
||||||
public class NameHistoryCMD extends PlexCommand
|
public class NameHistoryCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("MM/dd/yyyy 'at' hh:mm:ss a");
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||||
{
|
{
|
||||||
@ -50,7 +47,7 @@ public class NameHistoryCMD extends PlexCommand
|
|||||||
historyList.add(
|
historyList.add(
|
||||||
messageComponent("nameHistoryBody",
|
messageComponent("nameHistoryBody",
|
||||||
history.getUsername(),
|
history.getUsername(),
|
||||||
DATE_FORMAT.format(history.getLocalDateTime())));
|
PlexUtils.useTimezone(history.getLocalDateTime())));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -9,9 +9,13 @@ import dev.plex.punishment.extra.Note;
|
|||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.storage.StorageType;
|
import dev.plex.storage.StorageType;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.format.TextDecoration;
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -19,19 +23,10 @@ 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.time.LocalDateTime;
|
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
|
||||||
|
|
||||||
@CommandParameters(name = "notes", description = "Manage notes for a player", usage = "/<command> <player> <list | add <note> | remove <id> | clear>")
|
@CommandParameters(name = "notes", description = "Manage notes for a player", usage = "/<command> <player> <list | add <note> | remove <id> | clear>")
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.notes")
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.notes")
|
||||||
public class NotesCMD extends PlexCommand
|
public class NotesCMD extends PlexCommand
|
||||||
{
|
{
|
||||||
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("MM/dd/yyyy 'at' hh:mm:ss a");
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||||
{
|
{
|
||||||
@ -94,6 +89,10 @@ public class NotesCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
case "remove":
|
case "remove":
|
||||||
{
|
{
|
||||||
|
if (args.length < 3)
|
||||||
|
{
|
||||||
|
return usage();
|
||||||
|
}
|
||||||
int id;
|
int id;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -107,18 +106,20 @@ public class NotesCMD extends PlexCommand
|
|||||||
{
|
{
|
||||||
plugin.getSqlNotes().getNotes(plexPlayer.getUuid()).whenComplete((notes, ex) ->
|
plugin.getSqlNotes().getNotes(plexPlayer.getUuid()).whenComplete((notes, ex) ->
|
||||||
{
|
{
|
||||||
|
boolean deleted = false;
|
||||||
for (Note note : notes)
|
for (Note note : notes)
|
||||||
{
|
{
|
||||||
if (note.getId() == id)
|
if (note.getId() == id)
|
||||||
{
|
{
|
||||||
plugin.getSqlNotes().deleteNote(id, plexPlayer.getUuid()).whenComplete((notes1, ex1) ->
|
plugin.getSqlNotes().deleteNote(id, plexPlayer.getUuid()).whenComplete((notes1, ex1) ->
|
||||||
send(sender, Component.text("Removed note with ID: " + id).color(NamedTextColor.GREEN)));
|
send(sender, Component.text("Removed note with ID: " + id).color(NamedTextColor.GREEN)));
|
||||||
|
deleted = true;
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
if (!deleted)
|
||||||
{
|
{
|
||||||
send(sender, mmString("<red>A note with this ID could not be found"));
|
send(sender, mmString("<red>A note with this ID could not be found"));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
plexPlayer.getNotes().removeIf(note -> note.getId() == id);
|
plexPlayer.getNotes().removeIf(note -> note.getId() == id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -130,6 +131,7 @@ public class NotesCMD extends PlexCommand
|
|||||||
}
|
}
|
||||||
return mmString("<red>A note with this ID could not be found");
|
return mmString("<red>A note with this ID could not be found");
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
case "clear":
|
case "clear":
|
||||||
{
|
{
|
||||||
@ -166,8 +168,8 @@ public class NotesCMD extends PlexCommand
|
|||||||
AtomicReference<Component> noteList = new AtomicReference<>(Component.text("Player notes for: " + plexPlayer.getName()).color(NamedTextColor.GREEN));
|
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 = Component.text(note.getId() + " - Written by: " + DataUtils.getPlayer(note.getWrittenBy()).getName() + " on " + DATE_FORMAT.format(note.getTimestamp())).color(NamedTextColor.YELLOW).decoration(TextDecoration.ITALIC, false);
|
Component noteLine = mmString("<gold><!italic>" + note.getId() + " - Written by: " + DataUtils.getPlayer(note.getWrittenBy()).getName() + " on " + PlexUtils.useTimezone(note.getTimestamp()));
|
||||||
noteLine = noteLine.append(Component.text(note.getNote())).color(NamedTextColor.GOLD).decoration(TextDecoration.ITALIC, true);
|
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));
|
||||||
}
|
}
|
||||||
|
@ -9,16 +9,14 @@ import dev.plex.command.source.RequiredCommandSource;
|
|||||||
import dev.plex.module.PlexModule;
|
import dev.plex.module.PlexModule;
|
||||||
import dev.plex.module.PlexModuleFile;
|
import dev.plex.module.PlexModuleFile;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
|
import dev.plex.util.PlexLog;
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import dev.plex.util.PlexLog;
|
|
||||||
import dev.plex.util.PlexUtils;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.command.Command;
|
|
||||||
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;
|
||||||
@ -52,12 +50,15 @@ public class PlexCMD extends PlexCommand
|
|||||||
plugin.indefBans.load(false);
|
plugin.indefBans.load(false);
|
||||||
plugin.getPunishmentManager().mergeIndefiniteBans();
|
plugin.getPunishmentManager().mergeIndefiniteBans();
|
||||||
send(sender, "Reloaded indefinite bans");
|
send(sender, "Reloaded indefinite bans");
|
||||||
plugin.blockedCommands.load();
|
plugin.commands.load();
|
||||||
plugin.getCommandBlockerManager().syncCommands();
|
|
||||||
send(sender, "Reloaded blocked commands file");
|
send(sender, "Reloaded blocked commands file");
|
||||||
plugin.getRankManager().importDefaultRanks();
|
plugin.getRankManager().importDefaultRanks();
|
||||||
send(sender, "Imported ranks");
|
send(sender, "Imported ranks");
|
||||||
plugin.setSystem(plugin.config.getString("system"));
|
plugin.setSystem(plugin.config.getString("system"));
|
||||||
|
if (!plugin.setupPermissions() && plugin.getSystem().equalsIgnoreCase("permissions") && !plugin.getServer().getPluginManager().isPluginEnabled("Vault"))
|
||||||
|
{
|
||||||
|
throw new RuntimeException("Vault is required to run on the server if you use permissions!");
|
||||||
|
}
|
||||||
plugin.getServiceManager().endServices();
|
plugin.getServiceManager().endServices();
|
||||||
plugin.getServiceManager().startServices();
|
plugin.getServiceManager().startServices();
|
||||||
PlexLog.debug("Restarted services");
|
PlexLog.debug("Restarted services");
|
||||||
|
@ -33,14 +33,14 @@ public class RankCMD extends PlexCommand
|
|||||||
if (!(playerSender == null))
|
if (!(playerSender == null))
|
||||||
{
|
{
|
||||||
Rank rank = getPlexPlayer(playerSender).getRankFromString();
|
Rank rank = getPlexPlayer(playerSender).getRankFromString();
|
||||||
return messageComponent("yourRank", rank.getReadable());
|
return messageComponent("yourRank", rank.isAtLeast(Rank.ADMIN) && !getPlexPlayer(playerSender).isAdminActive() ? (playerSender.isOp() ? Rank.OP.getReadable() : Rank.NONOP.getReadable()) : rank.getReadable());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Player player = getNonNullPlayer(args[0]);
|
Player player = getNonNullPlayer(args[0]);
|
||||||
Rank rank = getPlexPlayer(player).getRankFromString();
|
Rank rank = getPlexPlayer(player).getRankFromString();
|
||||||
return messageComponent("otherRank", player.getName(), rank.getReadable());
|
return messageComponent("otherRank", player.getName(), rank.isAtLeast(Rank.ADMIN) && !getPlexPlayer(player).isAdminActive() ? (player.isOp() ? Rank.OP.getReadable() : Rank.NONOP.getReadable()) : rank.getReadable());
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SENIOR_ADMIN, permission = "plex.rawsay", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.SENIOR_ADMIN, permission = "plex.rawsay", source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "rawsay", usage = "/<command> <message>", description = "Displays a 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
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
|
31
src/main/java/dev/plex/command/impl/SayCMD.java
Normal file
31
src/main/java/dev/plex/command/impl/SayCMD.java
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
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.rank.enums.Rank;
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.say", source = RequiredCommandSource.ANY)
|
||||||
|
@CommandParameters(name = "say", usage = "/<command> <message>", description = "Displays a message to everyone")
|
||||||
|
public class SayCMD extends PlexCommand
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
protected Component execute(@NotNull CommandSender sender, @Nullable Player playerSender, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return usage();
|
||||||
|
}
|
||||||
|
|
||||||
|
PlexUtils.broadcast(PlexUtils.messageComponent("sayMessage", sender.getName(), PlexUtils.mmStripColor(StringUtils.join(args, " "))));
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -7,9 +7,10 @@ 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.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
|
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 net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
|
||||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -47,15 +48,15 @@ public class TagCMD extends PlexCommand
|
|||||||
return usage("/tag set <prefix>");
|
return usage("/tag set <prefix>");
|
||||||
}
|
}
|
||||||
String prefix = StringUtils.join(args, " ", 1, args.length);
|
String prefix = StringUtils.join(args, " ", 1, args.length);
|
||||||
Component convertedComponent = removeEvents(noColorComponentFromString(prefix));
|
|
||||||
convertedComponent = removeEvents(MiniMessage.miniMessage().deserialize(LegacyComponentSerializer.legacySection().serialize(convertedComponent)));
|
Component convertedComponent = removeEvents(PlexUtils.mmCustomDeserialize(prefix = prefix.replace("<newline>", "").replace("<br>", ""), StandardTags.color(), StandardTags.rainbow(), StandardTags.decorations(), StandardTags.gradient(), StandardTags.transition())); //noColorComponentFromString(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));
|
||||||
}
|
}
|
||||||
@ -85,7 +86,7 @@ public class TagCMD extends PlexCommand
|
|||||||
PlexPlayer plexTarget = DataUtils.getPlayer(target.getUniqueId());
|
PlexPlayer plexTarget = DataUtils.getPlayer(target.getUniqueId());
|
||||||
plexTarget.setPrefix("");
|
plexTarget.setPrefix("");
|
||||||
DataUtils.update(plexTarget);
|
DataUtils.update(plexTarget);
|
||||||
messageComponent("otherPrefixCleared");
|
return messageComponent("otherPrefixCleared", target.getName());
|
||||||
}
|
}
|
||||||
return usage();
|
return usage();
|
||||||
}
|
}
|
||||||
|
@ -5,24 +5,12 @@ 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.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.services.ServiceManager;
|
|
||||||
import dev.plex.services.impl.AutoWipeService;
|
|
||||||
import dev.plex.util.PlexUtils;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
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.Arrays;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.toggledrops", source = RequiredCommandSource.ANY)
|
@CommandPermissions(level = Rank.ADMIN, permission = "plex.toggledrops", source = RequiredCommandSource.ANY)
|
||||||
@CommandParameters(name = "toggledrops", description = "Toggle immediately removing drops.", usage = "/<command>", aliases = "td")
|
@CommandParameters(name = "toggledrops", description = "Toggle immediately removing drops.", usage = "/<command>", aliases = "td")
|
||||||
public class ToggleDropsCMD extends PlexCommand
|
public class ToggleDropsCMD extends PlexCommand
|
||||||
|
@ -14,7 +14,6 @@ import dev.plex.util.PlexUtils;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
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;
|
||||||
@ -47,7 +46,7 @@ public class UnbanCMD extends PlexCommand
|
|||||||
PlexPlayer plexPlayer = getOfflinePlexPlayer(targetUUID);
|
PlexPlayer plexPlayer = getOfflinePlexPlayer(targetUUID);
|
||||||
if (!aBoolean)
|
if (!aBoolean)
|
||||||
{
|
{
|
||||||
send(sender, MiniMessage.miniMessage().deserialize(new PlayerNotBannedException().getMessage()));
|
send(sender, PlexUtils.mmDeserialize(new PlayerNotBannedException().getMessage()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
plugin.getPunishmentManager().unban(targetUUID);
|
plugin.getPunishmentManager().unban(targetUUID);
|
||||||
|
@ -8,7 +8,7 @@ import org.bukkit.event.Event;
|
|||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event that is ran when a player is added to the admin list
|
* Event that is run when a player is added to the admin list
|
||||||
*/
|
*/
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@Data
|
@Data
|
||||||
|
@ -8,7 +8,7 @@ import org.bukkit.event.Event;
|
|||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event that is ran when a player is removed from the admin list
|
* Event that is run when a player is removed from the admin list
|
||||||
*/
|
*/
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@Data
|
@Data
|
||||||
|
@ -9,7 +9,7 @@ import org.bukkit.event.Event;
|
|||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Event that is ran when an admin's rank is set
|
* Event that is run when an admins rank is set
|
||||||
*/
|
*/
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
@Data
|
@Data
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package dev.plex.event;
|
package dev.plex.event;
|
||||||
|
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import java.util.UUID;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
@ -39,7 +39,8 @@ public class CommandHandler extends PlexBase
|
|||||||
commands.add(clazz.getConstructor().newInstance());
|
commands.add(clazz.getConstructor().newInstance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException ex)
|
catch (InvocationTargetException | InstantiationException | IllegalAccessException |
|
||||||
|
NoSuchMethodException ex)
|
||||||
{
|
{
|
||||||
PlexLog.error("Failed to register " + clazz.getSimpleName() + " as a command!");
|
PlexLog.error("Failed to register " + clazz.getSimpleName() + " as a command!");
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,8 @@ public class ListenerHandler extends PlexBase
|
|||||||
listeners.add(clazz.getConstructor().newInstance());
|
listeners.add(clazz.getConstructor().newInstance());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException ex)
|
catch (InvocationTargetException | InstantiationException | IllegalAccessException |
|
||||||
|
NoSuchMethodException ex)
|
||||||
{
|
{
|
||||||
PlexLog.error("Failed to register " + clazz.getSimpleName() + " as a listener!");
|
PlexLog.error("Failed to register " + clazz.getSimpleName() + " as a listener!");
|
||||||
}
|
}
|
||||||
|
@ -18,16 +18,17 @@ public class AdminListener extends PlexListener
|
|||||||
{
|
{
|
||||||
String userSender = event.getSender().getName();
|
String userSender = event.getSender().getName();
|
||||||
PlexPlayer target = event.getPlexPlayer();
|
PlexPlayer target = event.getPlexPlayer();
|
||||||
if (!target.getRank().isEmpty())
|
if (target.getRankFromString().isAtLeast(Rank.ADMIN))
|
||||||
{
|
{
|
||||||
PlexUtils.broadcast(messageComponent("adminReadded", userSender, target.getName(), target.getRankFromString().getReadable()));
|
PlexUtils.broadcast(messageComponent("adminReadded", userSender, target.getName(), target.getRankFromString().getReadable()));
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
target.setRank(Rank.ADMIN.name());
|
target.setRank(Rank.ADMIN.name());
|
||||||
PlexUtils.broadcast(messageComponent("newAdminAdded", userSender, target.getName()));
|
PlexUtils.broadcast(messageComponent("newAdminAdded", userSender, target.getName()));
|
||||||
}
|
}
|
||||||
target.setAdminActive(true);
|
target.setAdminActive(true);
|
||||||
DataUtils.update(target);
|
DataUtils.update(target);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -35,7 +36,6 @@ public class AdminListener extends PlexListener
|
|||||||
{
|
{
|
||||||
String userSender = event.getSender().getName();
|
String userSender = event.getSender().getName();
|
||||||
PlexPlayer target = event.getPlexPlayer();
|
PlexPlayer target = event.getPlexPlayer();
|
||||||
// target.setRank("");
|
|
||||||
target.setAdminActive(false);
|
target.setAdminActive(false);
|
||||||
DataUtils.update(target);
|
DataUtils.update(target);
|
||||||
PlexUtils.broadcast(messageComponent("adminRemoved", userSender, target.getName()));
|
PlexUtils.broadcast(messageComponent("adminRemoved", userSender, target.getName()));
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
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 java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import dev.plex.util.PlexUtils;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -28,7 +27,7 @@ public class BlockListener extends PlexListener
|
|||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
{
|
{
|
||||||
List<String> blockedBlocksConfig = plugin.config.getStringList("blockedBlocks");
|
List<String> blockedBlocksConfig = plugin.config.getStringList("blocked_blocks");
|
||||||
if (blockedBlocksConfig != cachedBlockedBlocksConfig)
|
if (blockedBlocksConfig != cachedBlockedBlocksConfig)
|
||||||
{
|
{
|
||||||
blockedBlocks.clear();
|
blockedBlocks.clear();
|
||||||
@ -57,17 +56,17 @@ public class BlockListener extends PlexListener
|
|||||||
if (blockedBlocks.contains(block.getType()))
|
if (blockedBlocks.contains(block.getType()))
|
||||||
{
|
{
|
||||||
block.setType(Material.CAKE);
|
block.setType(Material.CAKE);
|
||||||
PlexUtils.disabledEffect(event.getPlayer(), block.getLocation().add(0.5,0.5,0.5));
|
PlexUtils.disabledEffect(event.getPlayer(), block.getLocation().add(0.5, 0.5, 0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(SIGNS.contains(block.getType()))
|
if (SIGNS.contains(block.getType()))
|
||||||
{
|
{
|
||||||
Sign sign = (Sign) block.getState();
|
Sign sign = (Sign)block.getState();
|
||||||
boolean anythingChanged = false;
|
boolean anythingChanged = false;
|
||||||
for (int i = 0; i < sign.lines().size(); i++)
|
for (int i = 0; i < sign.lines().size(); i++)
|
||||||
{
|
{
|
||||||
Component line = sign.line(i);
|
Component line = sign.line(i);
|
||||||
if(line.clickEvent() != null)
|
if (line.clickEvent() != null)
|
||||||
{
|
{
|
||||||
anythingChanged = true;
|
anythingChanged = true;
|
||||||
sign.line(i, line.clickEvent(null));
|
sign.line(i, line.clickEvent(null));
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package dev.plex.listener.impl;
|
package dev.plex.listener.impl;
|
||||||
|
|
||||||
import dev.plex.cache.player.PlayerCache;
|
import dev.plex.cache.PlayerCache;
|
||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.listener.annotation.Toggleable;
|
import dev.plex.listener.annotation.Toggleable;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
@ -9,7 +9,7 @@ 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.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -51,14 +51,14 @@ public class ChatListener extends PlexListener
|
|||||||
return Component.empty()
|
return Component.empty()
|
||||||
.append(prefix)
|
.append(prefix)
|
||||||
.append(Component.space())
|
.append(Component.space())
|
||||||
.append(LegacyComponentSerializer.legacyAmpersand().deserialize("&" + plugin.config.getString("chat.name-color") + LegacyComponentSerializer.legacyAmpersand().serialize(sourceDisplayName)))
|
.append(MiniMessage.miniMessage().deserialize(plugin.config.getString("chat.name-color", "<white>"))).append(sourceDisplayName)
|
||||||
.append(Component.space())
|
.append(Component.space())
|
||||||
.append(Component.text("»").color(NamedTextColor.GRAY))
|
.append(Component.text("»").color(NamedTextColor.GRAY))
|
||||||
.append(Component.space())
|
.append(Component.space())
|
||||||
.append(message);
|
.append(message);
|
||||||
}
|
}
|
||||||
return Component.empty()
|
return Component.empty()
|
||||||
.append(LegacyComponentSerializer.legacyAmpersand().deserialize("&" + plugin.config.getString("chat.name-color") + LegacyComponentSerializer.legacyAmpersand().serialize(sourceDisplayName)))
|
.append(MiniMessage.miniMessage().deserialize(plugin.config.getString("chat.name-color", "<white>"))).append(sourceDisplayName)
|
||||||
.append(Component.space())
|
.append(Component.space())
|
||||||
.append(Component.text("»").color(NamedTextColor.GRAY))
|
.append(Component.text("»").color(NamedTextColor.GRAY))
|
||||||
.append(Component.space())
|
.append(Component.space())
|
||||||
|
@ -1,14 +1,18 @@
|
|||||||
package dev.plex.listener.impl;
|
package dev.plex.listener.impl;
|
||||||
|
|
||||||
import dev.plex.cache.DataUtils;
|
import dev.plex.cache.DataUtils;
|
||||||
import dev.plex.cache.player.PlayerCache;
|
import dev.plex.cache.PlayerCache;
|
||||||
import dev.plex.command.blocker.BaseCommand;
|
import dev.plex.command.blocking.BlockedCommand;
|
||||||
import dev.plex.command.blocker.MatchCommand;
|
|
||||||
import dev.plex.command.blocker.RegexCommand;
|
|
||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.rank.enums.Rank;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import dev.plex.services.impl.CommandBlockerService;
|
||||||
|
import dev.plex.util.PlexLog;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -30,44 +34,100 @@ public class CommandListener extends PlexListener
|
|||||||
pl.sendMessage(ChatColor.GRAY + player.getName() + ": " + command);
|
pl.sendMessage(ChatColor.GRAY + player.getName() + ": " + command);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!plugin.getCommandBlockerManager().loadedYet)
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void onCommandBlocking(PlayerCommandPreprocessEvent event)
|
||||||
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
String message = event.getMessage().substring(1).stripLeading(); // stripLeading() is VITAL for workaround blocking (/ minecraft:summon)
|
|
||||||
for (BaseCommand blockedCommand : plugin.getCommandBlockerManager().getBlockedCommands())
|
|
||||||
{
|
|
||||||
PlexPlayer plexPlayer = DataUtils.getPlayer(player.getUniqueId());
|
PlexPlayer plexPlayer = DataUtils.getPlayer(player.getUniqueId());
|
||||||
if (blockedCommand.getRank() != null && plexPlayer.getRankFromString().isAtLeast(blockedCommand.getRank()))
|
String commandName = StringUtils.normalizeSpace(event.getMessage()).split(" ")[0].replaceFirst("/", "");
|
||||||
|
String arguments = StringUtils.normalizeSpace(StringUtils.normalizeSpace(event.getMessage()).replace(event.getMessage().split(" ")[0], ""));
|
||||||
|
PlexLog.debug("Checking Command: {0} with args {1}", commandName, arguments);
|
||||||
|
AtomicReference<BlockedCommand> cmdRef = new AtomicReference<>();
|
||||||
|
PlexLog.debug("Blocked Commands List: " + CommandBlockerService.getBLOCKED_COMMANDS().size());
|
||||||
|
CommandBlockerService.getBLOCKED_COMMANDS().stream().filter(blockedCommand -> blockedCommand.getCommand() != null).forEach(blockedCommand ->
|
||||||
{
|
{
|
||||||
continue;
|
boolean matches = true;
|
||||||
|
String[] args = blockedCommand.getCommand().split(" ");
|
||||||
|
String[] cmdArgs = event.getMessage().replaceFirst("/", "").split(" ");
|
||||||
|
for (int i = 0; i < args.length; i++)
|
||||||
|
{
|
||||||
|
if (i + 1 > cmdArgs.length)
|
||||||
|
{
|
||||||
|
matches = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
if (!args[i].equalsIgnoreCase(cmdArgs[i]))
|
||||||
boolean isBlocked = false;
|
|
||||||
if (blockedCommand instanceof RegexCommand regexCommand)
|
|
||||||
{
|
{
|
||||||
if (regexCommand.getRegex().matcher(message).lookingAt())
|
matches = false;
|
||||||
{
|
break;
|
||||||
isBlocked = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (blockedCommand instanceof MatchCommand matchCommand)
|
if (matches)
|
||||||
{
|
{
|
||||||
if (message.toLowerCase().startsWith(matchCommand.getMatch().toLowerCase()))
|
PlexLog.debug("Used blocked command exactly matched");
|
||||||
{
|
cmdRef.set(blockedCommand);
|
||||||
isBlocked = true;
|
return;
|
||||||
}
|
}
|
||||||
}
|
if (blockedCommand.getCommandAliases().stream().anyMatch(s -> s.equalsIgnoreCase(commandName)))
|
||||||
if (isBlocked)
|
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
PlexLog.debug("Found a command name in a blocked command alias, checking arguments now.");
|
||||||
//PlexLog.debug("Command blocked.");
|
String[] commandArgs = blockedCommand.getCommand().split(" ");
|
||||||
player.sendMessage(MiniMessage.miniMessage().deserialize(PlexUtils.messageString("blockedCommandColor") + blockedCommand.getMessage()));
|
if (arguments.toLowerCase(Locale.ROOT).startsWith(StringUtils.join(commandArgs, " ", 1, commandArgs.length).toLowerCase(Locale.ROOT)))
|
||||||
|
{
|
||||||
|
PlexLog.debug("Player attempted to use a blocked command with an alias.");
|
||||||
|
cmdRef.set(blockedCommand);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
if (cmdRef.get() == null)
|
||||||
|
{
|
||||||
|
CommandBlockerService.getBLOCKED_COMMANDS().forEach(blockedCommand ->
|
||||||
|
{
|
||||||
|
if (blockedCommand.getRegex() != null)
|
||||||
|
{
|
||||||
|
Pattern pattern = Pattern.compile(blockedCommand.getRegex(), Pattern.CASE_INSENSITIVE);
|
||||||
|
Matcher matcher = pattern.matcher(event.getMessage().replaceFirst("/", ""));
|
||||||
|
if (matcher.find())
|
||||||
|
{
|
||||||
|
PlexLog.debug("Player attempted to use a blocked regex");
|
||||||
|
cmdRef.set(blockedCommand);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (cmdRef.get() != null)
|
||||||
|
{
|
||||||
|
BlockedCommand cmd = cmdRef.get();
|
||||||
|
switch (cmd.getRequiredLevel().toLowerCase(Locale.ROOT))
|
||||||
|
{
|
||||||
|
case "e" ->
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.getPlayer().sendMessage(cmd.getMessage());
|
||||||
|
}
|
||||||
|
case "a" ->
|
||||||
|
{
|
||||||
|
if (plexPlayer.isAdminActive() && plexPlayer.getRankFromString().isAtLeast(Rank.ADMIN))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.getPlayer().sendMessage(cmd.getMessage());
|
||||||
|
}
|
||||||
|
case "s" ->
|
||||||
|
{
|
||||||
|
if (plexPlayer.isAdminActive() && plexPlayer.getRankFromString().isAtLeast(Rank.SENIOR_ADMIN))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.getPlayer().sendMessage(cmd.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,9 @@ public class DropListener extends PlexListener
|
|||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||||
{
|
{
|
||||||
if (!plugin.config.getBoolean("allowdrops")) event.setCancelled(true);
|
if (!plugin.config.getBoolean("allowdrops"))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,17 @@
|
|||||||
package dev.plex.listener.impl;
|
package dev.plex.listener.impl;
|
||||||
|
|
||||||
import dev.plex.cache.DataUtils;
|
import dev.plex.cache.DataUtils;
|
||||||
import dev.plex.cache.player.PlayerCache;
|
import dev.plex.cache.PlayerCache;
|
||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.storage.StorageType;
|
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 net.kyori.adventure.text.minimessage.MiniMessage;
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.event.ClickEvent;
|
||||||
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -17,10 +21,7 @@ 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;
|
||||||
|
|
||||||
import java.util.Arrays;
|
public class PlayerListener<T> extends PlexListener
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class PlayerListener extends PlexListener
|
|
||||||
{
|
{
|
||||||
// setting up a player's data
|
// setting up a player's data
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
@ -73,20 +74,28 @@ public class PlayerListener extends PlexListener
|
|||||||
player.openInventory(player.getInventory());
|
player.openInventory(player.getInventory());
|
||||||
}
|
}
|
||||||
|
|
||||||
assert plexPlayer != null;
|
|
||||||
String loginMessage = plugin.getRankManager().getLoginMessage(plexPlayer);
|
String loginMessage = plugin.getRankManager().getLoginMessage(plexPlayer);
|
||||||
if (!loginMessage.isEmpty())
|
if (!loginMessage.isEmpty())
|
||||||
{
|
{
|
||||||
PlexUtils.broadcast(MiniMessage.miniMessage().deserialize("<aqua>" + player.getName() + " is " + loginMessage));
|
PlexUtils.broadcast(PlexUtils.mmDeserialize("<aqua>" + player.getName() + " is " + loginMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PlexUtils.setupPermissions(player);
|
||||||
|
|
||||||
if (plugin.getStorageType() != StorageType.MONGODB)
|
if (plugin.getStorageType() != StorageType.MONGODB)
|
||||||
{
|
{
|
||||||
plexPlayer.loadNotes().whenComplete((notes, throwable) ->
|
plexPlayer.loadNotes();
|
||||||
{
|
|
||||||
//TODO: Send note messages to admins
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
plugin.getSqlNotes().getNotes(plexPlayer.getUuid()).whenComplete((notes, ex) ->
|
||||||
|
{
|
||||||
|
String plural = notes.size() == 1 ? "note." : "notes.";
|
||||||
|
if (!notes.isEmpty())
|
||||||
|
{
|
||||||
|
PlexUtils.broadcastToAdmins(Component.text(plexPlayer.getName() + " has " + notes.size() + " " + plural).color(NamedTextColor.GOLD));
|
||||||
|
PlexUtils.broadcastToAdmins(Component.text("Click to view their " + plural).clickEvent(ClickEvent.runCommand("/notes " + plexPlayer.getName() + " list")).color(NamedTextColor.GOLD));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// saving the player's data
|
// saving the player's data
|
||||||
|
@ -2,6 +2,9 @@ package dev.plex.listener.impl;
|
|||||||
|
|
||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.List;
|
||||||
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;
|
||||||
@ -20,10 +23,6 @@ import org.bukkit.event.player.PlayerInteractEntityEvent;
|
|||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class SpawnListener extends PlexListener
|
public class SpawnListener extends PlexListener
|
||||||
{
|
{
|
||||||
private static final List<Material> SPAWN_EGGS = Arrays.stream(Material.values()).filter((mat) -> mat.name().endsWith("_SPAWN_EGG")).toList();
|
private static final List<Material> SPAWN_EGGS = Arrays.stream(Material.values()).filter((mat) -> mat.name().endsWith("_SPAWN_EGG")).toList();
|
||||||
@ -39,7 +38,7 @@ public class SpawnListener extends PlexListener
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.config.getStringList("blockedEntities").stream().anyMatch(type -> type.equalsIgnoreCase(event.getEntityType().name())))
|
if (plugin.config.getStringList("blocked_entities").stream().anyMatch(type -> type.equalsIgnoreCase(event.getEntityType().name())))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
Location location = event.getLocation();
|
Location location = event.getLocation();
|
||||||
@ -56,7 +55,7 @@ public class SpawnListener extends PlexListener
|
|||||||
if (SPAWN_EGGS.contains(itemType))
|
if (SPAWN_EGGS.contains(itemType))
|
||||||
{
|
{
|
||||||
Block block = event.getBlock();
|
Block block = event.getBlock();
|
||||||
Location blockLoc = block.getLocation().add(0.5,0.5,0.5).add(((Directional) block.getBlockData()).getFacing().getDirection().multiply(0.8));
|
Location blockLoc = block.getLocation().add(0.5, 0.5, 0.5).add(((Directional)block.getBlockData()).getFacing().getDirection().multiply(0.8));
|
||||||
EntityType eggType = spawnEggToEntityType(itemType);
|
EntityType eggType = spawnEggToEntityType(itemType);
|
||||||
if (eggType != null)
|
if (eggType != null)
|
||||||
{
|
{
|
||||||
@ -109,7 +108,8 @@ public class SpawnListener extends PlexListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static EntityType spawnEggToEntityType(Material mat){
|
private static EntityType spawnEggToEntityType(Material mat)
|
||||||
|
{
|
||||||
EntityType eggType;
|
EntityType eggType;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -2,7 +2,7 @@ package dev.plex.listener.impl;
|
|||||||
|
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.cache.DataUtils;
|
import dev.plex.cache.DataUtils;
|
||||||
import dev.plex.cache.player.PlayerCache;
|
import dev.plex.cache.PlayerCache;
|
||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
@ -21,7 +21,6 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.event.entity.EntitySpawnEvent;
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
import org.bukkit.event.player.PlayerChangedWorldEvent;
|
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -157,16 +156,20 @@ public class WorldListener extends PlexListener
|
|||||||
Title title = Title.valueOf(titleString.toUpperCase(Locale.ROOT));
|
Title title = Title.valueOf(titleString.toUpperCase(Locale.ROOT));
|
||||||
switch (title)
|
switch (title)
|
||||||
{
|
{
|
||||||
case DEV -> {
|
case DEV ->
|
||||||
|
{
|
||||||
hasAccess = PlexUtils.DEVELOPERS.contains(player.getUuid().toString());
|
hasAccess = PlexUtils.DEVELOPERS.contains(player.getUuid().toString());
|
||||||
}
|
}
|
||||||
case MASTER_BUILDER -> {
|
case MASTER_BUILDER ->
|
||||||
|
{
|
||||||
hasAccess = Plex.get().config.contains("titles.masterbuilders") && Plex.get().config.getStringList("titles.masterbuilders").contains(player.getName());
|
hasAccess = Plex.get().config.contains("titles.masterbuilders") && Plex.get().config.getStringList("titles.masterbuilders").contains(player.getName());
|
||||||
}
|
}
|
||||||
case OWNER -> {
|
case OWNER ->
|
||||||
|
{
|
||||||
hasAccess = Plex.get().config.contains("titles.owners") && Plex.get().config.getStringList("titles.owners").contains(player.getName());
|
hasAccess = Plex.get().config.contains("titles.owners") && Plex.get().config.getStringList("titles.owners").contains(player.getName());
|
||||||
}
|
}
|
||||||
default -> {
|
default ->
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,10 @@ package dev.plex.menu;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import dev.plex.cache.DataUtils;
|
import dev.plex.cache.DataUtils;
|
||||||
import dev.plex.cache.player.PlayerCache;
|
import dev.plex.cache.PlayerCache;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.punishment.Punishment;
|
import dev.plex.punishment.Punishment;
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.menu.AbstractMenu;
|
import dev.plex.util.menu.AbstractMenu;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -34,7 +35,7 @@ public class PunishedPlayerMenu extends AbstractMenu
|
|||||||
this.punishedPlayer = player;
|
this.punishedPlayer = player;
|
||||||
for (int i = 0; i <= punishedPlayer.getPunishments().size() / 53; i++)
|
for (int i = 0; i <= punishedPlayer.getPunishments().size() / 53; i++)
|
||||||
{
|
{
|
||||||
Inventory inventory = Bukkit.createInventory(null, 54, "Punishments Page " + (i + 1));
|
Inventory inventory = Bukkit.createInventory(null, 54, PlexUtils.mmDeserialize("Punishments Page " + (i + 1)));
|
||||||
ItemStack nextPage = new ItemStack(Material.FEATHER);
|
ItemStack nextPage = new ItemStack(Material.FEATHER);
|
||||||
ItemMeta meta = nextPage.getItemMeta();
|
ItemMeta meta = nextPage.getItemMeta();
|
||||||
meta.displayName(Component.text("Next Page").color(NamedTextColor.LIGHT_PURPLE));
|
meta.displayName(Component.text("Next Page").color(NamedTextColor.LIGHT_PURPLE));
|
||||||
|
@ -3,6 +3,7 @@ package dev.plex.menu;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import dev.plex.cache.DataUtils;
|
import dev.plex.cache.DataUtils;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
import dev.plex.util.menu.AbstractMenu;
|
import dev.plex.util.menu.AbstractMenu;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -27,15 +28,15 @@ public class PunishmentMenu extends AbstractMenu
|
|||||||
super("§c§lPunishments");
|
super("§c§lPunishments");
|
||||||
for (int i = 0; i <= Bukkit.getOnlinePlayers().size() / 53; i++)
|
for (int i = 0; i <= Bukkit.getOnlinePlayers().size() / 53; i++)
|
||||||
{
|
{
|
||||||
Inventory inventory = Bukkit.createInventory(null, 54, "Punishments Page " + (i + 1));
|
Inventory inventory = Bukkit.createInventory(null, 54, PlexUtils.mmDeserialize("Punishments Page " + (i + 1)));
|
||||||
ItemStack nextPage = new ItemStack(Material.FEATHER);
|
ItemStack nextPage = new ItemStack(Material.FEATHER);
|
||||||
ItemMeta meta = nextPage.getItemMeta();
|
ItemMeta meta = nextPage.getItemMeta();
|
||||||
meta.setDisplayName(ChatColor.LIGHT_PURPLE + "Next Page");
|
meta.displayName(PlexUtils.mmDeserialize("<light_purple>Next Page"));
|
||||||
nextPage.setItemMeta(meta);
|
nextPage.setItemMeta(meta);
|
||||||
|
|
||||||
ItemStack previousPage = new ItemStack(Material.FEATHER);
|
ItemStack previousPage = new ItemStack(Material.FEATHER);
|
||||||
ItemMeta meta2 = previousPage.getItemMeta();
|
ItemMeta meta2 = previousPage.getItemMeta();
|
||||||
meta2.setDisplayName(ChatColor.LIGHT_PURPLE + "Previous Page");
|
meta2.displayName(PlexUtils.mmDeserialize("<light_purple>Previous Page"));
|
||||||
previousPage.setItemMeta(meta2);
|
previousPage.setItemMeta(meta2);
|
||||||
|
|
||||||
inventory.setItem(50, nextPage);
|
inventory.setItem(50, nextPage);
|
||||||
@ -72,7 +73,7 @@ public class PunishmentMenu extends AbstractMenu
|
|||||||
ItemStack item = new ItemStack(Material.PLAYER_HEAD);
|
ItemStack item = new ItemStack(Material.PLAYER_HEAD);
|
||||||
SkullMeta meta = (SkullMeta)item.getItemMeta();
|
SkullMeta meta = (SkullMeta)item.getItemMeta();
|
||||||
meta.setOwningPlayer(players);
|
meta.setOwningPlayer(players);
|
||||||
meta.setDisplayName(ChatColor.YELLOW + players.getName());
|
meta.displayName(PlexUtils.mmDeserialize("<!italic><yellow>" + players.getName()));
|
||||||
item.setItemMeta(meta);
|
item.setItemMeta(meta);
|
||||||
|
|
||||||
inv.setItem(currentItemIndex, item);
|
inv.setItem(currentItemIndex, item);
|
||||||
@ -98,11 +99,19 @@ public class PunishmentMenu extends AbstractMenu
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!event.getCurrentItem().hasItemMeta())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!event.getCurrentItem().getItemMeta().hasDisplayName())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
ItemStack item = event.getCurrentItem();
|
ItemStack item = event.getCurrentItem();
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (item.getType() == Material.FEATHER)
|
if (item.getType() == Material.FEATHER)
|
||||||
{
|
{
|
||||||
if (item.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.LIGHT_PURPLE + "Next Page"))
|
if (item.getItemMeta().displayName().equals(PlexUtils.mmDeserialize("<light_purple>Next Page")))
|
||||||
{
|
{
|
||||||
if (getCurrentInventoryIndex(inv) + 1 > inventories.size() - 1)
|
if (getCurrentInventoryIndex(inv) + 1 > inventories.size() - 1)
|
||||||
{
|
{
|
||||||
@ -114,7 +123,7 @@ public class PunishmentMenu extends AbstractMenu
|
|||||||
}
|
}
|
||||||
openInv((Player)event.getWhoClicked(), getCurrentInventoryIndex(inv) + 1);
|
openInv((Player)event.getWhoClicked(), getCurrentInventoryIndex(inv) + 1);
|
||||||
}
|
}
|
||||||
else if (item.getItemMeta().getDisplayName().equalsIgnoreCase(ChatColor.LIGHT_PURPLE + "Previous Page"))
|
else if (item.getItemMeta().displayName().equals(PlexUtils.mmDeserialize("<light_purple>Previous Page")))
|
||||||
{
|
{
|
||||||
if (getCurrentInventoryIndex(inv) - 1 < 0)
|
if (getCurrentInventoryIndex(inv) - 1 < 0)
|
||||||
{
|
{
|
||||||
|
@ -82,7 +82,8 @@ public class ModuleManager
|
|||||||
plexModule.setLogger(LogManager.getLogger(plexModuleFile.getName()));
|
plexModule.setLogger(LogManager.getLogger(plexModuleFile.getName()));
|
||||||
modules.add(plexModule);
|
modules.add(plexModule);
|
||||||
}
|
}
|
||||||
catch (MalformedURLException | ClassNotFoundException | InvocationTargetException | InstantiationException | IllegalAccessException | NoSuchMethodException e)
|
catch (MalformedURLException | ClassNotFoundException | InvocationTargetException |
|
||||||
|
InstantiationException | IllegalAccessException | NoSuchMethodException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
14
src/main/java/dev/plex/permission/Permission.java
Normal file
14
src/main/java/dev/plex/permission/Permission.java
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
package dev.plex.permission;
|
||||||
|
|
||||||
|
import dev.morphia.annotations.Entity;
|
||||||
|
import java.util.UUID;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Entity
|
||||||
|
public class Permission
|
||||||
|
{
|
||||||
|
private final UUID uuid;
|
||||||
|
private final String permission;
|
||||||
|
private boolean allowed = true;
|
||||||
|
}
|
@ -7,18 +7,16 @@ import dev.morphia.annotations.Id;
|
|||||||
import dev.morphia.annotations.IndexOptions;
|
import dev.morphia.annotations.IndexOptions;
|
||||||
import dev.morphia.annotations.Indexed;
|
import dev.morphia.annotations.Indexed;
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
|
import dev.plex.permission.Permission;
|
||||||
import dev.plex.punishment.Punishment;
|
import dev.plex.punishment.Punishment;
|
||||||
import dev.plex.punishment.extra.Note;
|
import dev.plex.punishment.extra.Note;
|
||||||
import dev.plex.rank.enums.Rank;
|
import dev.plex.rank.enums.Rank;
|
||||||
import dev.plex.storage.StorageType;
|
import dev.plex.storage.StorageType;
|
||||||
|
import dev.plex.util.adapter.LocalDateTimeSerializer;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
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.stream.Collectors;
|
|
||||||
|
|
||||||
import dev.plex.util.adapter.LocalDateTimeSerializer;
|
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -26,6 +24,7 @@ import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.permissions.PermissionAttachment;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ -64,6 +63,9 @@ public class PlexPlayer
|
|||||||
private List<String> ips = Lists.newArrayList();
|
private List<String> ips = Lists.newArrayList();
|
||||||
private List<Punishment> punishments = Lists.newArrayList();
|
private List<Punishment> punishments = Lists.newArrayList();
|
||||||
private List<Note> notes = Lists.newArrayList();
|
private List<Note> notes = Lists.newArrayList();
|
||||||
|
private List<Permission> permissions = Lists.newArrayList();
|
||||||
|
|
||||||
|
private transient PermissionAttachment permissionAttachment;
|
||||||
|
|
||||||
public PlexPlayer()
|
public PlexPlayer()
|
||||||
{
|
{
|
||||||
@ -88,6 +90,10 @@ public class PlexPlayer
|
|||||||
|
|
||||||
this.rank = "";
|
this.rank = "";
|
||||||
this.loadPunishments();
|
this.loadPunishments();
|
||||||
|
if (Plex.get().getStorageType() != StorageType.MONGODB)
|
||||||
|
{
|
||||||
|
this.permissions.addAll(Plex.get().getSqlPermissions().getPermissions(this.uuid));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String displayName()
|
public String displayName()
|
||||||
@ -119,7 +125,7 @@ public class PlexPlayer
|
|||||||
{
|
{
|
||||||
if (Plex.get().getStorageType() != StorageType.MONGODB)
|
if (Plex.get().getStorageType() != StorageType.MONGODB)
|
||||||
{
|
{
|
||||||
this.setPunishments(Plex.get().getSqlPunishment().getPunishments(this.getUuid()).stream().filter(punishment -> punishment.getPunished().equals(this.getUuid())).collect(Collectors.toList()));
|
this.setPunishments(Plex.get().getSqlPunishment().getPunishments(this.getUuid()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ import dev.plex.util.PlexUtils;
|
|||||||
import dev.plex.util.adapter.LocalDateTimeDeserializer;
|
import dev.plex.util.adapter.LocalDateTimeDeserializer;
|
||||||
import dev.plex.util.adapter.LocalDateTimeSerializer;
|
import dev.plex.util.adapter.LocalDateTimeSerializer;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -20,7 +19,6 @@ import net.kyori.adventure.text.Component;
|
|||||||
public class Punishment
|
public class Punishment
|
||||||
{
|
{
|
||||||
private static final String banUrl = Plex.get().config.getString("banning.ban_url");
|
private static final String banUrl = Plex.get().config.getString("banning.ban_url");
|
||||||
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("MM/dd/yyyy 'at' hh:mm:ss a");
|
|
||||||
private final UUID punished;
|
private final UUID punished;
|
||||||
private final UUID punisher;
|
private final UUID punisher;
|
||||||
private String ip;
|
private String ip;
|
||||||
@ -46,7 +44,8 @@ public class Punishment
|
|||||||
public static Component generateBanMessage(Punishment punishment)
|
public static Component generateBanMessage(Punishment punishment)
|
||||||
{
|
{
|
||||||
return PlexUtils.messageComponent("banMessage", banUrl, punishment.getReason(),
|
return PlexUtils.messageComponent("banMessage", banUrl, punishment.getReason(),
|
||||||
DATE_FORMAT.format(punishment.getEndDate()), punishment.getPunisher() == null ? "CONSOLE" : MojangUtils.getInfo(punishment.getPunisher().toString()).getUsername());
|
PlexUtils.useTimezone(punishment.getEndDate()),
|
||||||
|
punishment.getPunisher() == null ? "CONSOLE" : MojangUtils.getInfo(punishment.getPunisher().toString()).getUsername());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component generateIndefBanMessage(String type)
|
public static Component generateIndefBanMessage(String type)
|
||||||
|
@ -159,10 +159,14 @@ public class PunishmentManager extends PlexBase
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
PlexLog.debug("Checking active bans mysql");
|
||||||
CompletableFuture<List<Punishment>> future = new CompletableFuture<>();
|
CompletableFuture<List<Punishment>> future = new CompletableFuture<>();
|
||||||
Plex.get().getSqlPunishment().getPunishments().whenComplete((punishments, throwable) ->
|
Plex.get().getSqlPunishment().getPunishments().whenComplete((punishments, throwable) ->
|
||||||
{
|
{
|
||||||
future.complete(punishments.stream().filter(Punishment::isActive).filter(punishment -> punishment.getType() == PunishmentType.BAN).toList());
|
PlexLog.debug("Received Punishments");
|
||||||
|
List<Punishment> punishmentList = punishments.stream().filter(Punishment::isActive).filter(punishment -> punishment.getType() == PunishmentType.BAN).toList();
|
||||||
|
PlexLog.debug("Completing with {0} punishments", punishmentList.size());
|
||||||
|
future.complete(punishmentList);
|
||||||
});
|
});
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,9 @@ package dev.plex.punishment.extra;
|
|||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import dev.morphia.annotations.Entity;
|
import dev.morphia.annotations.Entity;
|
||||||
import dev.plex.util.adapter.LocalDateTimeSerializer;
|
import dev.plex.util.adapter.LocalDateTimeSerializer;
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Entity
|
@Entity
|
||||||
|
@ -14,7 +14,7 @@ import java.util.stream.Collectors;
|
|||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
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 net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.json.JSONTokener;
|
import org.json.JSONTokener;
|
||||||
@ -95,7 +95,7 @@ public class RankManager
|
|||||||
{
|
{
|
||||||
if (!player.getPrefix().equals(""))
|
if (!player.getPrefix().equals(""))
|
||||||
{
|
{
|
||||||
return MiniMessage.miniMessage().deserialize(player.getPrefix());
|
return PlexUtils.mmCustomDeserialize(player.getPrefix(), StandardTags.color(), StandardTags.rainbow(), StandardTags.decorations(), StandardTags.gradient(), StandardTags.transition());
|
||||||
}
|
}
|
||||||
if (Plex.get().config.contains("titles.owners") && Plex.get().config.getStringList("titles.owners").contains(player.getName()))
|
if (Plex.get().config.contains("titles.owners") && Plex.get().config.getStringList("titles.owners").contains(player.getName()))
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package dev.plex.rank.enums;
|
package dev.plex.rank.enums;
|
||||||
|
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
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 net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ -47,7 +47,7 @@ public enum Rank
|
|||||||
|
|
||||||
public Component getPrefix()
|
public Component getPrefix()
|
||||||
{
|
{
|
||||||
return MiniMessage.miniMessage().deserialize(this.prefix);
|
return PlexUtils.mmDeserialize(this.prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject toJSON()
|
public JSONObject toJSON()
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package dev.plex.rank.enums;
|
package dev.plex.rank.enums;
|
||||||
|
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
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 net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
@ -39,7 +39,7 @@ public enum Title
|
|||||||
|
|
||||||
public Component getPrefix()
|
public Component getPrefix()
|
||||||
{
|
{
|
||||||
return MiniMessage.miniMessage().deserialize(this.prefix);
|
return PlexUtils.mmDeserialize(this.prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject toJSON()
|
public JSONObject toJSON()
|
||||||
|
@ -2,12 +2,15 @@ package dev.plex.services;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.services.impl.*;
|
import dev.plex.services.impl.AutoWipeService;
|
||||||
|
import dev.plex.services.impl.BanService;
|
||||||
|
import dev.plex.services.impl.CommandBlockerService;
|
||||||
|
import dev.plex.services.impl.GameRuleService;
|
||||||
|
import dev.plex.services.impl.UpdateCheckerService;
|
||||||
|
import java.util.List;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class ServiceManager
|
public class ServiceManager
|
||||||
{
|
{
|
||||||
private final List<AbstractService> services = Lists.newArrayList();
|
private final List<AbstractService> services = Lists.newArrayList();
|
||||||
|
@ -2,12 +2,10 @@ package dev.plex.services.impl;
|
|||||||
|
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.services.AbstractService;
|
import dev.plex.services.AbstractService;
|
||||||
|
import java.util.List;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class AutoWipeService extends AbstractService
|
public class AutoWipeService extends AbstractService
|
||||||
{
|
{
|
||||||
|
@ -1,20 +1,69 @@
|
|||||||
package dev.plex.services.impl;
|
package dev.plex.services.impl;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import dev.plex.command.blocking.BlockedCommand;
|
||||||
import dev.plex.services.AbstractService;
|
import dev.plex.services.AbstractService;
|
||||||
import dev.plex.util.PlexLog;
|
import dev.plex.util.PlexLog;
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
|
||||||
public class CommandBlockerService extends AbstractService
|
public class CommandBlockerService extends AbstractService
|
||||||
{
|
{
|
||||||
|
@Getter
|
||||||
|
private static final List<BlockedCommand> BLOCKED_COMMANDS = Lists.newArrayList();
|
||||||
|
|
||||||
public CommandBlockerService()
|
public CommandBlockerService()
|
||||||
{
|
{
|
||||||
super(false, true);
|
super(false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
plugin.getCommandBlockerManager().syncCommands();
|
BLOCKED_COMMANDS.clear();
|
||||||
PlexLog.log("Command Blocker commands loaded");
|
plugin.commands.getStringList("commands").forEach(s ->
|
||||||
|
{
|
||||||
|
BlockedCommand command = new BlockedCommand();
|
||||||
|
int lastDelim = s.lastIndexOf(':');
|
||||||
|
|
||||||
|
String cmdWithoutMsg = s.substring(0, lastDelim);
|
||||||
|
String[] args = cmdWithoutMsg.split(":", 3); // Delimiter code by ayunami
|
||||||
|
if (s.toLowerCase(Locale.ROOT).startsWith("r"))
|
||||||
|
{
|
||||||
|
command.setRequiredLevel(args[1]);
|
||||||
|
command.setRegex(args[2]);
|
||||||
|
command.setMessage(s.substring(lastDelim + 1).equalsIgnoreCase("_") ? PlexUtils.messageComponent("commandBlocked") : PlexUtils.mmDeserialize(s.substring(lastDelim + 1)));
|
||||||
|
/*PlexLog.debug("=Found regex blocked=");
|
||||||
|
PlexLog.debug(" Regex: " + command.getRegex());
|
||||||
|
PlexLog.debug(" Message: " + command.getMessage());
|
||||||
|
PlexLog.debug("====================");*/
|
||||||
|
}
|
||||||
|
else if (s.toLowerCase(Locale.ROOT).startsWith("m"))
|
||||||
|
{
|
||||||
|
command.setRequiredLevel(args[1]);
|
||||||
|
command.setCommand(args[2]);
|
||||||
|
command.setMessage(s.substring(lastDelim + 1).equalsIgnoreCase("_") ? PlexUtils.messageComponent("commandBlocked") : PlexUtils.mmDeserialize(s.substring(lastDelim + 1)));
|
||||||
|
Command cmd = plugin.getServer().getCommandMap().getCommand(command.getCommand().split(" ")[0]);
|
||||||
|
if (cmd == null)
|
||||||
|
{
|
||||||
|
PlexLog.error("Command '{0}' does not belong to any plugin!", command.getCommand().split(" ")[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
command.setCommandAliases(cmd.getAliases());
|
||||||
|
command.getCommandAliases().add(command.getCommand().split(" ")[0]);
|
||||||
|
/*PlexLog.debug("=Found command blocked=");
|
||||||
|
PlexLog.debug(" Required Level: " + command.getRequiredLevel());
|
||||||
|
PlexLog.debug(" Command: " + command.getCommand());
|
||||||
|
PlexLog.debug(" Message: " + command.getMessage());
|
||||||
|
PlexLog.debug(" Aliases: " + Arrays.toString(command.getCommandAliases().toArray(new String[0])));
|
||||||
|
PlexLog.debug("====================");*/
|
||||||
|
}
|
||||||
|
BLOCKED_COMMANDS.add(command);
|
||||||
|
});
|
||||||
|
PlexLog.log("Command Blocker has loaded {0} entries!", BLOCKED_COMMANDS.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package dev.plex.storage;
|
package dev.plex.storage;
|
||||||
|
|
||||||
import com.mongodb.*;
|
|
||||||
import com.mongodb.client.MongoClient;
|
import com.mongodb.client.MongoClient;
|
||||||
import com.mongodb.client.MongoClients;
|
import com.mongodb.client.MongoClients;
|
||||||
import dev.morphia.Datastore;
|
import dev.morphia.Datastore;
|
||||||
@ -32,10 +31,14 @@ public class MongoConnection extends PlexBase
|
|||||||
if (database != null && !database.isEmpty())
|
if (database != null && !database.isEmpty())
|
||||||
{
|
{
|
||||||
connectionString = "mongodb://" + username + ":" + password + "@" + host + ":" + port + "/?authSource=" + database;
|
connectionString = "mongodb://" + username + ":" + password + "@" + host + ":" + port + "/?authSource=" + database;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
connectionString = "mongodb://" + username + ":" + password + "@" + host + ":" + port + "/";
|
connectionString = "mongodb://" + username + ":" + password + "@" + host + ":" + port + "/";
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
connectionString = "mongodb://" + host + ":" + port + "/";
|
connectionString = "mongodb://" + host + ":" + port + "/";
|
||||||
}
|
}
|
||||||
connectionString += "?uuidRepresentation=STANDARD";
|
connectionString += "?uuidRepresentation=STANDARD";
|
||||||
|
@ -4,11 +4,10 @@ import com.zaxxer.hikari.HikariConfig;
|
|||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.PlexBase;
|
import dev.plex.PlexBase;
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class SQLConnection extends PlexBase
|
public class SQLConnection extends PlexBase
|
||||||
@ -45,7 +44,8 @@ public class SQLConnection extends PlexBase
|
|||||||
{
|
{
|
||||||
dataSource.setJdbcUrl("jdbc:sqlite:" + new File(plugin.getDataFolder(), "database.db").getAbsolutePath());
|
dataSource.setJdbcUrl("jdbc:sqlite:" + new File(plugin.getDataFolder(), "database.db").getAbsolutePath());
|
||||||
plugin.setStorageType(StorageType.SQLITE);
|
plugin.setStorageType(StorageType.SQLITE);
|
||||||
} else if (plugin.config.getString("data.central.storage").equalsIgnoreCase("mariadb"))
|
}
|
||||||
|
else if (plugin.config.getString("data.central.storage").equalsIgnoreCase("mariadb"))
|
||||||
{
|
{
|
||||||
Class.forName("org.mariadb.jdbc.Driver");
|
Class.forName("org.mariadb.jdbc.Driver");
|
||||||
dataSource.setJdbcUrl("jdbc:mariadb://" + host + ":" + port + "/" + database);
|
dataSource.setJdbcUrl("jdbc:mariadb://" + host + ":" + port + "/" + database);
|
||||||
@ -53,7 +53,8 @@ public class SQLConnection extends PlexBase
|
|||||||
dataSource.setPassword(password);
|
dataSource.setPassword(password);
|
||||||
Plex.get().setStorageType(StorageType.MARIADB);
|
Plex.get().setStorageType(StorageType.MARIADB);
|
||||||
}
|
}
|
||||||
} catch (ClassNotFoundException throwables)
|
}
|
||||||
|
catch (ClassNotFoundException throwables)
|
||||||
{
|
{
|
||||||
throwables.printStackTrace();
|
throwables.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -90,7 +91,13 @@ public class SQLConnection extends PlexBase
|
|||||||
"`note` VARCHAR(2000), " +
|
"`note` VARCHAR(2000), " +
|
||||||
"`timestamp` BIGINT" +
|
"`timestamp` BIGINT" +
|
||||||
");").execute();
|
");").execute();
|
||||||
} catch (SQLException throwables)
|
con.prepareStatement("CREATE TABLE IF NOT EXISTS `permissions` (" +
|
||||||
|
"`uuid` VARCHAR(46) NOT NULL," +
|
||||||
|
"`permission` VARCHAR(1000) NOT NULL," +
|
||||||
|
"`allowed` BOOLEAN" +
|
||||||
|
");").execute();
|
||||||
|
}
|
||||||
|
catch (SQLException throwables)
|
||||||
{
|
{
|
||||||
throwables.printStackTrace();
|
throwables.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -105,7 +112,8 @@ public class SQLConnection extends PlexBase
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
return dataSource.getConnection();
|
return dataSource.getConnection();
|
||||||
} catch (SQLException e)
|
}
|
||||||
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,95 @@
|
|||||||
|
package dev.plex.storage.permission;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import dev.plex.Plex;
|
||||||
|
import dev.plex.permission.Permission;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class SQLPermissions
|
||||||
|
{
|
||||||
|
private static final String SELECT = "SELECT * FROM `permissions` WHERE uuid=?";
|
||||||
|
private static final String INSERT = "INSERT INTO `permissions` (`uuid`, `permission`, `allowed`) VALUES(?, ?, ?)";
|
||||||
|
private static final String REMOVE_PERMISSION = "DELETE FROM `permissions` WHERE uuid=? AND permission=?";
|
||||||
|
private static final String UPDATE_PERMISSION = "UPDATE `permissions` SET allowed=? WHERE uuid=? AND permission=?";
|
||||||
|
|
||||||
|
public List<Permission> getPermissions(UUID uuid)
|
||||||
|
{
|
||||||
|
List<Permission> permissions = Lists.newArrayList();
|
||||||
|
try (Connection con = Plex.get().getSqlConnection().getCon())
|
||||||
|
{
|
||||||
|
PreparedStatement statement = con.prepareStatement(SELECT);
|
||||||
|
statement.setString(1, uuid.toString());
|
||||||
|
ResultSet set = statement.executeQuery();
|
||||||
|
while (set.next())
|
||||||
|
{
|
||||||
|
Permission permission = new Permission(UUID.fromString(set.getString("uuid")), set.getString("permission"));
|
||||||
|
permission.setAllowed(set.getBoolean("allowed"));
|
||||||
|
permissions.add(permission);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return permissions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addPermission(Permission permission)
|
||||||
|
{
|
||||||
|
try (Connection con = Plex.get().getSqlConnection().getCon())
|
||||||
|
{
|
||||||
|
PreparedStatement statement = con.prepareStatement(INSERT);
|
||||||
|
statement.setString(1, permission.getUuid().toString());
|
||||||
|
statement.setString(2, permission.getPermission().toLowerCase(Locale.ROOT));
|
||||||
|
statement.setBoolean(3, permission.isAllowed());
|
||||||
|
statement.execute();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updatePermission(Permission permission, boolean newValue)
|
||||||
|
{
|
||||||
|
try (Connection con = Plex.get().getSqlConnection().getCon())
|
||||||
|
{
|
||||||
|
PreparedStatement statement = con.prepareStatement(UPDATE_PERMISSION);
|
||||||
|
statement.setBoolean(1, newValue);
|
||||||
|
statement.setString(2, permission.getUuid().toString());
|
||||||
|
statement.setString(3, permission.getPermission().toLowerCase(Locale.ROOT));
|
||||||
|
statement.executeUpdate();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePermission(Permission permission)
|
||||||
|
{
|
||||||
|
this.removePermission(permission.getUuid(), permission.getPermission());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removePermission(UUID uuid, String permission)
|
||||||
|
{
|
||||||
|
try (Connection con = Plex.get().getSqlConnection().getCon())
|
||||||
|
{
|
||||||
|
PreparedStatement statement = con.prepareStatement(REMOVE_PERMISSION);
|
||||||
|
statement.setString(1, uuid.toString());
|
||||||
|
statement.setString(2, permission.toLowerCase(Locale.ROOT));
|
||||||
|
statement.execute();
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package dev.plex.cache.player;
|
package dev.plex.storage.player;
|
||||||
|
|
||||||
import dev.morphia.Datastore;
|
import dev.morphia.Datastore;
|
||||||
import dev.morphia.query.Query;
|
import dev.morphia.query.Query;
|
||||||
@ -6,6 +6,7 @@ import dev.morphia.query.Update;
|
|||||||
import dev.morphia.query.experimental.filters.Filters;
|
import dev.morphia.query.experimental.filters.Filters;
|
||||||
import dev.morphia.query.experimental.updates.UpdateOperators;
|
import dev.morphia.query.experimental.updates.UpdateOperators;
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
|
import dev.plex.cache.PlayerCache;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -43,6 +44,14 @@ public class MongoPlayerData
|
|||||||
return query.first() != null;
|
return query.first() != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean exists(String username)
|
||||||
|
{
|
||||||
|
Query<PlexPlayer> query = datastore.find(PlexPlayer.class)
|
||||||
|
.filter(Filters.regex("name").caseInsensitive().pattern(username));
|
||||||
|
|
||||||
|
return query.first() != null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the player from cache or from mongo's database
|
* Gets the player from cache or from mongo's database
|
||||||
*
|
*
|
@ -1,8 +1,9 @@
|
|||||||
package dev.plex.cache.player;
|
package dev.plex.storage.player;
|
||||||
|
|
||||||
import com.google.common.reflect.TypeToken;
|
import com.google.common.reflect.TypeToken;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
|
import dev.plex.cache.PlayerCache;
|
||||||
import dev.plex.player.PlexPlayer;
|
import dev.plex.player.PlexPlayer;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
@ -42,6 +43,22 @@ public class SQLPlayerData
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean exists(String username)
|
||||||
|
{
|
||||||
|
try (Connection con = Plex.get().getSqlConnection().getCon())
|
||||||
|
{
|
||||||
|
PreparedStatement statement = con.prepareStatement("SELECT * FROM `players` WHERE name=?");
|
||||||
|
statement.setString(1, username);
|
||||||
|
ResultSet set = statement.executeQuery();
|
||||||
|
return set.next();
|
||||||
|
}
|
||||||
|
catch (SQLException throwables)
|
||||||
|
{
|
||||||
|
throwables.printStackTrace();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the player from cache or from the SQL database
|
* Gets the player from cache or from the SQL database
|
||||||
*
|
*
|
@ -1,9 +1,8 @@
|
|||||||
package dev.plex.cache.sql;
|
package dev.plex.storage.punishment;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.punishment.extra.Note;
|
import dev.plex.punishment.extra.Note;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
@ -47,6 +46,7 @@ public class SQLNotes
|
|||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
return notes;
|
||||||
}
|
}
|
||||||
return notes;
|
return notes;
|
||||||
});
|
});
|
@ -1,4 +1,4 @@
|
|||||||
package dev.plex.cache.sql;
|
package dev.plex.storage.punishment;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
@ -36,7 +36,7 @@ public class SQLPunishment
|
|||||||
ResultSet set = statement.executeQuery();
|
ResultSet set = statement.executeQuery();
|
||||||
while (set.next())
|
while (set.next())
|
||||||
{
|
{
|
||||||
Punishment punishment = new Punishment(UUID.fromString(set.getString("punished")), UUID.fromString(set.getString("punisher")));
|
Punishment punishment = new Punishment(UUID.fromString(set.getString("punished")), set.getString("punisher") != null && set.getString("punisher").isEmpty() ? UUID.fromString(set.getString("punisher")) : null);
|
||||||
punishment.setActive(set.getBoolean("active"));
|
punishment.setActive(set.getBoolean("active"));
|
||||||
punishment.setType(PunishmentType.valueOf(set.getString("type")));
|
punishment.setType(PunishmentType.valueOf(set.getString("type")));
|
||||||
punishment.setCustomTime(set.getBoolean("customTime"));
|
punishment.setCustomTime(set.getBoolean("customTime"));
|
||||||
@ -50,6 +50,7 @@ public class SQLPunishment
|
|||||||
catch (SQLException e)
|
catch (SQLException e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
return punishments;
|
||||||
}
|
}
|
||||||
return punishments;
|
return punishments;
|
||||||
});
|
});
|
||||||
@ -111,6 +112,22 @@ public class SQLPunishment
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void syncRemoveBan(UUID uuid)
|
||||||
|
{
|
||||||
|
try (Connection con = Plex.get().getSqlConnection().getCon())
|
||||||
|
{
|
||||||
|
PreparedStatement statement = con.prepareStatement(UPDATE_BAN);
|
||||||
|
statement.setBoolean(1, false);
|
||||||
|
statement.setBoolean(2, true);
|
||||||
|
statement.setString(3, uuid.toString());
|
||||||
|
statement.setString(4, PunishmentType.BAN.name());
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public CompletableFuture<Void> removeBan(UUID uuid)
|
public CompletableFuture<Void> removeBan(UUID uuid)
|
||||||
{
|
{
|
||||||
return CompletableFuture.runAsync(() ->
|
return CompletableFuture.runAsync(() ->
|
@ -4,21 +4,12 @@ import com.google.common.collect.ImmutableSet;
|
|||||||
import com.google.common.reflect.ClassPath;
|
import com.google.common.reflect.ClassPath;
|
||||||
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.PlayerCache;
|
||||||
import dev.plex.config.Config;
|
import dev.plex.config.Config;
|
||||||
|
import dev.plex.permission.Permission;
|
||||||
|
import dev.plex.player.PlexPlayer;
|
||||||
import dev.plex.storage.StorageType;
|
import dev.plex.storage.StorageType;
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
|
||||||
import org.apache.commons.lang.math.NumberUtils;
|
|
||||||
import org.bukkit.*;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.PluginCommandYamlParser;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.json.simple.JSONObject;
|
|
||||||
import org.json.simple.parser.JSONParser;
|
|
||||||
import org.json.simple.parser.ParseException;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
@ -28,10 +19,46 @@ import java.sql.Connection;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.Month;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
import java.util.*;
|
import java.time.format.DateTimeFormatter;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TimeZone;
|
||||||
|
import java.util.UUID;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.resolver.TagResolver;
|
||||||
|
import net.kyori.adventure.text.minimessage.tag.standard.StandardTags;
|
||||||
|
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||||
|
import org.apache.commons.lang.math.NumberUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameRule;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Particle;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.PluginCommandYamlParser;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.permissions.PermissionAttachment;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.parser.JSONParser;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
public class PlexUtils extends PlexBase
|
public class PlexUtils extends PlexBase
|
||||||
{
|
{
|
||||||
@ -54,6 +81,9 @@ public class PlexUtils extends PlexBase
|
|||||||
"ca83b658-c03b-4106-9edc-72f70a80656d", // ayunami2000
|
"ca83b658-c03b-4106-9edc-72f70a80656d", // ayunami2000
|
||||||
"2e06e049-24c8-42e4-8bcf-d35372af31e6" //Fleek
|
"2e06e049-24c8-42e4-8bcf-d35372af31e6" //Fleek
|
||||||
);
|
);
|
||||||
|
private static final DateTimeFormatter DATE_FORMAT = DateTimeFormatter.ofPattern("MM/dd/yyyy 'at' hh:mm:ss a z");
|
||||||
|
private static final Set<String> TIMEZONES = Set.of(TimeZone.getAvailableIDs());
|
||||||
|
private static String TIMEZONE = Plex.get().config.getString("server.timezone");
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
@ -66,6 +96,64 @@ public class PlexUtils extends PlexBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setupPermissions(@NotNull Player player)
|
||||||
|
{
|
||||||
|
PlexPlayer plexPlayer = DataUtils.getPlayer(player.getUniqueId());
|
||||||
|
PermissionAttachment attachment = player.addAttachment(Plex.get());
|
||||||
|
plexPlayer.getPermissions().forEach(permission -> attachment.setPermission(permission.getPermission(), permission.isAllowed()));
|
||||||
|
plexPlayer.setPermissionAttachment(attachment);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addPermission(PlexPlayer player, Permission permission)
|
||||||
|
{
|
||||||
|
Plex.get().getSqlPermissions().addPermission(addToArrayList(player.getPermissions(), permission));
|
||||||
|
Player p = Bukkit.getPlayer(player.getUuid());
|
||||||
|
if (p == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.getPermissionAttachment().setPermission(permission.getPermission(), permission.isAllowed());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void addPermission(PlexPlayer player, String permission)
|
||||||
|
{
|
||||||
|
addPermission(player, new Permission(player.getUuid(), permission));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removePermission(PlexPlayer player, String permission)
|
||||||
|
{
|
||||||
|
Plex.get().getSqlPermissions().removePermission(player.getUuid(), permission);
|
||||||
|
player.getPermissions().removeIf(permission1 -> permission1.getPermission().equalsIgnoreCase(permission));
|
||||||
|
Player p = Bukkit.getPlayer(player.getUuid());
|
||||||
|
if (p == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.getPermissionAttachment().unsetPermission(permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void updatePermission(PlexPlayer player, String permission, boolean newValue)
|
||||||
|
{
|
||||||
|
player.getPermissions().stream().filter(permission1 -> permission.equalsIgnoreCase(permission)).findFirst().ifPresent(permission1 ->
|
||||||
|
{
|
||||||
|
Plex.get().getSqlPermissions().updatePermission(permission1, newValue);
|
||||||
|
});
|
||||||
|
player.getPermissions().removeIf(permission1 -> permission1.getPermission().equalsIgnoreCase(permission));
|
||||||
|
Player p = Bukkit.getPlayer(player.getUuid());
|
||||||
|
if (p == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.getPermissionAttachment().unsetPermission(permission);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T addToArrayList(List<T> list, T object)
|
||||||
|
{
|
||||||
|
list.add(object);
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
|
||||||
public static void disabledEffect(Player player, Location location)
|
public static void disabledEffect(Player player, Location location)
|
||||||
{
|
{
|
||||||
Particle.CLOUD.builder().location(location).receivers(player).extra(0).offset(0.5, 0.5, 0.5).count(5).spawn();
|
Particle.CLOUD.builder().location(location).receivers(player).extra(0).offset(0.5, 0.5, 0.5).count(5).spawn();
|
||||||
@ -145,6 +233,40 @@ public class PlexUtils extends PlexBase
|
|||||||
return ChatColor.translateAlternateColorCodes('&', string);
|
return ChatColor.translateAlternateColorCodes('&', string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final MiniMessage safeMessage = MiniMessage.builder().tags(TagResolver.builder().resolvers(
|
||||||
|
StandardTags.color(),
|
||||||
|
StandardTags.decorations(),
|
||||||
|
StandardTags.gradient(),
|
||||||
|
StandardTags.rainbow(),
|
||||||
|
StandardTags.reset()
|
||||||
|
).build()).build();
|
||||||
|
|
||||||
|
public static String mmStripColor(String input)
|
||||||
|
{
|
||||||
|
return PlainTextComponentSerializer.plainText().serialize(mmDeserialize(input));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Component mmDeserialize(String input)
|
||||||
|
{
|
||||||
|
boolean aprilFools = true; // true by default
|
||||||
|
if (plugin.config.contains("april_fools"))
|
||||||
|
{
|
||||||
|
aprilFools = plugin.config.getBoolean("april_fools");
|
||||||
|
}
|
||||||
|
LocalDateTime date = LocalDateTime.now();
|
||||||
|
if (aprilFools && date.getMonth() == Month.APRIL && date.getDayOfMonth() == 1)
|
||||||
|
{
|
||||||
|
Component component = MiniMessage.miniMessage().deserialize(input); // removes existing tags
|
||||||
|
return MiniMessage.miniMessage().deserialize("<rainbow>" + PlainTextComponentSerializer.plainText().serialize(component));
|
||||||
|
}
|
||||||
|
return MiniMessage.miniMessage().deserialize(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Component mmCustomDeserialize(String input, TagResolver... resolvers)
|
||||||
|
{
|
||||||
|
return MiniMessage.builder().tags(TagResolver.builder().resolvers(resolvers).build()).build().deserialize(input);
|
||||||
|
}
|
||||||
|
|
||||||
public static Component messageComponent(String entry, Object... objects)
|
public static Component messageComponent(String entry, Object... objects)
|
||||||
{
|
{
|
||||||
return MiniMessage.miniMessage().deserialize(messageString(entry, objects));
|
return MiniMessage.miniMessage().deserialize(messageString(entry, objects));
|
||||||
@ -202,6 +324,16 @@ public class PlexUtils extends PlexBase
|
|||||||
return (unit != null) ? unit : TimeUnit.DAY;
|
return (unit != null) ? unit : TimeUnit.DAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String useTimezone(LocalDateTime date)
|
||||||
|
{
|
||||||
|
// Use UTC if the timezone is null or not set correctly
|
||||||
|
if (TIMEZONE == null || !TIMEZONES.contains(TIMEZONE))
|
||||||
|
{
|
||||||
|
TIMEZONE = "Etc/UTC";
|
||||||
|
}
|
||||||
|
return DATE_FORMAT.withZone(ZoneId.of(TIMEZONE)).format(date);
|
||||||
|
}
|
||||||
|
|
||||||
public static LocalDateTime parseDateOffset(String... time)
|
public static LocalDateTime parseDateOffset(String... time)
|
||||||
{
|
{
|
||||||
Instant instant = Instant.now();
|
Instant instant = Instant.now();
|
||||||
@ -303,7 +435,7 @@ public class PlexUtils extends PlexBase
|
|||||||
|
|
||||||
public static void broadcast(String s)
|
public static void broadcast(String s)
|
||||||
{
|
{
|
||||||
Bukkit.broadcast(LegacyComponentSerializer.legacyAmpersand().deserialize(s));
|
Bukkit.broadcast(MiniMessage.miniMessage().deserialize(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void broadcast(Component component)
|
public static void broadcast(Component component)
|
||||||
@ -311,6 +443,12 @@ public class PlexUtils extends PlexBase
|
|||||||
Bukkit.broadcast(component);
|
Bukkit.broadcast(component);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void broadcastToAdmins(Component component)
|
||||||
|
{
|
||||||
|
Bukkit.getOnlinePlayers().stream().filter(pl -> PlayerCache.getPlexPlayer(pl.getUniqueId()).isAdminActive()).forEach(pl ->
|
||||||
|
Bukkit.broadcast(component));
|
||||||
|
}
|
||||||
|
|
||||||
public static Object simpleGET(String url)
|
public static Object simpleGET(String url)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -6,9 +6,17 @@ import com.google.gson.JsonObject;
|
|||||||
import com.google.gson.JsonSyntaxException;
|
import com.google.gson.JsonSyntaxException;
|
||||||
import dev.plex.Plex;
|
import dev.plex.Plex;
|
||||||
import dev.plex.PlexBase;
|
import dev.plex.PlexBase;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.HttpURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import javax.annotation.Nonnull;
|
||||||
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 net.kyori.adventure.text.minimessage.MiniMessage;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
import org.apache.commons.io.FileUtils;
|
||||||
import org.apache.http.HttpResponse;
|
import org.apache.http.HttpResponse;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
@ -19,16 +27,6 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
public class UpdateChecker extends PlexBase
|
public class UpdateChecker extends PlexBase
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
@ -114,28 +112,32 @@ public class UpdateChecker extends PlexBase
|
|||||||
|
|
||||||
switch (distance)
|
switch (distance)
|
||||||
{
|
{
|
||||||
case -1 -> {
|
case -1 ->
|
||||||
|
{
|
||||||
if (verbosity == 2)
|
if (verbosity == 2)
|
||||||
{
|
{
|
||||||
sender.sendMessage(Component.text("There was an error checking for updates.").color(NamedTextColor.RED));
|
sender.sendMessage(Component.text("There was an error checking for updates.").color(NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case 0 -> {
|
case 0 ->
|
||||||
|
{
|
||||||
if (verbosity == 2)
|
if (verbosity == 2)
|
||||||
{
|
{
|
||||||
sender.sendMessage(Component.text("Plex is up to date!").color(NamedTextColor.GREEN));
|
sender.sendMessage(Component.text("Plex is up to date!").color(NamedTextColor.GREEN));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case -2 -> {
|
case -2 ->
|
||||||
|
{
|
||||||
if (verbosity == 2)
|
if (verbosity == 2)
|
||||||
{
|
{
|
||||||
sender.sendMessage(Component.text("Unknown version, unable to check for updates.").color(NamedTextColor.RED));
|
sender.sendMessage(Component.text("Unknown version, unable to check for updates.").color(NamedTextColor.RED));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
default -> {
|
default ->
|
||||||
|
{
|
||||||
if (verbosity >= 1)
|
if (verbosity >= 1)
|
||||||
{
|
{
|
||||||
sender.sendMessage(Component.text("Plex is not up to date!", NamedTextColor.RED));
|
sender.sendMessage(Component.text("Plex is not up to date!", NamedTextColor.RED));
|
||||||
@ -147,11 +149,6 @@ public class UpdateChecker extends PlexBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMini(CommandSender sender, String message)
|
|
||||||
{
|
|
||||||
sender.sendMessage(MiniMessage.miniMessage().deserialize(message));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void updateJar(CommandSender sender)
|
public void updateJar(CommandSender sender)
|
||||||
{
|
{
|
||||||
CloseableHttpClient client = HttpClients.createDefault();
|
CloseableHttpClient client = HttpClients.createDefault();
|
||||||
@ -162,7 +159,7 @@ public class UpdateChecker extends PlexBase
|
|||||||
JSONObject object = new JSONObject(EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8));
|
JSONObject object = new JSONObject(EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8));
|
||||||
JSONObject artifact = object.getJSONArray("artifacts").getJSONObject(0);
|
JSONObject artifact = object.getJSONArray("artifacts").getJSONObject(0);
|
||||||
String name = artifact.getString("fileName");
|
String name = artifact.getString("fileName");
|
||||||
sendMini(sender, "<green>Downloading latest Plex jar file: " + name);
|
sender.sendMessage(PlexUtils.mmDeserialize("<green>Downloading latest Plex jar file: " + name));
|
||||||
CompletableFuture.runAsync(() ->
|
CompletableFuture.runAsync(() ->
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -171,7 +168,7 @@ public class UpdateChecker extends PlexBase
|
|||||||
new URL(DOWNLOAD_PAGE + "job/" + branch + "/lastSuccessfulBuild/artifact/build/libs/" + name),
|
new URL(DOWNLOAD_PAGE + "job/" + branch + "/lastSuccessfulBuild/artifact/build/libs/" + name),
|
||||||
new File(Bukkit.getUpdateFolderFile(), name)
|
new File(Bukkit.getUpdateFolderFile(), name)
|
||||||
);
|
);
|
||||||
sendMini(sender, "<green>Saved new jar. Please restart your server.");
|
sender.sendMessage(PlexUtils.mmDeserialize("<green>Saved new jar. Please restart your server."));
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package dev.plex.util.item;
|
package dev.plex.util.item;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
@ -9,8 +10,6 @@ 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;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
public class ItemBuilder
|
public class ItemBuilder
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -14,8 +14,8 @@
|
|||||||
#
|
#
|
||||||
# So these would be valid:
|
# So these would be valid:
|
||||||
# - "m:e:mail sendall:You cannot send messages to everyone on the server"
|
# - "m:e:mail sendall:You cannot send messages to everyone on the server"
|
||||||
# - "r:e:(.*:):Plugin specific commands are disabled"
|
# - "r:e:^[^ :]+::Plugin specific commands are disabled"
|
||||||
blockedCommands:
|
blockedCommands:
|
||||||
- "r:e:^[^ :]+::Plugin specific commands are disabled."
|
- "r:e:^[^ :]+::<gray>Plugin specific commands are disabled."
|
||||||
- "m:e:mail sendall:You cannot send messages to everyone on the server."
|
- "m:e:mail sendall:<gray>You cannot send messages to everyone on the server."
|
||||||
- "m:e:mail sendtempall:You cannot send messages to everyone on the server."
|
- "m:e:mail sendtempall:<gray>You cannot send messages to everyone on the server."
|
@ -7,6 +7,8 @@ server:
|
|||||||
colorize_motd: true
|
colorize_motd: true
|
||||||
sample:
|
sample:
|
||||||
- "&cForums: https://forum.plex.us.org"
|
- "&cForums: https://forum.plex.us.org"
|
||||||
|
# What timezone should various messages appear in (e.g. ban message end date)
|
||||||
|
timezone: Etc/UTC
|
||||||
|
|
||||||
titles:
|
titles:
|
||||||
masterbuilders: [ ]
|
masterbuilders: [ ]
|
||||||
@ -24,8 +26,8 @@ chat:
|
|||||||
# The maximum amount of characters a player can have for their tag
|
# The maximum amount of characters a player can have for their tag
|
||||||
# This does not include color tags such as <red> or <rainbow>
|
# This does not include color tags such as <red> or <rainbow>
|
||||||
max-tag-length: 64
|
max-tag-length: 64
|
||||||
# Color code for name color
|
# Color tag for name color
|
||||||
name-color: 'f'
|
name-color: '<white>'
|
||||||
|
|
||||||
# Should Plex use a "true op" system with ranks or only permission nodes
|
# Should Plex use a "true op" system with ranks or only permission nodes
|
||||||
# Options are "permissions" or "ranks"
|
# Options are "permissions" or "ranks"
|
||||||
@ -139,13 +141,13 @@ autowipe:
|
|||||||
allowdrops: true
|
allowdrops: true
|
||||||
|
|
||||||
# What blocks should be blocked?
|
# What blocks should be blocked?
|
||||||
blockedBlocks:
|
blocked_blocks:
|
||||||
- "SPAWNER"
|
- "SPAWNER"
|
||||||
- "STRUCTURE_BLOCK"
|
- "STRUCTURE_BLOCK"
|
||||||
- "JIGSAW"
|
- "JIGSAW"
|
||||||
|
|
||||||
# What entities should be blocked?
|
# What entities should be blocked?
|
||||||
blockedEntities:
|
blocked_entities:
|
||||||
- "WITHER"
|
- "WITHER"
|
||||||
- "ENDER_DRAGON"
|
- "ENDER_DRAGON"
|
||||||
- "MINECART_TNT"
|
- "MINECART_TNT"
|
||||||
|
@ -167,5 +167,10 @@ 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!"
|
||||||
allowDropsDisabled: "<gray>No longer allowing drops from players."
|
allowDropsDisabled: "<gray>No longer allowing drops from players."
|
||||||
allowDropsEnabled: "<gray>Now allowing drops from players."
|
allowDropsEnabled: "<gray>Now allowing drops from players."
|
||||||
blockedCommandColor: "<gray>"
|
commandBlocked: "<gray>That command is blocked."
|
||||||
commandBlocked: "That command is blocked."
|
# 0 - The command sender
|
||||||
|
# 1 - The message being said
|
||||||
|
sayMessage: "<blue>[Server: {0}] {1}"
|
||||||
|
# 0 - The command sender
|
||||||
|
# 1 - The message being said
|
||||||
|
consoleSayMessage: "<gray>[Console: {0}] <white>{1}"
|
Reference in New Issue
Block a user