|
20 | 20 | import lol.hyper.toolstats.ToolStats; |
21 | 21 | import net.kyori.adventure.text.Component; |
22 | 22 | import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer; |
| 23 | +import org.bukkit.Bukkit; |
23 | 24 | import org.bukkit.inventory.ItemStack; |
24 | 25 | import org.bukkit.inventory.meta.ItemMeta; |
25 | 26 | import org.bukkit.persistence.PersistentDataContainer; |
@@ -768,6 +769,13 @@ public ItemMeta updateFlightTime(ItemStack elytra, long duration) { |
768 | 769 | } |
769 | 770 | container.remove(toolStats.flightTime); |
770 | 771 | if (meta.hasLore()) { |
| 772 | + // if the old format is in the config, check to see if the old format is on the elytra |
| 773 | + if (toolStats.config.getString("messages.flight-time-old") != null) { |
| 774 | + String oldFormatFormatted = toolStats.numberFormat.formatDouble((double) flightTime / 1000); |
| 775 | + Component oldFormat = toolStats.configTools.formatLore("flight-time-old", "{time}", oldFormatFormatted); |
| 776 | + meta.lore(removeLore(meta.lore(), oldFormat)); |
| 777 | + } |
| 778 | + |
771 | 779 | Map<String, String> oldFlightTimeFormatted = toolStats.numberFormat.formatTime(flightTime); |
772 | 780 | Component lineToRemove = toolStats.configTools.formatLoreMultiplePlaceholders("flight-time", oldFlightTimeFormatted); |
773 | 781 | List<Component> newLore = removeLore(meta.lore(), lineToRemove); |
@@ -818,6 +826,12 @@ public ItemMeta updateFlightTime(ItemStack elytra, long duration) { |
818 | 826 | container.set(toolStats.flightTime, PersistentDataType.LONG, flightTime + duration); |
819 | 827 | Map<String, String> oldFlightFormatted = toolStats.numberFormat.formatTime(flightTime); |
820 | 828 | Map<String, String> newFlightFormatted = toolStats.numberFormat.formatTime(flightTime + duration); |
| 829 | + // if the old format is in the config, check to see if the old format is on the elytra |
| 830 | + if (toolStats.config.getString("messages.flight-time-old") != null) { |
| 831 | + String oldFormatFormatted = toolStats.numberFormat.formatDouble((double) flightTime / 1000); |
| 832 | + Component oldFormat = toolStats.configTools.formatLore("flight-time-old", "{time}", oldFormatFormatted); |
| 833 | + meta.lore(removeLore(meta.lore(), oldFormat)); |
| 834 | + } |
821 | 835 | Component oldLine = toolStats.configTools.formatLoreMultiplePlaceholders("flight-time", oldFlightFormatted); |
822 | 836 | Component newLine = toolStats.configTools.formatLoreMultiplePlaceholders("flight-time", newFlightFormatted); |
823 | 837 | if (oldLine == null || newLine == null) { |
|
0 commit comments