mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 10:36:10 +01:00
Edit itemstack parsing to pass the whole string to modifyItemStack since implementation has changed recently
This commit is contained in:
parent
17eeac29cf
commit
15d31aa357
@ -662,13 +662,15 @@ public class HologramTrait extends Trait {
|
||||
NPC npc = registry().createNPCUsingItem(EntityType.ITEM_DISPLAY, "", itemStack);
|
||||
npc.data().setPersistent(NPC.Metadata.NAMEPLATE_VISIBLE, false);
|
||||
if (itemMatcher.group(2) != null) {
|
||||
if (itemMatcher.group(2).charAt(1) == '{') {
|
||||
Bukkit.getUnsafe().modifyItemStack(itemStack, itemMatcher.group(2).substring(1));
|
||||
npc.setItemProvider(() -> itemStack);
|
||||
} else {
|
||||
npc.getOrAddTrait(ScoreboardTrait.class)
|
||||
.setColor(Util.matchEnum(ChatColor.values(), itemMatcher.group(2).substring(1)));
|
||||
for (ChatColor color : ChatColor.values()) {
|
||||
if (itemMatcher.group(2).equalsIgnoreCase(color.name())) {
|
||||
npc.getOrAddTrait(ScoreboardTrait.class)
|
||||
.setColor(Util.matchEnum(ChatColor.values(), itemMatcher.group(2)));
|
||||
return npc;
|
||||
}
|
||||
}
|
||||
Bukkit.getUnsafe().modifyItemStack(itemStack, itemMatcher.group(2));
|
||||
npc.setItemProvider(() -> itemStack.clone());
|
||||
}
|
||||
return npc;
|
||||
}
|
||||
@ -705,12 +707,18 @@ public class HologramTrait extends Trait {
|
||||
itemNPC = registry().createNPCUsingItem(Util.getFallbackEntityType("ITEM", "DROPPED_ITEM"), "", itemStack);
|
||||
itemNPC.data().setPersistent(NPC.Metadata.NAMEPLATE_VISIBLE, false);
|
||||
if (itemMatcher.group(2) != null) {
|
||||
if (itemMatcher.group(2).charAt(1) == '{') {
|
||||
Bukkit.getUnsafe().modifyItemStack(itemStack, itemMatcher.group(2).substring(1));
|
||||
itemNPC.setItemProvider(() -> itemStack);
|
||||
} else {
|
||||
itemNPC.getOrAddTrait(ScoreboardTrait.class)
|
||||
.setColor(Util.matchEnum(ChatColor.values(), itemMatcher.group(2).substring(1)));
|
||||
ChatColor matched = null;
|
||||
for (ChatColor color : ChatColor.values()) {
|
||||
if (itemMatcher.group(2).equalsIgnoreCase(color.name())) {
|
||||
itemNPC.getOrAddTrait(ScoreboardTrait.class)
|
||||
.setColor(Util.matchEnum(ChatColor.values(), itemMatcher.group(2)));
|
||||
matched = color;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (matched == null) {
|
||||
Bukkit.getUnsafe().modifyItemStack(itemStack, itemMatcher.group(2));
|
||||
itemNPC.setItemProvider(() -> itemStack.clone());
|
||||
}
|
||||
}
|
||||
itemNPC.spawn(base.getLocation());
|
||||
|
@ -344,7 +344,6 @@ public class Util {
|
||||
if (toMatch.equalsIgnoreCase(check.name())
|
||||
|| toMatch.equalsIgnoreCase("item") && check.name().equals("DROPPED_ITEM"))
|
||||
return check; // check for an exact match first
|
||||
|
||||
}
|
||||
for (T check : values) {
|
||||
String name = check.name().toLowerCase(Locale.ROOT);
|
||||
@ -395,7 +394,7 @@ public class Util {
|
||||
if (stack == null || stack.getType() == Material.AIR) {
|
||||
stack = new ItemStack(Material.STONE, 1);
|
||||
}
|
||||
if (item.charAt(0) == '{') {
|
||||
if (item.contains("{")) {
|
||||
try {
|
||||
Bukkit.getUnsafe().modifyItemStack(stack, item);
|
||||
} catch (Throwable t) {
|
||||
|
Loading…
Reference in New Issue
Block a user