Skip to content

Commit

Permalink
new tag: placeholder.player
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed May 30, 2020
1 parent d757475 commit 2d1735a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
Expand Up @@ -46,8 +46,19 @@ public void tagEvent(ReplaceableTagEvent event) {
Debug.echoError("Cannot use <placeholder[]> tags with 'denizen' prefix!");
return;
}
Player player = ((BukkitTagContext) event.getContext()).player != null ?
((BukkitTagContext) event.getContext()).player.getPlayerEntity() : null;
attribute = attribute.fulfill(1);
Player player = ((BukkitTagContext) event.getContext()).player != null ? ((BukkitTagContext) event.getContext()).player.getPlayerEntity() : null;

// <--[tag]
// @attribute <placeholder[<name>].player[<player>]>
// @returns ElementTag
// @plugin Depenizen, PlaceholderAPI
// @description
// Returns the value of the placeholder for the specified player.
// -->
if (attribute.matches("player") && attribute.hasContext(1) && PlayerTag.matches(attribute.getContext(1))) {
player = PlayerTag.valueOf(attribute.getContext(1)).getPlayerEntity();
}
event.setReplacedObject(new ElementTag(PlaceholderAPI.setPlaceholders(player, "%" + placeholder + "%"))
.getObjectAttribute(attribute.fulfill(1)));
}
Expand Down
Expand Up @@ -159,7 +159,7 @@ else if (typeLower.startsWith("variable:")) {
}
else if (typeLower.startsWith("items:")) {
List<ItemStack> itemsToSet = new ArrayList<>();
for (ItemTag item : new ListTag(type.substring("items:".length())).filter(ItemTag.class, path.container, true)) {
for (ItemTag item : ListTag.valueOf(type.substring("items:".length()), CoreUtilities.basicContext).filter(ItemTag.class, path.container, true)) {
itemsToSet.add(item.getItemStack());
}
reagents.setItems(itemsToSet);
Expand Down

0 comments on commit 2d1735a

Please sign in to comment.