diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..6e1065fe --- /dev/null +++ b/.gitignore @@ -0,0 +1,21 @@ +.gradle +**/build/ +!src/**/build/ + +# Ignore Gradle GUI config +gradle-app.setting + +# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored) +!gradle-wrapper.jar + +# Avoid ignore Gradle wrappper properties +!gradle-wrapper.properties + +# Cache of project +.gradletasknamecache + +# Eclipse Gradle plugin generated files +# Eclipse Core +.project +# JDT-specific (Eclipse Java Development Tools) +.classpath \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 00000000..f2f4ae73 --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,51 @@ +plugins { + `java-library` +} + +subprojects { + repositories { + mavenCentral() + mavenLocal() + + maven { + url = uri("https://repo.md-5.net/content/groups/public/") + } + + maven { + url = uri("https://papermc.io/repo/repository/maven-public/") + } + + maven { + url = uri("https://mvn.lumine.io/repository/maven-public/") + } + + maven { + url = uri("https://repo.codemc.io/repository/maven-releases/") + } + + maven { + url = uri("https://repo.codemc.io/repository/maven-snapshots/") + } + } + + apply(plugin = "java-library") + + java { + sourceCompatibility = JavaVersion.VERSION_1_8 + } + + tasks.withType { + options.encoding = "UTF-8" + sourceCompatibility = "1.8" + } + + group = "me.libraryaddict.disguises" + version = "1.0-SNAPSHOT" + + dependencies { + implementation(rootProject.libs.org.spigotmc.spigot.api) + + compileOnly(rootProject.libs.org.projectlombok.lombok) + annotationProcessor(rootProject.libs.org.projectlombok.lombok) + } +} \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 00000000..697755cc --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,45 @@ +# This file was generated by the Gradle 'init' task. +# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format + +[versions] +com-mojang-authlib = "6.0.54" +commons-lang-commons-lang = "2.6" +io-netty-netty-buffer = "4.1.90.Final" +io-netty-netty-codec = "4.1.90.Final" +io-papermc-paper-paper-api = "1.20.3-R0.1-SNAPSHOT" +net-kyori-adventure-api = "4.17.0" +net-kyori-adventure-text-minimessage = "4.17.0" +net-kyori-adventure-text-serializer-gson = "4.17.0" +net-kyori-adventure-text-serializer-json = "4.17.0" +net-md-v5-bungeecord-chat = "1.16-R0.4" +org-spigotmc-spigot-latest = "1.21-R0.1-SNAPSHOT" +com-retro-packetevents-version = "2.4.0" +lombok-version = "1.18.34" +shadow-version = "8.1.1" +junit-version = "4.13.2" +junit-jupiter-version = "5.9.3" +mockito-version = "5.12.0" + +[libraries] +com-mojang-authlib = { module = "com.mojang:authlib", version.ref = "com-mojang-authlib" } +commons-lang-commons-lang = { module = "commons-lang:commons-lang", version.ref = "commons-lang-commons-lang" } +io-netty-netty-buffer = { module = "io.netty:netty-buffer", version.ref = "io-netty-netty-buffer" } +io-netty-netty-codec = { module = "io.netty:netty-codec", version.ref = "io-netty-netty-codec" } +io-papermc-paper-paper-api = { module = "io.papermc.paper:paper-api", version.ref = "io-papermc-paper-paper-api" } +net-kyori-adventure-api = { module = "net.kyori:adventure-api", version.ref = "net-kyori-adventure-api" } +net-kyori-adventure-text-minimessage = { module = "net.kyori:adventure-text-minimessage", version.ref = "net-kyori-adventure-text-minimessage" } +net-kyori-adventure-text-serializer-gson = { module = "net.kyori:adventure-text-serializer-gson", version.ref = "net-kyori-adventure-text-serializer-gson" } +net-kyori-adventure-text-serializer-json = { module = "net.kyori:adventure-text-serializer-json", version.ref = "net-kyori-adventure-text-serializer-json" } +net-md-v5-bungeecord-chat = { module = "net.md-5:bungeecord-chat", version.ref = "net-md-v5-bungeecord-chat" } +org-spigotmc-spigot = { module = "org.spigotmc:spigot", version.ref = "org-spigotmc-spigot-latest" } +org-spigotmc-spigot-api = { module = "org.spigotmc:spigot-api", version.ref = "org-spigotmc-spigot-latest" } +com-retro-packetevents = { module = "com.github.retrooper:packetevents-spigot", version.ref = "com-retro-packetevents-version" } +org-projectlombok-lombok = { module = "org.projectlombok:lombok", version.ref = "lombok-version" } +libsdisguises-minimessage = { module = "me.libraryaddict.disguises:minimessage", version = "1.0-SNAPSHOT" } +junit-plugin = { module = "junit:junit", version.ref = "junit-version" } +junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit-jupiter-version" } +mockito = { module = "org.mockito:mockito-core", version.ref = "mockito-version" } + +[plugins] +shadowjar = { id = "com.github.johnrengelman.shadow", version.ref = "shadow-version" } + diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 00000000..2c352119 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 00000000..09523c0e --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100644 index 00000000..f5feea6d --- /dev/null +++ b/gradlew @@ -0,0 +1,252 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s +' "$PWD" ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +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. + +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 +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + 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. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + 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. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 00000000..9d21a218 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,94 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. 1>&2 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 +echo. 1>&2 +echo Please set the JAVA_HOME variable in your environment to match the 1>&2 +echo location of your Java installation. 1>&2 + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +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! +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 + +:omega diff --git a/minimessage/build.gradle.kts b/minimessage/build.gradle.kts new file mode 100644 index 00000000..69e780b7 --- /dev/null +++ b/minimessage/build.gradle.kts @@ -0,0 +1,45 @@ +plugins { + alias(libs.plugins.shadowjar) + `maven-publish` +} + +dependencies { + shadow(libs.net.kyori.adventure.api) + shadow(libs.net.kyori.adventure.text.minimessage) + shadow(libs.net.kyori.adventure.text.serializer.json) + shadow(libs.net.kyori.adventure.text.serializer.gson) { + exclude("*") + } +} + +artifacts.add("shadow", tasks.shadowJar.get()) + +tasks { + jar { + isEnabled = false + } + + build { + dependsOn(publish) + dependsOn(shadowJar) + } + + shadowJar { + configurations = listOf(project.configurations.shadow.get()) + relocate("net.kyori", "libsdisg.shaded.net.kyori") + archiveClassifier.set("shadow") + } +} + +publishing { + publications { + create("relocated") { + artifact(tasks["shadowJar"]) { + classifier = null + } + } + } + repositories { + mavenLocal() + } +} \ No newline at end of file diff --git a/minimessage/pom.xml b/minimessage/pom.xml deleted file mode 100644 index 3fbc5f36..00000000 --- a/minimessage/pom.xml +++ /dev/null @@ -1,113 +0,0 @@ - - - - parent - LibsDisguises - 1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - minimessage - 1.0-SNAPSHOT - - - 1.8 - 1.8 - UTF-8 - - - - - io.papermc.paper - paper-api - ${paper-api.version} - provided - true - - - net.kyori - adventure-api - ${adventure-minimessage.version} - compile - true - - - net.kyori - adventure-text-minimessage - ${adventure-minimessage.version} - compile - true - - - net.kyori - adventure-text-serializer-json - ${adventure-text.version} - compile - true - - - net.kyori - adventure-text-serializer-gson - ${adventure-text.version} - compile - true - - - - - - - org.codehaus.mojo - build-helper-maven-plugin - - - compile - package - - attach-artifact - - - - - ${basedir}/target/minimessage-1.0-SNAPSHOT.jar - jar - optional - - - - - - - - org.apache.maven.plugins - maven-shade-plugin - 3.2.4 - - - package - - shade - - - - - - - net.kyori:* - - - - - net.kyori - libsdisg.shaded.net.kyori - - - - - - - - \ No newline at end of file diff --git a/nms/nmsModule.gradle b/nms/nmsModule.gradle new file mode 100644 index 00000000..cd56bcfb --- /dev/null +++ b/nms/nmsModule.gradle @@ -0,0 +1,40 @@ +// Code copied from https://github.com/Shopkeepers/Shopkeepers/tree/master + +apply plugin: 'java-library' + +apply from: rootProject.file('nms/specialSource.gradle') + +ext { + // This needs to be defined by projects that apply this script. + craftbukkitVersion = 'UNSPECIFIED' + // This can be overridden by projects that apply this script. + remapServerCode = true +} + +dependencies { + implementation project(':shared') + afterEvaluate { + if (remapServerCode) { + implementation "org.spigotmc:spigot:${craftbukkitVersion}:remapped-mojang" + } else { + implementation "org.spigotmc:spigot:${craftbukkitVersion}" + } + } +} + +afterEvaluate { + if (remapServerCode) { + jar { + doLast { + def outputFiles = outputs.files.files + for (inputFile in outputFiles) { + File intermediateFile = new File(temporaryDir, inputFile.name.replace('.jar', '-obf.jar')) + File outputFile = inputFile + remapMojangToSpigot(inputFile, intermediateFile, outputFile, craftbukkitVersion) + } + } + } + } +} + +// Note: The NMS modules are not published as standalone artifacts, but are shaded into the final plugin jar. diff --git a/nms/pom.xml b/nms/pom.xml deleted file mode 100644 index 72f159e7..00000000 --- a/nms/pom.xml +++ /dev/null @@ -1,38 +0,0 @@ - - - 4.0.0 - nms - pom - - - parent - LibsDisguises - 1.0-SNAPSHOT - ../pom.xml - - - - - LibsDisguises - shared - 1.0-SNAPSHOT - true - - - - - v1_17_R1 - v1_18_R1 - v1_18_R2 - v1_19_R1 - v1_19_R2 - v1_19_R3 - v1_20_R1 - v1_20_R2 - v1_20_R3 - v1_20_R4 - v1_21_R1 - - - diff --git a/nms/specialSource.gradle b/nms/specialSource.gradle new file mode 100644 index 00000000..cf4b3847 --- /dev/null +++ b/nms/specialSource.gradle @@ -0,0 +1,73 @@ +// Code copied from https://github.com/Shopkeepers/Shopkeepers/tree/master + +buildscript { + repositories { + mavenCentral() + } + + configurations.create('specialSource') + + dependencies { + specialSource 'net.md-5:SpecialSource:1.11.4:shaded' + } +} + +// Spigot server code remapping: https://www.spigotmc.org/threads/spigot-bungeecord-1-17-1-17-1.510208/ +// These dependencies and mappings are installed into the local Maven repository when BuildTools builds the Spigot dependencies. +def m2Repo = new File(repositories.mavenLocal().url.path) +def remappedMojang = new File(m2Repo, 'org/spigotmc/spigot/{craftbukkitVersion}/spigot-{craftbukkitVersion}-remapped-mojang.jar').path +def remappedObf = new File(m2Repo, 'org/spigotmc/spigot/{craftbukkitVersion}/spigot-{craftbukkitVersion}-remapped-obf.jar').path +def mojangMappings = new File(m2Repo, 'org/spigotmc/minecraft-server/{craftbukkitVersion}/minecraft-server-{craftbukkitVersion}-maps-mojang.txt').path +def spigotMappings = new File(m2Repo, 'org/spigotmc/minecraft-server/{craftbukkitVersion}/minecraft-server-{craftbukkitVersion}-maps-spigot.csrg').path + +def specialSource = buildscript.configurations.specialSource.resolvedConfiguration.getFirstLevelModuleDependencies().find { + it.moduleGroup == 'net.md-5' && it.moduleName == 'SpecialSource' +}.moduleArtifacts.first().file.path + +// Converts from Mojang's mappings to Minecraft's obfuscated mappings. +ext.remapMojangToObfuscated = { inputFile, outputFile, craftbukkitVersion -> + println '> remapMojangToObfuscated' + println ' Input: ' + inputFile.path + println ' Output: ' + outputFile.path + println ' CraftBukkit version: ' + craftbukkitVersion + def classpathSeparator = System.properties['path.separator'] + exec { + commandLine 'java', + '-cp', "${specialSource}${classpathSeparator}${remappedMojang}".replace('{craftbukkitVersion}', craftbukkitVersion), + 'net.md_5.specialsource.SpecialSource', + '--live', + '-i', inputFile.path, + '-o', outputFile.path, + '-m', mojangMappings.replace('{craftbukkitVersion}', craftbukkitVersion), + '--reverse' + } +} + +// Converts from Minecraft's obfuscated mappings to Spigot's mappings. +ext.remapObfuscatedToSpigot = { inputFile, outputFile, craftbukkitVersion -> + println '> remapObfuscatedToSpigot' + println ' Input: ' + inputFile.path + println ' Output: ' + outputFile.path + println ' CraftBukkit version: ' + craftbukkitVersion + def classpathSeparator = System.properties['path.separator'] + exec { + commandLine 'java', + '-cp', "${specialSource}${classpathSeparator}${remappedObf}".replace('{craftbukkitVersion}', craftbukkitVersion), + 'net.md_5.specialsource.SpecialSource', + '--live', + '-i', inputFile.path, + '-o', outputFile.path, + '-m', spigotMappings.replace('{craftbukkitVersion}', craftbukkitVersion) + } +} + +// Converts from Mojang's mappings to Spigot's mappings. +ext.remapMojangToSpigot = { inputFile, intermediateFile, outputFile, craftbukkitVersion -> + println '> remapMojangToSpigot' + println ' Input: ' + inputFile.path + println ' Intermediate: ' + intermediateFile.path + println ' Output: ' + outputFile.path + println ' CraftBukkit version: ' + craftbukkitVersion + remapMojangToObfuscated(inputFile, intermediateFile, craftbukkitVersion) + remapObfuscatedToSpigot(intermediateFile, outputFile, craftbukkitVersion) +} diff --git a/nms/v1_17_R1/build.gradle.kts b/nms/v1_17_R1/build.gradle.kts new file mode 100644 index 00000000..91c4e379 --- /dev/null +++ b/nms/v1_17_R1/build.gradle.kts @@ -0,0 +1,9 @@ +plugins { + `java-library` +} + +apply(from = rootProject.file("nms/nmsModule.gradle")) + +extra["craftbukkitVersion"] = "1.17.1-R0.1-SNAPSHOT" + +description = "v1_17_R1" diff --git a/nms/v1_17_R1/pom.xml b/nms/v1_17_R1/pom.xml deleted file mode 100644 index ac3f814e..00000000 --- a/nms/v1_17_R1/pom.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - nms - LibsDisguises - 1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - - v1_17_R1 - 1.0-SNAPSHOT - - - 1.8 - 1.8 - UTF-8 - - 1.17.1-R0.1-SNAPSHOT - - - - - org.spigotmc - spigot - ${spigot.version} - remapped-mojang - provided - - - org.spigotmc - spigot-api - ${spigot.version} - provided - true - - - io.netty - netty-buffer - 4.1.90.Final - provided - true - - - - - - - net.md-5 - specialsource-maven-plugin - 1.2.4 - - - package - - remap - - remap-obf - - org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang - true - org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang - remapped-mojang - true - - - - package - - remap - - remap-spigot - - target/${project.build.finalName}-remapped-mojang.jar - org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot - org.spigotmc:spigot:${spigot.version}:jar:remapped-obf - remapped-spigot - true - - - - - - - \ No newline at end of file diff --git a/nms/v1_18_R1/build.gradle.kts b/nms/v1_18_R1/build.gradle.kts new file mode 100644 index 00000000..ee381726 --- /dev/null +++ b/nms/v1_18_R1/build.gradle.kts @@ -0,0 +1,9 @@ +plugins { + `java-library` +} + +apply(from = rootProject.file("nms/nmsModule.gradle")) + +extra["craftbukkitVersion"] = "1.18.1-R0.1-SNAPSHOT" + +description = "v1_18_R1" diff --git a/nms/v1_18_R1/pom.xml b/nms/v1_18_R1/pom.xml deleted file mode 100644 index 5f869522..00000000 --- a/nms/v1_18_R1/pom.xml +++ /dev/null @@ -1,112 +0,0 @@ - - - - nms - LibsDisguises - 1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - v1_18_R1 - 1.0-SNAPSHOT - - - 1.8 - 1.8 - UTF-8 - - 1.18.1-R0.1-SNAPSHOT - - - - - org.spigotmc - spigot - ${spigot.version} - remapped-mojang - provided - true - - - org.spigotmc - spigot-api - ${spigot.version} - provided - true - - - - com.mojang - authlib - 3.5.41 - provided - true - - - - it.unimi.dsi - fastutil - 8.5.8 - provided - true - - - - com.mojang - datafixerupper - 4.1.27 - provided - true - - - io.netty - netty-buffer - 4.1.90.Final - provided - true - - - - - - - net.md-5 - specialsource-maven-plugin - 1.2.4 - - - package - - remap - - remap-obf - - org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang - true - org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang - remapped-mojang - true - - - - package - - remap - - remap-spigot - - target/${project.build.finalName}-remapped-mojang.jar - org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot - org.spigotmc:spigot:${spigot.version}:jar:remapped-obf - remapped-spigot - true - - - - - - - \ No newline at end of file diff --git a/nms/v1_18_R2/build.gradle.kts b/nms/v1_18_R2/build.gradle.kts new file mode 100644 index 00000000..c494d8dd --- /dev/null +++ b/nms/v1_18_R2/build.gradle.kts @@ -0,0 +1,9 @@ +plugins { + `java-library` +} + +apply(from = rootProject.file("nms/nmsModule.gradle")) + +extra["craftbukkitVersion"] = "1.18.2-R0.1-SNAPSHOT" + +description = "v1_18_R2" diff --git a/nms/v1_18_R2/pom.xml b/nms/v1_18_R2/pom.xml deleted file mode 100644 index 56cd5a61..00000000 --- a/nms/v1_18_R2/pom.xml +++ /dev/null @@ -1,112 +0,0 @@ - - - - nms - LibsDisguises - 1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - v1_18_R2 - 1.0-SNAPSHOT - - - 1.8 - 1.8 - UTF-8 - - 1.18.2-R0.1-SNAPSHOT - - - - - org.spigotmc - spigot - ${spigot.version} - remapped-mojang - provided - true - - - org.spigotmc - spigot-api - ${spigot.version} - provided - true - - - - com.mojang - authlib - 3.5.41 - provided - true - - - - it.unimi.dsi - fastutil - 8.5.8 - provided - true - - - - com.mojang - datafixerupper - 4.1.27 - provided - true - - - io.netty - netty-buffer - 4.1.90.Final - provided - true - - - - - - - net.md-5 - specialsource-maven-plugin - 1.2.4 - - - package - - remap - - remap-obf - - org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang - true - org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang - remapped-mojang - true - - - - package - - remap - - remap-spigot - - target/${project.build.finalName}-remapped-mojang.jar - org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot - org.spigotmc:spigot:${spigot.version}:jar:remapped-obf - remapped-spigot - true - - - - - - - \ No newline at end of file diff --git a/nms/v1_19_R1/build.gradle.kts b/nms/v1_19_R1/build.gradle.kts new file mode 100644 index 00000000..ad64c1d5 --- /dev/null +++ b/nms/v1_19_R1/build.gradle.kts @@ -0,0 +1,9 @@ +plugins { + `java-library` +} + +apply(from = rootProject.file("nms/nmsModule.gradle")) + +extra["craftbukkitVersion"] = "1.19.1-R0.1-SNAPSHOT" + +description = "v1_19_R1" diff --git a/nms/v1_19_R1/pom.xml b/nms/v1_19_R1/pom.xml deleted file mode 100644 index 6864b37c..00000000 --- a/nms/v1_19_R1/pom.xml +++ /dev/null @@ -1,112 +0,0 @@ - - - - nms - LibsDisguises - 1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - v1_19_R1 - 1.0-SNAPSHOT - - - 1.8 - 1.8 - UTF-8 - - 1.19.1-R0.1-SNAPSHOT - - - - - org.spigotmc - spigot - ${spigot.version} - remapped-mojang - provided - true - - - org.spigotmc - spigot-api - ${spigot.version} - provided - true - - - - it.unimi.dsi - fastutil - 8.5.8 - provided - true - - - - com.mojang - authlib - 3.5.41 - provided - true - - - - com.mojang - datafixerupper - 5.0.28 - provided - true - - - io.netty - netty-buffer - 4.1.90.Final - provided - true - - - - - - - net.md-5 - specialsource-maven-plugin - 1.2.4 - - - package - - remap - - remap-obf - - org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang - true - org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang - remapped-mojang - true - - - - package - - remap - - remap-spigot - - target/${project.build.finalName}-remapped-mojang.jar - org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot - org.spigotmc:spigot:${spigot.version}:jar:remapped-obf - remapped-spigot - true - - - - - - - \ No newline at end of file diff --git a/nms/v1_19_R2/build.gradle.kts b/nms/v1_19_R2/build.gradle.kts new file mode 100644 index 00000000..f5fd2a29 --- /dev/null +++ b/nms/v1_19_R2/build.gradle.kts @@ -0,0 +1,9 @@ +plugins { + `java-library` +} + +apply(from = rootProject.file("nms/nmsModule.gradle")) + +extra["craftbukkitVersion"] = "1.19.3-R0.1-SNAPSHOT" + +description = "v1_19_R2" diff --git a/nms/v1_19_R2/pom.xml b/nms/v1_19_R2/pom.xml deleted file mode 100644 index fa8ecad1..00000000 --- a/nms/v1_19_R2/pom.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - nms - LibsDisguises - 1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - v1_19_R2 - 1.0-SNAPSHOT - - - 1.8 - 1.8 - UTF-8 - - 1.19.3-R0.1-SNAPSHOT - - - - - org.spigotmc - spigot - ${spigot.version} - remapped-mojang - provided - true - - - org.spigotmc - spigot-api - ${spigot.version} - provided - true - - - - it.unimi.dsi - fastutil - 8.5.8 - provided - true - - - - com.mojang - authlib - 3.5.41 - provided - true - - - - com.mojang - datafixerupper - 5.0.28 - provided - true - - - - com.mojang - brigadier - 1.0.18 - compile - true - - - io.netty - netty-buffer - 4.1.90.Final - provided - true - - - - - - - net.md-5 - specialsource-maven-plugin - 1.2.4 - - - package - - remap - - remap-obf - - org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang - true - org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang - remapped-mojang - true - - - - package - - remap - - remap-spigot - - target/${project.build.finalName}-remapped-mojang.jar - org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot - org.spigotmc:spigot:${spigot.version}:jar:remapped-obf - remapped-spigot - true - - - - - - - \ No newline at end of file diff --git a/nms/v1_19_R3/build.gradle.kts b/nms/v1_19_R3/build.gradle.kts new file mode 100644 index 00000000..32b8dceb --- /dev/null +++ b/nms/v1_19_R3/build.gradle.kts @@ -0,0 +1,9 @@ +plugins { + `java-library` +} + +apply(from = rootProject.file("nms/nmsModule.gradle")) + +extra["craftbukkitVersion"] = "1.19.4-R0.1-SNAPSHOT" + +description = "v1_19_R3" diff --git a/nms/v1_19_R3/pom.xml b/nms/v1_19_R3/pom.xml deleted file mode 100644 index 193982ee..00000000 --- a/nms/v1_19_R3/pom.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - nms - LibsDisguises - 1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - v1_19_R3 - 1.0-SNAPSHOT - - - 1.8 - 1.8 - UTF-8 - - 1.19.4-R0.1-SNAPSHOT - - - - - org.spigotmc - spigot - ${spigot.version} - remapped-mojang - provided - true - - - org.spigotmc - spigot-api - ${spigot.version} - provided - true - - - - it.unimi.dsi - fastutil - 8.5.8 - provided - true - - - - com.mojang - authlib - 3.5.41 - provided - true - - - - com.mojang - datafixerupper - 5.0.28 - provided - true - - - - com.mojang - brigadier - 1.0.18 - compile - true - - - io.netty - netty-buffer - 4.1.90.Final - provided - true - - - - - - - net.md-5 - specialsource-maven-plugin - 1.2.4 - - - package - - remap - - remap-obf - - org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang - true - org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang - remapped-mojang - true - - - - package - - remap - - remap-spigot - - target/${project.build.finalName}-remapped-mojang.jar - org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot - org.spigotmc:spigot:${spigot.version}:jar:remapped-obf - remapped-spigot - true - - - - - - - \ No newline at end of file diff --git a/nms/v1_20_R1/build.gradle.kts b/nms/v1_20_R1/build.gradle.kts new file mode 100644 index 00000000..c7785e89 --- /dev/null +++ b/nms/v1_20_R1/build.gradle.kts @@ -0,0 +1,9 @@ +plugins { + `java-library` +} + +apply(from = rootProject.file("nms/nmsModule.gradle")) + +extra["craftbukkitVersion"] = "1.20-R0.1-SNAPSHOT" + +description = "v1_20_R1" diff --git a/nms/v1_20_R1/pom.xml b/nms/v1_20_R1/pom.xml deleted file mode 100644 index 29e3b96c..00000000 --- a/nms/v1_20_R1/pom.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - nms - LibsDisguises - 1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - v1_20_R1 - 1.0-SNAPSHOT - - - 1.8 - 1.8 - UTF-8 - - 1.20-R0.1-SNAPSHOT - - - - - org.spigotmc - spigot - ${spigot.version} - remapped-mojang - provided - true - - - org.spigotmc - spigot-api - ${spigot.version} - provided - true - - - - it.unimi.dsi - fastutil - 8.5.8 - provided - true - - - - com.mojang - authlib - 3.5.41 - provided - true - - - - com.mojang - datafixerupper - 5.0.28 - provided - true - - - - com.mojang - brigadier - 1.0.18 - compile - true - - - io.netty - netty-buffer - 4.1.90.Final - provided - true - - - - - - - net.md-5 - specialsource-maven-plugin - 1.2.4 - - - package - - remap - - remap-obf - - org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang - true - org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang - remapped-mojang - true - - - - package - - remap - - remap-spigot - - target/${project.build.finalName}-remapped-mojang.jar - org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot - org.spigotmc:spigot:${spigot.version}:jar:remapped-obf - remapped-spigot - true - - - - - - - \ No newline at end of file diff --git a/nms/v1_20_R2/build.gradle.kts b/nms/v1_20_R2/build.gradle.kts new file mode 100644 index 00000000..3b9385c1 --- /dev/null +++ b/nms/v1_20_R2/build.gradle.kts @@ -0,0 +1,9 @@ +plugins { + `java-library` +} + +apply(from = rootProject.file("nms/nmsModule.gradle")) + +extra["craftbukkitVersion"] = "1.20.2-R0.1-SNAPSHOT" + +description = "v1_20_R2" diff --git a/nms/v1_20_R2/pom.xml b/nms/v1_20_R2/pom.xml deleted file mode 100644 index 88b1b63b..00000000 --- a/nms/v1_20_R2/pom.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - nms - LibsDisguises - 1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - v1_20_R2 - 1.0-SNAPSHOT - - - 1.8 - 1.8 - UTF-8 - - 1.20.2-R0.1-SNAPSHOT - - - - - org.spigotmc - spigot - ${spigot.version} - remapped-mojang - provided - true - - - org.spigotmc - spigot-api - ${spigot.version} - provided - true - - - - it.unimi.dsi - fastutil - 8.5.8 - provided - true - - - - com.mojang - authlib - 5.0.47 - provided - true - - - - com.mojang - datafixerupper - 5.0.28 - provided - true - - - - com.mojang - brigadier - 1.0.18 - compile - true - - - io.netty - netty-buffer - 4.1.90.Final - provided - true - - - - - - - net.md-5 - specialsource-maven-plugin - 1.2.4 - - - package - - remap - - remap-obf - - org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang - true - org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang - remapped-mojang - true - - - - package - - remap - - remap-spigot - - target/${project.build.finalName}-remapped-mojang.jar - org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot - org.spigotmc:spigot:${spigot.version}:jar:remapped-obf - remapped-spigot - true - - - - - - - \ No newline at end of file diff --git a/nms/v1_20_R3/build.gradle.kts b/nms/v1_20_R3/build.gradle.kts new file mode 100644 index 00000000..eb0fda5c --- /dev/null +++ b/nms/v1_20_R3/build.gradle.kts @@ -0,0 +1,9 @@ +plugins { + `java-library` +} + +apply(from = rootProject.file("nms/nmsModule.gradle")) + +extra["craftbukkitVersion"] = "1.20.3-R0.1-SNAPSHOT" + +description = "v1_20_R3" diff --git a/nms/v1_20_R3/pom.xml b/nms/v1_20_R3/pom.xml deleted file mode 100644 index efbc0134..00000000 --- a/nms/v1_20_R3/pom.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - nms - LibsDisguises - 1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - v1_20_R3 - 1.0-SNAPSHOT - - - 1.8 - 1.8 - UTF-8 - - 1.20.3-R0.1-SNAPSHOT - - - - - org.spigotmc - spigot - ${spigot.version} - remapped-mojang - provided - true - - - org.spigotmc - spigot-api - ${spigot.version} - provided - true - - - - it.unimi.dsi - fastutil - 8.5.8 - provided - true - - - - com.mojang - authlib - 5.0.47 - provided - true - - - - com.mojang - datafixerupper - 5.0.28 - provided - true - - - - com.mojang - brigadier - 1.0.18 - compile - true - - - io.netty - netty-buffer - 4.1.90.Final - provided - true - - - - - - - net.md-5 - specialsource-maven-plugin - 1.2.4 - - - package - - remap - - remap-obf - - org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang - true - org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang - remapped-mojang - true - - - - package - - remap - - remap-spigot - - target/${project.build.finalName}-remapped-mojang.jar - org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot - org.spigotmc:spigot:${spigot.version}:jar:remapped-obf - remapped-spigot - true - - - - - - - \ No newline at end of file diff --git a/nms/v1_20_R4/build.gradle.kts b/nms/v1_20_R4/build.gradle.kts new file mode 100644 index 00000000..2312f7e0 --- /dev/null +++ b/nms/v1_20_R4/build.gradle.kts @@ -0,0 +1,9 @@ +plugins { + `java-library` +} + +apply(from = rootProject.file("nms/nmsModule.gradle")) + +extra["craftbukkitVersion"] = "1.20.6-R0.1-SNAPSHOT" + +description = "v1_20_R4" diff --git a/nms/v1_20_R4/pom.xml b/nms/v1_20_R4/pom.xml deleted file mode 100644 index e8390ae3..00000000 --- a/nms/v1_20_R4/pom.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - nms - LibsDisguises - 1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - v1_20_R4 - 1.0-SNAPSHOT - - - 1.8 - 1.8 - UTF-8 - - 1.20.6-R0.1-SNAPSHOT - - - - - org.spigotmc - spigot - ${spigot.version} - remapped-mojang - provided - true - - - org.spigotmc - spigot-api - ${spigot.version} - provided - true - - - - it.unimi.dsi - fastutil - 8.5.8 - provided - true - - - - com.mojang - authlib - 6.0.54 - provided - true - - - - com.mojang - datafixerupper - 7.0.14 - provided - true - - - - com.mojang - brigadier - 1.2.9 - compile - true - - - io.netty - netty-buffer - 4.1.90.Final - provided - true - - - - - - - net.md-5 - specialsource-maven-plugin - 2.0.3 - - - package - - remap - - remap-obf - - org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang - true - org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang - remapped-mojang - true - - - - package - - remap - - remap-spigot - - target/${project.build.finalName}-remapped-mojang.jar - org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot - org.spigotmc:spigot:${spigot.version}:jar:remapped-obf - remapped-spigot - true - - - - - - - \ No newline at end of file diff --git a/nms/v1_21_R1/build.gradle.kts b/nms/v1_21_R1/build.gradle.kts new file mode 100644 index 00000000..2f3ef310 --- /dev/null +++ b/nms/v1_21_R1/build.gradle.kts @@ -0,0 +1,9 @@ +plugins { + `java-library` +} + +apply(from = rootProject.file("nms/nmsModule.gradle")) + +extra["craftbukkitVersion"] = "1.21-R0.1-SNAPSHOT"; + +description = "v1_21_R1" \ No newline at end of file diff --git a/nms/v1_21_R1/pom.xml b/nms/v1_21_R1/pom.xml deleted file mode 100644 index 80655f83..00000000 --- a/nms/v1_21_R1/pom.xml +++ /dev/null @@ -1,120 +0,0 @@ - - - - nms - LibsDisguises - 1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - v1_21_R1 - 1.0-SNAPSHOT - - - 1.8 - 1.8 - UTF-8 - - 1.21-R0.1-SNAPSHOT - - - - - org.spigotmc - spigot - ${spigot.version} - remapped-mojang - provided - true - - - org.spigotmc - spigot-api - ${spigot.version} - provided - true - - - - it.unimi.dsi - fastutil - 8.5.8 - provided - true - - - - com.mojang - authlib - 6.0.54 - provided - true - - - - com.mojang - datafixerupper - 7.0.14 - provided - true - - - - com.mojang - brigadier - 1.2.9 - compile - true - - - io.netty - netty-buffer - 4.1.90.Final - provided - true - - - - - - - net.md-5 - specialsource-maven-plugin - 2.0.3 - - - package - - remap - - remap-obf - - org.spigotmc:minecraft-server:${spigot.version}:txt:maps-mojang - true - org.spigotmc:spigot:${spigot.version}:jar:remapped-mojang - remapped-mojang - true - - - - package - - remap - - remap-spigot - - target/${project.build.finalName}-remapped-mojang.jar - org.spigotmc:minecraft-server:${spigot.version}:csrg:maps-spigot - org.spigotmc:spigot:${spigot.version}:jar:remapped-obf - remapped-spigot - true - - - - - - - \ No newline at end of file diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts new file mode 100644 index 00000000..a545cb3c --- /dev/null +++ b/plugin/build.gradle.kts @@ -0,0 +1,47 @@ +plugins { + `maven-publish` +} + +version = "10.0.44-SNAPSHOT" + +dependencies { + compileOnly(project(":shared")) + compileOnly(libs.io.netty.netty.buffer) + compileOnly(libs.io.netty.netty.codec) + compileOnly(libs.commons.lang.commons.lang) + compileOnly(libs.com.mojang.authlib) + compileOnly(libs.org.spigotmc.spigot.api) + compileOnly(libs.com.retro.packetevents) + compileOnly(libs.libsdisguises.minimessage) + compileOnly(libs.io.papermc.paper.paper.api); +} + +publishing { + repositories { +// maven { +// name = "md_5-releases" +// url = uri("https://repo.md-5.net/content/repositories/releases/") +// credentials { +// username = project.findProperty("repoUser") as String? ?: System.getenv("REPO_USER") +// password = project.findProperty("repoPassword") as String? ?: System.getenv("REPO_PASSWORD") +// } +// } +// maven { +// name = "md_5-snapshots" +// url = uri("https://repo.md-5.net/content/repositories/snapshots/") +// credentials { +// username = project.findProperty("repoUser") as String? ?: System.getenv("REPO_USER") +// password = project.findProperty("repoPassword") as String? ?: System.getenv("REPO_PASSWORD") +// } +// } + mavenLocal() + } + publications { + create("mavenJava") { + from(components["java"]) + + groupId = "LibsDisguises" + artifactId = "LibsDisguises" + } + } +} \ No newline at end of file diff --git a/plugin/pom.xml b/plugin/pom.xml deleted file mode 100644 index 6da8c2fa..00000000 --- a/plugin/pom.xml +++ /dev/null @@ -1,153 +0,0 @@ - - - - parent - LibsDisguises - 1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - - LibsDisguises - ${libsdisguises.version} - - - 1.8 - 1.8 - UTF-8 - - - - - - org.apache.maven.plugins - maven-install-plugin - 2.5.2 - - - default-install - - false - - - - - - org.apache.maven.plugins - maven-deploy-plugin - 3.1.2 - - - default-deploy - - false - - - - - - - - - - LibsDisguises - minimessage - 1.0-SNAPSHOT - provided - true - - - LibsDisguises - shared - 1.0-SNAPSHOT - provided - true - - - org.spigotmc - spigot - true - - - org.spigotmc - spigot-api - true - - - io.papermc.paper - paper-api - ${paper-api.version} - provided - true - - - * - * - - - - - net.md-5 - bungeecord-chat - ${bungeecord-chat.version} - provided - true - - - - - - it.unimi.dsi - fastutil - 8.5.12 - provided - true - - - com.mojang - authlib - 5.0.51 - provided - true - - - com.mojang - datafixerupper - 5.0.28 - provided - true - - - com.mojang - brigadier - 1.0.18 - provided - true - - - io.netty - netty-buffer - 4.1.90.Final - provided - true - - - io.netty - netty-codec - 4.1.90.Final - provided - true - - - commons-lang - commons-lang - 2.6 - true - provided - - - - \ No newline at end of file diff --git a/plugin/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java b/plugin/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java index b7d8e173..ab93b6fd 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/DisguiseConfig.java @@ -187,8 +187,6 @@ public class DisguiseConfig { @Getter @Setter private static int maxClonedDisguises; - @Getter - @Setter private static int uuidGeneratedVersion; @Getter @Setter diff --git a/plugin/src/main/java/me/libraryaddict/disguise/LibsDisguises.java b/plugin/src/main/java/me/libraryaddict/disguise/LibsDisguises.java index 858a7e7c..4304d131 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/LibsDisguises.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/LibsDisguises.java @@ -349,14 +349,14 @@ public class LibsDisguises extends JavaPlugin { buildNumber = StringUtils.stripToNull(pluginYml.getString("build-number")); buildDate = StringUtils.stripToNull(pluginYml.getString("build-date")); - int fileCount = ReflectionManager.getJarFileCount(getFile(), LibsPremium.ignoredDirectories()); + int fileCount = ReflectionManager.getJarFileCount(getFile()); int expected = pluginYml.getInt("file-count", fileCount); if (fileCount != expected) { getLogger().severe( "Hi, this is libraryaddict from Lib's Disguises informing you that I have detected that my plugin Lib's Disguises looks " + - "like another plugin (unknown) has injected malware into it as soon as it started running on your server, there were " + - (fileCount - expected) + + "like another plugin (don't know which) has injected malware into it as soon as Lib's Disguises started running on " + + "your server, there were " + (fileCount - expected) + " unknown files injected into the jar. Please redownload from a trusted source such as SpigotMC. If this warning " + "shows even after updating, try https://www.spigotmc.org/resources/spigot-anti-malware.64982/ but you will likely " + "need to reinstall all your plugins, jars, etc as just one infected plugin will infect everything else when it loads."); diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index f56fabb9..7fbb5f45 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -285,7 +285,6 @@ public class DisguiseUtilities { private static final HashMap> disguiseLoading = new HashMap<>(); @Getter private static boolean runningPaper; - @Getter private static MineSkinAPI mineSkinAPI; @Getter private static boolean invalidFile; diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/reflection/ReflectionManager.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/reflection/ReflectionManager.java index 5d8f4e71..1d7e33c5 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/reflection/ReflectionManager.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/reflection/ReflectionManager.java @@ -410,7 +410,9 @@ public class ReflectionManager { } public static long getGameTime(Entity entity) { - if (entity==null||entity.getWorld()==null ||!NmsVersion.v1_19_R3.isSupported())return 0L; + if (entity == null || entity.getWorld() == null || !NmsVersion.v1_19_R3.isSupported()) { + return 0L; + } return entity.getWorld().getGameTime(); } @@ -504,28 +506,17 @@ public class ReflectionManager { return null; } - public static int getJarFileCount(File file, String... ignoredDirectories) throws IOException { + public static int getJarFileCount(File file) throws IOException { try (JarFile jar = new JarFile(file)) { int count = 0; Enumeration entry = jar.entries(); - loop: while (entry.hasMoreElements()) { - JarEntry element = entry.nextElement(); - - if (element.isDirectory()) { + if (entry.nextElement().isDirectory()) { continue; } - for (String ignored : ignoredDirectories) { - if (!element.getName().startsWith(ignored)) { - continue; - } - - continue loop; - } - count++; } diff --git a/plugin/src/main/java/me/libraryaddict/disguise/utilities/sounds/DisguiseSoundEnums.java b/plugin/src/main/java/me/libraryaddict/disguise/utilities/sounds/DisguiseSoundEnums.java index a46be83b..fc3f0383 100644 --- a/plugin/src/main/java/me/libraryaddict/disguise/utilities/sounds/DisguiseSoundEnums.java +++ b/plugin/src/main/java/me/libraryaddict/disguise/utilities/sounds/DisguiseSoundEnums.java @@ -11,6 +11,7 @@ import java.util.HashMap; /** * Only living disguises go in here! */ +@Getter public enum DisguiseSoundEnums { ALLAY(Sound.ENTITY_ALLAY_HURT, null, Sound.ENTITY_ALLAY_DEATH, new Sound[]{Sound.ENTITY_ALLAY_AMBIENT_WITHOUT_ITEM, Sound.ENTITY_ALLAY_AMBIENT_WITH_ITEM}, Sound.ENTITY_ALLAY_ITEM_GIVEN, @@ -184,7 +185,7 @@ public enum DisguiseSoundEnums { Sound.ENTITY_PANDA_SNEEZE), PARROT(Sound.ENTITY_PARROT_HURT, Sound.ENTITY_PARROT_STEP, Sound.ENTITY_PARROT_DEATH, Sound.ENTITY_PARROT_AMBIENT, - Arrays.stream(Sound.values()).filter( + (Object) Arrays.stream(Sound.values()).filter( sound -> sound.name().contains("PARROT_IMITATE") || sound == Sound.ENTITY_PARROT_EAT || sound == Sound.ENTITY_PARROT_FLY) .toArray(Sound[]::new)), @@ -328,7 +329,6 @@ public enum DisguiseSoundEnums { ZOMBIFIED_PIGLIN(Sound.ENTITY_ZOMBIFIED_PIGLIN_HURT, null, Sound.ENTITY_ZOMBIFIED_PIGLIN_DEATH, Sound.ENTITY_ZOMBIFIED_PIGLIN_AMBIENT, Sound.ENTITY_ZOMBIFIED_PIGLIN_ANGRY, Sound.ENTITY_PIGLIN_CONVERTED_TO_ZOMBIFIED); - @Getter private final HashMap sounds = new HashMap<>(); DisguiseSoundEnums(Object hurt, Object step, Object death, Object idle, Object... sounds) { diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 143b1fd8..00000000 --- a/pom.xml +++ /dev/null @@ -1,170 +0,0 @@ - - - 4.0.0 - - LibsDisguises - parent - pom - 1.0-SNAPSHOT - - - shared - nms - minimessage - plugin - shaded - - - - 10.0.44-SNAPSHOT - - unknown - ${maven.build.timestamp} - dd/MM/yyyy HH:mm - 21 - 1.8 - UTF-8 - - 1.18.32 - 2.4.0 - 1.21-R0.1-SNAPSHOT - 4.13.2 - 5.9.3 - 1.20.3-R0.1-SNAPSHOT - 1.16-R0.4 - 4.17.0 - 4.17.0 - 5.12.0 - - - - - - - org.apache.maven.plugins - maven-install-plugin - 2.5.2 - - - default-install - - true - - - - - - org.apache.maven.plugins - maven-deploy-plugin - 3.1.2 - - - default-deploy - - true - - - - - - - - - - - org.projectlombok - lombok - ${lombok.version} - true - - - com.github.retrooper - packetevents-spigot - true - compile - - - - junit - junit - ${junit.version} - test - true - - - org.junit.jupiter - junit-jupiter - ${junit-jupiter.version} - test - true - - - org.mockito - mockito-core - ${mockito.version} - - - - - - - com.github.retrooper - packetevents-spigot - ${packetevents.version} - provided - - - org.spigotmc - spigot-api - ${spigot.version} - true - - - org.spigotmc - spigot - ${spigot.version} - true - - - - - - - md_5-releases - https://repo.md-5.net/content/groups/public/ - - - - papermc - https://papermc.io/repo/repository/maven-public/ - - - - - nexus - Lumine Releases - https://mvn.lumine.io/repository/maven-public/ - - - - codemc-releases - https://repo.codemc.io/repository/maven-releases/ - - - codemc-snapshots - https://repo.codemc.io/repository/maven-snapshots/ - - - - - - md_5-releases - https://repo.md-5.net/content/repositories/releases/ - - - md_5-snapshots - https://repo.md-5.net/content/repositories/snapshots/ - - - diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 00000000..4df4abd9 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,9 @@ +rootProject.name = "LibsDisguises" + +include("minimessage") + +include("shared", "plugin", "shaded") + +val nmsModules = File(rootDir, "nms").listFiles()!!.filter { s -> s.isDirectory() && s.name.matches("v[\\d_]+R\\d+".toRegex()) }.map { s -> ":nms:" + s.name }; +gradle.extra["nmsModules"] = nmsModules +include(nmsModules) diff --git a/shaded/build.gradle.kts b/shaded/build.gradle.kts new file mode 100644 index 00000000..35764604 --- /dev/null +++ b/shaded/build.gradle.kts @@ -0,0 +1,117 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar +import java.time.LocalDateTime +import java.time.format.DateTimeFormatter + +plugins { + `java` + alias(libs.plugins.shadowjar) + application +} + +tasks { + build { + dependsOn("shadowJar") + dependsOn("run") + dependsOn(getByName("jenkins")) + } + + task("publish") { + dependsOn("build") + } + + shadowJar { + configurations = listOf(project.configurations.shadow.get()) + exclude("**/CompileMethods.class") + } + + getByName("run") { + mustRunAfter(shadowJar) + } + + task("jenkins") { + mustRunAfter("run") + + doLast { + copy { + from(shadowJar.get().archiveFile.get().asFile.absolutePath) + into(rootProject.projectDir.absolutePath + "\\target") + rename { + "LibsDisguises.jar" + } + } + } + } + + processResources { + // Always inject timestamp & version + outputs.upToDateWhen { false } + + var number = "unknown"; + + if (gradle.startParameter.taskNames.contains("publish")) { + number = System.getProperty("build.number", "unknown"); + } + + filesMatching("plugin.yml") { + expand( + "libsdisguisesVersion" to project(":plugin").version, + "timestamp" to DateTimeFormatter.ofPattern("dd/MM/yyyy HH:mm").format(LocalDateTime.now()), + "buildNumber" to number + ) + } + } +} + +java { + sourceCompatibility = JavaVersion.VERSION_21 +} + +application { + mainClass = "me.libraryaddict.disguise.utilities.watchers.CompileMethods" + applicationDefaultJvmArgs = listOf( + "-Djar.path=" + tasks.named("shadowJar").get().archiveFile.get().asFile.absolutePath + ) +} + +testing { + suites { + val test by getting(JvmTestSuite::class) { + useJUnitJupiter() + } + } +} + +dependencies { + shadow(libs.libsdisguises.minimessage) { + exclude("*") + } + shadow(project(":shared")) { + exclude("*") + } + shadow(project(":plugin")) { + exclude("*") + } + runtimeOnly(project(":plugin")) + runtimeOnly(libs.com.retro.packetevents) + + (gradle.extra["nmsModules"] as List<*>).map { s -> project(s as String) }.forEach { + shadow(it) { + exclude("*") + } + } + + testCompileOnly(libs.org.projectlombok.lombok) + testAnnotationProcessor(libs.org.projectlombok.lombok) + + testImplementation(project(":shared")) + testImplementation(project(":plugin")) + testImplementation(libs.libsdisguises.minimessage) + testImplementation(libs.mockito) + testImplementation(libs.com.retro.packetevents) + testImplementation(libs.net.kyori.adventure.api) + testImplementation(libs.net.kyori.adventure.text.minimessage) + testImplementation(libs.net.kyori.adventure.text.serializer.gson) + testImplementation(libs.net.kyori.adventure.text.serializer.json) + testRuntimeOnly(libs.org.spigotmc.spigot.api) + testRuntimeOnly(libs.org.spigotmc.spigot) +} \ No newline at end of file diff --git a/shaded/pom.xml b/shaded/pom.xml deleted file mode 100644 index b38c46c6..00000000 --- a/shaded/pom.xml +++ /dev/null @@ -1,272 +0,0 @@ - - - - parent - LibsDisguises - 1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - shaded - 1.0-SNAPSHOT - - - 1.8 - 1.8 - UTF-8 - - - - exec:java clean package - LibsDisguises - - - - src/main/resources - true - - plugin.yml - - - - src/main/resources - false - - **/* - - - - ${project.basedir} - - README.md - - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.3.1 - - ../target - - - - maven-surefire-plugin - 3.1.2 - - - org.codehaus.mojo - exec-maven-plugin - 3.0.0 - - - - my-execution - compile - - java - - - - - true - me.libraryaddict.disguise.utilities.watchers.CompileMethods - - - - org.apache.maven.plugins - maven-shade-plugin - 3.2.4 - - - package - - shade - - - - - true - - - LibsDisguises:* - - ** - - - META-INF/**/v*/** - - - - - - LibsDisguises:* - - - - - - - - - - org.spigotmc - spigot-api - true - - - - LibsDisguises - minimessage - 1.0-SNAPSHOT - compile - true - - - LibsDisguises - shared - 1.0-SNAPSHOT - compile - true - - - LibsDisguises - LibsDisguises - ${libsdisguises.version} - compile - - - LibsDisguises - v1_17_R1 - 1.0-SNAPSHOT - remapped-spigot - compile - - - LibsDisguises - v1_18_R1 - 1.0-SNAPSHOT - remapped-spigot - compile - - - LibsDisguises - v1_18_R2 - 1.0-SNAPSHOT - remapped-spigot - compile - - - LibsDisguises - v1_19_R1 - 1.0-SNAPSHOT - remapped-spigot - compile - - - LibsDisguises - v1_19_R2 - 1.0-SNAPSHOT - remapped-spigot - compile - - - LibsDisguises - v1_19_R3 - 1.0-SNAPSHOT - remapped-spigot - compile - - - LibsDisguises - v1_20_R1 - 1.0-SNAPSHOT - remapped-spigot - compile - - - LibsDisguises - v1_20_R2 - 1.0-SNAPSHOT - remapped-spigot - compile - - - LibsDisguises - v1_20_R3 - 1.0-SNAPSHOT - remapped-spigot - compile - - - LibsDisguises - v1_20_R4 - 1.0-SNAPSHOT - remapped-spigot - compile - - - LibsDisguises - v1_21_R1 - 1.0-SNAPSHOT - remapped-spigot - compile - - - - - it.unimi.dsi - fastutil - 8.5.12 - provided - true - - - com.mojang - authlib - 5.0.51 - provided - true - - - com.mojang - datafixerupper - 5.0.28 - provided - true - - - com.mojang - brigadier - 1.0.18 - provided - true - - - io.netty - netty-buffer - 4.1.90.Final - provided - true - - - io.netty - netty-codec - 4.1.90.Final - provided - true - - - commons-lang - commons-lang - 2.6 - true - provided - - - - \ No newline at end of file diff --git a/shaded/src/main/java/me/libraryaddict/disguise/utilities/watchers/CompileMethods.java b/shaded/src/main/java/me/libraryaddict/disguise/utilities/watchers/CompileMethods.java index ebaf4c85..4f0f8404 100644 --- a/shaded/src/main/java/me/libraryaddict/disguise/utilities/watchers/CompileMethods.java +++ b/shaded/src/main/java/me/libraryaddict/disguise/utilities/watchers/CompileMethods.java @@ -16,59 +16,85 @@ import me.libraryaddict.disguise.utilities.reflection.annotations.NmsAddedIn; import me.libraryaddict.disguise.utilities.reflection.annotations.NmsRemovedIn; import me.libraryaddict.disguise.utilities.sounds.DisguiseSoundEnums; import me.libraryaddict.disguise.utilities.sounds.SoundGroup; -import org.jetbrains.annotations.NotNull; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.nio.charset.StandardCharsets; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; import java.nio.file.Files; -import java.nio.file.StandardOpenOption; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.Arrays; +import java.util.Enumeration; import java.util.List; import java.util.Map; import java.util.Random; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; public class CompileMethods { public static void main(String[] args) { - doMethods(); - doSounds(); - doFileCount(); + Path zipFilePath = Paths.get(System.getProperty("jar.path")); + + try (FileSystem fs = FileSystems.newFileSystem(zipFilePath, (ClassLoader) null)) { + Files.write(fs.getPath("/METHOD_MAPPINGS.txt"), doMethods()); + Files.write(fs.getPath("/SOUND_MAPPINGS.txt"), doSounds()); + // Count after we write the mappings + Files.write(fs.getPath("/plugin.yml"), doFileCount()); + } catch (IOException e) { + e.printStackTrace(); + } } - private static void doFileCount() { - int totalCount = 0; + private static int getJarFileCount(File file, String... skipFiles) { + try (JarFile jar = new JarFile(file)) { + int count = 0; - for (String folder : new String[]{"plugin/target/classes", "shaded/target/classes"}) { - totalCount += getFileCount(new File(folder)); - } + Enumeration entries = jar.entries(); - try { - Files.write(new File(new File("shaded/target/classes"), "plugin.yml").toPath(), - ("\nfile-count: " + totalCount).getBytes(StandardCharsets.UTF_8), StandardOpenOption.APPEND); + loop: + while (entries.hasMoreElements()) { + JarEntry entry = entries.nextElement(); + + if (entry.isDirectory()) { + continue; + } + + for (String skipFile : skipFiles) { + if (!skipFile.equals(entry.getName())) { + continue; + } + + continue loop; + } + + count++; + } + + return count; } catch (IOException e) { throw new RuntimeException(e); } } - private static int getFileCount(File folder) { - int count = 0; + private static byte[] doFileCount() { + int totalCount = getJarFileCount(new File(System.getProperty("jar.path")), "METHOD_MAPPINGS.txt", "SOUND_MAPPINGS.txt") + 2; - for (File f : folder.listFiles()) { - if (f.isFile()) { - count++; - } else { - count += getFileCount(f); - } + try { + Path path = new File(new File("build/resources/main"), "plugin.yml").toPath(); + String pluginYaml = + Files.readString(path, StandardCharsets.UTF_8).replaceFirst("file-count: -?\\d+", "file-count: " + totalCount); + return pluginYaml.getBytes(StandardCharsets.UTF_8); + } catch (IOException e) { + throw new RuntimeException(e); } - - return count; } - private static void doSounds() { + private static byte[] doSounds() { List list = new ArrayList<>(); for (DisguiseSoundEnums e : DisguiseSoundEnums.values()) { @@ -77,16 +103,9 @@ public class CompileMethods { list.add(sound.toString()); } - File soundsFile = new File("shaded/target/classes/SOUND_MAPPINGS.txt"); - - try (FileOutputStream fos = new FileOutputStream(soundsFile)) { - fos.write(String.join("\n", list).getBytes(StandardCharsets.UTF_8)); - } catch (IOException e) { - e.printStackTrace(); - } + return String.join("\n", list).getBytes(StandardCharsets.UTF_8); } - @NotNull private static StringBuilder getSoundAsString(DisguiseSoundEnums e) { StringBuilder sound = new StringBuilder(e.name()); @@ -122,7 +141,7 @@ public class CompileMethods { classes.add(c); } - private static void doMethods() { + private static byte[] doMethods() { ArrayList> classes = ClassGetter.getClassesForPackage(FlagWatcher.class, "me.libraryaddict.disguise.disguisetypes.watchers"); @@ -258,15 +277,7 @@ public class CompileMethods { throw new IllegalStateException("Methods were not compiled"); } - String gson = new Gson().toJson(methods); - - File methodsFile = new File("shaded/target/classes/METHOD_MAPPINGS.txt"); - - try (FileOutputStream fos = new FileOutputStream(methodsFile)) { - fos.write(gson.getBytes(StandardCharsets.UTF_8)); - } catch (IOException e) { - e.printStackTrace(); - } + return new Gson().toJson(methods).getBytes(StandardCharsets.UTF_8); } static String getDescriptorForClass(final Class c) { diff --git a/shaded/src/main/resources/plugin.yml b/shaded/src/main/resources/plugin.yml index 5765672e..5ecc9ddd 100644 --- a/shaded/src/main/resources/plugin.yml +++ b/shaded/src/main/resources/plugin.yml @@ -1,13 +1,14 @@ name: LibsDisguises main: me.libraryaddict.disguise.LibsDisguises description: A disguise plugin with various disguises. -version: ${libsdisguises.version} +version: ${libsdisguisesVersion} build-date: ${timestamp} -build-number: ${build.number} +build-number: ${buildNumber} author: libraryaddict authors: [ Byteflux, Navid K. ] softdepend: [ packetevents ] api-version: '1.13' +file-count: 0 commands: libsdisguises: aliases: [ libsdisg, ld ] diff --git a/shaded/src/test/java/me/libraryaddict/disguise/disguisetypes/DisguiseCloneTest.java b/shaded/src/test/java/me/libraryaddict/disguise/disguisetypes/DisguiseCloneTest.java index 05f5fd94..f63a4356 100644 --- a/shaded/src/test/java/me/libraryaddict/disguise/disguisetypes/DisguiseCloneTest.java +++ b/shaded/src/test/java/me/libraryaddict/disguise/disguisetypes/DisguiseCloneTest.java @@ -6,11 +6,12 @@ import me.libraryaddict.disguise.utilities.parser.WatcherMethod; import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; import org.bukkit.Material; import org.bukkit.inventory.ItemStack; -import org.junit.Assert; import java.lang.invoke.MethodHandle; import java.util.Map; +import static org.junit.jupiter.api.Assertions.fail; + public class DisguiseCloneTest { /** @@ -94,7 +95,7 @@ public class DisguiseCloneTest { if (!dString.equals(cString)) { System.err.println(dString); System.err.println(cString); - Assert.fail("Cloned disguise is not the same!"); + fail("Cloned disguise is not the same!"); } } } catch (Exception ex) { diff --git a/shaded/src/test/java/me/libraryaddict/disguise/utilities/DisguiseUtilitiesTest.java b/shaded/src/test/java/me/libraryaddict/disguise/utilities/DisguiseUtilitiesTest.java index e9e3444a..bb85e70b 100644 --- a/shaded/src/test/java/me/libraryaddict/disguise/utilities/DisguiseUtilitiesTest.java +++ b/shaded/src/test/java/me/libraryaddict/disguise/utilities/DisguiseUtilitiesTest.java @@ -1,72 +1,71 @@ package me.libraryaddict.disguise.utilities; import me.libraryaddict.disguise.disguisetypes.DisguiseType; -import org.junit.Assert; -import org.junit.Test; import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; import java.util.Arrays; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class DisguiseUtilitiesTest { @Test public void testNewlineSplitter() { - Assert.assertArrayEquals(new String[]{"Name 1", "Name 2"}, DisguiseUtilities.splitNewLine("Name 1\nName 2")); - Assert.assertArrayEquals(new String[]{"Name 1", "Name 2"}, DisguiseUtilities.splitNewLine("Name 1\\nName 2")); - Assert.assertArrayEquals(new String[]{"Name 1\\", "Name 2"}, DisguiseUtilities.splitNewLine("Name 1\\\nName 2")); - Assert.assertArrayEquals(new String[]{"Name 1\\nName 2"}, DisguiseUtilities.splitNewLine("Name 1\\\\nName 2")); - Assert.assertArrayEquals(new String[]{"Name 1\\", "Name 2"}, DisguiseUtilities.splitNewLine("Name 1\\\\\\nName 2")); - Assert.assertArrayEquals(new String[]{"Name 1\\\\nName 2"}, DisguiseUtilities.splitNewLine("Name 1\\\\\\\\nName 2")); + assertArrayEquals(new String[]{"Name 1", "Name 2"}, DisguiseUtilities.splitNewLine("Name 1\nName 2")); + assertArrayEquals(new String[]{"Name 1", "Name 2"}, DisguiseUtilities.splitNewLine("Name 1\\nName 2")); + assertArrayEquals(new String[]{"Name 1\\", "Name 2"}, DisguiseUtilities.splitNewLine("Name 1\\\nName 2")); + assertArrayEquals(new String[]{"Name 1\\nName 2"}, DisguiseUtilities.splitNewLine("Name 1\\\\nName 2")); + assertArrayEquals(new String[]{"Name 1\\", "Name 2"}, DisguiseUtilities.splitNewLine("Name 1\\\\\\nName 2")); + assertArrayEquals(new String[]{"Name 1\\\\nName 2"}, DisguiseUtilities.splitNewLine("Name 1\\\\\\\\nName 2")); } @Test public void testQuoteSplitter() { // Test if splits are correct - Assert.assertArrayEquals(new String[]{"A", "simple", "string"}, DisguiseUtilities.split("A simple string")); + assertArrayEquals(new String[]{"A", "simple", "string"}, DisguiseUtilities.split("A simple string")); - Assert.assertArrayEquals(new String[]{"A quoted string"}, DisguiseUtilities.split("\"A quoted string\"")); + assertArrayEquals(new String[]{"A quoted string"}, DisguiseUtilities.split("\"A quoted string\"")); - Assert.assertArrayEquals(new String[]{"\"A double quoted string\""}, DisguiseUtilities.split("\"\"A double quoted string\"\"")); + assertArrayEquals(new String[]{"\"A double quoted string\""}, DisguiseUtilities.split("\"\"A double quoted string\"\"")); - Assert.assertArrayEquals(new String[]{"A", "string", "containing a", "quote"}, - DisguiseUtilities.split("A string \"containing a\" quote")); + assertArrayEquals(new String[]{"A", "string", "containing a", "quote"}, DisguiseUtilities.split("A string \"containing a\" quote")); - Assert.assertArrayEquals(new String[]{"A", "string", "fully", "split"}, DisguiseUtilities.split("\"A\" string fully split")); + assertArrayEquals(new String[]{"A", "string", "fully", "split"}, DisguiseUtilities.split("\"A\" string fully split")); - Assert.assertArrayEquals(new String[]{"A", "string", "fully", "split"}, DisguiseUtilities.split("\"A\" \"string\" fully split")); + assertArrayEquals(new String[]{"A", "string", "fully", "split"}, DisguiseUtilities.split("\"A\" \"string\" fully split")); - Assert.assertArrayEquals(new String[]{"A", "string", "fully", "split"}, DisguiseUtilities.split("A \"string\" fully split")); + assertArrayEquals(new String[]{"A", "string", "fully", "split"}, DisguiseUtilities.split("A \"string\" fully split")); // Test if quotes are ignored properly and included in result - Assert.assertArrayEquals(new String[]{"A", "\"string", "fully", "split"}, DisguiseUtilities.split("A \"string fully split")); + assertArrayEquals(new String[]{"A", "\"string", "fully", "split"}, DisguiseUtilities.split("A \"string fully split")); - Assert.assertArrayEquals(new String[]{"A", "\"string", "\"fully", "split"}, DisguiseUtilities.split("A \"string \"fully split")); + assertArrayEquals(new String[]{"A", "\"string", "\"fully", "split"}, DisguiseUtilities.split("A \"string \"fully split")); - Assert.assertArrayEquals(new String[]{"\"A", "\"string", "\"fully", "split"}, - DisguiseUtilities.split("\"A \"string \"fully split")); + assertArrayEquals(new String[]{"\"A", "\"string", "\"fully", "split"}, DisguiseUtilities.split("\"A \"string \"fully split")); - Assert.assertArrayEquals(new String[]{"A", "string\"", "fully", "split"}, DisguiseUtilities.split("A string\" fully split")); + assertArrayEquals(new String[]{"A", "string\"", "fully", "split"}, DisguiseUtilities.split("A string\" fully split")); - Assert.assertArrayEquals(new String[]{"A", "string\"", "fully\"", "split"}, DisguiseUtilities.split("A string\" fully\" split")); + assertArrayEquals(new String[]{"A", "string\"", "fully\"", "split"}, DisguiseUtilities.split("A string\" fully\" split")); - Assert.assertArrayEquals(new String[]{"A", "string", "fully\"", "split"}, DisguiseUtilities.split("A \"string\" fully\" split")); + assertArrayEquals(new String[]{"A", "string", "fully\"", "split"}, DisguiseUtilities.split("A \"string\" fully\" split")); - Assert.assertArrayEquals(new String[]{"A \"string", "with", "four", "splits"}, - DisguiseUtilities.split("\"A \"string\" with four splits")); + assertArrayEquals(new String[]{"A \"string", "with", "four", "splits"}, DisguiseUtilities.split("\"A \"string\" with four splits")); // Test for quotes inside words - Assert.assertArrayEquals(new String[]{"Fully", "split", "\"", "message"}, DisguiseUtilities.split("Fully split \"\"\" message")); + assertArrayEquals(new String[]{"Fully", "split", "\"", "message"}, DisguiseUtilities.split("Fully split \"\"\" message")); // Test to make sure space can be quoted, with an empty quote at the end - Assert.assertArrayEquals(new String[]{" ", "\""}, DisguiseUtilities.split("\" \" \"")); + assertArrayEquals(new String[]{" ", "\""}, DisguiseUtilities.split("\" \" \"")); // Test to make sure empty quotes, are still quotes - Assert.assertArrayEquals(new String[]{"Three", "", "split"}, DisguiseUtilities.split("Three \"\" split")); + assertArrayEquals(new String[]{"Three", "", "split"}, DisguiseUtilities.split("Three \"\" split")); // Test to ensure single quotes, are still not quotes - Assert.assertArrayEquals(new String[]{"'Three", "split", "message'"}, DisguiseUtilities.split("'Three split message'")); + assertArrayEquals(new String[]{"'Three", "split", "message'"}, DisguiseUtilities.split("'Three split message'")); // There is a quoted message inside the quoted message, however it was not escaped - Assert.assertArrayEquals(new String[]{"A", "quoted message \"inside a quoted message\""}, + assertArrayEquals(new String[]{"A", "quoted message \"inside a quoted message\""}, DisguiseUtilities.split("A \"quoted message \"inside a quoted message\"\"")); // Now test for escaped quotes, however as escaped quotes look different inside editors, I'll be replacing \ @@ -118,15 +117,15 @@ public class DisguiseUtilitiesTest { String quoted = DisguiseUtilities.quote(string); String[] split = DisguiseUtilities.split(quoted); - Assert.assertEquals(1, split.length); - Assert.assertEquals(string, split[0]); + assertEquals(1, split.length); + assertEquals(string, split[0]); } private void splitEquals(String toSplit, String... expected) { String[] splitted = DisguiseUtilities.split(toSplit.replace("/", "\\").replace("'", "\"")); String[] expect = Arrays.stream(expected).map(string -> string.replace("/", "\\").replace("'", "\"")).toArray(String[]::new); - Assert.assertArrayEquals(expect, splitted); + assertArrayEquals(expect, splitted); splitAndBack(toSplit); } @@ -155,15 +154,14 @@ public class DisguiseUtilitiesTest { @Test public void testYaw() { - Assertions.assertEquals(180, DisguiseUtilities.getYaw(DisguiseType.MINECART, DisguiseType.PLAYER, 90)); + assertEquals(180, DisguiseUtilities.getYaw(DisguiseType.MINECART, DisguiseType.PLAYER, 90)); } @Test public void testQuoter() { - Assertions.assertEquals("\"&c10.0 ❤ &8| &5Prokurator &8(&7poz. 1&8)\"", - DisguiseUtilities.quote("&c10.0 ❤ &8| &5Prokurator &8(&7poz. 1&8)")); - Assertions.assertEquals("String", DisguiseUtilities.quote("String")); - Assertions.assertEquals("\"\"String\"", DisguiseUtilities.quote("\"String")); - Assertions.assertEquals("\"String 2\"", DisguiseUtilities.quote("String 2")); + assertEquals("\"&c10.0 ❤ &8| &5Prokurator &8(&7poz. 1&8)\"", DisguiseUtilities.quote("&c10.0 ❤ &8| &5Prokurator &8(&7poz. 1&8)")); + assertEquals("String", DisguiseUtilities.quote("String")); + assertEquals("\"\"String\"", DisguiseUtilities.quote("\"String")); + assertEquals("\"String 2\"", DisguiseUtilities.quote("String 2")); } } diff --git a/shaded/src/test/java/me/libraryaddict/disguise/utilities/parser/DisguisePermissionsTest.java b/shaded/src/test/java/me/libraryaddict/disguise/utilities/parser/DisguisePermissionsTest.java index 3005d2ac..2e2ab933 100644 --- a/shaded/src/test/java/me/libraryaddict/disguise/utilities/parser/DisguisePermissionsTest.java +++ b/shaded/src/test/java/me/libraryaddict/disguise/utilities/parser/DisguisePermissionsTest.java @@ -4,13 +4,15 @@ import lombok.SneakyThrows; import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.disguisetypes.DisguiseType; +import org.bukkit.Bukkit; import org.bukkit.permissions.Permissible; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionAttachment; import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.plugin.Plugin; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; import java.util.ArrayList; import java.util.Arrays; @@ -20,27 +22,36 @@ import java.util.HashSet; import java.util.List; import java.util.Set; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + public class DisguisePermissionsTest { + @BeforeAll + public static void beforeAll() { + Mockito.mockStatic(Bukkit.class).when(Bukkit::getConsoleSender).thenReturn(null); + } + @Test public void testDisguisesExist() { - Assert.assertNull("There should not be a reindeer disguise", DisguiseParser.getDisguisePerm("Reindeer")); + assertNull(DisguiseParser.getDisguisePerm("Reindeer"), "There should not be a reindeer disguise"); - Assert.assertNotNull("There should be a cow disguise", DisguiseParser.getDisguisePerm("Cow")); + assertNotNull(DisguiseParser.getDisguisePerm("Cow"), "There should be a cow disguise"); - Assert.assertNotNull("There should be a firework disguise", DisguiseParser.getDisguisePerm("Firework")); + assertNotNull(DisguiseParser.getDisguisePerm("Firework"), "There should be a firework disguise"); } @Test public void testPermissionNames() { - Assert.assertFalse("There should not be permissions", createPermissions("Disguise", false).hasPermissions()); + assertFalse(createPermissions("Disguise", false).hasPermissions(), "There should not be permissions"); - Assert.assertFalse("The commands should not match", - createPermissions("Disguise", false, "libsdisguises.disguiseentity.cow").hasPermissions()); + assertFalse(createPermissions("Disguise", false, "libsdisguises.disguiseentity.cow").hasPermissions(), + "The commands should not match"); - Assert.assertFalse("The commands should not match", - createPermissions("Disguised", false, "libsdisguises.disguise.cow").hasPermissions()); + assertFalse(createPermissions("Disguised", false, "libsdisguises.disguise.cow").hasPermissions(), "The commands should not match"); - Assert.assertTrue("There should be permissions", createPermissions("Disguise", false, "libsdisguises.*.animal").hasPermissions()); + assertTrue(createPermissions("Disguise", false, "libsdisguises.*.animal").hasPermissions(), "There should be permissions"); } @Test @@ -48,47 +59,47 @@ public class DisguisePermissionsTest { DisguisePermissions permissions = createPermissions("Disguise", true, "-libsdisguises.disguise.sheep", "-libsdisguises.disguise.horse.setBaby"); - Assert.assertTrue("There should be permissions", permissions.hasPermissions()); + assertTrue(permissions.hasPermissions(), "There should be permissions"); - Assert.assertTrue("The disguise cow should be allowed", permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow")), "The disguise cow should be allowed"); - Assert.assertFalse("The disguise sheep should not be allowed", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Sheep"))); + assertFalse(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Sheep")), "The disguise sheep should not be allowed"); - Assert.assertTrue("The disguise horse should be allowed", permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Horse"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Horse")), "The disguise horse should be allowed"); - Assert.assertFalse("The disguise horse should not be allowed with setBaby", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Horse"), Collections.singletonList("setBaby"))); + assertFalse(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Horse"), Collections.singletonList("setBaby")), + "The disguise horse should not be allowed with setBaby"); } @Test public void testWildcardsPermissions() { - Assert.assertTrue("The cow disguise should be allowed", - createPermissions("Disguise", false, "libsdisguises.*.animal").isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"))); + assertTrue(createPermissions("Disguise", false, "libsdisguises.*.animal").isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow")), + "The cow disguise should be allowed"); - Assert.assertFalse("The firework disguise should not be allowed", - createPermissions("Disguise", false, "libsdisguises.*.animal").isAllowedDisguise(DisguiseParser.getDisguisePerm("Firework"))); + assertFalse( + createPermissions("Disguise", false, "libsdisguises.*.animal").isAllowedDisguise(DisguiseParser.getDisguisePerm("Firework")), + "The firework disguise should not be allowed"); - Assert.assertTrue("The firework disguise should be allowed", - createPermissions("Disguise", false, "libsdisguises.*.*").isAllowedDisguise(DisguiseParser.getDisguisePerm("Firework"))); + assertTrue(createPermissions("Disguise", false, "libsdisguises.*.*").isAllowedDisguise(DisguiseParser.getDisguisePerm("Firework")), + "The firework disguise should be allowed"); - Assert.assertTrue("The firework disguise should be allowed", - createPermissions("Disguise", false, "libsdisguises.disguise.*").isAllowedDisguise(DisguiseParser.getDisguisePerm("Firework"))); + assertTrue( + createPermissions("Disguise", false, "libsdisguises.disguise.*").isAllowedDisguise(DisguiseParser.getDisguisePerm("Firework")), + "The firework disguise should be allowed"); - Assert.assertTrue("The firework disguise should be allowed", - createPermissions("Disguise", false, "libsdisguises.*.Firework").isAllowedDisguise(DisguiseParser.getDisguisePerm("Firework"))); + assertTrue( + createPermissions("Disguise", false, "libsdisguises.*.Firework").isAllowedDisguise(DisguiseParser.getDisguisePerm("Firework")), + "The firework disguise should be allowed"); - Assert.assertFalse("The firework disguise should not be allowed", - createPermissions("Disguise", false, "libsdisguises.*.*", "-libsdisguises.*.misc").isAllowedDisguise( - DisguiseParser.getDisguisePerm("Firework"))); + assertFalse(createPermissions("Disguise", false, "libsdisguises.*.*", "-libsdisguises.*.misc").isAllowedDisguise( + DisguiseParser.getDisguisePerm("Firework")), "The firework disguise should not be allowed"); - Assert.assertTrue("The firework disguise should be allowed", - createPermissions("Disguise", false, "libsdisguises.disguise.*", "-libsdisguises.*.*").isAllowedDisguise( - DisguiseParser.getDisguisePerm("Firework"))); + assertTrue(createPermissions("Disguise", false, "libsdisguises.disguise.*", "-libsdisguises.*.*").isAllowedDisguise( + DisguiseParser.getDisguisePerm("Firework")), "The firework disguise should be allowed"); - Assert.assertTrue("The firework disguise should be allowed", + assertTrue( createPermissions("Disguise", false, "libsdisguises.disguise.firework", "-libsdisguises.disguise.misc").isAllowedDisguise( - DisguiseParser.getDisguisePerm("Firework"))); + DisguiseParser.getDisguisePerm("Firework")), "The firework disguise should be allowed"); } @Test @@ -101,18 +112,18 @@ public class DisguisePermissionsTest { } private void testInheritedPermissions(DisguisePermissions permissions) { - Assert.assertTrue("The sheep disguise should be allowed", permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Sheep"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Sheep")), "The sheep disguise should be allowed"); - Assert.assertTrue("The cow disguise should be allowed", permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow")), "The cow disguise should be allowed"); - Assert.assertTrue("The cow disguise should be allowed with setBaby", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"), Collections.singletonList("setBaby"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"), Collections.singletonList("setBaby")), + "The cow disguise should be allowed with setBaby"); - Assert.assertFalse("The sheep disguise should not be allowed with setBaby", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Sheep"), Collections.singletonList("setBaby"))); + assertFalse(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Sheep"), Collections.singletonList("setBaby")), + "The sheep disguise should not be allowed with setBaby"); - Assert.assertFalse("The firework disguise should not be allowed", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Firework"))); + assertFalse(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Firework")), + "The firework disguise should not be allowed"); } @Test @@ -121,20 +132,19 @@ public class DisguisePermissionsTest { createPermissions("Disguise", false, "libsdisguises.disguise.sheep", "-libsdisguises.disguise.cow.setSprinting", "-libsdisguises.disguise.donkey", "-libsdisguises.disguise.horse.setRearing", "libsdisguises.disguise.horse"); - Assert.assertFalse("The cow disguise should not be allowed", permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"))); + assertFalse(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow")), "The cow disguise should not be allowed"); - Assert.assertTrue("The sheep disguise should be allowed", permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Sheep"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Sheep")), "The sheep disguise should be allowed"); - Assert.assertFalse("The donkey disguise should not be allowed", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Donkey"))); + assertFalse(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Donkey")), "The donkey disguise should not be allowed"); - Assert.assertTrue("The horse disguise should be allowed", permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Horse"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Horse")), "The horse disguise should be allowed"); - Assert.assertTrue("The horse disguise should be allowed with options", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Horse"), Collections.singletonList("setBaby"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Horse"), Collections.singletonList("setBaby")), + "The horse disguise should be allowed with options"); - Assert.assertFalse("The horse disguise should not be allowed setRearing", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Horse"), Collections.singletonList("setRearing"))); + assertFalse(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Horse"), Collections.singletonList("setRearing")), + "The horse disguise should not be allowed setRearing"); } @Test @@ -143,69 +153,69 @@ public class DisguisePermissionsTest { createPermissions("Disguise", false, "libsdisguises.disguise.cow.setBaby", "libsdisguises.disguise.cow.setHealth", "libsdisguises.disguise.cow.-setBurning"); - Assert.assertTrue("The cow disguise should be able to use setBaby", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"), Collections.singletonList("setBaby"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"), Collections.singletonList("setBaby")), + "The cow disguise should be able to use setBaby"); - Assert.assertTrue("The cow disguise should be able to use setHealth", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"), Collections.singletonList("setHealth"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"), Collections.singletonList("setHealth")), + "The cow disguise should be able to use setHealth"); - Assert.assertTrue("The cow disguise should be able to use setBaby and setHealth", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"), Arrays.asList("setBaby", "setHealth"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"), Arrays.asList("setBaby", "setHealth")), + "The cow disguise should be able to use setBaby and setHealth"); - Assert.assertFalse("The cow disguise should not be able to use setBurning", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"), Collections.singletonList("setBurning"))); + assertFalse(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"), Collections.singletonList("setBurning")), + "The cow disguise should not be able to use setBurning"); - Assert.assertFalse("The cow disguise should not be able to use setSprinting", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"), Collections.singletonList("setSprinting"))); + assertFalse(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"), Collections.singletonList("setSprinting")), + "The cow disguise should not be able to use setSprinting"); - Assert.assertFalse("The cow disguise should not be able to use setSprinting with setBaby", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"), Arrays.asList("setSprinting", "setBaby"))); + assertFalse(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"), Arrays.asList("setSprinting", "setBaby")), + "The cow disguise should not be able to use setSprinting with setBaby"); } @Test public void testOptions() { - Assert.assertFalse("The disguise should not be valid", - createPermissions("Disguise", false, "libsdisguises.disguise.cow", "-libsdisguises.disguise.cow").hasPermissions()); + assertFalse(createPermissions("Disguise", false, "libsdisguises.disguise.cow", "-libsdisguises.disguise.cow").hasPermissions(), + "The disguise should not be valid"); DisguisePermissions permissions = createPermissions("Disguise", false, "libsdisguises.disguise.cow", "libsdisguises.disguise.sheep.setColor.setSprinting", "libsdisguises.disguise.animal.-setSprinting", "libsdisguises.disguise.sheep.setcolor.blue"); - Assert.assertTrue("There should be a valid disguise", permissions.hasPermissions()); + assertTrue(permissions.hasPermissions(), "There should be a valid disguise"); DisguisePerm cow = DisguiseParser.getDisguisePerm("Cow"); - Assert.assertTrue("The cow disguise should be allowed", permissions.isAllowedDisguise(cow)); + assertTrue(permissions.isAllowedDisguise(cow), "The cow disguise should be allowed"); - Assert.assertTrue("The cow disguise should be allowed with options", - permissions.isAllowedDisguise(cow, Arrays.asList("setBaby", "setBurning"))); + assertTrue(permissions.isAllowedDisguise(cow, Arrays.asList("setBaby", "setBurning")), + "The cow disguise should be allowed with options"); - Assert.assertFalse("The cow disguise should not be allowed with options setSprinting", - permissions.isAllowedDisguise(cow, Arrays.asList("setBaby", "setSprinting"))); + assertFalse(permissions.isAllowedDisguise(cow, Arrays.asList("setBaby", "setSprinting")), + "The cow disguise should not be allowed with options setSprinting"); - Assert.assertFalse("The cow disguise should not be allowed with options", - permissions.isAllowedDisguise(cow, Collections.singletonList("setSprinting"))); + assertFalse(permissions.isAllowedDisguise(cow, Collections.singletonList("setSprinting")), + "The cow disguise should not be allowed with options"); DisguisePerm sheep = DisguiseParser.getDisguisePerm("Sheep"); - Assert.assertFalse("The sheep disguise should not be allowed with options", - permissions.isAllowedDisguise(sheep, Arrays.asList("setBaby", "setBurning"))); + assertFalse(permissions.isAllowedDisguise(sheep, Arrays.asList("setBaby", "setBurning")), + "The sheep disguise should not be allowed with options"); - Assert.assertTrue("The sheep disguise should be allowed setColor", - permissions.isAllowedDisguise(sheep, Collections.singletonList("setColor"))); + assertTrue(permissions.isAllowedDisguise(sheep, Collections.singletonList("setColor")), + "The sheep disguise should be allowed setColor"); - Assert.assertTrue("The sheep disguise should be allowed setSprinting", - permissions.isAllowedDisguise(sheep, Collections.singletonList("setSprinting"))); + assertTrue(permissions.isAllowedDisguise(sheep, Collections.singletonList("setSprinting")), + "The sheep disguise should be allowed setSprinting"); - Assert.assertFalse("The sheep disguise should not be allowed setColor and setBaby", - permissions.isAllowedDisguise(sheep, Arrays.asList("setColor", "setBaby"))); + assertFalse(permissions.isAllowedDisguise(sheep, Arrays.asList("setColor", "setBaby")), + "The sheep disguise should not be allowed setColor and setBaby"); DisguisePerm firework = DisguiseParser.getDisguisePerm("Firework"); - Assert.assertFalse("The firework disguise should not be allowed", permissions.isAllowedDisguise(firework)); + assertFalse(permissions.isAllowedDisguise(firework), "The firework disguise should not be allowed"); - Assert.assertFalse("The disguise should not be allowed even with options", - permissions.isAllowedDisguise(firework, Arrays.asList("setBaby", "setBurning"))); + assertFalse(permissions.isAllowedDisguise(firework, Arrays.asList("setBaby", "setBurning")), + "The disguise should not be allowed even with options"); } @@ -215,14 +225,14 @@ public class DisguisePermissionsTest { createPermissionsHolder(false, "libsdisguises.options.disguise.falling_block.setblock.stone"), "Disguise", new DisguisePerm(DisguiseType.FALLING_BLOCK)); - Assert.assertTrue("They should be allowed to use true as a disguise option on setBurning", - DisguisePermissions.hasPermissionOption(disguiseOptions, "setBurning", "true")); + assertTrue(DisguisePermissions.hasPermissionOption(disguiseOptions, "setBurning", "true"), + "They should be allowed to use true as a disguise option on setBurning"); - Assert.assertTrue("They should be allowed to use Material.STONE as a disguise option", - DisguisePermissions.hasPermissionOption(disguiseOptions, "setBlock", "STONE")); + assertTrue(DisguisePermissions.hasPermissionOption(disguiseOptions, "setBlock", "STONE"), + "They should be allowed to use Material.STONE as a disguise option"); - Assert.assertFalse("They should be not allowed to use Material.DIRT as a disguise option", - DisguisePermissions.hasPermissionOption(disguiseOptions, "setBlock", "DIRT")); + assertFalse(DisguisePermissions.hasPermissionOption(disguiseOptions, "setBlock", "DIRT"), + "They should be not allowed to use Material.DIRT as a disguise option"); } @Test @@ -230,28 +240,28 @@ public class DisguisePermissionsTest { DisguisePermissions permissions = createPermissions("Disguise", false, "libsdisguises.disguise.falling_block.setCustomName", "libsdisguises.disguise.valid.falling_block.setblock"); - Assert.assertFalse("The falling block disguise should not allow setBurning", - permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.FALLING_BLOCK), Arrays.asList("setBurning"))); + assertFalse(permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.FALLING_BLOCK), Arrays.asList("setBurning")), + "The falling block disguise should not allow setBurning"); - Assert.assertTrue("The falling block disguise should allow setCustomName", - permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.FALLING_BLOCK), Arrays.asList("setcustomname"))); + assertTrue(permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.FALLING_BLOCK), Arrays.asList("setcustomname")), + "The falling block disguise should allow setCustomName"); - Assert.assertTrue("The falling block disguise should allow setBlock", - permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.FALLING_BLOCK), Arrays.asList("setBlock"))); + assertTrue(permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.FALLING_BLOCK), Arrays.asList("setBlock")), + "The falling block disguise should allow setBlock"); } @Test public void testDisguiseValidDoesntGiveExtra() { DisguisePermissions permissions = createPermissions("Disguise", false, "libsdisguises.disguise.valid.falling_block.setblock"); - Assert.assertFalse("The falling block disguise should not be allowed", - permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.FALLING_BLOCK))); + assertFalse(permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.FALLING_BLOCK)), + "The falling block disguise should not be allowed"); - Assert.assertFalse("The falling block disguise should not allow setBurning", - permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.FALLING_BLOCK), Arrays.asList("setBurning"))); + assertFalse(permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.FALLING_BLOCK), Arrays.asList("setBurning")), + "The falling block disguise should not allow setBurning"); - Assert.assertFalse("The falling block disguise should not allow setBlock", - permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.FALLING_BLOCK), Arrays.asList("setBlock"))); + assertFalse(permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.FALLING_BLOCK), Arrays.asList("setBlock")), + "The falling block disguise should not allow setBlock"); } @SneakyThrows @@ -260,26 +270,26 @@ public class DisguisePermissionsTest { DisguiseConfig.getCustomDisguises().put(new DisguisePerm(DisguiseType.BEE, "babybee"), "bee setbaby"); DisguisePermissions permissions = - createPermissions("me/libraryaddict/disguise/utilities/watchers", false, "libsdisguises.disguise.bee.-*", "libsdisguises.disguise.babybee.nooptions"); + createPermissions("Disguise", false, "libsdisguises.disguise.bee.-*", "libsdisguises.disguise.babybee.nooptions"); - Assert.assertNotNull("The custom disguise babybee should exist", DisguiseParser.getDisguisePerm("babybee")); + assertNotNull(DisguiseParser.getDisguisePerm("babybee"), "The custom disguise babybee should exist"); - Assert.assertTrue("They should be allowed to disguise as a bee", permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.BEE))); + assertTrue(permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.BEE)), "They should be allowed to disguise as a bee"); - Assert.assertFalse("They should not be allowed to disguise as a bee and call setbaby", - permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.BEE), Collections.singletonList("setbaby"))); + assertFalse(permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.BEE), Collections.singletonList("setbaby")), + "They should not be allowed to disguise as a bee and call setbaby"); - Assert.assertFalse("They should not be allowed to disguise as a burning bee", - permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.BEE), Collections.singletonList("setburning"))); + assertFalse(permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.BEE), Collections.singletonList("setburning")), + "They should not be allowed to disguise as a burning bee"); - Assert.assertFalse("They should not be allowed to disguise as a slime", - permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.SLIME))); + assertFalse(permissions.isAllowedDisguise(new DisguisePerm(DisguiseType.SLIME)), + "They should not be allowed to disguise as a slime"); - Assert.assertTrue("They should be allowed to disguise as babybee", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("babybee"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("babybee")), + "They should be allowed to disguise as babybee"); - Assert.assertFalse("They should not be allowed to disguise as babybee and use setbaby", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("babybee"), Collections.singletonList("setbaby"))); + assertFalse(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("babybee"), Collections.singletonList("setbaby")), + "They should not be allowed to disguise as babybee and use setbaby"); DisguiseAPI.removeCustomDisguise("babybee"); } @@ -293,38 +303,36 @@ public class DisguisePermissionsTest { "libsdisguises.disguise.skeleton.*", "libsdisguises.disguise.wither.setburning", "libsdisguises.disguise.silverfish.-setburning"); - Assert.assertTrue("The cow disguise should be usable", permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow")), "The cow disguise should be usable"); - Assert.assertFalse("The cow disguise should not be able to use setBurning", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"), Collections.singletonList("setBurning"))); + assertFalse(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Cow"), Collections.singletonList("setBurning")), + "The cow disguise should not be able to use setBurning"); - Assert.assertTrue("The zombie disguise should be usable", permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Zombie"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Zombie")), "The zombie disguise should be usable"); - Assert.assertFalse("The zombie disguise should not be able to use setBurning", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Zombie"), Collections.singletonList("setBurning"))); + assertFalse(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Zombie"), Collections.singletonList("setBurning")), + "The zombie disguise should not be able to use setBurning"); - Assert.assertTrue("The skeleton disguise should be usable", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Skeleton"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Skeleton")), "The skeleton disguise should be usable"); - Assert.assertTrue("The skeleton disguise should be able to use setBurning", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Skeleton"), Collections.singletonList("setBurning"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Skeleton"), Collections.singletonList("setBurning")), + "The skeleton disguise should be able to use setBurning"); - Assert.assertTrue("The wither disguise should be usable", permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Wither"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Wither")), "The wither disguise should be usable"); - Assert.assertTrue("The wither disguise should be able to use setBurning", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Wither"), Collections.singletonList("setBurning"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Wither"), Collections.singletonList("setBurning")), + "The wither disguise should be able to use setBurning"); - Assert.assertFalse("The wither disguise should not be able to use setSprinting", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Wither"), Collections.singletonList("setSprinting"))); + assertFalse(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Wither"), Collections.singletonList("setSprinting")), + "The wither disguise should not be able to use setSprinting"); - Assert.assertTrue("The silverfish disguise should be usable", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Silverfish"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Silverfish")), "The silverfish disguise should be usable"); - Assert.assertFalse("The silverfish disguise should not be able to use setBurning", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Silverfish"), Collections.singletonList("setBurning"))); + assertFalse(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Silverfish"), Collections.singletonList("setBurning")), + "The silverfish disguise should not be able to use setBurning"); - Assert.assertTrue("The silverfish disguise should be able to use setSprinting", - permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Silverfish"), Collections.singletonList("setSprinting"))); + assertTrue(permissions.isAllowedDisguise(DisguiseParser.getDisguisePerm("Silverfish"), Collections.singletonList("setSprinting")), + "The silverfish disguise should be able to use setSprinting"); DisguiseConfig.setExplicitDisguisePermissions(false); } diff --git a/shared/build.gradle.kts b/shared/build.gradle.kts new file mode 100644 index 00000000..e53adac4 --- /dev/null +++ b/shared/build.gradle.kts @@ -0,0 +1,10 @@ +dependencies { + compileOnly(libs.org.spigotmc.spigot) + compileOnly(libs.org.spigotmc.spigot.api) + compileOnly(libs.com.mojang.authlib) + compileOnly(libs.io.papermc.paper.paper.api) + compileOnly(libs.io.netty.netty.buffer) + compileOnly(libs.com.retro.packetevents) +} + +description = "shared" diff --git a/shared/pom.xml b/shared/pom.xml deleted file mode 100644 index 93e37304..00000000 --- a/shared/pom.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - parent - LibsDisguises - 1.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - shared - 1.0-SNAPSHOT - - - 1.8 - 1.8 - UTF-8 - - - - - com.mojang - authlib - 3.5.41 - provided - true - - - org.spigotmc - spigot - true - - - org.spigotmc - spigot-api - true - - - io.papermc.paper - paper-api - ${paper-api.version} - provided - true - - - io.netty - netty-buffer - 4.1.90.Final - provided - true - - - - \ No newline at end of file