diff --git a/.idea/codeStyles/Plexus_Code_Style.xml b/.idea/codeStyles/Plexus_Code_Style.xml deleted file mode 100644 index a7db3e4..0000000 --- a/.idea/codeStyles/Plexus_Code_Style.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index df773a2..0000000 --- a/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index a6199f6..0000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,24 +0,0 @@ -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. \ No newline at end of file diff --git a/README.md b/README.md index db367d2..3f1635b 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,2 @@ -# Module-LibsDisguises [![Build Status](https://ci.plex.us.org/job/Module-LibsDisguises/badge/icon)](https://ci.plex.us.org/job/Module-LibsDisguises/) +# Module-LibsDisguises LibsDisguises module for Plex diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..ddde6df --- /dev/null +++ b/build.gradle @@ -0,0 +1,50 @@ +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 + } +} diff --git a/build.gradle.kts b/build.gradle.kts deleted file mode 100644 index b5902be..0000000 --- a/build.gradle.kts +++ /dev/null @@ -1,71 +0,0 @@ -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/") - } - - maven { - url = uri("https://repo.codemc.io/repository/maven-releases/") - } - - mavenCentral() -} - -dependencies { - compileOnly("org.projectlombok:lombok:1.18.34") - annotationProcessor("org.projectlombok:lombok:1.18.34") - compileOnly("io.papermc.paper:paper-api:1.21.1-R0.1-SNAPSHOT") - compileOnly("dev.plex:server:1.5-SNAPSHOT") - implementation("me.libraryaddict.disguises:libsdisguises:10.0.44-SNAPSHOT") - compileOnly("com.github.retrooper:packetevents-spigot:2.5.0") - -} - -group = "dev.plex" -version = "1.5-SNAPSHOT" -description = "Module-LibsDisguises" - -java { - toolchain.languageVersion.set(JavaLanguageVersion.of(21)) -} - -publishing { - publications { - create("maven") { - from(components["java"]) - } - } -} - -tasks.getByName("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() - } -} \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index d64cd49..41d9927 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index df97d72..00e33ed 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,7 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip -networkTimeout=10000 -validateDistributionUrl=true +distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index 1aa94a4..1b6c787 100755 --- a/gradlew +++ b/gradlew @@ -55,7 +55,7 @@ # Darwin, MinGW, and NonStop. # # (3) This script is generated from the Groovy template -# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# https://github.com/gradle/gradle/blob/master/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,11 +80,13 @@ do esac done -# This is normally unused -# shellcheck disable=SC2034 +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +APP_NAME="Gradle" APP_BASE_NAME=${0##*/} -# 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 + +# 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"' # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -131,29 +133,22 @@ location of your Java installation." fi else JAVACMD=java - 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. + which java >/dev/null 2>&1 || 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 @@ -198,15 +193,11 @@ if "$cygwin" || "$msys" ; then done fi - -# 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. +# 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. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ @@ -214,12 +205,6 @@ 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. diff --git a/gradlew.bat b/gradlew.bat index 6689b85..ac1b06f 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -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,8 +25,7 @@ if "%OS%"=="Windows_NT" setlocal set DIRNAME=%~dp0 -if "%DIRNAME%"=="" set DIRNAME=. -@rem This is normally unused +if "%DIRNAME%" == "" set DIRNAME=. set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% @@ -41,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -76,15 +75,13 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar :end @rem End local scope for the variables with windows NT shell -if %ERRORLEVEL% equ 0 goto mainEnd +if "%ERRORLEVEL%"=="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! -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% +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 :mainEnd if "%OS%"=="Windows_NT" endlocal diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..e07581b --- /dev/null +++ b/settings.gradle @@ -0,0 +1,2 @@ +rootProject.name = 'Module-LibsDisguises' + diff --git a/settings.gradle.kts b/settings.gradle.kts deleted file mode 100644 index afee02a..0000000 --- a/settings.gradle.kts +++ /dev/null @@ -1,2 +0,0 @@ -rootProject.name = "Module-LibsDisguises" - diff --git a/src/main/java/dev/plex/LibsDisguises.java b/src/main/java/dev/plex/LibsDisguises.java index 2bcc0f0..7aa2670 100644 --- a/src/main/java/dev/plex/LibsDisguises.java +++ b/src/main/java/dev/plex/LibsDisguises.java @@ -4,22 +4,14 @@ 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()); diff --git a/src/main/java/dev/plex/command/DisguiseToggleCMD.java b/src/main/java/dev/plex/command/DisguiseToggleCMD.java index 2685e26..af10e75 100644 --- a/src/main/java/dev/plex/command/DisguiseToggleCMD.java +++ b/src/main/java/dev/plex/command/DisguiseToggleCMD.java @@ -4,8 +4,7 @@ import dev.plex.LibsDisguises; import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandPermissions; import dev.plex.listener.UndisguiseEvent; -import java.util.Collections; -import java.util.List; +import dev.plex.rank.enums.Rank; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Bukkit; @@ -15,7 +14,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @CommandParameters(name = "disguisetoggle", description = "Toggle LibsDisguises", aliases = "dtoggle") -@CommandPermissions(permission = "plex.libsdisguises.disguisetoggle") +@CommandPermissions(level = Rank.ADMIN, permission = "plex.libsdisguises.disguisetoggle") public class DisguiseToggleCMD extends PlexCommand { @Override @@ -29,10 +28,4 @@ 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 smartTabComplete(@NotNull CommandSender sender, @NotNull String alias, @NotNull String[] args) throws IllegalArgumentException - { - return Collections.emptyList(); - } } diff --git a/src/main/java/dev/plex/command/UndisguiseAllCMD.java b/src/main/java/dev/plex/command/UndisguiseAllCMD.java index 6872d2a..4ca1fbf 100644 --- a/src/main/java/dev/plex/command/UndisguiseAllCMD.java +++ b/src/main/java/dev/plex/command/UndisguiseAllCMD.java @@ -3,8 +3,7 @@ package dev.plex.command; import dev.plex.command.annotation.CommandParameters; import dev.plex.command.annotation.CommandPermissions; import dev.plex.listener.UndisguiseEvent; -import java.util.Collections; -import java.util.List; +import dev.plex.rank.enums.Rank; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Bukkit; @@ -14,7 +13,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @CommandParameters(name = "undisguiseall", usage = "/ [-a]", description = "Undisguise all players", aliases = "undisall,uall") -@CommandPermissions(permission = "plex.libsdisguises.undisguiseall") +@CommandPermissions(level = Rank.ADMIN, permission = "plex.libsdisguises.undisguiseall") public class UndisguiseAllCMD extends PlexCommand { @Override @@ -34,18 +33,4 @@ public class UndisguiseAllCMD extends PlexCommand } return usage(); } - - @Override - public @NotNull List 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(); - } } diff --git a/src/main/java/dev/plex/listener/DisguiseListener.java b/src/main/java/dev/plex/listener/DisguiseListener.java index e3fa9b0..42a6abe 100644 --- a/src/main/java/dev/plex/listener/DisguiseListener.java +++ b/src/main/java/dev/plex/listener/DisguiseListener.java @@ -7,18 +7,8 @@ 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; @@ -30,91 +20,6 @@ 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 commands = new ArrayList<>(); @EventHandler @@ -129,9 +34,19 @@ public class DisguiseListener extends PlexListener else { PlexPlayer plexPlayer = DataUtils.getPlayer(player.getUniqueId()); - if (!player.hasPermission("plex.libsdisguises.bypass")) + if (plugin.getSystem().equalsIgnoreCase("ranks")) { - DisguiseAPI.undisguiseToAll(player); + if (!plugin.getRankManager().isAdmin(plexPlayer)) + { + DisguiseAPI.undisguiseToAll(player); + } + } + else if (plugin.getSystem().equalsIgnoreCase("permissions")) + { + if (!player.hasPermission("plex.libsdisguises.bypass")) + { + DisguiseAPI.undisguiseToAll(player); + } } } } diff --git a/src/main/resources/module.yml b/src/main/resources/module.yml index 74fe94c..1b2d7c5 100644 --- a/src/main/resources/module.yml +++ b/src/main/resources/module.yml @@ -1,4 +1,4 @@ -name: Module-LibsDisguises +name: LibsDisguises main: dev.plex.LibsDisguises description: Control LibsDisguises with Plex -version: 1.5-SNAPSHOT \ No newline at end of file +version: 1.0 \ No newline at end of file