Skip to content

Commit

Permalink
add warning to loot tables if rolls are empty
Browse files Browse the repository at this point in the history
  • Loading branch information
12rcu committed May 7, 2024
1 parent b716f89 commit ead80e0
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ open class BehaviourEntity(val unsafeParent: Entity): OverwriteComponents(unsafe
*
* @return a valid table that can be used in the loot table component
*/
@Deprecated("Use in component table() call", ReplaceWith("table()"))
fun generateLootTable(data: BehLootTables.() -> Unit): String {
unsafeLootTable.apply(data)
return unsafeParent.addon.config.paths.lootTableEntity.toString() + "/${unsafeParent.name}"
Expand Down Expand Up @@ -295,6 +296,7 @@ open class BehaviourEntity(val unsafeParent: Entity): OverwriteComponents(unsafe
}

if(!unsafeLootTable.isEmpty()) {
unsafeLootTable.debug(unsafeParent.name)
BehLootTables.Entity(unsafeLootTable).build(unsafeParent.name)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ class BlockComponents : MonsteraRawFile() {
*/
fun table(tableName: String, data: BehLootTables.() -> Unit) {
val lootTables = BehLootTables().apply(data)
lootTables.debug(tableName)
val target = BehLootTables.Block(lootTables).build(tableName)
target.fold({
loot = BehLootTables.resolveRelative(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Barter : MonsteraRawFile() {

fun table(tableName: String, data: BehLootTables.() -> Unit) {
val lootTables = BehLootTables().apply(data)
lootTables.debug(tableName)
val target = BehLootTables.Entity(lootTables).build(tableName)
target.fold({
barterTable = resolveRelative(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class BehRandomSearchAndDig : MonsteraRawFile() {
*/
fun itemTable(tableName: String, data: BehLootTables.() -> Unit) {
val lootTables = BehLootTables().apply(data)
lootTables.debug(tableName)
val target = BehLootTables.Entity(lootTables).build(tableName)
target.fold({
itemTable = BehLootTables.resolveRelative(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class BehSneeze : MonsteraRawFile() {
*/
fun lootTable(tableName: String, data: BehLootTables.() -> Unit) {
val lootTables = BehLootTables().apply(data)
lootTables.debug(tableName)
val target = BehLootTables.Entity(lootTables).build(tableName)
target.fold({
lootTable = BehLootTables.resolveRelative(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Equipment : MonsteraRawFile() {
*/
fun table(tableName: String, data: BehLootTables.() -> Unit) {
val lootTables = BehLootTables().apply(data)
lootTables.debug(tableName)
val target = BehLootTables.Entity(lootTables).build(tableName)
target.fold({
table = BehLootTables.resolveRelative(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class Loot : MonsteraRawFile() {
*/
fun table(tableName: String, data: BehLootTables.() -> Unit) {
val lootTables = BehLootTables().apply(data)
lootTables.debug(tableName)
val target = BehLootTables.Entity(lootTables).build(tableName)
target.fold({
table = BehLootTables.resolveRelative(it)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,15 @@ class BehLootTables: MonsteraRawFile() {
*/
fun isEmpty() = poolsData.isNullOrEmpty()

/**
* debug print infos and warnings
*/
fun debug(idInfo: String) {
poolsData?.firstOrNull { it.rollsData == null }?.run {
logger.warn("($idInfo) rolls not set - handled as implicit 0")
}
}

@SerializedName("pools")
@Expose
@JsonAdapter(MonsteraListFileTypeAdapter::class)
Expand Down

0 comments on commit ead80e0

Please sign in to comment.