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.call
|
||||||
import de.moritzruth.spigot_ttt.utils.nextTick
|
import de.moritzruth.spigot_ttt.utils.nextTick
|
||||||
import org.bukkit.ChatColor
|
import org.bukkit.ChatColor
|
||||||
|
import org.bukkit.GameMode
|
||||||
import org.bukkit.Material
|
import org.bukkit.Material
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
import org.bukkit.event.EventHandler
|
import org.bukkit.event.EventHandler
|
||||||
|
@ -165,24 +166,23 @@ object GameListener : Listener {
|
||||||
override fun onPacketSending(event: PacketEvent) {
|
override fun onPacketSending(event: PacketEvent) {
|
||||||
val packet = WrapperPlayServerPlayerInfo(event.packet)
|
val packet = WrapperPlayServerPlayerInfo(event.packet)
|
||||||
|
|
||||||
if (packet.action == EnumWrappers.PlayerInfoAction.UPDATE_GAME_MODE ||
|
if (
|
||||||
packet.action == EnumWrappers.PlayerInfoAction.ADD_PLAYER) {
|
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 (tttPlayer == null) info
|
||||||
if (event.player.uniqueId == info.profile.uuid) info
|
else PlayerInfoData(
|
||||||
else {
|
info.profile,
|
||||||
val tttPlayer = PlayerManager.tttPlayers.find { it.player.uniqueId == info.profile.uuid }
|
info.latency,
|
||||||
|
if (event.player.uniqueId == info.profile.uuid) {
|
||||||
if (tttPlayer == null) info
|
if (event.player.gameMode == GameMode.SPECTATOR) EnumWrappers.NativeGameMode.SPECTATOR
|
||||||
else PlayerInfoData(
|
else EnumWrappers.NativeGameMode.SURVIVAL
|
||||||
info.profile,
|
} else EnumWrappers.NativeGameMode.SURVIVAL,
|
||||||
info.latency,
|
info.displayName
|
||||||
if (info.gameMode == EnumWrappers.NativeGameMode.SPECTATOR)
|
)
|
||||||
EnumWrappers.NativeGameMode.SURVIVAL
|
|
||||||
else info.gameMode,
|
|
||||||
info.displayName
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}.toMutableList()
|
}.toMutableList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,8 +43,6 @@ object Ninja: TTTClass(
|
||||||
tttPlayer.player.velocity = Vector(current.x * 3, 0.8, current.z * 3)
|
tttPlayer.player.velocity = Vector(current.x * 3, 0.8, current.z * 3)
|
||||||
state.jumpsRemaining -= 1
|
state.jumpsRemaining -= 1
|
||||||
|
|
||||||
println(state.jumpsRemaining)
|
|
||||||
|
|
||||||
if (state.jumpsRemaining == 0) {
|
if (state.jumpsRemaining == 0) {
|
||||||
tttPlayer.player.allowFlight = false
|
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)
|
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)
|
if (Settings.detectiveEnabled) createTTTPlayer(Role.DETECTIVE)
|
||||||
|
|
||||||
|
|
Reference in a new issue