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"> <component name="GradleSettings">
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<option name="delegatedBuild" value="true" />
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="WRAPPED" /> <option name="distributionType" value="WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="/usr/share/java/gradle" /> <option name="gradleHome" value="/usr/share/java/gradle" />

View File

@ -14,7 +14,7 @@
<component name="FrameworkDetectionExcludesConfiguration"> <component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" /> <file type="web" url="file://$PROJECT_DIR$" />
</component> </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" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
<component name="SuppressionsComponent"> <component name="SuppressionsComponent">

View File

@ -4,7 +4,7 @@
<facet type="minecraft" name="Minecraft"> <facet type="minecraft" name="Minecraft">
<configuration> <configuration>
<autoDetectTypes> <autoDetectTypes>
<platformType>PAPER</platformType> <platformType>ADVENTURE</platformType>
</autoDetectTypes> </autoDetectTypes>
</configuration> </configuration>
</facet> </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.ArenaLoadout
import nl.kallestruik.darena.types.arena.ArenaSpawn 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 nl.kallestruik.darena.util.ConfigHelper
import java.io.File import java.io.File
data class ArenaConfig( data class ArenaConfig(
var name: String = "[Missing name]", var name: String = "[Missing name]",
var spawns: List<ArenaSpawn> = emptyList(), 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 loadouts: List<ArenaLoadout> = emptyList(),
var checkpoints: List<ArenaCheckpoint> = emptyList(),
var points: ArenaPoints = ArenaPoints(),
) { ) {
companion object { companion object {
fun load(file: File): ArenaConfig { fun load(file: File): ArenaConfig {
val config = ConfigHelper.getOrCreateConfig(file, "template/arena.yml") val config = ConfigHelper.getOrCreateConfig(file, "template/arena.yml")
val arenaConfig = ArenaConfig() val arenaConfig = ArenaConfig()
if (config.contains("name")) if (config.contains("name")) {
arenaConfig.name = config.getString("name")!! arenaConfig.name = config.getString("name")!!
}
if (config.contains("spawns")) if (config.contains("spawns")) {
arenaConfig.spawns = ArenaSpawn.loadList(config.getConfigurationSection("spawns")!!) arenaConfig.spawns = ArenaSpawn.loadList(config.getConfigurationSection("spawns")!!)
}
if (config.contains("spectatorSpawn")) if (config.contains("loadouts")) {
arenaConfig.spectatorSpawn = ArenaSpawn.load(config.getConfigurationSection("spectatorSpawn")!!)
if (config.contains("loadouts"))
arenaConfig.loadouts = ArenaLoadout.loadList(config.getConfigurationSection("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 return arenaConfig
} }

View File

@ -1,5 +1,20 @@
package nl.kallestruik.darena.types.arena package nl.kallestruik.darena.types.arena
import org.bukkit.configuration.ConfigurationSection
import nl.kallestruik.darena.util.ConfigHelper
data class ArenaPoints( 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 nl.kallestruik.darena.exceptions.MaterialNotFoundException
import org.bukkit.Material import org.bukkit.Material
import org.bukkit.configuration.file.YamlConfiguration import org.bukkit.configuration.file.YamlConfiguration
import org.bukkit.configuration.ConfigurationSection
import java.io.* import java.io.*
object ConfigHelper { object ConfigHelper {
@ -41,4 +42,21 @@ object ConfigHelper {
fun matchMaterial(material: String): Material { fun matchMaterial(material: String): Material {
return Material.matchMaterial(material) ?: throw MaterialNotFoundException("There is not material with the name '$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 # yaw: 0
# pitch: 0 # pitch: 0
# loadout: "default" # loadout: "default"
# loadouts: # specatorSpawn:
# default: # x: 0
# hotbar: # y: 150
# weapon: # z: 0
# material: iron_axe # yaw: 0
# amount: 1 # pitch: 0
# food: # loadout: "none"
# material: cooked_beef #loadouts:
# amount: 10 # default:
# armor: # hotbar:
# helmet: # weapon:
# material: golden_helmet # material: iron_axe
# amount: 1
# elytra:
# material: elytra
# amount: 1
# leggings:
# material: iron_leggings
# amount: 1
# boots:
# material: diamond_boots
# amount: 1
# offhand:
# material: shield
# amount: 1 # amount: 1
#specatorSpawn: # food:
# x: 0 # material: cooked_beef
# y: 150 # amount: 10
# z: 0 # armor:
# yaw: 0 # helmet:
# pitch: 0 # material: golden_helmet
# loadout: "none" # 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