Skip to content

Commit

Permalink
Fixes around items
Browse files Browse the repository at this point in the history
  • Loading branch information
d0by1 committed May 18, 2024
1 parent 1e8541e commit f1290a1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -424,12 +424,12 @@ public void show(Player... players) {
case HEAD:
case SMALLHEAD:
nms.showFakeEntityArmorStand(player, getLocation(), entityIds[0], true, HologramLineType.HEAD != type, false);
ItemStack itemStack = containsPlaceholders ? HologramItem.parseItemStack(item.getContent(), player) : item.parse();
ItemStack itemStack = HologramItem.parseItemStack(item.getContent(), player);
nms.helmetFakeEntity(player, itemStack, entityIds[0]);
break;
case ICON:
nms.showFakeEntityArmorStand(player, getLocation(), entityIds[0], true, true, false);
ItemStack itemStack1 = containsPlaceholders ? HologramItem.parseItemStack(item.getContent(), player) : item.parse();
ItemStack itemStack1 = HologramItem.parseItemStack(item.getContent(), player);
nms.showFakeEntityItem(player, getLocation(), itemStack1, entityIds[1]);
nms.attachFakeEntity(player, entityIds[0], entityIds[1]);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public ItemStack parse(Player player) {
if (material.name().contains("SKULL") || material.name().contains("HEAD")) {
if (extras != null) {
String extrasFinal = player == null ? extras.trim() : PAPI.setPlaceholders(player, extras).trim();
extrasFinal = extrasFinal.replace("{player}", player == null ? "" : player.getName());
if (!extrasFinal.isEmpty()) {
if (extrasFinal.startsWith("HEADDATABASE_") && Bukkit.getPluginManager().isPluginEnabled("HeadDatabase")) {
String headDatabaseId = extrasFinal.substring("HEADDATABASE_".length());
Expand Down Expand Up @@ -71,16 +72,6 @@ public ItemStack parse(Player player) {
private void parseContent() {
String string = this.content;

// Find NBT tag
if (string.contains("{") && string.contains("}")) {
int nbtStart = string.indexOf('{');
int nbtEnd = string.lastIndexOf('}');
if (nbtStart > 0 && nbtEnd > 0 && nbtEnd > nbtStart) {
this.nbt = string.substring(nbtStart, nbtEnd + 1);
string = string.substring(0, nbtStart) + string.substring(nbtEnd + 1);
}
}

// Find extras
if (string.contains("(") && string.contains(")")) {
int extrasStart = string.indexOf('(');
Expand All @@ -91,6 +82,16 @@ private void parseContent() {
}
}

// Find NBT tag
if (string.contains("{") && string.contains("}")) {
int nbtStart = string.indexOf('{');
int nbtEnd = string.lastIndexOf('}');
if (nbtStart > 0 && nbtEnd > 0 && nbtEnd > nbtStart) {
this.nbt = string.substring(nbtStart, nbtEnd + 1);
string = string.substring(0, nbtStart) + string.substring(nbtEnd + 1);
}
}

if (string.contains("!ENCHANTED")) {
string = string.replace("!ENCHANTED", "");
this.enchanted = true;
Expand Down Expand Up @@ -152,7 +153,7 @@ public static HologramItem fromItemStack(ItemStack itemStack) {

public static ItemStack parseItemStack(String string, Player player) {
string = PAPI.setPlaceholders(player, string);
return new HologramItem(string).parse();
return new HologramItem(string).parse(player);
}

}

0 comments on commit f1290a1

Please sign in to comment.