Server owners who use your plugins are going to want the ability to manage who can use what features that you offer for example here whenever i place on a torch a diamond block spawns instead and of course server owners might want this to only be allowed to certain people who Have bought a rank or some other type of requirement in order to do this we can use something known as permissions and it’s actually pretty simple so if i go over into my code here i’m simply listening for whenever a block is placed if it is not going to be a torch then I’m going to return then here i’m going to set the block type to a diamond block but let’s say i want to check if the player who is placing the block has a specific permission node what exactly is a permission node well for example let’s Say i have torch dot diamond this is a very basic example but a permission node is basically just going to be a string and you can have it be basically whatever you want typically it’s going to start with the name of your plugin so let’s say one of keysetorial.torch.diamond And this could be a permission node right here now whenever you’re going to publish your plugin to bucket or spigot or anywhere else you want to provide your permission notes so for example here if we go to the essentials wiki we have a link to the permissions list and If you don’t have many permissions then you could just add them onto that page on bucket or spigot but if you do have a lot you could consider making your own website to add them like essentials has right here and if we look at all the permissions here we see the different Module the associated command the actual permission node right here and a description now obviously essentials offers a lot of features so there’s a lot of permission those here and you basically want to have as many different permission nodes as you can that way server owners have the most amount of Customization possible whenever they’re using your plugins let’s take a look at how to actually do this i can now say if not event dot get player dot has permission then here i can pass in a string for example one of keys tutorial dot torch dot diamond so if they do not Have it thanks to this exclamation point i can then return meaning that this code right here will only be ran if the user who is placing the block does have this permission node right here i’m going to go ahead and build my plugin and for those of you following this entire Series i have changed how i built my plugin we are now using maven and a tutorial on how to do that can be found in the description and in the bin comment so now the build has been successful i’m going to go ahead and restart the server now i’m connected Again and whenever i place a torch i still get a diamond block and that’s because i am op on this server any ops are going to automatically have every single permission so to prove that this is the case i can de-op myself and then whenever i place down a torch we just See an actual torch if i go back into the console and i opt myself again we are now going to get down blocks as expected thanks for watching the video if you want to download the source code gain early access to new videos as well as get your own linux vps then consider Becoming a youtube member by clicking on the join button directly below this video Video Information
This video, titled ‘Permissions – Minecraft Plugin Development Ep. 3 (2022)’, was uploaded by Worn Off Keys on 2022-05-03 14:59:50. It has garnered 11589 views and 172 likes. The duration of the video is 00:02:49 or 169 seconds.
Learn how to check for permissions within your Spigot plugin. 🧠 Free Java course ➡ https://wornoffkeys.com/java-for-free
🔥 Updated video on how to deploy your plugin: https://youtu.be/XslTgP6Fgz4
🙋♂️ Need help? Ask in our Discord community: https://wornoffkeys.com/discord
📺 Watch more Discord.JS videos here: https://wornoffkeys.com/playlist/spigot
💡 Have an idea for a video or course? Request it here: https://wornoffkeys.com/content-request
⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
#minecraft #spigot #wornoffkeys
FTC Legal Disclaimer – Some links found in my video descriptions might be affiliate links, meaning I will make commission on sales you make through my link. This is at no extra cost to you and it helps support the channel so I can make more free YouTube videos.