Description: :) If you have time to use my scripts, you have time to leave a comment or thumbs up!
This is an early Alpha version of PerkPoints. It has the bare minimum functionality. It accepts votes
(even /fakevote) from players from any voting servers. You can specify a default perk point reward
for votes OR register voting services to have custom point values.
PerkPoints REQUIRES my SQLManager AND ConfigFileGenerator scripts!
The SQL backend functions are almost /completely/ handled by SQLManager. Automatically goes
into offline caching mode if the sql database goes offline! You won't have to worry about your
players losing PerkPoints if your sql server goes offline for some reason.
________________________________________________________________________________
|----------------!Read The Comments In The Script Below For Detailed Usage Instructions!---------------|
|_______________________________________________________________________________|
I want comments! Rip it apart! What have i done absolutely wrong? What have i done absolutely right?
Has this script helped you in any way? Did you try to use it and it just didn't work?
Thumbs Up are nice too!
________________________________________________________________________________
|----------------|______________Comment and Thumbs Up for Updates______________|---------------|
|_______________________________________________________________________________|
# ---------------------------------------------------------------------------- ## |# |# P e r k P o i n t S y s t e m |# |# A system for rewarding players for Votifier votes |# |# *REQUIRES MYSQL* |# |# |# Author: |Anthony| |# Version: 0.1 |# dScript Version: 0.9.5-b1518 |# Depenizen Version: b214 |# |# Dependencies: |# - SQLManager: http://scripts.citizensnpcs.co/view/m3gov1 |# - ConfigFileGenerator: http://scripts.citizensnpcs.co/view/0coo5b |# |# Optional: |# - VotifierVoteSimulator: http://scripts.citizensnpcs.co/view/d0dt1b |# |# ---------------------------------------------------------------------------- ## # # ABOUT:# # This is an early Alpha version of PerkPoints. It has the bare minimum# functionality. It accepts votes (even /fakevote) from players from any# voting servers. You can specify a default perk point reward for votes OR# register voting services to have custom point values.### PerkPoints REQUIRES my SQLManager AND ConfigFileGenerator scripts!# # The SQL backend functions are almost /completely/ handled by SQLManager.# Automatically goes into offline caching mode if the sql database goes# offline! You won't have to worry about your players losing PerkPoints if# your sql server goes offline for some reason.# # # USAGE:# #--- Setup## 1. Upload PerkPoints.yml SQLManager.yml and ConfigFileGenerator.yml to your# Denizen /scripts directory.## 2. Reload your denizen scripts# /denizen reload scripts## 3. Start PerkPoints - Run command from console OR in game. In game command# requires perkpoints.admin permission! The system will generate the# default files and then disable itself.# /perkadmin --restart## 4. Configure /Denizen/PerkPoints/config.yml# Edit anything you need to! The config file should be self explanatory.# Make sure you set useSql: 'true' when you have all the correct settings!## 5. Create an empty sql db with the database: name you set in the config.yml## 6. Restart PerkPoints - Now that you have your config and database setup # the system will run and create the tables in the sql database.# /perkadmin --restart## 7. PerkPoints is now Online!###--- Permissions## Basic user permission: perkpoints.user# Admin permission: perkpoints.admin# # # TODO - Future Feature Fluff:# # #______________________________________________________________________________#
PerkPointSystem:
type: world
debug: false
events:
on server start:
- run locally start delay:2s
on player joins:
- run locally join instantly
on perk command:
- inject locally commandHandler instantly
on perkadmin command:
- inject locally adminCommandHandler instantly
on votifier vote:
- inject locally voteEvent instantly
################## Consider adding an error event when there's more useful info for comparisons## on script generates error:# - announce "<context.message>" to_console# - announce "<context.queue>" to_console# - announce "<context.script>" to_console
start:
- ^define yamlName 'PerkPoints'
- ^define scriptName '<script.name>'
- ^inject locally reloadYaml instantly
- ^inject locally loadData instantly
- ^if <def[useSql].is[!=].to[true]> {
- announce "<&b>PerkPoints<&co><&c> Must be configured to use MySQL!" to_console
- inject locally unload
- queue stop
}# This checks the status as set by SQLManager to not duplicate restart# processes. This is the only time this script needs to set the status. The# SQLManager will handle every other situation.
- ^define status '<yaml[SQLManager_Offline].read[Offline_Cache.databases.%db%.status]||null>'
- ^if <def[status].is[==].to[connecting]> {
- announce "<&b>SQLManager<&co><&c> Already attempting to reconnect to %db% database!" to_console
- queue stop
}
else {
- yaml 'write:Offline_Cache.databases.%db%.status' 'value:connecting' 'id:SQLManager_Offline'
- yaml 'savefile:SQLManager/cache.yml' 'id:SQLManager_Offline'
}
- ^inject s@SQLManager
- ^announce "<&b>PerkPoints<&co><&a> System loaded!" to_console
- queue stop
reloadYaml:
# Reloads the yaml files and generates default files if they don't exist.
- announce "<&b>PerkPoints<&co><&3> Loading system config files..." to_console
- if !<server.has_file[PerkPoints/config.yml]>
|| !<server.has_file[PerkPoints/packages.yml]> {
- if <player> != null {
- flag <player> ConfigFileGeneratorNotify:true
- run s@ConfigFileGeneratorHelper def:PerkPoints|Configurations|false|false|false instantly
- flag <player> ConfigFileGeneratorNotify:!
}
else run s@ConfigFileGeneratorHelper def:PerkPoints|Configurations instantly
}
- if <yaml.list.contains[PerkPoints_config]> yaml unload 'id:PerkPoints_config'
- yaml 'load:PerkPoints/config.yml' 'id:PerkPoints_config'
- if <yaml.list.contains[PerkPoints_packages]> yaml unload 'id:PerkPoints_packages'
- yaml 'load:PerkPoints/packages.yml' 'id:PerkPoints_packages'
- inject s@PerkPoints_SQLTables
- announce "<&b>PerkPoints<&co><&a> System config files Loaded!" to_console
loadYaml:
# Quickly load the core yaml files if they are not already loaded.
- if !<yaml.list.contains[PerkPoints_config]> yaml 'load:PerkPoints/config.yml' 'id:PerkPoints_config'
- if !<yaml.list.contains[PerkPoints_packages]> yaml 'load:PerkPoints/packages.yml' 'id:PerkPoints_packages'
isOffline:
# Idk if i'll actually use this, but i'm going to leave it for now...
- ^if !<yaml.list.contains[PerkPoints_config]> {
- announce "<&b>PerkPoints<&co><&c> ERROR <&b>config.yml<&c> not loaded!" to_console
- define offline 'true'
}
- ^if !<yaml.list.contains[PerkPoints_packages]> {
- announce "<&b>PerkPoints<&co><&3> ERROR <&b>packages.yml<&c> not loaded!" to_console
- define offline 'true'
}
- ^if !<yaml.list.contains[SQLManager_Offline]> {
- announce "<&b>PerkPoints<&co><&3> ERROR <&b>SQLManager Offline Cache<&c> is not loaded!" to_console
- define offline 'true'
}
else {
- define status '<yaml[SQLManager_Offline].read[Offline_Cache.databases.%db%.status]||null>'
- if <def[status].is[!=].to[online]||null> {
- announce "<&b>PerkPoints<&co><&3> ERROR <&b>SQLManager<&c> reports PerkPoints is NOT ONLINE!" to_console
- define offline 'true'
}}
loadData:
- ^define yamlName 'PerkPoints'
- ^define scriptName '<script.name>'
- ^define useSql '<yaml[PerkPoints_config].read[config.MySQL.useSql]||false>'
- ^define db '<yaml[PerkPoints_config].read[config.MySQL.database]||false>'
- ^define autoCreateAccounts '<yaml[PerkPoints_config].read[config.General.AutoCreateAccounts]||false>'
- ^define points '<yaml[PerkPoints_config].read[config.General.Points]||5>'
- ^define transferrable '<yaml[PerkPoints_config].read[config.General.Transferrable]||false>'
- ^define expireOnStartup '<yaml[PerkPoints_config].read[config.General.ExpireOnStartup]||false>'
- ^define purgeOnStart '<yaml[PerkPoints_config].read[config.General.PurgeOnStart]||false>'
- ^define serverName '<yaml[PerkPoints_config].read[config.General.ServerName]||Minecraft Server>'
- ^define expireCheck '<yaml[PerkPoints_config].read[config.General.ExpireCheck]||10m>'
unload:
- ^if <yaml.list.contains[PerkPoints_config]> {
- announce "<&b>PerkPoints<&co><&3> Unloading config.yml file..." to_console
- yaml unload 'id:PerkPoints_config'
}
- ^if <yaml.list.contains[PerkPoints_packages]> {
- announce "<&b>PerkPoints<&co><&3> Unloading packages.yml file..." to_console
- yaml unload 'id:PerkPoints_packages'
}
- define sqlScriptName 'PerkPoints_SQLTables'
- if <yaml.list.contains[%sqlScriptName%]> {
- announce "<&b>PerkPoints<&co><&3> Unloading %sqlScriptName% file..." to_console
- yaml unload 'id:%sqlScriptName%'}
- ^announce "<&b>PerkPoints<&co><&c> System disabled..." to_console
################################################################################## Actions stuff#
showPlayerStats:
- define db '<yaml[PerkPoints_config].read[config.MySQL.database]>'
- define uuid '<def[uuid]||<player.uuid>>'
- define tableName '<yaml[PerkPoints_config].read[config.MySQL.tables.PerkPoints]>'
- define msgsHeaderTitle 'Player Stats'
- inject locally msgsHeader instantly
- if <proc[SQLManager_ConnectionCheck].context[%db%]> {
- sql id:%db% "query:SELECT playeruuid,created,totalvotes,pointsearned,pointsspent,pointsbalance FROM %tableName% WHERE playeruuid='%uuid%';" save:stats
- define stats '<entry[stats].result||null>'
- inject locally msgsStats instantly
}
else {
- narrate "<&5>|<&sp><&c>SQL Database is offline!"}
- inject locally msgsFooter instantly
join:
- define yamlName 'PerkPoints'
- define scriptName '<script.name>'
- define db '<yaml[PerkPoints_config].read[config.MySQL.database]>'
- if !<server.list_sql_connections.contains[%db%]> queue stop
- define uuid '<player.uuid||null>'
- define tableName '<yaml[PerkPoints_config].read[config.MySQL.tables.PerkPoints]>'
- inject locally checkPlayerRecord
editPoints:
- define yamlName 'PerkPoints'
- define scriptName '<script.name>'
- define db '<yaml[PerkPoints_config].read[config.MySQL.database]||null>'
- define tableName '<yaml[PerkPoints_config].read[config.MySQL.tables.PerkPoints]||null>'
- inject locally checkPlayerRecord
- define pointValue '<def[pointValue]||<yaml[PerkPoints_config].read[config.General.VoteReward]||null>>'
- if <def[pointValue].is[==].to[null]>
|| <def[pointValue]> !matches integer
|| <def[pointValue].is[OR_LESS].than[0]> {
- announce "<&b>PerkPoints<&co> <&c>Tried setting invalid pointValue. Setting sane default 5" to_console
- define pointValue '5'
}
- if <def[action].is[==].to[spend]> {
- define statement "UPDATE %tableName% SET pointsspent = pointsspent + %pointValue%, pointsbalance = pointsbalance - %pointValue% WHERE playeruuid='%uuid%';"
- inject s@SQLManager_Offline p:managedUpdateStatement
}
else if <def[action].is[==].to[give]> {
- define statement "UPDATE %tableName% SET pointsearned = pointsearned + %pointValue%, pointsbalance = pointsbalance + %pointValue% WHERE playeruuid='%uuid%';"
- inject s@SQLManager_Offline p:managedUpdateStatement
}
else if <def[action].is[==].to[vote]> {
- define statement "UPDATE %tableName% SET pointsearned = pointsearned + %pointValue%, totalvotes = totalvotes + 1, pointsbalance = pointsbalance + %pointValue% WHERE playeruuid='%uuid%';"
- inject s@SQLManager_Offline p:managedUpdateStatement
}
else if <def[action].is[==].to[take]> {
- define statement "UPDATE %tableName% SET pointsearned = pointsearned - %pointValue%, pointsbalance = pointsbalance - %pointValue% WHERE playeruuid='%uuid%';"
- inject s@SQLManager_Offline p:managedUpdateStatement
}
else if <def[action].is[==].to[reset]> {
- define statement "UPDATE %tableName% SET pointsearned = 0, pointsspent = 0, pointsbalance = 0, totalvotes = 0 WHERE playeruuid='%uuid%';"
- inject s@SQLManager_Offline p:managedUpdateStatement
}
checkPlayerRecord:
- if <proc[SQLManager_ConnectionCheck].context[%db%]> {
- sql id:%db% "query:SELECT COUNT(playeruuid) FROM %tablename% WHERE playeruuid='%uuid%';" save:idcount
- define idcount '<entry[idcount].result.get[1].split[/].get[1]||null>'
- if <def[idcount].is[==].to[0]> {
- announce "<&b>PerkPoints<&co> <&a>Creating player record for %uuid%" to_console
- define statement "INSERT INTO %tableName% (playeruuid) VALUES ('%uuid%');"
- inject s@SQLManager_Offline p:managedUpdateStatement
}
else if <def[idcount].is[==].to[1]> {
- announce "<&b>PerkPoints<&co> <&a>Found player record for %uuid%" to_console
}
else {
- announce "<&b>PerkPoints<&co> <&c>Something went wrong checking the %tableName% table for %uuid%!" to_console
- queue stop
}}
else {
- announce "<&b>PerkPoints<&co> <&c>Database Offline!" to_console
- define statement "INSERT INTO %tableName% (playeruuid) VALUES ('%uuid%');"
- inject s@SQLManager_Offline p:managedUpdateStatement
}################################################################################## Voting#
voteEvent:
- inject locally loadYaml instantly
- define yamlName 'PerkPoints'
- define scriptName '<script.name>'
- define username '<context.username.sql_escaped||null>'
- define uuid '<tern[<util.player_is_valid[%username%]>]:<player.uuid> || null>'
- define service '<context.service.sql_escaped.replace[.].with[-]||null>'
- define time '<context.time||null>'
- if <def[uuid].is[==].to[null]> {
- announce "<&6><&l>PerkPoints<&co> <&3><def[username].as_player.name||Someone> voted at <&a>%service%<&3> but has never logged in!"
- announce "<&6><&l>PerkPoints<&co> <&3>Timestamp - %time%"
- queue stop
}
- define action 'vote'
- define pointValue '<yaml[PerkPoints_config].read[config.Services.%service%]||null>'
- announce "<&6><&l>PerkPoints<&co> <&3><&o><def[username].as_player.name><&3> voted at <&o>%service%<&3>!"
- announce "<&6><&l>PerkPoints<&co> <&e><&o>Thank you for your support!"
- inject locally editPoints
- inject locally logVote
- queue stop
logVote:
- define db '<yaml[PerkPoints_config].read[config.MySQL.database]>'
- define tableName '<yaml[PerkPoints_config].read[config.MySQL.tables.VoteLogs]>'
- define server '<yaml[PerkPoints_config].read[config.General.ServerName]>'
- define statement "INSERT INTO %tableName% (playeruuid, service, server, points) VALUES ('%uuid%', '%service%', '%server%', '%pointValue%');"
- inject s@SQLManager_Offline p:managedUpdateStatement
- queue stop
listServicesSeen:
- define db '<yaml[PerkPoints_config].read[config.MySQL.database]>'
- define tableName '<yaml[PerkPoints_config].read[config.MySQL.tables.VoteLogs]>'
- define msgsHeaderTitle 'Known Services'
- inject locally msgsHeader instantly
- if <proc[SQLManager_ConnectionCheck].context[%db%]> {
- sql id:%db% "query:SELECT DISTINCT service FROM %tableName%;" save:services
- define services '<entry[services].result||null>'
- if <def[services].is[==].to[null]>
|| <def[services].is_empty> {
- narrate "<&5>|<&sp><&f>No services have been seen yet!"}
else {
- foreach %services% {
- define service '<def[value].replace[/]>'
- narrate "<&5>|<&sp><&f>%loop_index%<&co> <def[service]>"}}}
else {
- narrate "<&5>|<&sp><&c>SQL Database is offline!"}
- inject locally msgsFooter instantly
- queue stop
listServicesRegistered:
- define services '<yaml[PerkPoints_config].list_keys[config.Services].exclude[example|ExampleService]||null>'
- define msgsHeaderTitle 'Registered Services'
- inject locally msgsHeader instantly
- if <def[services].is[==].to[null]>
|| <def[services].is_empty> {
- narrate "<&5>|<&sp><&f>No services have been registered yet!"}
else {
- foreach %services% {
- define service %value%
- define point '<yaml[PerkPoints_config].read[config.Services.%service%]||null>'
- narrate "<&5>|<&sp><&f>%loop_index%. %service%<&co> %point%"}}
- inject locally msgsFooter instantly
- queue stop
registerService:
- define service '<c.args.get[2].escaped||null>'
- define pointValue '<c.args.get[3].escaped||null>'
- if <def[pointValue].is[==].to[null]> {
- narrate format:CmdSynFormat "/perkadmin regserv \<<\>service\<>\>\<<\>pointValue\<>\>"
- queue stop
}
- if <def[pointValue]> !matches integer
|| <def[pointValue].is[OR_LESS].than[0]> {
- narrate "<&b>PerkPoints<&co> <&c>Tried setting invalid pointValue. Setting sane default 5"
- define pointValue '5'
}
- yaml 'write:config.Services.<def[service].replace[.].with[-]>' 'value:%pointValue%' 'id:PerkPoints_config'
- yaml 'savefile:PerkPoints/config.yml' 'id:PerkPoints_config'
- queue stop
################################################################################## Packages#
packCommandHelper:
- inject locally loadYaml
- define arg2 '<c.args.get[2].escaped||null>'
- if <def[arg2].is[==].to[create]> {
- inject createPackage locally
}
- if <def[arg2].is[==].to[copy]> {
- inject copyPackage locally
}
- if <def[arg2].is[==].to[list]> {
- inject listPackages locally
}
- if <def[arg2].is[==].to[edit]> {
- inject editPackage locally
}
- if <def[arg2].is[==].to[del]> {
- inject delPackage locally
}
createPackage:
# BUG: Messages duplicate if sent from console. I'm not very concerned though.
- define pack '<c.args.get[3].replace[.].with[-].escaped||null>'
- define file 'packages'
- define node 'ExamplePackage'
- if <def[pack].is[==].to[null]> {
- narrate "<&b>PerkPoints<&co> <&c>You must specify a package name!"
- announce "<&b>PerkPoints<&co> <&c>You must specify a package name!" to_console
- queue stop
}
- define packList '<yaml[PerkPoints_packages].list_keys[packages]||null>'
- if <def[packList].contains[%pack%]> {
- narrate "<&b>PerkPoints<&co> <&c>Package <&b>%pack%<&c> already exists!"
- announce "<&b>PerkPoints<&co> <&c>Package <&b>%pack%<&c> already exists!" to_console
- queue stop
}
else {
- narrate "<&b>PerkPoints<&co> <&3>Creating <&b>%pack%<&3> Package..."
- announce "<&b>PerkPoints<&co> <&3>Creating <&b>%pack%<&3> Package..." to_console
- define readID 'PerkPoints_Configurations'
- define writeID 'PerkPoints_packages'
- define readPath '%readID%.%file%.%node%'
- define writePath 'packages.%pack%'
- if !<yaml.list.contains[%readID%]> yaml 'load:<script.relative_filename>' 'id:%readID%'
- run s@ConfigFileGenerator def:%readID%|%writeID%|%readPath%|%writePath%|false|false|false instantly
- yaml unload 'id:%readID%'
- yaml 'savefile:PerkPoints/packages.yml' 'id:%writeID%'
- narrate "<&b>PerkPoints<&co> <&b>Created %pack%<&a> package!"
- announce "<&b>PerkPoints<&co> <&b>Created %pack%<&a> package!" to_console
}
copyPackage:
# BUG: Messages duplicate if sent from console. I'm not very concerned though.
- define newPack '<c.args.get[3].replace[.].with[-].escaped||null>'
- define copyPack '<c.args.get[4].replace[.].with[-].escaped||null>'
- if <def[newPack].is[==].to[null]> {
- narrate "<&b>PerkPoints<&co> <&c>You must specify a new package name!"
- announce "<&b>PerkPoints<&co> <&c>You must specify a new package name!" to_console
- queue stop
}
- if <def[copyPack].is[==].to[null]> {
- narrate "<&b>PerkPoints<&co> <&c>You must specify an existing package name to copy!"
- announce "<&b>PerkPoints<&co> <&c>You must specify an existing package name to copy!" to_console
- queue stop
}
- define packList '<yaml[PerkPoints_packages].list_keys[packages]||null>'
- if <def[packList].contains[%newPack%]> {
- narrate "<&b>PerkPoints<&co> <&c>Package <&b>%newPack%<&c> already exists!"
- announce "<&b>PerkPoints<&co> <&c>Package <&b>%newPack%<&c> already exists!" to_console
- queue stop
}
- if !<def[packList].contains[%copyPack%]> {
- narrate "<&b>PerkPoints<&co> <&c>Package <&b>%copyPack%<&c> does not exist!"
- announce "<&b>PerkPoints<&co> <&c>Package <&b>%copyPack%<&c> does not exist!" to_console
- queue stop
}
else {
- narrate "<&b>PerkPoints<&co> <&3>Copying <&b>%copyPack%<&3> package..."
- announce "<&b>PerkPoints<&co> <&3>Copying <&b>%copyPack%<&3> package..." to_console
- define readID 'PerkPoints_packages'
- define writeID 'PerkPoints_packages'
- define readPath 'packages.%copyPack%'
- define writePath 'packages.%newPack%'
- run s@ConfigFileGenerator def:%readID%|%writeID%|%readPath%|%writePath%|false|false|false instantly
- yaml 'savefile:PerkPoints/packages.yml' 'id:%writeID%'
- narrate "<&b>PerkPoints<&co> <&b>Created %newPack%<&a> package!"
- announce "<&b>PerkPoints<&co> <&b>Created %newPack%<&a> package!" to_console
}
listPackages:
# Maybe add a permissions and requirements check so players only see what they# are able to get.# Should probably add a pagination system
- define msgsHeaderTitle 'Perk Packages List'
- inject locally msgsHeader instantly
- define packList '<yaml[PerkPoints_packages].list_keys[packages].exclude[ExamplePackage]||null>'
- if <def[packList].is[==].to[null]>
|| <def[packList].is_empty> {
- narrate "<&5>|<&sp><&f>No Perk Packs have been created yet!"}
else {
- foreach %packList% {
- define pack %value%
- define desc '<yaml[PerkPoints_packages].read[packages.%pack%.description]||null>'
- narrate "<&5>|<&sp><&f>%loop_index%. %pack%<&co> %desc%"
- narrate "<&5>|"}}
- inject locally msgsFooter instantly
delPackage:
- define pack '<c.args.get[3].replace[.].with[-].escaped||null>'
- if <def[pack].is[==].to[null]> {
- narrate "<&b>PerkPoints<&co> <&c>You must specify a package name!"
- announce "<&b>PerkPoints<&co> <&c>You must specify a package name!" to_console
- queue stop
}
- define packList '<yaml[PerkPoints_packages].list_keys[packages].exclude[ExamplePackage]||null>'
- if !<def[packList].contains[%pack%]> {
- narrate "<&b>PerkPoints<&co> <&c>Package <&b>%pack%<&c> does not exist!"
- announce "<&b>PerkPoints<&co> <&c>Package <&b>%pack%<&c> does not exist!" to_console
- queue stop
}
else {
- narrate "<&b>PerkPoints<&co> <&3>Deleting <&b>%pack%<&3> Package..."
- announce "<&b>PerkPoints<&co> <&3>Deleting <&b>%pack%<&3> Package..." to_console
- define writeID 'PerkPoints_packages'
- define writePath 'packages'
- yaml set %writePath%.%pack:! 'id:%writeID%'
- yaml 'savefile:PerkPoints/packages.yml' 'id:%writeID%'
- narrate "<&b>PerkPoints<&co> <&b>Deleted %pack%<&a> package!"
- announce "<&b>PerkPoints<&co> <&b>Deleted %pack%<&a> package!" to_console
}
editPackage:
# Still working on this
- define pack '<c.args.get[3].replace[.].with[-].escaped||null>'
- if <def[pack].is[==].to[null]> {
- narrate "<&b>PerkPoints<&co> <&c>You must specify a package name!"
- announce "<&b>PerkPoints<&co> <&c>You must specify a package name!" to_console
- queue stop
}
- define packList '<yaml[PerkPoints_packages].list_keys[packages].exclude[ExamplePackage]||null>'
- if !<def[packList].contains[%pack%]> {
- narrate "<&b>PerkPoints<&co> <&c>Package <&b>%pack%<&c> does not exist!"
- announce "<&b>PerkPoints<&co> <&c>Package <&b>%pack%<&c> does not exist!" to_console
- queue stop
}
else {
- define readID 'PerkPoints_Configurations'
- define readPath '%readID%.%file%.%node%'
- define writePath 'packages.%pack%'
- define writeID 'PerkPoints_packages'
- define writePath 'packages'
# - if !<yaml.list.contains[%readID%]> yaml 'load:<script.relative_filename>' 'id:%readID%'
- narrate "<&b>PerkPoints<&co> <&3>Deleting <&b>%pack%<&3> Package..."
- announce "<&b>PerkPoints<&co> <&3>Deleting <&b>%pack%<&3> Package..." to_console
# - yaml set %writePath%.%pack:! 'id:%writeID%'# - yaml 'savefile:PerkPoints/packages.yml' 'id:%writeID%'
- narrate "<&b>PerkPoints<&co> <&b>Deleted %pack%<&a> package!"
- announce "<&b>PerkPoints<&co> <&b>Deleted %pack%<&a> package!" to_console
}
packageInfo:
- narrate ""
buyPackage:
- narrate ""################################################################################## Messages#
msgsHeader:
- ^narrate "<&5>|----------------------------------------|"
- ^narrate "<&5>|<&sp><&sp><&sp><&6>Perk Points <&7>%msgsHeaderTitle%"
- ^narrate "<&5>|<&sp><&sp><&sp><&e>MineConomy <&f>Exclusive"
- ^narrate "<&5>|<&f>"
msgsFooter:
- ^narrate "<&5>|"
- ^narrate "<&d>|-----------S-c-r-o-l-l---U-p-------------|"
msgsStats:
- narrate "<&5>|<&sp><&f>Player<&co> <&3><def[stats].get[1].split[/].get[1].as_player.name||null>"
- narrate "<&5>|<&sp><&sp><&sp><&7>Account Created<&co> <&6><def[stats].get[1].split[/].get[2]||null>"
- narrate "<&5>|<&sp><&sp><&sp><&7>Total Votes<&co> <&6><def[stats].get[1].split[/].get[3]||null>"
- narrate "<&5>|<&sp><&f><yaml[PerkPoints_config].read[config.General.Points]><&co>"
- narrate "<&5>|<&sp><&sp><&sp><&7>Earned<&co> <&6><def[stats].get[1].split[/].get[4]||null>"
- narrate "<&5>|<&sp><&sp><&sp><&7>Redeemed<&co> <&c><def[stats].get[1].split[/].get[5]||null>"
- narrate "<&5>|<&sp><&sp><&sp><&7>Available<&co> <&b><def[stats].get[1].split[/].get[6]||null>"
msgsAdminHelp:
- ^narrate "<&5>|<&sp><&sp><&sp><&f>Give Points<&co><&sp><&sp><&e>/perkadmin give"
- ^narrate "<&5>|<&sp><&sp><&sp><&sp><&sp><&7>Take Points<&co><&sp><&sp><&6>/perkadmin take"
- ^narrate "<&5>|<&sp><&sp><&sp><&f>Reset Points<&co><&sp><&sp><&e>/perkadmin reset"
- ^narrate "<&5>|<&sp><&sp><&sp><&sp><&sp><&7>Deduct Points<&co><&sp><&sp><&6>/perkadmin spend"
- ^narrate "<&5>|<&sp><&sp><&sp><&f>Restart System<&co><&sp><&sp><&e>/perkadmin --restart"
- ^narrate "<&5>|<&sp><&sp><&sp><&sp><&sp><&7>Reset System<&co><&sp><&sp><&6>/perkadmin --reset"
- ^narrate "<&5>|<&sp><&sp><&sp><&f>Lists of Stuff<&co><&sp><&sp><&e>/perkadmin list"
msgsUserHelp:
- ^narrate "<&5>|<&sp><&sp><&sp><&f>Check your Stats<&co><&sp><&sp><&e>/perk stats"################################################################################## Command Handler stuff#
adminCommandHandler:
- if !<context.server> {
- if !<player.has_permission[perkpoints.admin]> queue stop
}
- determine passively FULFILLED
- define arg1 '<c.args.get[1].escaped||null>'
- define actions 'li@spend|give|take|reset'
- if <def[arg1].is[==].to[--restart]> {
- narrate "<&b>PerkPoints<&co> <&d>Restarting System!"
- inject locally loadYaml
- define yamlName 'PerkPoints'
- define scriptName '<script.name>'
- define db '<yaml[PerkPoints_config].read[config.MySQL.database]>'
- run s@SQLManager p:restart def:%yamlName%|%scriptName%|%db%
- queue stop
}
- if <def[arg1].is[==].to[--reset]> {
- narrate "<&b>PerkPoints<&co> <&c>System Reset feature hasn<&sq>t been impelemented yet!"
- narrate "<&b>PerkPoints<&co> <&f>Let<&sq>s RESTART the system instead..."
- inject locally loadYaml
- define yamlName 'PerkPoints'
- define scriptName '<script.name>'
- define db '<yaml[PerkPoints_config].read[config.MySQL.database]>'
- run s@SQLManager p:restart def:%yamlName%|%scriptName%|%db%
- queue stop
}
- if <def[arg1].is[==].to[regserv]> {
- inject locally registerService
- queue stop
}
- if <def[arg1].is[==].to[pack]> {
- inject locally packCommandHelper
- queue stop
}
- if <def[arg1].is[==].to[list]> {
- define arg2 '<c.args.get[2].escaped||null>'
- if <def[arg2].is[==].to[services]> {
- define arg3 '<c.args.get[3].escaped||null>'
- if <def[arg3].is[==].to[known]> {
- inject locally listServicesSeen
- queue stop
}
- if <def[arg3].is[==].to[registered]> {
- inject locally listServicesRegistered
- queue stop
}
- narrate format:CmdSynFormat "/perkadmin list services \<<\>known/registered\<>\>"
- queue stop
}
- narrate format:CmdSynFormat "/perkadmin list \<<\>services/players/packages\<>\>"
- queue stop
}
- if <def[actions].contains[<def[arg1]>]> {
- define action '<def[arg1]>'
- define player '<c.args.get[2].escaped||null>'
- define pointValue '<c.args.get[3].escaped||null>'
- if <def[player].is[==].to[null]>
|| !<util.player_is_valid[%player%]> {
- narrate "<&b>PerkPoints<&co> <&c>%player% is an unknown player!"
- queue stop
}
- define uuid '<def[player].as_player.uuid>'
- inject locally editPoints
- queue stop
}
- run locally adminCommandHelp instantly
- queue stop
adminCommandHelp:
- define msgsHeaderTitle 'Admin Help'
- inject locally msgsHeader instantly
- inject locally msgsAdminHelp instantly
- inject locally msgsFooter instantly
commandHandler:
- if <context.server> {
- determine passively FULFILLED
- announce "<&b>PerkPoints user commands must be done in game." to_console
- queue stop
}
- define arg1 '<c.args.get[1].escaped||null>'
- define arg2 '<c.args.get[2].escaped||null>'
- if !<player.has_permission[perkpoints.user]> queue stop
- determine passively FULFILLED
- if <def[arg1].is[==].to[stats]> {
- if <def[arg2].is[!=].to[null]>
&& <player.has_permission[perkpoints.admin]> {
- if <util.player_is_valid[%arg2%]> {
- define uuid '<def[arg2].as_player.uuid||null>'
}
else {
- narrate "<&b>PerkPoints<&co> <&c>%arg2% is an unknown player!"
- queue stop
}}
- inject locally showPlayerStats instantly
- queue stop
}
else {
- run locally commandHelp instantly
- queue stop
}
commandHelp:
- define msgsHeaderTitle 'User Help'
- inject locally msgsHeader instantly
- inject locally msgsUserHelp instantly
- inject locally msgsFooter instantly
################################################################################# ## Configuration Files ## ## These are the default config files. They will be used to build the default ## config file and data storage files. ## ##______________________________________________________________________________## ##______________________________DO_NOT_EDIT_THIS_DATA___________________________##______________________________________________________________________________#
PerkPoints_Configurations:
type: task
debug: false
config:
General:
AutoCreateAccounts: true
Points: Points
VoteReward: 5
Transferrable: false
ExpireOnStartup: true
PurgeOnStart: true
ServerName: Minecraft Server
ExpireCheck: 5m
Services:
example: point value
ExampleService: 5
MySQL:
useSql: false
connection:
keepAlive: 5m
retry: 3
retryDelay: 10s
host: localhost
port: 3306
username: root
password: password
database: PerkPoints
tables:
VoteLogs: perks_votelog
PerkPoints: perks_points
packages:
ExamplePackage:
active: false
price: 100
description: This is an example package.
hasLimit: false
limit: 3
activeImmediately: true
requireOnline: true
requirePrerequisite: false
prerequisite: []
requiredInventorySpace: 0
expires: false
expireTime: 3h
onActivate:
permissionSet: []
groupAdd: []
commands: []
announce: []
tell: []
onExpire:
permissionTake: []
groupRemove: []
commands: []
announce: []
tell: []################################################################################# ## SQL Table Structure ## ## This is where the table structure is defined. It would be best if you do ## not touch anything in this section! ## ##______________________________________________________________________________## ##______________________________DO_NOT_EDIT_THIS_DATA___________________________##______________________________________________________________________________#
PerkPoints_SQLTables:
# This script gets injected from the SQLManager on system start. It sets up some# data it needs and loads the table structure so it's ready for the SQLManager.
type: task
debug: false
script:
- define sqlScriptName 'PerkPoints_SQLTables'
- define sqlFile '<script.relative_filename>'
- if <yaml.list.contains[%sqlScriptName%]> yaml unload 'id:%sqlScriptName%'
- yaml 'load:%sqlFile%' 'id:%sqlScriptName%'
- if !<yaml.list.contains[%sqlScriptName%]> {
- announce "<&c>PerkPoints<&co><&b> An error occurred while loading %sqlScriptname%!" to_console
- announce "<&b>PerkPoints<&co><&3> Aborting..." to_console
- inject s@%scriptName% p:unload
- queue stop
}
tables:
VoteLogs:
columns:
id: INT NOT NULL AUTO_INCREMENT PRIMARY KEY
playeruuid: varchar(255)
date: TIMESTAMP DEFAULT CURRENT_TIMESTAMP
service: varchar(255)
server: varchar(255)
points: INT NOT NULL DEFAULT '0'
PerkPoints:
columns:
id: INT NOT NULL AUTO_INCREMENT PRIMARY KEY
playeruuid: varchar(255) NOT NULL UNIQUE
created: TIMESTAMP DEFAULT CURRENT_TIMESTAMP
totalvotes: INT NOT NULL DEFAULT '0'
pointsearned: INT NOT NULL DEFAULT '0'
pointsspent: INT NOT NULL DEFAULT '0'
pointsbalance: INT NOT NULL DEFAULT '0'