Skip to content

Commit 43da98e

Browse files
committed
feat: add has_unlocked_recipe (close #37)
1 parent 1f2ab8e commit 43da98e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/main/java/at/helpch/placeholderapi/expansion/player/PlayerExpansion.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
1111
import org.bukkit.Bukkit;
1212
import org.bukkit.Location;
13+
import org.bukkit.NamespacedKey;
1314
import org.bukkit.OfflinePlayer;
1415
import org.bukkit.World;
1516
import org.bukkit.block.BlockFace;
@@ -507,6 +508,18 @@ public boolean canRegister() {
507508
}
508509
}
509510

511+
// has_unlocked_recipe_<recipe-key>
512+
if (params.startsWith("has_unlocked_recipe_") && VersionHelper.HAS_KEYED_API) {
513+
final String recipeName = params.substring("has_unlocked_recipe_".length());
514+
final NamespacedKey recipeKey = (recipeName.contains(":")) ? NamespacedKey.fromString(recipeName) : NamespacedKey.minecraft(recipeName);
515+
516+
if (recipeKey == null) {
517+
return "Unknown recipe " + recipeName;
518+
}
519+
520+
return bool(player.hasDiscoveredRecipe(recipeKey));
521+
}
522+
510523
return null;
511524
}
512525

0 commit comments

Comments
 (0)