Spectator mode may be fixed now
This commit is contained in:
parent
f01bc4233d
commit
e4d8aaa2bc
4 changed files with 18 additions and 30 deletions
|
@ -12,6 +12,7 @@ import de.moritzruth.spigot_ttt.plugin
|
|||
import de.moritzruth.spigot_ttt.utils.call
|
||||
import de.moritzruth.spigot_ttt.utils.nextTick
|
||||
import org.bukkit.ChatColor
|
||||
import org.bukkit.GameMode
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.EventHandler
|
||||
|
@ -165,24 +166,23 @@ object GameListener : Listener {
|
|||
override fun onPacketSending(event: PacketEvent) {
|
||||
val packet = WrapperPlayServerPlayerInfo(event.packet)
|
||||
|
||||
if (packet.action == EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE ||
|
||||
packet.action == EnumWrappers.PlayerInfoAction.ADD_PLAYER) {
|
||||
if (
|
||||
packet.action == EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE ||
|
||||
packet.action == EnumWrappers.PlayerInfoAction.ADD_PLAYER
|
||||
) {
|
||||
packet.data = packet.data.map { info ->
|
||||
val tttPlayer = PlayerManager.tttPlayers.find { it.player.uniqueId == info.profile.uuid }
|
||||
|
||||
packet.data = packet.data.mapNotNull { info ->
|
||||
if (event.player.uniqueId == info.profile.uuid) info
|
||||
else {
|
||||
val tttPlayer = PlayerManager.tttPlayers.find { it.player.uniqueId == info.profile.uuid }
|
||||
|
||||
if (tttPlayer == null) info
|
||||
else PlayerInfoData(
|
||||
info.profile,
|
||||
info.latency,
|
||||
if (info.gameMode == EnumWrappers.NativeGameMode.SPECTATOR)
|
||||
EnumWrappers.NativeGameMode.SURVIVAL
|
||||
else info.gameMode,
|
||||
info.displayName
|
||||
)
|
||||
}
|
||||
if (tttPlayer == null) info
|
||||
else PlayerInfoData(
|
||||
info.profile,
|
||||
info.latency,
|
||||
if (event.player.uniqueId == info.profile.uuid) {
|
||||
if (event.player.gameMode == GameMode.SPECTATOR) EnumWrappers.NativeGameMode.SPECTATOR
|
||||
else EnumWrappers.NativeGameMode.SURVIVAL
|
||||
} else EnumWrappers.NativeGameMode.SURVIVAL,
|
||||
info.displayName
|
||||
)
|
||||
}.toMutableList()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,8 +43,6 @@ object Ninja: TTTClass(
|
|||
tttPlayer.player.velocity = Vector(current.x * 3, 0.8, current.z * 3)
|
||||
state.jumpsRemaining -= 1
|
||||
|
||||
println(state.jumpsRemaining)
|
||||
|
||||
if (state.jumpsRemaining == 0) {
|
||||
tttPlayer.player.allowFlight = false
|
||||
|
||||
|
|
|
@ -1,10 +0,0 @@
|
|||
package de.moritzruth.spigot_ttt.game.players
|
||||
|
||||
import org.bukkit.event.entity.EntityDamageEvent
|
||||
|
||||
data class DamageInfo(
|
||||
val damager: TTTPlayer,
|
||||
val deathReason: DeathReason,
|
||||
val expectedDamageCause: EntityDamageEvent.DamageCause = EntityDamageEvent.DamageCause.CUSTOM,
|
||||
val scream: Boolean = true
|
||||
)
|
|
@ -112,7 +112,7 @@ object PlayerManager {
|
|||
playersWithoutRole.remove(player)
|
||||
}
|
||||
|
||||
for (index in 1..Settings.traitorCount) createTTTPlayer(Role.JACKAL)
|
||||
for (index in 1..Settings.traitorCount) createTTTPlayer(Role.TRAITOR)
|
||||
|
||||
if (Settings.detectiveEnabled) createTTTPlayer(Role.DETECTIVE)
|
||||
|
||||
|
|
Reference in a new issue