Skip to content

Commit

Permalink
Added general storage categories
Browse files Browse the repository at this point in the history
Added general storage categories
  • Loading branch information
Abwasserrohr committed May 28, 2019
2 parents 945363b + d04a62e commit d6406c2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions STEEM.CRAFT/core/functions/getOpsInBlock.sk
Expand Up @@ -23,7 +23,7 @@ function getOpsInBlock(blocknumber:number,onlyvirtual:boolean=false) :: object:
#
# > If the block caching is not disabled.
else:
set {_tmp} to getGeneralStorageData("steemblocks","%{_blocknumber}%-%{_onlyvirtual}%")
set {_tmp} to getGeneralStorageData("steemblocks","%{_blocknumber}%-%{_onlyvirtual}%","b")
#
# > If the block is cached, decompress the base64 string and deserialize it
# > to make it a SteemJ object again.
Expand All @@ -35,5 +35,5 @@ function getOpsInBlock(blocknumber:number,onlyvirtual:boolean=false) :: object:
else:
set {_steemj} to new SteemJ()
set {_block} to {_steemj}.getOpsInBlock({_blocknumber},{_onlyvirtual})
saveGeneralStorageData("steemblocks","%{_blocknumber}%-%{_onlyvirtual}%",compressBase64(serialize({_block})))
saveGeneralStorageData("steemblocks","%{_blocknumber}%-%{_onlyvirtual}%","b",compressBase64(serialize({_block})))
return {_block}
10 changes: 6 additions & 4 deletions STEEM.CRAFT/core/functions/storage/storage.sk
Expand Up @@ -44,29 +44,31 @@ function getStorageData(usage:text,player:offline player,key:text) :: object:
# > Saves data for a specific usage type to the desired format.
# > Parameters:
# > <text>usage identifier
# > <text>category
# > <text>data key
# > <object>data value
function saveGeneralStorageData(usage:text,key:text,data:object):
function saveGeneralStorageData(usage:text,category:text,key:text,data:object):
#
# > Get the storage type out of the configuration to allow the server
# > operator multiple storage formats.
set {_storageformat} to getStorageType()
if {_storageformat} is "yaml":
saveyamldata({_usage},{_key},{_data})
saveyamldata({_usage},{_category},{_key},{_data})

#
# > Function - getGeneralStorageData
# > Returns the requested data from the desired storage format.
# > Try to cache results, since this may not very fast.
# > Parameters:
# > <text>usage identifier
# > <text>category
# > <text>data key
# > Returns:
# > <object>data value
function getGeneralStorageData(usage:text,key:text) :: object:
function getGeneralStorageData(usage:text,category:text,key:text) :: object:
#
# > Get the storage type out of the configuration to allow the server
# > operator multiple storage formats.
set {_storageformat} to getStorageType()
if {_storageformat} is "yaml":
return getyamldata({_usage},{_key})
return getyamldata({_usage},{_category},{_key})
10 changes: 6 additions & 4 deletions STEEM.CRAFT/core/functions/storage/yaml.sk
Expand Up @@ -36,19 +36,21 @@ function getyamluserdata(usage:text,player:offline player,key:text) :: object:
# > Saves data for a specific usage type in a yaml file.
# > Parameters:
# > <text>usage identifier
# > <text>category
# > <text>data key
# > <object>data value
function saveyamldata(usage:text,key:text,data:object):
set yaml value "%{_key}%" from "plugins/Skript/storage/%{_usage}%/%{_key}%.yml" to {_data}
function saveyamldata(usage:text,category:text,key:text,data:object):
set yaml value "%{_key}%" from "plugins/Skript/storage/%{_usage}%/%{_category}%.yml" to {_data}

#
# > Function - getyamldata
# > Returns the yaml data by parsing the file.
# > Try to cache results, since this is not very fast.
# > Parameters:
# > <text>usage identifier
# > <text>category
# > <text>data key
# > Returns:
# > <object>data value
function getyamldata(usage:text,key:text) :: object:
return yaml value "%{_key}%" from "plugins/Skript/storage/%{_usage}%/%{_key}%.yml"
function getyamldata(usage:text,category:text,key:text) :: object:
return yaml value "%{_key}%" from "plugins/Skript/storage/%{_usage}%/%{_category}%.yml"

0 comments on commit d6406c2

Please sign in to comment.