diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..9181bca --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,55 @@ +plugins { + java + id("io.izzel.taboolib") version "1.31" + id("org.jetbrains.kotlin.jvm") version "1.5.31" +} + +taboolib { + install("common") + install("common-5") + install("platform-bukkit") + install("module-lang") + install("module-ui") + install("module-chat") + install("module-configuration") + install("module-metrics") + install("module-database") + install("expansion-player-database") + classifier = null + version = "6.0.3-23" + description { + contributors { + name("Leosouthey") + } + dependencies { + name("PlaceholderAPI").optional(true) + } + } + +} + +repositories { + mavenCentral() +} + +dependencies { + implementation("ink.ptms.core:v11701:11701:mapped") + implementation("ink.ptms.core:v11701:11701:universal") + compileOnly("com.alibaba:fastjson:1.2.76") + compileOnly("org.jetbrains.kotlin:kotlin-stdlib:1.5.31") + compileOnly(fileTree("libs")) +} + +tasks.withType { + options.encoding = "UTF-8" +} + +tasks.withType { +// destinationDir = file("F:/Server/spigot 1.17/plugins") +// destinationDir = file("E:/FaithL/Server/Test1.12.2/plugins") +} + +configure { + sourceCompatibility = JavaVersion.VERSION_1_8 + targetCompatibility = JavaVersion.VERSION_1_8 +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..0d0b012 --- /dev/null +++ b/gradle.properties @@ -0,0 +1,2 @@ +group= com.faithl.bukkit.faithllevel +version= 1.0.2 \ No newline at end of file diff --git a/gradlew b/gradlew new file mode 100644 index 0000000..744e882 --- /dev/null +++ b/gradlew @@ -0,0 +1,185 @@ +#!/usr/bin/env sh + +# +# Copyright 2015 the original author or authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MSYS* | MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin or MSYS, switch paths to Windows format before running java +if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=`expr $i + 1` + done + case $i in + 0) set -- ;; + 1) set -- "$args0" ;; + 2) set -- "$args0" "$args1" ;; + 3) set -- "$args0" "$args1" "$args2" ;; + 4) set -- "$args0" "$args1" "$args2" "$args3" ;; + 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=`save "$@"` + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 0000000..107acd3 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,89 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/libs/MythicMobs-4.13.1.jar b/libs/MythicMobs-4.13.1.jar new file mode 100644 index 0000000..2ef1ea0 Binary files /dev/null and b/libs/MythicMobs-4.13.1.jar differ diff --git a/settings.gradle.kts b/settings.gradle.kts new file mode 100644 index 0000000..2f1bd90 --- /dev/null +++ b/settings.gradle.kts @@ -0,0 +1,2 @@ +rootProject.name = "FaithlLevel" + diff --git a/src/main/kotlin/com/faithl/bukkit/faithllevel/FaithlLevel.kt b/src/main/kotlin/com/faithl/bukkit/faithllevel/FaithlLevel.kt new file mode 100644 index 0000000..3c81e60 --- /dev/null +++ b/src/main/kotlin/com/faithl/bukkit/faithllevel/FaithlLevel.kt @@ -0,0 +1,92 @@ +package com.faithl.bukkit.faithllevel + +import com.alibaba.fastjson.JSONObject +import com.faithl.bukkit.faithllevel.util.JsonUtil +import org.bukkit.entity.Player +import taboolib.common.env.RuntimeDependency +import taboolib.common.io.newFile +import taboolib.common.platform.Plugin +import taboolib.common.platform.function.* +import taboolib.common.util.Version +import taboolib.expansion.releaseDataContainer +import taboolib.expansion.setupDataContainer +import taboolib.expansion.setupPlayerDatabase +import taboolib.module.configuration.Config +import taboolib.module.configuration.SecuredFile +import taboolib.module.lang.sendLang +import taboolib.module.metrics.Metrics +import taboolib.platform.BukkitPlugin +import taboolib.platform.util.sendLang + + +@RuntimeDependency(value = "com.alibaba:fastjson:1.2.76") +object FaithlLevel:Plugin() { + + @Config("settings.yml", migrate = true,autoReload = true) + lateinit var setting: SecuredFile + + @Config("levels.yml", migrate = false,autoReload = true) + lateinit var conf: SecuredFile + + @Config("commands.yml", migrate = false,autoReload = true) + lateinit var command: SecuredFile + + val plugin by lazy { BukkitPlugin.getInstance() } + var isOutDate = false + + override fun onLoad() { + Metrics(13122, pluginVersion, runningPlatform) + } + + override fun onEnable() { + init() + checkUpdate() + console().sendLang("Plugin-Enabled", pluginVersion,KotlinVersion.CURRENT.toString()) + for (player in onlinePlayers()) + player.setupDataContainer() + } + + override fun onDisable() { + for (player in onlinePlayers()) + player.releaseDataContainer() + } + + fun init(){ + val type = setting.getString("Options.Database.Type")!! + val host = setting.getString("Options.Database.Host")!! + val database = setting.getString("Options.Database.Database")!! + val user = setting.getString("Options.Database.User")!! + val password = setting.getString("Options.Database.Password")!! + val port = setting.getInt("Options.Database.Port") + val table = "${pluginId.lowercase()}_data" + if (type.contains("MySQL",true)) { + setupPlayerDatabase(host,port,user, password, database,table) + console().sendLang("Plugin-Database-Enabled", "MySQL") + } else { + setupPlayerDatabase(newFile(getDataFolder(), "smeltdata.db")) + console().sendLang("Plugin-Database-Enabled", "SQLite") + } + if (onlinePlayers().isNotEmpty()){ + for (player in onlinePlayers()){ + player.setupDataContainer() + } + } +// ExpDataManager.autoSave() + } + + fun checkUpdate(sender: Player? = null){ + if(!setting.getBoolean("Options.Check-Update")) + return + val json = JsonUtil.loadJson("https://api.faithl.com/version.php?plugin=FaithlLevel") + val `object` = JSONObject.parseObject(json) + val version = Version(`object`.getString("version")) + if (version > Version(pluginVersion)){ + isOutDate = true + if (sender == null) + console().sendLang("Plugin-Update",pluginVersion,version) + else + sender.sendLang("Plugin-Update",pluginVersion,version.source,"https://www.mcbbs.net/forum.php?mod=viewthread&tid=1273118") + } + } + +} \ No newline at end of file diff --git a/src/main/kotlin/com/faithl/bukkit/faithllevel/api/FaithlLevelAPI.kt b/src/main/kotlin/com/faithl/bukkit/faithllevel/api/FaithlLevelAPI.kt new file mode 100644 index 0000000..3c8fcd5 --- /dev/null +++ b/src/main/kotlin/com/faithl/bukkit/faithllevel/api/FaithlLevelAPI.kt @@ -0,0 +1,23 @@ +package com.faithl.bukkit.faithllevel.api + +import com.faithl.bukkit.faithllevel.internal.level.data.ExpDataManager +import com.faithl.bukkit.faithllevel.internal.level.LevelData +import com.faithl.bukkit.faithllevel.internal.level.LevelDataManager +import org.bukkit.entity.Player +import taboolib.common.platform.Awake + +@Awake +object FaithlLevelAPI { + fun getPlayerData(player: Player,levelData:LevelData): ExpDataManager { + System.gc() + return ExpDataManager(player, levelData) + } + + fun getLevelData(key:String): LevelData? { + return LevelDataManager.getLevelData(key) + } + + fun getLevelDataMap(): MutableMap { + return LevelDataManager.levelMap + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/faithl/bukkit/faithllevel/api/event/ChangeType.kt b/src/main/kotlin/com/faithl/bukkit/faithllevel/api/event/ChangeType.kt new file mode 100644 index 0000000..ba18cc3 --- /dev/null +++ b/src/main/kotlin/com/faithl/bukkit/faithllevel/api/event/ChangeType.kt @@ -0,0 +1,6 @@ +package com.faithl.bukkit.faithllevel.api.event + +enum class ChangeType { + ADD, + TAKE +} \ No newline at end of file diff --git a/src/main/kotlin/com/faithl/bukkit/faithllevel/api/event/ExpChangeEvent.kt b/src/main/kotlin/com/faithl/bukkit/faithllevel/api/event/ExpChangeEvent.kt new file mode 100644 index 0000000..21c3387 --- /dev/null +++ b/src/main/kotlin/com/faithl/bukkit/faithllevel/api/event/ExpChangeEvent.kt @@ -0,0 +1,12 @@ +package com.faithl.bukkit.faithllevel.api.event + +import com.faithl.bukkit.faithllevel.internal.level.LevelData +import com.faithl.bukkit.faithllevel.internal.level.data.ExpDataManager +import org.bukkit.entity.Player +import taboolib.platform.type.BukkitProxyEvent + + +class ExpChangeEvent(val player: Player, val expDataManager:ExpDataManager, val levelData: LevelData, val amount:Int, val type:ChangeType): BukkitProxyEvent() { + override val allowCancelled: Boolean + get() = false +} \ No newline at end of file diff --git a/src/main/kotlin/com/faithl/bukkit/faithllevel/api/event/LevelUpEvent.kt b/src/main/kotlin/com/faithl/bukkit/faithllevel/api/event/LevelUpEvent.kt new file mode 100644 index 0000000..f51ac98 --- /dev/null +++ b/src/main/kotlin/com/faithl/bukkit/faithllevel/api/event/LevelUpEvent.kt @@ -0,0 +1,11 @@ +package com.faithl.bukkit.faithllevel.api.event + +import com.faithl.bukkit.faithllevel.internal.level.LevelData +import com.faithl.bukkit.faithllevel.internal.level.data.ExpDataManager +import org.bukkit.entity.Player +import taboolib.platform.type.BukkitProxyEvent + +class LevelUpEvent(val player:Player, val expDataManager: ExpDataManager, val levelData: LevelData): BukkitProxyEvent() { + override val allowCancelled: Boolean + get() = false +} \ No newline at end of file diff --git a/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/command/CommandHandler.kt b/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/command/CommandHandler.kt new file mode 100644 index 0000000..1ad6c86 --- /dev/null +++ b/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/command/CommandHandler.kt @@ -0,0 +1,249 @@ +package com.faithl.bukkit.faithllevel.internal.command + +import com.faithl.bukkit.faithllevel.FaithlLevel +import com.faithl.bukkit.faithllevel.api.FaithlLevelAPI +import com.faithl.bukkit.faithllevel.internal.level.LevelDataManager +import com.faithl.bukkit.faithllevel.internal.level.data.ExpDataManager +import org.bukkit.Bukkit +import org.bukkit.Bukkit.getPlayerExact +import org.bukkit.command.CommandSender +import org.bukkit.entity.Player +import taboolib.common.platform.ProxyCommandSender +import taboolib.common.platform.command.CommandBody +import taboolib.common.platform.command.CommandHeader +import taboolib.common.platform.command.mainCommand +import taboolib.common.platform.command.subCommand +import taboolib.common.platform.function.adaptCommandSender +import taboolib.common.platform.function.onlinePlayers +import taboolib.common.platform.function.pluginVersion +import taboolib.common5.Coerce +import taboolib.module.chat.TellrawJson +import taboolib.module.lang.Language +import taboolib.module.lang.sendLang +import taboolib.platform.util.asLangText +import taboolib.platform.util.sendLang + + +@CommandHeader(name = "faithllevel", aliases = ["fl","flevel"], permission = "FaithlLevel.access") +object CommandHandler { + @CommandBody + val status = subCommand { + execute{ sender, _, _ -> + for (levelSystem in FaithlLevelAPI.getLevelDataMap().values){ + val playerData: ExpDataManager = FaithlLevelAPI.getPlayerData(sender,levelSystem) + sender.sendLang("Command-Status-Info",levelSystem.name,sender.name,playerData.getDisplay(),playerData.exp,playerData.getMaxExp()) + } + } + dynamic { + suggestion { _, _ -> + onlinePlayers().map { it.name} + } + execute{ sender, _, argument -> + val target = getPlayerExact(argument) ?: return@execute + for (levelSystem in FaithlLevelAPI.getLevelDataMap().values){ + val playerData: ExpDataManager = FaithlLevelAPI.getPlayerData(target,levelSystem) + sender.sendLang("Command-Status-Info",levelSystem.name,target.name,playerData.getDisplay(),playerData.exp,playerData.getMaxExp()) + } + } + } + } + + @CommandBody + val take = subCommand { + execute{ sender,_,_ -> + sender.sendLang("Command-Take-Error") + } + dynamic { + suggestion { _, _ -> + FaithlLevelAPI.getLevelDataMap().map {it.key} + } + dynamic { + suggestion(uncheck = true) { _ , _ -> + onlinePlayers().map { it.name } + } + execute{ sender, context, argument -> + val value = Coerce.toInteger(argument) + val playerData: ExpDataManager = FaithlLevelAPI.getPlayerData(sender,FaithlLevelAPI.getLevelData(context.argument(-1))?:return@execute) + playerData.takeExp(value) + } + dynamic { + restrict { _, _, argument -> + Coerce.asInteger(argument).isPresent + } + execute{ sender, context, argument -> + if (Coerce.asInteger(argument)==null){ + sender.sendLang("Command-Take-Error") + return@execute + } + val target = Bukkit.getPlayerExact(context.argument(-1)) ?: return@execute + val value = Coerce.toInteger(argument) + val playerData: ExpDataManager = FaithlLevelAPI.getPlayerData(target, + FaithlLevelAPI.getLevelData(context.argument(-2))!! + ) + playerData.takeExp(value) + sender.sendLang("Command-Take-Info",playerData.levelData.name,target.name,value,playerData.exp,playerData.getMaxExp()) + } + } + } + } + } + + @CommandBody + val set = subCommand { + execute{ sender,_,_ -> + sender.sendLang("Command-Set-Error") + } + dynamic { + suggestion { _, _ -> + FaithlLevelAPI.getLevelDataMap().map {it.key} + } + dynamic { + suggestion(uncheck = true) { _ , _ -> + onlinePlayers().map { it.name } + } + execute{ sender, context, argument -> + val value = Coerce.toInteger(argument) + val playerData: ExpDataManager = FaithlLevelAPI.getPlayerData(sender,FaithlLevelAPI.getLevelData(context.argument(-1))?:return@execute) + playerData.level = value + playerData.exp = 0 + playerData.updateOriginExp() + sender.sendLang("Command-Set-Info",playerData.levelData.name,sender.name,value) + } + dynamic { + restrict { _, _, argument -> + Coerce.asInteger(argument).isPresent + } + execute{ sender, context, argument -> + if (Coerce.asInteger(argument)==null){ + sender.sendLang("Command-Set-Error") + return@execute + } + val target = Bukkit.getPlayerExact(context.argument(-1)) ?: return@execute + val value = Coerce.toInteger(argument) + val playerData: ExpDataManager = FaithlLevelAPI.getPlayerData(target,FaithlLevelAPI.getLevelData(context.argument(-2))?:return@execute) + playerData.level = value + playerData.exp = 0 + sender.sendLang("Command-Set-Info",playerData.levelData.name,target.name,value) + playerData.updateOriginExp() + } + } + } + } + } + + @CommandBody + val add = subCommand { + execute{ sender,_,_ -> + sender.sendLang("Command-Add-Error") + } + //level + dynamic { + suggestion { _, _ -> + FaithlLevelAPI.getLevelDataMap().map {it.key} + } + //player || value + dynamic { + suggestion(uncheck = true) { _, _ -> + onlinePlayers().map { it.name } + } + execute { sender, context, argument -> + val value = Coerce.toInteger(argument) + val playerData: ExpDataManager = FaithlLevelAPI.getPlayerData(sender, + FaithlLevelAPI.getLevelData(context.argument(-1))?:return@execute + ) + playerData.addExp(value) + } + //value + dynamic { + restrict { _, _, argument -> + Coerce.asInteger(argument).isPresent + } + execute { sender, context, argument -> + if (Coerce.asInteger(argument) == null) { + sender.sendLang("Command-Add-Error") + return@execute + } + val target = Bukkit.getPlayerExact(context.argument(-1)) ?: return@execute + val value = Coerce.toInteger(argument) + val playerData: ExpDataManager = FaithlLevelAPI.getPlayerData(target,FaithlLevelAPI.getLevelData(context.argument(-2))?:return@execute) + playerData.addExp(value) + sender.sendLang("Command-Add-Info",playerData.levelData.name, target.name, value, playerData.exp, playerData.getMaxExp()) + } + } + } + } + } + + @CommandBody + val reload = subCommand { + execute { sender, _, _ -> + FaithlLevel.setting.reload() + FaithlLevel.conf.reload() + FaithlLevel.command.reload() + FaithlLevelAPI.getLevelDataMap().clear() + FaithlLevel.init() + LevelDataManager.init() + Language.reload() + sender.sendLang("Plugin-Reloaded", pluginVersion,KotlinVersion.CURRENT.toString()) + } + } + + @CommandBody + val main = mainCommand{ + execute { sender, _, argument -> + if (argument.isEmpty()) { + generateMainHelper(sender) + return@execute + } + incorrectCommand { _, _, _, _ -> + sender.sendMessage("§8[§3FaithlLevel§8] §8[§cERROR§8] Args §6$argument §3not found.") + TellrawJson() + .append("§8[§3FaithlLevel§8] §8[§bINFO§8] Type ").append("§f/FaithlLevel help") + .hoverText("§f/FaithlLevel help §8- §7more help...") + .suggestCommand("/FaithlLevel help") + .append("§3 for help.") + .sendTo(adaptCommandSender(sender)) + } + } + } + + @CommandBody + val help = subCommand{ + execute { sender, _, _ -> + generateMainHelper(sender) + } + } + + private fun generateMainHelper(sender: CommandSender){ + val proxySender = adaptCommandSender(sender) + proxySender.sendMessage("") + TellrawJson() + .append(" ").append("§3FaithlLevel") + .hoverText("§7FaithlLevel is modern and advanced Minecraft level-plugin") + .append(" ").append("§f${FaithlLevel.plugin.description.version}") + .hoverText(""" + §7Plugin version: §2${FaithlLevel.plugin.description.version} + """.trimIndent()).sendTo(proxySender) + proxySender.sendMessage("") + TellrawJson() + .append(" §7${sender.asLangText("Command-Help-Type")}: ").append("§f/FaithlLevel §8[...]") + .hoverText("§f/FaithlLevel §8[...]") + .suggestCommand("/FaithlLevel ") + .sendTo(proxySender) + proxySender.sendMessage(" §7${sender.asLangText("Command-Help-Args")}:") + fun displayArg(name: String, desc: String) { + TellrawJson() + .append(" §8- ").append("§f$name") + .hoverText("§f/FaithlLevel $name §8- §7$desc") + .suggestCommand("/FaithlLevel $name ") + .sendTo(proxySender) + proxySender.sendMessage(" §7$desc") + } + displayArg("add", sender.asLangText("Command-Add-Description")) + displayArg("set", sender.asLangText("Command-Set-Description")) + displayArg("take", sender.asLangText("Command-Take-Description")) + displayArg("status", sender.asLangText("Command-Status-Description")) + displayArg("reload", sender.asLangText("Command-Reload-Description")) + proxySender.sendMessage("") + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/conf/CommandLoader.kt b/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/conf/CommandLoader.kt new file mode 100644 index 0000000..423d199 --- /dev/null +++ b/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/conf/CommandLoader.kt @@ -0,0 +1,31 @@ +package com.faithl.bukkit.faithllevel.internal.conf + +import com.faithl.bukkit.faithllevel.FaithlLevel +import com.faithl.bukkit.faithllevel.internal.level.LevelData + +object CommandLoader { + fun getCommand(value:Int,event:String,levelData: LevelData):MutableList{ + val result:MutableList = mutableListOf() + if (FaithlLevel.command.getConfigurationSection(levelData.key)==null) + return mutableListOf("null") + val keys = FaithlLevel.command.getConfigurationSection(levelData.key).getKeys(false) ?: return mutableListOf("null") + for (key in keys){ + if (key.contains("Every-Level")){ + result += FaithlLevel.command.getStringList("${levelData.key}.${key}.${event}") ?: mutableListOf("null") + continue + } + if (key.contains("-")){ + val min = key.split("-").toTypedArray()[0].toInt() + val max = key.split("-").toTypedArray()[1].toInt() + if (value in min..max){ + result += FaithlLevel.command.getStringList("${levelData.key}.${min}-${max}.${event}") ?: mutableListOf("null") + return result + } + }else if (value == key.toInt()){ + result += FaithlLevel.command.getStringList("${levelData.key}.${key}.${event}") ?: mutableListOf("null") + return result + } + } + return mutableListOf("null") + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/hook/Placeholder.kt b/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/hook/Placeholder.kt new file mode 100644 index 0000000..1cc95b1 --- /dev/null +++ b/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/hook/Placeholder.kt @@ -0,0 +1,63 @@ +package com.faithl.bukkit.faithllevel.internal.hook + +import com.faithl.bukkit.faithllevel.FaithlLevel +import com.faithl.bukkit.faithllevel.api.FaithlLevelAPI +import org.bukkit.Bukkit.getPlayerExact +import org.bukkit.entity.Player +import taboolib.platform.compat.PlaceholderExpansion + +object Placeholder: PlaceholderExpansion { + override val identifier: String + get() = "faithl" + + override fun onPlaceholderRequest(player: Player, args: String): String { + val arr = args.split("_").toMutableList() + when(arr.size){ + //faithl_value + 1 -> { + val data = FaithlLevelAPI.getPlayerData(player, + FaithlLevelAPI.getLevelData(FaithlLevel.setting.getString("Main-Level"))?:return "Null level" + ) + when(arr[0]){ + "exp" -> return data.exp.toString() + "level" -> return data.level.toString() + "displayLevel" -> return data.getDisplay() + "maxExp" -> return data.getMaxExp().toString() + "nowExp" -> return "${data.exp}/${data.getMaxExp()}" + } + } + //faithl_level_value + 2 -> { + val data = FaithlLevelAPI.getPlayerData(player, + FaithlLevelAPI.getLevelData(arr[0])!!) + when(arr[1]){ + "exp" -> return data.exp.toString() + "level" -> return data.level.toString() + "displayLevel" -> return data.getDisplay() + "maxExp" -> return data.getMaxExp().toString() + "nowExp" -> return "${data.exp}/${data.getMaxExp()}" + } + } + } + //faithl_level_player_value + if (arr.size >= 3){ + val argument = arr.last() + arr.remove(argument) + val level = arr.first() + arr.remove(level) + var str = "" + for (a in arr) + str = "${str}_${a}" + val target = getPlayerExact(str.replaceFirst("_",""))?:return "Not online!" + val data = FaithlLevelAPI.getPlayerData(target, FaithlLevelAPI.getLevelData(level)?:return "Null level") + when(argument){ + "exp" -> return data.exp.toString() + "level" -> return data.level.toString() + "displayLevel" -> return data.getDisplay() + "maxExp" -> return data.getMaxExp().toString() + "nowExp" -> return "${data.exp}/${data.getMaxExp()}" + } + } + return "null" + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/level/LevelData.kt b/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/level/LevelData.kt new file mode 100644 index 0000000..9a05a79 --- /dev/null +++ b/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/level/LevelData.kt @@ -0,0 +1,11 @@ +package com.faithl.bukkit.faithllevel.internal.level + +import taboolib.library.configuration.ConfigurationSection + +class LevelData(private val configurationSection:ConfigurationSection) { + val key:String = configurationSection.name + val name:String = configurationSection.getString("Name") + val expGrow: MutableList = configurationSection.getStringList("Exp-Grow") + val expBottle: ConfigurationSection = configurationSection.getConfigurationSection("Exp-Bottle") + val levelDisplay: MutableList = configurationSection.getStringList("Level-Display") ?: mutableListOf("null") +} \ No newline at end of file diff --git a/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/level/LevelDataManager.kt b/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/level/LevelDataManager.kt new file mode 100644 index 0000000..ce9a70c --- /dev/null +++ b/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/level/LevelDataManager.kt @@ -0,0 +1,22 @@ +package com.faithl.bukkit.faithllevel.internal.level + +import com.faithl.bukkit.faithllevel.FaithlLevel + +object LevelDataManager { + var levelMap:MutableMap = mutableMapOf() + + init { + init() + } + + fun getLevelData(key:String): LevelData? { + return LevelDataManager.levelMap[key]!! + } + + fun init() { + val keys = FaithlLevel.conf.getConfigurationSection("").getKeys(false) + for (key in keys){ + LevelDataManager.levelMap[key] = LevelData(FaithlLevel.conf.getConfigurationSection(key)) + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/level/data/ExpDataManager.kt b/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/level/data/ExpDataManager.kt new file mode 100644 index 0000000..817e51c --- /dev/null +++ b/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/level/data/ExpDataManager.kt @@ -0,0 +1,199 @@ +package com.faithl.bukkit.faithllevel.internal.level.data + +import com.faithl.bukkit.faithllevel.FaithlLevel +import com.faithl.bukkit.faithllevel.api.event.LevelUpEvent +import com.faithl.bukkit.faithllevel.internal.level.LevelData +import com.faithl.bukkit.faithllevel.util.getFExp +import com.faithl.bukkit.faithllevel.util.getFLevel +import com.faithl.bukkit.faithllevel.util.setFExp +import com.faithl.bukkit.faithllevel.util.setFLevel +import org.bukkit.Sound +import org.bukkit.entity.Player +import taboolib.common.platform.function.adaptPlayer +import taboolib.common.util.replaceWithOrder +import taboolib.common5.Coerce +import taboolib.module.chat.colored +import taboolib.module.lang.TypeActionBar +import taboolib.platform.util.asLangText +import taboolib.platform.util.asLangTextList +import taboolib.platform.util.sendLang + +class ExpDataManager(private val player: Player, val levelData: LevelData) { + var level = 0 + var exp = 0 + init { + level = player.getFLevel(levelData).toInt() + exp = player.getFExp(levelData).toInt() + } + + fun updateOriginExp() { + val mainLevel = FaithlLevel.setting.getString("Options.Main-Level") + if (FaithlLevel.setting.getBoolean("Options.Main-Level-To-Origin") && levelData.name == mainLevel) { + player.level = level + if (this.getMaxExp() != 0) { + player.exp = exp / getMaxExp().toFloat() + } else { + player.exp = 0F + } + } + save() + } + + fun addExp(addExpAmount: Int) { + var addExp = addExpAmount + if (getMaxLevel() <= level) { + player.sendLang("Player-Level-Max",levelData.name) + return + } + val change = addExp + var levelUp = false + while (addExp > 0) { + if (getMaxExp() == 0) { + break + } + // 升级 + if (exp + addExp >= getMaxExp()) { + addExp = exp + addExp - getMaxExp() + exp = 0 + level += 1 + levelUp = true + } else { + exp += addExp + break + } + } + updateOriginExp() + sendActionBar(change) + if (!levelUp) { + player.playSound(player.location, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, change / 50f, change / 20f) + } else { + LevelUpEvent(player, this,levelData).call() + val title = player.asLangTextList("Player-Level-Up",levelData.name,getDisplay(), getMaxExp()).colored() + player.sendTitle(title[0], title[1], 5, 20, 5) + player.playSound(player.location, Sound.ENTITY_PLAYER_LEVELUP, change / 20f, change / 20f) + } + } + + private fun sendActionBar(change:Int){ + val message = TypeActionBar() + message.text = player.asLangText("Player-Exp-Change",levelData.name,getDisplay(), exp, getMaxExp(), "&b$change") + message.send(adaptPlayer(player)) + } + + fun hasExp(hasExpAmount: Int): Boolean{ + var hasExp = hasExpAmount + var level = level + var exp = exp + while (hasExp > 0) { + if (level <= 0 && hasExp > exp) { + return false + } + if (hasExp > exp) { + hasExp -= exp + level-- + exp = getMaxExp() + } else { + return true + } + } + return true + } + + fun takeExp(takeExpAmount: Int) { + var takeExp = takeExpAmount + val change = takeExp + while (takeExp > 0) { + if (level <= 0 && takeExp > exp) { + exp = 0 + break + } + if (takeExp > exp) { + takeExp -= exp + level-- + exp = getMaxExp() + } else { + exp -= takeExp + break + } + } + sendActionBar(change) + updateOriginExp() + } + + fun getMaxExp(): Int { + val expList: List = levelData.expGrow + if (this.getMaxLevel() <= level) { + return 0 + } + var maxExp = 0 + var level = -1 + for (str in expList) { + if (str.contains(":") && str.split(":").toTypedArray().size > 1) { + level = Coerce.toInteger(str.split(":").toTypedArray()[0].replace("[^0-9]".toRegex(), "")) + maxExp = Coerce.toInteger(str.split(":").toTypedArray()[1].replace("[^0-9]".toRegex(), "")) + } else { + level++ + maxExp = Coerce.toInteger(str.replace("[^0-9]".toRegex(), "")) + } + if (str.contains(" ") && str.split(" ").toTypedArray().size > 1) { + if (!player.hasPermission(str.split(" ").toTypedArray()[1])) { + break + } + } + if (this.level <= level) { + break + } + } + return maxExp + } + + private fun getMaxLevel(): Int { + val expList: List = levelData.expGrow + var maxLevel = -1 + for (str in expList) { + if (str.contains(":") && str.split(":").toTypedArray().size > 1) { + maxLevel = Coerce.toInteger(str.split(":").toTypedArray()[0].replace("[^0-9]".toRegex(), "")) + } else { + maxLevel++ + } + if (str.contains(" ") && str.split(" ").toTypedArray().size > 1) { + if (!player.hasPermission(str.split(" ").toTypedArray()[1])) { + break + } + } + } + return maxLevel + } + + fun getDisplay(): String { + val displayList = levelData.levelDisplay + if (displayList.contains("null")) + return this.level.toString() + if (this.getMaxLevel() <= level) { + return "null" + } + var level = -1 + var display = "" + for(str in displayList){ + if (str.contains(":")&& str.split(":").toTypedArray().size > 1){ + level = Coerce.toInteger(str.split(":").toTypedArray()[0].replace("[^0-9]".toRegex(), "")) + display = str.split(":").toTypedArray()[1] + } + if (this.level <= level) { + break + } + } + return display.replaceWithOrder(this.level).colored() + } + + /** + * 保存数据 + * + * @return playerData 返回自己 + */ + fun save(): ExpDataManager{ + player.setFExp(levelData,exp) + player.setFLevel(levelData,level) + return this + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/listener/DatabaseListener.kt b/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/listener/DatabaseListener.kt new file mode 100644 index 0000000..e91c948 --- /dev/null +++ b/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/listener/DatabaseListener.kt @@ -0,0 +1,25 @@ +package com.faithl.bukkit.faithllevel.internal.listener + +import com.faithl.bukkit.faithllevel.FaithlLevel +import com.faithl.bukkit.faithllevel.api.FaithlLevelAPI +import org.bukkit.event.player.AsyncPlayerChatEvent +import org.bukkit.event.player.PlayerJoinEvent +import org.bukkit.event.player.PlayerQuitEvent +import taboolib.common.platform.event.SubscribeEvent +import taboolib.expansion.releaseDataContainer +import taboolib.expansion.setupDataContainer + +object DatabaseListener{ + @SubscribeEvent + fun e(e: PlayerJoinEvent) { + e.player.setupDataContainer() + } + + @SubscribeEvent + fun e(e: PlayerQuitEvent) { + FaithlLevelAPI.getLevelDataMap().forEach{ + FaithlLevelAPI.getPlayerData(e.player, it.value).save() + } + e.player.releaseDataContainer() + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/listener/EventListener.kt b/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/listener/EventListener.kt new file mode 100644 index 0000000..989e6b2 --- /dev/null +++ b/src/main/kotlin/com/faithl/bukkit/faithllevel/internal/listener/EventListener.kt @@ -0,0 +1,76 @@ +package com.faithl.bukkit.faithllevel.internal.listener + +import com.faithl.bukkit.faithllevel.FaithlLevel +import com.faithl.bukkit.faithllevel.api.FaithlLevelAPI +import com.faithl.bukkit.faithllevel.api.FaithlLevelAPI.getPlayerData +import com.faithl.bukkit.faithllevel.internal.level.data.ExpDataManager +import com.faithl.bukkit.faithllevel.api.event.ChangeType +import com.faithl.bukkit.faithllevel.api.event.ExpChangeEvent +import com.faithl.bukkit.faithllevel.api.event.LevelUpEvent +import com.faithl.bukkit.faithllevel.internal.conf.CommandLoader.getCommand +import com.faithl.bukkit.faithllevel.internal.level.LevelData +import org.bukkit.Bukkit +import org.bukkit.entity.Player +import org.bukkit.event.entity.PlayerDeathEvent +import org.bukkit.event.player.PlayerExpChangeEvent +import org.bukkit.event.player.PlayerJoinEvent +import taboolib.common.platform.event.SubscribeEvent +import taboolib.common.util.replaceWithOrder + +object EventListener { + @SubscribeEvent + fun e(e: PlayerJoinEvent){ + if (FaithlLevel.isOutDate && e.player.isOp) + FaithlLevel.checkUpdate(e.player) + } + + @SubscribeEvent + fun e(e: PlayerExpChangeEvent) { + for (levelData in FaithlLevelAPI.getLevelDataMap()){ + if (levelData.value.expBottle.getBoolean("Enable")){ + val addExp = levelData.value.expBottle.getInt("Time") + val playerData: ExpDataManager = getPlayerData(e.player,levelData.value) + val event = ExpChangeEvent(e.player,playerData,levelData.value,addExp, ChangeType.ADD) + event.call() + if (!event.isCancelled) { + playerData.addExp(event.amount); + } + } + } + if(FaithlLevel.setting.getBoolean("Options.Disable-Origin-ExpChange")) + e.amount = 0 + } + + @SubscribeEvent + fun e(e:LevelUpEvent){ + doCommand("Level-Up-Event",e.player,e.levelData) + } + + @SubscribeEvent + fun e(e:PlayerDeathEvent){ + doAllCommand("Death-Event",e.entity) + } + + @SubscribeEvent + fun e(e:ExpChangeEvent){ + doCommand("Exp-Change-Event",e.player,e.levelData) + } + + private fun doCommand(event:String,player:Player,levelData:LevelData){ + val playerData: ExpDataManager = getPlayerData(player,levelData) + for (command in getCommand(playerData.level, event,levelData)){ + if (command != "null") + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replaceWithOrder(player.name,playerData.level,player.world.name)) + } + } + + private fun doAllCommand(event:String,player:Player){ + FaithlLevelAPI.getLevelDataMap().forEach{ + val playerData: ExpDataManager = getPlayerData(player,it.value) + for (command in getCommand(playerData.level, event,it.value)){ + if (command != "null") + Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command.replaceWithOrder(player.name,playerData.level,player.world.name)) + } + } + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/faithl/bukkit/faithllevel/util/Data.kt b/src/main/kotlin/com/faithl/bukkit/faithllevel/util/Data.kt new file mode 100644 index 0000000..20f7ed0 --- /dev/null +++ b/src/main/kotlin/com/faithl/bukkit/faithllevel/util/Data.kt @@ -0,0 +1,32 @@ +package com.faithl.bukkit.faithllevel.util + +import com.faithl.bukkit.faithllevel.internal.level.LevelData +import org.bukkit.entity.Player +import taboolib.common5.Coerce +import taboolib.expansion.getDataContainer +import taboolib.expansion.releaseDataContainer +import taboolib.expansion.setupDataContainer + +fun Player.getFExp(levelData:LevelData): Int { + releaseDataContainer() + setupDataContainer() + return Coerce.toInteger(getDataContainer()["${levelData.key}_exp"]) +} + +fun Player.getFLevel(levelData:LevelData): Int { + releaseDataContainer() + setupDataContainer() + return Coerce.toInteger(getDataContainer()["${levelData.key}_level"]) +} + +fun Player.setFExp(levelData:LevelData,value:Int){ + releaseDataContainer() + setupDataContainer() + getDataContainer()["${levelData.key}_exp"]=Coerce.toInteger(value) +} + +fun Player.setFLevel(levelData:LevelData,value:Int){ + releaseDataContainer() + setupDataContainer() + getDataContainer()["${levelData.key}_level"]=Coerce.toInteger(value) +} \ No newline at end of file diff --git a/src/main/kotlin/com/faithl/bukkit/faithllevel/util/JsonUtil.kt b/src/main/kotlin/com/faithl/bukkit/faithllevel/util/JsonUtil.kt new file mode 100644 index 0000000..756ea3e --- /dev/null +++ b/src/main/kotlin/com/faithl/bukkit/faithllevel/util/JsonUtil.kt @@ -0,0 +1,30 @@ +package com.faithl.bukkit.faithllevel.util + +import java.io.BufferedReader +import java.io.IOException +import java.io.InputStreamReader +import java.net.MalformedURLException +import java.net.URL +import java.net.URLConnection + + +object JsonUtil { + fun loadJson(url: String?): String{ + val json = StringBuilder() + try { + val urlObject = URL(url) + val uc: URLConnection = urlObject.openConnection() + val `in` = BufferedReader(InputStreamReader(uc.getInputStream())) + var inputLine:String? + while (`in`.readLine().also {inputLine = it } != null) { + json.append(inputLine) + } + `in`.close() + } catch (e: MalformedURLException) { + e.printStackTrace() + } catch (e: IOException) { + e.printStackTrace() + } + return json.toString() + } +} \ No newline at end of file diff --git a/src/main/resources/commands.yml b/src/main/resources/commands.yml new file mode 100644 index 0000000..650dfb5 --- /dev/null +++ b/src/main/resources/commands.yml @@ -0,0 +1,36 @@ +#------------所有占位符------------# +# {0} - 玩家名 +# {1} - 当前等级 +# {2} - 玩家所在世界 + +#------------所有事件------------# +#Level-Up-Event 玩家升级事件 +#Death-Event 玩家死亡事件(可用于死亡等级惩罚) +#Exp-Change-Event 玩家经验变化事件 + +#请与Levels中的标签一致 +MainLevel: + #每级执行 + Every-Level: + Level-Up-Event: + - "" + Death-Event: + - "" + #0-5级执行 + 0-5: + #事件名 + Level-Up-Event: + # 例如玩家Zha_Yun达到1(0-5级均会触发)级 则执行/fl take Zha_Yun 100 + - "fl take {0} 100" + Death-Event: + - "fl take {0} 100" + 6-10: + Level-Up-Event: + Death-Event: + # 单独一级请这样填写 + 11: + Level-Up-Event: + Death-Event: + 12-100: + Level-Up-Event: + Death-Event: \ No newline at end of file diff --git a/src/main/resources/lang/zh_CN.yml b/src/main/resources/lang/zh_CN.yml new file mode 100644 index 0000000..a6b4bc8 --- /dev/null +++ b/src/main/resources/lang/zh_CN.yml @@ -0,0 +1,25 @@ +Plugin-Enabled: '&8[&3FaithlLevel&8][&bINFO&8] &r插件已成功加载。 当前插件版本是 &b{0}&r, Kotlin版本是 &b{1}&r。' +Plugin-Database-Enabled: '&8[&3FaithlLevel&8][&bINFO&8] &r数据库已成功加载。 当前数据库为 &b{0}。' +Plugin-Reloaded: '&8[&3FaithlLevel&8][&bINFO&8] &r插件已成功重载。 当前插件版本是 &b{0}&r, Kotlin版本是 &b{1}&r。' +Plugin-Update: '&8[&3FaithlLevel&8][&bINFO&8] &r发现新版本, 当前版本 &b{0}&r, 最新版本 &b{1}&r, 插件地址 &b{2}&r。' + +Command-Help-Type: '命令' +Command-Help-Args: '参数' +Command-Reload-Description: '重载插件' +Command-Add-Description: '给予玩家经验' +Command-Add-Error: '&8[&3FaithlLevel&8][&cERROR&8] &r错误的用法, 请使用&b/faithllevel add [Level] [玩家] [经验]。' +Command-Add-Info: '&8[&3FaithlLevel&8][&b{0}&8] &r增长 &b{1}&r 玩家 &b{2} &r经验 &r[&b{3}&8/&3{4}&r]' +Command-Take-Description: '减少玩家经验' +Command-Take-Error: '&8[&3FaithlLevel&8][&cERROR&8] &r错误的用法, 请使用&b/faithllevel take [Level] [玩家] [经验]。' +Command-Take-Info: '&8[&3FaithlLevel&8][&b{0}&8] &r减少 &b{1}&r 玩家 &b{2} &r经验 &r[&b{3}&8/&3{4}&r]' +Command-Set-Description: '设置玩家等级' +Command-Set-Error: '&8[&3FaithlLevel&8][&cERROR&8] &r错误的用法, 请使用&b/faithllevel set [Level] [玩家] [等级]。' +Command-Set-Info: '&8[&3FaithlLevel&8][&b{0}&8] &r设置 &b{1}&r 玩家等级为: &b{2}&r 级。' +Command-Status-Description: '查看玩家信息' +Command-Status-Info: '&8[&3FaithlLevel&8][&b{0}&8] &r玩家 &b{1} &r当前信息: &b{2}&8 - &r[&b{3}&8/&3{4}&r]。' + +Player-Level-Max: '&8[&3FaithlLevel&8][&c{0}&8] &r你已经满级了!' +Player-Exp-Change: '&8[&3FaithlLevel&8][&b{0}&8] &rLv.{1}&8 - &r[&b{2}&8/&3{3}&r] &r[{4}&r]' +Player-Level-Up: + - '&8[&3FaithlLevel&8][&b{0}&8] &r你升级了!' + - '&rLv.&b{1}&r &8 - &r升级所需:&b{2}' \ No newline at end of file diff --git a/src/main/resources/levels.yml b/src/main/resources/levels.yml new file mode 100644 index 0000000..d17de5c --- /dev/null +++ b/src/main/resources/levels.yml @@ -0,0 +1,49 @@ +#等级系统标签 +MainLevel: + #等级系统名 + Name: "主等级" + #多少级到多少级,每级需要的经验 + #这里是0-5级每级需要10经验 5-10级每级需要50经验 以此类推 + #等级上限为最后一项的等级 + #若需要使用权限请在后面写空格+权限,玩家没有该权限无法升级 + Exp-Grow: + - "5:10" + - "10:50" + - "100:100 permission.access" + #经验瓶增长经验 + Exp-Bottle: + #开关 + Enable: true + #经验倍率 + Time: 1 + #等级展示,请使用{0}表示当前等级 + Level-Display: + - "10:&f{0}☆" + - "20:&a{0}☆" + - "30:&b{0}☆" +SurvivalLevel: + Name: "生存等级" + Exp-Grow: + - "5:10" + - "10:50" + - "100:100" + Exp-Bottle: + Enable: false + Time: 1 + Level-Display: + - "10:&f{0}☆" + - "20:&a{0}☆" + - "30:&b{0}☆" +BedwarsLevel: + Name: "起床战争等级" + Exp-Grow: + - "5:10" + - "10:50" + - "100:100" + Exp-Bottle: + Enable: false + Time: 1 + Level-Display: + - "10:&f{0}☆" + - "20:&a{0}☆" + - "30:&b{0}☆" \ No newline at end of file diff --git a/src/main/resources/settings.yml b/src/main/resources/settings.yml new file mode 100644 index 0000000..d7247f2 --- /dev/null +++ b/src/main/resources/settings.yml @@ -0,0 +1,19 @@ +Options: + #更新提醒 + Check-Update: true + #关闭原版经验变化 + Disable-Origin-ExpChange: true + #原版等级同步(关闭将不会同步到原版等级,且原版等级时刻为0) + Main-Level-To-Origin: true + #主等级系统 请与Levels中的标签一致 + Main-Level: MainLevel + #数据库配置 + Database: + #MySQL,SQLite + Type: SQLite + #若为SQLite不用配置下列项目 + Host: localhost + Port: 3306 + User: root + Password: root + Database: minecraft \ No newline at end of file diff --git a/src/test/kotlin/X.kt b/src/test/kotlin/X.kt new file mode 100644 index 0000000..32f47fe --- /dev/null +++ b/src/test/kotlin/X.kt @@ -0,0 +1,3 @@ +fun main() { + +}