Display tipped arrow level, fixes #2208

This commit is contained in:
PikaMug 2024-05-17 22:55:15 -04:00
parent 9f26e9d053
commit 15044ba9e2

View File

@ -1259,6 +1259,12 @@ public class BukkitQuester implements Quester {
final ChatColor color = progress.getAmount() < goal.getAmount() ? ChatColor.GREEN : ChatColor.GRAY; final ChatColor color = progress.getAmount() < goal.getAmount() ? ChatColor.GREEN : ChatColor.GRAY;
String message = formatCurrentObjectiveMessage(color, BukkitLang.get(getPlayer(), "craftItem"), String message = formatCurrentObjectiveMessage(color, BukkitLang.get(getPlayer(), "craftItem"),
progress.getAmount(), goal.getAmount()); progress.getAmount(), goal.getAmount());
if (goal.getType().name().equals("TIPPED_ARROW")) {
final String level = BukkitItemUtil.getPrettyPotionLevel(goal.getItemMeta());
if (!level.isEmpty()) {
message = message.replace("<item>", "<item> " + level);
}
}
if (formatNames) { if (formatNames) {
message = message.replace("<item>", BukkitItemUtil.getName(goal)); message = message.replace("<item>", BukkitItemUtil.getName(goal));
} }
@ -3375,9 +3381,17 @@ public class BukkitQuester implements Quester {
} else if (type.equals(ObjectiveType.CRAFT_ITEM)) { } else if (type.equals(ObjectiveType.CRAFT_ITEM)) {
final ItemStack is = ((BukkitStage) getCurrentStage(quest)).getItemsToCraft().get(getCurrentStage(quest).getItemsToCraft() final ItemStack is = ((BukkitStage) getCurrentStage(quest)).getItemsToCraft().get(getCurrentStage(quest).getItemsToCraft()
.indexOf(goal)); .indexOf(goal));
final String message = formatCompletedObjectiveMessage("craftItem", goal.getAmount()); String message = formatCompletedObjectiveMessage("craftItem", goal.getAmount());
if (plugin.getConfigSettings().canTranslateNames() && !goal.hasItemMeta() if (plugin.getConfigSettings().canTranslateNames() && !goal.hasItemMeta()
&& !goal.getItemMeta().hasDisplayName()) { && !goal.getItemMeta().hasDisplayName()) {
plugin.getLogger().info(goal.getType().name());
// Bukkit version is 1.9+
if (goal.getType().name().equals("TIPPED_ARROW")) {
final String level = BukkitItemUtil.getPrettyPotionLevel(goal.getItemMeta());
if (!level.isEmpty()) {
message = message.replace("<item>", "<item> " + level);
}
}
if (!plugin.getLocaleManager().sendMessage(p, message, goal.getType(), goal.getDurability(), null)) { if (!plugin.getLocaleManager().sendMessage(p, message, goal.getType(), goal.getDurability(), null)) {
sendMessage(message.replace("<item>", BukkitItemUtil.getName(is))); sendMessage(message.replace("<item>", BukkitItemUtil.getName(is)));
} }
@ -3400,7 +3414,8 @@ public class BukkitQuester implements Quester {
final ItemStack is = ((BukkitStage) getCurrentStage(quest)).getItemsToEnchant().get(getCurrentStage(quest) final ItemStack is = ((BukkitStage) getCurrentStage(quest)).getItemsToEnchant().get(getCurrentStage(quest)
.getItemsToEnchant().indexOf(goal)); .getItemsToEnchant().indexOf(goal));
final String message = formatCompletedObjectiveMessage("enchItem", goal.getAmount()); final String message = formatCompletedObjectiveMessage("enchItem", 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 (!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())) {
@ -3429,10 +3444,11 @@ 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)
.indexOf(goal)); .getItemsToBrew().indexOf(goal));
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().name().contains("POTION") && plugin.getLocaleManager().hasBasePotionData()) { if (goal.getType().name().contains("POTION") && plugin.getLocaleManager().hasBasePotionData()) {
final String level = BukkitItemUtil.getPrettyPotionLevel(goal.getItemMeta()); final String level = BukkitItemUtil.getPrettyPotionLevel(goal.getItemMeta());