Skip to content

Commit f6b8eec

Browse files
authored
Merge pull request #383 from BentoBoxWorld/382_Potion_types_not_showing_in_description
Add something for potions even if there is nothing in the translations
2 parents 459767e + f314f88 commit f6b8eec

File tree

1 file changed

+12
-16
lines changed
  • src/main/java/world/bentobox/challenges/utils

1 file changed

+12
-16
lines changed

src/main/java/world/bentobox/challenges/utils/Utils.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import org.bukkit.inventory.meta.ItemMeta;
2222
import org.bukkit.inventory.meta.PotionMeta;
2323
import org.bukkit.inventory.meta.SkullMeta;
24-
import org.bukkit.potion.PotionData;
2524
import org.bukkit.potion.PotionType;
2625
import org.eclipse.jdt.annotation.Nullable;
2726

@@ -745,7 +744,7 @@ public static String prettifyObject(PotionType type, User user)
745744
* @param user the user
746745
* @return the string
747746
*/
748-
public static String prettifyObject(ItemStack item, @Nullable PotionMeta potionMeta, User user)
747+
public static String prettifyObject(ItemStack item, @Nullable PotionMeta potionMeta, User user)
749748
{
750749
if (potionMeta == null)
751750
{
@@ -757,39 +756,36 @@ public static String prettifyObject(ItemStack item, @Nullable PotionMeta potionM
757756
final String itemReference = Constants.ITEM_STACKS + itemType.name().toLowerCase() + ".";
758757
final String metaReference = Constants.ITEM_STACKS + "meta.";
759758

760-
PotionData potionData = potionMeta.getBasePotionData();
759+
PotionType potionData = potionMeta.getBasePotionType();
761760

762761
// Check custom translation for potions.
763-
String type = user.getTranslationOrNothing(itemReference + potionData.getType().name().toLowerCase());
764-
762+
String type = user.getTranslationOrNothing(itemReference + potionData.name().toLowerCase());
765763
if (type.isEmpty())
766764
{
767765
// Check potion types translation.
768-
type = prettifyObject(potionData.getType(), user);
766+
type = prettifyObject(potionData, user);
769767
}
770-
771-
String upgraded = user.getTranslationOrNothing(metaReference + "upgraded");
772-
String extended = user.getTranslationOrNothing(metaReference + "extended");
773-
774768
// Get item specific translation.
775769
String specific = user.getTranslationOrNothing(itemReference + "name",
776770
"[type]", type,
777-
"[upgraded]", (potionData.isUpgraded() ? upgraded : ""),
778-
"[extended]", (potionData.isExtended() ? extended : ""));
771+
"[upgraded]", "", "[extended]", "");
779772

780773
if (specific.isEmpty())
781774
{
782775
// Use generic translation.
783776
String meta = user.getTranslationOrNothing(metaReference + "potion-meta",
784777
"[type]", type,
785-
"[upgraded]", (potionData.isUpgraded() ? upgraded : ""),
786-
"[extended]", (potionData.isExtended() ? extended : ""));
787-
778+
"[upgraded]", "", "[extended]", "");
779+
BentoBox.getInstance().logDebug("Generic ref: " + Constants.ITEM_STACKS + "generic");
788780
specific = user.getTranslationOrNothing(Constants.ITEM_STACKS + "generic",
789781
"[type]", prettifyObject(itemType, user),
790782
"[meta]", meta);
791783
}
792-
784+
if (specific.isEmpty()) {
785+
// Last ditch
786+
specific = prettifyObject(itemType, user) + ": " + type;
787+
}
788+
BentoBox.getInstance().logDebug(specific);
793789
return specific;
794790
}
795791

0 commit comments

Comments
 (0)