Skip to content

Commit

Permalink
feat: add has_unlocked_recipe (close #37)
Browse files Browse the repository at this point in the history
  • Loading branch information
iGabyTM committed Jun 24, 2024
1 parent 1f2ab8e commit 43da98e
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.OfflinePlayer;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
Expand Down Expand Up @@ -507,6 +508,18 @@ public boolean canRegister() {
}
}

// has_unlocked_recipe_<recipe-key>
if (params.startsWith("has_unlocked_recipe_") && VersionHelper.HAS_KEYED_API) {
final String recipeName = params.substring("has_unlocked_recipe_".length());
final NamespacedKey recipeKey = (recipeName.contains(":")) ? NamespacedKey.fromString(recipeName) : NamespacedKey.minecraft(recipeName);

if (recipeKey == null) {
return "Unknown recipe " + recipeName;
}

return bool(player.hasDiscoveredRecipe(recipeKey));
}

return null;
}

Expand Down

0 comments on commit 43da98e

Please sign in to comment.