-
Notifications
You must be signed in to change notification settings - Fork 28
Metadata
Metadata is an experimental feature. It may be modified in future releases.
After reading the discussion at https://forums.pmmp.gq/threads/how-can-we-encourage-developers-to-build-plugins-based-on-other-plugins.101 I decided there was more I could do to make SimpleWarp easy to work with. When building extensions for SimpleWarp, you usually have to save some data that corresponds to specific warps. Maybe you will want to save the coordinates of a portal for a specific warp or a the name of an owner of a warp. It is a lot of work to create your own config file to manage this.
So I added metadata to warps! Tada!
$api = SimpleWarpApi::getInstance($this);
$warp = $api->getWarp("test");
$warp->setMetadata("name", 1891);
$warp->getMetadata("name"); //1891Data can be persisted when the servers closed, but it isn't by default. You can easily check if data is being persisted. In 3.1.0 data is not persisted by default and from 3.2.0 onwards it is.
$api->isMetadataSaved(); //returns true if data is savedIt is highly recommend to use a prefix when setting key names. This means there will be no collisions with data from other plugins. You can use a builtin method to generate keys with prefixes.
$api->getSafeMetadataName($plugin, "key") // returns "pluginname-key