feat: remove favorite
This commit is contained in:
parent
e20dcabff7
commit
769fb97500
10 changed files with 24 additions and 78 deletions
|
@ -101,7 +101,7 @@ tasks {
|
|||
|
||||
runServer {
|
||||
downloadPlugins {
|
||||
//url("https://download.luckperms.net/1593/bukkit/loader/LuckPerms-Bukkit-5.5.8.jar")
|
||||
url("https://share.ineanto.xyz/-Yr74eKNUp6/NoEncryptionX-1.0.0-SNAPSHOT.jar")
|
||||
|
||||
// 1.20.5 - latest testing
|
||||
//url("https://ci.dmulloy2.net/job/ProtocolLib/lastSuccessfulBuild/artifact/build/libs/ProtocolLib.jar")
|
||||
|
|
|
@ -2,7 +2,6 @@ package xyz.ineanto.nicko;
|
|||
|
||||
import com.github.retrooper.packetevents.PacketEvents;
|
||||
import com.github.retrooper.packetevents.manager.server.ServerVersion;
|
||||
import com.github.retrooper.packetevents.settings.PacketEventsSettings;
|
||||
import io.github.retrooper.packetevents.factory.spigot.SpigotPacketEventsBuilder;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
@ -43,13 +42,7 @@ public class Nicko extends JavaPlugin {
|
|||
|
||||
@Override
|
||||
public void onLoad() {
|
||||
PacketEvents.setAPI(
|
||||
SpigotPacketEventsBuilder.build(this,
|
||||
new PacketEventsSettings()
|
||||
.checkForUpdates(true)
|
||||
.kickOnPacketException(true)
|
||||
)
|
||||
);
|
||||
PacketEvents.setAPI(SpigotPacketEventsBuilder.build(this));
|
||||
PacketEvents.getAPI().load();
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ 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;
|
||||
|
@ -37,7 +36,6 @@ public class FavoritesGUI {
|
|||
final ScrollDownItem scrollDownItem = new ScrollDownItem(playerLanguage);
|
||||
|
||||
final FavoriteAddItem favoriteAddItem = new FavoriteAddItem(player);
|
||||
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();
|
||||
|
@ -58,13 +56,12 @@ public class FavoritesGUI {
|
|||
"x x x x x x x x #",
|
||||
"x x x x x x x x #",
|
||||
"x x x x x x x x D",
|
||||
"% % % A B R % % %");
|
||||
"% % % A B % % % %");
|
||||
guiItemBuilder.addIngredient('x', Markers.CONTENT_LIST_SLOT_HORIZONTAL);
|
||||
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;
|
||||
|
|
|
@ -30,4 +30,4 @@ public class ChangeNameItem {
|
|||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ import xyz.ineanto.nicko.Nicko;
|
|||
import xyz.ineanto.nicko.appearance.ActionResult;
|
||||
import xyz.ineanto.nicko.appearance.Appearance;
|
||||
import xyz.ineanto.nicko.appearance.AppearanceManager;
|
||||
import xyz.ineanto.nicko.gui.FavoritesGUI;
|
||||
import xyz.ineanto.nicko.gui.items.ItemDefaults;
|
||||
import xyz.ineanto.nicko.language.LanguageKey;
|
||||
import xyz.ineanto.nicko.language.PlayerLanguage;
|
||||
|
@ -19,6 +20,8 @@ import xyz.xenondevs.invui.item.builder.SkullBuilder;
|
|||
import xyz.xenondevs.invui.item.impl.AsyncItem;
|
||||
import xyz.xenondevs.invui.item.impl.SuppliedItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FavoriteAppearanceEntryItem extends AsyncItem {
|
||||
private final PlayerDataStore dataStore = Nicko.getInstance().getDataStore();
|
||||
|
||||
|
@ -55,8 +58,19 @@ public class FavoriteAppearanceEntryItem extends AsyncItem {
|
|||
|
||||
@Override
|
||||
public void handleClick(@NotNull ClickType clickType, @NotNull Player player, @NotNull InventoryClickEvent event) {
|
||||
if(clickType.isShiftClick()) {
|
||||
final NickoProfile profile = dataStore.getData(player.getUniqueId()).orElse(NickoProfile.EMPTY_PROFILE);
|
||||
|
||||
final List<Appearance> favorites = profile.getFavorites();
|
||||
favorites.remove(appearance);
|
||||
dataStore.updateCache(player.getUniqueId(), profile);
|
||||
new FavoritesGUI(player).open();
|
||||
return;
|
||||
}
|
||||
|
||||
if (clickType.isLeftClick() || clickType.isRightClick()) {
|
||||
event.getView().close();
|
||||
|
||||
final NickoProfile profile = dataStore.getData(player.getUniqueId()).orElse(NickoProfile.EMPTY_PROFILE);
|
||||
final AppearanceManager appearanceManager = new AppearanceManager(player);
|
||||
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
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.Favorites.REMOVE);
|
||||
}, click -> {
|
||||
final ClickType clickType = click.getClickType();
|
||||
if (clickType.isLeftClick() || clickType.isRightClick()) {
|
||||
click.getEvent().getView().close();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
|
@ -27,7 +27,7 @@ public class FavoritesItem {
|
|||
if (clickType.isLeftClick() || clickType.isRightClick()) {
|
||||
click.getEvent().getView().close();
|
||||
new FavoritesGUI(click.getPlayer()).open();
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_CHEST_OPEN, 1, 1f);
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_CHEST_OPEN, 0.5f, 1f);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -33,6 +33,7 @@ public class ResetItem {
|
|||
optionalProfile.ifPresent(profile -> {
|
||||
if (!profile.hasData()) {
|
||||
player.sendMessage(playerLanguage.translateWithOops(LanguageKey.Event.Appearance.Remove.MISSING));
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1f, 1f);
|
||||
event.getEvent().getView().close();
|
||||
return;
|
||||
}
|
||||
|
@ -41,9 +42,10 @@ public class ResetItem {
|
|||
final ActionResult reset = appearanceManager.reset();
|
||||
if (!reset.isError()) {
|
||||
player.sendMessage(playerLanguage.translateWithWhoosh(LanguageKey.Event.Appearance.Remove.OK));
|
||||
player.playSound(player.getLocation(), Sound.BLOCK_WOODEN_BUTTON_CLICK_ON, 1f, 1f);
|
||||
} else {
|
||||
player.sendMessage(playerLanguage.translateWithOops(LanguageKey.Event.Appearance.Remove.ERROR, reset.getErrorKey()));
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1f);
|
||||
player.playSound(player.getLocation(), Sound.ENTITY_VILLAGER_HURT, 1f, 1f);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
|
|
@ -159,7 +159,7 @@ gui:
|
|||
name: "Random skin on login"
|
||||
favorites:
|
||||
add:
|
||||
name: "Add a favorite"
|
||||
name: "New favorite"
|
||||
lore:
|
||||
- "<grey>Add a new favorite appearance to the list.</grey>"
|
||||
- "<grey>Hold <gold>SHIFT</gold> to add your current disguise!</grey>"
|
||||
|
|
|
@ -161,15 +161,10 @@ gui:
|
|||
name: "Apparence aléatoire à la connexion"
|
||||
favorites:
|
||||
add:
|
||||
name: "Ajouter un favori"
|
||||
name: "Nouveau favori"
|
||||
lore:
|
||||
- "<grey>Ajoute une nouvelle apparence favorite.</grey>"
|
||||
- "<grey>Maintenez <gold>SHIFT</gold> pour ajouter votre apparence actuelle !</grey>"
|
||||
remove:
|
||||
name: "Activer la suppression"
|
||||
lore:
|
||||
- "<grey>Cliquer sur un déguisement lorsque le mode est</grey>"
|
||||
- "<grey>actif le supprimera de vos favoris.</grey>"
|
||||
entry:
|
||||
name: "<gold>Favori</gold>"
|
||||
lore:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue