Change the way the Cloaking Device works
This commit is contained in:
parent
4246e957c1
commit
b60b9eddb1
2 changed files with 4 additions and 30 deletions
|
@ -1,11 +1,11 @@
|
||||||
package de.moritzruth.spigot_ttt.game.items.impl
|
package de.moritzruth.spigot_ttt.game.items.impl
|
||||||
|
|
||||||
import de.moritzruth.spigot_ttt.Resourcepack
|
import de.moritzruth.spigot_ttt.Resourcepack
|
||||||
import de.moritzruth.spigot_ttt.game.items.TTTItemListener
|
|
||||||
import de.moritzruth.spigot_ttt.game.GameEndEvent
|
import de.moritzruth.spigot_ttt.game.GameEndEvent
|
||||||
import de.moritzruth.spigot_ttt.game.items.Buyable
|
import de.moritzruth.spigot_ttt.game.items.Buyable
|
||||||
import de.moritzruth.spigot_ttt.game.items.Selectable
|
import de.moritzruth.spigot_ttt.game.items.Selectable
|
||||||
import de.moritzruth.spigot_ttt.game.items.TTTItem
|
import de.moritzruth.spigot_ttt.game.items.TTTItem
|
||||||
|
import de.moritzruth.spigot_ttt.game.items.TTTItemListener
|
||||||
import de.moritzruth.spigot_ttt.game.players.*
|
import de.moritzruth.spigot_ttt.game.players.*
|
||||||
import de.moritzruth.spigot_ttt.utils.applyMeta
|
import de.moritzruth.spigot_ttt.utils.applyMeta
|
||||||
import de.moritzruth.spigot_ttt.utils.startItemDamageProgress
|
import de.moritzruth.spigot_ttt.utils.startItemDamageProgress
|
||||||
|
@ -19,9 +19,7 @@ import org.bukkit.potion.PotionEffect
|
||||||
import org.bukkit.potion.PotionEffectType
|
import org.bukkit.potion.PotionEffectType
|
||||||
import org.bukkit.scheduler.BukkitTask
|
import org.bukkit.scheduler.BukkitTask
|
||||||
|
|
||||||
object CloakingDevice: TTTItem,
|
object CloakingDevice: TTTItem, Buyable, Selectable {
|
||||||
Buyable,
|
|
||||||
Selectable {
|
|
||||||
override val itemStack = ItemStack(Resourcepack.Items.cloakingDevice).applyMeta {
|
override val itemStack = ItemStack(Resourcepack.Items.cloakingDevice).applyMeta {
|
||||||
setDisplayName("${ChatColor.GRAY}${ChatColor.MAGIC}###${ChatColor.RESET}${ChatColor.GRAY} Cloaking Device ${ChatColor.MAGIC}###")
|
setDisplayName("${ChatColor.GRAY}${ChatColor.MAGIC}###${ChatColor.RESET}${ChatColor.GRAY} Cloaking Device ${ChatColor.MAGIC}###")
|
||||||
lore = listOf(
|
lore = listOf(
|
||||||
|
@ -49,13 +47,10 @@ object CloakingDevice: TTTItem,
|
||||||
isSprinting = false
|
isSprinting = false
|
||||||
walkSpeed = 0.1F
|
walkSpeed = 0.1F
|
||||||
|
|
||||||
// To prevent jumping (amplifier 200)
|
addPotionEffect(PotionEffect(PotionEffectType.INVISIBILITY, 1000000, 0, false, false))
|
||||||
addPotionEffect(PotionEffect(PotionEffectType.JUMP, 1000000, 200, false, false))
|
|
||||||
|
|
||||||
playSound(location, Resourcepack.Sounds.Item.CloakingDevice.on, SoundCategory.PLAYERS, 1F, 1F)
|
playSound(location, Resourcepack.Sounds.Item.CloakingDevice.on, SoundCategory.PLAYERS, 1F, 1F)
|
||||||
}
|
}
|
||||||
|
|
||||||
tttPlayer.invisible = true
|
|
||||||
state.enabled = true
|
state.enabled = true
|
||||||
state.itemStack = itemStack
|
state.itemStack = itemStack
|
||||||
}
|
}
|
||||||
|
@ -66,11 +61,10 @@ object CloakingDevice: TTTItem,
|
||||||
|
|
||||||
tttPlayer.player.apply {
|
tttPlayer.player.apply {
|
||||||
walkSpeed = 0.2F
|
walkSpeed = 0.2F
|
||||||
removePotionEffect(PotionEffectType.JUMP)
|
removePotionEffect(PotionEffectType.INVISIBILITY)
|
||||||
playSound(location, Resourcepack.Sounds.Item.CloakingDevice.off, SoundCategory.PLAYERS, 1F, 1F)
|
playSound(location, Resourcepack.Sounds.Item.CloakingDevice.off, SoundCategory.PLAYERS, 1F, 1F)
|
||||||
}
|
}
|
||||||
|
|
||||||
tttPlayer.invisible = false
|
|
||||||
state.enabled = false
|
state.enabled = false
|
||||||
|
|
||||||
val itemStack = state.itemStack
|
val itemStack = state.itemStack
|
||||||
|
|
|
@ -14,8 +14,6 @@ import de.moritzruth.spigot_ttt.plugin
|
||||||
import de.moritzruth.spigot_ttt.utils.*
|
import de.moritzruth.spigot_ttt.utils.*
|
||||||
import org.bukkit.*
|
import org.bukkit.*
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
import org.bukkit.potion.PotionEffect
|
|
||||||
import org.bukkit.potion.PotionEffectType
|
|
||||||
import org.bukkit.scheduler.BukkitTask
|
import org.bukkit.scheduler.BukkitTask
|
||||||
import kotlin.properties.Delegates
|
import kotlin.properties.Delegates
|
||||||
|
|
||||||
|
@ -39,22 +37,6 @@ class TTTPlayer(player: Player, role: Role) {
|
||||||
}
|
}
|
||||||
var credits by Delegates.observable(Settings.initialCredits) { _, _, _ -> scoreboard.updateCredits() }
|
var credits by Delegates.observable(Settings.initialCredits) { _, _, _ -> scoreboard.updateCredits() }
|
||||||
val boughtItems = mutableListOf<TTTItem>()
|
val boughtItems = mutableListOf<TTTItem>()
|
||||||
|
|
||||||
var invisible by Delegates.observable(false) { _, _, value ->
|
|
||||||
if (value) {
|
|
||||||
PlayerManager.tttPlayers.forEach {
|
|
||||||
if (it.alive && it.role != role) {
|
|
||||||
it.player.hidePlayer(plugin, player)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// for the translucent effect seen by teammates
|
|
||||||
player.addPotionEffect(PotionEffect(PotionEffectType.INVISIBILITY, 1000000, 0, false, false))
|
|
||||||
} else {
|
|
||||||
plugin.server.onlinePlayers.forEach { it.showPlayer(plugin, player) }
|
|
||||||
player.removePotionEffect(PotionEffectType.INVISIBILITY)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var damageInfo: DamageInfo? = null
|
var damageInfo: DamageInfo? = null
|
||||||
|
|
||||||
private var staminaCooldown: Int = 0
|
private var staminaCooldown: Int = 0
|
||||||
|
@ -198,8 +180,6 @@ class TTTPlayer(player: Player, role: Role) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
invisible = false
|
|
||||||
|
|
||||||
player.gameMode = GameMode.SURVIVAL
|
player.gameMode = GameMode.SURVIVAL
|
||||||
player.activePotionEffects.forEach { player.removePotionEffect(it.type) }
|
player.activePotionEffects.forEach { player.removePotionEffect(it.type) }
|
||||||
player.health = 20.0
|
player.health = 20.0
|
||||||
|
|
Reference in a new issue