diff --git a/.github/workflows/main_17.yml b/.github/workflows/main_17.yml new file mode 100644 index 0000000..c431243 --- /dev/null +++ b/.github/workflows/main_17.yml @@ -0,0 +1,152 @@ +name: build_16 +on: + push: + branches: + - master +jobs: + build: + name: Build Jar1 + runs-on: ubuntu-latest + steps: + - name: checkout repository + uses: actions/checkout@v2 + - name: validate gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: setup jdk 8.0 + uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: 8.0 + - name: make gradle wrapper executable + run: chmod +x ./gradlew + # 第一次构建 + - name: build + continue-on-error: true + id: build_1 + run: ./gradlew build -Porder=$GITHUB_RUN_NUMBER + # 第二次构建 + - name: build (retry 1) + continue-on-error: true + id: build_2 + if: steps.build_1.outcome == 'failure' + run: ./gradlew build -Porder=$GITHUB_RUN_NUMBER + # 第三次构建 + - name: build (retry 2) + continue-on-error: true + id: build_3 + if: steps.build_2.outcome == 'failure' + run: ./gradlew build -Porder=$GITHUB_RUN_NUMBER + # 第四次构建 + - name: build (retry 3) + id: build_4 + if: steps.build_3.outcome == 'failure' + run: ./gradlew build -Porder=$GITHUB_RUN_NUMBER + # 上传构建文件 + - name: capture build artifacts + uses: actions/upload-artifact@v2 + with: + name: Artifacts + path: build/libs/ + build-api: + name: Build API Jar + runs-on: ubuntu-latest + steps: + - name: checkout repository + uses: actions/checkout@v2 + - name: validate gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: setup jdk 8.0 + uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: 8.0 + - name: make gradle wrapper executable + run: chmod +x ./gradlew + - name: build + continue-on-error: true + id: build_api_1 + run: ./gradlew build -Papi=common -Porder=$GITHUB_RUN_NUMBER + - name: build (retry 1) + continue-on-error: true + id: build_api_2 + if: steps.build_api_1.outcome == 'failure' + run: ./gradlew build -Papi=common -Porder=$GITHUB_RUN_NUMBER + - name: build (retry 2) + continue-on-error: true + id: build_api_3 + if: steps.build_api_2.outcome == 'failure' + run: ./gradlew build -Papi=common -Porder=$GITHUB_RUN_NUMBER + - name: build (retry 3) + id: build_api_4 + if: steps.build_api_3.outcome == 'failure' + run: ./gradlew build -Papi=common -Porder=$GITHUB_RUN_NUMBER + # 上传构建文件 + - name: capture build api artifacts + uses: actions/upload-artifact@v2 + with: + name: Artifacts + path: build/libs + release: + name: Release Jar + needs: [ build, build-api ] + runs-on: ubuntu-latest + steps: + - name: checkout repository + uses: actions/checkout@v2 + - name: validate gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: setup jdk 8.0 + uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: 8.0 + - name: make gradle wrapper executable + run: chmod +x ./gradlew + - name: Get Project name + id: get_name + run: | + output=$(./gradlew properties) + name=$(echo "$output" | grep "^name:" | cut -d' ' -f2) + echo "Project name: $name" + echo "::set-output name=project_name::$name" + env: + project_name: ${{ steps.get_name.outputs.project_name }} + - name: Get Project version + id: get_version + run: | + output=$(./gradlew properties) + version=$(echo "$output" | grep "^version:" | cut -d' ' -f2) + echo "Project version: $version-$GITHUB_RUN_NUMBER" + echo "::set-output name=project_version::$version-$GITHUB_RUN_NUMBER" + env: + project_version: ${{ steps.get_version.outputs.project_version }} + - name: Download Content + uses: actions/download-artifact@v2 + with: + name: Artifacts + - name: Create release + id: create-new-release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.get_version.outputs.project_version }} + release_name: ${{ steps.get_version.outputs.project_name }} ${{ steps.get_version.outputs.project_version }} + - name: Upload API Jar asset to Release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create-new-release.outputs.upload_url }} + asset_path: ${{ steps.get_name.outputs.project_name }}-${{ steps.get_version.outputs.project_version }}-api.jar + asset_name: ${{ steps.get_name.outputs.project_name }}-${{ steps.get_version.outputs.project_version }}-api.jar + asset_content_type: application/zip + - name: Upload Jar asset to Release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create-new-release.outputs.upload_url }} + asset_path: ${{ steps.get_name.outputs.project_name }}-${{ steps.get_version.outputs.project_version }}.jar + asset_name: ${{ steps.get_name.outputs.project_name }}-${{ steps.get_version.outputs.project_version }}.jar + asset_content_type: application/zip diff --git a/.github/workflows/publish_17.yml b/.github/workflows/publish_17.yml new file mode 100644 index 0000000..6008b8e --- /dev/null +++ b/.github/workflows/publish_17.yml @@ -0,0 +1,79 @@ +name: publish_16 +on: + push: + branches: + - master +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: checkout repository + uses: actions/checkout@v2 + - name: validate gradle wrapper + uses: gradle/wrapper-validation-action@v1 + - name: setup jdk 8.0 + uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: 8.0 + - name: Cache Gradle packages + uses: actions/cache@v2 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + - name: make gradle wrapper executable + run: chmod +x ./gradlew + - name: Decode + run: | + if [ ! -d "~/.gradle/" ];then + mkdir ~/.gradle + else + echo "~/.gradle/ exists" + fi + touch ~/.gradle/secring.pgp.base64 + echo "${{ secrets.SIGNING_SECRET_KEY_RING_FILE }}" > ~/.gradle/secring.pgp.base64 + base64 -d ~/.gradle/secring.pgp.base64 > ~/.gradle/secring.pgp + # 发布到仓库 + - name: publish + id: publish_1 + continue-on-error: true + env: + NEXUS_USERNAME: ${{ secrets.USERNAME }} + NEXUS_PASSWORD: ${{ secrets.PASSWORD }} + run: ./gradlew publish -Porder=$GITHUB_RUN_NUMBER -Pbuild=$GITHUB_RUN_NUMBER -Pusername=$NEXUS_USERNAME -Ppassword=$NEXUS_PASSWORD -Psigning.keyId=${{secrets.SIGNING_KEY_ID}} -Psigning.password=${{secrets.SIGNING_KEY_PASSWORD}} -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.pgp) + + # 发布到仓库: 重试-1 + - name: publish (retry 1) + id: publish_2 + if: steps.publish_1.outcome == 'failure' + continue-on-error: true + env: + NEXUS_USERNAME: ${{ secrets.USERNAME }} + NEXUS_PASSWORD: ${{ secrets.PASSWORD }} + run: ./gradlew publish -Porder=$GITHUB_RUN_NUMBER -Pbuild=$GITHUB_RUN_NUMBER -Pusername=$NEXUS_USERNAME -Ppassword=$NEXUS_PASSWORD -Psigning.keyId=${{secrets.SIGNING_KEY_ID}} -Psigning.password=${{secrets.SIGNING_KEY_PASSWORD}} -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.pgp) + + # 发布到仓库: 重试-2 + - name: publish (retry 2) + id: publish_3 + if: steps.publish_2.outcome == 'failure' + continue-on-error: true + env: + NEXUS_USERNAME: ${{ secrets.USERNAME }} + NEXUS_PASSWORD: ${{ secrets.PASSWORD }} + run: ./gradlew publish -Porder=$GITHUB_RUN_NUMBER -Pbuild=$GITHUB_RUN_NUMBER -Pusername=$NEXUS_USERNAME -Ppassword=$NEXUS_PASSWORD -Psigning.keyId=${{secrets.SIGNING_KEY_ID}} -Psigning.password=${{secrets.SIGNING_KEY_PASSWORD}} -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.pgp) + + # 发布到仓库: 重试-3 + - name: publish (retry 3) + id: publish_4 + if: steps.publish_3.outcome == 'failure' + env: + NEXUS_USERNAME: ${{ secrets.USERNAME }} + NEXUS_PASSWORD: ${{ secrets.PASSWORD }} + run: ./gradlew publish -Porder=$GITHUB_RUN_NUMBER -Pbuild=$GITHUB_RUN_NUMBER -Pusername=$NEXUS_USERNAME -Ppassword=$NEXUS_PASSWORD -Psigning.keyId=${{secrets.SIGNING_KEY_ID}} -Psigning.password=${{secrets.SIGNING_KEY_PASSWORD}} -Psigning.secretKeyRingFile=$(echo ~/.gradle/secring.pgp) + - name: Auto Close And Release + id: close_and_release + env: + NEXUS_USERNAME: ${{ secrets.USERNAME }} + NEXUS_PASSWORD: ${{ secrets.PASSWORD }} + run: ./gradlew closeAndReleaseRepository -Pusername=$NEXUS_USERNAME -Ppassword=$NEXUS_PASSWORD \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2dee4a6 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.gradle +.idea +build +libs/MythicMobs-Premium-5.1.0.jar +libs/MythicMobs-Premium-5.1.0.jar diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..1625c17 --- /dev/null +++ b/LICENSE @@ -0,0 +1,121 @@ +Creative Commons Legal Code + +CC0 1.0 Universal + + CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE + LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN + ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS + INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES + REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS + PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM + THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED + HEREUNDER. + +Statement of Purpose + +The laws of most jurisdictions throughout the world automatically confer +exclusive Copyright and Related Rights (defined below) upon the creator +and subsequent owner(s) (each and all, an "owner") of an original work of +authorship and/or a database (each, a "Work"). + +Certain owners wish to permanently relinquish those rights to a Work for +the purpose of contributing to a commons of creative, cultural and +scientific works ("Commons") that the public can reliably and without fear +of later claims of infringement build upon, modify, incorporate in other +works, reuse and redistribute as freely as possible in any form whatsoever +and for any purposes, including without limitation commercial purposes. +These owners may contribute to the Commons to promote the ideal of a free +culture and the further production of creative, cultural and scientific +works, or to gain reputation or greater distribution for their Work in +part through the use and efforts of others. + +For these and/or other purposes and motivations, and without any +expectation of additional consideration or compensation, the person +associating CC0 with a Work (the "Affirmer"), to the extent that he or she +is an owner of Copyright and Related Rights in the Work, voluntarily +elects to apply CC0 to the Work and publicly distribute the Work under its +terms, with knowledge of his or her Copyright and Related Rights in the +Work and the meaning and intended legal effect of CC0 on those rights. + +1. Copyright and Related Rights. A Work made available under CC0 may be +protected by copyright and related or neighboring rights ("Copyright and +Related Rights"). Copyright and Related Rights include, but are not +limited to, the following: + + i. the right to reproduce, adapt, distribute, perform, display, + communicate, and translate a Work; + ii. moral rights retained by the original author(s) and/or performer(s); +iii. publicity and privacy rights pertaining to a person's image or + likeness depicted in a Work; + iv. rights protecting against unfair competition in regards to a Work, + subject to the limitations in paragraph 4(a), below; + v. rights protecting the extraction, dissemination, use and reuse of data + in a Work; + vi. database rights (such as those arising under Directive 96/9/EC of the + European Parliament and of the Council of 11 March 1996 on the legal + protection of databases, and under any national implementation + thereof, including any amended or successor version of such + directive); and +vii. other similar, equivalent or corresponding rights throughout the + world based on applicable law or treaty, and any national + implementations thereof. + +2. Waiver. To the greatest extent permitted by, but not in contravention +of, applicable law, Affirmer hereby overtly, fully, permanently, +irrevocably and unconditionally waives, abandons, and surrenders all of +Affirmer's Copyright and Related Rights and associated claims and causes +of action, whether now known or unknown (including existing as well as +future claims and causes of action), in the Work (i) in all territories +worldwide, (ii) for the maximum duration provided by applicable law or +treaty (including future time extensions), (iii) in any current or future +medium and for any number of copies, and (iv) for any purpose whatsoever, +including without limitation commercial, advertising or promotional +purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each +member of the public at large and to the detriment of Affirmer's heirs and +successors, fully intending that such Waiver shall not be subject to +revocation, rescission, cancellation, termination, or any other legal or +equitable action to disrupt the quiet enjoyment of the Work by the public +as contemplated by Affirmer's express Statement of Purpose. + +3. Public License Fallback. Should any part of the Waiver for any reason +be judged legally invalid or ineffective under applicable law, then the +Waiver shall be preserved to the maximum extent permitted taking into +account Affirmer's express Statement of Purpose. In addition, to the +extent the Waiver is so judged Affirmer hereby grants to each affected +person a royalty-free, non transferable, non sublicensable, non exclusive, +irrevocable and unconditional license to exercise Affirmer's Copyright and +Related Rights in the Work (i) in all territories worldwide, (ii) for the +maximum duration provided by applicable law or treaty (including future +time extensions), (iii) in any current or future medium and for any number +of copies, and (iv) for any purpose whatsoever, including without +limitation commercial, advertising or promotional purposes (the +"License"). The License shall be deemed effective as of the date CC0 was +applied by Affirmer to the Work. Should any part of the License for any +reason be judged legally invalid or ineffective under applicable law, such +partial invalidity or ineffectiveness shall not invalidate the remainder +of the License, and in such case Affirmer hereby affirms that he or she +will not (i) exercise any of his or her remaining Copyright and Related +Rights in the Work or (ii) assert any associated claims and causes of +action with respect to the Work, in either case contrary to Affirmer's +express Statement of Purpose. + +4. Limitations and Disclaimers. + + a. No trademark or patent rights held by Affirmer are waived, abandoned, + surrendered, licensed or otherwise affected by this document. + b. Affirmer offers the Work as-is and makes no representations or + warranties of any kind concerning the Work, express, implied, + statutory or otherwise, including without limitation warranties of + title, merchantability, fitness for a particular purpose, non + infringement, or the absence of latent or other defects, accuracy, or + the present or absence of errors, whether or not discoverable, all to + the greatest extent permissible under applicable law. + c. Affirmer disclaims responsibility for clearing rights of other persons + that may apply to the Work or any use thereof, including without + limitation any person's Copyright and Related Rights in the Work. + Further, Affirmer disclaims responsibility for obtaining any necessary + consents, permissions or other rights required for any use of the + Work. + d. Affirmer understands and acknowledges that Creative Commons is not a + party to this document and has no duty or obligation with respect to + this CC0 or use of the Work. \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..2ae735a --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,92 @@ +plugins { + `java-library` + `maven-publish` + signing + id("io.izzel.taboolib") version "1.56" + id("org.jetbrains.kotlin.jvm") version "1.5.31" + id("io.codearte.nexus-staging") version "0.30.0" +} + + +val order: String? by project +val api: String? by project +task("api-add") { + var version = project.version.toString() + (order?.let { "-$it" } ?: "") + if (api != null && api == "common") + version = "$version-api" + project.version = version +} +task("info") { + println(project.name + "-" + project.version) + println(project.version.toString()) +} +taboolib { + if (api != null) { + println("api!") + taboolib.options("skip-kotlin-relocate", "keep-kotlin-module") + } + + description { + contributors { + name("Clok") + } + dependencies { + name("Pouvoir") + name("UnrealCore") + } + } + install("module-configuration") + install("module-lang") + install("platform-bukkit") + install("common") + install("module-metrics") + install("module-chat") + install("common-5") + + classifier = null + version = "6.0.12-69" +} +repositories { + mavenCentral() + maven { url = uri("https://mvn.lumine.io/repository/maven-public/") } +} + + +tasks.withType { + kotlinOptions { + jvmTarget = "1.8" + freeCompilerArgs = listOf("-Xjvm-default=all") + } +} +dependencies { + compileOnly("ink.ptms.core:v11800:11800-minimize:mapped") + compileOnly("ink.ptms.core:v11800:11800-minimize:api") + compileOnly("com.google.code.gson:gson:2.9.0") + compileOnly("io.lumine:Mythic-Dist:5.0.3") + compileOnly(kotlin("stdlib")) + compileOnly(fileTree("libs")) + +} + +tasks.withType { + options.encoding = "UTF-8" +} + +configure { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} + +tasks.register("buildAPIJar") { + dependsOn(tasks.compileJava, tasks.compileKotlin) + from(tasks.compileJava, tasks.compileKotlin) + includeEmptyDirs = false + include { it.isDirectory or it.name.endsWith(".class") or it.name.endsWith(".kotlin_module") } + archiveClassifier.set("api") +} + +tasks.register("buildSourcesJar") { + dependsOn(JavaPlugin.CLASSES_TASK_NAME) + archiveClassifier.set("sources") + from(sourceSets["main"].allSource) +} diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..3bf1491 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,2 @@ +group=com.skillw.uisystem +version=1.0.0 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..94336fc 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 0000000..573fe49 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,5 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists \ No newline at end of file diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..cccdd3d --- /dev/null +++ b/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# 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 + ;; + 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" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,84 @@ +@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=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@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= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +: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 %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/libs/Pouvoir-1.6.6-gamma-api.jar b/libs/Pouvoir-1.6.6-gamma-api.jar new file mode 100644 index 0000000..72fdd46 Binary files /dev/null and b/libs/Pouvoir-1.6.6-gamma-api.jar differ diff --git a/libs/UnrealCore-Plugin-2.0-beta30-Java8.jar b/libs/UnrealCore-Plugin-2.0-beta30-Java8.jar new file mode 100644 index 0000000..8caf6f1 Binary files /dev/null and b/libs/UnrealCore-Plugin-2.0-beta30-Java8.jar differ diff --git a/libs/patched_1.17.1.jar b/libs/patched_1.17.1.jar new file mode 100644 index 0000000..cd13dc6 Binary files /dev/null and b/libs/patched_1.17.1.jar differ diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..92b0706 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name="UISystem" \ No newline at end of file diff --git a/src/main/kotlin/com/skillw/uisystem/UISystem.kt b/src/main/kotlin/com/skillw/uisystem/UISystem.kt new file mode 100644 index 0000000..4b27696 --- /dev/null +++ b/src/main/kotlin/com/skillw/uisystem/UISystem.kt @@ -0,0 +1,64 @@ +package com.skillw.uisystem + +import com.skillw.pouvoir.api.manager.ManagerData +import com.skillw.pouvoir.api.plugin.SubPouvoir +import com.skillw.pouvoir.api.plugin.annotation.PouManager +import com.skillw.uisystem.api.manager.GuiManager +import com.skillw.uisystem.api.manager.RdataManager +import com.skillw.uisystem.internal.manager.UIConfig +import org.bukkit.plugin.java.JavaPlugin +import taboolib.common.platform.Plugin +import taboolib.module.configuration.Config +import taboolib.module.configuration.ConfigFile +import taboolib.platform.BukkitPlugin + +object UISystem : Plugin(), SubPouvoir { + + /** Basic */ + + override val key = "UISystem" + override val plugin: JavaPlugin by lazy(LazyThreadSafetyMode.NONE) { + BukkitPlugin.getInstance() + } + + /** Config */ + @Config("config.yml") + lateinit var config: ConfigFile + + + /** Managers */ + + override lateinit var managerData: ManagerData + + @JvmStatic + @PouManager + lateinit var configManager: UIConfig + + @JvmStatic + @PouManager + lateinit var guiManager: GuiManager + + @JvmStatic + @PouManager + lateinit var rdataManager: RdataManager + + + + override fun onLoad() { + load() + } + + override fun onEnable() { + enable() + } + + override fun onActive() { + active() + } + + override fun onDisable() { + disable() + } + + +} \ No newline at end of file diff --git a/src/main/kotlin/com/skillw/uisystem/api/UIApi.kt b/src/main/kotlin/com/skillw/uisystem/api/UIApi.kt new file mode 100644 index 0000000..ff1ea37 --- /dev/null +++ b/src/main/kotlin/com/skillw/uisystem/api/UIApi.kt @@ -0,0 +1,19 @@ +package com.skillw.uisystem.api + +import com.daxton.unrealcore.resource.controller.ResourceController +import com.skillw.uisystem.UISystem +import com.skillw.uisystem.internal.manager.UIConfig +import org.bukkit.entity.Player + +object UIApi { + + @JvmStatic + internal fun Player.openGui(key: String){ + UISystem.guiManager.OpenGui(this,key) + } + + @JvmStatic + internal fun Player.sendRes(){ + ResourceController.load(player, UIConfig.resources, UIConfig.resourcesPassword) + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/skillw/uisystem/api/event/GuiRegisterEvent.kt b/src/main/kotlin/com/skillw/uisystem/api/event/GuiRegisterEvent.kt new file mode 100644 index 0000000..abd7cae --- /dev/null +++ b/src/main/kotlin/com/skillw/uisystem/api/event/GuiRegisterEvent.kt @@ -0,0 +1,6 @@ +package com.skillw.uisystem.api.event + +import com.skillw.uisystem.api.gui.Gui +import taboolib.platform.type.BukkitProxyEvent + +class GuiRegisterEvent(val key: String, val gui: Gui) : BukkitProxyEvent() diff --git a/src/main/kotlin/com/skillw/uisystem/api/gui/Gui.kt b/src/main/kotlin/com/skillw/uisystem/api/gui/Gui.kt new file mode 100644 index 0000000..4ca8546 --- /dev/null +++ b/src/main/kotlin/com/skillw/uisystem/api/gui/Gui.kt @@ -0,0 +1,24 @@ +package com.skillw.uisystem.api.gui + +import com.daxton.unrealcore.display.been.gui.MainGUIData +import com.daxton.unrealcore.display.content.gui.UnrealCoreGUI +import com.daxton.unrealcore.display.content.module.ModuleComponents +import com.skillw.pouvoir.api.plugin.map.component.Registrable +import com.skillw.uisystem.UISystem + +abstract class Gui : + Registrable, UnrealCoreGUI() { + + abstract override val key: String + + abstract override fun opening() + + var release = false + + abstract override fun close() + + final override fun register() { + com.skillw.uisystem.UISystem.guiManager.register(this) + } + +} diff --git a/src/main/kotlin/com/skillw/uisystem/api/gui/test.kt b/src/main/kotlin/com/skillw/uisystem/api/gui/test.kt new file mode 100644 index 0000000..5648335 --- /dev/null +++ b/src/main/kotlin/com/skillw/uisystem/api/gui/test.kt @@ -0,0 +1,26 @@ +package com.skillw.uisystem.api.gui + +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister + +@AutoRegister +object test: Gui() { + override val key: String = "test" + init { + print(mainGUIData.moduleID) + val data = mainGUIData + data.image = "xxx.png" + data.x = "10" + data.y = "10" + data.position = "0" + data.width = "10" + data.height = "10" + data.mask = "true" + data.color = "ffffff" + data.transparent = "255" + } + override fun opening() { + } + + override fun close() { + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/skillw/uisystem/api/manager/GuiManager.kt b/src/main/kotlin/com/skillw/uisystem/api/manager/GuiManager.kt new file mode 100644 index 0000000..8a4c7af --- /dev/null +++ b/src/main/kotlin/com/skillw/uisystem/api/manager/GuiManager.kt @@ -0,0 +1,10 @@ +package com.skillw.uisystem.api.manager + +import com.skillw.pouvoir.api.manager.Manager +import com.skillw.pouvoir.api.plugin.map.KeyMap +import com.skillw.uisystem.api.gui.Gui +import org.bukkit.entity.Player + +abstract class GuiManager: KeyMap(), Manager{ + abstract fun OpenGui(player: Player, key: String) +} \ No newline at end of file diff --git a/src/main/kotlin/com/skillw/uisystem/api/manager/RdataManager.kt b/src/main/kotlin/com/skillw/uisystem/api/manager/RdataManager.kt new file mode 100644 index 0000000..e5728f7 --- /dev/null +++ b/src/main/kotlin/com/skillw/uisystem/api/manager/RdataManager.kt @@ -0,0 +1,36 @@ +package com.skillw.uisystem.api.manager + +import com.daxton.unrealcore.resource.been.ResourceStatus +import com.skillw.pouvoir.api.manager.Manager +import com.skillw.pouvoir.api.plugin.map.BaseMap +import com.skillw.uisystem.UISystem +import org.bukkit.entity.Player +import java.util.UUID + +abstract class RdataManager: Manager, BaseMap() { + + abstract fun setPlayer(player: Player,boolean: ResourceStatus) + + abstract fun removePlayer(player: Player) + + abstract fun hasPlayer(player: Player): Boolean + + abstract fun PlayerIsFinish(player: Player): Boolean? + + companion object { + + fun Player.addPlayer(r: ResourceStatus){ + UISystem.rdataManager.setPlayer(this,r) + } + + fun Player.removePlayer(){ + UISystem.rdataManager.removePlayer(this) + } + + fun Player.hasPlayer(){ + UISystem.rdataManager.hasPlayer(this) + } + + } + +} \ No newline at end of file diff --git a/src/main/kotlin/com/skillw/uisystem/internal/command/UICommand.kt b/src/main/kotlin/com/skillw/uisystem/internal/command/UICommand.kt new file mode 100644 index 0000000..76d3087 --- /dev/null +++ b/src/main/kotlin/com/skillw/uisystem/internal/command/UICommand.kt @@ -0,0 +1,89 @@ +package com.skillw.uisystem.internal.command + +import com.skillw.pouvoir.util.soundClick +import com.skillw.pouvoir.util.soundFail +import com.skillw.pouvoir.util.soundSuccess +import com.skillw.uisystem.UISystem +import com.skillw.uisystem.api.UIApi.openGui +import com.skillw.uisystem.internal.manager.UIConfig.isDebug +import org.bukkit.command.CommandSender +import org.bukkit.entity.Player +import taboolib.common.platform.ProxyCommandSender +import taboolib.common.platform.command.* +import taboolib.common.platform.function.console +import taboolib.module.chat.colored +import taboolib.module.lang.sendLang +import taboolib.platform.util.bukkitPlugin +import taboolib.platform.util.sendLang + +@CommandHeader(name = "ui", permission = "ui.command") +object UICommand { + + internal fun ProxyCommandSender.soundSuccess() { + (this.origin as? Player?)?.soundSuccess() + } + + internal fun ProxyCommandSender.soundFail() { + (this.origin as? Player?)?.soundFail() + } + + @CommandBody + val main = mainCommand { + execute { sender, _, _ -> + sender.sendLang("command-info") + sender.soundSuccess() + } + incorrectCommand { sender, _, _, _ -> + sender.sendLang("wrong-command") + sender.soundFail() + } + incorrectSender { sender, _ -> + sender.sendLang("wrong-sender") + sender.soundFail() + } + } + + @CommandBody(permission = "ui.command.help") + val help = subCommand { + execute { sender, _, _ -> + sender.soundSuccess() + sender.sendLang("command-info") + } + } + + @CommandBody(permission = "ui.command.debug") + val debug = subCommand { + execute { sender, _, _ -> + sender.soundSuccess() + isDebug = if (!isDebug) { + sender.sendMessage("&aDebug on!".colored()) + true + } else { + sender.sendMessage("&aDebug off!".colored()) + false + } + } + } + @CommandBody(permission = "ui.command.open") + val open = subCommand { + dynamic("guiID"){ + suggestion {zxy, _-> + zxy.soundSuccess() + UISystem.guiManager.keys.toList() + } + execute {zxy,context,_-> + (zxy.origin as Player).openGui(context["guiID"]) + } + } + } + + @CommandBody(permission = "ui.command.reload") + val reload = subCommand { + execute { sender, _, _ -> + sender.soundSuccess() + UISystem.reload() + sender.sendLang("command-reload") + } + } + +} \ No newline at end of file diff --git a/src/main/kotlin/com/skillw/uisystem/internal/feather/compat/pouvoir/annotation/GuiAnnotation.kt b/src/main/kotlin/com/skillw/uisystem/internal/feather/compat/pouvoir/annotation/GuiAnnotation.kt new file mode 100644 index 0000000..7ce1fa8 --- /dev/null +++ b/src/main/kotlin/com/skillw/uisystem/internal/feather/compat/pouvoir/annotation/GuiAnnotation.kt @@ -0,0 +1,31 @@ +package com.skillw.uisystem.internal.feather.compat.pouvoir.annotation + +import com.daxton.unrealcore.display.been.gui.MainGUIData +import com.skillw.pouvoir.Pouvoir +import com.skillw.pouvoir.api.plugin.annotation.AutoRegister +import com.skillw.pouvoir.api.script.annotation.ScriptAnnotation +import com.skillw.pouvoir.api.script.annotation.ScriptAnnotationData +import com.skillw.uisystem.api.gui.Gui +import javax.script.ScriptContext + +@AutoRegister +internal object GuiAnnotation: ScriptAnnotation("GuiCreate",fileAnnotation = true){ + override fun handle(data: ScriptAnnotationData) { + val script = data.script + val vars = script.script.engine.getBindings(ScriptContext.ENGINE_SCOPE) + val key = vars["key"]?.toString() ?: error("无法找到${script.key}变量key") + val setting = vars["setting"] as MainGUIData + object : Gui(){ + override val key: String = key + init { + this.mainGUIData = setting + } + override fun opening() { + Pouvoir.scriptManager.invoke(script, "opening", parameters = arrayOf(this)) + } + override fun close() { + Pouvoir.scriptManager.invoke(script, "close", parameters = arrayOf(this)) + } + }.register() + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/skillw/uisystem/internal/feather/resource/Listner.kt b/src/main/kotlin/com/skillw/uisystem/internal/feather/resource/Listner.kt new file mode 100644 index 0000000..523365f --- /dev/null +++ b/src/main/kotlin/com/skillw/uisystem/internal/feather/resource/Listner.kt @@ -0,0 +1,72 @@ +package com.skillw.uisystem.internal.feather.resource + +import com.daxton.unrealcore.communication.event.PlayerConnectionSuccessfulEvent +import com.daxton.unrealcore.resource.been.ResourceStatus +import com.daxton.unrealcore.resource.event.PlayerResourcePackEvent +import com.skillw.uisystem.UISystem +import com.skillw.uisystem.api.UIApi.sendRes +import com.skillw.uisystem.internal.manager.UIConfig +import com.skillw.uisystem.internal.manager.UIConfig.debug +import org.bukkit.entity.Player +import org.checkerframework.checker.guieffect.qual.UI +import taboolib.common.platform.event.EventPriority +import taboolib.common.platform.event.SubscribeEvent + +object Listner { + + @SubscribeEvent(priority = EventPriority.HIGHEST) + internal fun ee(event: PlayerConnectionSuccessfulEvent){ + if (UIConfig.resourcesEnable){ + event.player.sendRes() + } + debug(debug = { + println("加载材质包...${event.player}") + println("${UIConfig.resources},${UIConfig.resourcesPassword}") + }) + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + internal fun qwq(event: PlayerResourcePackEvent){ + UISystem.rdataManager.setPlayer(event.player,event.resourceStatus) + debug{ + println("加载材质包事件${event.player},状态${event.resourceStatus}") + println(UISystem.rdataManager.toString()) + } + } + + @SubscribeEvent(priority = EventPriority.HIGHEST) + internal fun awa(event: org.bukkit.event.player.PlayerQuitEvent) { + UISystem.rdataManager.removePlayer(event.player) + debug{ + println("退出${event.player}") + } + } + + @SubscribeEvent + internal fun pwp(event: org.bukkit.event.player.PlayerKickEvent){ + UISystem.rdataManager.removePlayer(event.player) + } + + @SubscribeEvent + internal fun xcx(event: org.bukkit.event.player.PlayerMoveEvent){ + if (UISystem.rdataManager[event.player.uniqueId] == ResourceStatus.Start_Load_Resource_Pack) event.isCancelled = true + } + + @SubscribeEvent + internal fun pvp(event: org.bukkit.event.player.PlayerInteractEvent){ + if (UISystem.rdataManager[event.player.uniqueId] == ResourceStatus.Start_Load_Resource_Pack) event.isCancelled = true + } + + @SubscribeEvent + internal fun rpg(event: org.bukkit.event.player.PlayerInteractEntityEvent){ + if (UISystem.rdataManager[event.player.uniqueId] == ResourceStatus.Start_Load_Resource_Pack) event.isCancelled = true + } + + @SubscribeEvent + internal fun xxx(event: org.bukkit.event.entity.EntityDamageEvent) { + if (event.entity is Player){ + if(UISystem.rdataManager[event.entity.uniqueId] == ResourceStatus.Start_Load_Resource_Pack) event.isCancelled = true + } + } + +} \ No newline at end of file diff --git a/src/main/kotlin/com/skillw/uisystem/internal/manager/GuiManagerImpl.kt b/src/main/kotlin/com/skillw/uisystem/internal/manager/GuiManagerImpl.kt new file mode 100644 index 0000000..83b5584 --- /dev/null +++ b/src/main/kotlin/com/skillw/uisystem/internal/manager/GuiManagerImpl.kt @@ -0,0 +1,30 @@ +package com.skillw.uisystem.internal.manager + +import com.daxton.unrealcore.application.UnrealCoreAPI +import com.skillw.pouvoir.api.plugin.SubPouvoir +import com.skillw.uisystem.UISystem +import com.skillw.uisystem.api.event.GuiRegisterEvent +import com.skillw.uisystem.api.gui.Gui +import com.skillw.uisystem.api.manager.GuiManager +import org.bukkit.entity.Player + +object GuiManagerImpl: GuiManager() { + override val key: String = "GuiManager" + override val priority = 1 + override val subPouvoir: SubPouvoir = UISystem + + override fun OpenGui(player: Player, key: String) { + this[key]?.let { UnrealCoreAPI.openGUI(player, it) } ?: return + } + + override fun onReload() { + this.entries.filter { it.value.release }.forEach { remove(it.key) } + } + + override fun register(key: String, value: Gui): Gui? { + val e = GuiRegisterEvent(key, gui = value) + e.call() + if (e.isCancelled) return null + return put(key,value) + } +} diff --git a/src/main/kotlin/com/skillw/uisystem/internal/manager/RdataManagerImpl.kt b/src/main/kotlin/com/skillw/uisystem/internal/manager/RdataManagerImpl.kt new file mode 100644 index 0000000..c09e1a2 --- /dev/null +++ b/src/main/kotlin/com/skillw/uisystem/internal/manager/RdataManagerImpl.kt @@ -0,0 +1,32 @@ +package com.skillw.uisystem.internal.manager + +import com.daxton.unrealcore.resource.been.ResourceStatus +import com.skillw.uisystem.UISystem +import com.skillw.uisystem.api.manager.RdataManager +import org.bukkit.entity.Player +import org.checkerframework.checker.guieffect.qual.UI + +object RdataManagerImpl: RdataManager() { + override val key: String = "RdataManager" + override val priority = 2 + override val subPouvoir = UISystem + + override fun setPlayer(player: Player,boolean: ResourceStatus) { + UISystem.rdataManager[player.uniqueId] = boolean + } + + override fun hasPlayer(player: Player): Boolean { + return UISystem.rdataManager[player.uniqueId] != null + } + + override fun removePlayer(player: Player) { + if (UISystem.rdataManager.hasPlayer(player)) remove(player.uniqueId) + } + + override fun PlayerIsFinish(player: Player): Boolean { + return UISystem.rdataManager[player.uniqueId] == ResourceStatus.Finish_Load_Resource_Pack + } + + + +} \ No newline at end of file diff --git a/src/main/kotlin/com/skillw/uisystem/internal/manager/UIConfig.kt b/src/main/kotlin/com/skillw/uisystem/internal/manager/UIConfig.kt new file mode 100644 index 0000000..8f117ee --- /dev/null +++ b/src/main/kotlin/com/skillw/uisystem/internal/manager/UIConfig.kt @@ -0,0 +1,50 @@ +package com.skillw.uisystem.internal.manager + +import com.skillw.pouvoir.Pouvoir +import com.skillw.pouvoir.api.manager.ConfigManager +import com.skillw.pouvoir.util.static +import com.skillw.uisystem.UISystem +import org.spigotmc.AsyncCatcher +import taboolib.common.platform.function.getDataFolder +import java.io.File + +object UIConfig : ConfigManager(UISystem) { + override val priority: Int = 0 + + + override fun onLoad() { + AsyncCatcher.enabled = false + createIfNotExists("scripts", "example.js") + Pouvoir.scriptEngineManager.globalVariables.let { + it["UISystem"] = UISystem::class.java.static() + } + } + + override fun onEnable() { + onReload() + } + override fun subReload() { + Pouvoir.scriptManager.addScriptDir(scripts) + } + + private val scripts = File(getDataFolder(), "scripts") + + var isDebug = false + + val debug: Boolean + get() = this["config"].getBoolean("options.debug") || isDebug + + val resources: String? + get() = this["config"].getString("resources.name") + val resourcesEnable: Boolean + get() = this["config"].getBoolean("resources.enable") + val resourcesPassword: String? + get() = this["config"].getString("resources.password") + + @JvmStatic + fun debug(debug: () -> Unit) { + if (this.debug) { + debug.invoke() + } + } +} \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml new file mode 100644 index 0000000..96ecd94 --- /dev/null +++ b/src/main/resources/config.yml @@ -0,0 +1,8 @@ +debug: false + +resources: + enable: true + #加载的材质包名称,不需要带zip + name: "UnrealResource" + #材质包密码 + password: "123456" \ No newline at end of file diff --git a/src/main/resources/lang/zh_CN.yml b/src/main/resources/lang/zh_CN.yml new file mode 100644 index 0000000..0bdc65e --- /dev/null +++ b/src/main/resources/lang/zh_CN.yml @@ -0,0 +1,12 @@ +prefix: '&d[&9UI系统&d] ' + +command-reload: '&d[&9UI系统&d] &a插件已重载成功!' +command-info: + - '&f&m─&6&m──────────────────────────────────&6&f&m─' + - ' &9指令列表:' + - ' &6/ui' + - ' &d- &eopen &5—— &a打开界面.' + - '&f&m─&6&m──────────────────────────────────&6&f&m─' +command-personal: '&d[&9UI系统&d] &e你成功打开 &6{0} &e界面 !' + +UInull: '&d[&9UI系统&d] &e没有名为 &6{0} &e界面 !' \ No newline at end of file diff --git a/src/main/resources/scripts/example.js b/src/main/resources/scripts/example.js new file mode 100644 index 0000000..1f323d3 --- /dev/null +++ b/src/main/resources/scripts/example.js @@ -0,0 +1,55 @@ +//@GuiCreate() +const MainGuiData = find("com.daxton.unrealcore.display.been.gui.MainGUIData") + +/* +* 最简单的gui插件,也是最全能的gui插件 +* +* Width这些都是字符串是因为要发给客户端,给客户端计算,减少服务器负担 +* +* */ + + +/* +*错误的做法:这会报错 +* +* setting = ()=>{ + const data = new MainGuiData() + data.setModuleID("example") + data.setY("0") + data.setX("0") + data.setPosition("5") + data.setImage("gui/background/background_2.png") + const a = Math.random().toString() + data.setWidth("250" + a) + data.setHeight("250") + data.setMask("true") + data.setColor = "ffffff" + data.transparent = "255" + return data + } +* +* */ +const data = new MainGuiData() +data.setModuleID("example") +data.setY("0") +data.setX("0") +data.setPosition("5") +data.setImage("gui/background/background_2.png") +//一个简单的计算 +const a = Math.random().toString() +data.setWidth("250" + a) + +data.setHeight("250") +data.setMask("true") +data.setColor = "ffffff" +data.transparent = "255" +//这两个是必要的 +key = "example" +setting = data + +function opening(data) { + print(data) +} +function close(data) { + print(data) +}