Fix issue when Color codes did not work in opened Panels and Titles (#110)

These text element colors were not translated correctly.
Now it should work.
This commit is contained in:
BONNe 2019-05-04 11:16:41 +03:00
parent c702dd492b
commit d60f20e394
6 changed files with 16 additions and 12 deletions

View File

@ -1,6 +1,7 @@
package world.bentobox.challenges.panel.admin; package world.bentobox.challenges.panel.admin;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
@ -275,7 +276,7 @@ public class EditLevelGUI extends CommonGUI
private PanelItem createChallengeIcon(Challenge challenge) private PanelItem createChallengeIcon(Challenge challenge)
{ {
return new PanelItemBuilder(). return new PanelItemBuilder().
name(challenge.getFriendlyName()). name(ChatColor.translateAlternateColorCodes('&', challenge.getFriendlyName())).
description(GuiUtils.stringSplit( description(GuiUtils.stringSplit(
challenge.getDescription(), challenge.getDescription(),
this.addon.getChallengesSettings().getLoreLineLength())). this.addon.getChallengesSettings().getLoreLineLength())).

View File

@ -1,6 +1,7 @@
package world.bentobox.challenges.panel.admin; package world.bentobox.challenges.panel.admin;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import java.util.List; import java.util.List;
@ -133,7 +134,7 @@ public class ListChallengesGUI extends CommonGUI
private PanelItem createChallengeIcon(Challenge challenge) private PanelItem createChallengeIcon(Challenge challenge)
{ {
PanelItemBuilder itemBuilder = new PanelItemBuilder(). PanelItemBuilder itemBuilder = new PanelItemBuilder().
name(challenge.getFriendlyName()). name(ChatColor.translateAlternateColorCodes('&', challenge.getFriendlyName())).
description(GuiUtils.stringSplit(this.generateChallengeDescription(challenge, this.user.getPlayer()), description(GuiUtils.stringSplit(this.generateChallengeDescription(challenge, this.user.getPlayer()),
this.addon.getChallengesSettings().getLoreLineLength())). this.addon.getChallengesSettings().getLoreLineLength())).
icon(challenge.getIcon()). icon(challenge.getIcon()).

View File

@ -1,6 +1,7 @@
package world.bentobox.challenges.panel.admin; package world.bentobox.challenges.panel.admin;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import java.util.List; import java.util.List;
@ -133,7 +134,7 @@ public class ListLevelsGUI extends CommonGUI
private PanelItem createLevelIcon(ChallengeLevel challengeLevel) private PanelItem createLevelIcon(ChallengeLevel challengeLevel)
{ {
PanelItemBuilder itemBuilder = new PanelItemBuilder(). PanelItemBuilder itemBuilder = new PanelItemBuilder().
name(challengeLevel.getFriendlyName()). name(ChatColor.translateAlternateColorCodes('&', challengeLevel.getFriendlyName())).
description(GuiUtils.stringSplit( description(GuiUtils.stringSplit(
this.generateLevelDescription(challengeLevel, this.user.getPlayer()), this.generateLevelDescription(challengeLevel, this.user.getPlayer()),
this.addon.getChallengesSettings().getLoreLineLength())). this.addon.getChallengesSettings().getLoreLineLength())).

View File

@ -1,6 +1,7 @@
package world.bentobox.challenges.panel.user; package world.bentobox.challenges.panel.user;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -349,7 +350,9 @@ public class ChallengesGUI extends CommonGUI
{ {
return new PanelItemBuilder(). return new PanelItemBuilder().
icon(challenge.getIcon()). icon(challenge.getIcon()).
name(challenge.getFriendlyName().isEmpty() ? challenge.getUniqueId() : challenge.getFriendlyName()). name(challenge.getFriendlyName().isEmpty() ?
challenge.getUniqueId() :
ChatColor.translateAlternateColorCodes('&', challenge.getFriendlyName())).
description(GuiUtils.stringSplit(this.generateChallengeDescription(challenge, this.user.getPlayer()), description(GuiUtils.stringSplit(this.generateChallengeDescription(challenge, this.user.getPlayer()),
this.addon.getChallengesSettings().getLoreLineLength())). this.addon.getChallengesSettings().getLoreLineLength())).
clickHandler((panel, user1, clickType, slot) -> { clickHandler((panel, user1, clickType, slot) -> {
@ -440,7 +443,7 @@ public class ChallengesGUI extends CommonGUI
return new PanelItemBuilder(). return new PanelItemBuilder().
icon(icon). icon(icon).
name(name). name(ChatColor.translateAlternateColorCodes('&', name)).
description(description). description(description).
glow(glow). glow(glow).
clickHandler(clickHandler). clickHandler(clickHandler).

View File

@ -1,6 +1,7 @@
package world.bentobox.challenges.panel.util; package world.bentobox.challenges.panel.util;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.event.inventory.ClickType; import org.bukkit.event.inventory.ClickType;
import java.util.*; import java.util.*;
@ -144,7 +145,7 @@ public class SelectChallengeGUI
return new PanelItemBuilder(). return new PanelItemBuilder().
name(challenge.getFriendlyName()). name(ChatColor.translateAlternateColorCodes('&', challenge.getFriendlyName())).
description(GuiUtils.stringSplit(description, this.lineLength)). description(GuiUtils.stringSplit(description, this.lineLength)).
icon(challenge.getIcon()). icon(challenge.getIcon()).
clickHandler((panel, user1, clickType, slot) -> { clickHandler((panel, user1, clickType, slot) -> {

View File

@ -4,10 +4,7 @@
package world.bentobox.challenges.tasks; package world.bentobox.challenges.tasks;
import org.bukkit.GameMode; import org.bukkit.*;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -1027,7 +1024,7 @@ public class TryToComplete
outputMessage = outputMessage.replace("[rewardText]", challenge.getRewardText()); outputMessage = outputMessage.replace("[rewardText]", challenge.getRewardText());
} }
return outputMessage; return ChatColor.translateAlternateColorCodes('&', outputMessage);
} }
@ -1047,7 +1044,7 @@ public class TryToComplete
outputMessage = outputMessage.replace("[rewardText]", level.getRewardText()); outputMessage = outputMessage.replace("[rewardText]", level.getRewardText());
} }
return outputMessage; return ChatColor.translateAlternateColorCodes('&', outputMessage);
} }