Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
*.psd
*.bat
*.ps1
*_ignore.*
*_ignore.*
*.psd
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | (\<code\>/random) \<amount\> (\<command\>/group) | Create a new code | spikehidden.admin, spikehidden.coderedeem.admin, spikehidden.coderedeem.codes |
Expand All @@ -81,6 +82,10 @@ If you want me to support more bots/software then just open an issue to request
| pastebin | \<username\> \<password\> | Get and save your pastebin userkey | spikehidden.admin, spikehidden.coderedeem.admin, spikehidden.coderedeem.pastebin |
| commandgroup | "\<command1\>" "\<command2\>" (...) | 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

Expand Down
160 changes: 160 additions & 0 deletions plugins/Denizen/scripts/SpikeCodeRedeem-Config.dsc
Original file line number Diff line number Diff line change
@@ -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 <p> 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 <&lt>p<&gt> diamond 64
# A list of commands that are always assigned to a code.
# Set to "alwaysCommand: none" to disable
always:
- minecraft:say <&lt>p<&gt> 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
179 changes: 179 additions & 0 deletions plugins/Denizen/scripts/SpikeCodeRedeem-Wizebot.dsc
Original file line number Diff line number Diff line change
@@ -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 <server.has_flag[SpikehiddenUpdater]>:
- 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 <server.has_flag[SpikeCodeRedeem]>:
- define port <script[SpikeCodeRedeemData].data_key[wizebot.web.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 <context.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[<empty>]>
- define group <[query].get[group].if_null[null]>

#headers
- define heads <context.headers>
- define type <[heads].get[content-type].get[1]>
- define boundary <[type].replace_text[multipart/form-data; boundary=]>

# Map POST parameters:
- define prepost <context.body.replace_text[Content-Disposition: form-data; name=<&dq>]>
- 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 <script[SpikeCodeRedeemData].data_key[wizebot.api.key].if_null[none]>
- define mode <script[SpikeCodeRedeemData].data_key[wizebot.shop.mode].if_null[ID]>
- define groupList <script[SpikeCodeRedeemData].data_key[wizebot.shop.groups].if_null[none]>

# 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 <script[SpikeCodeRedeemData].data_key[wizebot.shop.groups.<[group]>].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[<list>].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>

Loading