Compare commits
4 Commits
b3ddc04830
...
90666e2d20
| Author | SHA1 | Date | |
|---|---|---|---|
| 90666e2d20 | |||
| 77c6f41f1a | |||
| 315674ebd8 | |||
| 658dcd024d |
@ -29,6 +29,7 @@ import org.bukkit.configuration.ConfigurationSection
|
||||
import org.bukkit.configuration.file.YamlConfiguration
|
||||
import org.bukkit.entity.WanderingTrader
|
||||
import java.io.File
|
||||
import kotlin.math.abs
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
val world by lazy { plugin.server.worlds.first()!! }
|
||||
@ -56,6 +57,7 @@ object TNTLeagueWorldConfig {
|
||||
lateinit var blueTeam: TeamConfig
|
||||
lateinit var redTeam: TeamConfig
|
||||
lateinit var lobby: Location
|
||||
var teamsOnSameLine by Delegates.notNull<Boolean>()
|
||||
lateinit var targetMaterial: Material
|
||||
var minHeight by Delegates.notNull<Int>()
|
||||
var target by Delegates.notNull<Int>()
|
||||
@ -64,6 +66,7 @@ object TNTLeagueWorldConfig {
|
||||
try {
|
||||
blueTeam = TeamConfig.fromConfig(config.getConfigurationSection("blueTeam")!!)
|
||||
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))
|
||||
targetMaterial = Material.matchMaterial(config.getString("targetMaterial", "IRON_BLOCK")!!)!!
|
||||
minHeight = config.getInt("minHeight", 0)
|
||||
|
||||
@ -36,13 +36,13 @@ import org.bukkit.event.player.PlayerInteractEntityEvent
|
||||
import org.bukkit.event.player.PlayerJoinEvent
|
||||
import org.bukkit.event.player.PlayerMoveEvent
|
||||
|
||||
object IngameListener: Listener {
|
||||
object IngameListener : Listener {
|
||||
|
||||
@EventHandler
|
||||
fun onEntityInteract(e: PlayerInteractEntityEvent) {
|
||||
if (e.player.gameMode == GameMode.SPECTATOR) return
|
||||
|
||||
if(e.rightClicked.type == EntityType.WANDERING_TRADER) {
|
||||
if (e.rightClicked.type == EntityType.WANDERING_TRADER) {
|
||||
e.isCancelled = true
|
||||
DealerInventory(e.player).open()
|
||||
}
|
||||
@ -64,18 +64,20 @@ object IngameListener: Listener {
|
||||
|
||||
@EventHandler
|
||||
fun onMove(e: PlayerMoveEvent) {
|
||||
if (TNTLeagueGame.getTeam(e.player) != null) {
|
||||
if (e.to.blockX >= TNTLeagueWorldConfig.lobby.blockX && e.to.blockX <= TNTLeagueWorldConfig.lobby.blockX + 1 ||
|
||||
e.to.blockZ >= TNTLeagueWorldConfig.lobby.blockZ && e.to.blockZ <= TNTLeagueWorldConfig.lobby.blockZ + 1) {
|
||||
e.isCancelled = true
|
||||
}
|
||||
if (TNTLeagueGame.getTeam(e.player) == null) return
|
||||
if (e.to.blockZ >= TNTLeagueWorldConfig.lobby.blockZ && e.to.blockZ <= TNTLeagueWorldConfig.lobby.blockZ + 1) {
|
||||
e.isCancelled = true
|
||||
}
|
||||
if (!TNTLeagueWorldConfig.teamsOnSameLine && e.to.blockX >= TNTLeagueWorldConfig.lobby.blockX && e.to.blockX <= TNTLeagueWorldConfig.lobby.blockX + 1) {
|
||||
e.isCancelled = true
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
fun onPickupCoins(e: PlayerAttemptPickupItemEvent) {
|
||||
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.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> {
|
||||
this.forEach { (t, u) -> if(t != null) destination[t] = u }
|
||||
this.forEach { (t, u) -> if (t != null) destination[t] = u }
|
||||
return destination
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user