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.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)
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user