BlockStore
1.5.0Developer tool - adds persistent block metadata and checking whether a block is placed by a player

If a plugin you are wanting to use has requested this plugin to be installed, just download it, stick it in your plugins folder and restart your server and everything should work perfectly.
This plugin adds the ability to add metadata to blocks that persists across restarts! This is a very useful feature when you need to store information associated with blocks over a restart, such as the state of custom machines or the name of player heads.
The plugin also stores whether each block was placed by a player or if it was naturally generated. This is useful in many situations, such as if you wanted to make fortune work on gold ore, you wouldn't want players to be able to just place the gold ore, break and repeat!
/blockstore check
- Check whether a block was placed by a human and check a block's metadata
permission: blockstore.check
/blockstore info
- Get info on the loaded chunks
permission: blockstore.info
/blockstore reload
- Reload the configuration of BlockStore
permission : blockstore.reload
The default config is as follows, with the values you can give specified in comments:
# All - If a chunk is loaded in game, it will be preloaded by BlockStore
# Close - If a chunk is next to a player in the game, it will be preloaded by BlockStore
# None - No chunks will be preloaded by BlockStore, chunks will be loaded as they are used
preload: 'Close'
# The time in seconds to wait after a chunk store is used to unload it
unload-time: 60
If you are using a newer version of WorldEdit, this plugin will be able to hook into it and will mark any blocks changed by WorldEdit as natural.

Developers
Ok, so how do we use it?
Well, its quite simple actually, you can either:
a) add the plugin as a dependency in your plugin.yml
b) check whether the api is available to you using
Bukkit.getPluginManager().getPlugin("BlockStore") != null;Then you can use the api, which contains the methods:
boolean isPlaced(Block block)
boolean isPlaced(Location loc)
retrieveIsPlaced(Plugin callingPlugin, Block block, Consumer<Boolean> consumer)
retrieveIsPlaced(Plugin callingPlugin, Location loc, Consumer<Boolean> consumer)
setPlaced(Block block, boolean placed)
setPlaced(Location loc, boolean placed)
Object getBlockMeta(Block block, Plugin plugin, String key)
Object getBlockMeta(Location loc, Plugin plugin, String key)
retrieveBlockMeta(Plugin callingPlugin, Block block, Plugin plugin, String key, Consumer<Object> consumer)
retrieveBlockMeta(Plugin callingPlugin, Location loc, Plugin plugin, String key, Consumer<Object> consumer)
Map<String, Object> getAllBlockMeta(Block block, Plugin plugin)
Map<String, Object> getAllBlockMeta(Location loc, Plugin plugin)
retrieveAllBlockMeta(Plugin callingPlugin, Block block, Plugin plugin, Consumer<Map<String, Object>> consumer)
retrieveAllBlockMeta(Plugin callingPlugin, Location loc, Plugin plugin, Consumer<Map<String, Object>> consumer)
Map<String, Object> getAllBlockMeta(Block block)
Map<String, Object> getAllBlockMeta(Location loc)
retrieveAllBlockMeta(Plugin callingPlugin, Block block, Consumer<Map<String, Map<String, Object>>> consumer)
retrieveAllBlockMeta(Plugin callingPlugin, Location loc, Consumer<Map<String, Map<String, Object>>> consumer)
boolean containsBlockMeta(Block block, Plugin plugin, String key)
boolean containsBlockMeta(Location loc, Plugin plugin, String key)
retrieveContainsBlockMeta(Plugin callingPlugin, Block block, Plugin plugin, String key, Consumer<Boolean> consumer)
retrieveContainsBlockMeta(Plugin callingPlugin, Location loc, Plugin plugin, String key, Consumer<Boolean> consumer)
setBlockMeta(Block block, Plugin plugin, String key, Object value)
setBlockMeta(Location loc, Plugin plugin, String key, Object value)
removeBlockMeta(Block block, Plugin plugin, String key)
removeBlockMeta(Location loc, Plugin plugin, String key)All these methods are static members of the class BlockStoreApi and can be used as such:
String name = (String) BlockStoreApi.getBlockMeta(myBlock, myPlugin, "name");
Metadata Restrictions:
Block Metadata must be of the type
- String
- boolean
- byte
- short
- int
- long
- float
- double
and all the array subclasses of these, such as
String[] or int[][]
Note: Getting block's state during the ChunkLoadEvent or before chunks have loaded will cause the thread to block if the chunk has not already been preloaded by BlockStore. This can be fixed by running this logic asynchronously or using the retrieve methods of the API, which will handle waiting until the chunk is loaded for you.
The source code is available on BitBucket here.
A small, $5 donation helps me support my coding habits and provide you with awesome plugins such as this one, completely for free!
Although this plugin may appear simple (as it has been designed to be!), a huge amount of work has gone into its backend to make sure it uses CPU, memory and storage as efficiently as possible!
If this plugin helps you with your projects or servers, a small donation would be hugely appreciated!
You can donate here :)
Similar projects
Plugin →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
26.2MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.9MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
4.7MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta