Fixed world_name placeholder for settings titles.

This commit is contained in:
tastybento 2018-07-06 10:14:07 -07:00
parent 4963ea573c
commit 4c4a72718e
2 changed files with 11 additions and 9 deletions

View File

@ -34,7 +34,7 @@ public class IslandSettingsCommand extends CompositeCommand {
public boolean execute(User user, List<String> args) {
// Settings are only shown if you are in the right world
if (Util.getWorld(user.getWorld()).equals(getWorld())) {
SettingsPanel.openPanel(getPlugin(), user, Flag.Type.PROTECTION); //TODO keep track of history?
SettingsPanel.openPanel(getPlugin(), user, Flag.Type.PROTECTION, getWorld()); //TODO keep track of history?
return true;
} else {
user.sendMessage("general.errors.wrong-world");

View File

@ -1,6 +1,9 @@
package us.tastybento.bskyblock.panels;
import java.util.Comparator;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.inventory.ItemStack;
import us.tastybento.bskyblock.BSkyBlock;
@ -10,8 +13,6 @@ import us.tastybento.bskyblock.api.panels.builders.PanelBuilder;
import us.tastybento.bskyblock.api.panels.builders.PanelItemBuilder;
import us.tastybento.bskyblock.api.user.User;
import java.util.Comparator;
/**
* Creates settings panels
* @author Poslovitch, tastybento
@ -27,13 +28,14 @@ public class SettingsPanel {
* @param plugin - plugin
* @param user the User to show the panel to
*/
public static void openPanel(BSkyBlock plugin, User user, Flag.Type flagType) {
public static void openPanel(BSkyBlock plugin, User user, Flag.Type flagType, World world) {
String friendlyWorldName = plugin.getIWM().getFriendlyName(world);
// Create the panel
PanelBuilder panelBuilder = new PanelBuilder()
.name(user.getTranslation(PROTECTION_PANEL + flagType.toString() + ".title"))
.name(user.getTranslation(PROTECTION_PANEL + flagType.toString() + ".title", "[world_name]", friendlyWorldName))
.size(54);
setupHeader(user, panelBuilder, flagType);
setupHeader(user, panelBuilder, flagType, world, friendlyWorldName);
plugin.getFlagsManager().getFlags().stream().filter(f -> f.getType().equals(flagType))
.sorted(Comparator.comparing(Flag::getID)).forEach((f -> panelBuilder.item(f.toPanelItem(plugin, user))));
@ -42,17 +44,17 @@ public class SettingsPanel {
panelBuilder.build().open(user);
}
private static void setupHeader(User user, PanelBuilder panelBuilder, Flag.Type currentFlagType) {
private static void setupHeader(User user, PanelBuilder panelBuilder, Flag.Type currentFlagType, World world, String friendlyWorldName) {
int slot = 2;
for (Flag.Type flagType : Flag.Type.values()) {
PanelItem panelItem = new PanelItemBuilder()
.icon(flagType.getIcon())
.name(user.getTranslation(PROTECTION_PANEL + flagType.toString() + ".title"))
.name(user.getTranslation(PROTECTION_PANEL + flagType.toString() + ".title", "[world_name]", friendlyWorldName))
.description(user.getTranslation(PROTECTION_PANEL + flagType.toString() + ".description"))
.glow(flagType.equals(currentFlagType))
.clickHandler((panel, user1, clickType, slot1) -> {
if (!flagType.equals(currentFlagType)) {
openPanel(BSkyBlock.getInstance(), user, flagType);
openPanel(BSkyBlock.getInstance(), user, flagType, world);
}
return true;
})