Skip to content
This repository has been archived by the owner on Sep 17, 2024. It is now read-only.

Commit

Permalink
Add kill and death event (commands and sound)
Browse files Browse the repository at this point in the history
  • Loading branch information
M4h45amu7x committed Mar 26, 2023
1 parent 37f46db commit 426fef7
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = "xyz.mahasamut.gun_game"
version = "1.0.0"
version = "1.0.1"

repositories {
mavenCentral()
Expand Down
19 changes: 15 additions & 4 deletions src/main/kotlin/xyz/mahasamut/gun_game/config/configs/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ class Config(path: Path, properties: BukkitYamlProperties) : BukkitYamlConfigura
var resetTierOnQuit = true
var setExpRelatedToTier = true
var autoRespawn = true
var killSound = Sound(true, "LEVEL_UP")
var deathSound = Sound(false, "ENDERMAN_DEATH")
var event = Event()

@ElementType(TierItem::class)
var tierItem = mapOf(
Expand All @@ -81,10 +80,22 @@ class Config(path: Path, properties: BukkitYamlProperties) : BukkitYamlConfigura
)

@ConfigurationElement
data class Sound(var enable: Boolean = false, var value: String = "")
class Event {
var kill = EventType(Sound(true, "LEVEL_UP"), Command(true, arrayListOf("CONSOLE:money give %player% 10")))
var death = EventType(Sound(false, "ENDERMAN_DEATH"), Command(true, arrayListOf("PLAYER:msg %player% LOL")))

@ConfigurationElement
class EventType(var sound: Sound = Sound(), var command: Command = Command())

@ConfigurationElement
class Sound(var enable: Boolean = false, var value: String = "")

@ConfigurationElement
class Command(var enable: Boolean = false, var value: ArrayList<String> = arrayListOf())
}

@ConfigurationElement
data class TierItem(
class TierItem(
var helmet: String = "",
var chestplate: String = "",
var leggings: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,15 @@ class GameplayListener : Listener {

if (!WhiteListUtils.isAllow(player)) return

if (config.gameplay.deathSound.enable) player.playSound(
player.location, Sound.valueOf(config.gameplay.deathSound.value), 1f, 1f
if (config.gameplay.event.death.sound.enable) player.playSound(
player.location, Sound.valueOf(config.gameplay.event.death.sound.value), 1f, 1f
)
if (config.gameplay.event.death.command.enable) {
for (command in config.gameplay.event.death.command.value) GunGame.instance.server.dispatchCommand(
if (command.startsWith("CONSOLE:")) GunGame.instance.server.consoleSender else player,
StringUtils.format(command, player)
)
}

event.deathMessage = null
event.drops.clear()
Expand All @@ -74,9 +80,15 @@ class GameplayListener : Listener {
PlayerUtils.setPlayerTierItems(killer, playerData.tier)
}
killer.sendMessage(StringUtils.format(message.killer, killer, player))
if (config.gameplay.killSound.enable) killer.playSound(
killer.location, Sound.valueOf(config.gameplay.killSound.value), 1f, 1f
if (config.gameplay.event.kill.sound.enable) killer.playSound(
killer.location, Sound.valueOf(config.gameplay.event.kill.sound.value), 1f, 1f
)
if (config.gameplay.event.kill.command.enable) {
for (command in config.gameplay.event.kill.command.value) GunGame.instance.server.dispatchCommand(
if (command.startsWith("CONSOLE:")) GunGame.instance.server.consoleSender else killer,
StringUtils.format(command, killer)
)
}

DataManager.increaseDeath(player)
player.sendMessage(StringUtils.format(message.killed, killer, player))
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: GunGame
author: M4h45amu7x
version: 1.0.0
version: 1.0.1
main: xyz.mahasamut.gun_game.GunGame
depend:
- PlaceholderAPI

0 comments on commit 426fef7

Please sign in to comment.