├── .github └── workflows │ └── build.yml ├── .gitignore ├── LICENSE ├── README.md ├── build.gradle.kts ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── plugin └── build.gradle.kts ├── project ├── build.gradle.kts ├── common │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── kotlin │ │ └── ink │ │ └── ptms │ │ └── um │ │ ├── Item.kt │ │ ├── Mob.kt │ │ ├── MobType.kt │ │ ├── Mythic.kt │ │ ├── Skill.kt │ │ ├── event │ │ ├── MobConditionLoadEvent.kt │ │ ├── MobDeathEvent.kt │ │ ├── MobDropLoadEvent.kt │ │ ├── MobSkillLoadEvent.kt │ │ ├── MobSpawnEvent.kt │ │ └── MythicReloadEvent.kt │ │ ├── item │ │ └── DropMeta.kt │ │ └── skill │ │ ├── SkillCaster.kt │ │ ├── SkillConfig.kt │ │ ├── SkillMechanic.kt │ │ ├── SkillMeta.kt │ │ ├── SkillResult.kt │ │ ├── condition │ │ ├── BaseCondition.kt │ │ ├── CasterCondition.kt │ │ ├── EntityComparisonCondition.kt │ │ ├── EntityCondition.kt │ │ ├── EntityLocationDistanceCondition.kt │ │ ├── LocationCondition.kt │ │ ├── SkillMetaComparisonCondition.kt │ │ └── SkillMetadataCondition.kt │ │ ├── data │ │ ├── PlaceholderDouble.kt │ │ ├── PlaceholderFloat.kt │ │ ├── PlaceholderInt.kt │ │ └── PlaceholderString.kt │ │ └── type │ │ ├── BaseSkill.kt │ │ ├── EntityTargetSkill.kt │ │ ├── LocationTargetSkill.kt │ │ └── NoTargetSkill.kt ├── implementation-v4 │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── kotlin │ │ └── ink │ │ └── ptms │ │ └── um │ │ └── impl4 │ │ ├── Item.kt │ │ ├── Mob.kt │ │ ├── MobConfiguration.kt │ │ ├── MobListener.kt │ │ ├── MobListenerCondition.kt │ │ ├── MobListenerDrop.kt │ │ ├── MobListenerSkill.kt │ │ ├── MobType.kt │ │ ├── Mythic4.kt │ │ ├── Skill4.kt │ │ └── Utils.kt └── implementation-v5 │ ├── build.gradle.kts │ ├── libs │ └── MythicMobs-5.6.0.min.jar │ └── src │ └── main │ └── kotlin │ └── ink │ └── ptms │ └── um │ └── impl5 │ ├── Item.kt │ ├── Mob.kt │ ├── MobConfiguration.kt │ ├── MobListener.kt │ ├── MobListenerCondition.kt │ ├── MobListenerDrop.kt │ ├── MobListenerSkill.kt │ ├── MobType.kt │ ├── Mythic5.kt │ ├── Skill5.kt │ └── Utils.kt └── settings.gradle.kts /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Project Build 2 | on: [ push ] 3 | jobs: 4 | build: 5 | if: "contains(github.event.head_commit.message, 'publish')" 6 | runs-on: ubuntu-latest 7 | steps: 8 | - name: checkout repository 9 | uses: actions/checkout@v4 10 | - name: cache gradle packages 11 | uses: actions/cache@v4 12 | with: 13 | key: ${{ runner.os }}-build-${{ env.cache-name }} 14 | path: | 15 | ~/.gradle/caches 16 | ~/.gradle/wrapper 17 | - name: validate gradle wrapper 18 | uses: gradle/wrapper-validation-action@v3.5.0 19 | - name: setup jdk 17.0 20 | uses: actions/setup-java@v2 21 | with: 22 | distribution: adopt 23 | java-version: 17.0 24 | - name: make gradle wrapper executable 25 | run: chmod +x ./gradlew 26 | - name: build 27 | run: ./gradlew build 28 | - name: publish 29 | env: 30 | NEXUS_USERNAME: ${{ secrets.NEXUS_USERNAME }} 31 | NEXUS_PASSWORD: ${{ secrets.NEXUS_PASSWORD }} 32 | run: ./gradlew publish -PtaboolibUsername=$NEXUS_USERNAME -PtaboolibPassword=$NEXUS_PASSWORD 33 | - name: capture build artifacts 34 | uses: actions/upload-artifact@v4 35 | with: 36 | name: Artifacts 37 | path: plugin/build/libs/ 38 | overwrite: true 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .idea 3 | build 4 | bin -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Universal-Mythic 2 | 3 | 兼容 4 5 并提供一些简单的工具 4 | 5 | 使用方式: 6 | 7 | ```kotlin 8 | taboolib{ 9 | relocate("ink.ptms.um","xx.um") 10 | } 11 | 12 | taboo("ink.ptms:um:1.2.0") 13 | ``` 14 | -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | import org.jetbrains.kotlin.gradle.tasks.KotlinCompile 2 | 3 | plugins { 4 | id("org.gradle.java") 5 | id("org.gradle.maven-publish") 6 | id("org.jetbrains.kotlin.jvm") version "1.9.22" apply false 7 | } 8 | 9 | subprojects { 10 | apply() 11 | apply(plugin = "org.jetbrains.kotlin.jvm") 12 | 13 | repositories { 14 | mavenCentral() 15 | } 16 | dependencies { 17 | "compileOnly"(kotlin("stdlib")) 18 | } 19 | tasks.withType { 20 | kotlinOptions { 21 | jvmTarget = "1.8" 22 | freeCompilerArgs = listOf("-Xjvm-default=all") 23 | } 24 | } 25 | tasks.withType { 26 | options.encoding = "UTF-8" 27 | } 28 | } 29 | 30 | publishing { 31 | repositories { 32 | maven { 33 | url = uri("http://sacredcraft.cn:8081/repository/releases") 34 | isAllowInsecureProtocol = true 35 | credentials { 36 | username = project.findProperty("taboolibUsername").toString() 37 | password = project.findProperty("taboolibPassword").toString() 38 | } 39 | authentication { 40 | create("basic") 41 | } 42 | } 43 | } 44 | publications { 45 | create("maven") { 46 | artifactId = "um" 47 | groupId = "ink.ptms" 48 | version = project.version.toString() 49 | artifact(File("plugin/build/libs/${rootProject.name}-${project.version}.jar")) 50 | } 51 | } 52 | } 53 | 54 | gradle.buildFinished { 55 | buildDir.deleteRecursively() 56 | } 57 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | group=ink.ptms.um 2 | version=1.2.0 3 | taboolib_version=6.2.3-8cc2f66 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TabooLib/universal-mythic/6989c2c3885a9d4ba1adcadd9bb9d61d90f3e703/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /plugin/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar 2 | 3 | plugins { 4 | id("com.github.johnrengelman.shadow") version "7.1.2" 5 | } 6 | 7 | dependencies { 8 | implementation(project(":project:common")) 9 | implementation(project(":project:implementation-v4")) 10 | implementation(project(":project:implementation-v5")) 11 | } 12 | 13 | tasks { 14 | withType { 15 | archiveClassifier.set("") 16 | archiveBaseName.set(rootProject.name) 17 | } 18 | build { 19 | dependsOn(shadowJar) 20 | } 21 | } -------------------------------------------------------------------------------- /project/build.gradle.kts: -------------------------------------------------------------------------------- 1 | gradle.buildFinished { 2 | buildDir.deleteRecursively() 3 | } -------------------------------------------------------------------------------- /project/common/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import io.izzel.taboolib.gradle.Basic 2 | import io.izzel.taboolib.gradle.Bukkit 3 | import io.izzel.taboolib.gradle.BukkitUtil 4 | 5 | val taboolib_version: String by project 6 | 7 | plugins { 8 | id("io.izzel.taboolib") version "2.0.22" 9 | } 10 | 11 | taboolib { 12 | subproject = true 13 | env { 14 | // install(UNIVERSAL, BUKKIT_ALL) 15 | install(Basic, Bukkit, BukkitUtil) 16 | } 17 | version { 18 | taboolib = taboolib_version 19 | } 20 | } 21 | 22 | dependencies { 23 | compileOnly("ink.ptms:nms-all:1.0.0") 24 | compileOnly("com.electronwill.night-config:core-conversion:6.0.0") 25 | compileOnly("org.yaml:snakeyaml:1.26") 26 | compileOnly("ink.ptms.core:v11802:11802-minimize:mapped") 27 | compileOnly("ink.ptms.core:v11802:11802-minimize:universal") 28 | } 29 | 30 | configure { 31 | sourceCompatibility = JavaVersion.VERSION_1_8 32 | targetCompatibility = JavaVersion.VERSION_1_8 33 | } 34 | -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/Item.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um 2 | 3 | import org.bukkit.inventory.ItemStack 4 | import taboolib.library.configuration.ConfigurationSection 5 | 6 | /** 7 | * universal-mythic 8 | * ink.ptms.um.Item 9 | * 10 | * @author 坏黑 11 | * @since 2022/7/12 13:40 12 | */ 13 | interface Item { 14 | 15 | /** 16 | * 物品ID 17 | */ 18 | val internalName: String 19 | 20 | /** 21 | * 物品数量 22 | */ 23 | val amount: Int 24 | 25 | /** 26 | * 物品名 27 | */ 28 | val displayName: String? 29 | 30 | /** 31 | * 物品的配置文件 32 | */ 33 | val config: ConfigurationSection 34 | 35 | /** 36 | * 生成物品 37 | */ 38 | fun generateItemStack(amount: Int): ItemStack 39 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/Mob.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um 2 | 3 | import org.bukkit.entity.Entity 4 | import org.bukkit.entity.EntityType 5 | import org.bukkit.entity.LivingEntity 6 | import taboolib.library.configuration.ConfigurationSection 7 | 8 | /** 9 | * universal-mythic 10 | * ink.ptms.um.Mob 11 | * 12 | * @author 坏黑 13 | * @since 2022/7/12 13:34 14 | */ 15 | interface Mob { 16 | 17 | /** 18 | * 怪物序号,对应 internalName 字段 19 | */ 20 | val id: String 21 | 22 | /** 23 | * 展示名称 24 | */ 25 | val displayName: String 26 | 27 | /** 28 | * 获取 MythicMob 类型 29 | */ 30 | val type: MobType 31 | 32 | /** 33 | * 获取 Bukkit 实体对象 34 | */ 35 | val entity: Entity 36 | 37 | /** 38 | * 实体类型 39 | */ 40 | val entityType: EntityType 41 | 42 | /** 43 | * 等级 44 | */ 45 | val level: Double 46 | 47 | /** 48 | * 姿态 49 | */ 50 | val stance: String 51 | 52 | /** 53 | * 阵营 54 | */ 55 | val faction: String 56 | 57 | /** 58 | * 配置 59 | */ 60 | val config: ConfigurationSection 61 | 62 | /** 63 | * 增加仇恨 64 | */ 65 | fun addThreat(mob: Entity, target: LivingEntity, amount: Double) 66 | 67 | /** 68 | * 减少仇恨 69 | */ 70 | fun reduceThreat(mob: Entity, target: LivingEntity, amount: Double) 71 | } 72 | -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/MobType.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um 2 | 3 | import org.bukkit.Location 4 | import taboolib.library.configuration.ConfigurationSection 5 | 6 | /** 7 | * universal-mythic 8 | * ink.ptms.um.MobType 9 | * 10 | * @author 坏黑 11 | * @since 2022/7/12 13:40 12 | */ 13 | interface MobType { 14 | 15 | /** 16 | * 怪物序号,对应 internalName 字段 17 | */ 18 | val id: String 19 | 20 | /** 21 | * 展示名称 22 | */ 23 | val displayName: String 24 | 25 | /** 26 | * 实体类型 27 | */ 28 | val entityType: String 29 | 30 | /** 31 | * 配置 32 | */ 33 | val config: ConfigurationSection 34 | 35 | /** 36 | * 生成到指定位置 37 | */ 38 | fun spawn(location: Location, level: Double): Mob 39 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/Mythic.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um 2 | 3 | import org.bukkit.Location 4 | import org.bukkit.entity.Entity 5 | import org.bukkit.entity.LivingEntity 6 | import org.bukkit.entity.Player 7 | import org.bukkit.inventory.ItemStack 8 | import java.io.File 9 | import java.util.* 10 | 11 | interface Mythic { 12 | 13 | /** 是否 4.X 版本 */ 14 | val isLegacy: Boolean 15 | 16 | /** 获取 MythicItem 实例 */ 17 | fun getItem(name: String): Item? 18 | 19 | /** 获取 ItemStack 所对应的 MythicItem ID */ 20 | fun getItemId(itemStack: ItemStack): String? 21 | 22 | /** 获取 MythicItem 实例并构建到 ItemStack 不要用问号缺省,构建出来的代码不包含*/ 23 | fun getItemStack(name: String): ItemStack? 24 | 25 | /** 获取 MythicItem 实例并构建到 ItemStack */ 26 | fun getItemStack(name: String, player: Player?): ItemStack? 27 | 28 | /** 获取 MythicItem ID 列表 */ 29 | fun getItemIDList(): List 30 | 31 | /** 获取 MythicItem列表 */ 32 | fun getItemList(): List 33 | 34 | /** 获取 ActiveMob 实例 */ 35 | fun getMob(entity: Entity): Mob? 36 | 37 | /** 根据实体 UUID 获取 ActiveMob 实例 */ 38 | fun getMob(uuid: UUID): Mob? 39 | 40 | /** 获取所有 Mob ID 列表 */ 41 | fun getMobIDList(): List 42 | 43 | /** 获取 MythicMob 实例 */ 44 | fun getMobType(name: String): MobType? 45 | 46 | /** 获取技能类型 */ 47 | fun getSkillTrigger(name: String): Skill.Trigger 48 | 49 | /** 获取默认技能类型 */ 50 | fun getDefaultSkillTrigger(): Skill.Trigger 51 | 52 | /** 53 | * 将字符串转换为技能实例 54 | * 55 | * @param skillLine 技能字符串(如:`message{m="text"}`) 56 | */ 57 | fun getSkillMechanic(skillLine: String): Skill? 58 | 59 | /** 60 | * 获取玩家的目标 61 | * 62 | * @param player 玩家 63 | */ 64 | fun getTargetedEntity(player: Player): LivingEntity? 65 | 66 | /** 67 | * 释放技能 68 | * 69 | * @param caster 施法者 70 | * @param skillName 技能名称 71 | * @param trigger 触发器 72 | * @param origin 技能释放位置 73 | * @param et 技能释放目标 74 | * @param lt 技能释放位置 75 | * @param power 技能释放强度 76 | */ 77 | fun castSkill( 78 | caster: Entity, 79 | skillName: String, 80 | trigger: Entity? = null, 81 | origin: Location = caster.location, 82 | et: Collection = emptyList(), 83 | lt: Collection = emptyList(), 84 | power: Float = 1f, 85 | ): Boolean 86 | 87 | /** 88 | * 注册物品 89 | * 90 | * @param file 文件 91 | * @param node 节点名 92 | * 93 | * @return 如果物品存在则返回false 94 | */ 95 | fun registerItem(file: File, node: String): Boolean 96 | 97 | /** 98 | * 移除已注册物品 99 | * 100 | * @param node 节点名 101 | * 102 | * @return 当不存在物品时,返回false 103 | */ 104 | fun unregisterItem(node: String): Boolean 105 | 106 | /** 107 | * 注册怪物 108 | * 109 | * @param file 怪物文件 110 | * @param node 怪物节点名 111 | * 112 | * @return 如果已存在则返回false 113 | */ 114 | fun registerMob(file: File, node: String): Boolean 115 | 116 | /** 117 | * 移除已注册的怪物 118 | * 119 | * @param node 节点名 120 | * 121 | * @return 如果不存在则返回false 122 | */ 123 | fun unregisterMob(node: String): Boolean 124 | 125 | companion object { 126 | 127 | @JvmStatic 128 | lateinit var API: Mythic 129 | 130 | fun isLoaded(): Boolean { 131 | return ::API.isInitialized 132 | } 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/Skill.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um 2 | 3 | import ink.ptms.um.skill.SkillCaster 4 | import org.bukkit.Location 5 | import org.bukkit.entity.Entity 6 | 7 | /** 8 | * universal-mythic 9 | * ink.ptms.um.Skill 10 | * 11 | * @author 坏黑 12 | * @since 2022/7/12 13:34 13 | */ 14 | interface Skill { 15 | 16 | /** 延迟 */ 17 | val delay: Int 18 | 19 | /** 20 | * 释放技能 21 | * @param trigger 技能触发器 22 | * @param entity 技能施法者 23 | * @param target 技能目标 24 | * @param et 技能目标实体 25 | * @param lt 技能目标位置 26 | * @param power 技能强度 27 | * @param parameters 技能参数 28 | * @param targetFilter 技能目标过滤器 29 | */ 30 | fun execute( 31 | trigger: Trigger, 32 | entity: Entity, 33 | target: Entity, 34 | et: Set = emptySet(), 35 | lt: Set = emptySet(), 36 | power: Float = 0f, 37 | parameters: Map = emptyMap(), 38 | targetFilter: (Entity) -> Boolean = { true }, 39 | ): Boolean 40 | 41 | /** 获取技能是否正在冷却 */ 42 | fun onCooldown(caster: Entity): Boolean 43 | 44 | /** 获取技能冷却 */ 45 | fun getCooldown(caster: Entity): Float 46 | 47 | /** 设置技能冷却 */ 48 | fun setCooldown(caster: Entity, time: Double) 49 | 50 | /** 技能触发器 */ 51 | interface Trigger { 52 | 53 | /** 名称 */ 54 | val name: String 55 | } 56 | 57 | /** 技能施法者 */ 58 | interface ActiveCaster { 59 | 60 | /** 参数 */ 61 | val parameters: Map 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/event/MobConditionLoadEvent.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.event 2 | 3 | import ink.ptms.um.skill.SkillConfig 4 | import ink.ptms.um.skill.condition.BaseCondition 5 | import taboolib.platform.type.BukkitProxyEvent 6 | 7 | /** project name universal-mythic 8 | * package ink.ptms.um.event 9 | * time 2024/7/4 10 | * author 劫 11 | */ 12 | class MobConditionLoadEvent(val name: String, val config: SkillConfig) : BukkitProxyEvent() { 13 | var skillCondition: BaseCondition? = null 14 | 15 | fun register(condition: BaseCondition) { 16 | skillCondition = condition 17 | } 18 | 19 | fun fire(): MobConditionLoadEvent { 20 | call() 21 | return this 22 | } 23 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/event/MobDeathEvent.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.event 2 | 3 | import ink.ptms.um.Mob 4 | import org.bukkit.entity.LivingEntity 5 | import org.bukkit.inventory.ItemStack 6 | import taboolib.platform.type.BukkitProxyEvent 7 | 8 | class MobDeathEvent(val mob: Mob, val killer: LivingEntity?, val drop: MutableList = mutableListOf()) : BukkitProxyEvent() { 9 | 10 | fun fire(): MobDeathEvent { 11 | call() 12 | return this 13 | } 14 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/event/MobDropLoadEvent.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.event 2 | 3 | import ink.ptms.um.item.DropMeta 4 | import org.bukkit.inventory.ItemStack 5 | import taboolib.platform.type.BukkitProxyEvent 6 | import java.util.function.Function 7 | 8 | /** 9 | * universal-mythic 10 | * ink.ptms.um.event.MobDropLoadEvent 11 | * 12 | * @author 坏黑 13 | * @since 2023/6/11 22:17 14 | */ 15 | class MobDropLoadEvent(val dropName: String): BukkitProxyEvent() { 16 | 17 | val itemDrops = arrayListOf>() 18 | 19 | fun registerItem(func: Function) { 20 | itemDrops += func 21 | } 22 | 23 | fun fire(): MobDropLoadEvent { 24 | call() 25 | return this 26 | } 27 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/event/MobSkillLoadEvent.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.event 2 | 3 | import ink.ptms.um.skill.SkillConfig 4 | import ink.ptms.um.skill.type.BaseSkill 5 | import taboolib.platform.type.BukkitProxyEvent 6 | 7 | /** 8 | * universal-mythic 9 | * ink.ptms.um.event.MobDropLoadEvent 10 | * 11 | * @author 坏黑 12 | * @since 2023/6/11 22:17 13 | */ 14 | class MobSkillLoadEvent(val skillName: String, val config: SkillConfig): BukkitProxyEvent() { 15 | 16 | var registerSkill: BaseSkill? = null 17 | 18 | fun register(skill: BaseSkill) { 19 | registerSkill = skill 20 | } 21 | 22 | fun nameIs(vararg name: String): Boolean { 23 | return name.any { it.equals(skillName, true) } 24 | } 25 | 26 | fun fire(): MobSkillLoadEvent { 27 | call() 28 | return this 29 | } 30 | 31 | // @SubscribeEvent 32 | // fun example(event: MobSkillLoadEvent) { 33 | // if (event.nameIs("example_damage")) { 34 | // event.register(object : EntityTargetSkill { 35 | // 36 | // val value = event.config.getPlaceholderDouble(arrayOf("value"), 0.0) 37 | // 38 | // override fun cast(meta: SkillMeta, entity: Entity): SkillResult { 39 | // if (entity !is LivingEntity) return SkillResult.ERROR 40 | // entity.damage(value[meta.caster]) 41 | // return SkillResult.SUCCESS 42 | // } 43 | // }) 44 | // } 45 | // } 46 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/event/MobSpawnEvent.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.event 2 | 3 | import ink.ptms.um.Mob 4 | import ink.ptms.um.MobType 5 | import taboolib.platform.type.BukkitProxyEvent 6 | 7 | class MobSpawnEvent(val mob: Mob?, val mobType: MobType, var level: Double) : BukkitProxyEvent() { 8 | 9 | fun fire(): MobSpawnEvent { 10 | call() 11 | return this 12 | } 13 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/event/MythicReloadEvent.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.event 2 | 3 | import taboolib.platform.type.BukkitProxyEvent 4 | 5 | class MythicReloadEvent : BukkitProxyEvent() { 6 | 7 | fun fire(): MythicReloadEvent { 8 | call() 9 | return this 10 | } 11 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/item/DropMeta.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.item 2 | 3 | import ink.ptms.um.skill.SkillCaster 4 | import org.bukkit.entity.Entity 5 | 6 | /** 7 | * universal-mythic 8 | * ink.ptms.um.item.DropMeta 9 | * 10 | * @author 坏黑 11 | * @since 2023/6/11 23:40 12 | */ 13 | interface DropMeta { 14 | 15 | /** 掉落者 */ 16 | val dropper: SkillCaster? 17 | 18 | /** 触发者 */ 19 | val cause: Entity? 20 | 21 | var amount: Float 22 | 23 | var generations: Int 24 | 25 | fun tick() 26 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/SkillCaster.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill 2 | 3 | import org.bukkit.Location 4 | import org.bukkit.entity.Entity 5 | 6 | /** 7 | * universal-mythic 8 | * ink.ptms.um.skill.SkillCaster 9 | * 10 | * @author 坏黑 11 | * @since 2023/6/6 15:28 12 | */ 13 | interface SkillCaster { 14 | 15 | /** 技能施法者 */ 16 | val entity: Entity 17 | 18 | /** 技能施法者位置 */ 19 | val location: Location 20 | 21 | /** 等级 */ 22 | val level: Double 23 | 24 | /** 强度 */ 25 | val power: Float 26 | 27 | /** 全局冷却 */ 28 | var globalCooldown: Int 29 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/SkillConfig.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill 2 | 3 | import ink.ptms.um.skill.data.PlaceholderDouble 4 | import ink.ptms.um.skill.data.PlaceholderFloat 5 | import ink.ptms.um.skill.data.PlaceholderInt 6 | import ink.ptms.um.skill.data.PlaceholderString 7 | import java.awt.Color 8 | 9 | /** 10 | * universal-mythic 11 | * ink.ptms.um.Config 12 | * 13 | * @author 坏黑 14 | * @since 2023/6/6 15:51 15 | */ 16 | interface SkillConfig { 17 | 18 | /** 获取完整内容 */ 19 | fun line(): String 20 | 21 | /** 获取元素数量 */ 22 | fun size(): Int 23 | 24 | /** 获取所有元素 */ 25 | fun entrySet(): Set> 26 | 27 | /** 获取 Key */ 28 | fun getKey(): String 29 | 30 | /** 获取 Key */ 31 | fun getKey(s: String): String 32 | 33 | /** 获取布尔值 */ 34 | fun getBoolean(key: String) = getBoolean(key, false) 35 | 36 | /** 获取布尔值 */ 37 | fun getBoolean(key: String, def: Boolean) = getBoolean(arrayOf(key), def) 38 | 39 | /** 获取布尔值 */ 40 | fun getBoolean(key: Array, def: Boolean): Boolean 41 | 42 | /** 获取字符串 */ 43 | fun getString(key: String) = getString(key, "") 44 | 45 | /** 获取字符串 */ 46 | fun getString(key: String, def: String) = getString(arrayOf(key), def) 47 | 48 | /** 获取字符串 */ 49 | fun getString(key: Array, def: String): String 50 | 51 | /** 获取带变量的字符串 */ 52 | fun getPlaceholderString(key: Array, def: String, vararg args: String): PlaceholderString 53 | 54 | /** 获取整数 */ 55 | fun getInt(key: String) = getInt(key, 0) 56 | 57 | /** 获取整数 */ 58 | fun getInt(key: String, def: Int) = getInt(arrayOf(key), def) 59 | 60 | /** 获取整数 */ 61 | fun getInt(key: Array, def: Int): Int 62 | 63 | /** 获取带变量的整数 */ 64 | fun getPlaceholderInt(key: String, def: Int, vararg args: String) = getPlaceholderInt(arrayOf(key), def, *args) 65 | 66 | /** 获取带变量的整数 */ 67 | fun getPlaceholderInt(key: Array, def: Int, vararg args: String): PlaceholderInt 68 | 69 | /** 获取浮点数(双精度)*/ 70 | fun getDouble(key: String) = getDouble(key, 0.0) 71 | 72 | /** 获取浮点数(双精度)*/ 73 | fun getDouble(key: String, def: Double) = getDouble(arrayOf(key), def) 74 | 75 | /** 获取浮点数(双精度)*/ 76 | fun getDouble(key: Array, def: Double): Double 77 | 78 | /** 获取带变量的浮点数(双精度)*/ 79 | fun getPlaceholderDouble(key: String, def: Double, vararg args: String) = getPlaceholderDouble(arrayOf(key), def, *args) 80 | 81 | /** 获取带变量的浮点数(双精度)*/ 82 | fun getPlaceholderDouble(key: Array, def: Double, vararg args: String): PlaceholderDouble 83 | 84 | /** 获取浮点数(单精度)*/ 85 | fun getFloat(key: String) = getFloat(key, 0f) 86 | 87 | /** 获取浮点数(单精度)*/ 88 | fun getFloat(key: String, def: Float) = getFloat(arrayOf(key), def) 89 | 90 | /** 获取浮点数(单精度)*/ 91 | fun getFloat(key: Array, def: Float): Float 92 | 93 | /** 获取带变量的浮点数(单精度)*/ 94 | fun getPlaceholderFloat(key: String, def: Float, vararg args: String) = getPlaceholderFloat(arrayOf(key), def, *args) 95 | 96 | /** 获取带变量的浮点数(单精度)*/ 97 | fun getPlaceholderFloat(key: Array, def: Float, vararg args: String): PlaceholderFloat 98 | 99 | /** 获取长整数 */ 100 | fun getLong(key: String) = getLong(key, 0) 101 | 102 | /** 获取长整数 */ 103 | fun getLong(key: String, def: Long) = getLong(arrayOf(key), def) 104 | 105 | /** 获取长整数 */ 106 | fun getLong(key: Array, def: Long): Long 107 | 108 | /** 获取颜色 */ 109 | fun getColor(key: String, def: String): Color 110 | 111 | /** 获取颜色 */ 112 | fun getColor(key: Array, def: String): Color 113 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/SkillMechanic.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill 2 | 3 | /** 4 | * universal-mythic 5 | * ink.ptms.um.skill.SkillMechanic 6 | * 7 | * @author 坏黑 8 | * @since 2023/6/6 16:03 9 | */ 10 | interface SkillMechanic -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/SkillMeta.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill 2 | 3 | import ink.ptms.um.Skill 4 | import org.bukkit.Location 5 | import org.bukkit.entity.Entity 6 | 7 | /** 8 | * universal-mythic 9 | * ink.ptms.um.skill.SkillMeta 10 | * 11 | * @author 坏黑 12 | * @since 2023/6/6 15:28 13 | */ 14 | interface SkillMeta { 15 | 16 | /** 技能施法者 */ 17 | var caster: SkillCaster 18 | 19 | /** 技能触发者 */ 20 | var trigger: Entity 21 | 22 | /** 原点 */ 23 | var origin: Location 24 | 25 | /** 释放方式 */ 26 | val cause: Skill.Trigger 27 | 28 | /** 强度 */ 29 | var power: Float 30 | 31 | /** 是否异步 */ 32 | var isAsync: Boolean 33 | 34 | /** 目标实体 */ 35 | var entityTargets: Set 36 | 37 | /** 目标坐标 */ 38 | var locationTargets: Set 39 | 40 | /** 元数据 */ 41 | val metadata: Map 42 | 43 | /** 参数 */ 44 | val parameters: Map 45 | 46 | /** 设置元数据 */ 47 | fun setMetadata(key: String, value: Any) 48 | 49 | /** 设置参数 */ 50 | fun setParameter(key: String, value: String) 51 | 52 | /** 复制 */ 53 | fun clone(): SkillMeta 54 | 55 | /** 深度复制 */ 56 | fun deepClone(): SkillMeta 57 | } 58 | -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/SkillResult.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill 2 | 3 | enum class SkillResult { 4 | SUCCESS, 5 | ERROR, 6 | REQUIRES_PREMIUM, 7 | INVALID_VERSION, 8 | INVALID_TARGET, 9 | INVALID_CONFIG, 10 | MISSING_COMPATIBILITY, 11 | CONDITION_FAILED 12 | } 13 | -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/condition/BaseCondition.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill.condition 2 | 3 | /** project name universal-mythic 4 | * package ink.ptms.um.skill.condition 5 | * time 2024/7/6 6 | * author 香香软软的枫溪宝贝 7 | */ 8 | interface BaseCondition { 9 | companion object { 10 | @JvmStatic 11 | fun isSubclass(subclass: BaseCondition): Boolean { 12 | return when (subclass) { 13 | is CasterCondition, is EntityCondition, is LocationCondition, 14 | is SkillMetadataCondition, is EntityComparisonCondition, 15 | is SkillMetaComparisonCondition, is EntityLocationDistanceCondition -> true 16 | else -> false 17 | } 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/condition/CasterCondition.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill.condition 2 | 3 | import ink.ptms.um.skill.SkillCaster 4 | 5 | /** project name universal-mythic 6 | * package ink.ptms.um.skill.condition 7 | * time 2024/7/6 8 | * author 劫 9 | */ 10 | interface CasterCondition:BaseCondition { 11 | fun check(skillCaster: SkillCaster?):Boolean 12 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/condition/EntityComparisonCondition.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill.condition 2 | 3 | import org.bukkit.entity.Entity 4 | 5 | /** project name universal-mythic 6 | * package ink.ptms.um.skill.condition 7 | * time 2024/7/6 8 | * author 劫 9 | */ 10 | interface EntityComparisonCondition : BaseCondition { 11 | fun check(caster: Entity?, entity: Entity?): Boolean 12 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/condition/EntityCondition.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill.condition 2 | 3 | import org.bukkit.entity.Entity 4 | 5 | /** project name universal-mythic 6 | * package ink.ptms.um.skill.condition 7 | * time 2024/7/6 8 | * author 劫 9 | */ 10 | interface EntityCondition:BaseCondition { 11 | fun check(entity: Entity?):Boolean 12 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/condition/EntityLocationDistanceCondition.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill.condition 2 | 3 | import org.bukkit.Location 4 | import org.bukkit.entity.Entity 5 | 6 | /** project name universal-mythic 7 | * package ink.ptms.um.skill.condition 8 | * time 2024/7/6 9 | * author 劫 10 | */ 11 | interface EntityLocationDistanceCondition : BaseCondition { 12 | fun check(entity: Entity?, location: Location?): Boolean 13 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/condition/LocationCondition.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill.condition 2 | 3 | import org.bukkit.Location 4 | 5 | /** project name universal-mythic 6 | * package ink.ptms.um.skill.condition 7 | * time 2024/7/6 8 | * author 劫 9 | */ 10 | interface LocationCondition:BaseCondition { 11 | fun check(location: Location?):Boolean 12 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/condition/SkillMetaComparisonCondition.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill.condition 2 | 3 | import ink.ptms.um.skill.SkillMeta 4 | import org.bukkit.entity.Entity 5 | 6 | /** project name universal-mythic 7 | * package ink.ptms.um.skill.condition 8 | * time 2024/7/8 9 | * author 劫 10 | */ 11 | interface SkillMetaComparisonCondition:BaseCondition { 12 | fun check(skillMeta: SkillMeta?, entity: Entity?):Boolean 13 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/condition/SkillMetadataCondition.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill.condition 2 | 3 | import ink.ptms.um.skill.SkillMeta 4 | 5 | /** project name universal-mythic 6 | * package ink.ptms.um.skill.condition 7 | * time 2024/7/6 8 | * author 劫 9 | */ 10 | interface SkillMetadataCondition :BaseCondition{ 11 | fun check(skill: SkillMeta?):Boolean 12 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/data/PlaceholderDouble.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill.data 2 | 3 | import ink.ptms.um.skill.SkillCaster 4 | import org.bukkit.entity.Entity 5 | 6 | /** 7 | * universal-mythic 8 | * ink.ptms.um.data.PlaceholderDouble 9 | * 10 | * @author 坏黑 11 | * @since 2023/6/6 15:57 12 | */ 13 | interface PlaceholderDouble { 14 | 15 | /** 获取 */ 16 | fun get(): Double 17 | 18 | /** 通过实体获取 */ 19 | operator fun get(entity: Entity): Double 20 | 21 | /** 通过技能施法者获取 */ 22 | operator fun get(caster: SkillCaster): Double 23 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/data/PlaceholderFloat.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill.data 2 | 3 | import ink.ptms.um.skill.SkillCaster 4 | import org.bukkit.entity.Entity 5 | 6 | /** 7 | * universal-mythic 8 | * ink.ptms.um.data.PlaceholderFloat 9 | * 10 | * @author 坏黑 11 | * @since 2023/6/6 15:57 12 | */ 13 | interface PlaceholderFloat { 14 | 15 | /** 获取 */ 16 | fun get(): Float 17 | 18 | /** 通过实体获取 */ 19 | fun get(entity: Entity): Float 20 | 21 | /** 通过技能施法者获取 */ 22 | fun get(caster: SkillCaster): Float 23 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/data/PlaceholderInt.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill.data 2 | 3 | import ink.ptms.um.skill.SkillCaster 4 | import org.bukkit.entity.Entity 5 | 6 | /** 7 | * universal-mythic 8 | * ink.ptms.um.data.PlaceholderInt 9 | * 10 | * @author 坏黑 11 | * @since 2023/6/6 15:57 12 | */ 13 | interface PlaceholderInt { 14 | 15 | /** 获取 */ 16 | fun get(): Int 17 | 18 | /** 通过实体获取 */ 19 | fun get(entity: Entity): Int 20 | 21 | /** 通过技能施法者获取 */ 22 | fun get(caster: SkillCaster): Int 23 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/data/PlaceholderString.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill.data 2 | 3 | import ink.ptms.um.skill.SkillCaster 4 | import org.bukkit.entity.Entity 5 | 6 | /** 7 | * universal-mythic 8 | * ink.ptms.um.data.PlaceholderString 9 | * 10 | * @author 坏黑 11 | * @since 2023/6/6 15:57 12 | */ 13 | interface PlaceholderString { 14 | 15 | /** 获取 */ 16 | fun get(): String 17 | 18 | /** 通过实体获取 */ 19 | fun get(entity: Entity): String 20 | 21 | /** 通过技能施法者获取 */ 22 | fun get(caster: SkillCaster): String 23 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/type/BaseSkill.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill.type 2 | 3 | /** 4 | * universal-mythic 5 | * ink.ptms.um.skill.type.BaseSkill 6 | * 7 | * @author 坏黑 8 | * @since 2023/6/12 01:05 9 | */ 10 | interface BaseSkill -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/type/EntityTargetSkill.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill.type 2 | 3 | import ink.ptms.um.skill.SkillMeta 4 | import ink.ptms.um.skill.SkillResult 5 | import org.bukkit.entity.Entity 6 | 7 | /** 8 | * universal-mythic 9 | * ink.ptms.um.skill.EntityTargetSkill 10 | * 11 | * @author 坏黑 12 | * @since 2023/6/6 16:06 13 | */ 14 | interface EntityTargetSkill : BaseSkill { 15 | 16 | /** 施法 */ 17 | fun cast(meta: SkillMeta, entity: Entity): SkillResult 18 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/type/LocationTargetSkill.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill.type 2 | 3 | import ink.ptms.um.skill.SkillMeta 4 | import ink.ptms.um.skill.SkillResult 5 | import org.bukkit.Location 6 | 7 | /** 8 | * universal-mythic 9 | * ink.ptms.um.skill.LocationTargetSkill 10 | * 11 | * @author 坏黑 12 | * @since 2023/6/6 16:06 13 | */ 14 | interface LocationTargetSkill : BaseSkill { 15 | 16 | /** 施法 */ 17 | fun cast(meta: SkillMeta, location: Location): SkillResult 18 | } -------------------------------------------------------------------------------- /project/common/src/main/kotlin/ink/ptms/um/skill/type/NoTargetSkill.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.skill.type 2 | 3 | import ink.ptms.um.skill.SkillMeta 4 | import ink.ptms.um.skill.SkillResult 5 | 6 | /** 7 | * universal-mythic 8 | * ink.ptms.um.skill.NoTargetSkill 9 | * 10 | * @author 坏黑 11 | * @since 2023/6/6 16:05 12 | */ 13 | interface NoTargetSkill : BaseSkill { 14 | 15 | /** 施法 */ 16 | fun cast(meta: SkillMeta): SkillResult 17 | } -------------------------------------------------------------------------------- /project/implementation-v4/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import io.izzel.taboolib.gradle.* 2 | 3 | val taboolib_version: String by project 4 | 5 | plugins { 6 | id("io.izzel.taboolib") version "2.0.22" 7 | } 8 | 9 | taboolib { 10 | subproject = true 11 | env { 12 | // install(UNIVERSAL, BUKKIT_ALL, NMS_UTIL) 13 | install(Basic, Bukkit, BukkitNMS, BukkitNMSUtil, BukkitUtil) 14 | 15 | } 16 | version { 17 | taboolib = taboolib_version 18 | } 19 | } 20 | 21 | dependencies { 22 | api(project(":project:common")) 23 | compileOnly("com.electronwill.night-config:core-conversion:6.0.0") 24 | compileOnly("com.electronwill.night-config:core:3.6.6") 25 | compileOnly("public:MythicMobs:1.0.1") 26 | compileOnly("ink.ptms:nms-all:1.0.0") 27 | compileOnly("org.yaml:snakeyaml:1.26") 28 | compileOnly("ink.ptms.core:v11802:11802-minimize:mapped") 29 | compileOnly("ink.ptms.core:v11802:11802-minimize:universal") 30 | } 31 | 32 | configure { 33 | sourceCompatibility = JavaVersion.VERSION_1_8 34 | targetCompatibility = JavaVersion.VERSION_1_8 35 | } 36 | -------------------------------------------------------------------------------- /project/implementation-v4/src/main/kotlin/ink/ptms/um/impl4/Item.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl4 2 | 3 | import ink.ptms.um.Item 4 | import io.lumine.xikage.mythicmobs.items.MythicItem 5 | import org.bukkit.inventory.ItemStack 6 | 7 | internal class Item(val source: MythicItem) : Item { 8 | 9 | override val internalName: String 10 | get() = source.internalName 11 | 12 | override val amount: Int 13 | get() = source.amount 14 | 15 | override val displayName: String? 16 | get() = source.displayName 17 | 18 | override val config: taboolib.library.configuration.ConfigurationSection 19 | get() = MobConfiguration(source.config) 20 | 21 | override fun generateItemStack(amount: Int): ItemStack { 22 | return source.generateItemStack(amount).toBukkit() 23 | } 24 | } -------------------------------------------------------------------------------- /project/implementation-v4/src/main/kotlin/ink/ptms/um/impl4/Mob.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl4 2 | 3 | import ink.ptms.um.Mob 4 | import ink.ptms.um.MobType 5 | import io.lumine.xikage.mythicmobs.MythicMobs 6 | import io.lumine.xikage.mythicmobs.mobs.ActiveMob 7 | import org.bukkit.entity.Entity 8 | import org.bukkit.entity.EntityType 9 | import org.bukkit.entity.LivingEntity 10 | import taboolib.library.configuration.ConfigurationSection 11 | 12 | /** 13 | * universal-mythic 14 | * ink.ptms.um.impl4.Mob4 15 | * 16 | * @author 坏黑 17 | * @since 2022/7/12 13:51 18 | */ 19 | internal class Mob(val source: ActiveMob) : Mob { 20 | 21 | override val id: String 22 | get() = source.type.internalName 23 | 24 | override val displayName: String 25 | get() = source.displayName 26 | 27 | override val type: MobType 28 | get() = MobType(source.type) 29 | 30 | override val entity: Entity 31 | get() = source.entity.bukkitEntity 32 | 33 | override val entityType: EntityType 34 | get() = entity.type 35 | 36 | override val level: Double 37 | get() = source.level 38 | 39 | override val stance: String 40 | get() = source.stance 41 | 42 | override val faction: String 43 | get() = source.faction 44 | 45 | override val config: ConfigurationSection 46 | get() = type.config 47 | 48 | 49 | override fun addThreat(mob: Entity, target: LivingEntity, amount: Double) { 50 | MythicMobs.inst().apiHelper.addThreat(mob, target, amount) 51 | } 52 | 53 | override fun reduceThreat(mob: Entity, target: LivingEntity, amount: Double) { 54 | MythicMobs.inst().apiHelper.reduceThreat(mob, target, amount) 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /project/implementation-v4/src/main/kotlin/ink/ptms/um/impl4/MobConfiguration.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl4 2 | 3 | import com.electronwill.nightconfig.core.CommentedConfig 4 | import io.lumine.xikage.mythicmobs.io.MythicConfig 5 | import io.lumine.xikage.mythicmobs.utils.config.file.FileConfiguration 6 | import taboolib.common.util.unsafeLazy 7 | import taboolib.library.configuration.ConfigurationSection 8 | import taboolib.library.reflex.Reflex.Companion.getProperty 9 | import taboolib.module.configuration.Type 10 | 11 | /** 12 | * universal-mythic 13 | * ink.ptms.um.impl4.MobConfiguration 14 | * 15 | * @author 坏黑 16 | * @since 2022/9/2 14:46 17 | */ 18 | internal class MobConfiguration(val config: MythicConfig) : ConfigurationSection { 19 | 20 | override val primitiveConfig: Any 21 | get() = config 22 | 23 | override var name: String 24 | get() = config.key 25 | set(value) { 26 | config.key = value 27 | } 28 | 29 | override val parent: ConfigurationSection? 30 | get() = null 31 | 32 | override val type: Type 33 | get() = Type.YAML 34 | 35 | override fun addComments(path: String, comments: List) { 36 | getComments(path).toMutableList().apply { 37 | addAll(comments) 38 | setComments(path, this) 39 | } 40 | } 41 | 42 | val root: FileConfiguration by unsafeLazy { 43 | runCatching { config.fileConfiguration }.getOrElse { config.getProperty("fc")!! } 44 | } 45 | 46 | override fun clear() { 47 | error("Unmodifiable") 48 | } 49 | 50 | override fun contains(path: String): Boolean { 51 | return config.isSet(path) 52 | } 53 | 54 | override fun createSection(path: String): ConfigurationSection { 55 | error("Unmodifiable") 56 | } 57 | 58 | override fun get(path: String): Any? { 59 | return root.get("$name.$path") 60 | } 61 | 62 | override fun get(path: String, def: Any?): Any? { 63 | return root.get("$name.$path", def) 64 | } 65 | 66 | override fun getBoolean(path: String): Boolean { 67 | return root.getBoolean("$name.$path") 68 | } 69 | 70 | override fun getBoolean(path: String, def: Boolean): Boolean { 71 | return root.getBoolean("$name.$path", def) 72 | } 73 | 74 | override fun getBooleanList(path: String): List { 75 | return root.getBooleanList("$name.$path") 76 | } 77 | 78 | override fun getByteList(path: String): List { 79 | return root.getByteList("$name.$path") 80 | } 81 | 82 | override fun getCharacterList(path: String): List { 83 | return root.getCharacterList("$name.$path") 84 | } 85 | 86 | override fun getComment(path: String): String? { 87 | return (root as? CommentedConfig)?.getComment(path) 88 | } 89 | 90 | override fun getComments(path: String): List { 91 | return getComment(path)?.lines() ?: emptyList() 92 | } 93 | 94 | override fun getConfigurationSection(path: String): ConfigurationSection? { 95 | return root.getConfigurationSection("$name.$path")?.let { 96 | MobConfiguration(MythicConfig("$name.$path", root)) 97 | } 98 | } 99 | 100 | override fun getDouble(path: String): Double { 101 | return root.getDouble("$name.$path") 102 | } 103 | 104 | override fun getDouble(path: String, def: Double): Double { 105 | return root.getDouble("$name.$path", def) 106 | } 107 | 108 | override fun getDoubleList(path: String): List { 109 | return root.getDoubleList("$name.$path") 110 | } 111 | 112 | override fun > getEnum(path: String, type: Class): T? { 113 | error("Unsupported") 114 | } 115 | 116 | override fun > getEnumList(path: String, type: Class): List { 117 | error("Unsupported") 118 | } 119 | 120 | override fun getFloatList(path: String): List { 121 | return root.getFloatList("$name.$path") 122 | } 123 | 124 | override fun getInt(path: String): Int { 125 | return root.getInt("$name.$path") 126 | } 127 | 128 | override fun getInt(path: String, def: Int): Int { 129 | return root.getInt("$name.$path", def) 130 | } 131 | 132 | override fun getIntegerList(path: String): List { 133 | return root.getIntegerList("$name.$path") 134 | } 135 | 136 | override fun getKeys(deep: Boolean): Set { 137 | return root.getConfigurationSection(name)?.getKeys(deep) ?: emptySet() 138 | } 139 | 140 | override fun getList(path: String): List<*>? { 141 | return root.getList("$name.$path") 142 | } 143 | 144 | override fun getList(path: String, def: List<*>?): List<*>? { 145 | return root.getList("$name.$path", def) 146 | } 147 | 148 | override fun getLong(path: String): Long { 149 | return root.getLong("$name.$path") 150 | } 151 | 152 | override fun getLong(path: String, def: Long): Long { 153 | return root.getLong("$name.$path", def) 154 | } 155 | 156 | override fun getLongList(path: String): List { 157 | return root.getLongList("$name.$path") 158 | } 159 | 160 | override fun getMapList(path: String): List> { 161 | return root.getMapList("$name.$path") 162 | } 163 | 164 | override fun getShortList(path: String): List { 165 | return root.getShortList("$name.$path") 166 | } 167 | 168 | override fun getString(path: String): String? { 169 | return root.getString("$name.$path") 170 | } 171 | 172 | override fun getString(path: String, def: String?): String? { 173 | return root.getString("$name.$path", def) 174 | } 175 | 176 | override fun getStringList(path: String): List { 177 | return root.getStringList("$name.$path") 178 | } 179 | 180 | override fun getValues(deep: Boolean): Map { 181 | return root.getConfigurationSection(name)?.getValues(deep) ?: emptyMap() 182 | } 183 | 184 | override fun isBoolean(path: String): Boolean { 185 | return root.isBoolean("$name.$path") 186 | } 187 | 188 | override fun isConfigurationSection(path: String): Boolean { 189 | return root.isConfigurationSection("$name.$path") 190 | } 191 | 192 | override fun isDouble(path: String): Boolean { 193 | return root.isDouble("$name.$path") 194 | } 195 | 196 | override fun isInt(path: String): Boolean { 197 | return root.isInt("$name.$path") 198 | } 199 | 200 | override fun isList(path: String): Boolean { 201 | return root.isList("$name.$path") 202 | } 203 | 204 | override fun isLong(path: String): Boolean { 205 | return root.isLong("$name.$path") 206 | } 207 | 208 | override fun isSet(path: String): Boolean { 209 | return root.isSet("$name.$path") 210 | } 211 | 212 | override fun isString(path: String): Boolean { 213 | return root.isString("$name.$path") 214 | } 215 | 216 | override fun set(path: String, value: Any?) { 217 | root.set(path, value) 218 | } 219 | 220 | override fun setComment(path: String, comment: String?) { 221 | (root as? CommentedConfig)?.setComment(path, if (comment?.isBlank() == true) null else comment) 222 | } 223 | 224 | override fun setComments(path: String, comments: List) { 225 | return setComment(path, comments.joinToString("\n")) 226 | } 227 | 228 | override fun toMap(): Map { 229 | error("Unsupported") 230 | } 231 | } 232 | -------------------------------------------------------------------------------- /project/implementation-v4/src/main/kotlin/ink/ptms/um/impl4/MobListener.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl4 2 | 3 | import ink.ptms.um.event.MobDeathEvent 4 | import ink.ptms.um.event.MobSpawnEvent 5 | import ink.ptms.um.event.MythicReloadEvent 6 | import io.lumine.xikage.mythicmobs.MythicMobs 7 | import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent 8 | import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobSpawnEvent 9 | import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicReloadedEvent 10 | import taboolib.common.platform.Ghost 11 | import taboolib.common.platform.event.SubscribeEvent 12 | 13 | internal object MobListener { 14 | 15 | @Ghost 16 | @SubscribeEvent 17 | fun onMobDeathEvent(event: MythicMobDeathEvent) { 18 | // 唤起事件,并更新掉落物 19 | val activeMob = runCatching { 20 | event.mob 21 | }.getOrElse { 22 | MythicMobs.inst().mobManager.getMythicMobInstance(event.entity) ?: return 23 | } 24 | event.drops = MobDeathEvent(Mob(activeMob), event.killer, event.drops).fire().drop 25 | } 26 | 27 | @Ghost 28 | @SubscribeEvent 29 | fun onMobSpawnEvent(event: MythicMobSpawnEvent) { 30 | // 在部分 MythicMobs 版本无法在 MythicMobSpawnEvent 中获取 mob 参数 31 | val activeMob = runCatching { 32 | event.mob 33 | }.getOrElse { 34 | MythicMobs.inst().mobManager.getMythicMobInstance(event.entity) ?: return 35 | } 36 | val mob4 = Mob(activeMob) 37 | // 唤起事件 38 | val e = MobSpawnEvent(mob4, mob4.type, runCatching { event.mobLevel }.getOrElse { 0.0 }).fire() 39 | // 更新等级 40 | runCatching { event.mobLevel = e.level } 41 | if (e.isCancelled) event.setCancelled() 42 | } 43 | 44 | @Ghost 45 | @SubscribeEvent 46 | fun onMythicReloadEvent(event: MythicReloadedEvent) { 47 | MythicReloadEvent().fire() 48 | } 49 | } -------------------------------------------------------------------------------- /project/implementation-v4/src/main/kotlin/ink/ptms/um/impl4/MobListenerCondition.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl4 2 | 3 | import ink.ptms.um.event.MobConditionLoadEvent 4 | import ink.ptms.um.skill.condition.* 5 | import io.lumine.xikage.mythicmobs.adapters.AbstractEntity 6 | import io.lumine.xikage.mythicmobs.adapters.AbstractLocation 7 | import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicConditionLoadEvent 8 | import io.lumine.xikage.mythicmobs.io.MythicLineConfig 9 | import io.lumine.xikage.mythicmobs.skills.SkillCaster 10 | import io.lumine.xikage.mythicmobs.skills.SkillCondition 11 | import io.lumine.xikage.mythicmobs.skills.SkillMetadata 12 | import io.lumine.xikage.mythicmobs.skills.conditions.* 13 | import taboolib.common.platform.Ghost 14 | import taboolib.common.platform.event.SubscribeEvent 15 | 16 | /** project name universal-mythic 17 | * package ink.ptms.um.impl4 18 | * time 2024/7/6 19 | * author 劫 20 | */ 21 | internal object MobListenerCondition { 22 | 23 | @Ghost 24 | @SubscribeEvent 25 | fun onSkillConditionEvent(event: MythicConditionLoadEvent) { 26 | val config = event.config 27 | val e = MobConditionLoadEvent(config.key, config.toUniversal()).fire() 28 | val registerCondition = e.skillCondition ?: return 29 | if (!BaseCondition.isSubclass(registerCondition)) { 30 | error("Unsupported skill: $registerCondition") 31 | } 32 | when (registerCondition) { 33 | is EntityCondition -> event.register(Entity(registerCondition, config)) 34 | is CasterCondition -> event.register(Caster(registerCondition, config)) 35 | is LocationCondition -> event.register(Location(registerCondition, config)) 36 | is SkillMetadataCondition -> event.register(SkillMeta(registerCondition, config)) 37 | is EntityComparisonCondition -> event.register(EntityComparison(registerCondition, config)) 38 | is EntityLocationDistanceCondition -> event.register(EntityLocation(registerCondition, config)) 39 | is SkillMetaComparisonCondition -> throw NullPointerException("当前MM版本不支持这个条件") 40 | } 41 | } 42 | 43 | class Caster(val condition: CasterCondition, config: MythicLineConfig) : SkillCondition(config.line), ICasterCondition { 44 | override fun check(p0: SkillCaster?): Boolean { 45 | return condition.check(p0?.toUniversal()) 46 | } 47 | } 48 | 49 | class EntityComparison(val condition: EntityComparisonCondition, config: MythicLineConfig) : SkillCondition(config.line), 50 | IEntityComparisonCondition { 51 | override fun check(p0: AbstractEntity?, p1: AbstractEntity?): Boolean { 52 | return condition.check(p0?.bukkitEntity, p1?.bukkitEntity) 53 | } 54 | } 55 | 56 | class EntityLocation(val condition: EntityLocationDistanceCondition, config: MythicLineConfig) : SkillCondition(config.line), 57 | IEntityLocationComparisonCondition { 58 | override fun check(p0: AbstractEntity?, p1: AbstractLocation?): Boolean { 59 | return condition.check(p0?.bukkitEntity, p1?.toBukkit()) 60 | } 61 | } 62 | 63 | class Entity(val condition: EntityCondition, config: MythicLineConfig) : SkillCondition(config.line), IEntityCondition { 64 | override fun check(p0: AbstractEntity?): Boolean { 65 | return condition.check(p0?.bukkitEntity) 66 | } 67 | } 68 | 69 | class SkillMeta(val condition: SkillMetadataCondition, config: MythicLineConfig) : SkillCondition(config.line), ISkillMetaCondition { 70 | override fun check(p0: SkillMetadata?): Boolean { 71 | return condition.check(p0?.toUniversal()) 72 | } 73 | } 74 | 75 | class Location(val condition: LocationCondition, config: MythicLineConfig) : SkillCondition(config.line), ILocationCondition { 76 | override fun check(p0: AbstractLocation?): Boolean { 77 | return condition.check(p0?.toBukkit()) 78 | } 79 | } 80 | } -------------------------------------------------------------------------------- /project/implementation-v4/src/main/kotlin/ink/ptms/um/impl4/MobListenerDrop.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl4 2 | 3 | import ink.ptms.um.event.MobDropLoadEvent 4 | import ink.ptms.um.item.DropMeta 5 | import ink.ptms.um.skill.SkillCaster 6 | import io.lumine.xikage.mythicmobs.adapters.AbstractItemStack 7 | import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitAdapter 8 | import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicDropLoadEvent 9 | import io.lumine.xikage.mythicmobs.drops.Drop 10 | import io.lumine.xikage.mythicmobs.drops.DropMetadata 11 | import io.lumine.xikage.mythicmobs.drops.IItemDrop 12 | import org.bukkit.entity.Entity 13 | import taboolib.common.platform.Ghost 14 | import taboolib.common.platform.event.SubscribeEvent 15 | 16 | internal object MobListenerDrop { 17 | 18 | @Ghost 19 | @SubscribeEvent 20 | fun onDropLoadEvent(event: MythicDropLoadEvent) { 21 | val e = MobDropLoadEvent(event.dropName).fire() 22 | e.itemDrops.forEach { dropFunc -> 23 | event.register(object : Drop(event.dropName, event.config), IItemDrop { 24 | 25 | override fun getDrop(dropMeta: DropMetadata): AbstractItemStack { 26 | return BukkitAdapter.adapt(dropFunc.apply(object : DropMeta { 27 | 28 | override val dropper: SkillCaster? 29 | get() = dropMeta.caster?.toUniversal() 30 | 31 | override val cause: Entity? 32 | get() = dropMeta.trigger?.bukkitEntity 33 | 34 | override var amount: Float 35 | get() = dropMeta.amount 36 | set(value) { 37 | dropMeta.amount = value 38 | } 39 | 40 | override var generations: Int 41 | get() = dropMeta.generations 42 | set(value) { 43 | dropMeta.generations = value 44 | } 45 | 46 | override fun tick() { 47 | dropMeta.tick() 48 | } 49 | })) 50 | } 51 | }) 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /project/implementation-v4/src/main/kotlin/ink/ptms/um/impl4/MobListenerSkill.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl4 2 | 3 | import ink.ptms.um.event.MobSkillLoadEvent 4 | import ink.ptms.um.skill.SkillResult 5 | import ink.ptms.um.skill.type.BaseSkill 6 | import ink.ptms.um.skill.type.EntityTargetSkill 7 | import ink.ptms.um.skill.type.LocationTargetSkill 8 | import ink.ptms.um.skill.type.NoTargetSkill 9 | import io.lumine.xikage.mythicmobs.adapters.AbstractEntity 10 | import io.lumine.xikage.mythicmobs.adapters.AbstractLocation 11 | import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMechanicLoadEvent 12 | import io.lumine.xikage.mythicmobs.io.MythicLineConfig 13 | import io.lumine.xikage.mythicmobs.skills.* 14 | import taboolib.common.platform.Ghost 15 | import taboolib.common.platform.event.SubscribeEvent 16 | import taboolib.common.platform.function.warning 17 | 18 | internal object MobListenerSkill { 19 | 20 | var isCrashed = false 21 | 22 | @Ghost 23 | @SubscribeEvent 24 | fun onDropLoadEvent(event: MythicMechanicLoadEvent) { 25 | if (isCrashed) return 26 | try { 27 | val e = MobSkillLoadEvent(event.mechanicName, event.config.toUniversal()).fire() 28 | val registerSkill = e.registerSkill ?: return 29 | // 如果注册的技能,不在这三种类型中,那么就是无效的技能类型 30 | if (registerSkill !is EntityTargetSkill && registerSkill !is LocationTargetSkill && registerSkill !is NoTargetSkill) { 31 | error("Unsupported skill: $registerSkill") 32 | } 33 | event.register(ProxySkill(registerSkill, event.mechanicName, event.config)) 34 | } catch (ex: Throwable) { 35 | isCrashed = true 36 | ex.printStackTrace() 37 | } 38 | } 39 | 40 | class ProxySkill(val skill: BaseSkill, name: String, mlc: MythicLineConfig) : SkillMechanic(name, mlc), ITargetedEntitySkill, ITargetedLocationSkill, INoTargetSkill { 41 | 42 | override fun castAtEntity(metadata: SkillMetadata, entity: AbstractEntity): Boolean { 43 | if (skill is EntityTargetSkill) { 44 | return skill.cast(metadata.toUniversal(), entity.bukkitEntity) == SkillResult.SUCCESS 45 | } 46 | warning("$skill is not ITargetedEntitySkill") 47 | return false 48 | } 49 | 50 | override fun castAtLocation(metadata: SkillMetadata, location: AbstractLocation): Boolean { 51 | if (skill is LocationTargetSkill) { 52 | return skill.cast(metadata.toUniversal(), location.toBukkit()) == SkillResult.SUCCESS 53 | } 54 | warning("$skill is not ITargetedLocationSkill") 55 | return false 56 | } 57 | 58 | override fun cast(metadata: SkillMetadata): Boolean { 59 | if (skill is NoTargetSkill) { 60 | return skill.cast(metadata.toUniversal()) == SkillResult.SUCCESS 61 | } 62 | warning("$skill is not INoTargetSkill") 63 | return false 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /project/implementation-v4/src/main/kotlin/ink/ptms/um/impl4/MobType.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl4 2 | 3 | import ink.ptms.um.Mob 4 | import ink.ptms.um.MobType 5 | import io.lumine.xikage.mythicmobs.mobs.MythicMob 6 | import org.bukkit.Location 7 | import taboolib.library.configuration.ConfigurationSection 8 | 9 | internal class MobType(val source: MythicMob) : MobType { 10 | 11 | override val id: String 12 | get() = source.internalName 13 | 14 | override val displayName: String 15 | get() = source.displayName.get() 16 | 17 | override val entityType: String 18 | get() = source.entityType 19 | 20 | override val config: ConfigurationSection 21 | get() = MobConfiguration(source.config) 22 | 23 | override fun spawn(location: Location, level: Double): Mob { 24 | return Mob(source.spawn(location.toMythic(), level)) 25 | } 26 | } -------------------------------------------------------------------------------- /project/implementation-v4/src/main/kotlin/ink/ptms/um/impl4/Mythic4.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl4 2 | 3 | import ink.ptms.um.Mythic 4 | import ink.ptms.um.Skill 5 | import io.lumine.xikage.mythicmobs.MythicMobs 6 | import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitAdapter 7 | import io.lumine.xikage.mythicmobs.drops.DropMetadata 8 | import io.lumine.xikage.mythicmobs.io.MythicConfig 9 | import io.lumine.xikage.mythicmobs.io.MythicLineConfig 10 | import io.lumine.xikage.mythicmobs.items.ItemManager 11 | import io.lumine.xikage.mythicmobs.items.MythicItem 12 | import io.lumine.xikage.mythicmobs.mobs.GenericCaster 13 | import io.lumine.xikage.mythicmobs.mobs.MobManager 14 | import io.lumine.xikage.mythicmobs.mobs.MythicMob 15 | import io.lumine.xikage.mythicmobs.skills.SkillManager 16 | import io.lumine.xikage.mythicmobs.skills.SkillTrigger 17 | import io.lumine.xikage.mythicmobs.util.MythicUtil 18 | import io.lumine.xikage.mythicmobs.utils.config.file.YamlConfiguration 19 | import org.bukkit.Location 20 | import org.bukkit.entity.Entity 21 | import org.bukkit.entity.LivingEntity 22 | import org.bukkit.entity.Player 23 | import org.bukkit.inventory.ItemStack 24 | import taboolib.common.LifeCycle 25 | import taboolib.common.platform.Awake 26 | import taboolib.common.util.unsafeLazy 27 | import taboolib.library.reflex.Reflex.Companion.getProperty 28 | import taboolib.module.nms.getName 29 | import java.io.File 30 | import java.util.* 31 | import java.util.concurrent.ConcurrentHashMap 32 | import kotlin.jvm.optionals.getOrNull 33 | 34 | /** 35 | * universal-mythic ink.ptms.um.impl4.Mythic4 36 | * 37 | * @author 坏黑 38 | * @since 2022/7/12 13:47 39 | */ 40 | internal class Mythic4 : Mythic { 41 | 42 | val api: MythicMobs 43 | get() = MythicMobs.inst() 44 | 45 | val mobManager: MobManager by unsafeLazy { api.mobManager } 46 | 47 | val itemManager: ItemManager by unsafeLazy { api.itemManager } 48 | 49 | val skillManager: SkillManager by unsafeLazy { api.skillManager } 50 | 51 | val mmList: ConcurrentHashMap by unsafeLazy { 52 | mobManager.getProperty>("mmList")!! 53 | } 54 | 55 | override val isLegacy = true 56 | 57 | override fun getTargetedEntity(player: Player): LivingEntity? { 58 | return MythicUtil.getTargetedEntity(player) 59 | } 60 | 61 | override fun getItem(name: String): ink.ptms.um.Item? { 62 | return Item(itemManager.getItem(name)?.get() ?: return null) 63 | } 64 | 65 | override fun getItemId(itemStack: ItemStack): String? { 66 | /** 观看了低版本MythicItem 的写法 判断Display即可 判断ItemStack会触发大量创建ItemStack */ 67 | return getItemList().firstOrNull { item -> itemStack.getName().equals(item.displayName, true) }?.internalName 68 | } 69 | 70 | override fun getItemStack(name: String, player: Player?): ItemStack? { 71 | val target = player?.let { BukkitAdapter.adapt(it) } 72 | val meta = target?.let { DropMetadata(GenericCaster(target), target) } 73 | return meta?.let { itemManager.getItem(name)?.get()?.generateItemStack(it, 1)?.toBukkit() } 74 | ?: itemManager.getItemStack(name) 75 | } 76 | 77 | override fun getItemStack(name: String): ItemStack? { 78 | return itemManager.getItemStack(name) 79 | } 80 | 81 | override fun getItemIDList(): List { 82 | return itemManager.items.map { it.internalName } 83 | } 84 | 85 | override fun getItemList(): List { 86 | return itemManager.items.map { Item(it) } 87 | } 88 | 89 | override fun getMob(entity: Entity): ink.ptms.um.Mob? { 90 | return Mob(mobManager.getMythicMobInstance(entity) ?: return null) 91 | } 92 | 93 | override fun getMob(uuid: UUID): ink.ptms.um.Mob? { 94 | return Mob(mobManager.getActiveMob(uuid).getOrNull() ?: return null) 95 | } 96 | 97 | override fun getMobIDList(): List { 98 | return mobManager.mobNames.toList() 99 | } 100 | 101 | override fun getMobType(name: String): ink.ptms.um.MobType? { 102 | return MobType(mobManager.getMythicMob(name) ?: return null) 103 | } 104 | 105 | override fun getSkillTrigger(name: String): Skill.Trigger { 106 | return Skill4.Trigger(SkillTrigger.valueOf(name.uppercase())) 107 | } 108 | 109 | override fun getDefaultSkillTrigger(): Skill.Trigger { 110 | return Skill4.Trigger(SkillTrigger.DEFAULT) 111 | } 112 | 113 | override fun getSkillMechanic(skillLine: String): Skill? { 114 | return Skill4(skillManager.getSkillMechanic(MythicLineConfig.unparseBlock(skillLine)) ?: return null) 115 | } 116 | 117 | override fun castSkill( 118 | caster: Entity, 119 | skillName: String, 120 | trigger: Entity?, 121 | origin: Location, 122 | et: Collection, 123 | lt: Collection, 124 | power: Float, 125 | ): Boolean { 126 | return api.apiHelper.castSkill(caster, skillName, trigger, origin, et, lt, power) 127 | } 128 | 129 | override fun registerItem(file: File, node: String): Boolean { 130 | return itemManager.registerItem(node, MythicItem(file.name, node, MythicConfig(node, file, YamlConfiguration.loadConfiguration(file)))) 131 | } 132 | 133 | override fun unregisterItem(node: String): Boolean { 134 | return itemManager.getProperty>("items")!!.let { 135 | if (it.contains(node)) { 136 | it.remove(node) 137 | true 138 | } else false 139 | } 140 | } 141 | 142 | override fun registerMob(file: File, node: String): Boolean { 143 | return if (!mmList.contains(node)) { 144 | mmList[node] = MythicMob(file.name, node, MythicConfig(node, file, YamlConfiguration.loadConfiguration(file))) 145 | true 146 | } else false 147 | } 148 | 149 | override fun unregisterMob(node: String): Boolean { 150 | return if (mmList.contains(node)) { 151 | mmList.remove(node) 152 | true 153 | } else false 154 | } 155 | 156 | object Loader { 157 | 158 | @Awake(LifeCycle.ENABLE) 159 | fun setup() { 160 | if (runCatching { Class.forName("io.lumine.xikage.mythicmobs.MythicMobs") }.getOrNull() != null) { 161 | Mythic.API = Mythic4() 162 | } 163 | } 164 | } 165 | } 166 | -------------------------------------------------------------------------------- /project/implementation-v4/src/main/kotlin/ink/ptms/um/impl4/Skill4.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl4 2 | 3 | import ink.ptms.um.Skill 4 | import io.lumine.xikage.mythicmobs.MythicMobs 5 | import io.lumine.xikage.mythicmobs.adapters.AbstractEntity 6 | import io.lumine.xikage.mythicmobs.adapters.AbstractLocation 7 | import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitAdapter 8 | import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitPlayer 9 | import io.lumine.xikage.mythicmobs.mobs.GenericCaster 10 | import io.lumine.xikage.mythicmobs.skills.SkillCaster 11 | import io.lumine.xikage.mythicmobs.skills.SkillMechanic 12 | import io.lumine.xikage.mythicmobs.skills.SkillMetadata 13 | import io.lumine.xikage.mythicmobs.skills.SkillTrigger 14 | import io.lumine.xikage.mythicmobs.skills.mechanics.DelaySkill 15 | import org.bukkit.Location 16 | import org.bukkit.entity.Entity 17 | import org.bukkit.entity.Player 18 | import java.util.function.Function 19 | 20 | internal class Skill4(val source: SkillMechanic) : Skill { 21 | 22 | override val delay: Int = (source as? DelaySkill)?.ticks ?: -1 23 | 24 | override fun execute( 25 | trigger: Skill.Trigger, 26 | entity: Entity, 27 | target: Entity, 28 | et: Set, 29 | lt: Set, 30 | power: Float, 31 | parameters: Map, 32 | targetFilter: (Entity) -> Boolean 33 | ): Boolean { 34 | val caster = if (entity is Player) BukkitPlayer(entity) else BukkitAdapter.adapt(entity) 35 | MythicMobs.inst().skillManager.runSecondPass() 36 | return source.executeSkills( 37 | MetadataImpl( 38 | (trigger as Trigger).source, 39 | CasterImpl(caster, parameters), 40 | BukkitAdapter.adapt(target), 41 | BukkitAdapter.adapt(entity.location), 42 | et.map { BukkitAdapter.adapt(it) }.toHashSet(), 43 | lt.map { BukkitAdapter.adapt(it) }.toHashSet(), 44 | power, 45 | targetFilter 46 | ) 47 | ) 48 | } 49 | 50 | /** 获取技能是否正在冷却 */ 51 | override fun onCooldown(caster: Entity): Boolean { 52 | return source.onCooldown(CasterImpl(BukkitAdapter.adapt(caster), emptyMap())) 53 | } 54 | 55 | /** 获取技能冷却 */ 56 | override fun getCooldown(caster: Entity): Float { 57 | return source.getCooldown(CasterImpl(BukkitAdapter.adapt(caster), emptyMap())) 58 | } 59 | 60 | /** 设置技能冷却 */ 61 | override fun setCooldown(caster: Entity, time: Double) { 62 | return source.setCooldown(CasterImpl(BukkitAdapter.adapt(caster), emptyMap()), time.toFloat()) 63 | } 64 | 65 | class Trigger(obj: Any) : Skill.Trigger { 66 | 67 | val source = obj as SkillTrigger 68 | 69 | override val name: String = source.name 70 | } 71 | 72 | /** 73 | * 技能施法者内部实现 74 | */ 75 | class CasterImpl(entity: AbstractEntity?, override val parameters: Map) : GenericCaster(entity), Skill.ActiveCaster 76 | 77 | /** 78 | * 技能元数据内部实现 79 | */ 80 | class MetadataImpl( 81 | cause: SkillTrigger, 82 | caster: SkillCaster, 83 | trigger: AbstractEntity, 84 | origin: AbstractLocation, 85 | et: HashSet, 86 | lt: HashSet, 87 | power: Float, 88 | val targetFilter: Function 89 | ) : SkillMetadata(cause, caster, trigger, origin, et.filter { targetFilter.apply(it.bukkitEntity) }.toHashSet(), lt, power) { 90 | 91 | override fun setEntityTarget(target: AbstractEntity): SkillMetadata { 92 | if (targetFilter.apply(target.bukkitEntity)) { 93 | return super.setEntityTarget(target) 94 | } 95 | return this 96 | } 97 | 98 | override fun setEntityTargets(targets: java.util.HashSet): SkillMetadata { 99 | return super.setEntityTargets(targets.filter { targetFilter.apply(it.bukkitEntity) }.toHashSet()) 100 | } 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /project/implementation-v4/src/main/kotlin/ink/ptms/um/impl4/Utils.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl4 2 | 3 | import ink.ptms.um.Skill 4 | import ink.ptms.um.skill.SkillConfig 5 | import ink.ptms.um.skill.SkillMeta 6 | import io.lumine.xikage.mythicmobs.adapters.AbstractEntity 7 | import io.lumine.xikage.mythicmobs.adapters.AbstractItemStack 8 | import io.lumine.xikage.mythicmobs.adapters.AbstractLocation 9 | import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitAdapter 10 | import io.lumine.xikage.mythicmobs.io.MythicLineConfig 11 | import io.lumine.xikage.mythicmobs.skills.SkillCaster 12 | import io.lumine.xikage.mythicmobs.skills.SkillMetadata 13 | import io.lumine.xikage.mythicmobs.skills.placeholders.parsers.PlaceholderDouble 14 | import io.lumine.xikage.mythicmobs.skills.placeholders.parsers.PlaceholderFloat 15 | import io.lumine.xikage.mythicmobs.skills.placeholders.parsers.PlaceholderInt 16 | import io.lumine.xikage.mythicmobs.skills.placeholders.parsers.PlaceholderString 17 | import org.bukkit.Location 18 | import org.bukkit.entity.Entity 19 | import org.bukkit.inventory.ItemStack 20 | import taboolib.library.reflex.Reflex.Companion.getProperty 21 | import java.awt.Color 22 | import java.util.HashMap 23 | 24 | internal fun AbstractItemStack.toBukkit(): ItemStack { 25 | return BukkitAdapter.adapt(this) 26 | } 27 | 28 | internal fun AbstractLocation.toBukkit(): Location { 29 | return BukkitAdapter.adapt(this) 30 | } 31 | 32 | internal fun Location.toMythic(): AbstractLocation { 33 | return BukkitAdapter.adapt(this) 34 | } 35 | 36 | internal fun Entity.toMythic(): AbstractEntity { 37 | return BukkitAdapter.adapt(this) 38 | } 39 | 40 | internal fun SkillCaster.toUniversal(): ink.ptms.um.skill.SkillCaster { 41 | return SkillCasterProxy4(this) 42 | } 43 | 44 | internal fun ink.ptms.um.skill.SkillCaster.toMythic(): SkillCaster { 45 | return (this as SkillCasterProxy4).origin 46 | } 47 | 48 | internal class SkillCasterProxy4(val origin: SkillCaster) : ink.ptms.um.skill.SkillCaster { 49 | 50 | override val entity: Entity 51 | get() = origin.entity.bukkitEntity 52 | 53 | override val location: Location 54 | get() = origin.location.toBukkit() 55 | 56 | override val level: Double 57 | get() = origin.level 58 | 59 | override val power: Float 60 | get() = origin.power 61 | 62 | override var globalCooldown: Int 63 | get() = origin.globalCooldown 64 | set(value) { 65 | origin.globalCooldown = value 66 | } 67 | } 68 | 69 | internal fun PlaceholderString.toUniversal(): ink.ptms.um.skill.data.PlaceholderString { 70 | return object : ink.ptms.um.skill.data.PlaceholderString { 71 | 72 | override fun get(): String { 73 | return this@toUniversal.get() 74 | } 75 | 76 | override fun get(entity: Entity): String { 77 | return this@toUniversal.get(entity.toMythic()) 78 | } 79 | 80 | override fun get(caster: ink.ptms.um.skill.SkillCaster): String { 81 | return this@toUniversal.get(caster.toMythic()) 82 | } 83 | } 84 | } 85 | 86 | internal fun PlaceholderInt.toUniversal(): ink.ptms.um.skill.data.PlaceholderInt { 87 | return object : ink.ptms.um.skill.data.PlaceholderInt { 88 | 89 | override fun get(): Int { 90 | return this@toUniversal.get() 91 | } 92 | 93 | override fun get(entity: Entity): Int { 94 | return this@toUniversal.get(entity.toMythic()) 95 | } 96 | 97 | override fun get(caster: ink.ptms.um.skill.SkillCaster): Int { 98 | return this@toUniversal.get(caster.toMythic()) 99 | } 100 | } 101 | } 102 | 103 | internal fun PlaceholderDouble.toUniversal(): ink.ptms.um.skill.data.PlaceholderDouble { 104 | return object : ink.ptms.um.skill.data.PlaceholderDouble { 105 | 106 | override fun get(): Double { 107 | return this@toUniversal.get() 108 | } 109 | 110 | override fun get(entity: Entity): Double { 111 | return this@toUniversal.get(entity.toMythic()) 112 | } 113 | 114 | override fun get(caster: ink.ptms.um.skill.SkillCaster): Double { 115 | return this@toUniversal.get(caster.toMythic()) 116 | } 117 | } 118 | } 119 | 120 | internal fun PlaceholderFloat.toUniversal(): ink.ptms.um.skill.data.PlaceholderFloat { 121 | return object : ink.ptms.um.skill.data.PlaceholderFloat { 122 | 123 | override fun get(): Float { 124 | return this@toUniversal.get() 125 | } 126 | 127 | override fun get(entity: Entity): Float { 128 | return this@toUniversal.get(entity.toMythic()) 129 | } 130 | 131 | override fun get(caster: ink.ptms.um.skill.SkillCaster): Float { 132 | return this@toUniversal.get(caster.toMythic()) 133 | } 134 | } 135 | } 136 | 137 | internal fun MythicLineConfig.toUniversal(): SkillConfig { 138 | return object : SkillConfig { 139 | 140 | override fun line(): String { 141 | return this@toUniversal.line 142 | } 143 | 144 | override fun size(): Int { 145 | return this@toUniversal.size() 146 | } 147 | 148 | override fun entrySet(): Set> { 149 | return this@toUniversal.entrySet() 150 | } 151 | 152 | override fun getKey(): String { 153 | return this@toUniversal.key 154 | } 155 | 156 | override fun getKey(s: String): String { 157 | return this@toUniversal.key 158 | } 159 | 160 | override fun getBoolean(key: Array, def: Boolean): Boolean { 161 | return this@toUniversal.getBoolean(key, def) 162 | } 163 | 164 | override fun getString(key: Array, def: String): String { 165 | return this@toUniversal.getString(key, def) 166 | } 167 | 168 | override fun getPlaceholderString(key: Array, def: String, vararg args: String): ink.ptms.um.skill.data.PlaceholderString { 169 | return this@toUniversal.getPlaceholderString(key, def, *args).toUniversal() 170 | } 171 | 172 | override fun getInt(key: Array, def: Int): Int { 173 | return this@toUniversal.getInteger(key, def) 174 | } 175 | 176 | override fun getPlaceholderInt(key: Array, def: Int, vararg args: String): ink.ptms.um.skill.data.PlaceholderInt { 177 | return this@toUniversal.getPlaceholderInteger(key, def, *args).toUniversal() 178 | } 179 | 180 | override fun getDouble(key: Array, def: Double): Double { 181 | return this@toUniversal.getDouble(key, def) 182 | } 183 | 184 | override fun getPlaceholderDouble(key: Array, def: Double, vararg args: String): ink.ptms.um.skill.data.PlaceholderDouble { 185 | return this@toUniversal.getPlaceholderDouble(key, def, *args).toUniversal() 186 | } 187 | 188 | override fun getFloat(key: Array, def: Float): Float { 189 | return this@toUniversal.getFloat(key, def) 190 | } 191 | 192 | override fun getPlaceholderFloat(key: Array, def: Float, vararg args: String): ink.ptms.um.skill.data.PlaceholderFloat { 193 | return this@toUniversal.getPlaceholderFloat(key, def, *args).toUniversal() 194 | } 195 | 196 | override fun getLong(key: Array, def: Long): Long { 197 | return this@toUniversal.getLong(key, def) 198 | } 199 | 200 | override fun getColor(key: String, def: String): Color { 201 | return this@toUniversal.getColor(key, def) 202 | } 203 | 204 | override fun getColor(key: Array, def: String): Color { 205 | return this@toUniversal.getColor(key, def) 206 | } 207 | } 208 | } 209 | 210 | internal fun SkillMetadata.toUniversal(): SkillMeta { 211 | return object : SkillMeta { 212 | 213 | val metadataMap = this@toUniversal.getProperty>("metadata")!! 214 | 215 | override var caster: ink.ptms.um.skill.SkillCaster 216 | get() = this@toUniversal.caster.toUniversal() 217 | set(value) { 218 | this@toUniversal.caster = value.toMythic() 219 | } 220 | 221 | override var trigger: Entity 222 | get() = this@toUniversal.trigger.bukkitEntity 223 | set(value) { 224 | this@toUniversal.trigger = value.toMythic() 225 | } 226 | 227 | override var origin: Location 228 | get() = this@toUniversal.origin.toBukkit() 229 | set(value) { 230 | this@toUniversal.origin = value.toMythic() 231 | } 232 | 233 | override val cause: Skill.Trigger 234 | get() = Skill4.Trigger(this@toUniversal.cause) 235 | 236 | override var power: Float 237 | get() = this@toUniversal.power 238 | set(value) { 239 | this@toUniversal.power = value 240 | } 241 | 242 | override var isAsync: Boolean 243 | get() = this@toUniversal.isAsync 244 | set(value) { 245 | this@toUniversal.isAsync = value 246 | } 247 | 248 | override var entityTargets: Set 249 | get() = this@toUniversal.entityTargets.map { it.bukkitEntity }.toSet() 250 | set(value) { 251 | this@toUniversal.setEntityTargets(value.map { it.toMythic() }.toHashSet()) 252 | } 253 | 254 | override var locationTargets: Set 255 | get() = this@toUniversal.locationTargets.map { it.toBukkit() }.toSet() 256 | set(value) { 257 | this@toUniversal.setLocationTargets(value.map { it.toMythic() }.toHashSet()) 258 | } 259 | 260 | override val metadata: Map 261 | get() = metadataMap 262 | 263 | override val parameters: Map 264 | get() = emptyMap() // 该版本不支持 265 | 266 | override fun setMetadata(key: String, value: Any) { 267 | metadataMap[key] = value 268 | } 269 | 270 | override fun setParameter(key: String, value: String) { 271 | // 该版本不支持 272 | } 273 | 274 | override fun clone(): SkillMeta { 275 | return this@toUniversal.clone().toUniversal() 276 | } 277 | 278 | override fun deepClone(): SkillMeta { 279 | return this@toUniversal.deepClone().toUniversal() 280 | } 281 | } 282 | } -------------------------------------------------------------------------------- /project/implementation-v5/build.gradle.kts: -------------------------------------------------------------------------------- 1 | import io.izzel.taboolib.gradle.* 2 | 3 | val taboolib_version: String by project 4 | 5 | plugins { 6 | id("io.izzel.taboolib") version "2.0.22" 7 | } 8 | 9 | taboolib { 10 | subproject = true 11 | env { 12 | // install(UNIVERSAL, BUKKIT_ALL, NMS_UTIL) 13 | install(Basic, Bukkit, BukkitNMS, BukkitNMSUtil, BukkitUtil) 14 | } 15 | version { 16 | taboolib = taboolib_version 17 | } 18 | } 19 | 20 | dependencies { 21 | api(project(":project:common")) 22 | compileOnly("com.electronwill.night-config:core-conversion:6.0.0") 23 | compileOnly("com.electronwill.night-config:core:3.6.6") 24 | // 你改你妈个蛋,我爱说实话 25 | // compileOnly("public:MythicMobs5:5.0.4") 26 | compileOnly(fileTree("libs")) 27 | compileOnly("ink.ptms:nms-all:1.0.0") 28 | compileOnly("org.yaml:snakeyaml:1.26") 29 | compileOnly("ink.ptms.core:v11802:11802-minimize:mapped") 30 | compileOnly("ink.ptms.core:v11802:11802-minimize:universal") 31 | } 32 | 33 | configure { 34 | sourceCompatibility = JavaVersion.VERSION_17 35 | targetCompatibility = JavaVersion.VERSION_17 36 | } 37 | 38 | tasks.withType { 39 | kotlinOptions { 40 | jvmTarget = "1.8" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /project/implementation-v5/libs/MythicMobs-5.6.0.min.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TabooLib/universal-mythic/6989c2c3885a9d4ba1adcadd9bb9d61d90f3e703/project/implementation-v5/libs/MythicMobs-5.6.0.min.jar -------------------------------------------------------------------------------- /project/implementation-v5/src/main/kotlin/ink/ptms/um/impl5/Item.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl5 2 | 3 | import ink.ptms.um.Item 4 | import io.lumine.mythic.core.items.MythicItem 5 | import org.bukkit.inventory.ItemStack 6 | import taboolib.library.configuration.ConfigurationSection 7 | 8 | internal class Item(val source: MythicItem) : Item { 9 | 10 | override val internalName: String 11 | get() = source.internalName 12 | 13 | override val amount: Int 14 | get() = source.amount 15 | 16 | override val displayName: String? 17 | get() = source.displayName 18 | 19 | override val config: ConfigurationSection 20 | get() = MobConfiguration(source.config) 21 | 22 | override fun generateItemStack(amount: Int): ItemStack { 23 | return source.generateItemStack(amount).toBukkit() 24 | } 25 | } -------------------------------------------------------------------------------- /project/implementation-v5/src/main/kotlin/ink/ptms/um/impl5/Mob.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl5 2 | 3 | import ink.ptms.um.Mob 4 | import ink.ptms.um.MobType 5 | import io.lumine.mythic.api.MythicProvider 6 | import io.lumine.mythic.bukkit.MythicBukkit 7 | import io.lumine.mythic.core.mobs.ActiveMob 8 | import org.bukkit.entity.Entity 9 | import org.bukkit.entity.EntityType 10 | import org.bukkit.entity.LivingEntity 11 | import taboolib.library.configuration.ConfigurationSection 12 | 13 | /** 14 | * universal-mythic 15 | * ink.ptms.um.impl5.Mob5 16 | * 17 | * @author 坏黑 18 | * @since 2022/7/12 13:52 19 | */ 20 | internal class Mob(val source: ActiveMob) : Mob { 21 | 22 | override val id: String 23 | get() = source.type.internalName 24 | 25 | override val displayName: String 26 | get() = source.displayName 27 | 28 | override val type: MobType 29 | get() = MobType(source.type) 30 | 31 | override val entity: Entity 32 | get() = source.entity.bukkitEntity 33 | 34 | override val entityType: EntityType 35 | get() = entity.type 36 | 37 | override val level: Double 38 | get() = source.level 39 | 40 | override val stance: String 41 | get() = source.stance 42 | 43 | override val faction: String 44 | get() = source.faction 45 | 46 | override val config: ConfigurationSection 47 | get() = type.config 48 | 49 | val api by lazy { 50 | MythicProvider.get() as MythicBukkit 51 | } 52 | 53 | override fun addThreat(mob: Entity, target: LivingEntity, amount: Double) { 54 | api.apiHelper.addThreat(mob, target, amount) 55 | } 56 | 57 | override fun reduceThreat(mob: Entity, target: LivingEntity, amount: Double) { 58 | api.apiHelper.reduceThreat(mob, target, amount) 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /project/implementation-v5/src/main/kotlin/ink/ptms/um/impl5/MobConfiguration.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl5 2 | 3 | import com.electronwill.nightconfig.core.CommentedConfig 4 | import io.lumine.mythic.api.config.MythicConfig 5 | import org.bukkit.configuration.file.FileConfiguration 6 | import io.lumine.mythic.core.config.MythicConfigImpl 7 | import taboolib.library.configuration.ConfigurationSection 8 | import taboolib.library.reflex.Reflex.Companion.getProperty 9 | import taboolib.module.configuration.Type 10 | 11 | /** 12 | * universal-mythic 13 | * ink.ptms.um.impl4.MobConfiguration 14 | * 15 | * @author 坏黑 16 | * @since 2022/9/2 14:46 17 | */ 18 | internal class MobConfiguration(sourceConfig: MythicConfig) : ConfigurationSection { 19 | 20 | val config = sourceConfig as MythicConfigImpl 21 | 22 | override val primitiveConfig: Any 23 | get() = config 24 | 25 | override var name: String 26 | get() = config.key 27 | set(value) { 28 | config.key = value 29 | } 30 | 31 | override val parent: ConfigurationSection? 32 | get() = null 33 | 34 | override val type: Type 35 | get() = Type.YAML 36 | 37 | override fun addComments(path: String, comments: List) { 38 | getComments(path).toMutableList().apply { 39 | addAll(comments) 40 | setComments(path, this) 41 | } 42 | } 43 | 44 | val root: FileConfiguration = runCatching { config.fileConfiguration }.getOrElse { config.getProperty("fc")!! } 45 | 46 | override fun clear() { 47 | error("Unmodifiable") 48 | } 49 | 50 | override fun contains(path: String): Boolean { 51 | return config.isSet(path) 52 | } 53 | 54 | override fun createSection(path: String): ConfigurationSection { 55 | error("Unmodifiable") 56 | } 57 | 58 | override fun get(path: String): Any? { 59 | return root.get("$name.$path") 60 | } 61 | 62 | override fun get(path: String, def: Any?): Any? { 63 | return root.get("$name.$path", def) 64 | } 65 | 66 | override fun getBoolean(path: String): Boolean { 67 | return root.getBoolean("$name.$path") 68 | } 69 | 70 | override fun getBoolean(path: String, def: Boolean): Boolean { 71 | return root.getBoolean("$name.$path", def) 72 | } 73 | 74 | override fun getBooleanList(path: String): List { 75 | return root.getBooleanList("$name.$path") 76 | } 77 | 78 | override fun getByteList(path: String): List { 79 | return root.getByteList("$name.$path") 80 | } 81 | 82 | override fun getCharacterList(path: String): List { 83 | return root.getCharacterList("$name.$path") 84 | } 85 | 86 | override fun getComment(path: String): String? { 87 | return (root as? CommentedConfig)?.getComment(path) 88 | } 89 | 90 | override fun getComments(path: String): List { 91 | return getComment(path)?.lines() ?: emptyList() 92 | } 93 | 94 | override fun getConfigurationSection(path: String): ConfigurationSection? { 95 | return root.getConfigurationSection("$name.$path")?.let { MobConfiguration(MythicConfigImpl("$name.$path", root)) } 96 | } 97 | 98 | override fun getDouble(path: String): Double { 99 | return root.getDouble("$name.$path") 100 | } 101 | 102 | override fun getDouble(path: String, def: Double): Double { 103 | return root.getDouble("$name.$path", def) 104 | } 105 | 106 | override fun getDoubleList(path: String): List { 107 | return root.getDoubleList("$name.$path") 108 | } 109 | 110 | override fun > getEnum(path: String, type: Class): T? { 111 | error("Unsupported") 112 | } 113 | 114 | override fun > getEnumList(path: String, type: Class): List { 115 | error("Unsupported") 116 | } 117 | 118 | override fun getFloatList(path: String): List { 119 | return root.getFloatList("$name.$path") 120 | } 121 | 122 | override fun getInt(path: String): Int { 123 | return root.getInt("$name.$path") 124 | } 125 | 126 | override fun getInt(path: String, def: Int): Int { 127 | return root.getInt("$name.$path", def) 128 | } 129 | 130 | override fun getIntegerList(path: String): List { 131 | return root.getIntegerList("$name.$path") 132 | } 133 | 134 | override fun getKeys(deep: Boolean): Set { 135 | return root.getConfigurationSection(name)?.getKeys(deep) ?: emptySet() 136 | } 137 | 138 | override fun getList(path: String): List<*>? { 139 | return root.getList("$name.$path") 140 | } 141 | 142 | override fun getList(path: String, def: List<*>?): List<*>? { 143 | return root.getList("$name.$path", def) 144 | } 145 | 146 | override fun getLong(path: String): Long { 147 | return root.getLong("$name.$path") 148 | } 149 | 150 | override fun getLong(path: String, def: Long): Long { 151 | return root.getLong("$name.$path", def) 152 | } 153 | 154 | override fun getLongList(path: String): List { 155 | return root.getLongList("$name.$path") 156 | } 157 | 158 | override fun getMapList(path: String): List> { 159 | return root.getMapList("$name.$path") 160 | } 161 | 162 | override fun getShortList(path: String): List { 163 | return root.getShortList("$name.$path") 164 | } 165 | 166 | override fun getString(path: String): String? { 167 | return root.getString("$name.$path") 168 | } 169 | 170 | override fun getString(path: String, def: String?): String? { 171 | return root.getString("$name.$path", def) 172 | } 173 | 174 | override fun getStringList(path: String): List { 175 | return root.getStringList("$name.$path") 176 | } 177 | 178 | override fun getValues(deep: Boolean): Map { 179 | return root.getConfigurationSection(name)?.getValues(deep) ?: emptyMap() 180 | } 181 | 182 | override fun isBoolean(path: String): Boolean { 183 | return root.isBoolean("$name.$path") 184 | } 185 | 186 | override fun isConfigurationSection(path: String): Boolean { 187 | return root.isConfigurationSection("$name.$path") 188 | } 189 | 190 | override fun isDouble(path: String): Boolean { 191 | return root.isDouble("$name.$path") 192 | } 193 | 194 | override fun isInt(path: String): Boolean { 195 | return root.isInt("$name.$path") 196 | } 197 | 198 | override fun isList(path: String): Boolean { 199 | return root.isList("$name.$path") 200 | } 201 | 202 | override fun isLong(path: String): Boolean { 203 | return root.isLong("$name.$path") 204 | } 205 | 206 | override fun isSet(path: String): Boolean { 207 | return root.isSet("$name.$path") 208 | } 209 | 210 | override fun isString(path: String): Boolean { 211 | return root.isString("$name.$path") 212 | } 213 | 214 | override fun set(path: String, value: Any?) { 215 | root.set(path, value) 216 | } 217 | 218 | override fun setComment(path: String, comment: String?) { 219 | (root as? CommentedConfig)?.setComment(path, if (comment?.isBlank() == true) null else comment) 220 | } 221 | 222 | override fun setComments(path: String, comments: List) { 223 | return setComment(path, comments.joinToString("\n")) 224 | } 225 | 226 | override fun toMap(): Map { 227 | error("Unsupported") 228 | } 229 | } 230 | -------------------------------------------------------------------------------- /project/implementation-v5/src/main/kotlin/ink/ptms/um/impl5/MobListener.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl5 2 | 3 | import ink.ptms.um.event.MobDeathEvent 4 | import ink.ptms.um.event.MobSpawnEvent 5 | import ink.ptms.um.event.MythicReloadEvent 6 | import io.lumine.mythic.bukkit.events.MythicMobDeathEvent 7 | import io.lumine.mythic.bukkit.events.MythicMobSpawnEvent 8 | import io.lumine.mythic.bukkit.events.MythicReloadedEvent 9 | import taboolib.common.platform.Ghost 10 | import taboolib.common.platform.event.SubscribeEvent 11 | 12 | internal object MobListener { 13 | 14 | @Ghost 15 | @SubscribeEvent 16 | fun onMobDeathEvent(event: MythicMobDeathEvent) { 17 | event.drops = MobDeathEvent(Mob(event.mob), event.killer, event.drops).fire().drop 18 | } 19 | 20 | @Ghost 21 | @SubscribeEvent 22 | fun onMobSpawnEvent(event: MythicMobSpawnEvent) { 23 | val e = MobSpawnEvent(Mob(event.mob), MobType(event.mob.type), event.mobLevel).fire() 24 | event.mobLevel = e.level 25 | kotlin.runCatching { 26 | event.isCancelled = e.isCancelled 27 | }.onFailure { 28 | if (e.isCancelled) event.setCancelled() 29 | } 30 | } 31 | 32 | @Ghost 33 | @SubscribeEvent 34 | fun onMythicReloadEvent(event: MythicReloadedEvent) { 35 | MythicReloadEvent().fire() 36 | } 37 | } -------------------------------------------------------------------------------- /project/implementation-v5/src/main/kotlin/ink/ptms/um/impl5/MobListenerCondition.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl5 2 | 3 | import ink.ptms.um.event.MobConditionLoadEvent 4 | import ink.ptms.um.skill.condition.* 5 | import io.lumine.mythic.api.adapters.AbstractEntity 6 | import io.lumine.mythic.api.adapters.AbstractLocation 7 | import io.lumine.mythic.api.config.MythicLineConfig 8 | import io.lumine.mythic.api.skills.SkillCaster 9 | import io.lumine.mythic.api.skills.SkillMetadata 10 | import io.lumine.mythic.api.skills.conditions.* 11 | import io.lumine.mythic.bukkit.events.MythicConditionLoadEvent 12 | import io.lumine.mythic.core.skills.SkillCondition 13 | import taboolib.common.platform.Ghost 14 | import taboolib.common.platform.event.SubscribeEvent 15 | 16 | /** project name universal-mythic 17 | * package ink.ptms.um.impl5 18 | * time 2024/7/6 19 | * author 劫 20 | */ 21 | internal object MobListenerCondition { 22 | @Ghost 23 | @SubscribeEvent 24 | fun onMythicConditionLoad(event: MythicConditionLoadEvent) { 25 | val config = event.config 26 | val e = MobConditionLoadEvent(config.key, config.toUniversal()).fire() 27 | val registerCondition = e.skillCondition ?: return 28 | // 如果注册的条件,不在这些类型中,那么就是无效的技能类型 29 | if (!BaseCondition.isSubclass(registerCondition)) { 30 | error("Unsupported skill: $registerCondition") 31 | } 32 | when (registerCondition) { 33 | is EntityCondition -> event.register(Entity(registerCondition, config)) 34 | is CasterCondition -> event.register(Caster(registerCondition, config)) 35 | is LocationCondition -> event.register(Location(registerCondition, config)) 36 | is SkillMetadataCondition -> event.register(SkillMeta(registerCondition, config)) 37 | is EntityComparisonCondition -> event.register(EntityComparison(registerCondition, config)) 38 | is EntityLocationDistanceCondition -> event.register(EntityLocation(registerCondition, config)) 39 | is SkillMetaComparisonCondition -> event.register(SkillMetaComparison(registerCondition, config)) 40 | } 41 | 42 | } 43 | 44 | 45 | class SkillMetaComparison(val condition: SkillMetaComparisonCondition, config: MythicLineConfig) : SkillCondition(config.line), 46 | ISkillMetaComparisonCondition { 47 | override fun check(p0: SkillMetadata?, p1: AbstractEntity?): Boolean { 48 | return condition.check(p0?.toUniversal(), p1?.bukkitEntity) 49 | } 50 | } 51 | 52 | class Caster(val condition: CasterCondition, config: MythicLineConfig) : SkillCondition(config.line), ICasterCondition { 53 | override fun check(p0: SkillCaster?): Boolean { 54 | return condition.check(p0?.toUniversal()) 55 | } 56 | } 57 | 58 | class EntityComparison(val condition: EntityComparisonCondition, config: MythicLineConfig) : SkillCondition(config.line), 59 | IEntityComparisonCondition { 60 | override fun check(p0: AbstractEntity?, p1: AbstractEntity?): Boolean { 61 | return condition.check(p0?.bukkitEntity, p1?.bukkitEntity) 62 | } 63 | } 64 | 65 | class EntityLocation(val condition: EntityLocationDistanceCondition, config: MythicLineConfig) : SkillCondition(config.line), 66 | IEntityLocationComparisonCondition { 67 | override fun check(p0: AbstractEntity?, p1: AbstractLocation?): Boolean { 68 | return condition.check(p0?.bukkitEntity, p1?.toBukkit()) 69 | } 70 | } 71 | 72 | class Entity(val condition: EntityCondition, config: MythicLineConfig) : SkillCondition(config.line), IEntityCondition { 73 | override fun check(p0: AbstractEntity?): Boolean { 74 | return condition.check(p0?.bukkitEntity) 75 | } 76 | } 77 | 78 | class SkillMeta(val condition: SkillMetadataCondition, config: MythicLineConfig) : SkillCondition(config.line), ISkillMetaCondition { 79 | override fun check(p0: SkillMetadata?): Boolean { 80 | return condition.check(p0?.toUniversal()) 81 | } 82 | } 83 | 84 | class Location(val condition: LocationCondition, config: MythicLineConfig) : SkillCondition(config.line), ILocationCondition { 85 | override fun check(p0: AbstractLocation?): Boolean { 86 | return condition.check(p0?.toBukkit()) 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /project/implementation-v5/src/main/kotlin/ink/ptms/um/impl5/MobListenerDrop.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl5 2 | 3 | import ink.ptms.um.event.MobDropLoadEvent 4 | import ink.ptms.um.item.DropMeta 5 | import ink.ptms.um.skill.SkillCaster 6 | import io.lumine.mythic.api.adapters.AbstractItemStack 7 | import io.lumine.mythic.api.drops.DropMetadata 8 | import io.lumine.mythic.api.drops.IItemDrop 9 | import io.lumine.mythic.bukkit.BukkitAdapter 10 | import io.lumine.mythic.bukkit.events.MythicDropLoadEvent 11 | import io.lumine.mythic.core.drops.Drop 12 | import io.lumine.mythic.core.drops.DropMetadataImpl 13 | import org.bukkit.entity.Entity 14 | import taboolib.common.platform.Ghost 15 | import taboolib.common.platform.event.SubscribeEvent 16 | 17 | internal object MobListenerDrop { 18 | 19 | @Ghost 20 | @SubscribeEvent 21 | fun onDropLoadEvent(event: MythicDropLoadEvent) { 22 | val e = MobDropLoadEvent(event.dropName).fire() 23 | e.itemDrops.forEach { dropFunc -> 24 | event.register(object : Drop(event.dropName, event.config), IItemDrop { 25 | 26 | override fun getDrop(dropMeta: DropMetadata, amount: Double): AbstractItemStack { 27 | dropMeta as DropMetadataImpl 28 | val item = dropFunc.apply(object : DropMeta { 29 | 30 | override val dropper: SkillCaster? 31 | get() = dropMeta.caster?.toUniversal() 32 | 33 | override val cause: Entity? 34 | get() = dropMeta.trigger?.bukkitEntity 35 | 36 | override var amount: Float 37 | get() = dropMeta.amount 38 | set(value) { 39 | dropMeta.amount = value 40 | } 41 | 42 | override var generations: Int 43 | get() = dropMeta.generations 44 | set(value) { 45 | dropMeta.generations = value 46 | } 47 | 48 | override fun tick() { 49 | dropMeta.tick() 50 | } 51 | }) 52 | item.amount = (item.amount.toDouble() * amount).toInt() 53 | return BukkitAdapter.adapt(item) 54 | } 55 | }) 56 | } 57 | } 58 | } -------------------------------------------------------------------------------- /project/implementation-v5/src/main/kotlin/ink/ptms/um/impl5/MobListenerSkill.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl5 2 | 3 | import ink.ptms.um.event.MobSkillLoadEvent 4 | import ink.ptms.um.skill.type.BaseSkill 5 | import ink.ptms.um.skill.type.EntityTargetSkill 6 | import ink.ptms.um.skill.type.LocationTargetSkill 7 | import ink.ptms.um.skill.type.NoTargetSkill 8 | import io.lumine.mythic.api.adapters.AbstractEntity 9 | import io.lumine.mythic.api.adapters.AbstractLocation 10 | import io.lumine.mythic.api.config.MythicLineConfig 11 | import io.lumine.mythic.api.skills.* 12 | import io.lumine.mythic.bukkit.MythicBukkit 13 | import io.lumine.mythic.bukkit.events.MythicMechanicLoadEvent 14 | import io.lumine.mythic.core.skills.SkillExecutor 15 | import io.lumine.mythic.core.skills.SkillMechanic 16 | import taboolib.common.platform.Ghost 17 | import taboolib.common.platform.event.SubscribeEvent 18 | import taboolib.common.platform.function.warning 19 | 20 | internal object MobListenerSkill { 21 | 22 | @Ghost 23 | @SubscribeEvent 24 | fun onDropLoadEvent(event: MythicMechanicLoadEvent) { 25 | val e = MobSkillLoadEvent(event.mechanicName, event.config.toUniversal()).fire() 26 | val registerSkill = e.registerSkill ?: return 27 | // 如果注册的技能,不在这三种类型中,那么就是无效的技能类型 28 | if (registerSkill !is EntityTargetSkill && registerSkill !is LocationTargetSkill && registerSkill !is NoTargetSkill) { 29 | error("Unsupported skill: $registerSkill") 30 | } 31 | event.register(ProxySkill(registerSkill, MythicBukkit.inst().skillManager, event.mechanicName, event.config)) 32 | } 33 | 34 | class ProxySkill(val skill: BaseSkill, manager: SkillExecutor, name: String, mlc: MythicLineConfig) : SkillMechanic(manager, name, mlc), ITargetedEntitySkill, ITargetedLocationSkill, INoTargetSkill { 35 | 36 | override fun castAtEntity(metadata: SkillMetadata, entity: AbstractEntity): SkillResult { 37 | if (skill is EntityTargetSkill) { 38 | return skill.cast(metadata.toUniversal(), entity.bukkitEntity).toMythic() 39 | } 40 | warning("$skill is not ITargetedEntitySkill") 41 | return SkillResult.ERROR 42 | } 43 | 44 | override fun castAtLocation(metadata: SkillMetadata, location: AbstractLocation): SkillResult { 45 | if (skill is LocationTargetSkill) { 46 | return skill.cast(metadata.toUniversal(), location.toBukkit()).toMythic() 47 | } 48 | warning("$skill is not ITargetedLocationSkill") 49 | return SkillResult.ERROR 50 | } 51 | 52 | override fun cast(metadata: SkillMetadata): SkillResult { 53 | if (skill is NoTargetSkill) { 54 | return skill.cast(metadata.toUniversal()).toMythic() 55 | } 56 | warning("$skill is not INoTargetSkill") 57 | return SkillResult.ERROR 58 | } 59 | 60 | private fun ink.ptms.um.skill.SkillResult.toMythic(): SkillResult { 61 | return try { 62 | SkillResult.values()[ordinal] 63 | } catch (_: Throwable) { 64 | SkillResult.ERROR 65 | } 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /project/implementation-v5/src/main/kotlin/ink/ptms/um/impl5/MobType.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl5 2 | 3 | import ink.ptms.um.Mob 4 | import ink.ptms.um.MobType 5 | import io.lumine.mythic.api.mobs.MythicMob 6 | import org.bukkit.Location 7 | import taboolib.library.configuration.ConfigurationSection 8 | 9 | internal class MobType(val source: MythicMob) : MobType { 10 | 11 | override val id: String 12 | get() = source.internalName 13 | 14 | override val displayName: String 15 | get() = source.displayName.get() 16 | 17 | override val entityType: String 18 | get() = source.entityType.name 19 | 20 | override val config: ConfigurationSection 21 | get() = MobConfiguration(source.config) 22 | 23 | override fun spawn(location: Location, level: Double): Mob { 24 | return Mob(source.spawn(location.toMythic(), level)) 25 | } 26 | } -------------------------------------------------------------------------------- /project/implementation-v5/src/main/kotlin/ink/ptms/um/impl5/Mythic5.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl5 2 | 3 | import ink.ptms.um.Mythic 4 | import ink.ptms.um.Skill 5 | import io.lumine.mythic.api.MythicProvider 6 | import io.lumine.mythic.api.mobs.GenericCaster 7 | import io.lumine.mythic.api.mobs.MythicMob 8 | import io.lumine.mythic.api.skills.SkillTrigger 9 | import io.lumine.mythic.bukkit.BukkitAdapter 10 | import io.lumine.mythic.bukkit.MythicBukkit 11 | import io.lumine.mythic.core.config.MythicConfigImpl 12 | import io.lumine.mythic.core.config.MythicLineConfigImpl 13 | import io.lumine.mythic.core.drops.DropMetadataImpl 14 | import io.lumine.mythic.core.items.MythicItem 15 | import io.lumine.mythic.core.mobs.MobExecutor 16 | import io.lumine.mythic.core.utils.MythicUtil 17 | import org.bukkit.Location 18 | import org.bukkit.configuration.file.YamlConfiguration 19 | import org.bukkit.entity.Entity 20 | import org.bukkit.entity.LivingEntity 21 | import org.bukkit.entity.Player 22 | import org.bukkit.inventory.ItemStack 23 | import taboolib.common.LifeCycle 24 | import taboolib.common.platform.Awake 25 | import taboolib.common.util.orNull 26 | import taboolib.library.reflex.Reflex.Companion.getProperty 27 | import taboolib.library.reflex.Reflex.Companion.invokeMethod 28 | import java.io.File 29 | import java.util.* 30 | import kotlin.jvm.optionals.getOrNull 31 | 32 | /** 33 | * universal-mythic ink.ptms.um.impl5.Mythic5 34 | * 35 | * @author 坏黑 36 | * @since 2022/7/12 13:47 37 | */ 38 | internal class Mythic5 : Mythic { 39 | 40 | val api: MythicBukkit 41 | get() = MythicProvider.get() as MythicBukkit 42 | 43 | val mmList: MutableMap by lazy { 44 | api.mobManager.getProperty>("mmList")!! 45 | } 46 | 47 | override val isLegacy = false 48 | 49 | override fun getItem(name: String): ink.ptms.um.Item? { 50 | return Item(api.itemManager.getItem(name).orNull() ?: return null) 51 | } 52 | 53 | override fun getItemId(itemStack: ItemStack): String? { 54 | return api.itemManager.getMythicTypeFromItem(itemStack) 55 | } 56 | 57 | override fun getItemStack(name: String, player: Player?): ItemStack? { 58 | val target = player?.let { BukkitAdapter.adapt(it) } 59 | val meta = target?.let { DropMetadataImpl(GenericCaster(target), target) } 60 | return meta?.let { api.itemManager?.getItem(name)?.get()?.generateItemStack(it, 1)?.toBukkit() } 61 | ?: api.itemManager?.getItem(name)?.get()?.generateItemStack(1)?.toBukkit() 62 | } 63 | 64 | override fun getItemStack(name: String): ItemStack? { 65 | return api.itemManager?.getItem(name)?.get()?.generateItemStack(1)?.toBukkit() 66 | } 67 | 68 | override fun getItemIDList(): List { 69 | return api.itemManager.items.map { it.internalName } 70 | } 71 | 72 | override fun getItemList(): List { 73 | return api.itemManager.items.map { Item(it) } 74 | } 75 | 76 | override fun getMob(entity: Entity): ink.ptms.um.Mob? { 77 | return Mob((MythicProvider.get().mobManager as MobExecutor).getMythicMobInstance(entity) ?: return null) 78 | } 79 | 80 | override fun getMob(uuid: UUID): ink.ptms.um.Mob? { 81 | return Mob((MythicProvider.get().mobManager as MobExecutor).getActiveMob(uuid).getOrNull() ?: return null) 82 | } 83 | 84 | override fun getMobIDList(): List { 85 | return api.mobManager.mobNames.toList() 86 | } 87 | 88 | override fun getMobType(name: String): ink.ptms.um.MobType? { 89 | return MobType(api.mobManager.getMythicMob(name).orNull() ?: return null) 90 | } 91 | 92 | override fun getSkillTrigger(name: String): Skill.Trigger { 93 | val invokeMethod = Class.forName(SkillTrigger::class.java.name).invokeMethod("get", name.uppercase(), isStatic = true) ?: return getDefaultSkillTrigger() 94 | return Skill5.Trigger(invokeMethod) 95 | } 96 | 97 | override fun getDefaultSkillTrigger(): Skill.Trigger { 98 | val invokeMethod = Class.forName(SkillTrigger::class.java.name).invokeMethod("get", "DEFAULT", isStatic = true) 99 | return Skill5.Trigger(invokeMethod!!) 100 | } 101 | 102 | override fun getSkillMechanic(skillLine: String): Skill? { 103 | return Skill5(api.skillManager.getMechanic(MythicLineConfigImpl.unparseBlock(skillLine)) ?: return null) 104 | } 105 | 106 | override fun getTargetedEntity(player: Player): LivingEntity? { 107 | return MythicUtil.getTargetedEntity(player) 108 | } 109 | 110 | override fun castSkill( 111 | caster: Entity, 112 | skillName: String, 113 | trigger: Entity?, 114 | origin: Location, 115 | et: Collection, 116 | lt: Collection, 117 | power: Float, 118 | ): Boolean { 119 | return api.apiHelper.castSkill(caster, skillName, trigger, origin, et, lt, power) 120 | } 121 | 122 | override fun registerItem(file: File, node: String): Boolean { 123 | return api.itemManager.registerItem( 124 | node, 125 | MythicItem(null, file, node, MythicConfigImpl(node, file, YamlConfiguration.loadConfiguration(file))) 126 | ) 127 | } 128 | 129 | override fun unregisterItem(node: String): Boolean { 130 | return api.itemManager.getProperty>("items")!!.let { 131 | if (it.containsKey(node)) { 132 | it.remove(node) 133 | true 134 | } else false 135 | } 136 | } 137 | 138 | override fun registerMob(file: File, node: String): Boolean { 139 | return if (!mmList.containsKey(node)) { 140 | mmList[node] = io.lumine.mythic.core.mobs.MobType( 141 | MythicBukkit.inst().mobManager, 142 | null, 143 | file, 144 | node, 145 | MythicConfigImpl(node, file, YamlConfiguration.loadConfiguration(file)) 146 | ) 147 | true 148 | } else false 149 | } 150 | 151 | override fun unregisterMob(node: String): Boolean { 152 | return if (mmList.containsKey(node)) { 153 | mmList.remove(node) 154 | true 155 | } else false 156 | } 157 | 158 | object Loader { 159 | 160 | @Awake(LifeCycle.ENABLE) 161 | fun setup() { 162 | if (runCatching { Class.forName("io.lumine.mythic.api.MythicProvider") }.getOrNull() != null) { 163 | Mythic.API = Mythic5() 164 | } 165 | } 166 | } 167 | } 168 | -------------------------------------------------------------------------------- /project/implementation-v5/src/main/kotlin/ink/ptms/um/impl5/Skill5.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl5 2 | 3 | import ink.ptms.um.Skill 4 | import io.lumine.mythic.api.adapters.AbstractEntity 5 | import io.lumine.mythic.api.mobs.GenericCaster 6 | import io.lumine.mythic.api.skills.SkillTrigger 7 | import io.lumine.mythic.api.skills.placeholders.PlaceholderInt 8 | import io.lumine.mythic.bukkit.BukkitAdapter 9 | import io.lumine.mythic.bukkit.adapters.BukkitPlayer 10 | import io.lumine.mythic.core.skills.SkillMechanic 11 | import io.lumine.mythic.core.skills.SkillMetadataImpl 12 | import io.lumine.mythic.core.skills.mechanics.DelaySkill 13 | import org.bukkit.Location 14 | import org.bukkit.entity.Entity 15 | import org.bukkit.entity.Player 16 | import taboolib.library.reflex.Reflex.Companion.getProperty 17 | 18 | internal class Skill5(obj: Any) : Skill { 19 | 20 | val source = obj as SkillMechanic 21 | 22 | val placeholderDelay = (source as? DelaySkill)?.getProperty("ticks") 23 | 24 | override val delay: Int 25 | get() = placeholderDelay?.get() ?: -1 26 | 27 | override fun execute( 28 | trigger: Skill.Trigger, 29 | entity: Entity, 30 | target: Entity, 31 | et: Set, 32 | lt: Set, 33 | power: Float, 34 | parameters: Map, 35 | targetFilter: (Entity) -> Boolean 36 | ): Boolean { 37 | val caster = if (entity is Player) BukkitPlayer(entity) else BukkitAdapter.adapt(entity) 38 | return source.execute( 39 | SkillMetadataImpl( 40 | (trigger as Trigger).source, 41 | CasterImpl(caster, parameters), 42 | BukkitAdapter.adapt(target), 43 | BukkitAdapter.adapt(entity.location), 44 | et.map { BukkitAdapter.adapt(it) }.toHashSet(), 45 | lt.map { BukkitAdapter.adapt(it) }.toHashSet(), 46 | power 47 | ) 48 | ) 49 | } 50 | 51 | /** 获取技能是否正在冷却 */ 52 | override fun onCooldown(caster: Entity): Boolean { 53 | return source.onCooldown(CasterImpl(BukkitAdapter.adapt(caster), emptyMap())) 54 | } 55 | 56 | /** 获取技能冷却 */ 57 | override fun getCooldown(caster: Entity): Float { 58 | return source.getCooldown(CasterImpl(BukkitAdapter.adapt(caster), emptyMap())) 59 | } 60 | 61 | /** 设置技能冷却 */ 62 | override fun setCooldown(caster: Entity, time: Double) { 63 | return source.setCooldown(CasterImpl(BukkitAdapter.adapt(caster), emptyMap()), time) 64 | } 65 | 66 | class Trigger(obj: Any) : Skill.Trigger { 67 | 68 | val source = obj as SkillTrigger<*> 69 | 70 | override val name: String = source.getProperty("name")!! 71 | } 72 | 73 | class CasterImpl(entity: AbstractEntity?, override val parameters: Map) : GenericCaster(entity), Skill.ActiveCaster 74 | } 75 | -------------------------------------------------------------------------------- /project/implementation-v5/src/main/kotlin/ink/ptms/um/impl5/Utils.kt: -------------------------------------------------------------------------------- 1 | package ink.ptms.um.impl5 2 | 3 | import ink.ptms.um.Skill 4 | import ink.ptms.um.skill.SkillConfig 5 | import ink.ptms.um.skill.SkillMeta 6 | import io.lumine.mythic.api.adapters.AbstractEntity 7 | import io.lumine.mythic.api.adapters.AbstractItemStack 8 | import io.lumine.mythic.api.adapters.AbstractLocation 9 | import io.lumine.mythic.api.config.MythicLineConfig 10 | import io.lumine.mythic.api.skills.SkillCaster 11 | import io.lumine.mythic.api.skills.SkillMetadata 12 | import io.lumine.mythic.api.skills.placeholders.PlaceholderDouble 13 | import io.lumine.mythic.api.skills.placeholders.PlaceholderFloat 14 | import io.lumine.mythic.api.skills.placeholders.PlaceholderInt 15 | import io.lumine.mythic.api.skills.placeholders.PlaceholderString 16 | import io.lumine.mythic.bukkit.BukkitAdapter 17 | import io.lumine.mythic.core.config.MythicLineConfigImpl 18 | import io.lumine.mythic.core.skills.SkillMetadataImpl 19 | import org.bukkit.Location 20 | import org.bukkit.entity.Entity 21 | import org.bukkit.inventory.ItemStack 22 | import taboolib.library.reflex.Reflex.Companion.getProperty 23 | import java.awt.Color 24 | import java.util.HashMap 25 | 26 | internal fun AbstractItemStack.toBukkit(): ItemStack { 27 | return BukkitAdapter.adapt(this) 28 | } 29 | 30 | internal fun AbstractLocation.toBukkit(): Location { 31 | return BukkitAdapter.adapt(this) 32 | } 33 | 34 | internal fun Location.toMythic(): AbstractLocation { 35 | return BukkitAdapter.adapt(this) 36 | } 37 | 38 | internal fun Entity.toMythic(): AbstractEntity { 39 | return BukkitAdapter.adapt(this) 40 | } 41 | 42 | internal fun SkillCaster.toUniversal(): ink.ptms.um.skill.SkillCaster { 43 | return object : ink.ptms.um.skill.SkillCaster { 44 | 45 | override val entity: Entity 46 | get() = this@toUniversal.entity.bukkitEntity 47 | 48 | override val location: Location 49 | get() = this@toUniversal.location.toBukkit() 50 | 51 | override val level: Double 52 | get() = this@toUniversal.level 53 | 54 | override val power: Float 55 | get() = this@toUniversal.power 56 | 57 | override var globalCooldown: Int 58 | get() = this@toUniversal.globalCooldown 59 | set(value) { 60 | this@toUniversal.globalCooldown = value 61 | } 62 | } 63 | } 64 | 65 | internal fun ink.ptms.um.skill.SkillCaster.toMythic(): SkillCaster { 66 | return (this as SkillCasterProxy5).origin 67 | } 68 | 69 | internal class SkillCasterProxy5(val origin: SkillCaster) : ink.ptms.um.skill.SkillCaster { 70 | 71 | override val entity: Entity 72 | get() = origin.entity.bukkitEntity 73 | 74 | override val location: Location 75 | get() = origin.location.toBukkit() 76 | 77 | override val level: Double 78 | get() = origin.level 79 | 80 | override val power: Float 81 | get() = origin.power 82 | 83 | override var globalCooldown: Int 84 | get() = origin.globalCooldown 85 | set(value) { 86 | origin.globalCooldown = value 87 | } 88 | } 89 | 90 | internal fun PlaceholderString.toUniversal(): ink.ptms.um.skill.data.PlaceholderString { 91 | return object : ink.ptms.um.skill.data.PlaceholderString { 92 | 93 | override fun get(): String { 94 | return this@toUniversal.get() 95 | } 96 | 97 | override fun get(entity: Entity): String { 98 | return this@toUniversal.get(entity.toMythic()) 99 | } 100 | 101 | override fun get(caster: ink.ptms.um.skill.SkillCaster): String { 102 | return this@toUniversal.get(caster.toMythic()) 103 | } 104 | } 105 | } 106 | 107 | internal fun PlaceholderInt.toUniversal(): ink.ptms.um.skill.data.PlaceholderInt { 108 | return object : ink.ptms.um.skill.data.PlaceholderInt { 109 | 110 | override fun get(): Int { 111 | return this@toUniversal.get() 112 | } 113 | 114 | override fun get(entity: Entity): Int { 115 | return this@toUniversal.get(entity.toMythic()) 116 | } 117 | 118 | override fun get(caster: ink.ptms.um.skill.SkillCaster): Int { 119 | return this@toUniversal.get(caster.toMythic()) 120 | } 121 | } 122 | } 123 | 124 | internal fun PlaceholderDouble.toUniversal(): ink.ptms.um.skill.data.PlaceholderDouble { 125 | return object : ink.ptms.um.skill.data.PlaceholderDouble { 126 | 127 | override fun get(): Double { 128 | return this@toUniversal.get() 129 | } 130 | 131 | override fun get(entity: Entity): Double { 132 | return this@toUniversal.get(entity.toMythic()) 133 | } 134 | 135 | override fun get(caster: ink.ptms.um.skill.SkillCaster): Double { 136 | return this@toUniversal.get(caster.toMythic()) 137 | } 138 | } 139 | } 140 | 141 | internal fun PlaceholderFloat.toUniversal(): ink.ptms.um.skill.data.PlaceholderFloat { 142 | return object : ink.ptms.um.skill.data.PlaceholderFloat { 143 | 144 | override fun get(): Float { 145 | return this@toUniversal.get() 146 | } 147 | 148 | override fun get(entity: Entity): Float { 149 | return this@toUniversal.get(entity.toMythic()) 150 | } 151 | 152 | override fun get(caster: ink.ptms.um.skill.SkillCaster): Float { 153 | return this@toUniversal.get(caster.toMythic()) 154 | } 155 | } 156 | } 157 | 158 | internal fun MythicLineConfig.toUniversal(): SkillConfig { 159 | this as MythicLineConfigImpl 160 | return object : SkillConfig { 161 | 162 | override fun line(): String { 163 | return this@toUniversal.line 164 | } 165 | 166 | override fun size(): Int { 167 | return this@toUniversal.size() 168 | } 169 | 170 | override fun entrySet(): Set> { 171 | return this@toUniversal.entrySet() 172 | } 173 | 174 | override fun getKey(): String { 175 | return this@toUniversal.key 176 | } 177 | 178 | override fun getKey(s: String): String { 179 | return this@toUniversal.key 180 | } 181 | 182 | override fun getBoolean(key: Array, def: Boolean): Boolean { 183 | return this@toUniversal.getBoolean(key, def) 184 | } 185 | 186 | override fun getString(key: Array, def: String): String { 187 | return this@toUniversal.getString(key, def) 188 | } 189 | 190 | override fun getPlaceholderString(key: Array, def: String, vararg args: String): ink.ptms.um.skill.data.PlaceholderString { 191 | return this@toUniversal.getPlaceholderString(key, def, *args).toUniversal() 192 | } 193 | 194 | override fun getInt(key: Array, def: Int): Int { 195 | return this@toUniversal.getInteger(key, def) 196 | } 197 | 198 | override fun getPlaceholderInt(key: Array, def: Int, vararg args: String): ink.ptms.um.skill.data.PlaceholderInt { 199 | return this@toUniversal.getPlaceholderInteger(key, def, *args).toUniversal() 200 | } 201 | 202 | override fun getDouble(key: Array, def: Double): Double { 203 | return this@toUniversal.getDouble(key, def) 204 | } 205 | 206 | override fun getPlaceholderDouble(key: Array, def: Double, vararg args: String): ink.ptms.um.skill.data.PlaceholderDouble { 207 | return this@toUniversal.getPlaceholderDouble(key, def, *args).toUniversal() 208 | } 209 | 210 | override fun getFloat(key: Array, def: Float): Float { 211 | return this@toUniversal.getFloat(key, def) 212 | } 213 | 214 | override fun getPlaceholderFloat(key: Array, def: Float, vararg args: String): ink.ptms.um.skill.data.PlaceholderFloat { 215 | return this@toUniversal.getPlaceholderFloat(key, def, *args).toUniversal() 216 | } 217 | 218 | override fun getLong(key: Array, def: Long): Long { 219 | return this@toUniversal.getLong(key, def) 220 | } 221 | 222 | override fun getColor(key: String, def: String): Color { 223 | return this@toUniversal.getColor(key, def) 224 | } 225 | 226 | override fun getColor(key: Array, def: String): Color { 227 | return this@toUniversal.getColor(key, def) 228 | } 229 | } 230 | } 231 | 232 | internal fun SkillMetadata.toUniversal(): SkillMeta { 233 | this as SkillMetadataImpl 234 | return object : SkillMeta { 235 | 236 | val metadataMap = this@toUniversal.getProperty>("metadata")!! 237 | val parameterMap = this@toUniversal.getProperty>("parameters")!! 238 | 239 | override var caster: ink.ptms.um.skill.SkillCaster 240 | get() = this@toUniversal.caster.toUniversal() 241 | set(value) { 242 | this@toUniversal.caster = value.toMythic() 243 | } 244 | 245 | override var trigger: Entity 246 | get() = this@toUniversal.trigger.bukkitEntity 247 | set(value) { 248 | this@toUniversal.trigger = value.toMythic() 249 | } 250 | 251 | override var origin: Location 252 | get() = this@toUniversal.origin.toBukkit() 253 | set(value) { 254 | this@toUniversal.origin = value.toMythic() 255 | } 256 | 257 | override val cause: Skill.Trigger 258 | get() = Skill5.Trigger(this@toUniversal.cause) 259 | 260 | override var power: Float 261 | get() = this@toUniversal.power 262 | set(value) { 263 | this@toUniversal.power = value 264 | } 265 | 266 | override var isAsync: Boolean 267 | get() = this@toUniversal.isAsync() 268 | set(value) { 269 | this@toUniversal.setIsAsync(value) 270 | } 271 | 272 | override var entityTargets: Set 273 | get() = this@toUniversal.entityTargets.map { it.bukkitEntity }.toSet() 274 | set(value) { 275 | this@toUniversal.setEntityTargets(value.map { it.toMythic() }.toHashSet()) 276 | } 277 | 278 | override var locationTargets: Set 279 | get() = this@toUniversal.locationTargets.map { it.toBukkit() }.toSet() 280 | set(value) { 281 | this@toUniversal.setLocationTargets(value.map { it.toMythic() }.toHashSet()) 282 | } 283 | 284 | override val metadata: Map 285 | get() = metadataMap 286 | 287 | override val parameters: Map 288 | get() = parameterMap 289 | 290 | override fun setMetadata(key: String, value: Any) { 291 | metadataMap[key] = value 292 | } 293 | 294 | override fun setParameter(key: String, value: String) { 295 | parameterMap[key] = value 296 | } 297 | 298 | override fun clone(): SkillMeta { 299 | return this@toUniversal.clone().toUniversal() 300 | } 301 | 302 | override fun deepClone(): SkillMeta { 303 | return this@toUniversal.deepClone().toUniversal() 304 | } 305 | } 306 | } -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "universal-mythic" 2 | 3 | include("plugin") 4 | include("project:common") 5 | include("project:implementation-v4") 6 | include("project:implementation-v5") --------------------------------------------------------------------------------