mirror of
				https://github.com/GayPizzaSpecifications/foundation.git
				synced 2025-11-04 11:39:39 +00:00 
			
		
		
		
	More stuff.
This commit is contained in:
		@ -2,14 +2,14 @@ package gay.pizza.foundation.chaos
 | 
			
		||||
 | 
			
		||||
import com.charleskorn.kaml.Yaml
 | 
			
		||||
import gay.pizza.foundation.chaos.model.ChaosConfig
 | 
			
		||||
import gay.pizza.foundation.common.BaseFoundationPlugin
 | 
			
		||||
import gay.pizza.foundation.common.FoundationCoreLoader
 | 
			
		||||
import gay.pizza.foundation.shared.PluginMainClass
 | 
			
		||||
import gay.pizza.foundation.shared.copyDefaultConfig
 | 
			
		||||
import org.bukkit.plugin.java.JavaPlugin
 | 
			
		||||
import kotlin.io.path.inputStream
 | 
			
		||||
 | 
			
		||||
@PluginMainClass
 | 
			
		||||
class FoundationChaosPlugin : JavaPlugin() {
 | 
			
		||||
class FoundationChaosPlugin : BaseFoundationPlugin() {
 | 
			
		||||
  lateinit var config: ChaosConfig
 | 
			
		||||
 | 
			
		||||
  val controller by lazy {
 | 
			
		||||
@ -24,7 +24,6 @@ class FoundationChaosPlugin : JavaPlugin() {
 | 
			
		||||
      "chaos.yaml"
 | 
			
		||||
    )
 | 
			
		||||
    config = Yaml.default.decodeFromStream(ChaosConfig.serializer(), configPath.inputStream())
 | 
			
		||||
    val chaosCommand = getCommand("chaos")!!
 | 
			
		||||
    chaosCommand.setExecutor(ChaosToggleCommand())
 | 
			
		||||
    registerCommandExecutor("chaos", ChaosToggleCommand())
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -8,6 +8,7 @@ object ChaosModules {
 | 
			
		||||
    TeleportAllEntitiesNearestPlayer(plugin),
 | 
			
		||||
    KillRandomPlayer(plugin),
 | 
			
		||||
    TntAllPlayers(plugin),
 | 
			
		||||
    MegaTnt(plugin)
 | 
			
		||||
  )
 | 
			
		||||
    MegaTnt(plugin),
 | 
			
		||||
    PlayerSwap(plugin)
 | 
			
		||||
  ).shuffled()
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,30 @@
 | 
			
		||||
package gay.pizza.foundation.chaos.modules
 | 
			
		||||
 | 
			
		||||
import org.bukkit.Location
 | 
			
		||||
import org.bukkit.entity.Player
 | 
			
		||||
import org.bukkit.plugin.Plugin
 | 
			
		||||
 | 
			
		||||
class PlayerSwap(val plugin: Plugin) : ChaosModule {
 | 
			
		||||
  override fun id(): String = "player-swap"
 | 
			
		||||
  override fun name(): String = "Player Swap"
 | 
			
		||||
  override fun what(): String = "Randomly swaps player positions."
 | 
			
		||||
 | 
			
		||||
  override fun activate() {
 | 
			
		||||
    for (world in plugin.server.worlds) {
 | 
			
		||||
      if (world.playerCount <= 0) {
 | 
			
		||||
        continue
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      val players = world.players
 | 
			
		||||
      val map = mutableMapOf<Player, Location>()
 | 
			
		||||
      for (player in players) {
 | 
			
		||||
        val next = players.filter { it != player }.randomOrNull() ?: continue
 | 
			
		||||
        map[player] = next.location.clone()
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      for ((player, next) in map) {
 | 
			
		||||
        player.teleport(next)
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user