Skip to content

Commit e752cd2

Browse files
committed
6.0.12 Update "stopsound"
1 parent fa72f1b commit e752cd2

File tree

2 files changed

+31
-0
lines changed
  • module/module-kether/src/main/kotlin/taboolib/module/kether/action/game
  • platform/platform-bukkit/src/main/kotlin/taboolib/platform/type

2 files changed

+31
-0
lines changed

module/module-kether/src/main/kotlin/taboolib/module/kether/action/game/Actions.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,20 @@ internal object Actions {
121121
}
122122
}
123123
}
124+
125+
@PlatformSide([Platform.BUKKIT])
126+
@KetherParser(["stopsound"])
127+
fun actionStopSound() = combinationParser {
128+
it.group(
129+
text(),
130+
).apply(it) { sound ->
131+
now {
132+
if (sound.startsWith("resource:")) {
133+
player().playSoundResource(player().location, sound.substringAfter("resource:"), -1f, -1f)
134+
} else {
135+
player().playSound(player().location, sound.replace('.', '_').uppercase(), -1f, -1f)
136+
}
137+
}
138+
}
139+
}
124140
}

platform/platform-bukkit/src/main/kotlin/taboolib/platform/type/BukkitPlayer.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,10 +313,18 @@ class BukkitPlayer(val player: Player) : ProxyPlayer {
313313
}
314314

315315
override fun playSound(location: Location, sound: String, volume: Float, pitch: Float) {
316+
if (volume == -1f && pitch == -1f) {
317+
player.stopSound(sound)
318+
return
319+
}
316320
player.playSound(location.toBukkitLocation(), Sound.valueOf(sound), volume, pitch)
317321
}
318322

319323
override fun playSoundResource(location: Location, sound: String, volume: Float, pitch: Float) {
324+
if (volume == -1f && pitch == -1f) {
325+
player.stopSound(sound)
326+
return
327+
}
320328
player.playSound(location.toBukkitLocation(), sound, volume, pitch)
321329
}
322330

@@ -380,9 +388,11 @@ class BukkitPlayer(val player: Player) : ProxyPlayer {
380388
data.size
381389
)
382390
}
391+
383392
is ProxyParticle.DustData -> {
384393
Particle.DustOptions(Color.fromRGB(data.color.red, data.color.green, data.color.blue), data.size)
385394
}
395+
386396
is ProxyParticle.ItemData -> {
387397
val item = ItemStack(Material.valueOf(data.material))
388398
val itemMeta = item.itemMeta!!
@@ -398,26 +408,31 @@ class BukkitPlayer(val player: Player) : ProxyPlayer {
398408
}
399409
item
400410
}
411+
401412
is ProxyParticle.BlockData -> {
402413
if (bukkitParticle.dataType == MaterialData::class.java) {
403414
MaterialData(Material.valueOf(data.material), data.data.toByte())
404415
} else {
405416
Material.valueOf(data.material).createBlockData()
406417
}
407418
}
419+
408420
is ProxyParticle.VibrationData -> {
409421
Vibration(
410422
data.origin.toBukkitLocation(), when (val destination = data.destination) {
411423
is ProxyParticle.VibrationData.LocationDestination -> {
412424
Vibration.Destination.BlockDestination(destination.location.toBukkitLocation())
413425
}
426+
414427
is ProxyParticle.VibrationData.EntityDestination -> {
415428
Vibration.Destination.EntityDestination(Bukkit.getEntity(destination.entity)!!)
416429
}
430+
417431
else -> error("out of case")
418432
}, data.arrivalTime
419433
)
420434
}
435+
421436
else -> null
422437
}
423438
player.spawnParticle(bukkitParticle, location.toBukkitLocation(), count, offset.x, offset.y, offset.z, speed, bukkitData)

0 commit comments

Comments
 (0)