diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 3694199..071db5e 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,6 +1,6 @@ # These are supported funding model platforms -github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +github: spikehidden # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: spikehidden diff --git a/.gitignore b/.gitignore index 170c67c..76254de 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.psd *.bat *.ps1 -*_ignore.* \ No newline at end of file +*_ignore.* +*.psd diff --git a/README.md b/README.md index cbd2d1a..8b11540 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,8 @@ Currently we are supporting export formats for easier import of codelists for th If you want me to support more bots/software then just open an issue to request it and I happily will if possible. -## Commands +## Commands & Permissions +### Core Script | Command | arguments | Feature | Permissions | | :----------------------- | :----------------------------------------------------------- | :---------------------------------- | :------------------------------------------------------------------------------- | | redeemadmin create | (\/random) \ (\/group) | Create a new code | spikehidden.admin, spikehidden.coderedeem.admin, spikehidden.coderedeem.codes | @@ -81,6 +82,10 @@ If you want me to support more bots/software then just open an issue to request | pastebin | \ \ | Get and save your pastebin userkey | spikehidden.admin, spikehidden.coderedeem.admin, spikehidden.coderedeem.pastebin | | commandgroup | "\" "\" (...) | Creates a temporary command group | spikehidden.admin, spikehidden.coderedeem.admin, spikehidden.coderedeem.codes | +### Auto Generate Code AddOn +| Command | arguments | Feature | Permissions | +| :----------- | :-------- | :---------------------------------------- | :------------------------------ | +| (No command) | | Permission to get generated code on join. | spikehidden.coderedeem.autocode | ## License diff --git a/plugins/Denizen/scripts/SpikeCodeRedeem-Config.dsc b/plugins/Denizen/scripts/SpikeCodeRedeem-Config.dsc new file mode 100644 index 0000000..f73c86c --- /dev/null +++ b/plugins/Denizen/scripts/SpikeCodeRedeem-Config.dsc @@ -0,0 +1,160 @@ +# ++++++ License Notice ++++++ +# +# The following code is distributed under +# the CC-BY-SA-4.0 license (Attribution-ShareAlike 4.0 International). +# +# | You are free to: +# - Share +# copy and redistribute the material in any medium or format +# +# - Adapt +# remix, transform, and build upon the material +# for any purpose, even commercially. +# +# | Under the following terms: +# - Attribution +# You must give appropriate credit, +# provide a link to the license, and indicate if changes were made. +# You may do so in any reasonable manner, +# but not in any way that suggests the licensor endorses you or your use. +# +# - ShareAlike +# If you remix, transform, or build upon the material, +# you must distribute your contributions under the same license as the original. +# +# - A copy of the full license can be found here: https://creativecommons.org/licenses/by-sa/4.0/ +# +# ++++++ License End ++++++ +# +# +---------------------------------+ +# | | +# | Redeemable Codes - Configs | +# | | +# | This is only the config file | +# | DO NOT DELETE THIS FILE! | +# | | +# +---------------------------------+ +# +# @author Spikehidden +# @date 2022/06/10 +# @denizen-build 1.2.4-SNAPSHOT (build 1766-REL) +# @script-version 1.0 +# +# + REQUIREMENTS + +# - None +# +# + Required or recommended for some features + +# - A Pastebin Account + DevKey if you want to use that feature. + +# + CONTACT + +# +# If you need help with the setup +# or want me to add a feature please +# contact me via Twitter or Discord +# or open an issue at GitHub! +# +# - Twitter: https://spikey.biz/twitter +# - Discord: https://spikey.biz/discord +# - Twitch: https://spikey.biz/twitch +# - Ko-Fi: https://spikey.biz/kofi + +# ++++++ Config ++++++ +SpikeCodeRedeemData: + type: data + # + Core configs + # ------ Pastebin ------ + # Do you want to use private or public pastes on Pastebin.com ? + # You can find more info in the readme at https://github.com/spikehidden/CodeRedeemScript + # Default is false as it is not recommended to use this feature when bulk creating codes! + UsePastebin: false + # Put your pastebin devKey in here as it's not possible to retrieve it from the "secrets.secret" file at the moment. + # As soon as it is possible we'll do it that way. + devKey: Put Your Key Here! + + # + Not AddOn specific configs + # This setting is used by the following AddOns: + # - Wizebot API + server: + name: My Minecraft Server + ip: mc.example.tld + + # + Add-On configs. + # ------ Auto Generate ------ + # For these feature you need the Auto Generate Addon + auto: + # The prefix of the auto genereated code. + # Set to "none" (without quotes) to disable. + prefix: daily- + + # The name of the code after the prefix. + # Use "random" (without quotes) to generate a random code + code: random + + # A list of commands that should be executed when redeeming the code. + commands: + - say this is a command. + - minecraft:give

64 diamonds + + # The intervall in hours of when the code gets generated. + interval: 24 + + # Amount of how many players can use the code. + # Set to "unlimited" (without quotes) to have no limit. + amount: unlimited + + # Should we delete the old code? + # Set to false to keep the old one but you need to + # set auto.code to random then or it will throw errors. + delete: true + + # ------ Wizebot API ------- + # For these feature you need the Wizebot Addon + wizebot: + web: + # Only change this if you use nginx or something similar. If you do it anyway Wizebot won't be able to connect to your server. + port: 80 + API: + # Set here a SECURE API key. + # If set to none it's not usable + key: none + + shop: + # ID = Uses the item_id to check which commands to assign. + # group = Uses the "group" query parameter to get the - Easier + # For more info and to get t know how to get the item IDs take a look at the wiki on Github + # https://github.com/spikehidden/coderedeemscript/wiki + mode: ID + + # Map of group IDs which will be used for group mode. + groups: + # Group ID + group_01: + # List of Wizebot item IDs that shall be part of this group. + # Won't be used if mode is set to group + ids: + - 64509 + commands: + # The amount of random commands to choose. + amount: 1 + # The commands to randomly assign. + # Set amount to 0 to disable + random: + - minecraft:give <<>p<>> diamond 64 + # A list of commands that are always assigned to a code. + # Set to "alwaysCommand: none" to disable + always: + - minecraft:say <<>p<>> redeemed <[code]> + + + #+ ------ Debug & Log ------ + # Shall redemption be logged? + redemptionLog: true + logPath: spikehidden/logs/ + + #+ ------ Advanced Settings ------ + # Don't change this unless Pastebin changed their API endpoints + API: + endpoint: pastebin.com/api/ + data: api_raw.php + login: api_login.php + paste: api_post.php \ No newline at end of file diff --git a/plugins/Denizen/scripts/SpikeCodeRedeem-Wizebot.dsc b/plugins/Denizen/scripts/SpikeCodeRedeem-Wizebot.dsc new file mode 100644 index 0000000..b122346 --- /dev/null +++ b/plugins/Denizen/scripts/SpikeCodeRedeem-Wizebot.dsc @@ -0,0 +1,179 @@ +# ++++++ License Notice ++++++ +# +# The following code is distributed under +# the CC-BY-SA-4.0 license (Attribution-ShareAlike 4.0 International). +# +# | You are free to: +# - Share +# copy and redistribute the material in any medium or format +# +# - Adapt +# remix, transform, and build upon the material +# for any purpose, even commercially. +# +# | Under the following terms: +# - Attribution +# You must give appropriate credit, +# provide a link to the license, and indicate if changes were made. +# You may do so in any reasonable manner, +# but not in any way that suggests the licensor endorses you or your use. +# +# - ShareAlike +# If you remix, transform, or build upon the material, +# you must distribute your contributions under the same license as the original. +# +# - A copy of the full license can be found here: https://creativecommons.org/licenses/by-sa/4.0/ +# +# ++++++ License End ++++++ +# +# +---------------------------------+ +# | | +# | Redeemable Codes - Configs | +# | | +# | This is only the config file | +# | DO NOT DELETE THIS FILE! | +# | | +# +---------------------------------+ +# +# @author Spikehidden +# @date 2022/06/10 +# @denizen-build 1.2.4-SNAPSHOT (build 1766-REL) +# @script-version 1.2 +# +# + REQUIREMENTS + +# - Spikehidden Redeemable Codes | https://github.com/spikehidden/ +# +# + Required or recommended for some features + +# - A Pastebin Account + DevKey if you want to use that feature. + +# + CONTACT + +# +# If you need help with the setup +# or want me to add a feature please +# contact me via Twitter or Discord +# or open an issue at GitHub! +# +# - Twitter: https://spikey.biz/twitter +# - Discord: https://spikey.biz/discord +# - Twitch: https://spikey.biz/twitch +# - Ko-Fi: https://spikey.biz/kofi + +# ++++++ World ++++++ +SpikeCodeRedeemWizebotSystem: + type: world + debug: true + events: + #- Check if core script is loaded + on scripts loaded: + - if : + - announce "<&ss>9[SpikeCodeRedeem]<&ss>r Spikehidden's Auto Updater has been found!" to_console + - flag server SpikeCodeRedeemAutoUpdate:github + - flag server SpikehiddenUpdater.data:->:SpikeCodeRedeemAutoUpdate + - announce "<&ss>9[SpikeCodeRedeem]<&ss>r Providing Update data of Auto Generate Addon for Spikehidden's Auto Updater" to_console + after scripts loaded: + - if : + - define port + - flag server SpikeCodeRedeem.addon.wizebot + - announce "<&ss>9[SpikeCodeRedeem]<&ss>r Add-On <&dq>Wizebot<&dq> is loaded." to_console + - webserver start port:<[port]> + - else: + - announce "<&ss>9[SpikeCodeRedeem]<&ss>r Add-On <&dq>Wizebot<&dq> can't be used without core script." to_console + - announce "<&ss>9[SpikeCodeRedeem]<&ss>r Download core script from https://github.com/spikehidden/CodeRedeemScript" to_console + +SpikeCodeRedeemWizebotAPI: + type: world + debug: true + events: + on webserver web request method:post path:/wizebot/create: + # Get query parameters + - define query + - define code <[query].get[code].if_null[random]> + - define queryKey <[query].get[key].if_null[null]> + - define duration <[query].get[duration].if_null[unlimited]> + - define prefix <[query].get[prefix].if_null[]> + - define group <[query].get[group].if_null[null]> + + #headers + - define heads + - define type <[heads].get[content-type].get[1]> + - define boundary <[type].replace_text[multipart/form-data; boundary=]> + + # Map POST parameters: + - define prepost ]> + - define prepost <[prepost].split[<&chr[000D]><&chr[000A]>]> + - define prepost <[prepost].separated_by[]> + - define post_list <[prepost].split[--<[boundary]>].remove[first].remove[last]> + - define post <[post_list].to_map[<&dq>]> + - define item_id <[post].get[item_id].if_null[null]> + - define item_name <[post].get[item_name].if_null[null]> + - define viewer_id <[post].get[item_id].if_null[null]> + - define viewer_name <[post].get[item_id].if_null[null]> + + # Get stuff from config + - define key + - define mode + - define groupList + + # If key is missing, invalid or not configerured send 401 ERROR + - if <[key]> == none || <[queryKey]> != <[key]>: + - define answer "UNAUTHORIZED - KEY IS MISSING OR INVALID" + - determine code:401 passively + - determine headers:[Content-Type=text/plain] passively + - determine RAW_TEXT_CONTENT:<[answer]> + + # If nothing is set up in the Config send KO status and ERROR + - if <[groupList]> == none: + - define text "Configuration Error! - Please tell the Streamer that something went wrong." + - define status KO + - definemap answer: + status: <[status]> + text_to_return: <[text]> + - determine code:200 passively + - determine headers:[Content-Type=application/json] passively + - determine RAW_TEXT_CONTENT:<[answer].to_json> + + # Get group if in ID mode + - if <[mode]> == ID: + - foreach <[groupList]>: + - if <[value].get[ids].contains_text[<[item_id]>]>: + - define group <[key]> + - foreach stop + + # Get group Data + - define groupData ].if_null[none]> + - define randomAmount <[groupData].deep_get[commands.amount].if_null[0]> + - define random <[groupData].deep_get[commands.random].if_null[null]> + - define always <[groupData].deep_get[commands.always].if_null[none]> + + # Add always commands. + - if <[always]> != none: + - define commands <[always].as[list]> + + # Choose radnom commands. + - if <[randomAmount]> >= 1 && <[random]> != null: + - define commands:->:<[random].random[<[randomAmount]>]> + + # If commands are empty run error. + - if <[commands].if_null[].is_empty>: + - define text "Configuration Error! - Please tell the Streamer that something went wrong." + - define status KO + - definemap answer: + text_to_return: <[text]> + status: <[status]> + - determine code:200 passively + - determine headers:[Content-Type=application/json] passively + - determine RAW_TEXT_CONTENT:<[answer].to_json> + + #Inject Code Creation Task + - define amount 1 + - define permission null + - inject SpikeCodeCreateCode + + # Finaly send the code to Wizebot + - definemap answer: + text_to_return: Your code for Foxcraft is: <[code]> + status: OK + - determine passively code:200 + - determine passively headers:[Content-Type=application/json] + - determine RAW_TEXT_CONTENT:<[answer].to_json> + diff --git a/SpikeCodeRedeem.dsc b/plugins/Denizen/scripts/SpikeCodeRedeem.dsc similarity index 91% rename from SpikeCodeRedeem.dsc rename to plugins/Denizen/scripts/SpikeCodeRedeem.dsc index 3bb2976..080dde9 100644 --- a/SpikeCodeRedeem.dsc +++ b/plugins/Denizen/scripts/SpikeCodeRedeem.dsc @@ -58,56 +58,35 @@ # - Twitch: https://spikey.biz/twitch # - Ko-Fi: https://spikey.biz/kofi -# + Config + -SpikeCodeRedeemData: - type: data - # ------ Pastebin ------ - # Do you want to use private or public pastes on Pastebin.com ? - # You can find more info in the readme at https://github.com/spikehidden/CodeRedeemScript - # Default is false as it is not recommended to use this feature when bulk creating codes! - UsePastebin: false - # Put your pastebin devKey in here as it's not possible to retrieve it from the "secrets.secret" file at the moment. - # As soon as it is possible we'll do it that way. - devKey: Put Your Key Here! - - # ------ Debug & Log ------ - # Shall redemption be logged? - redemptionLog: true - logPath: spikehidden/logs/ - - # ------ Advanced Settings ------ - # Don't change this unless Pastebin changed their API endpoints - API: - endpoint: pastebin.com/api/ - data: api_raw.php - login: api_login.php - paste: api_post.php - # =========== DO NOT EDIT ANYTHING BELOW THIS LINE IF YOU DON'T KNOW WHAT YOU'RE DOING! =========== # ++++++ Data for Updater Scripts ++++++ +# This is in advance for a future project of mine. SpikeCodeRedeemUpdate: type: data - Github: + github: profile: Spikehidden respository: CodeRedeemScript - filename: SpikeCodeRedeem.dsc - version: 1.0 + files: + - SpikeCodeRedeem.dsc + - SpikeCodeRedeem-Config.dsc + version: 1.2 + prerelease: false # ++++++ Tasks ++++++ # + Create Code Task + SpikeCodeCreateCode: type: task debug: false - definitions: code|amount|command|permission|prefix|code_amount|group + definitions: code|amount|command|permission|prefix|code_amount|group|commands script: # Check if a random code shall be generated - if <[code]> == random: - define url https://www.random.org/strings/?num=<[code_amount].if_null[1]>&len=8&digits=on&upperalpha=off&loweralpha=on&unique=on&format=plain&rnd=new - ~webget <[url]> save:newcodelist - - define newCodeList ]> + - define newCodeList ]> # - define code ]> # - define code <[code].replace_text[<&nl>]> # - if <[prefix].exists>: @@ -115,24 +94,23 @@ SpikeCodeCreateCode: - else: - define newCodeList ]> - define codeList - - foreach <[newCodeList]> as:code: + - foreach <[newCodeList]> as:value: + - define code <[value]> # Add prefix - if <[prefix].exists>: - define code <[prefix]><[code]> - # Sets the amount how often the code can be used. + # Sets the amount how often the code can be used. - flag server redeemableCodes.<[code]>.amount:<[amount]> # Sets the commands that shall be executed! - - if <[command]> == group: + - if <[commands].exists>: + - flag server redeemableCodes.<[code]>.commands:<[commands]> + - else if <[command]> == group: - flag server redeemableCodes.<[code]>.commands: - else: - flag server redeemableCodes.<[code]>.commands: - flag server redeemableCodes.<[code]>.commands:->:<[command]> - # Add code group if existing - - if <[group].exists>: - - flag server redeemableCodes.<[code]>.group:<[group]> - - flag server redeemableGroups.<[group]>.codes:->:<[code]> # Check if a permission shall be set. - - if <[permission]> != null: + - if <[permission].if_null[null]> != null: - define msg 'The code "<[code]>" with <[amount]> possible redemption(s) and the "<[permission]>" permission required was created!' - flag server redeemableCodes.<[code]>.permission:<[permission]> # If so set the permission. @@ -196,7 +174,8 @@ SpikeCodeRedeemSystem: - flag server SpikeCodeRedeem - if : - announce "<&ss>9[SpikeCodeRedeem]<&ss>r Spikehidden's Auto Updater has been found!" to_console - - flag server SpikehiddenUpdater.data:->:SpikeCodeRedeem.update + - flag server SpikeCodeRedeemUpdate:github + - flag server SpikehiddenUpdater.data:->:SpikeCodeRedeemUpdate - announce "<&ss>9[SpikeCodeRedeem]<&ss>r Providing Update data for the Spikehidden's Auto Updater" to_console on shutdown: - flag server SpikeCodeRedeem:! @@ -247,7 +226,7 @@ SpikeCodeRedeemAdminCommand: debug: false name: redeemsettings description: Admin Settings for Spike's redeemable codes. - usage: /redeemsettings <&lb>create/edit/delete<&rb> <&lb><<>code<>>/random<&rb> <&lb><<>amount of uses<>>/unlimited<&rb> <&lb><<>command<>>/group:<<>command group<>><&rb> (<<>permission<>>) + usage: /redeemsettings help - for help aliases: - redeemadmin - codeadmin @@ -258,7 +237,7 @@ SpikeCodeRedeemAdminCommand: allowed help: - determine |||||| tab completions: - 1: create|edit|delete + 1: create|edit|delete|help tab complete: - if >= 2: # If create @@ -268,8 +247,10 @@ SpikeCodeRedeemAdminCommand: - else if == 3: - determine 1|10|100|unlimited - else if == 4: + - determine 1s|1m|1h|1d|1w|1y|unlimited + - else if == 5: - determine group| - - else if >= 5: + - else if >= 6: - determine <<>argument<>> # If Edit - else if == edit: @@ -339,10 +320,11 @@ SpikeCodeRedeemAdminCommand: # define stuff for the create command - define code <[args].get[2].if_null[null]> - define amount <[args].get[3].if_null[null]> - - define command <[args].get[4].to[last].space_separated.if_null[null]> + - define duration <[args].get[4].as_duration.if_null[null]> + - define command <[args].get[5].to[last].space_separated.if_null[null]> - define permission null # Check if arguments exist - - if <[amount]> == null || <[command]> == null: + - if <[amount]> == null || <[command]> == null || <[duration]> == null: - define msg "Missing arguments!" # Check if amount is decimal or unlimited - else if !<[amount].is_decimal> && <[amount]> != unlimited: @@ -466,6 +448,13 @@ SpikeCodeRedeemAdminCommand: - define msg "The code group <&dq><[name]><&dq> with <[codeCount]> code/s was succesfully deleted." - else: - define msg 'The specified group does not exits!"' + + # - Help + - default: + - define msg "<&l><&9>Help for '/redeemsettings'<&r><&nl>" + - define msg "<[msg]>/redeemsettings create <&lb><<>code<>>|random<&rb> <&lb><<>uses<>>|unlimited<&rb> <&lb><<>duration<>>|unlimited<&rb> <&lb><<>command<>>|group<&rb><&nl>" + - define msg "<[msg]>/redeemsettings edit <&lb>code|group<&rb> <&lb><<>ID<>><&rb> <&lb>amount|command|duration<&rb> <&lb><<>value<>><&rb><&nl>" + - define msg "<[msg]>/redeemsettings delete <&lb><<>code|group<&rb> <&lb><<>name<>><&rb>" - narrate <[msg]> # + Command for redeeming codes. @@ -560,7 +549,7 @@ SpikeCodeRedeemBulkCreate: debug: false name: bulkcodecreate description: Admin Settings for Spike's redeemable codes. - usage: /bulkcodecreate <&lb><<>code group name<>><&rb> <&lb><<>amount of codes<>><&rb> <&lb><<>command<>>/group<<>command group<>><&rb> (<<>format for list export<>>) (<<>permission<>>) + usage: /bulkcodecreate <&lb><<>code group name<>><&rb> <&lb><<>Amount_of_Codes<>><&rb> <&lb><<>Duration<>><&rb> <&lb><<>command<>>/group<<>command group<>><&rb> (<<>format for list export<>>) (<<>permission<>>) aliases: - bulkcreate permission: spikehidden.admin;spikehidden.coderedeem.admin;spikehidden.coderedeem.codes @@ -571,36 +560,40 @@ SpikeCodeRedeemBulkCreate: 1: <<>Code_Group_Name<>> # amount of codes 2: 1|2|3|4|5|10|100|1000 + # duration + 3: 1s|1m|1h|1d|1w|1y # format - 3: list|wizebot + 4: list|wizebot default: tab complete: - - if == 4: + - if == 5: - determine group| - - else if == 5: + - else if == 6: - determine <&lb>prefix<&rb> - - else if >= 5: + - else if >= 7: - determine "Too many arguments! Try putting the arguments in quotes (<&dq><&dq>)!" script: - define args + # 1 - define group <[args].get[1].if_null[null]> + # 2 - define groupAmount <[args].get[2].if_null[null]> - - define command <[args].get[4].if_null[null]> - - define format <[args].get[3].if_null[null]> - - define prefix <[args].get[5].if_null[]> + # 3 + - define duration <[args].get[3].if_null[null]> + # 4 + - define format <[args].get[4].if_null[null]> + # 5 + - define command <[args].get[5].if_null[null]> + # 6 + - define prefix <[args].get[6].if_null[]> - define UsePastebin -# - define permission +# - define permission - define permission null - define amount 1 # check for missing arguments - - if <[group]> == null || <[groupAmount]> == null || <[command]> == null: - - narrate "Missing arguments!" - - stop - # - Create - # Check if arguments exist - - if <[groupAmount]> == null || <[command]> == null: + - if <[groupAmount]> == null || <[duration]> == null || <[command]> == null: - define msg "Missing arguments!" # Check if groupAmount is decimal - else if !<[groupAmount].is_decimal>: @@ -618,6 +611,9 @@ SpikeCodeRedeemBulkCreate: - narrate 'Could not create an unused random code group name. Try again or if this error persists open an issue on GitHub.' - stop - define group ]> + # Set group expire if duration is not unlimited + - if <[duration]> != unlimited: + - flag server redeemableGroups.<[group]> expire:<[duration]> # Sets the amount how may codes are in the group. - flag server redeemableGroups.<[group]>.amount:<[amount]> # Creates the specified amount of codes by injecting Code creation script @@ -632,6 +628,7 @@ SpikeCodeRedeemBulkCreate: # If so set the permission. - else: - define msg 'The group "<[group]>" with <[amount]> possible redemption was created!' + # Run pastbin task if it is set in config - if <[UsePastebin]>: - choose <[format]>: - case list: @@ -643,6 +640,7 @@ SpikeCodeRedeemBulkCreate: - run SpikeCodeSendPastebin def:|<[group]>|<[csv].separated_by[<&nl>]>|<[format]> - default: - run SpikeCodeSendPastebin def:|<[group]>|.codes].separated_by[<&nl>]>|list + # If not save list localy. - else: - choose <[format]>: - case list: diff --git a/plugins/Denizen/scripts/SpikeCodeRedeemAutoGenerate.dsc b/plugins/Denizen/scripts/SpikeCodeRedeemAutoGenerate.dsc new file mode 100644 index 0000000..4cd29aa --- /dev/null +++ b/plugins/Denizen/scripts/SpikeCodeRedeemAutoGenerate.dsc @@ -0,0 +1,137 @@ +# ++++++ License Notice ++++++ +# +# The following code is distributed under +# the CC-BY-SA-4.0 license (Attribution-ShareAlike 4.0 International). +# +# | You are free to: +# - Share +# copy and redistribute the material in any medium or format +# +# - Adapt +# remix, transform, and build upon the material +# for any purpose, even commercially. +# +# | Under the following terms: +# - Attribution +# You must give appropriate credit, +# provide a link to the license, and indicate if changes were made. +# You may do so in any reasonable manner, +# but not in any way that suggests the licensor endorses you or your use. +# +# - ShareAlike +# If you remix, transform, or build upon the material, +# you must distribute your contributions under the same license as the original. +# +# - A copy of the full license can be found here: https://creativecommons.org/licenses/by-sa/4.0/ +# +# ++++++ License End ++++++ +# +# +---------------------------------+ +# | | +# | Auto Generate Codes | +# | | +# | An Addon for | +# | Spikehidden's Redeemable Codes | +# | | +# +---------------------------------+ +# +# @author Spikehidden +# @date 2022/06/10 +# @denizen-build 1.2.4-SNAPSHOT (build 1766-REL) +# @script-version 1.0 +# +# + REQUIREMENTS + +# - Spikehidden Redeemable Codes | https://github.com/spikehidden/ +# +# + Required or recommended for some features + +# - A Pastebin Account + DevKey if you want to use that feature. + +# + CONTACT + +# +# If you need help with the setup +# or want me to add a feature please +# contact me via Twitter or Discord +# or open an issue at GitHub! +# +# - Twitter: https://spikey.biz/twitter +# - Discord: https://spikey.biz/discord +# - Twitch: https://spikey.biz/twitch +# - Ko-Fi: https://spikey.biz/kofi + +# =========== DO NOT EDIT ANYTHING BELOW THIS LINE IF YOU DON'T KNOW WHAT YOU'RE DOING! =========== + +# ++++++ Data for Updater Scripts ++++++ +# This is in advance for a future project of mine. +SpikeCodeRedeemAutoUpdate: + type: data + + github: + profile: Spikehidden + respository: CodeRedeemScript + files: + - SpikeCodeRedeemAutoGenerate.dsc + version: 1.2 + prerelease: false + +# ++++++ World ++++++ +SpikeCodeRedeemAutoEvents: + type: world + debug: false + events: + #- Check if core script is loaded + on server start: + - if : + - announce "<&ss>9[SpikeCodeRedeem]<&ss>r Spikehidden's Auto Updater has been found!" to_console + - flag server SpikeCodeRedeemAutoUpdate:github + - flag server SpikehiddenUpdater.data:->:SpikeCodeRedeemAutoUpdate + - announce "<&ss>9[SpikeCodeRedeem]<&ss>r Providing Update data of Auto Generate Addon for Spikehidden's Auto Updater" to_console + after server start: + - if : + - flag server SpikeCodeRedeem.addon.autogenerate + - announce "<&ss>9[SpikeCodeRedeem]<&ss>r Add-On <&dq>Auto Generate Codes<&dq> is loaded." to_console + - else: + - announce "<&ss>9[SpikeCodeRedeem]<&ss>r Add-On <&dq>Auto Generate Codes<&dq> can't be used without core script." to_console + - announce "<&ss>9[SpikeCodeRedeem]<&ss>r Download core script from https://github.com/spikehidden/CodeRedeemScript" to_console + + #-The actual magic happens here + on system time hourly: + - define interval + # Check if an interval was set and if not throw an error to the console. + - if <[interval]> == null: + - announce "<&ss>9[SpikeCodeRedeem]<&ss>r There isn't an intervall specified for the auto generate feature." to_console + - announce "<&ss>9[SpikeCodeRedeem]<&ss>r Please check the <&dq>SpikeCodeRedeem-Config.dsc<&dq> in your Denizen Script directory" to_console + # Check if the hour flag already exists. + - if !: + - flag server spikeCodeRedeem.auto.hour:0 + + - define hour + - if <[hour]> >= <[interval]>: + - define code + - define prefix + - define amount + - define command + - define delete + - if <[code]> == null || <[prefix]> == null || <[amount]> == null || <[command]> == null || <[delete]> == null: + - announce "<&ss>9[SpikeCodeRedeem]<&ss>r Couldn't auto generate Code. There are missing arguments in the config." to_console + - announce "<&ss>9[SpikeCodeRedeem]<&ss>r Please check the <&dq>SpikeCodeRedeem-Config.dsc<&dq> in your Denizen Script directory" to_console + - stop + # Delete old code + - if <[delete]> && : + - define lastCode + - if ]>: + - flag server redeemableCodes.<[lastCode]>:! + - flag server spikeCodeRedeem.auto.lastCode:! + # Delete prefix if it's "none" + - if <[prefix]> == none: + - define prefix:! + # Inject code generator script. + - inject SpikeCodeCreateCode + - flag server spikeCodeRedeem.auto.lastCode:<[code]> + + #- Send current code to player on join. + after player join permission:spikehidden.coderedeem.autocode: + - if : + - define interval + - define code + - if ]>: + - narrate "The current <[interval]> hours code is <[code]>." \ No newline at end of file