Remove original LanguagePanel
This commit is contained in:
parent
0c6fcab27b
commit
5e6eec8dff
|
@ -7,7 +7,7 @@ import java.util.Optional;
|
|||
|
||||
import world.bentobox.bentobox.api.commands.CompositeCommand;
|
||||
import world.bentobox.bentobox.api.user.User;
|
||||
import world.bentobox.bentobox.panels.LanguagePanel;
|
||||
import world.bentobox.bentobox.panels.customizable.LanguagePanel;
|
||||
import world.bentobox.bentobox.util.Util;
|
||||
|
||||
/**
|
||||
|
@ -46,7 +46,7 @@ public class IslandLanguageCommand extends CompositeCommand {
|
|||
return false;
|
||||
}
|
||||
} else {
|
||||
LanguagePanel.openPanel(user);
|
||||
LanguagePanel.openPanel(this, user);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
package world.bentobox.bentobox.panels;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.apache.commons.lang.WordUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import world.bentobox.bentobox.BentoBox;
|
||||
import world.bentobox.bentobox.api.localization.BentoBoxLocale;
|
||||
import world.bentobox.bentobox.api.localization.TextVariables;
|
||||
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.managers.LocalesManager;
|
||||
|
||||
/**
|
||||
* @author Poslovitch
|
||||
*/
|
||||
public class LanguagePanel {
|
||||
|
||||
private LanguagePanel() {}
|
||||
|
||||
/**
|
||||
* Dynamically creates the panel.
|
||||
* @param user the User to show the panel to
|
||||
*/
|
||||
public static void openPanel(User user) {
|
||||
PanelBuilder panelBuilder = new PanelBuilder()
|
||||
.name(user.getTranslation("language.panel-title"));
|
||||
|
||||
LocalesManager localesManager = BentoBox.getInstance().getLocalesManager();
|
||||
|
||||
for (Locale locale : localesManager.getAvailableLocales(true)) {
|
||||
PanelItemBuilder localeIcon = new PanelItemBuilder();
|
||||
|
||||
BentoBoxLocale language = localesManager.getLanguages().get(locale);
|
||||
|
||||
ItemStack localeBanner = language.getBanner();
|
||||
// Set to a blank banner.
|
||||
localeIcon.icon(Objects.requireNonNullElseGet(localeBanner, () -> new ItemStack(Material.WHITE_BANNER, 1)));
|
||||
localeIcon.name(ChatColor.WHITE + WordUtils.capitalize(locale.getDisplayName(user.getLocale())))
|
||||
.clickHandler((panel, u, click, slot) -> {
|
||||
BentoBox.getInstance().getPlayers().setLocale(u.getUniqueId(), locale.toLanguageTag());
|
||||
u.sendMessage("language.edited", "[lang]", WordUtils.capitalize(locale.getDisplayName(user.getLocale())));
|
||||
openPanel(u);
|
||||
return true;
|
||||
});
|
||||
if (user.getLocale().equals(locale)) {
|
||||
localeIcon.description(user.getTranslation("language.description.selected"), "");
|
||||
} else {
|
||||
localeIcon.description(user.getTranslation("language.description.click-to-select"), "");
|
||||
}
|
||||
|
||||
localeIcon.description(user.getTranslation("language.description.authors"));
|
||||
for (String author : language.getAuthors()) {
|
||||
localeIcon.description(user.getTranslation("language.description.author", TextVariables.NAME, author));
|
||||
}
|
||||
|
||||
panelBuilder.item(localeIcon.build());
|
||||
}
|
||||
|
||||
panelBuilder.build().open(user);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue