-
-
Notifications
You must be signed in to change notification settings - Fork 4
Start Setting Data
PUUIDs uses a "handshake" from your plugin to confirm that you are reading/writing as your plugin, and not accidentally writing or reading over another plugins data. If you choose to not use the handshake, you will not be able to write any data in PUUIDs. Here's what the handshake looks like:
public void onEnable() {
// This if statement ensures we don't try to connect if PUUIDs is disabled.
if(getServer().getPluginManager().isPluginEnabled("PUUIDs")) {
PUUIDs.connect(this, APIVersion.V4);
// APIVersion should always be the highest number available.
// This ensures compatibility between your plugin & PUUIDs
// If this number is not the latest, your plugin may not run.
}
}The connect statement also returns a boolean. This will return true if the plugin was able to connect, and false if it wasn't able to connect. The only reason .connect would ever return false is if it is called outside of the startup onEnable() task, your APIVersion is too low, or if a plugin is already connected with the same name as yours.
Setting data is pretty simple. After you've done the handshake above, you only need to call the set method and you're- well... all set!
PUUIDs.set(Plugin, String, String, Object);-
Plugin: Should be your plugin's instance. By default, use
this - String: (1st String) Should be the player's UUID as a string.
- String: (2nd String) Should be the path of your data. Similar to getConfig paths.
- Object: This is your data! It can be anything: Boolean, String, Double, Long, List, Integer etc.
final Player p = e.getPlayer();
final String uuid = p.getUniqueId().toString();
PUUIDs.set(this, uuid, "MyVariable", true);
PUUIDs.set(this, uuid, "My2ndVariable", 0.5);
PUUIDs.set(this, uuid, "My3rdVariable", "I love PUUIDs!");
PUUIDs.set(this, uuid, "My4thVariable.Is-Awesome", true);This will set 3 variables under the file associated with that UUID. If using lots of .set calls, I recommend making a uuid variable (like above) as a string. Here's what that data would look like in a file:
UUID: 6191ff85-e092-4e9a-94bd-63df409c2079
IP: 12.345.678.90
Username: zach_attack
Last-On: 1587855153569
Time-Played: 0
Plugins:
MYPLUGIN:
MyVariable: true
My2ndVariable: 0.5
My3rdVaribable: 'I love PUUIDs'
My4thVariable:
Is-Awesome: trueNOTE: For this example, you see MYPLUGIN in the file. This will be replaced with your plugins name (in all capitals) that is received from the this instance shown in our example.
This Wiki is still under construction. I am working my best to accurately document the API and ensure up to date information for PUUIDs.