Fix some other places where LangUtils is not applied.

This commit is contained in:
ApacheZy 2021-03-07 13:02:36 +08:00
parent e1a096674f
commit 3f3b021050
5 changed files with 15 additions and 13 deletions

View File

@ -8,6 +8,7 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
@ -437,11 +438,12 @@ public class EditChallengeGUI extends CommonGUI
description.add(this.user.getTranslation("challenges.gui.descriptions.admin.environment"));
description.add((this.challenge.getEnvironment().contains(World.Environment.NORMAL) ? "&2" : "&c") +
this.user.getTranslation("challenges.gui.descriptions.normal"));
// If color code is removed from here, users can use color code in language files.
ChatColor.stripColor(this.user.getTranslation("challenges.gui.descriptions.normal")));
description.add((this.challenge.getEnvironment().contains(World.Environment.NETHER) ? "&2" : "&c") +
this.user.getTranslation("challenges.gui.descriptions.nether"));
ChatColor.stripColor(this.user.getTranslation("challenges.gui.descriptions.nether")));
description.add((this.challenge.getEnvironment().contains(World.Environment.THE_END) ? "&2" : "&c") +
this.user.getTranslation("challenges.gui.descriptions.the-end"));
ChatColor.stripColor(this.user.getTranslation("challenges.gui.descriptions.the-end")));
icon = new ItemStack(Material.DROPPER);
clickHandler = (panel, user, clickType, slot) -> {

View File

@ -8,7 +8,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.WordUtils;
import org.bukkit.Material;
import org.bukkit.World;
@ -16,6 +15,7 @@ import world.bentobox.bentobox.api.panels.PanelItem;
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.hooks.LangUtilsHook;
import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.panel.CommonGUI;
import world.bentobox.challenges.panel.util.NumberGUI;
@ -166,7 +166,7 @@ public class ManageBlocksGUI extends CommonGUI
private PanelItem createElementButton(Material material)
{
return new PanelItemBuilder().
name(WordUtils.capitalize(material.name().toLowerCase().replace("_", " "))).
name(LangUtilsHook.getMaterialName(material, user)).
icon(GuiUtils.getMaterialItem(material, this.materialMap.get(material))).
description(this.selectedMaterials.contains(material) ?
this.user.getTranslation("challenges.gui.descriptions.admin.selected") : "").

View File

@ -8,7 +8,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.apache.commons.lang.WordUtils;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.entity.EntityType;
@ -17,6 +16,7 @@ import world.bentobox.bentobox.api.panels.PanelItem;
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.hooks.LangUtilsHook;
import world.bentobox.challenges.ChallengesAddon;
import world.bentobox.challenges.panel.CommonGUI;
import world.bentobox.challenges.panel.util.NumberGUI;
@ -175,7 +175,7 @@ public class ManageEntitiesGUI extends CommonGUI
private PanelItem createEntityButton(EntityType entity)
{
return new PanelItemBuilder().
name(WordUtils.capitalize(entity.name().toLowerCase().replace("_", " "))).
name(LangUtilsHook.getEntityName(entity, user)).
description(this.selectedEntities.contains(entity) ?
this.user.getTranslation("challenges.gui.descriptions.admin.selected") : "").
icon(this.asEggs ?

View File

@ -7,7 +7,6 @@ import java.util.List;
import java.util.Set;
import java.util.function.BiConsumer;
import org.apache.commons.lang.WordUtils;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
@ -15,6 +14,7 @@ import world.bentobox.bentobox.api.panels.PanelItem;
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.hooks.LangUtilsHook;
import world.bentobox.challenges.utils.GuiUtils;
@ -158,7 +158,7 @@ public class SelectBlocksGUI
if (!this.selectedMaterials.isEmpty())
{
description.add(this.user.getTranslation("challenges.gui.descriptions.admin.selected") + ":");
this.selectedMaterials.forEach(material -> description.add(" - " + material.name()));
this.selectedMaterials.forEach(material -> description.add(" - " + LangUtilsHook.getMaterialName(material, user)));
}
panelBuilder.item(5,
@ -218,7 +218,7 @@ public class SelectBlocksGUI
ItemStack itemStack = GuiUtils.getMaterialItem(material);
return new PanelItemBuilder().
name(WordUtils.capitalize(material.name().toLowerCase().replace("_", " "))).
name(LangUtilsHook.getMaterialName(material, user)).
description(this.selectedMaterials.contains(material) ?
this.user.getTranslation("challenges.gui.descriptions.admin.selected") : "").
icon(itemStack).

View File

@ -9,7 +9,6 @@ import java.util.List;
import java.util.Set;
import java.util.function.BiConsumer;
import org.apache.commons.lang.WordUtils;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
@ -18,6 +17,7 @@ import world.bentobox.bentobox.api.panels.PanelItem;
import world.bentobox.bentobox.api.panels.builders.PanelBuilder;
import world.bentobox.bentobox.api.panels.builders.PanelItemBuilder;
import world.bentobox.bentobox.api.user.User;
import world.bentobox.bentobox.hooks.LangUtilsHook;
import world.bentobox.challenges.utils.GuiUtils;
@ -101,7 +101,7 @@ public class SelectEntityGUI
if (!this.selectedEntities.isEmpty())
{
description.add(this.user.getTranslation("challenges.gui.descriptions.admin.selected") + ":");
this.selectedEntities.forEach(entity -> description.add(" - " + entity.name()));
this.selectedEntities.forEach(entity -> description.add(" - " + LangUtilsHook.getEntityName(entity, user)));
}
panelBuilder.item(5,
@ -178,7 +178,7 @@ public class SelectEntityGUI
ItemStack itemStack = this.asEggs ? GuiUtils.getEntityEgg(entity) : GuiUtils.getEntityHead(entity);
return new PanelItemBuilder().
name(WordUtils.capitalize(entity.name().toLowerCase().replace("_", " "))).
name(LangUtilsHook.getEntityName(entity, user)).
icon(itemStack).
description(this.selectedEntities.contains(entity) ?
this.user.getTranslation("challenges.gui.descriptions.admin.selected") : "").