mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-22 10:36:09 +01:00
Reveal display names and update library, fixes #2116
This commit is contained in:
parent
56a75acc37
commit
90bf028624
@ -149,7 +149,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.PikaMug</groupId>
|
<groupId>com.github.PikaMug</groupId>
|
||||||
<artifactId>LocaleLib</artifactId>
|
<artifactId>LocaleLib</artifactId>
|
||||||
<version>3.4</version>
|
<version>3.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>xyz.upperlevel.spigot.book</groupId>
|
<groupId>xyz.upperlevel.spigot.book</groupId>
|
||||||
|
@ -2181,29 +2181,28 @@ public class Quester implements IQuester {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Settings settings = plugin.getSettings();
|
|
||||||
final LocaleManager localeManager = plugin.getLocaleManager();
|
final LocaleManager localeManager = plugin.getLocaleManager();
|
||||||
if (settings.canTranslateNames() && localeManager == null) {
|
final Settings settings = plugin.getSettings();
|
||||||
|
if (localeManager == null && settings.canTranslateNames()) {
|
||||||
settings.setTranslateNames(false);
|
settings.setTranslateNames(false);
|
||||||
plugin.getLogger().severe("Problem with locale manager! Item name translation disabled.");
|
plugin.getLogger().severe("Problem with locale manager! Item name translation disabled.");
|
||||||
}
|
}
|
||||||
for (BukkitObjective objective : q.getCurrentObjectivesTemp(quest, false, false)) {
|
for (final BukkitObjective objective : q.getCurrentObjectivesTemp(quest, false, false)) {
|
||||||
final String message = "- " + objective.getMessage();
|
final String message = "- " + objective.getMessage();
|
||||||
if (objective.getProgressAsItem() != null && objective.getGoalAsItem() != null) {
|
if (objective.getProgressAsItem() != null && objective.getGoalAsItem() != null) {
|
||||||
ItemStack progress = objective.getProgressAsItem();
|
final ItemStack progress = objective.getProgressAsItem();
|
||||||
ItemStack goal = objective.getGoalAsItem();
|
final ItemStack goal = objective.getGoalAsItem();
|
||||||
if (!settings.canShowCompletedObjs() && progress.getAmount() >= goal.getAmount()) {
|
if (!settings.canShowCompletedObjs() && progress.getAmount() >= goal.getAmount()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (settings.canTranslateNames() && goal.hasItemMeta()) {
|
if (localeManager != null && settings.canTranslateNames() && !goal.hasItemMeta()
|
||||||
// Bukkit version is 1.9+
|
|
||||||
localeManager.sendMessage(quester.getPlayer(), message, goal.getType(), goal.getDurability(),
|
|
||||||
goal.getEnchantments(), goal.getItemMeta());
|
|
||||||
} else if (settings.canTranslateNames() && !goal.hasItemMeta()
|
|
||||||
&& Material.getMaterial("LINGERING_POTION") == null) {
|
&& Material.getMaterial("LINGERING_POTION") == null) {
|
||||||
// Bukkit version is below 1.9
|
// Bukkit version is below 1.9 and item has no metadata
|
||||||
localeManager.sendMessage(quester.getPlayer(), message, goal.getType(), goal.getDurability(),
|
localeManager.sendMessage(quester.getPlayer(), message, goal);
|
||||||
goal.getEnchantments());
|
} else if (localeManager != null && settings.canTranslateNames() && goal.getItemMeta() != null
|
||||||
|
&& !goal.getItemMeta().hasDisplayName() && !goal.getType().equals(Material.WRITTEN_BOOK)) {
|
||||||
|
// Bukkit version is 1.9+ and item lacks custom name
|
||||||
|
localeManager.sendMessage(quester.getPlayer(), message, goal);
|
||||||
} else {
|
} else {
|
||||||
if (goal.getEnchantments().isEmpty()) {
|
if (goal.getEnchantments().isEmpty()) {
|
||||||
quester.sendMessage(message.replace("<item>", ItemUtil.getName(goal))
|
quester.sendMessage(message.replace("<item>", ItemUtil.getName(goal))
|
||||||
@ -2224,7 +2223,7 @@ public class Quester implements IQuester {
|
|||||||
if (!settings.canShowCompletedObjs() && progress.getCount() >= goal.getCount()) {
|
if (!settings.canShowCompletedObjs() && progress.getCount() >= goal.getCount()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (settings.canTranslateNames()) {
|
if (localeManager != null && settings.canTranslateNames()) {
|
||||||
localeManager.sendMessage(quester.getPlayer(), message, goal.getEntityType(), null);
|
localeManager.sendMessage(quester.getPlayer(), message, goal.getEntityType(), null);
|
||||||
} else {
|
} else {
|
||||||
quester.sendMessage(message.replace("<mob>", MiscUtil.getProperMobName(goal.getEntityType())));
|
quester.sendMessage(message.replace("<mob>", MiscUtil.getProperMobName(goal.getEntityType())));
|
||||||
|
@ -293,8 +293,10 @@ public class ItemStackPrompt extends QuestsEditorNumericPrompt {
|
|||||||
if (is.hasItemMeta()) {
|
if (is.hasItemMeta()) {
|
||||||
final ItemMeta meta = is.getItemMeta();
|
final ItemMeta meta = is.getItemMeta();
|
||||||
if (meta != null) {
|
if (meta != null) {
|
||||||
|
if (meta.hasDisplayName()) {
|
||||||
final String display = meta.getDisplayName().replace(ChatColor.COLOR_CHAR, '&');
|
final String display = meta.getDisplayName().replace(ChatColor.COLOR_CHAR, '&');
|
||||||
context.setSessionData("tempDisplay", display);
|
context.setSessionData("tempDisplay", display);
|
||||||
|
}
|
||||||
if (meta.getLore() != null) {
|
if (meta.getLore() != null) {
|
||||||
final LinkedList<String> lore = new LinkedList<>(meta.getLore());
|
final LinkedList<String> lore = new LinkedList<>(meta.getLore());
|
||||||
context.setSessionData("tempLore", lore);
|
context.setSessionData("tempLore", lore);
|
||||||
|
@ -600,6 +600,9 @@ public class ItemUtil {
|
|||||||
final String text;
|
final String text;
|
||||||
if (is.getItemMeta() != null && is.getItemMeta().hasDisplayName()) {
|
if (is.getItemMeta() != null && is.getItemMeta().hasDisplayName()) {
|
||||||
text = "" + ChatColor.DARK_AQUA + ChatColor.ITALIC + is.getItemMeta().getDisplayName();
|
text = "" + ChatColor.DARK_AQUA + ChatColor.ITALIC + is.getItemMeta().getDisplayName();
|
||||||
|
} else if (is.getType().equals(Material.WRITTEN_BOOK)) {
|
||||||
|
final BookMeta bookMeta = (BookMeta) is.getItemMeta();
|
||||||
|
text = "" + ChatColor.DARK_AQUA + ChatColor.LIGHT_PURPLE + bookMeta.getTitle();
|
||||||
} else {
|
} else {
|
||||||
text = ChatColor.AQUA + getPrettyItemName(is.getType().name());
|
text = ChatColor.AQUA + getPrettyItemName(is.getType().name());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user