Did stuff on laptop.

master
kalle 2021-10-28 18:38:41 +02:00
parent cf745b35b9
commit 63f40bef55
7 changed files with 127 additions and 44 deletions

View File

@ -4,6 +4,8 @@
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="delegatedBuild" value="true" />
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="/usr/share/java/gradle" />

View File

@ -14,7 +14,7 @@
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_16" default="true" project-jdk-name="openjdk-16" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_16" default="true" project-jdk-name="16" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="SuppressionsComponent">

View File

@ -4,7 +4,7 @@
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>PAPER</platformType>
<platformType>ADVENTURE</platformType>
</autoDetectTypes>
</configuration>
</facet>

View File

@ -2,32 +2,42 @@ package nl.kallestruik.darena.arenas
import nl.kallestruik.darena.types.arena.ArenaLoadout
import nl.kallestruik.darena.types.arena.ArenaSpawn
import nl.kallestruik.darena.types.arena.ArenaCheckpoint
import nl.kallestruik.darena.types.arena.ArenaPoints
import nl.kallestruik.darena.util.ConfigHelper
import java.io.File
data class ArenaConfig(
var name: String = "[Missing name]",
var spawns: List<ArenaSpawn> = emptyList(),
var spectatorSpawn: ArenaSpawn = ArenaSpawn("default", 0.0, 100.0, 0.0, 0.0F, 0.0F, "default"),
var loadouts: List<ArenaLoadout> = emptyList(),
var checkpoints: List<ArenaCheckpoint> = emptyList(),
var points: ArenaPoints = ArenaPoints(),
) {
companion object {
fun load(file: File): ArenaConfig {
val config = ConfigHelper.getOrCreateConfig(file, "template/arena.yml")
val arenaConfig = ArenaConfig()
if (config.contains("name"))
if (config.contains("name")) {
arenaConfig.name = config.getString("name")!!
}
if (config.contains("spawns"))
if (config.contains("spawns")) {
arenaConfig.spawns = ArenaSpawn.loadList(config.getConfigurationSection("spawns")!!)
}
if (config.contains("spectatorSpawn"))
arenaConfig.spectatorSpawn = ArenaSpawn.load(config.getConfigurationSection("spectatorSpawn")!!)
if (config.contains("loadouts"))
if (config.contains("loadouts")) {
arenaConfig.loadouts = ArenaLoadout.loadList(config.getConfigurationSection("loadouts")!!)
}
if (config.contains("checkpoints")) {
arenaConfig.checkpoints = ArenaCheckpoint.loadList(config.getConfigurationSection("checkpoints")!!)
}
if (config.contains("points")) {
arenaConfig.points = ArenaPoints.load(config.getConfigurationSection("points")!!)
}
return arenaConfig
}

View File

@ -1,5 +1,20 @@
package nl.kallestruik.darena.types.arena
import org.bukkit.configuration.ConfigurationSection
import nl.kallestruik.darena.util.ConfigHelper
data class ArenaPoints(
val kill: Int,
)
val kill: List<Int> = listOf(0),
val lastManStanding: List<Int> = listOf(0),
val checkpoints: Map<String, List<Int>> = mapOf()
) {
companion object {
fun load(section: ConfigurationSection): ArenaPoints {
return ArenaPoints(
ConfigHelper.parseIntList(section.getString("kill")!!),
ConfigHelper.parseIntList(section.getString("lastManStanding")!!),
ConfigHelper.parseStringIntListMap(section.getConfigurationSection("checkpoints")!!)
)
}
}
}

View File

@ -3,6 +3,7 @@ package nl.kallestruik.darena.util
import nl.kallestruik.darena.exceptions.MaterialNotFoundException
import org.bukkit.Material
import org.bukkit.configuration.file.YamlConfiguration
import org.bukkit.configuration.ConfigurationSection
import java.io.*
object ConfigHelper {
@ -41,4 +42,21 @@ object ConfigHelper {
fun matchMaterial(material: String): Material {
return Material.matchMaterial(material) ?: throw MaterialNotFoundException("There is not material with the name '$material'")
}
fun parseIntList(string: String): List<Int> {
val list = mutableListOf<Int>()
for (key in string.split(" ")) {
list.add(key.toInt())
}
return list
}
fun parseStringIntListMap(section: ConfigurationSection): Map<String, List<Int>> {
val map = mutableMapOf<String, List<Int>>()
for (key in section.getKeys(true)) {
map[key] = parseIntList(section.getString(key)!!)
}
return map
}
}

View File

@ -30,35 +30,73 @@
# yaw: 0
# pitch: 0
# loadout: "default"
# loadouts:
# default:
# hotbar:
# weapon:
# material: iron_axe
# amount: 1
# food:
# material: cooked_beef
# amount: 10
# armor:
# helmet:
# material: golden_helmet
# amount: 1
# elytra:
# material: elytra
# amount: 1
# leggings:
# material: iron_leggings
# amount: 1
# boots:
# material: diamond_boots
# amount: 1
# offhand:
# material: shield
# specatorSpawn:
# x: 0
# y: 150
# z: 0
# yaw: 0
# pitch: 0
# loadout: "none"
#loadouts:
# default:
# hotbar:
# weapon:
# material: iron_axe
# amount: 1
#specatorSpawn:
# x: 0
# y: 150
# z: 0
# yaw: 0
# pitch: 0
# loadout: "none"
# food:
# material: cooked_beef
# amount: 10
# armor:
# helmet:
# material: golden_helmet
# amount: 1
# elytra:
# material: elytra
# amount: 1
# leggings:
# material: iron_leggings
# amount: 1
# boots:
# material: diamond_boots
# amount: 1
# offhand:
# material: shield
# amount: 1
#checkpoints:
# checkpoint1:
# lower:
# x: 0
# y: 0
# z: 0
# upper:
# x: 10
# y: 10
# z: 10
# spawn: "label1"
# checkpoint2:
# lower:
# x: 20
# y: 0
# z: 20
# upper:
# x: 30
# y: 10
# z: 30
# spawn: "label2"
# finish:
# lower:
# x: 40
# y: 0
# z: 40
# upper:
# x: 50
# y: 10
# z: 50
# spawn: "spectatorSpawn"
#points:
# kill: 10 5
# last-man-standing: 10 5 3 0
# checkpoints:
# checkpoint1: 10
# checkpoint2: 5
# finish: 20 10 5