diff --git a/build.gradle.kts b/build.gradle.kts index 703c4d4..fff9505 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,6 @@ plugins { kotlin("jvm") version "1.8.0" - id("io.papermc.paperweight.userdev") version "1.5.4" +// id("io.papermc.paperweight.userdev") version "1.5.4" } group = "group.pvpconnect" @@ -8,7 +8,7 @@ version = "1.0.1" repositories { mavenCentral() -// maven("https://repo.papermc.io/repository/maven-public/") + maven("https://repo.papermc.io/repository/maven-public/") } java { @@ -17,9 +17,9 @@ java { dependencies { testImplementation(kotlin("test")) -// compileOnly("io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT") - paperweight.paperDevBundle("1.19.2-R0.1-SNAPSHOT") - implementation("io.github.monun:kommand-api:3.1.3") + compileOnly("io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT") +// paperweight.paperDevBundle("1.19.2-R0.1-SNAPSHOT") + implementation("io.github.monun:kommand-api:3.1.7") } tasks.test { diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..7f93135 Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..3fa8f86 --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 index 79a61d4..1aa94a4 --- a/gradlew +++ b/gradlew @@ -83,10 +83,8 @@ done # This is normally unused # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} -APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum @@ -133,10 +131,13 @@ 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. + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. @@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then case $MAX_FD in #( max*) # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 MAX_FD=$( ulimit -H -n ) || warn "Could not query maximum file descriptor limit" esac @@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then '' | soft) :;; #( *) # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. - # shellcheck disable=SC3045 + # shellcheck disable=SC2039,SC3045 ulimit -n "$MAX_FD" || warn "Could not set maximum file descriptor limit to $MAX_FD" esac @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then done fi -# Collect all arguments for the java command; -# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of -# shell script including quotes and variable substitutions, so put them in -# double quotes to make sure that they get re-expanded; and -# * put everything else in single quotes, so that it's not re-expanded. + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. set -- \ "-Dorg.gradle.appname=$APP_BASE_NAME" \ diff --git a/gradlew.bat b/gradlew.bat index 93e3f59..6689b85 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -1,92 +1,92 @@ -@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=. -@rem This is normally unused -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if %ERRORLEVEL% equ 0 goto execute - -echo. -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% equ 0 goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -set EXIT_CODE=%ERRORLEVEL% -if %EXIT_CODE% equ 0 set EXIT_CODE=1 -if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% -exit /b %EXIT_CODE% - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@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=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +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% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/src/main/kotlin/group/pvpconnect/combat_f/Main.kt b/src/main/kotlin/group/pvpconnect/combat_f/Main.kt index c3c372f..d3da51e 100644 --- a/src/main/kotlin/group/pvpconnect/combat_f/Main.kt +++ b/src/main/kotlin/group/pvpconnect/combat_f/Main.kt @@ -39,7 +39,7 @@ class Main:JavaPlugin() { if(list[it.key]!!.second == null) return@forEach if(list[it.key]!!.third == null) return@forEach if(it.value.third!!/1000 + combatData.instance.getTime() <= System.currentTimeMillis()/1000){ - list[it.key] = Triple(false,null,null) + list.remove(it.key) } } Bukkit.getOnlinePlayers().forEach{ @@ -47,6 +47,7 @@ class Main:JavaPlugin() { if(!list[it.uniqueId]!!.first) return@forEach if(list[it.uniqueId]!!.second == null) return@forEach if(list[it.uniqueId]!!.third == null) return@forEach + it.isGliding = false if(combatData.getOtherHit(it.world.name)){ it.sendActionBar(Component.text("${ChatColor.RESET}${ChatColor.WHITE}${list[it.uniqueId]!!.third!! /1000 + combatData.instance.getTime() - System.currentTimeMillis()/1000}${ChatColor.RED}${ChatColor.BOLD}초 뒤 전투모드가 끝납니다!")) }else { diff --git a/src/main/kotlin/group/pvpconnect/combat_f/cmd/CombatCmd.kt b/src/main/kotlin/group/pvpconnect/combat_f/cmd/CombatCmd.kt index 690147d..487c09c 100644 --- a/src/main/kotlin/group/pvpconnect/combat_f/cmd/CombatCmd.kt +++ b/src/main/kotlin/group/pvpconnect/combat_f/cmd/CombatCmd.kt @@ -4,6 +4,7 @@ import group.pvpconnect.combat_f.Main import group.pvpconnect.combat_f.data.CombatData import io.github.monun.kommand.getValue import io.github.monun.kommand.kommand +import org.bukkit.Bukkit import org.bukkit.ChatColor import org.bukkit.World @@ -12,7 +13,7 @@ class CombatCmd(plugin:Main, private val cd:CombatData) { plugin.apply { kommand { register("combat"){ - requires { isPlayer && isOp } + requires { isOp } then("toggle"){ then("world" to dimension()){ executes { diff --git a/src/main/kotlin/group/pvpconnect/combat_f/event/CombatEvent.kt b/src/main/kotlin/group/pvpconnect/combat_f/event/CombatEvent.kt index 57bb811..f0c15ff 100644 --- a/src/main/kotlin/group/pvpconnect/combat_f/event/CombatEvent.kt +++ b/src/main/kotlin/group/pvpconnect/combat_f/event/CombatEvent.kt @@ -4,16 +4,19 @@ import group.pvpconnect.combat_f.Main import group.pvpconnect.combat_f.data.CombatData import org.bukkit.Bukkit import org.bukkit.ChatColor +import org.bukkit.command.CommandSender import org.bukkit.entity.EntityType import org.bukkit.entity.Player import org.bukkit.event.EventHandler import org.bukkit.event.Listener import org.bukkit.event.entity.EntityDamageByEntityEvent +import org.bukkit.event.entity.EntityDamageEvent import org.bukkit.event.entity.PlayerDeathEvent import org.bukkit.event.entity.ProjectileHitEvent import org.bukkit.event.player.PlayerChangedWorldEvent import org.bukkit.event.player.PlayerCommandPreprocessEvent import org.bukkit.event.player.PlayerQuitEvent +import org.bukkit.scoreboard.Team @Suppress("unused") class CombatEvent(private val plugin:Main, private val combatData: CombatData):Listener { @@ -24,9 +27,15 @@ class CombatEvent(private val plugin:Main, private val combatData: CombatData):L @EventHandler fun onOtherDamage(e:EntityDamageByEntityEvent){ - if(!combatData.instance.getUseWorld(e.entity.world.name)) return if(e.entityType != EntityType.PLAYER) return if(e.damager.type != EntityType.PLAYER) return + if(!combatData.instance.getUseWorld(e.entity.world.name)) return + val team = Bukkit.getServer().scoreboardManager.mainScoreboard.teams + lateinit var plteam: Team + team.forEach { if(it.hasPlayer(Bukkit.getOfflinePlayer(e.entity.name))) plteam = it } + if(plteam.hasPlayer(Bukkit.getOfflinePlayer(e.damager.name))){ + return + } val list = plugin.instance.list[e.entity.uniqueId] val dlist = plugin.instance.list[e.damager.uniqueId] if((dlist?.second != null) && (dlist.second != e.entity.uniqueId)&& !combatData.instance.getOtherHit(e.entity.world.name)){ e.isCancelled = true;return} @@ -41,6 +50,8 @@ class CombatEvent(private val plugin:Main, private val combatData: CombatData):L e.isCancelled = true return } + plugin.instance.list[e.entity.uniqueId] = Triple(true,e.damager.uniqueId,System.currentTimeMillis()) + plugin.instance.list[e.damager.uniqueId] = Triple(true,e.entity.uniqueId,System.currentTimeMillis()) if(combatData.instance.getCanSeeWorld(e.entity.world.name) && !plugin.instance.list[e.entity.uniqueId]!!.first){ Bukkit.getOnlinePlayers().forEach { if(it.name != e.entity.name && it.name != e.damager.name){ @@ -51,17 +62,20 @@ class CombatEvent(private val plugin:Main, private val combatData: CombatData):L } } } - plugin.instance.list[e.entity.uniqueId] = Triple(true,e.damager.uniqueId,System.currentTimeMillis()) - plugin.instance.list[e.damager.uniqueId] = Triple(true,e.entity.uniqueId,System.currentTimeMillis()) - } @EventHandler fun onArrow(e:ProjectileHitEvent){ - if(!combatData.instance.getUseWorld(e.entity.world.name)) return if(e.hitEntity == null) return if(e.hitEntity!!.type != EntityType.PLAYER) return if(e.entity.shooter !is Player) return + if(!combatData.instance.getUseWorld(e.entity.world.name)) return + val team = Bukkit.getServer().scoreboardManager.mainScoreboard.teams + lateinit var plteam: Team + team.forEach { if(it.hasPlayer(Bukkit.getOfflinePlayer(e.entity.name))) plteam = it } + if(plteam.hasPlayer(Bukkit.getOfflinePlayer((e.entity.shooter as Player).name))){ + return + } val player = e.hitEntity as Player val shooter = e.entity.shooter as Player val list = plugin.instance.list[player.uniqueId] @@ -102,7 +116,7 @@ class CombatEvent(private val plugin:Main, private val combatData: CombatData):L val list = plugin.instance.list[e.player.uniqueId] ?: return if(!list.first) return e.player.killer = Bukkit.getPlayer(list.second!!) - e.player.health = 0.0 + Bukkit.dispatchCommand(,) if(combatData.instance.getCanSeeWorld(e.player.world.name)){ Bukkit.getOnlinePlayers().forEach { val player = e.player @@ -115,8 +129,8 @@ class CombatEvent(private val plugin:Main, private val combatData: CombatData):L } } } - plugin.instance.list[e.player.uniqueId] = Triple(false,null,null) - plugin.instance.list[list.second!!] = Triple(false,null,null) + plugin.instance.list.remove(e.player.uniqueId) + plugin.instance.list.remove(list.second!!) } @EventHandler @@ -135,8 +149,8 @@ class CombatEvent(private val plugin:Main, private val combatData: CombatData):L } } } - plugin.instance.list[e.player.uniqueId] = Triple(false,null,null) - plugin.instance.list[list.second!!] = Triple(false,null,null) + plugin.instance.list.remove(e.player.uniqueId) + plugin.instance.list.remove(list.second!!) } @EventHandler diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 23ee7f8..8954b29 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -4,4 +4,4 @@ main: group.pvpconnect.combat_f.Main api-version: 1.19 author: faiz libraries: - - io.github.monun:kommand-core:3.1.3 \ No newline at end of file + - io.github.monun:kommand-core:3.1.7 \ No newline at end of file