1
0
Fork 0

Change the way the Cloaking Device works

This commit is contained in:
Moritz Ruth 2020-06-14 00:42:11 +02:00
parent 4246e957c1
commit b60b9eddb1
No known key found for this signature in database
GPG key ID: AFD57E23E753841B
2 changed files with 4 additions and 30 deletions

View file

@ -1,11 +1,11 @@
package de.moritzruth.spigot_ttt.game.items.impl
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.items.Buyable
import de.moritzruth.spigot_ttt.game.items.Selectable
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.utils.applyMeta
import de.moritzruth.spigot_ttt.utils.startItemDamageProgress
@ -19,9 +19,7 @@ import org.bukkit.potion.PotionEffect
import org.bukkit.potion.PotionEffectType
import org.bukkit.scheduler.BukkitTask
object CloakingDevice: TTTItem,
Buyable,
Selectable {
object CloakingDevice: TTTItem, Buyable, Selectable {
override val itemStack = ItemStack(Resourcepack.Items.cloakingDevice).applyMeta {
setDisplayName("${ChatColor.GRAY}${ChatColor.MAGIC}###${ChatColor.RESET}${ChatColor.GRAY} Cloaking Device ${ChatColor.MAGIC}###")
lore = listOf(
@ -49,13 +47,10 @@ object CloakingDevice: TTTItem,
isSprinting = false
walkSpeed = 0.1F
// To prevent jumping (amplifier 200)
addPotionEffect(PotionEffect(PotionEffectType.JUMP, 1000000, 200, false, false))
addPotionEffect(PotionEffect(PotionEffectType.INVISIBILITY, 1000000, 0, false, false))
playSound(location, Resourcepack.Sounds.Item.CloakingDevice.on, SoundCategory.PLAYERS, 1F, 1F)
}
tttPlayer.invisible = true
state.enabled = true
state.itemStack = itemStack
}
@ -66,11 +61,10 @@ object CloakingDevice: TTTItem,
tttPlayer.player.apply {
walkSpeed = 0.2F
removePotionEffect(PotionEffectType.JUMP)
removePotionEffect(PotionEffectType.INVISIBILITY)
playSound(location, Resourcepack.Sounds.Item.CloakingDevice.off, SoundCategory.PLAYERS, 1F, 1F)
}
tttPlayer.invisible = false
state.enabled = false
val itemStack = state.itemStack

View file

@ -14,8 +14,6 @@ import de.moritzruth.spigot_ttt.plugin
import de.moritzruth.spigot_ttt.utils.*
import org.bukkit.*
import org.bukkit.entity.Player
import org.bukkit.potion.PotionEffect
import org.bukkit.potion.PotionEffectType
import org.bukkit.scheduler.BukkitTask
import kotlin.properties.Delegates
@ -39,22 +37,6 @@ class TTTPlayer(player: Player, role: Role) {
}
var credits by Delegates.observable(Settings.initialCredits) { _, _, _ -> scoreboard.updateCredits() }
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
private var staminaCooldown: Int = 0
@ -198,8 +180,6 @@ class TTTPlayer(player: Player, role: Role) {
}
}
invisible = false
player.gameMode = GameMode.SURVIVAL
player.activePotionEffects.forEach { player.removePotionEffect(it.type) }
player.health = 20.0