️버그 수정

This commit is contained in:
root 2024-01-14 18:50:01 +09:00
parent 4a5072f31c
commit fb5883997e
9 changed files with 150 additions and 122 deletions

View File

@ -1,6 +1,6 @@
plugins { plugins {
kotlin("jvm") version "1.8.0" 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" group = "group.pvpconnect"
@ -8,7 +8,7 @@ version = "1.0.1"
repositories { repositories {
mavenCentral() mavenCentral()
// maven("https://repo.papermc.io/repository/maven-public/") maven("https://repo.papermc.io/repository/maven-public/")
} }
java { java {
@ -17,9 +17,9 @@ java {
dependencies { dependencies {
testImplementation(kotlin("test")) testImplementation(kotlin("test"))
// compileOnly("io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT") compileOnly("io.papermc.paper:paper-api:1.19.2-R0.1-SNAPSHOT")
paperweight.paperDevBundle("1.19.2-R0.1-SNAPSHOT") // paperweight.paperDevBundle("1.19.2-R0.1-SNAPSHOT")
implementation("io.github.monun:kommand-api:3.1.3") implementation("io.github.monun:kommand-api:3.1.7")
} }
tasks.test { tasks.test {

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -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

29
gradlew vendored Normal file → Executable file
View File

@ -83,10 +83,8 @@ done
# This is normally unused # This is normally unused
# shellcheck disable=SC2034 # shellcheck disable=SC2034
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # 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
# 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. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@ -133,10 +131,13 @@ location of your Java installation."
fi fi
else else
JAVACMD=java 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 Please set the JAVA_HOME variable in your environment to match the
location of your Java installation." location of your Java installation."
fi
fi fi
# Increase the maximum file descriptors if we can. # Increase the maximum file descriptors if we can.
@ -144,7 +145,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #( case $MAX_FD in #(
max*) max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. # 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 ) || MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit" warn "Could not query maximum file descriptor limit"
esac esac
@ -152,7 +153,7 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
'' | soft) :;; #( '' | soft) :;; #(
*) *)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. # 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" || ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD" warn "Could not set maximum file descriptor limit to $MAX_FD"
esac esac
@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done done
fi fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
# shell script including quotes and variable substitutions, so put them in DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded. # 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 -- \ set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \ "-Dorg.gradle.appname=$APP_BASE_NAME" \

View File

@ -39,7 +39,7 @@ class Main:JavaPlugin() {
if(list[it.key]!!.second == null) return@forEach if(list[it.key]!!.second == null) return@forEach
if(list[it.key]!!.third == null) return@forEach if(list[it.key]!!.third == null) return@forEach
if(it.value.third!!/1000 + combatData.instance.getTime() <= System.currentTimeMillis()/1000){ 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{ Bukkit.getOnlinePlayers().forEach{
@ -47,6 +47,7 @@ class Main:JavaPlugin() {
if(!list[it.uniqueId]!!.first) return@forEach if(!list[it.uniqueId]!!.first) return@forEach
if(list[it.uniqueId]!!.second == null) return@forEach if(list[it.uniqueId]!!.second == null) return@forEach
if(list[it.uniqueId]!!.third == null) return@forEach if(list[it.uniqueId]!!.third == null) return@forEach
it.isGliding = false
if(combatData.getOtherHit(it.world.name)){ 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}초 뒤 전투모드가 끝납니다!")) it.sendActionBar(Component.text("${ChatColor.RESET}${ChatColor.WHITE}${list[it.uniqueId]!!.third!! /1000 + combatData.instance.getTime() - System.currentTimeMillis()/1000}${ChatColor.RED}${ChatColor.BOLD}초 뒤 전투모드가 끝납니다!"))
}else { }else {

View File

@ -4,6 +4,7 @@ import group.pvpconnect.combat_f.Main
import group.pvpconnect.combat_f.data.CombatData import group.pvpconnect.combat_f.data.CombatData
import io.github.monun.kommand.getValue import io.github.monun.kommand.getValue
import io.github.monun.kommand.kommand import io.github.monun.kommand.kommand
import org.bukkit.Bukkit
import org.bukkit.ChatColor import org.bukkit.ChatColor
import org.bukkit.World import org.bukkit.World
@ -12,7 +13,7 @@ class CombatCmd(plugin:Main, private val cd:CombatData) {
plugin.apply { plugin.apply {
kommand { kommand {
register("combat"){ register("combat"){
requires { isPlayer && isOp } requires { isOp }
then("toggle"){ then("toggle"){
then("world" to dimension()){ then("world" to dimension()){
executes { executes {

View File

@ -4,16 +4,19 @@ import group.pvpconnect.combat_f.Main
import group.pvpconnect.combat_f.data.CombatData import group.pvpconnect.combat_f.data.CombatData
import org.bukkit.Bukkit import org.bukkit.Bukkit
import org.bukkit.ChatColor import org.bukkit.ChatColor
import org.bukkit.command.CommandSender
import org.bukkit.entity.EntityType import org.bukkit.entity.EntityType
import org.bukkit.entity.Player import org.bukkit.entity.Player
import org.bukkit.event.EventHandler import org.bukkit.event.EventHandler
import org.bukkit.event.Listener import org.bukkit.event.Listener
import org.bukkit.event.entity.EntityDamageByEntityEvent import org.bukkit.event.entity.EntityDamageByEntityEvent
import org.bukkit.event.entity.EntityDamageEvent
import org.bukkit.event.entity.PlayerDeathEvent import org.bukkit.event.entity.PlayerDeathEvent
import org.bukkit.event.entity.ProjectileHitEvent import org.bukkit.event.entity.ProjectileHitEvent
import org.bukkit.event.player.PlayerChangedWorldEvent import org.bukkit.event.player.PlayerChangedWorldEvent
import org.bukkit.event.player.PlayerCommandPreprocessEvent import org.bukkit.event.player.PlayerCommandPreprocessEvent
import org.bukkit.event.player.PlayerQuitEvent import org.bukkit.event.player.PlayerQuitEvent
import org.bukkit.scoreboard.Team
@Suppress("unused") @Suppress("unused")
class CombatEvent(private val plugin:Main, private val combatData: CombatData):Listener { 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 @EventHandler
fun onOtherDamage(e:EntityDamageByEntityEvent){ fun onOtherDamage(e:EntityDamageByEntityEvent){
if(!combatData.instance.getUseWorld(e.entity.world.name)) return
if(e.entityType != EntityType.PLAYER) return if(e.entityType != EntityType.PLAYER) return
if(e.damager.type != 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 list = plugin.instance.list[e.entity.uniqueId]
val dlist = plugin.instance.list[e.damager.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} 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 e.isCancelled = true
return 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){ if(combatData.instance.getCanSeeWorld(e.entity.world.name) && !plugin.instance.list[e.entity.uniqueId]!!.first){
Bukkit.getOnlinePlayers().forEach { Bukkit.getOnlinePlayers().forEach {
if(it.name != e.entity.name && it.name != e.damager.name){ 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 @EventHandler
fun onArrow(e:ProjectileHitEvent){ fun onArrow(e:ProjectileHitEvent){
if(!combatData.instance.getUseWorld(e.entity.world.name)) return
if(e.hitEntity == null) return if(e.hitEntity == null) return
if(e.hitEntity!!.type != EntityType.PLAYER) return if(e.hitEntity!!.type != EntityType.PLAYER) return
if(e.entity.shooter !is 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 player = e.hitEntity as Player
val shooter = e.entity.shooter as Player val shooter = e.entity.shooter as Player
val list = plugin.instance.list[player.uniqueId] 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 val list = plugin.instance.list[e.player.uniqueId] ?: return
if(!list.first) return if(!list.first) return
e.player.killer = Bukkit.getPlayer(list.second!!) e.player.killer = Bukkit.getPlayer(list.second!!)
e.player.health = 0.0 Bukkit.dispatchCommand(,)
if(combatData.instance.getCanSeeWorld(e.player.world.name)){ if(combatData.instance.getCanSeeWorld(e.player.world.name)){
Bukkit.getOnlinePlayers().forEach { Bukkit.getOnlinePlayers().forEach {
val player = e.player 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.remove(e.player.uniqueId)
plugin.instance.list[list.second!!] = Triple(false,null,null) plugin.instance.list.remove(list.second!!)
} }
@EventHandler @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.remove(e.player.uniqueId)
plugin.instance.list[list.second!!] = Triple(false,null,null) plugin.instance.list.remove(list.second!!)
} }
@EventHandler @EventHandler

View File

@ -4,4 +4,4 @@ main: group.pvpconnect.combat_f.Main
api-version: 1.19 api-version: 1.19
author: faiz author: faiz
libraries: libraries:
- io.github.monun:kommand-core:3.1.3 - io.github.monun:kommand-core:3.1.7