4 Commits

Author SHA1 Message Date
90666e2d20 Merge pull request 'Add teamsOnSameLine for Arena Monochrome' (#5) from TNTLeague/TeamsOnSameLine into main
All checks were successful
SteamWarCI Build successful
Reviewed-on: #5
Reviewed-by: Chaoscaot <max@chaoscaot.de>
Reviewed-by: YoyoNow <yoyonow@noreply.localhost>
2025-01-29 21:20:19 +01:00
77c6f41f1a Merge branch 'main' into TNTLeague/TeamsOnSameLine
All checks were successful
SteamWarCI Build successful
2025-01-29 21:19:35 +01:00
315674ebd8 Merge branch 'main' into TNTLeague/TeamsOnSameLine
All checks were successful
SteamWarCI Build successful
2025-01-24 22:44:47 +01:00
658dcd024d Add teamsOnSameLine for Arena Monochrome 2025-01-20 01:04:09 +01:00
2 changed files with 14 additions and 9 deletions

View File

@ -29,6 +29,7 @@ import org.bukkit.configuration.ConfigurationSection
import org.bukkit.configuration.file.YamlConfiguration import org.bukkit.configuration.file.YamlConfiguration
import org.bukkit.entity.WanderingTrader import org.bukkit.entity.WanderingTrader
import java.io.File import java.io.File
import kotlin.math.abs
import kotlin.properties.Delegates import kotlin.properties.Delegates
val world by lazy { plugin.server.worlds.first()!! } val world by lazy { plugin.server.worlds.first()!! }
@ -56,6 +57,7 @@ object TNTLeagueWorldConfig {
lateinit var blueTeam: TeamConfig lateinit var blueTeam: TeamConfig
lateinit var redTeam: TeamConfig lateinit var redTeam: TeamConfig
lateinit var lobby: Location lateinit var lobby: Location
var teamsOnSameLine by Delegates.notNull<Boolean>()
lateinit var targetMaterial: Material lateinit var targetMaterial: Material
var minHeight by Delegates.notNull<Int>() var minHeight by Delegates.notNull<Int>()
var target by Delegates.notNull<Int>() var target by Delegates.notNull<Int>()
@ -64,6 +66,7 @@ object TNTLeagueWorldConfig {
try { try {
blueTeam = TeamConfig.fromConfig(config.getConfigurationSection("blueTeam")!!) blueTeam = TeamConfig.fromConfig(config.getConfigurationSection("blueTeam")!!)
redTeam = TeamConfig.fromConfig(config.getConfigurationSection("redTeam")!!) redTeam = TeamConfig.fromConfig(config.getConfigurationSection("redTeam")!!)
teamsOnSameLine = abs(blueTeam.spawnLocation.blockX - redTeam.spawnLocation.blockX) < 20
lobby = config.getWorldLocation("lobby", blueTeam.spawnLocation.clone().add(redTeam.spawnLocation).multiply(0.5)) lobby = config.getWorldLocation("lobby", blueTeam.spawnLocation.clone().add(redTeam.spawnLocation).multiply(0.5))
targetMaterial = Material.matchMaterial(config.getString("targetMaterial", "IRON_BLOCK")!!)!! targetMaterial = Material.matchMaterial(config.getString("targetMaterial", "IRON_BLOCK")!!)!!
minHeight = config.getInt("minHeight", 0) minHeight = config.getInt("minHeight", 0)

View File

@ -36,13 +36,13 @@ import org.bukkit.event.player.PlayerInteractEntityEvent
import org.bukkit.event.player.PlayerJoinEvent import org.bukkit.event.player.PlayerJoinEvent
import org.bukkit.event.player.PlayerMoveEvent import org.bukkit.event.player.PlayerMoveEvent
object IngameListener: Listener { object IngameListener : Listener {
@EventHandler @EventHandler
fun onEntityInteract(e: PlayerInteractEntityEvent) { fun onEntityInteract(e: PlayerInteractEntityEvent) {
if (e.player.gameMode == GameMode.SPECTATOR) return if (e.player.gameMode == GameMode.SPECTATOR) return
if(e.rightClicked.type == EntityType.WANDERING_TRADER) { if (e.rightClicked.type == EntityType.WANDERING_TRADER) {
e.isCancelled = true e.isCancelled = true
DealerInventory(e.player).open() DealerInventory(e.player).open()
} }
@ -64,18 +64,20 @@ object IngameListener: Listener {
@EventHandler @EventHandler
fun onMove(e: PlayerMoveEvent) { fun onMove(e: PlayerMoveEvent) {
if (TNTLeagueGame.getTeam(e.player) != null) { if (TNTLeagueGame.getTeam(e.player) == null) return
if (e.to.blockX >= TNTLeagueWorldConfig.lobby.blockX && e.to.blockX <= TNTLeagueWorldConfig.lobby.blockX + 1 || if (e.to.blockZ >= TNTLeagueWorldConfig.lobby.blockZ && e.to.blockZ <= TNTLeagueWorldConfig.lobby.blockZ + 1) {
e.to.blockZ >= TNTLeagueWorldConfig.lobby.blockZ && e.to.blockZ <= TNTLeagueWorldConfig.lobby.blockZ + 1) {
e.isCancelled = true e.isCancelled = true
} }
if (!TNTLeagueWorldConfig.teamsOnSameLine && e.to.blockX >= TNTLeagueWorldConfig.lobby.blockX && e.to.blockX <= TNTLeagueWorldConfig.lobby.blockX + 1) {
e.isCancelled = true
} }
} }
@EventHandler @EventHandler
fun onPickupCoins(e: PlayerAttemptPickupItemEvent) { fun onPickupCoins(e: PlayerAttemptPickupItemEvent) {
if (e.item.itemStack.isSimilar(DealerInventory.coins)) { if (e.item.itemStack.isSimilar(DealerInventory.coins)) {
TNTLeagueGame.getTeam(e.player)?.coins = e.item.itemStack.amount + (TNTLeagueGame.getTeam(e.player)?.coins ?: 0) TNTLeagueGame.getTeam(e.player)?.coins =
e.item.itemStack.amount + (TNTLeagueGame.getTeam(e.player)?.coins ?: 0)
e.item.itemStack.amount = 0 e.item.itemStack.amount = 0
e.isCancelled = true e.isCancelled = true
@ -91,7 +93,7 @@ object IngameListener: Listener {
} }
private fun <K, T> Map<K?, T>.filterKeysNotNull(destination: MutableMap<K, T> = mutableMapOf()): Map<K, T> { private fun <K, T> Map<K?, T>.filterKeysNotNull(destination: MutableMap<K, T> = mutableMapOf()): Map<K, T> {
this.forEach { (t, u) -> if(t != null) destination[t] = u } this.forEach { (t, u) -> if (t != null) destination[t] = u }
return destination return destination
} }
} }