Ok I think I might have already posted something similar to this before, but I wasn't specific. I have a plugin that adds in a shaped recipe. I already have the recipe added in and it works. What I want to do is add a permission node for this recipe, so that people who have the permission, or ops, are the only ones who can use that recipe. How would I do that? (If possible could I have an example please)
Numenorean95 I know how permissions work but how do I tie that into a recipe? The way I do the recipe now, it gets added in at onEnable I need to know some way to cancel it or enable it for a certain player or something
Sorry, this should work. This would be in a listener class, if you need help with that ask. Code: @EventHandler public void onPlayerCraft(CraftItemEvent e){ if(e.getRecipe().equals(myRecipe) && !e.getWhoClicked().hasPermission("thing.perm"){ e.setCancelled(true); } } Edit: im not sure whether the method would be called onPlayerCraft or something else, maybe onItemCrafted, or whether it even matters.
Numenorean95 It's alright I should have elaborated more in my original post. I pretty well have events covered and the .setCancelled thing, I was just having an issue with detecting if it was my recipe. However, do I still add in the recipe in onEnable? If so would I make an instance of my main class [MainClass i = new MainClass();] or would I make the recipe static or what? Thanks
Sorry for my misunderrrstanding, Yes, still do it there, but when you create your listener class, pass in the the constructer the current Object that is you plugin, so that it can retrieve your recipe Code: MyListener list = new MyListener(this);