Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor BukkitFcItem and BukkitFcText to fix item name/lore.
- Loading branch information
1 parent
2058eb2
commit 8631258
Showing
20 changed files
with
131 additions
and
91 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
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
20 changes: 18 additions & 2 deletions
20
...c/main/kotlin/net/benwoodworth/fastcraft/bukkit/item/BukkitFcItemConverter_1_13_00_R01.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 |
---|---|---|
@@ -1,12 +1,28 @@ | ||
package net.benwoodworth.fastcraft.bukkit.item | ||
|
||
import net.benwoodworth.fastcraft.bukkit.text.BukkitFcTextConverter | ||
import net.benwoodworth.fastcraft.platform.text.FcLocale | ||
import org.bukkit.inventory.ItemStack | ||
import javax.inject.Inject | ||
|
||
class BukkitFcItemConverter_1_13_00_R01 @Inject constructor( | ||
private val textConverter: BukkitFcTextConverter | ||
) : BukkitFcItemConverter { | ||
|
||
override fun BukkitFcItem.toItemStack(): ItemStack { | ||
return itemStack.clone() | ||
override fun BukkitFcItem.toItemStack(locale: FcLocale): ItemStack { | ||
val itemStack = base.clone() | ||
val meta = itemStack.itemMeta | ||
|
||
with(textConverter) { | ||
|
||
meta.displayName = displayName?.toLegacy(locale) | ||
|
||
meta.lore = lore | ||
.takeIf { it.any() } | ||
?.map { it.toLegacy(locale) } | ||
} | ||
|
||
itemStack.itemMeta = meta | ||
return itemStack | ||
} | ||
} |
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
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
3 changes: 1 addition & 2 deletions
3
...0.1/src/main/kotlin/net/benwoodworth/fastcraft/bukkit/text/BukkitLocalizer_1_13_00_R01.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 |
---|---|---|
@@ -1,13 +1,12 @@ | ||
package net.benwoodworth.fastcraft.bukkit.text | ||
|
||
import net.benwoodworth.fastcraft.bukkit.bukkit | ||
import net.benwoodworth.fastcraft.platform.text.FcLocale | ||
import javax.inject.Inject | ||
|
||
class BukkitLocalizer_1_13_00_R01 @Inject constructor( | ||
) : BukkitLocalizer { | ||
|
||
override fun localize(key: String, locale: FcLocale): String? { | ||
return "[${locale.bukkit.localeId}/$key]" | ||
return key // TODO | ||
} | ||
} |
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
3 changes: 2 additions & 1 deletion
3
...it/bukkit/src/main/kotlin/net/benwoodworth/fastcraft/bukkit/item/BukkitFcItemConverter.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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
package net.benwoodworth.fastcraft.bukkit.item | ||
|
||
import net.benwoodworth.fastcraft.platform.text.FcLocale | ||
import org.bukkit.inventory.ItemStack | ||
|
||
interface BukkitFcItemConverter { | ||
|
||
fun BukkitFcItem.toItemStack(): ItemStack | ||
fun BukkitFcItem.toItemStack(locale: FcLocale): ItemStack | ||
} |
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
5 changes: 3 additions & 2 deletions
5
...it/bukkit/src/main/kotlin/net/benwoodworth/fastcraft/bukkit/text/BukkitFcTextConverter.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 |
---|---|---|
@@ -1,10 +1,11 @@ | ||
package net.benwoodworth.fastcraft.bukkit.text | ||
|
||
import net.benwoodworth.fastcraft.platform.text.FcLocale | ||
import net.benwoodworth.fastcraft.platform.text.FcText | ||
|
||
interface BukkitFcTextConverter { | ||
|
||
fun BukkitFcText.toRaw(): String | ||
fun FcText.toRaw(): String | ||
|
||
fun BukkitFcText.toLegacy(locale: FcLocale): String | ||
fun FcText.toLegacy(locale: FcLocale): String | ||
} |
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
Oops, something went wrong.