mirror of
https://github.com/HibiscusMC/HMCCosmetics.git
synced 2025-12-26 18:39:07 +00:00
Fixed dyes not working and lore changing with permission
This commit is contained in:
@@ -78,22 +78,22 @@ public class CosmeticGui {
|
||||
|
||||
final String permission = armorItem.getPermission() == null ? "" : armorItem.getPermission();
|
||||
|
||||
final boolean hasPermission = permission.isBlank() || player.hasPermission(permission);
|
||||
|
||||
placeholders.put(
|
||||
Placeholder.ALLOWED,
|
||||
String.valueOf(
|
||||
player.hasPermission(permission)).
|
||||
toUpperCase(Locale.ROOT)
|
||||
);
|
||||
String.valueOf(hasPermission).
|
||||
toLowerCase(Locale.ROOT));
|
||||
|
||||
this.gui.setItem(slot,
|
||||
new GuiItem(
|
||||
ItemBuilder.from(
|
||||
armorItem.getItemStack()
|
||||
armorItem.getItemStack(hasPermission)
|
||||
).namePlaceholders(placeholders).
|
||||
lorePlaceholders(placeholders).
|
||||
build(),
|
||||
event -> {
|
||||
if (!permission.isBlank() && !player.hasPermission(armorItem.getPermission())) {
|
||||
if (!hasPermission) {
|
||||
this.messageHandler.sendMessage(
|
||||
player,
|
||||
Messages.NO_PERMISSION
|
||||
|
||||
@@ -10,10 +10,12 @@ import io.github.fisher2911.hmccosmetics.util.builder.ColorBuilder;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Color;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.LeatherArmorMeta;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
public class DyeSelectorGui extends CosmeticGui{
|
||||
|
||||
@@ -107,4 +109,10 @@ public class DyeSelectorGui extends CosmeticGui{
|
||||
|
||||
return gui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void open(final HumanEntity player) {
|
||||
final Optional<User> optionalUser = this.plugin.getUserManager().get(player.getUniqueId());
|
||||
optionalUser.ifPresent(user -> this.getGui(user, user.getLastSetItem()).open(player));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ public class User {
|
||||
private final UUID uuid;
|
||||
private final PlayerArmor playerArmor;
|
||||
private ArmorStand attached;
|
||||
private ArmorItem lastSetItem;
|
||||
|
||||
public User(final UUID uuid, final PlayerArmor playerArmor) {
|
||||
this.uuid = uuid;
|
||||
@@ -40,6 +41,7 @@ public class User {
|
||||
|
||||
public void setBackpack(final ArmorItem backpack) {
|
||||
this.playerArmor.setBackpack(backpack);
|
||||
this.lastSetItem = backpack;
|
||||
}
|
||||
|
||||
// return true if backpack was set
|
||||
@@ -81,6 +83,7 @@ public class User {
|
||||
public void setHat(final ArmorItem hat) {
|
||||
this.playerArmor.setHat(hat);
|
||||
this.getPlayer().getEquipment().setHelmet(this.playerArmor.getHat().getItemStack());
|
||||
this.lastSetItem = hat;
|
||||
}
|
||||
|
||||
// return true if hat was set
|
||||
@@ -169,4 +172,7 @@ public class User {
|
||||
player.getLocation().getPitch());
|
||||
}
|
||||
|
||||
public ArmorItem getLastSetItem() {
|
||||
return lastSetItem;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user