✨버그 수정
This commit is contained in:
parent
a86571b435
commit
49ecbfd718
@ -35,18 +35,10 @@ class Main:JavaPlugin() {
|
||||
schedule = this.server.scheduler.runTaskTimerAsynchronously(this, Runnable {
|
||||
list.forEach{
|
||||
if(list[it.key] == null) return@forEach
|
||||
if(!list[it.key]!!.first) return@forEach
|
||||
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){
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,13 @@
|
||||
package group.pvpconnect.combat_f.cmd
|
||||
|
||||
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
|
||||
import org.bukkit.plugin.Plugin
|
||||
|
||||
class CombatCmd(plugin:Plugin, val cd:CombatData) {
|
||||
class CombatCmd(plugin:Main, private val cd:CombatData) {
|
||||
init {
|
||||
plugin.apply {
|
||||
kommand {
|
||||
@ -30,16 +29,6 @@ class CombatCmd(plugin:Plugin, val cd:CombatData) {
|
||||
val world:World by it
|
||||
val bool = cd.instance.getCanSeeWorld(world.name)
|
||||
cd.instance.setCanSeeWorld(world.name,!bool)
|
||||
if(!bool){
|
||||
Bukkit.getOnlinePlayers().forEach{ pl1 ->
|
||||
Bukkit.getOnlinePlayers().forEach { pl2 ->
|
||||
if(pl1.world.name == world.name || pl2.world.name == world.name){
|
||||
pl1.showPlayer(plugin,pl2)
|
||||
pl2.showPlayer(plugin,pl1)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sender.sendMessage("${ChatColor.BOLD}${ChatColor.GOLD}[${ChatColor.GREEN}✓${ChatColor.GOLD}] ${ChatColor.WHITE}${world.name}의 컴뱃중 다른 사람 볼수있음이 ${if(!bool)"활성화 되었습니다!" else "비활성화 되었습니다!"}")
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import org.bukkit.plugin.Plugin
|
||||
import java.io.File
|
||||
|
||||
@Suppress("unused")
|
||||
class CombatData(val plugin:Plugin) {
|
||||
class CombatData(private val plugin:Plugin) {
|
||||
var instance:CombatData = this
|
||||
|
||||
private val file get() = File(plugin.dataFolder, "data.yml")
|
||||
|
@ -11,6 +11,7 @@ import org.bukkit.event.Listener
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent
|
||||
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
|
||||
|
||||
@ -30,18 +31,24 @@ class CombatEvent(private val plugin:Main, private val combatData: CombatData):L
|
||||
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(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.damager.sendMessage(
|
||||
"${ChatColor.RED}${ChatColor.BOLD}해당 플레이어는 ${ChatColor.RESET}${ChatColor.WHITE}${
|
||||
Bukkit.getPlayer(
|
||||
list.second!!
|
||||
)!!.name
|
||||
}${ChatColor.RED}${ChatColor.BOLD}님과 전투중입니다!"
|
||||
)
|
||||
e.isCancelled = true
|
||||
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
|
||||
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){
|
||||
it.hidePlayer(plugin,e.entity as Player)
|
||||
it.hidePlayer(plugin,e.damager as Player)
|
||||
(e.entity as Player).hidePlayer(plugin,it)
|
||||
(e.damager as Player).hidePlayer(plugin, it)
|
||||
}
|
||||
(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())
|
||||
@ -67,13 +74,14 @@ class CombatEvent(private val plugin:Main, private val combatData: CombatData):L
|
||||
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
|
||||
if(combatData.instance.getCanSeeWorld(player.world.name) && !plugin.instance.list[player.uniqueId]!!.first){
|
||||
Bukkit.getOnlinePlayers().forEach {
|
||||
if(it.name != player.name && it.name != shooter.name){
|
||||
it.hidePlayer(plugin, player)
|
||||
it.hidePlayer(plugin,shooter)
|
||||
player.hidePlayer(plugin,it)
|
||||
shooter.hidePlayer(plugin, it)
|
||||
}
|
||||
shooter.hidePlayer(plugin,it)
|
||||
player.hidePlayer(plugin,it)
|
||||
}
|
||||
}
|
||||
plugin.instance.list[player.uniqueId] = Triple(true,shooter.uniqueId,System.currentTimeMillis())
|
||||
@ -96,10 +104,15 @@ class CombatEvent(private val plugin:Main, private val combatData: CombatData):L
|
||||
e.player.killer = Bukkit.getPlayer(list.second!!)
|
||||
e.player.health = 0.0
|
||||
if(combatData.instance.getCanSeeWorld(e.player.world.name)){
|
||||
Bukkit.getOnlinePlayers().forEach{
|
||||
if(it.uniqueId == e.player.uniqueId || it.uniqueId == e.player.killer!!.uniqueId) return@forEach
|
||||
e.player.showPlayer(plugin,it)
|
||||
e.player.killer!!.showPlayer(plugin,it)
|
||||
Bukkit.getOnlinePlayers().forEach {
|
||||
val player = e.player
|
||||
val killer = e.player.killer!!
|
||||
if(it.name != player.name && it.name != killer.name){
|
||||
it.showPlayer(plugin, player)
|
||||
it.showPlayer(plugin,killer)
|
||||
player.showPlayer(plugin,it)
|
||||
killer.showPlayer(plugin, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin.instance.list[e.player.uniqueId] = Triple(false,null,null)
|
||||
@ -111,14 +124,32 @@ class CombatEvent(private val plugin:Main, private val combatData: CombatData):L
|
||||
val list = plugin.instance.list[e.player.uniqueId] ?: return
|
||||
if(!list.first) return
|
||||
if(combatData.instance.getCanSeeWorld(e.player.world.name)){
|
||||
Bukkit.getOnlinePlayers().forEach{
|
||||
if(it.uniqueId == e.player.uniqueId || it.uniqueId == e.player.killer!!.uniqueId) return@forEach
|
||||
e.player.showPlayer(plugin,it)
|
||||
e.player.killer!!.showPlayer(plugin,it)
|
||||
Bukkit.getOnlinePlayers().forEach {
|
||||
val player = e.player
|
||||
val killer = e.player.killer!!
|
||||
if(it.name != player.name && it.name != killer.name){
|
||||
it.showPlayer(plugin, player)
|
||||
it.showPlayer(plugin,killer)
|
||||
player.showPlayer(plugin,it)
|
||||
killer.showPlayer(plugin, it)
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin.instance.list[e.player.uniqueId] = Triple(false,null,null)
|
||||
plugin.instance.list[list.second!!] = Triple(false,null,null)
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
fun onChangeWorld(e:PlayerChangedWorldEvent){
|
||||
if(combatData.instance.getCanSeeWorld(e.player.world.name)){
|
||||
Bukkit.getOnlinePlayers().forEach{
|
||||
if(it.world.name != e.player.world.name) return@forEach
|
||||
if(plugin.instance.list[it.uniqueId]?.first == true){
|
||||
it.hidePlayer(plugin,e.player)
|
||||
e.player.hidePlayer(plugin,it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user