Skip to content

Commit

Permalink
fix: allow using heads that are not the player's head in hotbar items
Browse files Browse the repository at this point in the history
Signed-off-by: Cristóbal Veas <cristobal.veas@proton.me>
  • Loading branch information
zetastormy committed Jul 28, 2024
1 parent 1dbe059 commit a2263eb
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.OfflinePlayer;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand All @@ -38,6 +39,8 @@
import org.bukkit.persistence.PersistentDataType;
import team.devblook.akropolis.AkropolisPlugin;
import team.devblook.akropolis.util.ItemStackBuilder;
import team.devblook.akropolis.util.PlaceholderUtil;
import team.devblook.akropolis.util.TextUtil;

import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -110,7 +113,11 @@ public void giveItem(Player player) {
ItemStack newItem = item.clone();

if (getConfigurationSection() != null && getConfigurationSection().contains("username")) {
newItem = new ItemStackBuilder(newItem).setSkullOwner(player.getName()).build();
String skullName = TextUtil.raw(PlaceholderUtil
.setPlaceholders(getConfigurationSection().getString("username", player.getName()), player));
OfflinePlayer skullPlayer = Bukkit.getOfflinePlayer(skullName);

newItem = new ItemStackBuilder(newItem).setSkullOwner(skullPlayer).build();
}

player.getInventory().setItem(slot, newItem);
Expand Down

0 comments on commit a2263eb

Please sign in to comment.