Compare commits
2 commits
666c45735d
...
b85325fde5
Author | SHA1 | Date | |
---|---|---|---|
b85325fde5 | |||
8d394df1d6 |
11 changed files with 135 additions and 14 deletions
|
@ -6,7 +6,9 @@ import xyz.ineanto.nicko.appearance.Appearance;
|
|||
import xyz.ineanto.nicko.gui.items.common.GoBackItem;
|
||||
import xyz.ineanto.nicko.gui.items.common.ScrollDownItem;
|
||||
import xyz.ineanto.nicko.gui.items.common.ScrollUpItem;
|
||||
import xyz.ineanto.nicko.gui.items.favorites.FavoriteAddItem;
|
||||
import xyz.ineanto.nicko.gui.items.favorites.FavoriteAppearanceEntryItem;
|
||||
import xyz.ineanto.nicko.gui.items.favorites.FavoriteRemoveItem;
|
||||
import xyz.ineanto.nicko.language.LanguageKey;
|
||||
import xyz.ineanto.nicko.language.PlayerLanguage;
|
||||
import xyz.ineanto.nicko.profile.NickoProfile;
|
||||
|
@ -34,6 +36,9 @@ public class FavoritesGUI {
|
|||
final ScrollUpItem scrollUpItem = new ScrollUpItem(playerLanguage);
|
||||
final ScrollDownItem scrollDownItem = new ScrollDownItem(playerLanguage);
|
||||
|
||||
final FavoriteAddItem favoriteAddItem = new FavoriteAddItem(playerLanguage);
|
||||
final FavoriteRemoveItem favoriteRemoveItem = new FavoriteRemoveItem(playerLanguage);
|
||||
|
||||
final NickoProfile profile = Nicko.getInstance().getDataStore().getData(player.getUniqueId()).orElse(NickoProfile.EMPTY_PROFILE);
|
||||
final List<Appearance> favorites = profile.getFavorites();
|
||||
List<Item> items;
|
||||
|
@ -58,6 +63,8 @@ public class FavoritesGUI {
|
|||
guiItemBuilder.addIngredient('U', scrollUpItem);
|
||||
guiItemBuilder.addIngredient('D', scrollDownItem);
|
||||
guiItemBuilder.addIngredient('B', backItem.get(parent.getGUI(), parent.getTitle()));
|
||||
guiItemBuilder.addIngredient('A', favoriteAddItem.get());
|
||||
guiItemBuilder.addIngredient('R', favoriteRemoveItem.get());
|
||||
guiItemBuilder.setContent(items);
|
||||
});
|
||||
this.player = player;
|
||||
|
|
|
@ -3,7 +3,7 @@ package xyz.ineanto.nicko.gui.items.appearance;
|
|||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import xyz.ineanto.nicko.gui.prompt.PromptManager;
|
||||
import xyz.ineanto.nicko.prompt.PromptManager;
|
||||
import xyz.ineanto.nicko.language.LanguageKey;
|
||||
import xyz.ineanto.nicko.language.PlayerLanguage;
|
||||
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
||||
|
|
|
@ -3,7 +3,7 @@ package xyz.ineanto.nicko.gui.items.appearance;
|
|||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import xyz.ineanto.nicko.gui.prompt.PromptManager;
|
||||
import xyz.ineanto.nicko.prompt.PromptManager;
|
||||
import xyz.ineanto.nicko.language.LanguageKey;
|
||||
import xyz.ineanto.nicko.language.PlayerLanguage;
|
||||
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
||||
|
|
|
@ -4,7 +4,7 @@ import org.bukkit.Material;
|
|||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import xyz.ineanto.nicko.Nicko;
|
||||
import xyz.ineanto.nicko.gui.prompt.PromptManager;
|
||||
import xyz.ineanto.nicko.prompt.PromptManager;
|
||||
import xyz.ineanto.nicko.language.LanguageKey;
|
||||
import xyz.ineanto.nicko.language.PlayerLanguage;
|
||||
import xyz.ineanto.nicko.storage.name.PlayerNameStore;
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
package xyz.ineanto.nicko.gui.items.favorites;
|
||||
|
||||
import io.papermc.paper.datacomponent.DataComponentTypes;
|
||||
import io.papermc.paper.datacomponent.item.TooltipDisplay;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BannerMeta;
|
||||
import xyz.ineanto.nicko.language.LanguageKey;
|
||||
import xyz.ineanto.nicko.language.PlayerLanguage;
|
||||
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
||||
import xyz.xenondevs.invui.item.impl.SuppliedItem;
|
||||
|
||||
public class FavoriteAddItem {
|
||||
private final PlayerLanguage playerLanguage;
|
||||
|
||||
public FavoriteAddItem(PlayerLanguage playerLanguage) {
|
||||
this.playerLanguage = playerLanguage;
|
||||
}
|
||||
|
||||
public SuppliedItem get() {
|
||||
return new SuppliedItem(() -> {
|
||||
final ItemStack banner = new ItemStack(Material.GREEN_BANNER);
|
||||
final BannerMeta bannerMeta = (BannerMeta) banner.getItemMeta();
|
||||
|
||||
// Plus sign
|
||||
bannerMeta.addPattern(new Pattern(DyeColor.WHITE, PatternType.STRIPE_MIDDLE));
|
||||
bannerMeta.addPattern(new Pattern(DyeColor.WHITE, PatternType.STRIPE_CENTER));
|
||||
|
||||
// Remove excess on the borders
|
||||
bannerMeta.addPattern(new Pattern(DyeColor.GREEN, PatternType.BORDER));
|
||||
bannerMeta.addPattern(new Pattern(DyeColor.GREEN, PatternType.CURLY_BORDER));
|
||||
bannerMeta.addPattern(new Pattern(DyeColor.GREEN, PatternType.STRIPE_TOP));
|
||||
bannerMeta.addPattern(new Pattern(DyeColor.GREEN, PatternType.STRIPE_BOTTOM));
|
||||
|
||||
banner.setItemMeta(bannerMeta);
|
||||
|
||||
banner.addItemFlags(ItemFlag.HIDE_ADDITIONAL_TOOLTIP);
|
||||
banner.setData(DataComponentTypes.TOOLTIP_DISPLAY, TooltipDisplay
|
||||
.tooltipDisplay()
|
||||
.addHiddenComponents(DataComponentTypes.BANNER_PATTERNS)
|
||||
.build()
|
||||
);
|
||||
|
||||
final ItemBuilder builder = new ItemBuilder(banner);
|
||||
return playerLanguage.translateItem(builder, LanguageKey.GUI.Home.FAVORITES);
|
||||
}, click -> {
|
||||
final ClickType clickType = click.getClickType();
|
||||
if (clickType.isLeftClick() || clickType.isRightClick()) {
|
||||
click.getEvent().getView().close();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package xyz.ineanto.nicko.gui.items.favorites;
|
||||
|
||||
import io.papermc.paper.datacomponent.DataComponentTypes;
|
||||
import io.papermc.paper.datacomponent.item.TooltipDisplay;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.banner.Pattern;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
import org.bukkit.event.inventory.ClickType;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.BannerMeta;
|
||||
import xyz.ineanto.nicko.language.LanguageKey;
|
||||
import xyz.ineanto.nicko.language.PlayerLanguage;
|
||||
import xyz.xenondevs.invui.item.builder.ItemBuilder;
|
||||
import xyz.xenondevs.invui.item.impl.SuppliedItem;
|
||||
|
||||
public class FavoriteRemoveItem {
|
||||
private final PlayerLanguage playerLanguage;
|
||||
|
||||
public FavoriteRemoveItem(PlayerLanguage playerLanguage) {
|
||||
this.playerLanguage = playerLanguage;
|
||||
}
|
||||
|
||||
public SuppliedItem get() {
|
||||
return new SuppliedItem(() -> {
|
||||
final ItemStack banner = new ItemStack(Material.RED_BANNER);
|
||||
final BannerMeta bannerMeta = (BannerMeta) banner.getItemMeta();
|
||||
|
||||
// Minus sign
|
||||
bannerMeta.addPattern(new Pattern(DyeColor.WHITE, PatternType.STRIPE_MIDDLE));
|
||||
|
||||
// Remove excess
|
||||
bannerMeta.addPattern(new Pattern(DyeColor.RED, PatternType.BORDER));
|
||||
banner.setItemMeta(bannerMeta);
|
||||
|
||||
banner.addItemFlags(ItemFlag.HIDE_ADDITIONAL_TOOLTIP);
|
||||
banner.setData(DataComponentTypes.TOOLTIP_DISPLAY, TooltipDisplay
|
||||
.tooltipDisplay()
|
||||
.addHiddenComponents(DataComponentTypes.BANNER_PATTERNS)
|
||||
.build()
|
||||
);
|
||||
|
||||
final ItemBuilder builder = new ItemBuilder(banner);
|
||||
return playerLanguage.translateItem(builder, LanguageKey.GUI.Home.FAVORITES);
|
||||
}, click -> {
|
||||
final ClickType clickType = click.getClickType();
|
||||
if (clickType.isLeftClick() || clickType.isRightClick()) {
|
||||
click.getEvent().getView().close();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package xyz.ineanto.nicko.gui.prompt;
|
||||
package xyz.ineanto.nicko.prompt;
|
||||
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.entity.Player;
|
||||
|
@ -50,7 +50,7 @@ public abstract class Prompt {
|
|||
final ActionResult actionResult = appearanceManager.update(skinChange);
|
||||
if (!actionResult.isError()) {
|
||||
player.sendMessage(playerLanguage.translateWithWhoosh(LanguageKey.Event.Appearance.Set.OK));
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1, 1f);
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1f, 1f);
|
||||
} else {
|
||||
player.sendMessage(
|
||||
playerLanguage.translateWithOops(
|
|
@ -1,7 +1,7 @@
|
|||
package xyz.ineanto.nicko.gui.prompt;
|
||||
package xyz.ineanto.nicko.prompt;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import xyz.ineanto.nicko.gui.prompt.conversation.ConversationPrompt;
|
||||
import xyz.ineanto.nicko.prompt.conversation.ConversationPrompt;
|
||||
|
||||
public class PromptManager {
|
||||
private final Prompt prompt;
|
|
@ -1,4 +1,4 @@
|
|||
package xyz.ineanto.nicko.gui.prompt.anvil;
|
||||
package xyz.ineanto.nicko.prompt.anvil;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.wesjd.anvilgui.AnvilGUI;
|
||||
|
@ -7,15 +7,15 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import xyz.ineanto.nicko.Nicko;
|
||||
import xyz.ineanto.nicko.gui.prompt.Prompt;
|
||||
import xyz.ineanto.nicko.prompt.Prompt;
|
||||
import xyz.ineanto.nicko.language.LanguageKey;
|
||||
import xyz.ineanto.nicko.mojang.MojangUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* This is currently unused, I'm waiting for AnvilGUI
|
||||
* to be updated to compile with Paper mappings.
|
||||
* This is currently unused, I'm waiting on AnvilGUI
|
||||
* to be compiled against Paper mappings.
|
||||
*/
|
||||
// TODO (Ineanto, 16/05/2025): Do some validation on the inputs
|
||||
public class AnvilPrompt extends Prompt {
|
|
@ -1,4 +1,4 @@
|
|||
package xyz.ineanto.nicko.gui.prompt.conversation;
|
||||
package xyz.ineanto.nicko.prompt.conversation;
|
||||
|
||||
import org.bukkit.conversations.ConversationContext;
|
||||
import org.bukkit.conversations.ConversationFactory;
|
||||
|
@ -7,7 +7,7 @@ import org.bukkit.entity.Player;
|
|||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import xyz.ineanto.nicko.Nicko;
|
||||
import xyz.ineanto.nicko.gui.prompt.Prompt;
|
||||
import xyz.ineanto.nicko.prompt.Prompt;
|
||||
import xyz.ineanto.nicko.language.LanguageKey;
|
||||
|
||||
import java.util.Map;
|
|
@ -100,7 +100,6 @@ public class MariaDBStorage extends Storage {
|
|||
favorites = gson.fromJson(resultSet.getString("favorites"), new TypeToken<List<Appearance>>() { }.getType());
|
||||
}
|
||||
|
||||
// TODO (Ineanto, 17/05/2025): Retrieve favorites
|
||||
final NickoProfile profile = new NickoProfile(new Appearance(name, skin), Language.fromCode(locale), randomSkin, favorites);
|
||||
return Optional.of(profile);
|
||||
} catch (SQLException e) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue