diff --git a/scripts/has_permission.js b/scripts/has_permission.js index 039bfdc..654b4c0 100644 --- a/scripts/has_permission.js +++ b/scripts/has_permission.js @@ -1,20 +1,35 @@ -// create a variable and name it whatever you want like this -// and use the placeholder you want, i'm using this one +/* +A simple placeholder which checks if the user has a permission + +First we create our permission variables which will give a boolean output whether or not +the user has the specified permission +*/ var haspermission = "%player_has_permission_permission.test%"; -// create a function with the name you want -function permission() { +/* +Here we create a function called hasPermission (can be named whatever you'd like) +which will do all the checks +*/ +function hasPermission() { -// if the haspermission variable that we created before returns yes (true boolean) -// the js placeholder will return what we set in the return down + +/* +If the haspermission variable which we created above returns yes (true boolean) +the placeholder will return the bellow if statements value +*/ if (haspermission === "yes") { return "&aYou have the Test permission!"; } -// if the haspermission variable wasnt true it will return what we set down +/* +If the haspermission variable doesn't return the above state (true boolean), +the user does not have the checked permission, so we return the bellow else statements value +*/ else { return "&cYou don't have the Test permission!"; } } -// by this we are calling the function to run -permission(); +/* +Here we call the hasPermission function so it runs +*/ +hasPermission(); diff --git a/scripts/master_list.json b/scripts/master_list.json index f53bb26..ccd897c 100644 --- a/scripts/master_list.json +++ b/scripts/master_list.json @@ -13,4 +13,10 @@ "description": "A simple placeholder which will return brackets around the faction name if the user is in a faction, if they are not it will return nothing", "url": "https://raw.githubusercontent.com/PlaceholderAPI/Javascript-Expansion/master/scripts/factions.js" } + { + "name": "tags", + "author": "Frosty", + "version": "1.0.0", + "description": "A simple placeholder which formats DeluxeTags tag spacing", + "url": "https://raw.githubusercontent.com/PlaceholderAPI/Javascript-Expansion/master/scripts/tags.js", ] diff --git a/scripts/tags.js b/scripts/tags.js new file mode 100644 index 0000000..ef3860b --- /dev/null +++ b/scripts/tags.js @@ -0,0 +1,37 @@ +/* +A simple placeholder which formats DeluxeTags to better suit a chat format, +meaning it returns a space if the user has a tag equipped + +Creating our tags variable which will return either a tag if the user has it equipped +or a blank string if they do not +*/ +var tags = "%deluxetags_tag%"; + +/* +Creating our hasTags function which will return the correct value +*/ +function hasTag() +{ + /* + If our tags variable which we created above returns an empty string, + we return an empty string back as the user does not have a tag equipped + and if our variable isn't empty, we return a space after it to fix spacing + in the chat format + */ + if (tags == '') + { + return ''; + } + return tags + ' '; + + /* + A compacter way of defining if statements + Checked value ? Boolean true : Boolean false + return tags == '' ? '' : tags + ' '; + */ +} +/* +Calling the hasTag function +*/ +hasTag(); +