mirror of
https://github.com/plexusorg/Plex.git
synced 2025-07-04 16:56:40 +00:00
Compare commits
49 Commits
Author | SHA1 | Date | |
---|---|---|---|
22199be335 | |||
2e077c40d2 | |||
517b829420 | |||
7fa26f9a64 | |||
09846f1d33 | |||
ed70a0ec8b | |||
16e29b80a7 | |||
829bb88959 | |||
d6b44863aa | |||
f806470fd5 | |||
3611148b4c | |||
262af44193 | |||
a014a38e2f | |||
d896179f47 | |||
9dac0e799e | |||
5c27fb00e7 | |||
679d8bcbc0 | |||
46de6dba84 | |||
d2649508b3 | |||
dd8e22b676 | |||
b26e489e83 | |||
5f64e02cae | |||
4a14f94158 | |||
6763e12d81 | |||
1d0fb85fa1 | |||
665a2f4e72 | |||
9c67911c1b | |||
f1ebbc3664 | |||
4aa3ae7c50 | |||
08e2f31eae | |||
a1c009909d | |||
7d2c44975d | |||
b2faec70a9 | |||
a0cca2aea5 | |||
337334d403 | |||
2e8fe8767e | |||
dbdf720a9e | |||
5a9d6dd60d | |||
84a9535123 | |||
41aff575d0 | |||
65b8188b37 | |||
c8a35c8e0e | |||
13acf7ba9d | |||
5fe48cfd7f | |||
abf2aca0f2 | |||
dc4ac39fe4 | |||
1ae8e779b1 | |||
658f4a4b05 | |||
7ccfb2ad27 |
40
.github/workflows/codeql-analysis.yml
vendored
40
.github/workflows/codeql-analysis.yml
vendored
@ -1,14 +1,3 @@
|
||||
# For most projects, this workflow file will not need changing; you simply need
|
||||
# to commit it to your repository.
|
||||
#
|
||||
# You may wish to alter this file to override the set of languages analyzed,
|
||||
# or to provide custom queries or build logic.
|
||||
#
|
||||
# ******** NOTE ********
|
||||
# We have attempted to detect the languages in your repository. Please check
|
||||
# the `language` matrix defined below to confirm you have the correct set of
|
||||
# supported CodeQL languages.
|
||||
#
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
@ -18,7 +7,7 @@ on:
|
||||
# The branches below must be a subset of the branches above
|
||||
branches: [ master ]
|
||||
schedule:
|
||||
- cron: '29 4 * * *'
|
||||
- cron: '30 4 * * *'
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
@ -33,45 +22,26 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [ 'java' ]
|
||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
|
||||
# Learn more about CodeQL language support at https://git.io/codeql-language-support
|
||||
java: [17]
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v2
|
||||
- name: Set up JDK ${{ matrix.java }}
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
java-version: ${{ matrix.java }}
|
||||
cache: gradle
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v2
|
||||
with:
|
||||
languages: ${{ matrix.language }}
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||
|
||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||
# If this step fails, then you should remove it and run the build manually (see below)
|
||||
- name: Autobuild
|
||||
uses: github/codeql-action/autobuild@v2
|
||||
|
||||
# ℹ️ Command-line programs to run using the OS shell.
|
||||
# 📚 https://git.io/JvXDl
|
||||
|
||||
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||
# and modify them (or add more) to build your code if your project
|
||||
# uses a compiled language
|
||||
|
||||
- run: |
|
||||
chmod +x gradlew
|
||||
./gradlew build --no-daemon
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v2
|
||||
|
32
.github/workflows/gradle.yml
vendored
32
.github/workflows/gradle.yml
vendored
@ -1,18 +1,26 @@
|
||||
name: Gradle
|
||||
|
||||
on: [ push ]
|
||||
# Adapted from Paper's build script
|
||||
name: Build
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
# Only run on PRs if the source branch is on someone else's repo
|
||||
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
java: [17]
|
||||
fail-fast: true
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: JDK ${{ matrix.java }}
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: temurin
|
||||
java-version: 17
|
||||
cache: gradle
|
||||
- name: Build with Gradle
|
||||
run: chmod a+x gradlew && ./gradlew build --no-daemon
|
||||
java-version: ${{ matrix.java }}
|
||||
cache: 'gradle'
|
||||
distribution: 'temurin'
|
||||
- name: Build
|
||||
run: |
|
||||
git config --global user.email "no-reply@github.com"
|
||||
git config --global user.name "Github Actions"
|
||||
./gradlew build --stacktrace
|
||||
|
3
.gitignore
vendored
3
.gitignore
vendored
@ -15,3 +15,6 @@ Thumbs.db
|
||||
/build/
|
||||
/*/build/
|
||||
/.gradle/
|
||||
|
||||
# Common working directory
|
||||
run/
|
@ -1,5 +1,5 @@
|
||||
For those who are wanting to contribute, we fully encourage doing so. There are a few rules we require following when
|
||||
contributing however.
|
||||
contributing.
|
||||
|
||||
## Steps
|
||||
|
||||
@ -17,7 +17,8 @@ contributing however.
|
||||
- Keep in mind that it **must** be formatted correctly. If you are using IntelliJ, there is a `codeStyle.xml` file that
|
||||
tells IntelliJ how to format your code. Check this link for information on how to use the
|
||||
file: https://www.jetbrains.com/help/idea/configuring-code-style.html#import-export-schemes
|
||||
- If you are not using IntelliJ, that is fine. We use Allman style so please format your code accordingly.
|
||||
- If you are not using IntelliJ, that is fine. We use the Plexus Code Style (which is almost the same as Allman) so
|
||||
please format your code accordingly.
|
||||
|
||||
6. Push your changes to your new branch and make a PR based off of that branch.
|
||||
|
||||
|
2
Jenkinsfile
vendored
2
Jenkinsfile
vendored
@ -24,7 +24,7 @@ pipeline {
|
||||
post {
|
||||
always {
|
||||
archiveArtifacts artifacts: "build/libs/*.jar", fingerprint: true
|
||||
javadoc javadocDir: "api/build/docs/javadoc", keepAll: false
|
||||
javadoc javadocDir: "server/build/docs/javadoc", keepAll: false
|
||||
discordSend description: "**Build:** ${env.BUILD_NUMBER}\n**Status:** ${currentBuild.currentResult}", enableArtifactsList: true, footer: "Built with Jenkins", link: env.BUILD_URL, result: currentBuild.currentResult, scmWebUrl: "https://github.com/plexusorg/Plex", showChangeset: true, title: env.JOB_NAME, webhookURL: env.WEBHOOK_URL
|
||||
cleanWs()
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Plex [](https://ci.plex.us.org/job/Plex/job/master/)
|
||||
# Plex [](https://ci.plex.us.org/job/Plex/job/master/) 
|
||||
|
||||
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
|
||||
|
@ -1,32 +0,0 @@
|
||||
group = rootProject.group
|
||||
version = rootProject.version
|
||||
description = "Plex-API"
|
||||
|
||||
jar {
|
||||
archiveBaseName.set("Plex-API")
|
||||
}
|
||||
|
||||
tasks {
|
||||
jar {
|
||||
finalizedBy(rootProject.tasks.copyJars)
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
enabled = false
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
from components.java
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "org.projectlombok:lombok:1.18.24"
|
||||
annotationProcessor "org.projectlombok:lombok:1.18.24"
|
||||
compileOnly "io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT"
|
||||
compileOnly "org.json:json:20220320"
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
package dev.plex.api;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface IPlayerCache<T>
|
||||
{
|
||||
Map<UUID, T> getPlexPlayerMap();
|
||||
|
||||
T getPlexPlayer(UUID uuid);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package dev.plex.api;
|
||||
|
||||
public interface PlexApi
|
||||
{
|
||||
IPlayerCache<?> getPlayerCache();
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
package dev.plex.api;
|
||||
|
||||
public interface PlexApiProvider
|
||||
{
|
||||
PlexApi getApi();
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
package dev.plex.api.chat;
|
||||
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
|
||||
public interface IChatHandler
|
||||
{
|
||||
void doChat(AsyncChatEvent event);
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
package dev.plex.api.permission;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface IPermissionHandler
|
||||
{
|
||||
default boolean hasPermission(@NotNull Player player, @Nullable String permission)
|
||||
{
|
||||
if (permission == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return player.hasPermission(permission);
|
||||
}
|
||||
|
||||
default boolean hasPermission(@NotNull OfflinePlayer player, @Nullable String permission)
|
||||
{
|
||||
if (permission == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (player.isOnline() && Bukkit.getPlayer(player.getUniqueId()) != null)
|
||||
{
|
||||
return Bukkit.getPlayer(player.getUniqueId()).hasPermission(permission);
|
||||
}
|
||||
throw new UnsupportedOperationException("Not implemented yet");
|
||||
}
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
package dev.plex.api.player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
|
||||
public interface IPlexPlayer
|
||||
{
|
||||
String getId();
|
||||
|
||||
UUID getUuid();
|
||||
|
||||
String getName();
|
||||
|
||||
Player getPlayer();
|
||||
|
||||
void setPlayer(Player player);
|
||||
|
||||
String getLoginMessage();
|
||||
|
||||
void setLoginMessage(String message);
|
||||
|
||||
String getPrefix();
|
||||
|
||||
void setPrefix(String prefix);
|
||||
|
||||
boolean isVanished();
|
||||
|
||||
void setVanished(boolean vanished);
|
||||
|
||||
boolean isCommandSpy();
|
||||
|
||||
void setCommandSpy(boolean commandSpy);
|
||||
|
||||
boolean isFrozen();
|
||||
|
||||
void setFrozen(boolean frozen);
|
||||
|
||||
boolean isMuted();
|
||||
|
||||
void setMuted(boolean muted);
|
||||
|
||||
boolean isLockedUp();
|
||||
|
||||
void setLockedUp(boolean lockedUp);
|
||||
|
||||
boolean isAdminActive();
|
||||
|
||||
void setAdminActive(boolean active);
|
||||
|
||||
long getCoins();
|
||||
|
||||
void setCoins(long coins);
|
||||
|
||||
String getRank();
|
||||
|
||||
void setRank(String rank);
|
||||
|
||||
List<String> getIps();
|
||||
|
||||
void setIps(List<String> ips);
|
||||
|
||||
PermissionAttachment getPermissionAttachment();
|
||||
|
||||
void setPermissionAttachment(PermissionAttachment attachment);
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
package dev.plex.api.plugin;
|
||||
|
||||
import dev.plex.api.chat.IChatHandler;
|
||||
import dev.plex.api.permission.IPermissionHandler;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public abstract class PlexPlugin extends JavaPlugin
|
||||
{
|
||||
@Setter(AccessLevel.NONE)
|
||||
private static PlexPlugin plugin;
|
||||
|
||||
private IChatHandler chatHandler;
|
||||
private IPermissionHandler permissionHandler;
|
||||
|
||||
@Override
|
||||
public void onLoad()
|
||||
{
|
||||
plugin = this;
|
||||
}
|
||||
|
||||
public static PlexPlugin get()
|
||||
{
|
||||
return plugin;
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
package dev.plex.api.rank;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public interface IRank<T>
|
||||
{
|
||||
int getLevel();
|
||||
|
||||
String getLoginMessage();
|
||||
|
||||
void setLoginMessage(String message);
|
||||
|
||||
String getReadable();
|
||||
|
||||
Component getPrefix();
|
||||
|
||||
void setPrefix(String prefix);
|
||||
|
||||
NamedTextColor getColor();
|
||||
|
||||
boolean isAtLeast(T rank);
|
||||
|
||||
JSONObject toJSON();
|
||||
}
|
@ -5,7 +5,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "dev.plex"
|
||||
version = "1.1"
|
||||
version = "1.2"
|
||||
description = "Plex"
|
||||
|
||||
subprojects {
|
||||
@ -60,7 +60,6 @@ subprojects {
|
||||
}
|
||||
|
||||
clean {
|
||||
dependsOn(":api:clean")
|
||||
dependsOn(":server:clean")
|
||||
dependsOn(":proxy:clean")
|
||||
}
|
||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions-snapshots/gradle-7.6-20220825090952+0000-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id("net.kyori.blossom") version "1.2.0"
|
||||
id("net.kyori.blossom") version "1.3.0"
|
||||
}
|
||||
|
||||
group = rootProject.group
|
||||
@ -42,5 +42,4 @@ dependencies {
|
||||
compileOnly("org.json:json:20220320")
|
||||
compileOnly("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
|
||||
annotationProcessor("com.velocitypowered:velocity-api:3.1.2-SNAPSHOT")
|
||||
implementation(project(":api"))
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
plugins {
|
||||
id "net.minecrell.plugin-yml.bukkit" version "0.6.1-SNAPSHOT"
|
||||
id "net.minecrell.plugin-yml.bukkit" version "0.5.2"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@ -7,28 +7,27 @@ dependencies {
|
||||
annotationProcessor "org.projectlombok:lombok:1.18.24"
|
||||
library "org.json:json:20220320"
|
||||
library "commons-io:commons-io:2.11.0"
|
||||
library "dev.morphia.morphia:morphia-core:2.2.6"
|
||||
library "redis.clients:jedis:4.2.2"
|
||||
library "org.mariadb.jdbc:mariadb-java-client:3.0.4"
|
||||
library "dev.morphia.morphia:morphia-core:2.2.7"
|
||||
library "redis.clients:jedis:4.2.3"
|
||||
library "org.mariadb.jdbc:mariadb-java-client:3.0.6"
|
||||
library "com.zaxxer:HikariCP:5.0.1"
|
||||
library "org.apache.httpcomponents:httpclient:4.5.13"
|
||||
library "org.apache.httpcomponents.client5:httpclient5:5.2-beta1"
|
||||
library "org.apache.commons:commons-lang3:3.12.0"
|
||||
library "org.apache.maven.resolver:maven-resolver-api:1.8.0"
|
||||
library "org.apache.maven.resolver:maven-resolver-impl:1.8.0"
|
||||
library "org.apache.maven.resolver:maven-resolver-connector-basic:1.8.0"
|
||||
library "org.apache.maven.resolver:maven-resolver-transport-http:1.8.0"
|
||||
library "org.apache.maven.resolver:maven-resolver-api:1.8.2"
|
||||
library "org.apache.maven.resolver:maven-resolver-impl:1.8.2"
|
||||
library "org.apache.maven.resolver:maven-resolver-connector-basic:1.8.2"
|
||||
library "org.apache.maven.resolver:maven-resolver-transport-http:1.8.2"
|
||||
library "org.apache.maven:maven-resolver-provider:3.8.5"
|
||||
library "org.eclipse.jetty:jetty-server:11.0.9"
|
||||
library "org.eclipse.jetty:jetty-servlet:11.0.9"
|
||||
library "org.eclipse.jetty:jetty-proxy:11.0.9"
|
||||
library "org.eclipse.jetty:jetty-server:11.0.11"
|
||||
library "org.eclipse.jetty:jetty-servlet:11.0.11"
|
||||
library "org.eclipse.jetty:jetty-proxy:11.0.11"
|
||||
library "com.google.code.gson:gson:2.9.0"
|
||||
compileOnly "io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT"
|
||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7") {
|
||||
compileOnly "io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT"
|
||||
compileOnly("com.github.MilkBowl:VaultAPI:1.7.1") {
|
||||
exclude group: "org.bukkit", module: "bukkit"
|
||||
}
|
||||
implementation "org.bstats:bstats-base:3.0.0"
|
||||
implementation "org.bstats:bstats-bukkit:3.0.0"
|
||||
implementation project(":api")
|
||||
}
|
||||
|
||||
group = rootProject.group
|
||||
|
@ -2,19 +2,12 @@ package dev.plex;
|
||||
|
||||
import dev.plex.admin.Admin;
|
||||
import dev.plex.admin.AdminList;
|
||||
import dev.plex.api.PlexApi;
|
||||
import dev.plex.api.PlexApiProvider;
|
||||
import dev.plex.api.plugin.PlexPlugin;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.cache.PlayerCache;
|
||||
import dev.plex.config.Config;
|
||||
import dev.plex.handlers.CommandHandler;
|
||||
import dev.plex.handlers.ListenerHandler;
|
||||
import dev.plex.hook.VaultHook;
|
||||
import dev.plex.listener.impl.ChatListener;
|
||||
import dev.plex.module.ModuleManager;
|
||||
import dev.plex.permission.handler.NativePermissionHandler;
|
||||
import dev.plex.permission.handler.VaultPermissionHandler;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.punishment.PunishmentManager;
|
||||
import dev.plex.rank.RankManager;
|
||||
@ -33,33 +26,31 @@ import dev.plex.util.BungeeUtil;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.UpdateChecker;
|
||||
import dev.plex.util.redis.MessageUtil;
|
||||
import dev.plex.world.CustomWorld;
|
||||
import java.io.File;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bson.conversions.Bson;
|
||||
import net.milkbowl.vault.chat.Chat;
|
||||
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
|
||||
@Setter
|
||||
public class Plex extends PlexPlugin implements PlexApiProvider
|
||||
public class Plex extends JavaPlugin
|
||||
{
|
||||
public static final BuildInfo build = new BuildInfo();
|
||||
private static Plex plugin;
|
||||
|
||||
public Config config;
|
||||
public Config messages;
|
||||
public Config indefBans;
|
||||
public Config commands;
|
||||
public Config toggles;
|
||||
|
||||
private PlexProvider provider;
|
||||
|
||||
public File modulesFolder;
|
||||
private StorageType storageType = StorageType.SQLITE;
|
||||
|
||||
public static final BuildInfo build = new BuildInfo();
|
||||
|
||||
private SQLConnection sqlConnection;
|
||||
private MongoConnection mongoConnection;
|
||||
private RedisConnection redisConnection;
|
||||
@ -82,6 +73,9 @@ public class Plex extends PlexPlugin implements PlexApiProvider
|
||||
private UpdateChecker updateChecker;
|
||||
private String system;
|
||||
|
||||
private Permission permissions;
|
||||
private Chat chat;
|
||||
|
||||
|
||||
public static Plex get()
|
||||
{
|
||||
@ -110,8 +104,7 @@ public class Plex extends PlexPlugin implements PlexApiProvider
|
||||
moduleManager.loadAllModules();
|
||||
moduleManager.loadModules();
|
||||
|
||||
this.setChatHandler(new ChatListener.ChatHandlerImpl());
|
||||
|
||||
//this.setChatHandler(new ChatListener.ChatHandlerImpl());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -145,21 +138,15 @@ public class Plex extends PlexPlugin implements PlexApiProvider
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
boolean permissions = false;
|
||||
if (getServer().getPluginManager().isPluginEnabled("Vault"))
|
||||
if (system.equals("permissions"))
|
||||
{
|
||||
VaultPermissionHandler handler = new VaultPermissionHandler();
|
||||
if (VaultHook.getPermission() != null)
|
||||
if (!getServer().getPluginManager().isPluginEnabled("Vault"))
|
||||
{
|
||||
this.setPermissionHandler(handler);
|
||||
permissions = true;
|
||||
PlexLog.debug("Enabling Vault support for permissions with a permission plugin: " + VaultHook.getPermission().getName());
|
||||
}
|
||||
throw new RuntimeException("Vault is required to run on the server if you use permissions!");
|
||||
}
|
||||
|
||||
if (!permissions)
|
||||
{
|
||||
this.setPermissionHandler(new NativePermissionHandler());
|
||||
permissions = setupPermissions();
|
||||
chat = setupChat();
|
||||
}
|
||||
|
||||
updateChecker = new UpdateChecker();
|
||||
@ -173,6 +160,8 @@ public class Plex extends PlexPlugin implements PlexApiProvider
|
||||
{
|
||||
redisConnection.getJedis();
|
||||
PlexLog.log("Connected to Redis!");
|
||||
MessageUtil.subscribe();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -221,8 +210,6 @@ public class Plex extends PlexPlugin implements PlexApiProvider
|
||||
}
|
||||
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||
|
||||
|
||||
provider = new PlexProvider();
|
||||
moduleManager.enableModules();
|
||||
}
|
||||
|
||||
@ -284,9 +271,17 @@ public class Plex extends PlexPlugin implements PlexApiProvider
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlexApi getApi()
|
||||
private Permission setupPermissions()
|
||||
{
|
||||
return provider;
|
||||
RegisteredServiceProvider<Permission> rsp = Bukkit.getServicesManager().getRegistration(Permission.class);
|
||||
permissions = rsp.getProvider();
|
||||
return permissions;
|
||||
}
|
||||
|
||||
private Chat setupChat()
|
||||
{
|
||||
RegisteredServiceProvider<Chat> rsp = Bukkit.getServicesManager().getRegistration(Chat.class);
|
||||
chat = rsp.getProvider();
|
||||
return chat;
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +0,0 @@
|
||||
package dev.plex;
|
||||
|
||||
import dev.plex.api.IPlayerCache;
|
||||
import dev.plex.api.PlexApi;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
|
||||
public class PlexProvider implements PlexApi
|
||||
{
|
||||
@Override
|
||||
public IPlayerCache<PlexPlayer> getPlayerCache()
|
||||
{
|
||||
return Plex.get().getPlayerCache();
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package dev.plex.cache;
|
||||
|
||||
import com.google.common.collect.Maps;
|
||||
import dev.plex.api.IPlayerCache;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -10,7 +9,7 @@ import java.util.UUID;
|
||||
* Cache storage
|
||||
*/
|
||||
|
||||
public class PlayerCache implements IPlayerCache<PlexPlayer>
|
||||
public class PlayerCache
|
||||
{
|
||||
/**
|
||||
* A key/value pair where the key is the unique ID of the Plex Player
|
||||
|
@ -132,6 +132,11 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
{
|
||||
PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayerMap().get(player.getUniqueId());
|
||||
|
||||
if (plexPlayer == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||
{
|
||||
if (!plexPlayer.getRankFromString().isAtLeast(getLevel()))
|
||||
@ -150,7 +155,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
}
|
||||
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
if (!perms.permission().isEmpty() && !plugin.getPermissionHandler().hasPermission(player, perms.permission()))
|
||||
if (!perms.permission().isEmpty() && !player.hasPermission(perms.permission()))
|
||||
{
|
||||
send(sender, messageComponent("noPermissionNode", perms.permission()));
|
||||
return true;
|
||||
@ -186,7 +191,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
}
|
||||
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
if (!perms.permission().isEmpty() && !plugin.getPermissionHandler().hasPermission(Bukkit.getOfflinePlayer(plexPlayer.getName()), perms.permission()))
|
||||
if (!perms.permission().isEmpty() && !plugin.getPermissions().playerHas(null, Bukkit.getPlayer(plexPlayer.getName()), perms.permission()))
|
||||
{
|
||||
send(sender, messageComponent("noPermissionNode", perms.permission()));
|
||||
return true;
|
||||
@ -201,7 +206,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
}
|
||||
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)
|
||||
{
|
||||
send(sender, component);
|
||||
@ -287,7 +292,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
{
|
||||
if (!isConsole(sender))
|
||||
{
|
||||
return checkRank((Player) sender, rank, permission);
|
||||
return checkRank((Player)sender, rank, permission);
|
||||
}
|
||||
if (!sender.getName().equalsIgnoreCase("console"))
|
||||
{
|
||||
@ -305,7 +310,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
}
|
||||
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
if (!perms.permission().isEmpty() && !plugin.getPermissionHandler().hasPermission(Bukkit.getOfflinePlayer(plexPlayer.getName()), perms.permission()))
|
||||
if (!perms.permission().isEmpty() && !plugin.getPermissions().playerHas(null, Bukkit.getOfflinePlayer(plexPlayer.getName()), perms.permission()))
|
||||
{
|
||||
throw new CommandFailException(PlexUtils.messageString("noPermissionNode", permission));
|
||||
}
|
||||
@ -343,7 +348,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
}
|
||||
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
if (!perms.permission().isEmpty() && !plugin.getPermissionHandler().hasPermission(player, permission))
|
||||
if (!perms.permission().isEmpty() && !player.hasPermission(perms.permission()))
|
||||
{
|
||||
throw new CommandFailException(PlexUtils.messageString("noPermissionNode", permission));
|
||||
}
|
||||
@ -364,7 +369,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
}
|
||||
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
return !perms.permission().isEmpty() && plugin.getPermissionHandler().hasPermission(player, permission);
|
||||
return !perms.permission().isEmpty() && player.hasPermission(permission);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -382,7 +387,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
{
|
||||
if (!isConsole(sender))
|
||||
{
|
||||
return checkTab((Player) sender, rank, permission);
|
||||
return checkTab((Player)sender, rank, permission);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -405,7 +410,7 @@ public abstract class PlexCommand extends Command implements PluginIdentifiableC
|
||||
}
|
||||
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
return !perms.permission().isEmpty() && plugin.getPermissionHandler().hasPermission(player, permission);
|
||||
return !perms.permission().isEmpty() && player.hasPermission(permission);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,9 +1,6 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.api.event.AdminAddEvent;
|
||||
import dev.plex.api.event.AdminRemoveEvent;
|
||||
import dev.plex.api.event.AdminSetRankEvent;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
@ -12,13 +9,16 @@ import dev.plex.command.annotation.System;
|
||||
import dev.plex.command.exception.ConsoleOnlyException;
|
||||
import dev.plex.command.exception.PlayerNotFoundException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.event.AdminAddEvent;
|
||||
import dev.plex.event.AdminRemoveEvent;
|
||||
import dev.plex.event.AdminSetRankEvent;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
@ -7,9 +8,12 @@ import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
import dev.plex.util.redis.MessageUtil;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -24,33 +28,17 @@ public class AdminChatCMD extends PlexCommand
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
if (playerSender != null) {
|
||||
PlexPlayer player = DataUtils.getPlayer(playerSender.getUniqueId());
|
||||
player.setStaffChat(!player.isStaffChat());
|
||||
return messageComponent("adminChatToggled", BooleanUtils.toStringOnOff(player.isStaffChat()));
|
||||
}
|
||||
return usage();
|
||||
}
|
||||
|
||||
adminChat(sender, StringUtils.join(args, " "));
|
||||
String message = StringUtils.join(args, " ");
|
||||
plugin.getServer().getConsoleSender().sendMessage(messageComponent("adminChatFormat", sender.getName(), message));
|
||||
MessageUtil.sendStaffChat(sender, SafeMiniMessage.mmDeserialize(message), PlexUtils.adminChat(sender.getName(), message).toArray(UUID[]::new));
|
||||
return null;
|
||||
}
|
||||
|
||||
private void adminChat(CommandSender sender, String message)
|
||||
{
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||
{
|
||||
PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayerMap().get(player.getUniqueId());
|
||||
if (plexPlayer.getRankFromString().isAtLeast(Rank.ADMIN) && plexPlayer.isAdminActive())
|
||||
{
|
||||
player.sendMessage(PlexUtils.messageComponent("adminChatFormat", sender.getName(), message));
|
||||
}
|
||||
}
|
||||
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
if (plugin.getPermissionHandler().hasPermission(player, "plex.adminchat"))
|
||||
{
|
||||
player.sendMessage(PlexUtils.messageComponent("adminChatFormat", sender.getName(), message));
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin.getServer().getConsoleSender().sendMessage(PlexUtils.messageComponent("adminChatFormat", sender.getName(), message));
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,12 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.api.event.GameModeUpdateEvent;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.exception.CommandFailException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.event.GameModeUpdateEvent;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
|
@ -22,7 +22,7 @@ import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -7,7 +7,7 @@ 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.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -1,12 +1,12 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.api.event.GameModeUpdateEvent;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.exception.CommandFailException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.event.GameModeUpdateEvent;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
|
@ -1,11 +1,11 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import dev.plex.api.event.GameModeUpdateEvent;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.exception.CommandFailException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.event.GameModeUpdateEvent;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.Arrays;
|
||||
|
@ -18,7 +18,7 @@ import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "localspawn", description = "Teleport to the spawnpoint of the world you are in")
|
||||
@CommandPermissions(level = Rank.OP, permission = "plex.spawnpoint", source = RequiredCommandSource.IN_GAME)
|
||||
@CommandPermissions(level = Rank.OP, permission = "plex.localspawn", source = RequiredCommandSource.IN_GAME)
|
||||
public class LocalSpawnCMD extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
|
@ -16,7 +16,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -7,7 +7,7 @@ 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.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -7,7 +7,7 @@ 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.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
@ -17,8 +17,8 @@ import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.title.Title;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
@ -1,12 +1,12 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.api.event.GameModeUpdateEvent;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.exception.CommandFailException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.event.GameModeUpdateEvent;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
|
@ -1,12 +1,12 @@
|
||||
package dev.plex.command.impl;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import dev.plex.api.event.GameModeUpdateEvent;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.exception.CommandFailException;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.event.GameModeUpdateEvent;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import java.util.List;
|
||||
|
@ -7,11 +7,12 @@ import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.command.source.RequiredCommandSource;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -46,7 +47,7 @@ public class TagCMD extends PlexCommand
|
||||
{
|
||||
return usage("/tag set <prefix>");
|
||||
}
|
||||
String prefix = StringUtils.join(args, " ", 1, args.length);
|
||||
String prefix = PlexUtils.cleanString(StringUtils.join(args, " ", 1, args.length));
|
||||
|
||||
Component convertedComponent = SafeMiniMessage.mmDeserializeWithoutEvents(prefix);
|
||||
|
||||
|
@ -18,7 +18,7 @@ import dev.plex.util.WebUtils;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -31,6 +31,7 @@ public class ToggleCMD extends PlexCommand
|
||||
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Explosions" + status("explosions")));
|
||||
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Fluidspread" + status("fluidspread")));
|
||||
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Drops" + status("drops")));
|
||||
sender.sendMessage(PlexUtils.mmDeserialize("<gray> - Redstone" + status("redstone")));
|
||||
return null;
|
||||
}
|
||||
switch (args[0].toLowerCase())
|
||||
@ -47,6 +48,10 @@ public class ToggleCMD extends PlexCommand
|
||||
{
|
||||
return toggle("drops");
|
||||
}
|
||||
case "redstone" ->
|
||||
{
|
||||
return toggle("redstone");
|
||||
}
|
||||
default ->
|
||||
{
|
||||
return messageComponent("invalidToggle");
|
||||
|
@ -1,6 +1,6 @@
|
||||
package dev.plex.api.event;
|
||||
package dev.plex.event;
|
||||
|
||||
import dev.plex.api.player.IPlexPlayer;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -24,7 +24,7 @@ public class AdminAddEvent extends Event
|
||||
/**
|
||||
* The PlexPlayer that was added
|
||||
*/
|
||||
private final IPlexPlayer plexPlayer;
|
||||
private final PlexPlayer plexPlayer;
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
package dev.plex.api.event;
|
||||
package dev.plex.event;
|
||||
|
||||
import dev.plex.api.player.IPlexPlayer;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -24,7 +24,7 @@ public class AdminRemoveEvent extends Event
|
||||
/**
|
||||
* The PlexPlayer that was removed
|
||||
*/
|
||||
private final IPlexPlayer plexPlayer;
|
||||
private final PlexPlayer plexPlayer;
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
@ -1,7 +1,7 @@
|
||||
package dev.plex.api.event;
|
||||
package dev.plex.event;
|
||||
|
||||
import dev.plex.api.player.IPlexPlayer;
|
||||
import dev.plex.api.rank.IRank;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -25,12 +25,12 @@ public class AdminSetRankEvent extends Event
|
||||
/**
|
||||
* The PlexPlayer that was removed
|
||||
*/
|
||||
private final IPlexPlayer plexPlayer;
|
||||
private final PlexPlayer plexPlayer;
|
||||
|
||||
/**
|
||||
* The rank the player was set to
|
||||
*/
|
||||
private final IRank rank;
|
||||
private final Rank rank;
|
||||
|
||||
public static HandlerList getHandlerList()
|
||||
{
|
@ -1,4 +1,4 @@
|
||||
package dev.plex.api.event;
|
||||
package dev.plex.event;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
@ -1,6 +1,6 @@
|
||||
package dev.plex.api.event;
|
||||
package dev.plex.event;
|
||||
|
||||
import dev.plex.api.player.IPlexPlayer;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -16,7 +16,7 @@ public abstract class PunishedPlayerEvent extends PlayerEvent implements Cancell
|
||||
/**
|
||||
* The player who was punished
|
||||
*/
|
||||
protected IPlexPlayer punishedPlayer;
|
||||
protected PlexPlayer punishedPlayer;
|
||||
|
||||
/**
|
||||
* Whether the event was cancelled
|
||||
@ -28,9 +28,9 @@ public abstract class PunishedPlayerEvent extends PlayerEvent implements Cancell
|
||||
* Creates an event object
|
||||
*
|
||||
* @param punishedPlayer The player who was punished
|
||||
* @see IPlexPlayer
|
||||
* @see PlexPlayer
|
||||
*/
|
||||
protected PunishedPlayerEvent(IPlexPlayer punishedPlayer)
|
||||
protected PunishedPlayerEvent(PlexPlayer punishedPlayer)
|
||||
{
|
||||
super(Bukkit.getPlayer(punishedPlayer.getUuid()));
|
||||
this.punishedPlayer = punishedPlayer;
|
@ -1,6 +1,6 @@
|
||||
package dev.plex.api.event;
|
||||
package dev.plex.event;
|
||||
|
||||
import dev.plex.api.player.IPlexPlayer;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@ -24,7 +24,7 @@ public class PunishedPlayerFreezeEvent extends PunishedPlayerEvent implements Ca
|
||||
* @param punishedPlayer The player who was punished
|
||||
* @param frozen The new frozen status
|
||||
*/
|
||||
public PunishedPlayerFreezeEvent(IPlexPlayer punishedPlayer, boolean frozen)
|
||||
public PunishedPlayerFreezeEvent(PlexPlayer punishedPlayer, boolean frozen)
|
||||
{
|
||||
super(punishedPlayer);
|
||||
this.frozen = frozen;
|
@ -1,6 +1,6 @@
|
||||
package dev.plex.api.event;
|
||||
package dev.plex.event;
|
||||
|
||||
import dev.plex.api.player.IPlexPlayer;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@ -24,7 +24,7 @@ public class PunishedPlayerLockupEvent extends PunishedPlayerEvent implements Ca
|
||||
* @param punishedPlayer The player who was punished
|
||||
* @param lockedUp The new muted status
|
||||
*/
|
||||
public PunishedPlayerLockupEvent(IPlexPlayer punishedPlayer, boolean lockedUp)
|
||||
public PunishedPlayerLockupEvent(PlexPlayer punishedPlayer, boolean lockedUp)
|
||||
{
|
||||
super(punishedPlayer);
|
||||
this.lockedUp = lockedUp;
|
@ -1,6 +1,6 @@
|
||||
package dev.plex.api.event;
|
||||
package dev.plex.event;
|
||||
|
||||
import dev.plex.api.player.IPlexPlayer;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.event.Cancellable;
|
||||
import org.bukkit.event.HandlerList;
|
||||
@ -24,7 +24,7 @@ public class PunishedPlayerMuteEvent extends PunishedPlayerEvent implements Canc
|
||||
* @param punishedPlayer The player who was punished
|
||||
* @param muted The new muted status
|
||||
*/
|
||||
public PunishedPlayerMuteEvent(IPlexPlayer punishedPlayer, boolean muted)
|
||||
public PunishedPlayerMuteEvent(PlexPlayer punishedPlayer, boolean muted)
|
||||
{
|
||||
super(punishedPlayer);
|
||||
this.muted = muted;
|
@ -1,9 +1,9 @@
|
||||
package dev.plex.listener.impl;
|
||||
|
||||
import dev.plex.api.event.AdminAddEvent;
|
||||
import dev.plex.api.event.AdminRemoveEvent;
|
||||
import dev.plex.api.event.AdminSetRankEvent;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.event.AdminAddEvent;
|
||||
import dev.plex.event.AdminRemoveEvent;
|
||||
import dev.plex.event.AdminSetRankEvent;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
@ -17,7 +17,7 @@ public class AdminListener extends PlexListener
|
||||
public void onAdminAdd(AdminAddEvent event)
|
||||
{
|
||||
String userSender = event.getSender().getName();
|
||||
PlexPlayer target = (PlexPlayer) event.getPlexPlayer();
|
||||
PlexPlayer target = (PlexPlayer)event.getPlexPlayer();
|
||||
if (target.getRankFromString().isAtLeast(Rank.ADMIN))
|
||||
{
|
||||
PlexUtils.broadcast(messageComponent("adminReadded", userSender, target.getName(), target.getRankFromString().getReadable()));
|
||||
@ -35,7 +35,7 @@ public class AdminListener extends PlexListener
|
||||
public void onAdminRemove(AdminRemoveEvent event)
|
||||
{
|
||||
String userSender = event.getSender().getName();
|
||||
PlexPlayer target = (PlexPlayer) event.getPlexPlayer();
|
||||
PlexPlayer target = (PlexPlayer)event.getPlexPlayer();
|
||||
target.setAdminActive(false);
|
||||
DataUtils.update(target);
|
||||
PlexUtils.broadcast(messageComponent("adminRemoved", userSender, target.getName()));
|
||||
@ -45,8 +45,8 @@ public class AdminListener extends PlexListener
|
||||
public void onAdminSetRank(AdminSetRankEvent event)
|
||||
{
|
||||
String userSender = event.getSender().getName();
|
||||
PlexPlayer target = (PlexPlayer) event.getPlexPlayer();
|
||||
Rank newRank = (Rank) event.getRank();
|
||||
PlexPlayer target = (PlexPlayer)event.getPlexPlayer();
|
||||
Rank newRank = (Rank)event.getRank();
|
||||
target.setRank(newRank.name().toLowerCase());
|
||||
DataUtils.update(target);
|
||||
PlexUtils.broadcast(messageComponent("adminSetRank", userSender, target.getName(), newRank.getReadable()));
|
||||
|
@ -16,13 +16,10 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
||||
public class BlockListener extends PlexListener
|
||||
{
|
||||
public List<String> blockedPlayers = new ArrayList<>();
|
||||
|
||||
private static final List<Material> blockedBlocks = new ArrayList<>();
|
||||
|
||||
private static List<String> cachedBlockedBlocksConfig = null;
|
||||
|
||||
private static final List<Material> SIGNS = Arrays.stream(Material.values()).filter((mat) -> mat.name().endsWith("_SIGN")).toList();
|
||||
private static List<String> cachedBlockedBlocksConfig = null;
|
||||
public List<String> blockedPlayers = new ArrayList<>();
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
@ -38,9 +35,8 @@ public class BlockListener extends PlexListener
|
||||
{
|
||||
blockedBlocks.add(Material.valueOf(block.toUpperCase()));
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
catch (IllegalArgumentException ignored)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -61,7 +57,7 @@ public class BlockListener extends PlexListener
|
||||
|
||||
if (SIGNS.contains(block.getType()))
|
||||
{
|
||||
Sign sign = (Sign) block.getState();
|
||||
Sign sign = (Sign)block.getState();
|
||||
boolean anythingChanged = false;
|
||||
for (int i = 0; i < sign.lines().size(); i++)
|
||||
{
|
||||
|
@ -24,6 +24,6 @@ public class BookListener extends PlexListener
|
||||
}
|
||||
|
||||
|
||||
event.setNewBookMeta((BookMeta) event.getNewBookMeta().pages(pages));
|
||||
event.setNewBookMeta((BookMeta)event.getNewBookMeta().pages(pages));
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,20 @@
|
||||
package dev.plex.listener.impl;
|
||||
|
||||
import dev.plex.api.chat.IChatHandler;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.listener.annotation.Toggleable;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
import dev.plex.util.redis.MessageUtil;
|
||||
import io.papermc.paper.chat.ChatRenderer;
|
||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextReplacementConfig;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
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 org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -24,7 +22,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
@Toggleable("chat.enabled")
|
||||
public class ChatListener extends PlexListener
|
||||
{
|
||||
private final static TextReplacementConfig URL_REPLACEMENT_CONFIG = TextReplacementConfig
|
||||
|
||||
public static final TextReplacementConfig URL_REPLACEMENT_CONFIG = TextReplacementConfig
|
||||
.builder()
|
||||
.match("(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]")
|
||||
.replacement((matchResult, builder) -> Component.empty()
|
||||
@ -32,21 +31,18 @@ public class ChatListener extends PlexListener
|
||||
.clickEvent(ClickEvent.openUrl(
|
||||
matchResult.group()
|
||||
))).build();
|
||||
private final PlexChatRenderer renderer = new PlexChatRenderer();
|
||||
|
||||
@EventHandler
|
||||
public void onChat(AsyncChatEvent event)
|
||||
{
|
||||
plugin.getChatHandler().doChat(event);
|
||||
}
|
||||
|
||||
public static class ChatHandlerImpl implements IChatHandler
|
||||
{
|
||||
private final PlexChatRenderer renderer = new PlexChatRenderer();
|
||||
|
||||
@Override
|
||||
public void doChat(AsyncChatEvent event)
|
||||
{
|
||||
PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayerMap().get(event.getPlayer().getUniqueId());
|
||||
if (plexPlayer.isStaffChat()) {
|
||||
MessageUtil.sendStaffChat(event.getPlayer(), event.message(), PlexUtils.adminChat(event.getPlayer().getName(), SafeMiniMessage.mmSerialize(event.message())).toArray(UUID[]::new));
|
||||
plugin.getServer().getConsoleSender().sendMessage(PlexUtils.messageComponent("adminChatFormat", event.getPlayer().getName(), SafeMiniMessage.mmSerialize(event.message())).replaceText(URL_REPLACEMENT_CONFIG));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Component prefix = plugin.getRankManager().getPrefix(plexPlayer);
|
||||
|
||||
if (prefix != null)
|
||||
@ -62,7 +58,6 @@ public class ChatListener extends PlexListener
|
||||
|
||||
event.renderer(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
public static class PlexChatRenderer implements ChatRenderer
|
||||
{
|
||||
@ -73,7 +68,7 @@ public class ChatListener extends PlexListener
|
||||
@Override
|
||||
public @NotNull Component render(@NotNull Player source, @NotNull Component sourceDisplayName, @NotNull Component message, @NotNull Audience viewer)
|
||||
{
|
||||
String text = PlexUtils.getTextFromComponent(message);
|
||||
String text = PlexUtils.cleanString(PlexUtils.getTextFromComponent(message));
|
||||
|
||||
Component component = Component.empty();
|
||||
|
||||
@ -86,8 +81,12 @@ public class ChatListener extends PlexListener
|
||||
component = component.append(prefix).append(Component.space());
|
||||
}
|
||||
return component
|
||||
.append(Component.space())
|
||||
.append(PlexUtils.mmDeserialize(plugin.config.getString("chat.name-color", "<white>") + SafeMiniMessage.MINI_MESSAGE.serialize(sourceDisplayName)))
|
||||
.append(Component.empty())
|
||||
.append(
|
||||
source.name().equals(sourceDisplayName) ?
|
||||
SafeMiniMessage.mmDeserialize(plugin.config.getString("chat.name-color") + SafeMiniMessage.mmSerialize(sourceDisplayName))
|
||||
: SafeMiniMessage.mmDeserialize(plugin.config.getString("chat.name-color")).append(sourceDisplayName)
|
||||
)
|
||||
.append(Component.space())
|
||||
.append(Component.text("»").color(NamedTextColor.GRAY))
|
||||
.append(Component.space())
|
||||
|
@ -11,9 +11,10 @@ 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 net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -24,13 +25,16 @@ public class CommandListener extends PlexListener
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
Bukkit.getOnlinePlayers().stream().filter(pl -> plugin.getPlayerCache().getPlexPlayer(pl.getUniqueId()).isCommandSpy() && hasCommandSpy(plugin.getPlayerCache().getPlexPlayer(pl.getUniqueId()))).forEach(pl ->
|
||||
Bukkit.getOnlinePlayers().stream().filter(pl -> {
|
||||
PlexPlayer player = plugin.getPlayerCache().getPlexPlayer(pl.getUniqueId());
|
||||
return player.isCommandSpy() && hasCommandSpy(plugin.getPlayerCache().getPlexPlayer(pl.getUniqueId()));
|
||||
}).forEach(pl ->
|
||||
{
|
||||
Player player = event.getPlayer();
|
||||
String command = event.getMessage();
|
||||
if (pl != player)
|
||||
if (!pl.getUniqueId().equals(player.getUniqueId()))
|
||||
{
|
||||
pl.sendMessage(ChatColor.GRAY + player.getName() + ": " + command);
|
||||
pl.sendMessage(Component.text(player.getName() + ": " + command).color(NamedTextColor.GRAY));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -38,10 +42,11 @@ public class CommandListener extends PlexListener
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onCommandBlocking(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
String command = "/" + event.getMessage().replaceFirst("/", "").trim();
|
||||
Player player = event.getPlayer();
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(player.getUniqueId());
|
||||
String commandName = StringUtils.normalizeSpace(event.getMessage()).split(" ")[0].replaceFirst("/", "");
|
||||
String arguments = StringUtils.normalizeSpace(StringUtils.normalizeSpace(event.getMessage()).replace(event.getMessage().split(" ")[0], ""));
|
||||
String commandName = StringUtils.normalizeSpace(command).split(" ")[0].replaceFirst("/", "");
|
||||
String arguments = StringUtils.normalizeSpace(StringUtils.normalizeSpace(command).replace(command.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());
|
||||
@ -49,7 +54,7 @@ public class CommandListener extends PlexListener
|
||||
{
|
||||
boolean matches = true;
|
||||
String[] args = blockedCommand.getCommand().split(" ");
|
||||
String[] cmdArgs = event.getMessage().replaceFirst("/", "").split(" ");
|
||||
String[] cmdArgs = command.replaceFirst("/", "").split(" ");
|
||||
for (int i = 0; i < args.length; i++)
|
||||
{
|
||||
if (i + 1 > cmdArgs.length)
|
||||
@ -87,7 +92,7 @@ public class CommandListener extends PlexListener
|
||||
if (blockedCommand.getRegex() != null)
|
||||
{
|
||||
Pattern pattern = Pattern.compile(blockedCommand.getRegex(), Pattern.CASE_INSENSITIVE);
|
||||
Matcher matcher = pattern.matcher(event.getMessage().replaceFirst("/", ""));
|
||||
Matcher matcher = pattern.matcher(command.replaceFirst("/", ""));
|
||||
if (matcher.find())
|
||||
{
|
||||
PlexLog.debug("Player attempted to use a blocked regex");
|
||||
|
@ -1,6 +1,6 @@
|
||||
package dev.plex.listener.impl;
|
||||
|
||||
import dev.plex.api.event.GameModeUpdateEvent;
|
||||
import dev.plex.event.GameModeUpdateEvent;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
@ -28,6 +28,27 @@ public class MobListener extends PlexListener
|
||||
{
|
||||
private static final List<Material> SPAWN_EGGS = Arrays.stream(Material.values()).filter((mat) -> mat.name().endsWith("_SPAWN_EGG")).toList();
|
||||
|
||||
private static EntityType spawnEggToEntityType(Material mat)
|
||||
{
|
||||
EntityType eggType;
|
||||
try
|
||||
{
|
||||
if (mat == Material.MOOSHROOM_SPAWN_EGG)
|
||||
{
|
||||
eggType = EntityType.MUSHROOM_COW;
|
||||
}
|
||||
else
|
||||
{
|
||||
eggType = EntityType.valueOf(mat.name().substring(0, mat.name().length() - 10));
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException ignored)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return eggType;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntitySpawn(EntitySpawnEvent event)
|
||||
{
|
||||
@ -56,7 +77,7 @@ public class MobListener extends PlexListener
|
||||
if (SPAWN_EGGS.contains(itemType))
|
||||
{
|
||||
Block block = event.getBlock();
|
||||
Location blockLoc = BlockUtils.relative(block.getLocation(), ((Directional) block.getBlockData()).getFacing()).add(.5, 0, .5);
|
||||
Location blockLoc = BlockUtils.relative(block.getLocation(), ((Directional)block.getBlockData()).getFacing()).add(.5, 0, .5);
|
||||
EntityType eggType = spawnEggToEntityType(itemType);
|
||||
if (eggType != null)
|
||||
{
|
||||
@ -108,25 +129,4 @@ public class MobListener extends PlexListener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static EntityType spawnEggToEntityType(Material mat)
|
||||
{
|
||||
EntityType eggType;
|
||||
try
|
||||
{
|
||||
if (mat == Material.MOOSHROOM_SPAWN_EGG)
|
||||
{
|
||||
eggType = EntityType.MUSHROOM_COW;
|
||||
}
|
||||
else
|
||||
{
|
||||
eggType = EntityType.valueOf(mat.name().substring(0, mat.name().length() - 10));
|
||||
}
|
||||
}
|
||||
catch (IllegalArgumentException ignored)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return eggType;
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,8 @@ import dev.plex.storage.StorageType;
|
||||
import dev.plex.util.PermissionsUtil;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.ClickEvent;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
@ -36,7 +34,8 @@ public class PlayerListener<T> extends PlexListener
|
||||
{
|
||||
player.setOp(true);
|
||||
PlexLog.debug("Automatically opped " + player.getName() + " since ranks are enabled.");
|
||||
} else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
}
|
||||
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
player.setOp(false);
|
||||
PlexLog.debug("Automatically deopped " + player.getName() + " since ranks are disabled.");
|
||||
@ -49,7 +48,8 @@ public class PlayerListener<T> extends PlexListener
|
||||
plexPlayer.setName(player.getName()); // set the name of the player
|
||||
plexPlayer.setIps(Arrays.asList(player.getAddress().getAddress().getHostAddress().trim())); // set the arraylist of ips
|
||||
DataUtils.insert(plexPlayer); // insert data in some wack db
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
plexPlayer = DataUtils.getPlayer(player.getUniqueId());
|
||||
List<String> ips = plexPlayer.getIps();
|
||||
|
@ -1,9 +1,9 @@
|
||||
package dev.plex.listener.impl;
|
||||
|
||||
import dev.plex.api.event.AdminAddEvent;
|
||||
import dev.plex.api.event.AdminRemoveEvent;
|
||||
import dev.plex.api.event.AdminSetRankEvent;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.event.AdminAddEvent;
|
||||
import dev.plex.event.AdminRemoveEvent;
|
||||
import dev.plex.event.AdminSetRankEvent;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -25,7 +25,7 @@ public class TabListener extends PlexListener
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onAdminAdd(AdminAddEvent event)
|
||||
{
|
||||
PlexPlayer plexPlayer = (PlexPlayer) event.getPlexPlayer();
|
||||
PlexPlayer plexPlayer = (PlexPlayer)event.getPlexPlayer();
|
||||
Player player = event.getPlexPlayer().getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
@ -37,7 +37,7 @@ public class TabListener extends PlexListener
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onAdminRemove(AdminRemoveEvent event)
|
||||
{
|
||||
PlexPlayer plexPlayer = (PlexPlayer) event.getPlexPlayer();
|
||||
PlexPlayer plexPlayer = (PlexPlayer)event.getPlexPlayer();
|
||||
Player player = event.getPlexPlayer().getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
@ -49,7 +49,7 @@ public class TabListener extends PlexListener
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onAdminSetRank(AdminSetRankEvent event)
|
||||
{
|
||||
PlexPlayer plexPlayer = (PlexPlayer) event.getPlexPlayer();
|
||||
PlexPlayer plexPlayer = (PlexPlayer)event.getPlexPlayer();
|
||||
Player player = event.getPlexPlayer().getPlayer();
|
||||
if (player == null)
|
||||
{
|
||||
|
@ -3,13 +3,24 @@ package dev.plex.listener.impl;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.block.BlockFromToEvent;
|
||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
|
||||
public class TogglesListener extends PlexListener
|
||||
{
|
||||
@EventHandler
|
||||
public void onEntityExplode(ExplosionPrimeEvent event)
|
||||
public void onBlockExplode(ExplosionPrimeEvent event)
|
||||
{
|
||||
if (!plugin.toggles.getBoolean("explosions"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntityExplode(EntityExplodeEvent event)
|
||||
{
|
||||
if (!plugin.toggles.getBoolean("explosions"))
|
||||
{
|
||||
@ -34,4 +45,18 @@ public class TogglesListener extends PlexListener
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
/* I have no idea if this is the best way to do this
|
||||
There is a very weird bug where if you try to create a loop using two repeaters and a lever, after disabling
|
||||
and re-enabling redstone, you are unable to recreate the loop with a lever. Using a redstone torch works fine.
|
||||
Using a lever works fine also as long as you never toggle redstone.
|
||||
*/
|
||||
@EventHandler
|
||||
public void onBlockRedstone(BlockRedstoneEvent event)
|
||||
{
|
||||
if (!plugin.toggles.getBoolean("redstone"))
|
||||
{
|
||||
event.setNewCurrent(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package dev.plex.listener.impl;
|
||||
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.cache.DataUtils;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
@ -13,7 +12,7 @@ import java.util.List;
|
||||
import java.util.Locale;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
@ -31,42 +30,41 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class WorldListener extends PlexListener
|
||||
{
|
||||
private final List<String> EDIT_COMMANDS = Arrays.asList("bigtree", "ebigtree", "largetree", "elargetree",
|
||||
"break", "ebreak", "antioch", "nuke", "editsign", "tree", "etree");
|
||||
private final List<String> EDIT_COMMANDS = Arrays.asList("bigtree", "ebigtree", "largetree", "elargetree", "break", "ebreak", "antioch", "nuke", "editsign", "tree", "etree");
|
||||
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent e)
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (!checkPermission(e.getPlayer(), true))
|
||||
if (!canModifyWorld(event.getPlayer(), true))
|
||||
{
|
||||
e.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent e)
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (!checkPermission(e.getPlayer(), true))
|
||||
if (!canModifyWorld(event.getPlayer(), true))
|
||||
{
|
||||
e.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onEntitySpawn(EntitySpawnEvent e)
|
||||
public void onEntitySpawn(EntitySpawnEvent event)
|
||||
{
|
||||
if (e.getEntityType() != EntityType.SLIME)
|
||||
if (event.getEntityType() != EntityType.SLIME)
|
||||
{
|
||||
return;
|
||||
}
|
||||
e.setCancelled(true);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
// If the person has permission to modify the world, we don't need to block WorldEdit
|
||||
if (checkPermission(event.getPlayer(), false))
|
||||
if (canModifyWorld(event.getPlayer(), false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -78,8 +76,8 @@ public class WorldListener extends PlexListener
|
||||
if (command != null)
|
||||
{
|
||||
// This does check for aliases
|
||||
boolean isWeCommand = command instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) command).getPlugin().equals(Bukkit.getPluginManager().getPlugin("WorldEdit"));
|
||||
boolean isFaweCommand = command instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand) command).getPlugin().equals(Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit"));
|
||||
boolean isWeCommand = command instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand)command).getPlugin().equals(Bukkit.getPluginManager().getPlugin("WorldEdit"));
|
||||
boolean isFaweCommand = command instanceof PluginIdentifiableCommand && ((PluginIdentifiableCommand)command).getPlugin().equals(Bukkit.getPluginManager().getPlugin("FastAsyncWorldEdit"));
|
||||
if (isWeCommand || isFaweCommand || EDIT_COMMANDS.contains(message.toLowerCase()))
|
||||
{
|
||||
event.getPlayer().sendMessage(Component.text("You do not have permission to use that command in this world.").color(NamedTextColor.RED));
|
||||
@ -88,26 +86,12 @@ public class WorldListener extends PlexListener
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Add an entry setting in the config.yml and allow checking for all worlds
|
||||
@EventHandler
|
||||
public void onWorldTeleport(PlayerTeleportEvent e)
|
||||
public void onWorldTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
final World adminworld = Bukkit.getWorld("adminworld");
|
||||
if (adminworld == null)
|
||||
if (!canEnterWorld(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(e.getPlayer().getUniqueId());
|
||||
if (e.getTo().getWorld().equals(adminworld))
|
||||
{
|
||||
if (plugin.getSystem().equals("ranks") && !plexPlayer.isAdminActive())
|
||||
{
|
||||
e.setCancelled(true);
|
||||
}
|
||||
else if (plugin.getSystem().equals("permissions") && !plugin.getPermissionHandler().hasPermission(e.getPlayer(), "plex.adminworld.enter"))
|
||||
{
|
||||
e.setCancelled(true);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -152,27 +136,34 @@ public class WorldListener extends PlexListener
|
||||
return hasAccess;
|
||||
}
|
||||
|
||||
private boolean checkPermission(Player player, boolean showMessage)
|
||||
/**
|
||||
* Check if a Player has the ability to modify the world they are in
|
||||
*
|
||||
* @param player The player who wants to modify the world
|
||||
* @param showMessage Whether the message from the config.yml should be shown
|
||||
* @return Returns true if the person has the ability to modify the world
|
||||
*/
|
||||
private boolean canModifyWorld(Player player, boolean showMessage)
|
||||
{
|
||||
PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayerMap().get(player.getUniqueId());
|
||||
World world = player.getWorld();
|
||||
if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
String permission = plugin.config.getString("plex." + world.getName().toLowerCase() + ".permission");
|
||||
String permission = plugin.config.getString("worlds." + world.getName().toLowerCase() + ".modification.permission");
|
||||
if (permission == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (plugin.getPermissionHandler().hasPermission(player, permission))
|
||||
if (player.hasPermission(permission))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||
{
|
||||
if (plugin.config.contains("worlds." + world.getName().toLowerCase() + ".requiredLevels"))
|
||||
if (plugin.config.contains("worlds." + world.getName().toLowerCase() + ".modification.requiredLevels"))
|
||||
{
|
||||
@NotNull List<String> requiredLevel = plugin.config.getStringList("worlds." + world.getName().toLowerCase() + ".requiredLevels");
|
||||
@NotNull List<String> requiredLevel = plugin.config.getStringList("worlds." + world.getName().toLowerCase() + ".modification.requiredLevels");
|
||||
if (checkLevel(plexPlayer, requiredLevel.toArray(String[]::new)))
|
||||
{
|
||||
return true;
|
||||
@ -186,12 +177,58 @@ public class WorldListener extends PlexListener
|
||||
|
||||
if (showMessage)
|
||||
{
|
||||
String noEdit = plugin.config.getString("worlds." + world.getName().toLowerCase() + ".noEdit");
|
||||
String noEdit = plugin.config.getString("worlds." + world.getName().toLowerCase() + ".modification.message");
|
||||
if (noEdit != null)
|
||||
{
|
||||
player.sendMessage(LegacyComponentSerializer.legacyAmpersand().deserialize(noEdit));
|
||||
player.sendMessage(MiniMessage.miniMessage().deserialize(noEdit));
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a Player has the ability to enter the requested world
|
||||
*
|
||||
* @param player The player who wants to enter the world
|
||||
* @return Returns true if the person has the ability to enter the world
|
||||
*/
|
||||
private boolean canEnterWorld(Player player)
|
||||
{
|
||||
PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayerMap().get(player.getUniqueId());
|
||||
World world = player.getWorld();
|
||||
if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
String permission = plugin.config.getString("worlds." + world.getName().toLowerCase() + ".entry.permission");
|
||||
if (permission == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (player.hasPermission(permission))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||
{
|
||||
if (plugin.config.contains("worlds." + world.getName().toLowerCase() + ".entry.requiredLevels"))
|
||||
{
|
||||
@NotNull List<String> requiredLevel = plugin.config.getStringList("worlds." + world.getName().toLowerCase() + ".entry.requiredLevels");
|
||||
if (checkLevel(plexPlayer, requiredLevel.toArray(String[]::new)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
String noEntry = plugin.config.getString("worlds." + world.getName().toLowerCase() + ".entry.message");
|
||||
if (noEntry != null)
|
||||
{
|
||||
player.sendMessage(MiniMessage.miniMessage().deserialize(noEntry));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
@ -12,7 +12,6 @@ import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -134,7 +133,7 @@ public class PunishedPlayerMenu extends AbstractMenu
|
||||
{
|
||||
return;
|
||||
}
|
||||
openInv((Player) event.getWhoClicked(), getCurrentInventoryIndex(inv) + 1);
|
||||
openInv((Player)event.getWhoClicked(), getCurrentInventoryIndex(inv) + 1);
|
||||
}
|
||||
else if (item.getItemMeta().displayName().equals(Component.text("Previous Page").color(NamedTextColor.LIGHT_PURPLE)))
|
||||
{
|
||||
@ -150,23 +149,23 @@ public class PunishedPlayerMenu extends AbstractMenu
|
||||
{
|
||||
return;
|
||||
}
|
||||
openInv((Player) event.getWhoClicked(), getCurrentInventoryIndex(inv) - 1);
|
||||
openInv((Player)event.getWhoClicked(), getCurrentInventoryIndex(inv) - 1);
|
||||
}
|
||||
|
||||
}
|
||||
else if (item.getType() == Material.BARRIER)
|
||||
{
|
||||
new PunishmentMenu().openInv((Player) event.getWhoClicked(), 0);
|
||||
new PunishmentMenu().openInv((Player)event.getWhoClicked(), 0);
|
||||
}
|
||||
else if (item.getType() == Material.PLAYER_HEAD)
|
||||
{
|
||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||
SkullMeta meta = (SkullMeta)item.getItemMeta();
|
||||
OfflinePlayer player = meta.getOwningPlayer();
|
||||
assert player != null;
|
||||
PlexPlayer punishedPlayer = DataUtils.getPlayer(player.getUniqueId()) == null ? null : Plex.get().getPlayerCache().getPlexPlayer(player.getUniqueId());
|
||||
if (punishedPlayer == null)
|
||||
{
|
||||
event.getWhoClicked().sendMessage(ChatColor.RED + "This player does not exist. Try doing /punishments <player> instead.");
|
||||
event.getWhoClicked().sendMessage(Component.text("This player does not exist. Try doing /punishments <player> instead.").color(NamedTextColor.RED));
|
||||
event.getWhoClicked().closeInventory();
|
||||
return;
|
||||
}
|
||||
|
@ -6,8 +6,9 @@ import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.menu.AbstractMenu;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -71,7 +72,7 @@ public class PunishmentMenu extends AbstractMenu
|
||||
|
||||
|
||||
ItemStack item = new ItemStack(Material.PLAYER_HEAD);
|
||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||
SkullMeta meta = (SkullMeta)item.getItemMeta();
|
||||
meta.setOwningPlayer(players);
|
||||
meta.displayName(PlexUtils.mmDeserialize("<!italic><yellow>" + players.getName()));
|
||||
item.setItemMeta(meta);
|
||||
@ -121,7 +122,7 @@ public class PunishmentMenu extends AbstractMenu
|
||||
{
|
||||
return;
|
||||
}
|
||||
openInv((Player) event.getWhoClicked(), getCurrentInventoryIndex(inv) + 1);
|
||||
openInv((Player)event.getWhoClicked(), getCurrentInventoryIndex(inv) + 1);
|
||||
}
|
||||
else if (item.getItemMeta().displayName().equals(PlexUtils.mmDeserialize("<light_purple>Previous Page")))
|
||||
{
|
||||
@ -137,23 +138,23 @@ public class PunishmentMenu extends AbstractMenu
|
||||
{
|
||||
return;
|
||||
}
|
||||
openInv((Player) event.getWhoClicked(), getCurrentInventoryIndex(inv) - 1);
|
||||
openInv((Player)event.getWhoClicked(), getCurrentInventoryIndex(inv) - 1);
|
||||
}
|
||||
|
||||
}
|
||||
else if (item.getType() == Material.PLAYER_HEAD)
|
||||
{
|
||||
SkullMeta meta = (SkullMeta) item.getItemMeta();
|
||||
SkullMeta meta = (SkullMeta)item.getItemMeta();
|
||||
OfflinePlayer player = meta.getOwningPlayer();
|
||||
assert player != null;
|
||||
PlexPlayer punishedPlayer = DataUtils.getPlayer(player.getUniqueId());
|
||||
if (punishedPlayer == null)
|
||||
{
|
||||
event.getWhoClicked().sendMessage(ChatColor.RED + "This player does not exist. Try doing /punishments <player> instead.");
|
||||
event.getWhoClicked().sendMessage(Component.text("This player does not exist. Try doing /punishments <player> instead.").color(NamedTextColor.RED));
|
||||
event.getWhoClicked().closeInventory();
|
||||
return;
|
||||
}
|
||||
new PunishedPlayerMenu(punishedPlayer).openInv((Player) event.getWhoClicked(), 0);
|
||||
new PunishedPlayerMenu(punishedPlayer).openInv((Player)event.getWhoClicked(), 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -21,10 +21,11 @@ public class ToggleMenu extends AbstractMenu implements PlexBase
|
||||
public ToggleMenu()
|
||||
{
|
||||
super("§a§lToggles");
|
||||
Inventory inventory = Bukkit.createInventory(null, 54, PlexUtils.mmDeserialize("Toggles"));
|
||||
Inventory inventory = Bukkit.createInventory(null, 9, PlexUtils.mmDeserialize("Toggles"));
|
||||
resetExplosionItem(inventory);
|
||||
resetFluidspreadItem(inventory);
|
||||
resetDropsItem(inventory);
|
||||
resetRedstoneItem(inventory);
|
||||
inventories.add(inventory);
|
||||
}
|
||||
|
||||
@ -77,6 +78,12 @@ public class ToggleMenu extends AbstractMenu implements PlexBase
|
||||
resetDropsItem(inv);
|
||||
event.getWhoClicked().sendMessage(PlexUtils.mmDeserialize("<gray>Toggled drops."));
|
||||
}
|
||||
if (item.getType() == Material.REDSTONE)
|
||||
{
|
||||
plugin.toggles.set("redstone", !plugin.toggles.getBoolean("redstone"));
|
||||
resetRedstoneItem(inv);
|
||||
event.getWhoClicked().sendMessage(PlexUtils.mmDeserialize("<gray>Toggled redstone."));
|
||||
}
|
||||
}
|
||||
|
||||
public int getCurrentInventoryIndex(Inventory inventory)
|
||||
@ -125,4 +132,14 @@ public class ToggleMenu extends AbstractMenu implements PlexBase
|
||||
feather.setItemMeta(featherItemMeta);
|
||||
inventory.setItem(2, feather);
|
||||
}
|
||||
|
||||
private void resetRedstoneItem(Inventory inventory)
|
||||
{
|
||||
ItemStack redstone = new ItemStack(Material.REDSTONE);
|
||||
ItemMeta redstoneItemMeta = redstone.getItemMeta();
|
||||
redstoneItemMeta.displayName(PlexUtils.mmDeserialize("<light_purple>Redstone"));
|
||||
redstoneItemMeta.lore(List.of(PlexUtils.mmDeserialize("<yellow>Redstone is " + (plugin.toggles.getBoolean("redstone") ? "<green>enabled" : "<red>disabled"))));
|
||||
redstone.setItemMeta(redstoneItemMeta);
|
||||
inventory.setItem(3, redstone);
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,6 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@Getter
|
||||
public class ModuleManager
|
||||
{
|
||||
|
||||
private final List<PlexModule> modules = Lists.newArrayList();
|
||||
private final LibraryLoader libraryLoader;
|
||||
|
||||
@ -67,7 +66,7 @@ public class ModuleManager
|
||||
|
||||
PlexModuleFile plexModuleFile = new PlexModuleFile(name, main, description, version);
|
||||
plexModuleFile.setLibraries(libraries);
|
||||
Class<? extends PlexModule> module = (Class<? extends PlexModule>) Class.forName(main, true, loader);
|
||||
Class<? extends PlexModule> module = (Class<? extends PlexModule>)Class.forName(main, true, loader);
|
||||
|
||||
PlexModule plexModule = module.getConstructor().newInstance();
|
||||
plexModule.setPlex(Plex.get());
|
||||
@ -142,7 +141,7 @@ public class ModuleManager
|
||||
{
|
||||
try
|
||||
{
|
||||
((URLClassLoader) module.getClass().getClassLoader()).close();
|
||||
((URLClassLoader)module.getClass().getClassLoader()).close();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
|
@ -4,11 +4,13 @@ import com.google.common.collect.Lists;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.command.PlexCommand;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import dev.plex.util.PlexLog;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import lombok.AccessLevel;
|
||||
@ -46,22 +48,42 @@ public abstract class PlexModule
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a PlexListener within a module
|
||||
*
|
||||
* @param listener The PlexListener to be registered
|
||||
*/
|
||||
public void registerListener(PlexListener listener)
|
||||
{
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a PlexListener. Handled by Plex automatically
|
||||
*
|
||||
* @param listener The PlexListener to be registered
|
||||
*/
|
||||
public void unregisterListener(PlexListener listener)
|
||||
{
|
||||
listeners.remove(listener);
|
||||
HandlerList.unregisterAll(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a PlexCommand within a module
|
||||
*
|
||||
* @param command The PlexCommand to be registered
|
||||
*/
|
||||
public void registerCommand(PlexCommand command)
|
||||
{
|
||||
commands.add(command);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a PlexCommand. Handled by Plex automatically
|
||||
*
|
||||
* @param command The PlexCommand to be registered
|
||||
*/
|
||||
public void unregisterCommand(PlexCommand command)
|
||||
{
|
||||
commands.remove(command);
|
||||
@ -72,6 +94,41 @@ public abstract class PlexModule
|
||||
return commands.stream().filter(plexCommand -> plexCommand.getName().equalsIgnoreCase(name) || plexCommand.getAliases().stream().map(String::toLowerCase).toList().contains(name.toLowerCase(Locale.ROOT))).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a message to the messages.yml file
|
||||
*
|
||||
* @param message The key value for the message
|
||||
* @param initValue The message itself
|
||||
*/
|
||||
public void addDefaultMessage(String message, Object initValue)
|
||||
{
|
||||
if (plex.messages.getString(message) == null)
|
||||
{
|
||||
plex.messages.set(message, initValue);
|
||||
plex.messages.save();
|
||||
PlexLog.debug("'{0}' message added from " + plexModuleFile.getName(), message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a message to the messages.yml with a comment
|
||||
*
|
||||
* @param message The key value for the message
|
||||
* @param initValue The message itself
|
||||
* @param comments The comments to be placed above the message
|
||||
*/
|
||||
public void addDefaultMessage(String message, Object initValue, String... comments)
|
||||
{
|
||||
if (plex.messages.getString(message) == null)
|
||||
{
|
||||
plex.messages.set(message, initValue);
|
||||
plex.messages.save();
|
||||
plex.messages.setComments(message, Arrays.asList(comments));
|
||||
plex.messages.save();
|
||||
PlexLog.debug("'{0}' message added from " + plexModuleFile.getName(), message);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public InputStream getResource(@NotNull String filename)
|
||||
{
|
||||
|
@ -105,7 +105,7 @@ public class LibraryLoader
|
||||
DependencyResult result;
|
||||
try
|
||||
{
|
||||
result = repository.resolveDependencies(session, new DependencyRequest(new CollectRequest((Dependency) null, dependencies, repositories), null));
|
||||
result = repository.resolveDependencies(session, new DependencyRequest(new CollectRequest((Dependency)null, dependencies, repositories), null));
|
||||
}
|
||||
catch (DependencyResolutionException ex)
|
||||
{
|
||||
|
@ -1,7 +0,0 @@
|
||||
package dev.plex.permission.handler;
|
||||
|
||||
import dev.plex.api.permission.IPermissionHandler;
|
||||
|
||||
public class NativePermissionHandler implements IPermissionHandler
|
||||
{
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
package dev.plex.permission.handler;
|
||||
|
||||
import dev.plex.api.permission.IPermissionHandler;
|
||||
import dev.plex.hook.VaultHook;
|
||||
import lombok.Getter;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Getter
|
||||
public class VaultPermissionHandler implements IPermissionHandler
|
||||
{
|
||||
@Override
|
||||
public boolean hasPermission(@NotNull OfflinePlayer player, @Nullable String permission)
|
||||
{
|
||||
if (!Bukkit.getPluginManager().isPluginEnabled("Vault"))
|
||||
{
|
||||
return IPermissionHandler.super.hasPermission(player, permission);
|
||||
}
|
||||
if (VaultHook.getPermission() == null)
|
||||
{
|
||||
return IPermissionHandler.super.hasPermission(player, permission);
|
||||
}
|
||||
return VaultHook.getPermission().playerHas(null, player, permission);
|
||||
|
||||
}
|
||||
}
|
@ -7,7 +7,6 @@ import dev.morphia.annotations.Id;
|
||||
import dev.morphia.annotations.IndexOptions;
|
||||
import dev.morphia.annotations.Indexed;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.api.player.IPlexPlayer;
|
||||
import dev.plex.permission.Permission;
|
||||
import dev.plex.punishment.Punishment;
|
||||
import dev.plex.punishment.extra.Note;
|
||||
@ -30,7 +29,7 @@ import org.bukkit.permissions.PermissionAttachment;
|
||||
@Getter
|
||||
@Setter
|
||||
@Entity(value = "players", useDiscriminator = false)
|
||||
public class PlexPlayer implements IPlexPlayer
|
||||
public class PlexPlayer
|
||||
{
|
||||
@Setter(AccessLevel.NONE)
|
||||
@Id
|
||||
@ -42,11 +41,11 @@ public class PlexPlayer implements IPlexPlayer
|
||||
|
||||
@Indexed
|
||||
private String name;
|
||||
private transient Player player;
|
||||
|
||||
private String loginMessage;
|
||||
private String prefix;
|
||||
|
||||
private boolean staffChat;
|
||||
private boolean vanished;
|
||||
private boolean commandSpy;
|
||||
|
||||
@ -79,7 +78,6 @@ public class PlexPlayer implements IPlexPlayer
|
||||
this.id = uuid.toString().substring(0, 8);
|
||||
|
||||
this.name = "";
|
||||
this.player = Bukkit.getPlayer(name);
|
||||
|
||||
this.loginMessage = "";
|
||||
this.prefix = "";
|
||||
@ -107,7 +105,7 @@ public class PlexPlayer implements IPlexPlayer
|
||||
|
||||
public String displayName()
|
||||
{
|
||||
return PlainTextComponentSerializer.plainText().serialize(player.displayName());
|
||||
return PlainTextComponentSerializer.plainText().serialize(getPlayer().displayName());
|
||||
}
|
||||
|
||||
public Rank getRankFromString()
|
||||
@ -151,4 +149,8 @@ public class PlexPlayer implements IPlexPlayer
|
||||
{
|
||||
return new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, new ZonedDateTimeSerializer()).create().toJson(this);
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return Bukkit.getPlayer(this.uuid);
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import dev.plex.storage.StorageType;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.TimeUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@ -23,7 +22,6 @@ import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
@ -107,7 +105,8 @@ public class PunishmentManager implements PlexBase
|
||||
{
|
||||
DataUtils.update(plexPlayer);
|
||||
});
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
Plex.get().getSqlPunishment().insertPunishment(punishment);
|
||||
}
|
||||
@ -118,7 +117,8 @@ public class PunishmentManager implements PlexBase
|
||||
try
|
||||
{
|
||||
return !FileUtils.readFileToString(file, StandardCharsets.UTF_8).trim().isEmpty();
|
||||
} catch (IOException e)
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -164,7 +164,8 @@ public class PunishmentManager implements PlexBase
|
||||
List<PlexPlayer> players = Plex.get().getMongoPlayerData().getPlayers();
|
||||
return players.stream().map(PlexPlayer::getPunishments).flatMap(Collection::stream).filter(Punishment::isActive).filter(punishment -> punishment.getType() == PunishmentType.BAN || punishment.getType() == PunishmentType.TEMPBAN).toList();
|
||||
});
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
//PlexLog.debug("Checking active bans mysql");
|
||||
CompletableFuture<List<Punishment>> future = new CompletableFuture<>();
|
||||
@ -195,7 +196,8 @@ public class PunishmentManager implements PlexBase
|
||||
.peek(punishment -> punishment.setActive(false)).collect(Collectors.toList()));
|
||||
DataUtils.update(plexPlayer);
|
||||
});
|
||||
} else
|
||||
}
|
||||
else
|
||||
{
|
||||
return Plex.get().getSqlPunishment().removeBan(uuid);
|
||||
}
|
||||
@ -223,7 +225,8 @@ public class PunishmentManager implements PlexBase
|
||||
Bukkit.broadcast(PlexUtils.messageComponent("unfrozePlayer", "Plex", Bukkit.getOfflinePlayer(player.getUuid()).getName()));
|
||||
}
|
||||
}.runTaskLater(Plex.get(), 20 * seconds);
|
||||
} else if (punishment.getType() == PunishmentType.MUTE)
|
||||
}
|
||||
else if (punishment.getType() == PunishmentType.MUTE)
|
||||
{
|
||||
player.setMuted(true);
|
||||
ZonedDateTime now = ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE));
|
||||
|
@ -1,6 +1,5 @@
|
||||
package dev.plex.rank.enums;
|
||||
|
||||
import dev.plex.api.rank.IRank;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@ -9,7 +8,7 @@ import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.json.JSONObject;
|
||||
|
||||
@Getter
|
||||
public enum Rank implements IRank<Rank>
|
||||
public enum Rank
|
||||
{
|
||||
IMPOSTOR(-1, "<aqua>an <yellow>Impostor<reset>", "Impostor", "<dark_gray>[<yellow>Imp<dark_gray>]", NamedTextColor.YELLOW),
|
||||
NONOP(0, "a <white>Non-Op<reset>", "Non-Op", "", NamedTextColor.WHITE),
|
||||
@ -19,18 +18,14 @@ public enum Rank implements IRank<Rank>
|
||||
EXECUTIVE(4, "an <red>Executive<reset>", "Executive", "<dark_gray>[<red>Exec<dark_gray>]", NamedTextColor.RED);
|
||||
|
||||
private final int level;
|
||||
|
||||
@Setter
|
||||
private String loginMessage;
|
||||
|
||||
@Setter
|
||||
private String readable;
|
||||
|
||||
@Setter
|
||||
private String prefix;
|
||||
|
||||
@Getter
|
||||
private final NamedTextColor color;
|
||||
@Setter
|
||||
private String loginMessage;
|
||||
@Setter
|
||||
private String readable;
|
||||
@Setter
|
||||
private String prefix;
|
||||
|
||||
Rank(int level, String loginMessage, String readable, String prefix, NamedTextColor color)
|
||||
{
|
||||
|
@ -15,18 +15,14 @@ public enum Title
|
||||
OWNER(2, "<aqua>an <blue>Owner<reset>", "Owner", "<dark_gray>[<blue>Owner<dark_gray>]", NamedTextColor.BLUE);
|
||||
|
||||
private final int level;
|
||||
|
||||
@Setter
|
||||
private String loginMessage;
|
||||
|
||||
@Setter
|
||||
private String readable;
|
||||
|
||||
@Setter
|
||||
private String prefix;
|
||||
|
||||
@Getter
|
||||
private final NamedTextColor color;
|
||||
@Setter
|
||||
private String loginMessage;
|
||||
@Setter
|
||||
private String readable;
|
||||
@Setter
|
||||
private String prefix;
|
||||
|
||||
Title(int level, String loginMessage, String readable, String prefix, NamedTextColor color)
|
||||
{
|
||||
|
@ -1,7 +1,6 @@
|
||||
package dev.plex.storage;
|
||||
|
||||
import com.mongodb.ConnectionString;
|
||||
import com.mongodb.MongoClientOptions;
|
||||
import com.mongodb.MongoClientSettings;
|
||||
import com.mongodb.client.MongoClient;
|
||||
import com.mongodb.client.MongoClients;
|
||||
|
@ -67,7 +67,8 @@ public class SQLConnection implements PlexBase
|
||||
"`login_msg` VARCHAR(2000), " +
|
||||
"`prefix` VARCHAR(2000), " +
|
||||
"`rank` VARCHAR(20), " +
|
||||
"`adminActive` BOOLEAN," +
|
||||
"`adminActive` BOOLEAN, " +
|
||||
"`staffChat` BOOLEAN, " +
|
||||
"`ips` VARCHAR(2000), " +
|
||||
"`coins` BIGINT, " +
|
||||
"`vanished` BOOLEAN, " +
|
||||
@ -96,6 +97,11 @@ public class SQLConnection implements PlexBase
|
||||
"`permission` VARCHAR(1000) NOT NULL," +
|
||||
"`allowed` BOOLEAN" +
|
||||
");").execute();
|
||||
// Plex 1.2
|
||||
|
||||
try {
|
||||
con.prepareStatement("ALTER TABLE `players` ADD COLUMN `staffChat` BOOLEAN DEFAULT false;").execute();
|
||||
} catch (SQLException ignored) {}
|
||||
}
|
||||
catch (SQLException throwables)
|
||||
{
|
||||
|
@ -1,15 +1,13 @@
|
||||
package dev.plex.storage.codec;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import org.bson.BsonReader;
|
||||
import org.bson.BsonWriter;
|
||||
import org.bson.codecs.Codec;
|
||||
import org.bson.codecs.DecoderContext;
|
||||
import org.bson.codecs.EncoderContext;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
|
||||
import static dev.plex.util.TimeUtils.TIMEZONE;
|
||||
|
||||
public class ZonedDateTimeCodec implements Codec<ZonedDateTime>
|
||||
|
@ -2,7 +2,7 @@ package dev.plex.util;
|
||||
|
||||
import dev.plex.Plex;
|
||||
import java.util.Locale;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.bukkit.GameRule;
|
||||
import org.bukkit.World;
|
||||
|
||||
@ -27,8 +27,8 @@ public class GameRuleUtil
|
||||
private static <T> void readGameRules(World world, String s)
|
||||
{
|
||||
String gameRule = s.split(";")[0];
|
||||
T value = (T) s.split(";")[1];
|
||||
GameRule<T> rule = (GameRule<T>) GameRule.getByName(gameRule);
|
||||
T value = (T)s.split(";")[1];
|
||||
GameRule<T> rule = (GameRule<T>)GameRule.getByName(gameRule);
|
||||
if (rule != null && check(value).getClass().equals(rule.getType()))
|
||||
{
|
||||
world.setGameRule(rule, value);
|
||||
|
@ -38,7 +38,7 @@ public class MojangUtils
|
||||
return null;
|
||||
}
|
||||
client.close();
|
||||
AshconInfo ashconInfo = new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, (JsonDeserializer<ZonedDateTime>) (json1, typeOfT, context) ->
|
||||
AshconInfo ashconInfo = new GsonBuilder().registerTypeAdapter(ZonedDateTime.class, (JsonDeserializer<ZonedDateTime>)(json1, typeOfT, context) ->
|
||||
ZonedDateTime.ofInstant(Instant.from(DateTimeFormatter.ISO_INSTANT.parse(json1.getAsJsonPrimitive().getAsString())), ZoneId.of(Plex.get().config.getString("server.timezone")))).create().fromJson(json, AshconInfo.class);
|
||||
|
||||
Arrays.sort(ashconInfo.getUsernameHistories(), (o1, o2) ->
|
||||
|
@ -3,11 +3,12 @@ package dev.plex.util;
|
||||
import dev.plex.Plex;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import net.kyori.adventure.text.logger.slf4j.ComponentLogger;
|
||||
|
||||
public class PlexLog
|
||||
{
|
||||
private static final ComponentLogger logger = ComponentLogger.logger("");
|
||||
|
||||
public static void log(String message, Object... strings)
|
||||
{
|
||||
for (int i = 0; i < strings.length; i++)
|
||||
@ -17,12 +18,12 @@ public class PlexLog
|
||||
message = message.replace("{" + i + "}", strings[i].toString());
|
||||
}
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage(String.format(ChatColor.YELLOW + "[Plex] " + ChatColor.GRAY + "%s", message));
|
||||
logger.info(PlexUtils.mmDeserialize("<yellow>[Plex] <gray>" + message));
|
||||
}
|
||||
|
||||
public static void log(Component component)
|
||||
{
|
||||
Bukkit.getConsoleSender().sendMessage(Component.text("[Plex] ").color(NamedTextColor.YELLOW).append(component).colorIfAbsent(NamedTextColor.GRAY));
|
||||
logger.info(Component.text("[Plex] ").color(NamedTextColor.YELLOW).append(component).colorIfAbsent(NamedTextColor.GRAY));
|
||||
}
|
||||
|
||||
public static void error(String message, Object... strings)
|
||||
@ -34,8 +35,7 @@ public class PlexLog
|
||||
message = message.replace("{" + i + "}", strings[i].toString());
|
||||
}
|
||||
}
|
||||
Bukkit.getConsoleSender().sendMessage(PlexUtils.mmDeserialize("<red>[Plex Error] <gold>" + message));
|
||||
// Bukkit.getConsoleSender().sendMessage(String.format(ChatColor.RED + "[Plex Error] " + ChatColor.GOLD + "%s", message));
|
||||
logger.error(PlexUtils.mmDeserialize("<red>[Plex Error] <gold>" + message));
|
||||
}
|
||||
|
||||
public static void warn(String message, Object... strings)
|
||||
@ -47,11 +47,12 @@ public class PlexLog
|
||||
message = message.replace("{" + i + "}", strings[i].toString());
|
||||
}
|
||||
}
|
||||
// Bukkit.getConsoleSender().sendMessage(String.format(ChatColor.YELLOW + "[Plex Warning] " + ChatColor.GOLD + "%s", message));
|
||||
Bukkit.getConsoleSender().sendMessage(PlexUtils.mmDeserialize("<#eb7c0e>[Plex Warning] <gold>" + message));
|
||||
logger.warn(PlexUtils.mmDeserialize("<#eb7c0e>[Plex Warning] <gold>" + message));
|
||||
}
|
||||
|
||||
public static void debug(String message, Object... strings)
|
||||
{
|
||||
if (Plex.get().config.getBoolean("debug"))
|
||||
{
|
||||
for (int i = 0; i < strings.length; i++)
|
||||
{
|
||||
@ -60,10 +61,7 @@ public class PlexLog
|
||||
message = message.replace("{" + i + "}", strings[i].toString());
|
||||
}
|
||||
}
|
||||
if (Plex.get().config.getBoolean("debug"))
|
||||
{
|
||||
Bukkit.getConsoleSender().sendMessage(PlexUtils.mmDeserialize("<dark_purple>[Plex Debug] <gold>" + message));
|
||||
// Bukkit.getConsoleSender().sendMessage(String.format(ChatColor.DARK_PURPLE + "[Plex Debug] " + ChatColor.GOLD + "%s", message));
|
||||
logger.info(PlexUtils.mmDeserialize("<dark_purple>[Plex Debug] <gold>" + message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,12 @@
|
||||
package dev.plex.util;
|
||||
|
||||
import com.google.common.base.CharMatcher;
|
||||
import com.google.common.collect.Lists;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.PlexBase;
|
||||
import dev.plex.listener.impl.ChatListener;
|
||||
import dev.plex.player.PlexPlayer;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import dev.plex.storage.StorageType;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
@ -10,6 +15,7 @@ import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
@ -53,9 +59,15 @@ public class PlexUtils implements PlexBase
|
||||
|
||||
public static void disabledEffectMultiple(Player[] players, Location location)
|
||||
{
|
||||
if (players.length < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Particle.CLOUD.builder().location(location).receivers(players).extra(0).offset(0.5, 0.5, 0.5).count(5).spawn();
|
||||
Particle.FLAME.builder().location(location).receivers(players).extra(0).offset(0.5, 0.5, 0.5).count(3).spawn();
|
||||
Particle.SOUL_FIRE_FLAME.builder().location(location).receivers(players).offset(0.5, 0.5, 0.5).extra(0).count(2).spawn();
|
||||
Particle.SOUL_FIRE_FLAME.builder().location(location).receivers(players).offset(0.5, 0.5, 0.5).extra(0).count(2)
|
||||
.spawn();
|
||||
// note that the sound is played to everyone who is close enough to hear it
|
||||
players[0].getWorld().playSound(location, org.bukkit.Sound.BLOCK_FIRE_EXTINGUISH, 0.5f, 0.5f);
|
||||
}
|
||||
@ -124,7 +136,7 @@ public class PlexUtils implements PlexBase
|
||||
{
|
||||
aprilFools = plugin.config.getBoolean("april_fools");
|
||||
}
|
||||
ZonedDateTime date = ZonedDateTime.now(ZoneId.of(TimeUtils.TIMEZONE));
|
||||
ZonedDateTime date = ZonedDateTime.now(ZoneId.systemDefault());
|
||||
if (aprilFools && date.getMonth() == Month.APRIL && date.getDayOfMonth() == 1)
|
||||
{
|
||||
Component component = MINI_MESSAGE.deserialize(input); // removes existing tags
|
||||
@ -224,4 +236,39 @@ public class PlexUtils implements PlexBase
|
||||
pl.sendMessage(component);
|
||||
});
|
||||
}
|
||||
|
||||
public static List<UUID> adminChat(String senderName, String message, UUID... ignore)
|
||||
{
|
||||
List<UUID> sent = Lists.newArrayList();
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
{
|
||||
if (Arrays.stream(ignore).anyMatch(uuid -> player.getUniqueId().equals(uuid)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||
{
|
||||
PlexPlayer plexPlayer = plugin.getPlayerCache().getPlexPlayerMap().get(player.getUniqueId());
|
||||
if (plexPlayer.getRankFromString().isAtLeast(Rank.ADMIN) && plexPlayer.isAdminActive())
|
||||
{
|
||||
player.sendMessage(messageComponent("adminChatFormat", senderName, message).replaceText(ChatListener.URL_REPLACEMENT_CONFIG));
|
||||
sent.add(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
if (player.hasPermission("plex.adminchat"))
|
||||
{
|
||||
player.sendMessage(PlexUtils.messageComponent("adminChatFormat", senderName, message).replaceText(ChatListener.URL_REPLACEMENT_CONFIG));
|
||||
sent.add(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
}
|
||||
return sent;
|
||||
}
|
||||
|
||||
public static String cleanString(String input)
|
||||
{
|
||||
return CharMatcher.ascii().retainFrom(input);
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ public class ReflectionsUtil
|
||||
{
|
||||
if (clazz.getSuperclass() == subType || Arrays.asList(clazz.getInterfaces()).contains(subType))
|
||||
{
|
||||
classes.add((Class<? extends T>) clazz);
|
||||
classes.add((Class<? extends T>)clazz);
|
||||
}
|
||||
});
|
||||
return Collections.unmodifiableSet(classes);
|
||||
|
@ -9,11 +9,10 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
|
||||
public class TimeUtils
|
||||
{
|
||||
public static String TIMEZONE = Plex.get().config.getString("server.timezone");
|
||||
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 final List<String> timeUnits = new ArrayList<>()
|
||||
@ -26,6 +25,7 @@ public class TimeUtils
|
||||
add("mo");
|
||||
add("y");
|
||||
}};
|
||||
public static String TIMEZONE = Plex.get().config.getString("server.timezone");
|
||||
|
||||
private static int parseInteger(String s) throws NumberFormatException
|
||||
{
|
||||
|
@ -38,7 +38,8 @@ public class UpdateChecker implements PlexBase
|
||||
* > 0 = Number of commits behind
|
||||
*/
|
||||
private final String DOWNLOAD_PAGE = "https://ci.plex.us.org/job/";
|
||||
private String branch = plugin.config.getString("update_branch");
|
||||
private final String REPO = plugin.config.getString("update_repo");
|
||||
private String BRANCH = plugin.config.getString("update_branch");
|
||||
private int distance = -4;
|
||||
|
||||
// Adapted from Paper
|
||||
@ -46,7 +47,7 @@ public class UpdateChecker implements PlexBase
|
||||
{
|
||||
try
|
||||
{
|
||||
HttpURLConnection connection = (HttpURLConnection) new URL("https://api.github.com/repos/" + repo + "/compare/" + branch + "..." + hash).openConnection();
|
||||
HttpURLConnection connection = (HttpURLConnection)new URL("https://api.github.com/repos/" + repo + "/compare/" + branch + "..." + hash).openConnection();
|
||||
connection.connect();
|
||||
if (connection.getResponseCode() == HttpURLConnection.HTTP_NOT_FOUND)
|
||||
{
|
||||
@ -85,15 +86,15 @@ public class UpdateChecker implements PlexBase
|
||||
// If verbose is 2, it will display all messages
|
||||
public boolean getUpdateStatusMessage(CommandSender sender, boolean cached, int verbosity)
|
||||
{
|
||||
if (branch == null)
|
||||
if (BRANCH == null)
|
||||
{
|
||||
PlexLog.error("You did not specify a branch to use for update checking. Defaulting to master.");
|
||||
branch = "master";
|
||||
BRANCH = "master";
|
||||
}
|
||||
// If it's -4, it hasn't checked for updates yet
|
||||
if (distance == -4)
|
||||
{
|
||||
distance = fetchDistanceFromGitHub("plexusorg/Plex", branch, BuildInfo.getHead());
|
||||
distance = fetchDistanceFromGitHub(REPO, BRANCH, BuildInfo.getHead());
|
||||
PlexLog.debug("Never checked for updates, checking now...");
|
||||
}
|
||||
else
|
||||
@ -101,7 +102,7 @@ public class UpdateChecker implements PlexBase
|
||||
// If the request isn't asked to be cached, fetch it
|
||||
if (!cached)
|
||||
{
|
||||
distance = fetchDistanceFromGitHub("plexusorg/Plex", branch, BuildInfo.getHead());
|
||||
distance = fetchDistanceFromGitHub(REPO, BRANCH, BuildInfo.getHead());
|
||||
PlexLog.debug("We have checked for updates before, but this request was not asked to be cached.");
|
||||
}
|
||||
else
|
||||
@ -141,7 +142,7 @@ public class UpdateChecker implements PlexBase
|
||||
if (verbosity >= 1)
|
||||
{
|
||||
sender.sendMessage(Component.text("Plex is not up to date!", NamedTextColor.RED));
|
||||
sender.sendMessage(Component.text("Download a new version at: " + DOWNLOAD_PAGE).color(NamedTextColor.RED));
|
||||
sender.sendMessage(Component.text("Download a new version at: " + DOWNLOAD_PAGE + "Plex").color(NamedTextColor.RED));
|
||||
sender.sendMessage(Component.text("Or run: /plex update").color(NamedTextColor.RED));
|
||||
}
|
||||
return true;
|
||||
@ -155,7 +156,7 @@ public class UpdateChecker implements PlexBase
|
||||
AtomicReference<String> url = new AtomicReference<>(DOWNLOAD_PAGE + name);
|
||||
if (!module)
|
||||
{
|
||||
url.set(url.get() + "/job/" + branch);
|
||||
url.set(url.get() + "/job/" + BRANCH);
|
||||
}
|
||||
PlexLog.debug(url.toString());
|
||||
HttpGet get = new HttpGet(url + "/lastSuccessfulBuild/api/json");
|
||||
|
@ -17,7 +17,7 @@ public class WebUtils
|
||||
try
|
||||
{
|
||||
URL u = new URL(url);
|
||||
HttpURLConnection connection = (HttpURLConnection) u.openConnection();
|
||||
HttpURLConnection connection = (HttpURLConnection)u.openConnection();
|
||||
connection.setRequestMethod("GET");
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String line;
|
||||
@ -39,13 +39,13 @@ public class WebUtils
|
||||
public static UUID getFromName(String name)
|
||||
{
|
||||
JSONObject profile;
|
||||
profile = (JSONObject) simpleGET("https://api.ashcon.app/mojang/v2/user/" + name);
|
||||
profile = (JSONObject)simpleGET("https://api.ashcon.app/mojang/v2/user/" + name);
|
||||
if (profile == null)
|
||||
{
|
||||
PlexLog.error("Profile from Ashcon API returned null!");
|
||||
return null;
|
||||
}
|
||||
String uuidString = (String) profile.get("uuid");
|
||||
String uuidString = (String)profile.get("uuid");
|
||||
return UUID.fromString(uuidString);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ public class SafeMiniMessage
|
||||
public static class SafeMiniMessageTagResolver implements TagResolver
|
||||
{
|
||||
private static final TagResolver STANDARD_RESOLVER = TagResolver.standard();
|
||||
private static final List<String> IGNORED_TAGS = ImmutableList.of("obfuscated", "obf", "br", "newline");
|
||||
private static final List<String> IGNORED_TAGS = ImmutableList.of("obfuscated", "obf", "br", "newline", "lang", "key");
|
||||
|
||||
@Override
|
||||
public @Nullable Tag resolve(@NotNull String name, @NotNull ArgumentQueue arguments, @NotNull Context ctx) throws ParsingException
|
||||
|
69
server/src/main/java/dev/plex/util/redis/MessageUtil.java
Normal file
69
server/src/main/java/dev/plex/util/redis/MessageUtil.java
Normal file
@ -0,0 +1,69 @@
|
||||
package dev.plex.util.redis;
|
||||
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.google.gson.Gson;
|
||||
import dev.plex.Plex;
|
||||
import dev.plex.util.PlexLog;
|
||||
import dev.plex.util.PlexUtils;
|
||||
import dev.plex.util.minimessage.SafeMiniMessage;
|
||||
import java.util.UUID;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import redis.clients.jedis.JedisPubSub;
|
||||
import static dev.plex.util.PlexUtils.messageComponent;
|
||||
|
||||
public class MessageUtil {
|
||||
private static final Gson GSON = new Gson();
|
||||
private static JedisPubSub SUBSCRIBER;
|
||||
|
||||
public static void subscribe() {
|
||||
PlexLog.debug("Subscribing");
|
||||
SUBSCRIBER = new JedisPubSub() {
|
||||
@Override
|
||||
public void onMessage(String channel, String message) {
|
||||
try {
|
||||
JSONObject object = new JSONObject(message);
|
||||
if (channel.equalsIgnoreCase("staffchat")) {
|
||||
UUID[] ignore = GSON.fromJson(object.getString("ignore"), new TypeToken<UUID[]>(){}.getType());
|
||||
String sender = object.getString("sender").isEmpty() ? "CONSOLE": object.getString("sender");
|
||||
PlexUtils.adminChat(sender, object.getString("message"), ignore);
|
||||
String[] server = object.getString("server").split(":");
|
||||
if (!Bukkit.getServer().getIp().equalsIgnoreCase(server[0]) || Bukkit.getServer().getPort() != Integer.parseInt(server[1])) {
|
||||
Plex.get().getServer().getConsoleSender().sendMessage(messageComponent("adminChatFormat", sender, object.getString("message")));
|
||||
}
|
||||
}
|
||||
} catch (JSONException ignored) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSubscribe(String channel, int subscribedChannels)
|
||||
{
|
||||
PlexLog.debug("Subscribed to {0}", channel);
|
||||
}
|
||||
};
|
||||
// SUBSCRIBER.subscribe("staffchat", "chat");
|
||||
Plex.get().getRedisConnection().runAsync(jedis -> {
|
||||
jedis.subscribe(SUBSCRIBER, "staffchat", "chat");
|
||||
});
|
||||
}
|
||||
|
||||
public static void sendStaffChat(CommandSender sender, Component message, UUID... ignore) {
|
||||
if (!Plex.get().getRedisConnection().isEnabled() || Plex.get().getRedisConnection().getJedis() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String miniMessage = SafeMiniMessage.mmSerialize(message);
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("sender", sender instanceof Player player ? player.getName() : "");
|
||||
object.put("message", miniMessage);
|
||||
object.put("ignore", GSON.toJson(ignore));
|
||||
object.put("server", String.format("%s:%s", Bukkit.getServer().getIp(), Bukkit.getServer().getPort()));
|
||||
Plex.get().getRedisConnection().getJedis().publish("staffchat", object.toString());
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@ public abstract class NoiseChunkGenerator extends CustomChunkGenerator
|
||||
{
|
||||
for (int zz = 0; zz < 16; zz++)
|
||||
{
|
||||
height = (int) generator.noise(options.getX(), options.getY(), options.getFrequency(), options.getAmplitude(), options.isNormalized());
|
||||
height = (int)generator.noise(options.getX(), options.getY(), options.getFrequency(), options.getAmplitude(), options.isNormalized());
|
||||
createLoopChunkData(xx, height, zz, chunk);
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public abstract class OctaveChunkGenerator extends CustomChunkGenerator
|
||||
{
|
||||
for (int zz = 0; zz < 16; zz++)
|
||||
{
|
||||
height = (int) generator.noise(options.getX(), options.getY(), options.getFrequency(), options.getAmplitude(), options.isNormalized());
|
||||
height = (int)generator.noise(options.getX(), options.getY(), options.getFrequency(), options.getAmplitude(), options.isNormalized());
|
||||
createLoopChunkData(xx, height, zz, chunk);
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ chat:
|
||||
|
||||
# Should Plex use a "true op" system with ranks or only permission nodes
|
||||
# Options are "permissions" or "ranks"
|
||||
# NOTE: If you are using a proxy such as BungeeCord or Velocity, it is highly recommended to use permissions
|
||||
system: ranks
|
||||
|
||||
data:
|
||||
@ -169,8 +170,9 @@ global_gamerules:
|
||||
worlds:
|
||||
flatlands:
|
||||
name: "Flatlands"
|
||||
permission: "plex.world.flatlands"
|
||||
noEdit: "&cYou can't edit this world!"
|
||||
modification:
|
||||
permission: "plex.world.flatlands.modify"
|
||||
message: "<red>You do not have permission to modify this world."
|
||||
gameRules:
|
||||
# The gamerules here override the global gamerules
|
||||
- "doWeatherCycle;false"
|
||||
@ -182,10 +184,18 @@ worlds:
|
||||
bedrock: 1
|
||||
adminworld:
|
||||
name: "Admin World"
|
||||
permission: "plex.world.adminworld"
|
||||
entry:
|
||||
permission: "plex.world.adminworld.enter"
|
||||
# Minimum rank requirement
|
||||
requiredLevels:
|
||||
- "Rank.ADMIN" # Minimum rank requirement
|
||||
noEdit: "&cYou can't edit this world!"
|
||||
- "Rank.ADMIN"
|
||||
message: "<red>You do not have permission to enter this world."
|
||||
modification:
|
||||
permission: "plex.world.adminworld.modify"
|
||||
# Minimum rank requirement
|
||||
requiredLevels:
|
||||
- "Rank.ADMIN"
|
||||
message: "<red>You do not have permission to modify this world."
|
||||
gameRules:
|
||||
- "doWeatherCycle;false"
|
||||
- "doDaylightCycle;false"
|
||||
@ -196,10 +206,17 @@ worlds:
|
||||
bedrock: 1
|
||||
masterbuilderworld:
|
||||
name: "MasterBuilder World"
|
||||
permission: "plex.world.masterbuilderworld"
|
||||
entry:
|
||||
permission: "plex.world.masterbuilderworld.enter"
|
||||
requiredLevels:
|
||||
- "Title.MASTER_BUILDER" # Title has no "minimum", so this will have to be their title
|
||||
noEdit: "&cYou can't edit this world!"
|
||||
- "Rank.OP"
|
||||
message: "<red>You do not have permission to enter this world."
|
||||
modification:
|
||||
permission: "plex.world.masterbuilderworld.modify"
|
||||
requiredLevels:
|
||||
# Title has no "minimum", so this will have to be their title
|
||||
- "Title.MASTER_BUILDER"
|
||||
message: "<red><red>You do not have permission to modify this world."
|
||||
gameRules:
|
||||
- "doWeatherCycle;false"
|
||||
- "doDaylightCycle;false"
|
||||
@ -209,8 +226,11 @@ worlds:
|
||||
stone: 16
|
||||
bedrock: 1
|
||||
|
||||
# If you are running a custom fork of Plex, you may wish to check for updates from a different repository.
|
||||
update_repo: "plexusorg/Plex"
|
||||
|
||||
# What branch should Plex fetch updates from?
|
||||
update_branch: master
|
||||
update_branch: "master"
|
||||
|
||||
# Additional logging for debugging
|
||||
debug: false
|
@ -124,6 +124,8 @@ disabled: "<gray>disabled."
|
||||
# 0 - The admin / staff member
|
||||
# 1 - The message
|
||||
adminChatFormat: '<dark_gray>[<blue>AdminChat<dark_gray>] <dark_red>{0} <gray>» <gold>{1}'
|
||||
# 0 - Whether it was toggled on or off
|
||||
adminChatToggled: '<gray>AdminChat was toggled {0}'
|
||||
# 0 - Maximum length, configured in config.yml
|
||||
maximumPrefixLength: "<red>The maximum length for a tag may only be {0}."
|
||||
prefixCleared: "<aqua>Your prefix has been cleared."
|
||||
|
@ -8,3 +8,6 @@ fluidspread: true
|
||||
|
||||
# Should drops be enabled?
|
||||
drops: true
|
||||
|
||||
# Should redstone be enabled?
|
||||
redstone: true
|
@ -1,11 +1,4 @@
|
||||
pluginManagement {
|
||||
repositories {
|
||||
maven { url = uri("https://nexus.telesphoreo.me/repository/gradle-plugins/") }
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
rootProject.name = "Plex"
|
||||
include 'api'
|
||||
include 'server'
|
||||
include 'proxy'
|
||||
|
||||
|
Reference in New Issue
Block a user