9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-28 19:39:14 +00:00

Fixed placeholder cosmetic items

This commit is contained in:
MasterOfTheFish
2022-02-19 21:13:50 -05:00
parent be7092b422
commit d10afc3df3
39 changed files with 66 additions and 20 deletions

Binary file not shown.

View File

@@ -23,6 +23,8 @@ set-other-off-hand: "%prefix% <gradient:#6D9DC5:#45CDE9>You have set the off han
set-other-chest-plate: "%prefix% <gradient:#6D9DC5:#45CDE9>You have set the chest plate of %player% to %type%"
set-other-pants: "%prefix% <gradient:#6D9DC5:#45CDE9>You have set the pants of %player% to %type%"
set-other-boots: "%prefix% <gradient:#6D9DC5:#45CDE9>You have set the boots of %player% to %type%"
hid-cosmetics: "%prefix% <gradient:#6D9DC5:#45CDE9>You have hidden your cosmetics"
shown-cosmetics: "%prefix% <gradient:#6D9DC5:#45CDE9>You have shown your cosmetics"
opened-wardrobe:
type: title
message: "<black>"

View File

@@ -337,7 +337,27 @@ public class CosmeticsCommand extends CommandBase {
);
}
}
};
}
}
@SubCommand("hide")
public void hide(final Player player) {
final Optional<User> optionalUser = this.userManager.get(player.getUniqueId());
if (optionalUser.isEmpty()) return;
final User user = optionalUser.get();
if (user.isHidden()) {
user.setHidden(false);
this.messageHandler.sendMessage(
player,
Messages.SHOWN_COSMETICS
);
return;
}
user.setHidden(true);
this.messageHandler.sendMessage(
player,
Messages.HID_COSMETICS
);
}
private void setNpcCosmetic(final CitizensHook hook, final CommandSender sender, final int npcId, final ArmorItem item) {

View File

@@ -115,7 +115,7 @@ public class ItemSerializer implements TypeSerializer<GuiItem> {
}
}
final String name = StringUtils.parseStringToString(nameNode.getString());
final String name = StringUtils.parseStringToString(Utils.replaceIfNull("", nameNode.getString()));
final boolean unbreakable = unbreakableNode.getBoolean();
final boolean glowing = glowingNode.getBoolean();

View File

@@ -56,20 +56,6 @@ public class DyeSelectorGui extends CosmeticGui {
this.selectedCosmetic = selected == null ? this.selectedCosmetic : selected;
}
for (final var entry : this.cosmeticsSlots.entrySet()) {
gui.setItem(
entry.getKey(),
new GuiItem(
this.applyPlaceholders(
user,
player,
user.getPlayerArmor().getItem(entry.getValue()),
true
)
)
);
}
for (final var entry : this.guiItemMap.entrySet()) {
final GuiItem guiItem = entry.getValue();
@@ -87,6 +73,21 @@ public class DyeSelectorGui extends CosmeticGui {
gui.setItem(entry.getKey(), guiItem);
}
for (final var entry : this.cosmeticsSlots.entrySet()) {
final ArmorItem guiItem = user.getPlayerArmor().getItem(entry.getValue()).copy();
final ItemStack itemStack = guiItem.getItemStack();
if (itemStack == null || guiItem.isEmpty()) continue;
guiItem.setItemStack(
ItemBuilder.from(itemStack.clone()).papiPlaceholders(player).build()
);
gui.setItem(entry.getKey(), guiItem);
}
final PlayerArmor playerArmor = user.getPlayerArmor();
this.select(this.selectedCosmetic, user, player);
@@ -129,8 +130,11 @@ public class DyeSelectorGui extends CosmeticGui {
armorItem.setDye(colorItem.getColor().asRGB());
if (user.isWardrobeActive())
this.plugin.getUserManager().setItem(user, armorItem);
if (user.isWardrobeActive()) {
this.plugin.getUserManager().setItem(user.getWardrobe(), armorItem);
} else {
this.plugin.getUserManager().setItem(user, armorItem);
}
this.updateSelected(user, player);
});
@@ -182,11 +186,14 @@ public class DyeSelectorGui extends CosmeticGui {
return;
}
final ArmorItem armorItem = user.getPlayerArmor().getItem(type);
if (armorItem.isEmpty()) return;
this.gui.updateItem(
this.selectedCosmetic,
ItemBuilder.from(
this.applyPlaceholders(
user, player, user.getPlayerArmor().getItem(type), true
user, player, armorItem, true
)
).build());
}

View File

@@ -54,6 +54,10 @@ public class Messages {
public static final Message SET_NPC_COSMETIC =
new Message("set-npc-cosmetic", ChatColor.GREEN + "Set " + Placeholder.TYPE + " of " +
Placeholder.ID + " to " + Placeholder.ITEM);
public static final Message HID_COSMETICS =
new Message("hid-cosmetics", ChatColor.GREEN + "You have hidden your cosmetics");
public static final Message SHOWN_COSMETICS =
new Message("showed-cosmetics", ChatColor.GREEN + "You have shown your cosmetics");
public static final Message HELP_COMMAND =
new Message("help-command",
"""

View File

@@ -16,6 +16,7 @@ public class User extends BaseUser<UUID> {
protected Wardrobe wardrobe;
private CosmeticGui openGui;
private boolean hidden;
public User(final UUID uuid, final int entityId, final PlayerArmor playerArmor, final Wardrobe wardrobe, final int armorStandId) {
super(uuid, entityId, playerArmor, armorStandId);
@@ -37,6 +38,7 @@ public class User extends BaseUser<UUID> {
public boolean shouldShow(final Player other) {
final Player player = this.getPlayer();
if (player == null) return false;
if (player.getUniqueId().equals(other.getUniqueId()) && this.hidden) return false;
return player.getGameMode() != GameMode.SPECTATOR &&
(!player.hasPotionEffect(PotionEffectType.INVISIBILITY) &&
other.canSee(player) &&
@@ -77,4 +79,12 @@ public class User extends BaseUser<UUID> {
public boolean isWardrobeActive() {
return this.wardrobe.isActive();
}
public boolean isHidden() {
return hidden;
}
public void setHidden(final boolean hidden) {
this.hidden = hidden;
}
}

View File

@@ -23,6 +23,8 @@ set-other-off-hand: "%prefix% <gradient:#6D9DC5:#45CDE9>You have set the off han
set-other-chest-plate: "%prefix% <gradient:#6D9DC5:#45CDE9>You have set the chest plate of %player% to %type%"
set-other-pants: "%prefix% <gradient:#6D9DC5:#45CDE9>You have set the pants of %player% to %type%"
set-other-boots: "%prefix% <gradient:#6D9DC5:#45CDE9>You have set the boots of %player% to %type%"
hid-cosmetics: "%prefix% <gradient:#6D9DC5:#45CDE9>You have hidden your cosmetics"
shown-cosmetics: "%prefix% <gradient:#6D9DC5:#45CDE9>You have shown your cosmetics"
opened-wardrobe:
type: title
message: "<black>"