mirror of
https://github.com/GayPizzaSpecifications/foundation.git
synced 2025-08-03 13:31:32 +00:00
chaos: mega-tnt and chunk exporter fixes
This commit is contained in:
@ -3,5 +3,6 @@ plugins {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(project(":common-plugin"))
|
||||
compileOnly(project(":foundation-core"))
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
package gay.pizza.foundation.chaos
|
||||
|
||||
import gay.pizza.foundation.chaos.model.ChaosConfig
|
||||
import gay.pizza.foundation.chaos.model.ChaosModuleConfig
|
||||
import gay.pizza.foundation.chaos.modules.ChaosModule
|
||||
import gay.pizza.foundation.chaos.modules.ChaosModules
|
||||
import net.kyori.adventure.text.Component
|
||||
import org.bukkit.boss.BarColor
|
||||
import org.bukkit.boss.BarStyle
|
||||
import org.bukkit.boss.BossBar
|
||||
@ -28,7 +28,7 @@ class ChaosController(val plugin: Plugin, val config: ChaosConfig) : Listener {
|
||||
if (state.get()) {
|
||||
return
|
||||
}
|
||||
allowedModules = allModules.filter { config.enable[it.id()] ?: true }
|
||||
allowedModules = filterEnabledModules()
|
||||
state.set(true)
|
||||
selectorController.schedule()
|
||||
bossBar = plugin.server.createBossBar("Chaos Mode", BarColor.RED, BarStyle.SOLID)
|
||||
@ -37,6 +37,11 @@ class ChaosController(val plugin: Plugin, val config: ChaosConfig) : Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private fun filterEnabledModules(): List<ChaosModule> = allModules.filter { module ->
|
||||
val moduleConfig = config.modules[module.id()] ?: config.defaultModuleConfiguration
|
||||
moduleConfig.enabled
|
||||
}
|
||||
|
||||
fun activateAll() {
|
||||
for (module in allowedModules) {
|
||||
if (activeModules.contains(module)) {
|
||||
|
@ -10,7 +10,7 @@ class ChaosSelectorController(val controller: ChaosController, val plugin: Plugi
|
||||
cancel()
|
||||
task = plugin.server.scheduler.runTaskTimer(controller.plugin, { ->
|
||||
select()
|
||||
}, controller.config.selectionTimerTicks, controller.config.selectionTimerTicks)
|
||||
}, 20, controller.config.selection.timerTicks)
|
||||
}
|
||||
|
||||
fun select() {
|
||||
|
@ -5,6 +5,17 @@ import kotlinx.serialization.Serializable
|
||||
@Serializable
|
||||
class ChaosConfig(
|
||||
val allowed: Boolean = true,
|
||||
val enable: Map<String, Boolean> = mapOf(),
|
||||
val selectionTimerTicks: Long
|
||||
val defaultModuleConfiguration: ChaosModuleConfig,
|
||||
val modules: Map<String, ChaosModuleConfig> = emptyMap(),
|
||||
val selection: ChaosSelectionConfig
|
||||
)
|
||||
|
||||
@Serializable
|
||||
class ChaosModuleConfig(
|
||||
val enabled: Boolean
|
||||
)
|
||||
|
||||
@Serializable
|
||||
class ChaosSelectionConfig(
|
||||
val timerTicks: Long
|
||||
)
|
||||
|
@ -7,6 +7,7 @@ object ChaosModules {
|
||||
NearestPlayerEntitySpawn(plugin),
|
||||
TeleportAllEntitiesNearestPlayer(plugin),
|
||||
KillRandomPlayer(plugin),
|
||||
TntAllPlayers(plugin)
|
||||
TntAllPlayers(plugin),
|
||||
MegaTnt(plugin)
|
||||
)
|
||||
}
|
||||
|
@ -0,0 +1,19 @@
|
||||
package gay.pizza.foundation.chaos.modules
|
||||
|
||||
import gay.pizza.foundation.common.spawn
|
||||
import org.bukkit.entity.TNTPrimed
|
||||
import org.bukkit.plugin.Plugin
|
||||
|
||||
class MegaTnt(val plugin: Plugin) : ChaosModule {
|
||||
override fun id(): String = "mega-tnt"
|
||||
override fun name(): String = "Mega TNT"
|
||||
override fun what(): String = "Spawn a massive TNT explosion"
|
||||
|
||||
override fun activate() {
|
||||
for (player in plugin.server.onlinePlayers) {
|
||||
val tnt = player.spawn(TNTPrimed::class)
|
||||
tnt.fuseTicks = 1
|
||||
tnt.yield = 10.0f
|
||||
}
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package gay.pizza.foundation.chaos.modules
|
||||
|
||||
import gay.pizza.foundation.common.spawn
|
||||
import org.bukkit.entity.TNTPrimed
|
||||
import org.bukkit.plugin.Plugin
|
||||
|
||||
@ -10,7 +11,7 @@ class TntAllPlayers(val plugin: Plugin) : ChaosModule {
|
||||
|
||||
override fun activate() {
|
||||
for (player in plugin.server.onlinePlayers) {
|
||||
player.world.spawn(player.location, TNTPrimed::class.java)
|
||||
player.spawn(TNTPrimed::class)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,16 @@
|
||||
# Whether enabling the chaos mode is allowed.
|
||||
allowed: false
|
||||
# Chaos modules enablement.
|
||||
enable:
|
||||
nearest-player-entity-spawn: true
|
||||
teleport-all-entities-nearest-player: true
|
||||
selectionTimerTicks: 100
|
||||
# The default module configuration for modules with
|
||||
# no explicit configuration.
|
||||
defaultModuleConfiguration:
|
||||
enabled: true
|
||||
# Module configuration.
|
||||
modules:
|
||||
nearest-player-entity-spawn:
|
||||
enabled: true
|
||||
teleport-all-entities-nearest-player:
|
||||
enabled: true
|
||||
# Chaos selection configuration.
|
||||
selection:
|
||||
# The number of ticks before a new selection is made.
|
||||
timerTicks: 6000
|
||||
|
Reference in New Issue
Block a user