mirror of
https://github.com/plexusorg/Module-LibsDisguises.git
synced 2024-09-28 03:14:48 +00:00
Compare commits
23 commits
Author | SHA1 | Date | |
---|---|---|---|
cad134f9d1 | |||
c1c1525d1d | |||
7286ec2523 | |||
54e003963a | |||
c9b047fdb2 | |||
30757aab94 | |||
e4d3839a1d | |||
572c8cd2eb | |||
da2397cb41 | |||
daa319c9a7 | |||
d13b8f86d2 | |||
68b31f19f2 | |||
a4df61e317 | |||
e54daca7dc | |||
af28e37be1 | |||
b3fb0f01f3 | |||
7bdffd6c0d | |||
8d01678fae | |||
7b28553128 | |||
56d1d97c97 | |||
c486df94a8 | |||
4fa0085192 | |||
4afe2e7155 |
49
.idea/codeStyles/Plexus_Code_Style.xml
Normal file
49
.idea/codeStyles/Plexus_Code_Style.xml
Normal file
|
@ -0,0 +1,49 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<code_scheme name="Plexus Code Style" version="1">
|
||||
<JavaCodeStyleSettings>
|
||||
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="20" />
|
||||
<option name="IMPORT_LAYOUT_TABLE">
|
||||
<value>
|
||||
<package name="" withSubpackages="true" static="false" />
|
||||
<package name="" withSubpackages="true" static="true" />
|
||||
</value>
|
||||
</option>
|
||||
</JavaCodeStyleSettings>
|
||||
<JetCodeStyleSettings>
|
||||
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||
<value>
|
||||
<package name="java.util" alias="false" withSubpackages="false" />
|
||||
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
||||
<package name="io.ktor" alias="false" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
<option name="PACKAGES_IMPORT_LAYOUT">
|
||||
<value>
|
||||
<package name="" alias="false" withSubpackages="true" />
|
||||
<package name="java" alias="false" withSubpackages="true" />
|
||||
<package name="javax" alias="false" withSubpackages="true" />
|
||||
<package name="kotlin" alias="false" withSubpackages="true" />
|
||||
<package name="" alias="true" withSubpackages="true" />
|
||||
</value>
|
||||
</option>
|
||||
</JetCodeStyleSettings>
|
||||
<codeStyleSettings language="JAVA">
|
||||
<option name="BRACE_STYLE" value="2" />
|
||||
<option name="CLASS_BRACE_STYLE" value="2" />
|
||||
<option name="METHOD_BRACE_STYLE" value="2" />
|
||||
<option name="LAMBDA_BRACE_STYLE" value="2" />
|
||||
<option name="ELSE_ON_NEW_LINE" value="true" />
|
||||
<option name="WHILE_ON_NEW_LINE" value="true" />
|
||||
<option name="CATCH_ON_NEW_LINE" value="true" />
|
||||
<option name="FINALLY_ON_NEW_LINE" value="true" />
|
||||
<option name="SPACE_AFTER_TYPE_CAST" value="true" />
|
||||
<option name="IF_BRACE_FORCE" value="3" />
|
||||
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
||||
<option name="WHILE_BRACE_FORCE" value="3" />
|
||||
<option name="FOR_BRACE_FORCE" value="3" />
|
||||
<option name="BLANK_LINES_AFTER_CLASS_HEADER" value="0" />
|
||||
<option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="1" />
|
||||
<option name="KEEP_FIRST_COLUMN_COMMENT" value="false" />
|
||||
</codeStyleSettings>
|
||||
</code_scheme>
|
||||
</component>
|
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
Normal file
|
@ -0,0 +1,5 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Plexus Code Style" />
|
||||
</state>
|
||||
</component>
|
24
CONTRIBUTING.md
Normal file
24
CONTRIBUTING.md
Normal file
|
@ -0,0 +1,24 @@
|
|||
For those who are wanting to contribute, we fully encourage doing so. There are a few rules we require following when contributing however.
|
||||
|
||||
## Steps
|
||||
1. Make an issue and get feedback. It's important to know if your idea will be accepted before writing any code.
|
||||
- If it is a feature request, describe the feature and be extremely specific.
|
||||
- If it is a bug report, ensure you include how to reproduce the bug and the expected outcome
|
||||
- If it is an enhancement, describe your proposed changes. Ensure you are extremely specific.
|
||||
2. Fork this project
|
||||
3. Create a new branch that describes the new feature, enhancement, or bug fix. For example, this is good: `feature/add-xyz`. This is bad: `fix-this-lol`.
|
||||
4. Write the code that addresses your change.
|
||||
- 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 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.
|
||||
|
||||
## Requirements for a PR
|
||||
- The issue must be marked as approved
|
||||
- It must only address each specific issue. Don't make one PR for multiple issues.
|
||||
- Your PR must compile and work. If it does not compile or work, your PR will most likely be rejected.
|
||||
|
||||
## Code requirements
|
||||
- Most importantly, your code must be efficient. Your pull request may be rejected if your code is deemed inefficient or sloppy.
|
||||
- Do not repeat yourself. Create functions as needed if you're using large blocks of code over and over again.
|
||||
- Do not use an excessive amount of commits when making your PR. It makes the master branch look messy.
|
||||
- Your code must be consistent with Plex's codebase. If a function already exists, use it.
|
|
@ -1,2 +1,2 @@
|
|||
# Module-LibsDisguises
|
||||
# Module-LibsDisguises [![Build Status](https://ci.plex.us.org/job/Module-LibsDisguises/badge/icon)](https://ci.plex.us.org/job/Module-LibsDisguises/)
|
||||
LibsDisguises module for Plex
|
||||
|
|
50
build.gradle
50
build.gradle
|
@ -1,50 +0,0 @@
|
|||
plugins {
|
||||
id "java"
|
||||
id "maven-publish"
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url = uri("https://papermc.io/repo/repository/maven-public/")
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri("https://nexus.telesphoreo.me/repository/plex")
|
||||
}
|
||||
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "org.projectlombok:lombok:1.18.22"
|
||||
annotationProcessor "org.projectlombok:lombok:1.18.22"
|
||||
compileOnly "io.papermc.paper:paper-api:1.18.2-R0.1-SNAPSHOT"
|
||||
compileOnly "dev.plex:Plex:0.8"
|
||||
implementation "LibsDisguises:LibsDisguises:10.0.27"
|
||||
}
|
||||
|
||||
group = "dev.plex"
|
||||
version = "1.0"
|
||||
description = "LibsDisguises"
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
from(components.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
tasks {
|
||||
javadoc {
|
||||
options.memberLevel = JavadocMemberLevel.PRIVATE
|
||||
}
|
||||
}
|
65
build.gradle.kts
Normal file
65
build.gradle.kts
Normal file
|
@ -0,0 +1,65 @@
|
|||
plugins {
|
||||
java
|
||||
`maven-publish`
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url = uri("https://repo.papermc.io/repository/maven-public/")
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri("https://nexus.telesphoreo.me/repository/plex/")
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri("https://repo.md-5.net/content/groups/public")
|
||||
}
|
||||
|
||||
maven {
|
||||
url = uri("https://repo.dmulloy2.net/repository/public/")
|
||||
}
|
||||
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("org.projectlombok:lombok:1.18.30")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.30")
|
||||
compileOnly("io.papermc.paper:paper-api:1.20.4-R0.1-SNAPSHOT")
|
||||
compileOnly("dev.plex:server:1.4-SNAPSHOT")
|
||||
implementation("LibsDisguises:LibsDisguises:10.0.37")
|
||||
}
|
||||
|
||||
group = "dev.plex"
|
||||
version = "1.4-SNAPSHOT"
|
||||
description = "Module-LibsDisguises"
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("maven") {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.getByName<Jar>("jar") {
|
||||
archiveBaseName.set("Module-LibsDisguises")
|
||||
archiveVersion.set("")
|
||||
}
|
||||
|
||||
tasks {
|
||||
compileJava {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
}
|
||||
javadoc {
|
||||
options.encoding = Charsets.UTF_8.name()
|
||||
}
|
||||
processResources {
|
||||
filteringCharset = Charsets.UTF_8.name()
|
||||
}
|
||||
}
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
|
@ -1,5 +1,7 @@
|
|||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
|
41
gradlew
vendored
41
gradlew
vendored
|
@ -55,7 +55,7 @@
|
|||
# Darwin, MinGW, and NonStop.
|
||||
#
|
||||
# (3) This script is generated from the Groovy template
|
||||
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
|
||||
# within the Gradle project.
|
||||
#
|
||||
# You can find Gradle at https://github.com/gradle/gradle/.
|
||||
|
@ -80,13 +80,11 @@ do
|
|||
esac
|
||||
done
|
||||
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
|
||||
|
||||
APP_NAME="Gradle"
|
||||
# This is normally unused
|
||||
# shellcheck disable=SC2034
|
||||
APP_BASE_NAME=${0##*/}
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD=maximum
|
||||
|
@ -133,22 +131,29 @@ location of your Java installation."
|
|||
fi
|
||||
else
|
||||
JAVACMD=java
|
||||
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
if ! command -v java >/dev/null 2>&1
|
||||
then
|
||||
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
||||
Please set the JAVA_HOME variable in your environment to match the
|
||||
location of your Java installation."
|
||||
fi
|
||||
fi
|
||||
|
||||
# Increase the maximum file descriptors if we can.
|
||||
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
|
||||
case $MAX_FD in #(
|
||||
max*)
|
||||
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
MAX_FD=$( ulimit -H -n ) ||
|
||||
warn "Could not query maximum file descriptor limit"
|
||||
esac
|
||||
case $MAX_FD in #(
|
||||
'' | soft) :;; #(
|
||||
*)
|
||||
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
|
||||
# shellcheck disable=SC2039,SC3045
|
||||
ulimit -n "$MAX_FD" ||
|
||||
warn "Could not set maximum file descriptor limit to $MAX_FD"
|
||||
esac
|
||||
|
@ -193,11 +198,15 @@ if "$cygwin" || "$msys" ; then
|
|||
done
|
||||
fi
|
||||
|
||||
# Collect all arguments for the java command;
|
||||
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
|
||||
# shell script including quotes and variable substitutions, so put them in
|
||||
# double quotes to make sure that they get re-expanded; and
|
||||
# * put everything else in single quotes, so that it's not re-expanded.
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Collect all arguments for the java command:
|
||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||
# and any embedded shellness will be escaped.
|
||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||
# treated as '${Hostname}' itself on the command line.
|
||||
|
||||
set -- \
|
||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||
|
@ -205,6 +214,12 @@ set -- \
|
|||
org.gradle.wrapper.GradleWrapperMain \
|
||||
"$@"
|
||||
|
||||
# Stop when "xargs" is not available.
|
||||
if ! command -v xargs >/dev/null 2>&1
|
||||
then
|
||||
die "xargs is not available"
|
||||
fi
|
||||
|
||||
# Use "xargs" to parse quoted args.
|
||||
#
|
||||
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
|
||||
|
|
15
gradlew.bat
vendored
15
gradlew.bat
vendored
|
@ -14,7 +14,7 @@
|
|||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
|
@ -25,7 +25,8 @@
|
|||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
if "%DIRNAME%"=="" set DIRNAME=.
|
||||
@rem This is normally unused
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
|
@ -40,7 +41,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
|
|||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto execute
|
||||
if %ERRORLEVEL% equ 0 goto execute
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
|
@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
|||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
if %ERRORLEVEL% equ 0 goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
set EXIT_CODE=%ERRORLEVEL%
|
||||
if %EXIT_CODE% equ 0 set EXIT_CODE=1
|
||||
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
|
||||
exit /b %EXIT_CODE%
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
rootProject.name = 'Module-LibsDisguises'
|
||||
|
2
settings.gradle.kts
Normal file
2
settings.gradle.kts
Normal file
|
@ -0,0 +1,2 @@
|
|||
rootProject.name = "Module-LibsDisguises"
|
||||
|
|
@ -4,14 +4,22 @@ import dev.plex.command.DisguiseToggleCMD;
|
|||
import dev.plex.command.UndisguiseAllCMD;
|
||||
import dev.plex.listener.DisguiseListener;
|
||||
import dev.plex.module.PlexModule;
|
||||
import dev.plex.util.PlexLog;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
public class LibsDisguises extends PlexModule
|
||||
{
|
||||
public static boolean enabled = true;
|
||||
DisguiseListener disguiseListener;
|
||||
|
||||
@Override
|
||||
public void enable()
|
||||
{
|
||||
if (!Bukkit.getPluginManager().isPluginEnabled("LibsDisguises"))
|
||||
{
|
||||
PlexLog.error("The Plex-LibsDisguises module requires the LibsDisguises plugin to work.");
|
||||
return;
|
||||
}
|
||||
registerCommand(new DisguiseToggleCMD());
|
||||
registerCommand(new UndisguiseAllCMD());
|
||||
registerListener(new DisguiseListener());
|
||||
|
|
|
@ -4,7 +4,8 @@ import dev.plex.LibsDisguises;
|
|||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.listener.UndisguiseEvent;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -14,7 +15,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "disguisetoggle", description = "Toggle LibsDisguises", aliases = "dtoggle")
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.libsdisguises.disguisetoggle")
|
||||
@CommandPermissions(permission = "plex.libsdisguises.disguisetoggle")
|
||||
public class DisguiseToggleCMD extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
|
@ -28,4 +29,10 @@ public class DisguiseToggleCMD extends PlexCommand
|
|||
Bukkit.broadcast(Component.text(commandSender.getName() + " - " + (LibsDisguises.enabled ? "Enabling LibsDisguises" : "Disabling LibsDisguises")).color((LibsDisguises.enabled ? NamedTextColor.AQUA : NamedTextColor.RED)));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,8 @@ package dev.plex.command;
|
|||
import dev.plex.command.annotation.CommandParameters;
|
||||
import dev.plex.command.annotation.CommandPermissions;
|
||||
import dev.plex.listener.UndisguiseEvent;
|
||||
import dev.plex.rank.enums.Rank;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -13,7 +14,7 @@ import org.jetbrains.annotations.NotNull;
|
|||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@CommandParameters(name = "undisguiseall", usage = "/<command> [-a]", description = "Undisguise all players", aliases = "undisall,uall")
|
||||
@CommandPermissions(level = Rank.ADMIN, permission = "plex.libsdisguises.undisguiseall")
|
||||
@CommandPermissions(permission = "plex.libsdisguises.undisguiseall")
|
||||
public class UndisguiseAllCMD extends PlexCommand
|
||||
{
|
||||
@Override
|
||||
|
@ -33,4 +34,18 @@ public class UndisguiseAllCMD extends PlexCommand
|
|||
}
|
||||
return usage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException
|
||||
{
|
||||
if (silentCheckPermission(sender, this.getPermission()))
|
||||
{
|
||||
if (args.length == 1)
|
||||
{
|
||||
return Collections.singletonList("-a");
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,18 @@ import dev.plex.util.PlexLog;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import me.libraryaddict.disguise.DisguiseAPI;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AreaEffectCloudWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.EnderDragonWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PhantomWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.SlimeWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.WitherWatcher;
|
||||
import me.libraryaddict.disguise.events.DisguiseEvent;
|
||||
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.serializer.plain.PlainTextComponentSerializer;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.PluginCommandYamlParser;
|
||||
|
@ -20,6 +30,91 @@ import org.bukkit.plugin.Plugin;
|
|||
|
||||
public class DisguiseListener extends PlexListener
|
||||
{
|
||||
private static float safeYMod(float f)
|
||||
{
|
||||
return Math.max(-256f, Math.min(256f, f));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDisguiseEvent(DisguiseEvent event)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
PlexPlayer plexPlayer = null;
|
||||
if (event.getCommandSender() instanceof Player player)
|
||||
{
|
||||
plexPlayer = DataUtils.getPlayer(player.getUniqueId());
|
||||
}
|
||||
if (event.getDisguise().getType() == DisguiseType.FISHING_HOOK)
|
||||
{
|
||||
event.getCommandSender().sendMessage(Component.text("You cannot use Fishing Hook disguises").color(NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
String name = event.getDisguise().getWatcher().getCustomName();
|
||||
if (name != null)
|
||||
{
|
||||
int noColorLen = PlainTextComponentSerializer.plainText().serialize(LegacyComponentSerializer.legacySection().deserialize(name)).length();
|
||||
// each color code counts as one char rather than two, for flexibility
|
||||
if (((name.length() - noColorLen) / 2) + noColorLen > 32)
|
||||
{
|
||||
event.getCommandSender().sendMessage(Component.text("Your disguise name is too long").color(NamedTextColor.RED));
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (event.getDisguise().getWatcher() instanceof EnderDragonWatcher watcher && watcher.getPhase() == 7)
|
||||
{
|
||||
watcher.setPhase(6);
|
||||
}
|
||||
if (event.getDisguise().getWatcher() instanceof WitherWatcher watcher && watcher.getInvulnerability() > 2048)
|
||||
{
|
||||
watcher.setInvulnerability(2048);
|
||||
}
|
||||
if (event.getDisguise().isPlayerDisguise() && plexPlayer != null && !plexPlayer.getPlayer().hasPermission("plex.libsdisguises.player"))
|
||||
{
|
||||
PlayerDisguise playerDisguise = (PlayerDisguise)event.getDisguise();
|
||||
String targetName = playerDisguise.getName();
|
||||
String origName = event.getDisguised().getName();
|
||||
playerDisguise.setName(origName);
|
||||
playerDisguise.setNameVisible(true);
|
||||
playerDisguise.getWatcher().setNameYModifier(0);
|
||||
playerDisguise.setSkin(targetName);
|
||||
playerDisguise.setDisplayedInTab(false);
|
||||
playerDisguise.setTablistName(origName);
|
||||
}
|
||||
if (event.getDisguise().isHidePlayer())
|
||||
{
|
||||
event.getDisguise().setHidePlayer(false);
|
||||
}
|
||||
if (event.getDisguise().getWatcher() instanceof AreaEffectCloudWatcher watcher)
|
||||
{
|
||||
if (watcher.getRadius() > 5)
|
||||
{
|
||||
watcher.setRadius(5);
|
||||
}
|
||||
else if (watcher.getRadius() < 0)
|
||||
{
|
||||
watcher.setRadius(0);
|
||||
}
|
||||
}
|
||||
event.getDisguise().getWatcher().setNameYModifier(safeYMod(event.getDisguise().getWatcher().getNameYModifier()));
|
||||
event.getDisguise().getWatcher().setYModifier(safeYMod(event.getDisguise().getWatcher().getYModifier()));
|
||||
if (event.getDisguise().getWatcher() instanceof SlimeWatcher watcher && watcher.getSize() > 10)
|
||||
{
|
||||
watcher.setSize(10);
|
||||
}
|
||||
if (event.getDisguise().getWatcher() instanceof PhantomWatcher watcher)
|
||||
{
|
||||
if (watcher.getSize() > 20)
|
||||
{
|
||||
watcher.setSize(20);
|
||||
}
|
||||
else if (watcher.getSize() < -36)
|
||||
{
|
||||
watcher.setSize(-36);
|
||||
}
|
||||
}
|
||||
event.setCancelled(false);
|
||||
}
|
||||
|
||||
final List<Command> commands = new ArrayList<>();
|
||||
|
||||
@EventHandler
|
||||
|
@ -34,19 +129,9 @@ public class DisguiseListener extends PlexListener
|
|||
else
|
||||
{
|
||||
PlexPlayer plexPlayer = DataUtils.getPlayer(player.getUniqueId());
|
||||
if (plugin.getSystem().equalsIgnoreCase("ranks"))
|
||||
if (!player.hasPermission("plex.libsdisguises.bypass"))
|
||||
{
|
||||
if (!plugin.getRankManager().isAdmin(plexPlayer))
|
||||
{
|
||||
DisguiseAPI.undisguiseToAll(player);
|
||||
}
|
||||
}
|
||||
else if (plugin.getSystem().equalsIgnoreCase("permissions"))
|
||||
{
|
||||
if (!player.hasPermission("plex.libsdisguises.bypass"))
|
||||
{
|
||||
DisguiseAPI.undisguiseToAll(player);
|
||||
}
|
||||
DisguiseAPI.undisguiseToAll(player);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
name: LibsDisguises
|
||||
name: Module-LibsDisguises
|
||||
main: dev.plex.LibsDisguises
|
||||
description: Control LibsDisguises with Plex
|
||||
version: 1.0
|
||||
version: 1.4-SNAPSHOT
|
Loading…
Reference in a new issue