diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/HMCCosmetics.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/HMCCosmetics.class index c68a1a88..ca5925fb 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/HMCCosmetics.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/HMCCosmetics.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/api/CosmeticItem.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/api/CosmeticItem.class index 401ce953..4d0fb1cd 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/api/CosmeticItem.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/api/CosmeticItem.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/command/CosmeticsCommand.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/command/CosmeticsCommand.class index 6549888b..cd0b012d 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/command/CosmeticsCommand.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/command/CosmeticsCommand.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/ActionSerializer.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/ActionSerializer.class index 46efa1ec..3e7e9098 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/ActionSerializer.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/ActionSerializer.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/DyeGuiSerializer.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/DyeGuiSerializer.class index 6973a6f4..5dd3d8ba 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/DyeGuiSerializer.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/DyeGuiSerializer.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/GuiSerializer.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/GuiSerializer.class index 11d4bc8c..742ee5e5 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/GuiSerializer.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/GuiSerializer.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/ItemSerializer.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/ItemSerializer.class index 6192bc9a..65d0142b 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/ItemSerializer.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/ItemSerializer.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/WardrobeSettings.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/WardrobeSettings.class index 6a6e076c..33bb3a99 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/WardrobeSettings.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/config/WardrobeSettings.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/cosmetic/CosmeticManager.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/cosmetic/CosmeticManager.class index af63b576..ec04a59e 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/cosmetic/CosmeticManager.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/cosmetic/CosmeticManager.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/database/Database.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/database/Database.class index 06030ae4..6dd04d7e 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/database/Database.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/database/Database.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/ArmorItem$1.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/ArmorItem$1.class index fa1fd9be..a5f58bc3 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/ArmorItem$1.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/ArmorItem$1.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/ArmorItem$Type.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/ArmorItem$Type.class index 2cd5f31f..d49ce624 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/ArmorItem$Type.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/ArmorItem$Type.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/ArmorItem.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/ArmorItem.class index cf3a77ed..1fda1e1c 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/ArmorItem.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/ArmorItem.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/CosmeticGui.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/CosmeticGui.class index 5015f707..7eb2cbdd 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/CosmeticGui.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/CosmeticGui.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/CosmeticsMenu.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/CosmeticsMenu.class index 7925f0d3..b5a87388 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/CosmeticsMenu.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/gui/CosmeticsMenu.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/listener/PlayerShiftListener.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/listener/PlayerShiftListener.class index edd5385e..36329e34 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/listener/PlayerShiftListener.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/listener/PlayerShiftListener.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/Adventure.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/Adventure.class index f0bf132a..45977acf 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/Adventure.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/Adventure.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/MessageHandler$1.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/MessageHandler$1.class index 6b877de1..9066d110 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/MessageHandler$1.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/MessageHandler$1.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/MessageHandler.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/MessageHandler.class index eb4102bb..8d1a1ea5 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/MessageHandler.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/MessageHandler.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/Messages$1.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/Messages$1.class index 483b904b..758ef937 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/Messages$1.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/Messages$1.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/Messages.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/Messages.class index d8ad0244..29757ab7 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/Messages.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/Messages.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/Permission.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/Permission.class index b5e81d37..0c51fb3f 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/Permission.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/message/Permission.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/packet/PacketManager.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/packet/PacketManager.class index 3bff95bb..9d973eb0 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/packet/PacketManager.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/packet/PacketManager.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/UserManager$1.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/UserManager$1.class index 21db65e8..579a70d4 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/UserManager$1.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/UserManager$1.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/UserManager.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/UserManager.class index 82851050..6e8353c7 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/UserManager.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/UserManager.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/Wardrobe.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/Wardrobe.class index 2a398e6e..4b0a4d99 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/Wardrobe.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/user/Wardrobe.class differ diff --git a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/util/Keys.class b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/util/Keys.class index 381d421c..86b5d6c2 100644 Binary files a/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/util/Keys.class and b/common/build/classes/java/main/io/github/fisher2911/hmccosmetics/util/Keys.class differ diff --git a/common/build/tmp/compileJava/previous-compilation-data.bin b/common/build/tmp/compileJava/previous-compilation-data.bin index a3efe597..da81514c 100644 Binary files a/common/build/tmp/compileJava/previous-compilation-data.bin and b/common/build/tmp/compileJava/previous-compilation-data.bin differ diff --git a/common/src/main/java/io/github/fisher2911/hmccosmetics/api/CosmeticItem.java b/common/src/main/java/io/github/fisher2911/hmccosmetics/api/CosmeticItem.java index d3423cf2..a0d6aa7b 100644 --- a/common/src/main/java/io/github/fisher2911/hmccosmetics/api/CosmeticItem.java +++ b/common/src/main/java/io/github/fisher2911/hmccosmetics/api/CosmeticItem.java @@ -27,6 +27,7 @@ public class CosmeticItem { public CosmeticItem( final ItemStack itemStack, + final String name, final String id, final ItemStack locked, final ItemStack applied, @@ -34,7 +35,7 @@ public class CosmeticItem { final ArmorItem.Type type, final boolean dyeable, final int rgb) { - this.armorItem = new ArmorItem(itemStack, id, locked, applied, permission, type, dyeable, rgb); + this.armorItem = new ArmorItem(itemStack, name, id, locked, applied, permission, type, dyeable, rgb); } /** @@ -47,6 +48,7 @@ public class CosmeticItem { public CosmeticItem( final Material material, + final String name, final String id, final Material locked, final Material applied, @@ -55,7 +57,7 @@ public class CosmeticItem { final boolean dyeable, final int rgb ) { - this.armorItem = new ArmorItem(material, id, new ItemStack(locked), new ItemStack(applied), permission, type, dyeable, rgb); + this.armorItem = new ArmorItem(material, name, id, new ItemStack(locked), new ItemStack(applied), permission, type, dyeable, rgb); } /** @@ -64,8 +66,8 @@ public class CosmeticItem { * @param type the cosmetic item type */ - public CosmeticItem(final ItemStack itemStack, final String id, final ItemStack locked, final ItemStack applied, final ArmorItem.Type type) { - this(itemStack, id, locked, applied, "", type, false, -1); + public CosmeticItem(final ItemStack itemStack, final String name, final String id, final ItemStack locked, final ItemStack applied, final ArmorItem.Type type) { + this(itemStack, name, id, locked, applied, "", type, false, -1); } /** @@ -74,8 +76,8 @@ public class CosmeticItem { * @param type the cosmetic item type */ - public CosmeticItem(final Material material, final Material locked, final Material applied, final String id, final ArmorItem.Type type) { - this(material, id, locked, applied, "", type, false, -1); + public CosmeticItem(final Material material, final Material locked, final Material applied, final String name, final String id, final ArmorItem.Type type) { + this(material, name, id, locked, applied, "", type, false, -1); } public ItemStack getItemStack(final ArmorItem.Status status) { diff --git a/common/src/main/java/io/github/fisher2911/hmccosmetics/command/CosmeticsCommand.java b/common/src/main/java/io/github/fisher2911/hmccosmetics/command/CosmeticsCommand.java index 371b7794..f916d9a3 100644 --- a/common/src/main/java/io/github/fisher2911/hmccosmetics/command/CosmeticsCommand.java +++ b/common/src/main/java/io/github/fisher2911/hmccosmetics/command/CosmeticsCommand.java @@ -379,7 +379,10 @@ public class CosmeticsCommand extends CommandBase { @SubCommand("token") @Permission(io.github.fisher2911.hmccosmetics.message.Permission.GIVE_TOKEN) - public void token(final CommandSender sender, @Completion("#tokens") final String tokenId, @me.mattstudios.mf.annotations.Optional Player giveTo) { + public void token( + final CommandSender sender, + @Completion("#tokens") final String tokenId, + @Completion("#players") @me.mattstudios.mf.annotations.Optional Player giveTo) { if (!(sender instanceof Player) && giveTo == null) { this.messageHandler.sendMessage( sender, @@ -399,7 +402,7 @@ public class CosmeticsCommand extends CommandBase { return; } giveTo.getInventory().addItem(token.getItemStack().clone()); - final String tokenName = token.getArmorItem().getItemName(); + final String tokenName = token.getArmorItem().getName(); this.messageHandler.sendMessage( sender, Messages.GAVE_TOKEN, diff --git a/common/src/main/java/io/github/fisher2911/hmccosmetics/config/ArmorItemSerializer.java b/common/src/main/java/io/github/fisher2911/hmccosmetics/config/ArmorItemSerializer.java index 2f02cb3c..5ec68c8d 100644 --- a/common/src/main/java/io/github/fisher2911/hmccosmetics/config/ArmorItemSerializer.java +++ b/common/src/main/java/io/github/fisher2911/hmccosmetics/config/ArmorItemSerializer.java @@ -30,8 +30,9 @@ public class ArmorItemSerializer implements TypeSerializer { private ArmorItemSerializer() { } - private static final String ITEM = "item"; + private static final String NAME = "name"; private static final String LOCKED_LORE = "locked-lore"; + private static final String APPLIED_LORE = "applied-lore"; private static final String LOCKED_ITEM = "locked-item"; private static final String APPLIED_ITEM = "applied-item"; private static final String PERMISSION = "permission"; @@ -54,7 +55,9 @@ public class ArmorItemSerializer implements TypeSerializer { @Override public WrappedGuiItem deserialize(final Type type, final ConfigurationNode source) throws SerializationException { + final ConfigurationNode nameNode = source.node(NAME); final ConfigurationNode lockedLoreNode = source.node(LOCKED_LORE); + final ConfigurationNode appliedLoreNode = source.node(APPLIED_LORE); final ConfigurationNode lockedItemNode = source.node(LOCKED_ITEM); final ConfigurationNode appliedItemNode = source.node(APPLIED_ITEM); final ConfigurationNode permissionNode = source.node(PERMISSION); @@ -76,7 +79,12 @@ public class ArmorItemSerializer implements TypeSerializer { lockedItem = ItemBuilder.from(itemStack.clone()).lore(lockedLore).build(); } ItemStack appliedItem = ItemSerializer.INSTANCE.deserialize(ItemStack.class, appliedItemNode); - if (appliedItem == null) appliedItem = itemStack.clone(); + if (appliedItem == null) { + final List appliedLore = Utils.replaceIfNull(appliedLoreNode.getList(String.class), + new ArrayList()). + stream().map(StringUtils::parseStringToString).collect(Collectors.toList()); + appliedItem = ItemBuilder.from(itemStack.clone()).lore(appliedLore).build(); + } final boolean dyeable = dyeableNode.getBoolean(); @@ -95,6 +103,7 @@ public class ArmorItemSerializer implements TypeSerializer { return new BalloonItem( itemStack, actions, + Utils.replaceIfNull(nameNode.getString(), ""), Utils.replaceIfNull(idNode.getString(), ""), lockedItem, appliedItem, @@ -109,6 +118,7 @@ public class ArmorItemSerializer implements TypeSerializer { return new ArmorItem( itemStack, actions, + Utils.replaceIfNull(nameNode.getString(), ""), Utils.replaceIfNull(idNode.getString(), ""), lockedItem, appliedItem, diff --git a/common/src/main/java/io/github/fisher2911/hmccosmetics/gui/ArmorItem.java b/common/src/main/java/io/github/fisher2911/hmccosmetics/gui/ArmorItem.java index 729242bf..2afaaf96 100644 --- a/common/src/main/java/io/github/fisher2911/hmccosmetics/gui/ArmorItem.java +++ b/common/src/main/java/io/github/fisher2911/hmccosmetics/gui/ArmorItem.java @@ -2,13 +2,10 @@ package io.github.fisher2911.hmccosmetics.gui; import com.comphenix.protocol.wrappers.EnumWrappers; import dev.triumphteam.gui.components.GuiAction; -import dev.triumphteam.gui.guis.GuiItem; import io.github.fisher2911.hmccosmetics.config.CosmeticGuiAction; import io.github.fisher2911.hmccosmetics.util.builder.ColorBuilder; -import io.github.fisher2911.hmccosmetics.util.builder.ItemBuilder; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import org.bukkit.Color; @@ -16,12 +13,12 @@ import org.bukkit.Material; import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; -import org.bukkit.inventory.meta.ItemMeta; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public class ArmorItem extends WrappedGuiItem { + private final String name; private final String id; private final ItemStack lockedItem; private final ItemStack appliedItem; @@ -34,6 +31,7 @@ public class ArmorItem extends WrappedGuiItem { public ArmorItem( @NotNull final ItemStack itemStack, final List actions, + final String name, final String id, final ItemStack lockedItem, final ItemStack appliedItem, @@ -41,7 +39,7 @@ public class ArmorItem extends WrappedGuiItem { final Type type, final int dye) { super(itemStack, null); - + this.name = name; this.id = id; this.lockedItem = lockedItem; this.appliedItem = appliedItem; @@ -53,6 +51,7 @@ public class ArmorItem extends WrappedGuiItem { public ArmorItem( @NotNull final ItemStack itemStack, + final String name, final String id, final ItemStack lockedItem, final ItemStack appliedItem, @@ -61,6 +60,7 @@ public class ArmorItem extends WrappedGuiItem { final int dye) { super(itemStack); this.id = id; + this.name = name; this.lockedItem = lockedItem; this.appliedItem = appliedItem; this.actions = new ArrayList<>(); @@ -71,6 +71,7 @@ public class ArmorItem extends WrappedGuiItem { public ArmorItem( @NotNull final Material material, + final String name, final String id, final ItemStack lockedItem, final ItemStack appliedItem, @@ -79,6 +80,7 @@ public class ArmorItem extends WrappedGuiItem { final int dye) { super(material); this.id = id; + this.name = name; this.lockedItem = lockedItem; this.appliedItem = appliedItem; this.actions = new ArrayList<>(); @@ -90,6 +92,7 @@ public class ArmorItem extends WrappedGuiItem { public ArmorItem( @NotNull final Material material, final List actions, + final String name, final String id, final ItemStack lockedItem, final ItemStack appliedItem, @@ -97,10 +100,11 @@ public class ArmorItem extends WrappedGuiItem { final Type type, final int dye) { super(material, null); + this.actions = actions; this.id = id; + this.name = name; this.lockedItem = lockedItem; this.appliedItem = appliedItem; - this.actions = new ArrayList<>(); this.permission = permission; this.type = type; this.dye = dye; @@ -109,6 +113,7 @@ public class ArmorItem extends WrappedGuiItem { public ArmorItem( @NotNull final ItemStack itemStack, final List actions, + final String name, final String id, final ItemStack lockedItem, final ItemStack appliedItem, @@ -117,6 +122,7 @@ public class ArmorItem extends WrappedGuiItem { final boolean dyeable, final int dye) { super(itemStack, null); + this.name = name; this.id = id; this.lockedItem = lockedItem; this.appliedItem = appliedItem; @@ -129,6 +135,7 @@ public class ArmorItem extends WrappedGuiItem { public ArmorItem( @NotNull final ItemStack itemStack, + final String name, final String id, final ItemStack lockedItem, final ItemStack appliedItem, @@ -137,6 +144,7 @@ public class ArmorItem extends WrappedGuiItem { final boolean dyeable, final int dye) { super(itemStack); + this.name = name; this.id = id; this.lockedItem = lockedItem; this.appliedItem = appliedItem; @@ -149,6 +157,7 @@ public class ArmorItem extends WrappedGuiItem { public ArmorItem( @NotNull final Material material, + final String name, final String id, final ItemStack lockedItem, final ItemStack appliedItem, @@ -158,6 +167,7 @@ public class ArmorItem extends WrappedGuiItem { final int dye) { super(material); this.id = id; + this.name = name; this.lockedItem = lockedItem; this.appliedItem = appliedItem; this.actions = new ArrayList<>(); @@ -170,6 +180,7 @@ public class ArmorItem extends WrappedGuiItem { public ArmorItem( @NotNull final Material material, @Nullable final GuiAction action, + final String name, final String id, final ItemStack lockedItem, final ItemStack appliedItem, @@ -178,6 +189,7 @@ public class ArmorItem extends WrappedGuiItem { final boolean dyeable, final int dye) { super(material, action); + this.name = name; this.id = id; this.lockedItem = lockedItem; this.appliedItem = appliedItem; @@ -190,6 +202,7 @@ public class ArmorItem extends WrappedGuiItem { protected ArmorItem(final ArmorItem armorItem) { super(armorItem.getItemStack().clone(), null); + this.name = armorItem.getName(); this.id = armorItem.getId(); this.lockedItem = armorItem.getLockedItem().clone(); this.appliedItem = armorItem.getAppliedItem().clone(); @@ -209,6 +222,7 @@ public class ArmorItem extends WrappedGuiItem { return new BalloonItem( new ItemStack(Material.AIR), id, + id, new ItemStack(Material.AIR), new ItemStack(Material.AIR), "", @@ -220,6 +234,7 @@ public class ArmorItem extends WrappedGuiItem { return new ArmorItem( new ItemStack(Material.AIR), id, + id, new ItemStack(Material.AIR), new ItemStack(Material.AIR), "", @@ -298,10 +313,8 @@ public class ArmorItem extends WrappedGuiItem { return new ArmorItem(this); } - public String getItemName() { - final ItemMeta itemMeta = this.getItemStack(Status.ALLOWED).getItemMeta(); - if (itemMeta == null) return this.id; - return itemMeta.getDisplayName(); + public String getName() { + return this.name; } public enum Type { diff --git a/common/src/main/java/io/github/fisher2911/hmccosmetics/gui/BalloonItem.java b/common/src/main/java/io/github/fisher2911/hmccosmetics/gui/BalloonItem.java index b4f077b9..5c29745d 100644 --- a/common/src/main/java/io/github/fisher2911/hmccosmetics/gui/BalloonItem.java +++ b/common/src/main/java/io/github/fisher2911/hmccosmetics/gui/BalloonItem.java @@ -19,6 +19,7 @@ public class BalloonItem extends ArmorItem { this( item.getItemStack(), item.getActions(), + item.getName(), item.getId(), item.getLockedItem(), item.getAppliedItem(), @@ -29,43 +30,43 @@ public class BalloonItem extends ArmorItem { ); } - public BalloonItem(final @NotNull ItemStack itemStack, final List actions, final String id, final ItemStack lockedItem, final ItemStack appliedItem, final String permission, final Type type, final int dye, final String modelId) { - super(itemStack, actions, id, lockedItem, appliedItem, permission, type, dye); + public BalloonItem(final @NotNull ItemStack itemStack, final List actions, final String name, final String id, final ItemStack lockedItem, final ItemStack appliedItem, final String permission, final Type type, final int dye, final String modelId) { + super(itemStack, actions, name, id, lockedItem, appliedItem, permission, type, dye); this.modelId = modelId; } - public BalloonItem(final @NotNull ItemStack itemStack, final String id, final ItemStack lockedItem, final ItemStack appliedItem, final String permission, final Type type, final int dye, final String modelId) { - super(itemStack, id, lockedItem, appliedItem, permission, type, dye); + public BalloonItem(final @NotNull ItemStack itemStack, final String name, final String id, final ItemStack lockedItem, final ItemStack appliedItem, final String permission, final Type type, final int dye, final String modelId) { + super(itemStack, name, id, lockedItem, appliedItem, permission, type, dye); this.modelId = modelId; } - public BalloonItem(final @NotNull Material material, final String id, final ItemStack lockedItem, final ItemStack appliedItem, final String permission, final Type type, final int dye, final String modelId) { - super(material, id, lockedItem, appliedItem, permission, type, dye); + public BalloonItem(final @NotNull Material material, final String name, final String id, final ItemStack lockedItem, final ItemStack appliedItem, final String permission, final Type type, final int dye, final String modelId) { + super(material, name, id, lockedItem, appliedItem, permission, type, dye); this.modelId = modelId; } - public BalloonItem(final @NotNull Material material, final List actions, final String id, final ItemStack lockedItem, final ItemStack appliedItem, final String permission, final Type type, final int dye, final String modelId) { - super(material, actions, id, lockedItem, appliedItem, permission, type, dye); + public BalloonItem(final @NotNull Material material, final List actions, final String name, final String id, final ItemStack lockedItem, final ItemStack appliedItem, final String permission, final Type type, final int dye, final String modelId) { + super(material, actions, name, id, lockedItem, appliedItem, permission, type, dye); this.modelId = modelId; } - public BalloonItem(final @NotNull ItemStack itemStack, final List actions, final String id, final ItemStack lockedItem, final ItemStack appliedItem, final String permission, final Type type, final boolean dyeable, final int dye, final String modelId) { - super(itemStack, actions, id, lockedItem, appliedItem, permission, type, dyeable, dye); + public BalloonItem(final @NotNull ItemStack itemStack, final List actions, final String name, final String id, final ItemStack lockedItem, final ItemStack appliedItem, final String permission, final Type type, final boolean dyeable, final int dye, final String modelId) { + super(itemStack, actions, name, id, lockedItem, appliedItem, permission, type, dyeable, dye); this.modelId = modelId; } - public BalloonItem(final @NotNull ItemStack itemStack, final String id, final ItemStack lockedItem, final ItemStack appliedItem, final String permission, final Type type, final boolean dyeable, final int dye, final String modelId) { - super(itemStack, id, lockedItem, appliedItem, permission, type, dyeable, dye); + public BalloonItem(final @NotNull ItemStack itemStack, final String name, final String id, final ItemStack lockedItem, final ItemStack appliedItem, final String permission, final Type type, final boolean dyeable, final int dye, final String modelId) { + super(itemStack, name, id, lockedItem, appliedItem, permission, type, dyeable, dye); this.modelId = modelId; } - public BalloonItem(final @NotNull Material material, final String id, final ItemStack lockedItem, final ItemStack appliedItem, final String permission, final Type type, final boolean dyeable, final int dye, final String modelId) { - super(material, id, lockedItem, appliedItem, permission, type, dyeable, dye); + public BalloonItem(final @NotNull Material material, final String name, final String id, final ItemStack lockedItem, final ItemStack appliedItem, final String permission, final Type type, final boolean dyeable, final int dye, final String modelId) { + super(material, name, id, lockedItem, appliedItem, permission, type, dyeable, dye); this.modelId = modelId; } - public BalloonItem(final @NotNull Material material, final @Nullable GuiAction action, final String id, final ItemStack lockedItem, final ItemStack appliedItem, final String permission, final Type type, final boolean dyeable, final int dye, final String modelId) { - super(material, action, id, lockedItem, appliedItem, permission, type, dyeable, dye); + public BalloonItem(final @NotNull Material material, final String name, final @Nullable GuiAction action, final String id, final ItemStack lockedItem, final ItemStack appliedItem, final String permission, final Type type, final boolean dyeable, final int dye, final String modelId) { + super(material, action, name, id, lockedItem, appliedItem, permission, type, dyeable, dye); this.modelId = modelId; } diff --git a/common/src/main/java/io/github/fisher2911/hmccosmetics/gui/TokenGui.java b/common/src/main/java/io/github/fisher2911/hmccosmetics/gui/TokenGui.java index 381f3552..55ed98ca 100644 --- a/common/src/main/java/io/github/fisher2911/hmccosmetics/gui/TokenGui.java +++ b/common/src/main/java/io/github/fisher2911/hmccosmetics/gui/TokenGui.java @@ -1,13 +1,15 @@ package io.github.fisher2911.hmccosmetics.gui; -import com.google.common.collect.HashBiMap; import dev.triumphteam.gui.guis.GuiItem; import io.github.fisher2911.hmccosmetics.HMCCosmetics; import io.github.fisher2911.hmccosmetics.cosmetic.CosmeticManager; import io.github.fisher2911.hmccosmetics.message.Messages; import io.github.fisher2911.hmccosmetics.message.Placeholder; import io.github.fisher2911.hmccosmetics.user.User; +import org.bukkit.Bukkit; +import org.bukkit.Material; import org.bukkit.entity.Player; +import org.bukkit.event.inventory.ClickType; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; @@ -33,28 +35,38 @@ public class TokenGui extends CosmeticGui { @Override public void open(final User user, final Player player) { - player.sendMessage("Opened GUI"); super.open(user, player); + this.gui.setDragAction(event -> event.setCancelled(true)); this.gui.setDefaultClickAction(event -> { - player.sendMessage("Test"); final int slot = event.getSlot(); final Inventory inventory = event.getClickedInventory(); if (inventory == null) { event.setCancelled(true); return; } - if (event.getClickedInventory().equals(event.getView().getBottomInventory())) { - player.sendMessage("Same inventory"); - return; - } - player.sendMessage("Not same"); - if (slot != tokenSlot && slot != this.cosmeticSlot) { + final ClickType clickType = event.getClick(); + if (clickType == ClickType.SHIFT_RIGHT || clickType == ClickType.SHIFT_LEFT) { event.setCancelled(true); return; } + if (event.getClickedInventory().equals(event.getView().getBottomInventory())) return; + ItemStack tokenItem = event.getInventory().getItem(this.tokenSlot); + if (slot != tokenSlot && slot != this.cosmeticSlot) { + event.setCancelled(true); + if (tokenItem == null) { + inventory.setItem(this.cosmeticSlot, new ItemStack(Material.AIR)); + } + return; + } final ItemStack inHand = event.getCursor(); + Token token; if (slot == this.tokenSlot) { - final Token token = this.cosmeticManager.getToken(inHand); + if (inHand == null || inHand.getType() == Material.AIR) { + if (tokenItem != null && tokenItem.getAmount() > 1 && clickType == ClickType.RIGHT) return; + inventory.setItem(this.cosmeticSlot, new ItemStack(Material.AIR)); + return; + } + token = this.cosmeticManager.getToken(inHand); if (token == null) { event.setCancelled(true); return; @@ -63,18 +75,16 @@ public class TokenGui extends CosmeticGui { inventory.setItem(this.cosmeticSlot, item.getItemStack(ArmorItem.Status.ALLOWED)); return; } - final ItemStack tokenItem = event.getInventory().getItem(this.tokenSlot); - if (tokenItem == null) { + if (inHand != null && inHand.getType() != Material.AIR) { event.setCancelled(true); return; } - final Token token = this.cosmeticManager.getToken(tokenItem); + tokenItem = inventory.getItem(this.tokenSlot); + token = this.cosmeticManager.getToken(tokenItem); if (token == null) { event.setCancelled(true); return; } - tokenItem.setAmount(tokenItem.getAmount() - 1); - inventory.setItem(this.tokenSlot, tokenItem); final ItemStack clicked = event.getCurrentItem(); final ArmorItem armorItem = token.getArmorItem(); if (clicked == null) return; @@ -82,22 +92,26 @@ public class TokenGui extends CosmeticGui { this.messageHandler.sendMessage( player, Messages.ALREADY_UNLOCKED, - Map.of(Placeholder.ID, armorItem.getItemName()) + Map.of(Placeholder.ID, armorItem.getName()) ); + event.setCancelled(true); return; } + tokenItem.setAmount(tokenItem.getAmount() - 1); + inventory.setItem(this.tokenSlot, tokenItem); clicked.setAmount(0); player.addAttachment(this.plugin, armorItem.getPermission(), true); this.messageHandler.sendMessage( player, Messages.TRADED_TOKEN, - Map.of(Placeholder.ID, armorItem.getItemName()) + Map.of(Placeholder.ID, armorItem.getName()) ); }); this.gui.setCloseGuiAction(event -> { final Inventory inventory = event.getInventory(); final ItemStack tokens = inventory.getItem(this.tokenSlot); + if (tokens == null) return; event.getPlayer().getInventory().addItem(tokens); user.setOpenGui(null); }); diff --git a/common/src/main/java/io/github/fisher2911/hmccosmetics/hook/PAPIExpansion.java b/common/src/main/java/io/github/fisher2911/hmccosmetics/hook/PAPIExpansion.java index a44bd258..f7fca73d 100644 --- a/common/src/main/java/io/github/fisher2911/hmccosmetics/hook/PAPIExpansion.java +++ b/common/src/main/java/io/github/fisher2911/hmccosmetics/hook/PAPIExpansion.java @@ -1,9 +1,7 @@ package io.github.fisher2911.hmccosmetics.hook; import io.github.fisher2911.hmccosmetics.HMCCosmetics; -import io.github.fisher2911.hmccosmetics.api.CosmeticItem; import io.github.fisher2911.hmccosmetics.gui.ArmorItem; -import io.github.fisher2911.hmccosmetics.message.Placeholder; import io.github.fisher2911.hmccosmetics.message.Translation; import io.github.fisher2911.hmccosmetics.user.User; import io.github.fisher2911.hmccosmetics.user.UserManager; @@ -12,9 +10,6 @@ import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import java.util.Collection; -import java.util.Collections; -import java.util.List; import java.util.Optional; public class PAPIExpansion extends PlaceholderExpansion { @@ -76,7 +71,7 @@ public class PAPIExpansion extends PlaceholderExpansion { for (final ArmorItem item : user.getPlayerArmor().getArmorItems()) { if (item.getType().equals(type)) { if (formatted) { - final String name = item.getItemName(); + final String name = item.getName(); if (name.isBlank()) return item.getId().replace("_", ""); return name; }