✨마지막 일뻔한, 다른사람이 볼수있게 가능 / 다른사람이 때릴수 있게 가능
This commit is contained in:
parent
a948a1ff08
commit
7fb3f1fad0
@ -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.3"
|
id("io.papermc.paperweight.userdev") version "1.5.4"
|
||||||
}
|
}
|
||||||
|
|
||||||
group = "group.pvpconnect"
|
group = "group.pvpconnect"
|
||||||
|
@ -15,6 +15,7 @@ class Main:JavaPlugin() {
|
|||||||
// 첫번째 전투 여부, 두번째 전투자 UUID, 남은 시간?
|
// 첫번째 전투 여부, 두번째 전투자 UUID, 남은 시간?
|
||||||
var list:HashMap<UUID,Triple<Boolean,UUID?,Long?>> = HashMap()
|
var list:HashMap<UUID,Triple<Boolean,UUID?,Long?>> = HashMap()
|
||||||
private lateinit var schedule:BukkitTask
|
private lateinit var schedule:BukkitTask
|
||||||
|
private lateinit var schedule2:BukkitTask
|
||||||
lateinit var instance: Main
|
lateinit var instance: Main
|
||||||
|
|
||||||
private val combatData by lazy { CombatData(this) }
|
private val combatData by lazy { CombatData(this) }
|
||||||
@ -36,6 +37,16 @@ class Main:JavaPlugin() {
|
|||||||
if(list[it.key] == null) return@forEach
|
if(list[it.key] == 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){
|
||||||
|
val player = Bukkit.getPlayer(it.key)!!
|
||||||
|
val damager = Bukkit.getPlayer(list[it.key]!!.second!!)!!
|
||||||
|
if(combatData.instance.getCanSeeWorld(player.world.name)){
|
||||||
|
Bukkit.getOnlinePlayers().forEach{ onlinep ->
|
||||||
|
onlinep.showPlayer(this,player)
|
||||||
|
onlinep.showPlayer(this,damager)
|
||||||
|
player.showPlayer(this,onlinep)
|
||||||
|
damager.showPlayer(this,onlinep)
|
||||||
|
}
|
||||||
|
}
|
||||||
list[it.key] = Triple(false,null,null)
|
list[it.key] = Triple(false,null,null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -44,8 +55,13 @@ 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
|
||||||
|
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 {
|
||||||
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}초 뒤 전투모드가 끝납니다!"))
|
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)
|
},1L,1L)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,16 +23,26 @@ class CombatCmd(plugin:Plugin, val cd:CombatData) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// then("visiable"){
|
then("visiable"){
|
||||||
// then("world" to dimension()){
|
then("world" to dimension()){
|
||||||
// executes {
|
executes {
|
||||||
// val world:World by it
|
val world:World by it
|
||||||
// val bool = cd.instance.getCanSeeWorld(world.name)
|
val bool = cd.instance.getCanSeeWorld(world.name)
|
||||||
// cd.instance.setCanSeeWorld(world.name,!bool)
|
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.GREEN}✓${ChatColor.GOLD}] ${ChatColor.WHITE}${world.name}의 컴뱃중 다른 사람 볼수있음이 ${if(!bool)"활성화 되었습니다!" else "비활성화 되었습니다!"}")
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
then("hitother"){
|
||||||
|
then("world" to dimension()){
|
||||||
|
executes {
|
||||||
|
val world:World by it
|
||||||
|
val bool = cd.instance.getOtherHit(world.name)
|
||||||
|
cd.instance.setOtherHit(world.name,!bool)
|
||||||
|
sender.sendMessage("${ChatColor.BOLD}${ChatColor.GOLD}[${ChatColor.GREEN}✓${ChatColor.GOLD}] ${ChatColor.WHITE}${world.name}의 컴뱃중 다른 사람의 공격 가능이 ${if(!bool)"활성화 되었습니다!" else "비활성화 되었습니다!"}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
then("time"){
|
then("time"){
|
||||||
then("int" to int()){
|
then("int" to int()){
|
||||||
executes {
|
executes {
|
||||||
|
@ -44,6 +44,14 @@ class CombatData(val plugin:Plugin) {
|
|||||||
return yaml.getInt("time")
|
return yaml.getInt("time")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setOtherHit(world:String,hitable:Boolean){
|
||||||
|
yaml.set("${world}.otherhitable",hitable)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getOtherHit(world:String):Boolean{
|
||||||
|
return yaml.getBoolean("${world}.otherhitable")
|
||||||
|
}
|
||||||
|
|
||||||
fun save(){
|
fun save(){
|
||||||
yaml.save(file)
|
yaml.save(file)
|
||||||
}
|
}
|
||||||
|
@ -3,12 +3,14 @@ package group.pvpconnect.combat_f.event
|
|||||||
import group.pvpconnect.combat_f.Main
|
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.entity.EntityType
|
import org.bukkit.entity.EntityType
|
||||||
|
import org.bukkit.entity.Player
|
||||||
import org.bukkit.event.EventHandler
|
import org.bukkit.event.EventHandler
|
||||||
import org.bukkit.event.EventPriority
|
|
||||||
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.PlayerDeathEvent
|
import org.bukkit.event.entity.PlayerDeathEvent
|
||||||
|
import org.bukkit.event.entity.ProjectileHitEvent
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent
|
||||||
import org.bukkit.event.player.PlayerQuitEvent
|
import org.bukkit.event.player.PlayerQuitEvent
|
||||||
|
|
||||||
@ -26,16 +28,62 @@ class CombatEvent(private val plugin:Main, private val combatData: CombatData):L
|
|||||||
if(e.damager.type != EntityType.PLAYER) return
|
if(e.damager.type != EntityType.PLAYER) 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)){ e.isCancelled = true;return}
|
if((dlist?.second != null) && (dlist.second != e.entity.uniqueId)&& !combatData.instance.getOtherHit(e.entity.world.name)){ e.isCancelled = true;return}
|
||||||
if(list?.second != null && list.second != e.damager.uniqueId) {
|
if(list?.second != null && list.second != e.damager.uniqueId && !combatData.instance.getOtherHit(e.entity.world.name)) {
|
||||||
|
e.damager.sendMessage("${ChatColor.RED}${ChatColor.BOLD}해당 플레이어는 ${ChatColor.RESET}${ChatColor.WHITE}${Bukkit.getPlayer(
|
||||||
|
list.second!!)!!.name}${ChatColor.RED}${ChatColor.BOLD}님과 전투중입니다!")
|
||||||
e.isCancelled = true
|
e.isCancelled = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if(combatData.instance.getCanSeeWorld(e.entity.world.name)){
|
||||||
|
Bukkit.getOnlinePlayers().forEach{
|
||||||
|
if(it.uniqueId == e.damager.uniqueId || it.uniqueId == e.entity.uniqueId){
|
||||||
|
return@forEach
|
||||||
|
}
|
||||||
|
it.hidePlayer(plugin,e.damager as Player)
|
||||||
|
it.hidePlayer(plugin,e.entity as Player)
|
||||||
|
(e.damager as Player).hidePlayer(plugin,it)
|
||||||
|
(e.entity as Player).hidePlayer(plugin,it)
|
||||||
|
}
|
||||||
|
}
|
||||||
plugin.instance.list[e.entity.uniqueId] = Triple(true,e.damager.uniqueId,System.currentTimeMillis())
|
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())
|
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
|
||||||
|
val player = e.hitEntity as Player
|
||||||
|
val shooter = e.entity.shooter as Player
|
||||||
|
val list = plugin.instance.list[player.uniqueId]
|
||||||
|
val dlist = plugin.instance.list[shooter.uniqueId]
|
||||||
|
if((dlist?.second != null) && (dlist.second != player.uniqueId)&&!combatData.instance.getOtherHit(shooter.world.name)){ e.isCancelled = true;return}
|
||||||
|
if(list?.second != null && list.second != shooter.uniqueId && !combatData.instance.getOtherHit(shooter.world.name)) {
|
||||||
|
shooter.sendMessage("${ChatColor.RED}${ChatColor.BOLD}해당 플레이어는 ${ChatColor.RESET}${ChatColor.WHITE}${Bukkit.getPlayer(
|
||||||
|
list.second!!)!!.name}${ChatColor.RED}${ChatColor.BOLD}님과 전투중입니다!")
|
||||||
|
e.isCancelled = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if(player.uniqueId == shooter.uniqueId) return
|
||||||
|
if(combatData.instance.getCanSeeWorld(e.entity.world.name)){
|
||||||
|
Bukkit.getOnlinePlayers().forEach{
|
||||||
|
if(it.uniqueId == shooter.uniqueId || it.uniqueId == player.uniqueId){
|
||||||
|
return@forEach
|
||||||
|
}
|
||||||
|
it.hidePlayer(plugin,shooter)
|
||||||
|
it.hidePlayer(plugin,player)
|
||||||
|
shooter.hidePlayer(plugin,it)
|
||||||
|
player.hidePlayer(plugin,it)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
plugin.instance.list[player.uniqueId] = Triple(true,shooter.uniqueId,System.currentTimeMillis())
|
||||||
|
plugin.instance.list[shooter.uniqueId] = Triple(true,player.uniqueId,System.currentTimeMillis())
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
fun onCommand(e:PlayerCommandPreprocessEvent){
|
fun onCommand(e:PlayerCommandPreprocessEvent){
|
||||||
if(listOf("l","lobby","home","spawn").any { e.message == it }){
|
if(listOf("l","lobby","home","spawn").any { e.message == it }){
|
||||||
@ -51,6 +99,14 @@ class CombatEvent(private val plugin:Main, private val combatData: CombatData):L
|
|||||||
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
|
e.player.health = 0.0
|
||||||
|
if(combatData.instance.getCanSeeWorld(e.player.world.name)){
|
||||||
|
Bukkit.getOnlinePlayers().forEach{
|
||||||
|
it.showPlayer(plugin,e.player)
|
||||||
|
it.showPlayer(plugin,e.player.killer!!)
|
||||||
|
e.player.showPlayer(plugin,it)
|
||||||
|
e.player.killer!!.showPlayer(plugin,it)
|
||||||
|
}
|
||||||
|
}
|
||||||
plugin.instance.list[e.player.uniqueId] = Triple(false,null,null)
|
plugin.instance.list[e.player.uniqueId] = Triple(false,null,null)
|
||||||
plugin.instance.list[list.second!!] = Triple(false,null,null)
|
plugin.instance.list[list.second!!] = Triple(false,null,null)
|
||||||
}
|
}
|
||||||
@ -59,6 +115,14 @@ class CombatEvent(private val plugin:Main, private val combatData: CombatData):L
|
|||||||
fun onDeath(e:PlayerDeathEvent){
|
fun onDeath(e:PlayerDeathEvent){
|
||||||
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
|
||||||
|
if(combatData.instance.getCanSeeWorld(e.player.world.name)){
|
||||||
|
Bukkit.getOnlinePlayers().forEach{
|
||||||
|
it.showPlayer(plugin,e.player)
|
||||||
|
it.showPlayer(plugin,e.player.killer!!)
|
||||||
|
e.player.showPlayer(plugin,it)
|
||||||
|
e.player.killer!!.showPlayer(plugin,it)
|
||||||
|
}
|
||||||
|
}
|
||||||
plugin.instance.list[e.player.uniqueId] = Triple(false,null,null)
|
plugin.instance.list[e.player.uniqueId] = Triple(false,null,null)
|
||||||
plugin.instance.list[list.second!!] = Triple(false,null,null)
|
plugin.instance.list[list.second!!] = Triple(false,null,null)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user