From a948a1ff08b6b5ba54ceb15e8bfce737e4a62e0b Mon Sep 17 00:00:00 2001 From: faiz36 Date: Sat, 1 Apr 2023 14:13:05 +0900 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=EB=A7=88=EC=A7=80=EB=A7=89=EC=9D=B4?= =?UTF-8?q?=20=EB=90=A0=EC=88=98=EB=8F=84=20=EC=9E=88=EB=8A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 8 ++--- .../kotlin/group/pvpconnect/combat_f/Main.kt | 7 +++- .../pvpconnect/combat_f/cmd/CombatCmd.kt | 24 ++++++------- .../pvpconnect/combat_f/event/CombatEvent.kt | 34 ++++++++++--------- 4 files changed, 40 insertions(+), 33 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a6d9ddc..f20032b 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.3" + id("io.papermc.paperweight.userdev") version "1.5.3" } group = "group.pvpconnect" @@ -8,7 +8,7 @@ version = "1.0-SNAPSHOT" repositories { mavenCentral() - maven("https://repo.papermc.io/repository/maven-public/") +// maven("https://repo.papermc.io/repository/maven-public/") } java { @@ -17,8 +17,8 @@ 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") +// 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") } diff --git a/src/main/kotlin/group/pvpconnect/combat_f/Main.kt b/src/main/kotlin/group/pvpconnect/combat_f/Main.kt index 0ccdfc4..75e8d6d 100644 --- a/src/main/kotlin/group/pvpconnect/combat_f/Main.kt +++ b/src/main/kotlin/group/pvpconnect/combat_f/Main.kt @@ -24,6 +24,7 @@ class Main:JavaPlugin() { } override fun onDisable() { + combatData.save() schedule.cancel() } @@ -32,6 +33,8 @@ class Main:JavaPlugin() { CombatEvent(this,combatData) schedule = this.server.scheduler.runTaskTimerAsynchronously(this, Runnable { list.forEach{ + if(list[it.key] == 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) } @@ -39,7 +42,9 @@ class Main:JavaPlugin() { Bukkit.getOnlinePlayers().forEach{ if(list[it.uniqueId] == null) return@forEach if(!list[it.uniqueId]!!.first) return@forEach - it.sendActionBar(Component.text("${ChatColor.WHITE}${Bukkit.getPlayer(list[it.uniqueId]!!.second!!)!!.name}${ChatColor.RED}님과 전투중입니다! ${ChatColor.WHITE}${list[it.uniqueId]!!.third!! /1000 + combatData.instance.getTime() - System.currentTimeMillis()/1000}${ChatColor.RED}초 뒤 전투모드가 끝납니다!")) + if(list[it.uniqueId]!!.second == null) return@forEach + if(list[it.uniqueId]!!.third == null) return@forEach + it.sendActionBar(Component.text("${ChatColor.WHITE}${Bukkit.getPlayer(list[it.uniqueId]!!.second!!)!!.name}${ChatColor.RED}${ChatColor.BOLD}님과 전투중입니다! ${ChatColor.RESET}${ChatColor.WHITE}${list[it.uniqueId]!!.third!! /1000 + combatData.instance.getTime() - System.currentTimeMillis()/1000}${ChatColor.RED}${ChatColor.BOLD}초 뒤 전투모드가 끝납니다!")) } },1L,1L) } 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 34f09bb..1614202 100644 --- a/src/main/kotlin/group/pvpconnect/combat_f/cmd/CombatCmd.kt +++ b/src/main/kotlin/group/pvpconnect/combat_f/cmd/CombatCmd.kt @@ -19,20 +19,20 @@ class CombatCmd(plugin:Plugin, val cd:CombatData) { val world: World by it val bool = cd.instance.getUseWorld(world.name) cd.instance.setUseWorld(world.name,!bool) - sender.sendMessage("${ChatColor.BOLD}${ChatColor.GOLD}[${ChatColor.GREEN}✓${ChatColor.GOLD}] ${ChatColor.WHITE}${world.name}의 컴뱃 모드 사용이 ${if(!bool)"활성화 되었습니다!" else "비활성화 되었습니다!"}") - } - } - } - then("visiable"){ - then("world" to dimension()){ - executes { - val world:World by it - val bool = cd.instance.getCanSeeWorld(world.name) - cd.instance.setCanSeeWorld(world.name,!bool) - sender.sendMessage("${ChatColor.BOLD}${ChatColor.GOLD}[${ChatColor.GREEN}✓${ChatColor.GOLD}] ${ChatColor.WHITE}${world.name}의 컴뱃중 다른 사람 볼수있음이 ${if(!bool)"활성화 되었습니다!" else "비활성화 되었습니다!"}") + sender.sendMessage("${ChatColor.BOLD}${ChatColor.GOLD}[${ChatColor.BOLD}${ChatColor.GREEN}✓${ChatColor.RESET}${ChatColor.GOLD}] ${ChatColor.WHITE}${world.name}의 컴뱃 모드 사용이 ${if(!bool)"활성화 되었습니다!" else "비활성화 되었습니다!"}") } } } +// then("visiable"){ +// then("world" to dimension()){ +// executes { +// val world:World by it +// val bool = cd.instance.getCanSeeWorld(world.name) +// cd.instance.setCanSeeWorld(world.name,!bool) +// sender.sendMessage("${ChatColor.BOLD}${ChatColor.GOLD}[${ChatColor.GREEN}✓${ChatColor.GOLD}] ${ChatColor.WHITE}${world.name}의 컴뱃중 다른 사람 볼수있음이 ${if(!bool)"활성화 되었습니다!" else "비활성화 되었습니다!"}") +// } +// } +// } then("time"){ then("int" to int()){ executes { @@ -40,7 +40,7 @@ class CombatCmd(plugin:Plugin, val cd:CombatData) { val otime = cd.instance.getTime() val ctime = int cd.instance.setTime(ctime) - sender.sendMessage("${ChatColor.BOLD}${ChatColor.GOLD}[${ChatColor.GREEN}✓${ChatColor.GOLD}] ${ChatColor.WHITE}컴뱃타임이 ${otime}초에서 ${ctime}초으로 변경되었습니다!") + sender.sendMessage("${ChatColor.BOLD}${ChatColor.GOLD}[${ChatColor.BOLD}${ChatColor.GREEN}✓${ChatColor.RESET}${ChatColor.GOLD}] ${ChatColor.WHITE}컴뱃타임이 ${otime}초에서 ${ctime}초으로 변경되었습니다!") } } } 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 b557de5..ee01672 100644 --- a/src/main/kotlin/group/pvpconnect/combat_f/event/CombatEvent.kt +++ b/src/main/kotlin/group/pvpconnect/combat_f/event/CombatEvent.kt @@ -5,9 +5,11 @@ import group.pvpconnect.combat_f.data.CombatData import org.bukkit.Bukkit import org.bukkit.entity.EntityType import org.bukkit.event.EventHandler +import org.bukkit.event.EventPriority import org.bukkit.event.Listener import org.bukkit.event.entity.EntityDamageByEntityEvent import org.bukkit.event.entity.PlayerDeathEvent +import org.bukkit.event.player.PlayerCommandPreprocessEvent import org.bukkit.event.player.PlayerQuitEvent @Suppress("unused") @@ -17,30 +19,30 @@ class CombatEvent(private val plugin:Main, private val combatData: CombatData):L Bukkit.getPluginManager().registerEvents(this,plugin) } - @EventHandler - fun onDamage(e:EntityDamageByEntityEvent){ - if(!combatData.instance.getUseWorld(e.entity.world.name)) return - if(e.entityType != EntityType.PLAYER) return - if(e.damager.type != EntityType.PLAYER) 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()) - } - @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 - val list = plugin.instance.list[e.entity.uniqueId] ?: return - if(!list.first) return - if(list.second == e.damager.uniqueId) { - 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()) + 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)){ e.isCancelled = true;return} + if(list?.second != null && list.second != e.damager.uniqueId) { + e.isCancelled = true return - }else{ + } + 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 onCommand(e:PlayerCommandPreprocessEvent){ + if(listOf("l","lobby","home","spawn").any { e.message == it }){ + val list = plugin.instance.list[e.player.uniqueId] ?: return + if(!list.first) return e.isCancelled = true } - } @EventHandler