9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-29 20:09:13 +00:00

Allowed setting of other items in cosmetic slots

This commit is contained in:
MasterOfTheFish
2022-02-18 20:06:20 -05:00
parent 54fe2719d1
commit ed41b71ff3
3 changed files with 26 additions and 8 deletions

View File

@@ -151,7 +151,7 @@ public class CosmeticGui {
}
@Nullable
private GuiItem getGuiItem(final User user, final Player player, final GuiItem guiItem, final ItemStack itemStack) {
protected GuiItem getGuiItem(final User user, final Player player, final GuiItem guiItem, final ItemStack itemStack) {
if (guiItem instanceof final ArmorItem armorItem) {
final String permission =
armorItem.getPermission() == null ? "" : armorItem.getPermission();
@@ -188,8 +188,12 @@ public class CosmeticGui {
return guiItem;
}
protected ItemStack applyPlaceholders(final User user, final Player player,
final ArmorItem armorItem, final boolean hasPermission) {
protected ItemStack applyPlaceholders(
final User user,
final Player player,
final ArmorItem armorItem,
final boolean hasPermission
) {
final Map<String, String> placeholders = new HashMap<>();
final PlayerArmor playerArmor = user.getPlayerArmor();

View File

@@ -139,19 +139,33 @@ public class DyeSelectorGui extends CosmeticGui {
final PlayerArmor playerArmor = user.getPlayerArmor();
final ArmorItem previousArmorItem = playerArmor.getItem(this.cosmeticsSlots.get(this.selectedCosmetic));
final ItemStack previous = this.applyPlaceholders(
user,
player,
playerArmor.getItem(this.cosmeticsSlots.get(this.selectedCosmetic)),
previousArmorItem,
true
);
if (previous != null && previous.getType() != Material.AIR) {
if (previous != null && !previousArmorItem.isEmpty()) {
final ItemStack previousItem = dev.triumphteam.gui.builder.item.ItemBuilder.from(
previous
).glow(false).build();
this.gui.updateItem(this.selectedCosmetic, previousItem);
} else {
final GuiItem guiItem = this.guiItemMap.get(this.selectedCosmetic);
final ItemStack itemStack = this.itemStackMap.get(this.selectedCosmetic);
if (itemStack != null && guiItem != null) {
final GuiItem setItem = this.getGuiItem(
user,
player,
guiItem,
itemStack
);
this.gui.updateItem(this.selectedCosmetic, setItem);
}
}
this.selectedCosmetic = slot;
@@ -166,8 +180,8 @@ public class DyeSelectorGui extends CosmeticGui {
return;
}
this.gui.updateItem(this.selectedCosmetic,
this.gui.updateItem(
this.selectedCosmetic,
ItemBuilder.from(
this.applyPlaceholders(
user, player, user.getPlayerArmor().getItem(type), true