This repository has been archived by the owner on May 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support migrating old items by custom model data
- Loading branch information
Showing
4 changed files
with
42 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...main/kotlin/com/mineinabyss/looty/migration/custommodeldata/CustomModelDataToPrefabMap.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.mineinabyss.looty.migration.custommodeldata | ||
|
||
import com.mineinabyss.geary.prefabs.PrefabKey | ||
import com.mineinabyss.looty.ecs.queries.LootyTypeQuery | ||
import org.bukkit.Material | ||
|
||
data class CustomItem( | ||
val material: Material, | ||
val customModelData: Int | ||
) | ||
|
||
/** | ||
* Assists in migrating old items which only have custom model data to define their item type. | ||
*/ | ||
object CustomModelDataToPrefabMap { | ||
private val map = mutableMapOf<CustomItem, PrefabKey>() | ||
|
||
init { | ||
LootyTypeQuery.run { | ||
forEach { | ||
val item = it.type.item | ||
map[CustomItem(item.type ?: return@forEach, item.customModelData ?: return@forEach)] = it.key | ||
} | ||
} | ||
} | ||
|
||
operator fun get(item: CustomItem) = map[item] | ||
} |