mirror of
https://github.com/PikaMug/Quests.git
synced 2024-11-22 02:25:42 +01:00
Parse format tokens in objective message
This commit is contained in:
parent
3413895abf
commit
3e59fc5659
@ -57,8 +57,8 @@ public class BukkitQuestJournal {
|
||||
}
|
||||
|
||||
public List<BaseComponent[]> getPages() {
|
||||
final Player player = owner.getPlayer();
|
||||
if (owner.getCurrentQuests().isEmpty()) {
|
||||
final Player player = owner.getPlayer();
|
||||
final String title = BukkitLang.get(player, "journalTitle");
|
||||
return Collections.singletonList(new BookUtil.PageBuilder().add(new TextComponent(ChatColor.DARK_RED
|
||||
+ BukkitLang.get(player, "journalNoQuests").replace("<journal>", title))).build());
|
||||
@ -74,47 +74,50 @@ public class BukkitQuestJournal {
|
||||
final BookUtil.PageBuilder builder = new BookUtil.PageBuilder().add(title).newLine();
|
||||
for (final Objective obj : owner.getCurrentObjectives(quest, false, false)) {
|
||||
final BukkitObjective objective = (BukkitObjective) obj;
|
||||
if (!plugin.getConfigSettings().canShowCompletedObjs()
|
||||
&& objective.getMessage().startsWith(ChatColor.GRAY.toString())) {
|
||||
if (objective.getMessage() == null) {
|
||||
continue;
|
||||
}
|
||||
if (objective.getMessage() != null) {
|
||||
String[] split = null;
|
||||
if (objective.getMessage().contains("<item>") && objective.getGoalAsItem() != null) {
|
||||
split = objective.getMessage().split("<item>");
|
||||
builder.add(split[0]);
|
||||
final ItemStack goal = objective.getGoalAsItem();
|
||||
if (goal.getItemMeta() != null && goal.getItemMeta().hasDisplayName()) {
|
||||
builder.add("" + ChatColor.DARK_AQUA + ChatColor.ITALIC
|
||||
+ goal.getItemMeta().getDisplayName());
|
||||
} else {
|
||||
if (plugin.getConfigSettings().canTranslateNames()) {
|
||||
final TranslatableComponent tc = new TranslatableComponent(plugin.getLocaleManager()
|
||||
.queryItemStack(goal));
|
||||
tc.setColor(net.md_5.bungee.api.ChatColor.DARK_AQUA);
|
||||
builder.add(tc);
|
||||
} else {
|
||||
builder.add(ChatColor.AQUA + BukkitItemUtil.getPrettyItemName(goal.getType().name()));
|
||||
}
|
||||
}
|
||||
builder.add(split[1]).newLine();
|
||||
}
|
||||
if (objective.getMessage().contains("<mob>") && objective.getGoalAsMob() != null) {
|
||||
split = objective.getMessage().split("<mob>");
|
||||
builder.add(split[0]);
|
||||
final String message = "- " + BukkitLang.BukkitFormatToken.convertString(player,
|
||||
objective.getMessage());
|
||||
if (!plugin.getConfigSettings().canShowCompletedObjs()
|
||||
&& message.startsWith(ChatColor.GRAY.toString())) {
|
||||
continue;
|
||||
}
|
||||
String[] split = null;
|
||||
if (message.contains("<item>") && objective.getGoalAsItem() != null) {
|
||||
split = message.split("<item>");
|
||||
builder.add(split[0]);
|
||||
final ItemStack goal = objective.getGoalAsItem();
|
||||
if (goal.getItemMeta() != null && goal.getItemMeta().hasDisplayName()) {
|
||||
builder.add("" + ChatColor.DARK_AQUA + ChatColor.ITALIC
|
||||
+ goal.getItemMeta().getDisplayName());
|
||||
} else {
|
||||
if (plugin.getConfigSettings().canTranslateNames()) {
|
||||
final TranslatableComponent tc = new TranslatableComponent(plugin.getLocaleManager()
|
||||
.queryEntityType(objective.getGoalAsMob().getEntityType(), null)); // TODO extra data
|
||||
tc.setColor(net.md_5.bungee.api.ChatColor.DARK_RED);
|
||||
.queryItemStack(goal));
|
||||
tc.setColor(net.md_5.bungee.api.ChatColor.DARK_AQUA);
|
||||
builder.add(tc);
|
||||
} else {
|
||||
builder.add(BukkitMiscUtil.snakeCaseToUpperCamelCase(objective.getGoalAsMob().getEntityType().name()));
|
||||
builder.add(ChatColor.AQUA + BukkitItemUtil.getPrettyItemName(goal.getType().name()));
|
||||
}
|
||||
builder.add(split[1]).newLine();
|
||||
}
|
||||
if (split == null) {
|
||||
builder.add(objective.getMessage()).newLine();
|
||||
builder.add(split[1]).newLine();
|
||||
}
|
||||
if (message.contains("<mob>") && objective.getGoalAsMob() != null) {
|
||||
split = message.split("<mob>");
|
||||
builder.add(split[0]);
|
||||
if (plugin.getConfigSettings().canTranslateNames()) {
|
||||
final TranslatableComponent tc = new TranslatableComponent(plugin.getLocaleManager()
|
||||
.queryEntityType(objective.getGoalAsMob().getEntityType(), null)); // TODO extra data
|
||||
tc.setColor(net.md_5.bungee.api.ChatColor.DARK_RED);
|
||||
builder.add(tc);
|
||||
} else {
|
||||
builder.add(BukkitMiscUtil.snakeCaseToUpperCamelCase(objective.getGoalAsMob().getEntityType().name()));
|
||||
}
|
||||
builder.add(split[1]).newLine();
|
||||
}
|
||||
if (split == null) {
|
||||
builder.add(message).newLine();
|
||||
}
|
||||
}
|
||||
pages.add(builder.build());
|
||||
|
@ -1714,7 +1714,8 @@ public class BukkitQuester implements Quester {
|
||||
}
|
||||
for (final Objective obj : q.getCurrentObjectives(quest, false, false)) {
|
||||
final BukkitObjective objective = (BukkitObjective) obj;
|
||||
final String message = "- " + objective.getMessage();
|
||||
final String message = "- " + BukkitLang.BukkitFormatToken.convertString(quester.getPlayer(),
|
||||
objective.getMessage());
|
||||
if (objective.getProgressAsItem() != null && objective.getGoalAsItem() != null) {
|
||||
final ItemStack progress = objective.getProgressAsItem();
|
||||
final ItemStack goal = objective.getGoalAsItem();
|
||||
|
Loading…
Reference in New Issue
Block a user