Expose potion level for 1.9+, part 2. See #2205

This commit is contained in:
PikaMug 2024-05-13 01:44:40 -04:00
parent 1fdb1b8a80
commit 90f8f0ec27

View File

@ -1605,11 +1605,11 @@ public class BukkitQuester implements Quester {
// Bukkit version is 1.9+ and item lacks custom name // Bukkit version is 1.9+ and item lacks custom name
if (goal.getType().equals(Material.POTION) && localeManager.hasBasePotionData()) { if (goal.getType().equals(Material.POTION) && localeManager.hasBasePotionData()) {
final PotionMeta meta = (PotionMeta) goal.getItemMeta(); final PotionMeta meta = (PotionMeta) goal.getItemMeta();
if (meta.getBasePotionData().isUpgraded()) { if (meta != null && meta.getBasePotionData().isUpgraded()) {
final int level = meta.getBasePotionData().getType().name().contains("SLOWNESS") ? 4 : 2; final int level = meta.getBasePotionData().getType().name().contains("SLOWNESS") ? 4 : 2;
message = message.replace("<level>", ChatColor.GREEN + RomanNumeral.getNumeral(level) message = message.replace("<level>", ChatColor.GREEN + RomanNumeral.getNumeral(level)
+ ChatColor.RESET); + ChatColor.RESET);
} else if (meta.getBasePotionData().isExtended()) { } else if (meta != null && meta.getBasePotionData().isExtended()) {
message = message.replace("<level>", ChatColor.GREEN + "+" + ChatColor.RESET); message = message.replace("<level>", ChatColor.GREEN + "+" + ChatColor.RESET);
} else { } else {
message = message.replace(" <level>", ""); message = message.replace(" <level>", "");
@ -3430,9 +3430,21 @@ public class BukkitQuester implements Quester {
} else if (type.equals(ObjectiveType.BREW_ITEM)) { } else if (type.equals(ObjectiveType.BREW_ITEM)) {
final ItemStack is = ((BukkitStage) getCurrentStage(quest)).getItemsToBrew().get(getCurrentStage(quest).getItemsToBrew() final ItemStack is = ((BukkitStage) getCurrentStage(quest)).getItemsToBrew().get(getCurrentStage(quest).getItemsToBrew()
.indexOf(goal)); .indexOf(goal));
final String message = formatCompletedObjectiveMessage("brewItem", goal.getAmount()); String message = formatCompletedObjectiveMessage("brewItem", goal.getAmount());
if (plugin.getConfigSettings().canTranslateNames() && is.hasItemMeta() && !is.getItemMeta().hasDisplayName()) { if (plugin.getConfigSettings().canTranslateNames() && is.hasItemMeta() && !is.getItemMeta().hasDisplayName()) {
// Bukkit version is 1.9+ // Bukkit version is 1.9+
if (goal.getType().equals(Material.POTION) && plugin.getLocaleManager().hasBasePotionData()) {
final PotionMeta meta = (PotionMeta) goal.getItemMeta();
if (meta != null && meta.getBasePotionData().isUpgraded()) {
final int level = meta.getBasePotionData().getType().name().contains("SLOWNESS") ? 4 : 2;
message = message.replace("<level>", ChatColor.GREEN + RomanNumeral.getNumeral(level)
+ ChatColor.RESET);
} else if (meta != null && meta.getBasePotionData().isExtended()) {
message = message.replace("<level>", ChatColor.GREEN + "+" + ChatColor.RESET);
} else {
message = message.replace(" <level>", "");
}
}
if (!plugin.getLocaleManager().sendMessage(p, message, goal.getType(), goal.getDurability(), if (!plugin.getLocaleManager().sendMessage(p, message, goal.getType(), goal.getDurability(),
goal.getEnchantments(), goal.getItemMeta())) { goal.getEnchantments(), goal.getItemMeta())) {
sendMessage(message.replace("<item>", BukkitItemUtil.getName(is))); sendMessage(message.replace("<item>", BukkitItemUtil.getName(is)));