Skip to content

API Usage

Garrett Foy edited this page May 18, 2020 · 1 revision

General

The CpasAPI allows any external plugin to hook into CPAS's PlayerCache, which is a mySQL based player cache system that stores all of the essential MAUL information that CPAS provides onLogin, and stores it for other plugins to use in real-time.

Adding a Dependency

Thank's to the help of JitPack, integrating CpasSpigot into your plugin has never been easier!

For maven, add the following snippet to your maven

	<repositories>
		<repository>
		    <id>jitpack.io</id>
		    <url>https://jitpack.io</url>
		</repository>
	</repositories>
	<dependency>
	    <groupId>com.github.garrettpfoy</groupId>
	    <artifactId>CpasSpigot</artifactId>
	    <version>-SNAPSHOT</version>
	</dependency>

For gradle, add the following to your gradle

	allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}
     dependencies {
	        implementation 'com.github.garrettpfoy:CpasSpigot:-SNAPSHOT'
	}

Usage

To fetch a player's cache, use the following:

CpasPlayerCache playerData = CpasAPI.getCache(uuid)

It is important to note that the UUID parameter must be of type UUID, not String. A future update may add string & player support, however for now fetch a UUID through a player object or by other means.

Once you have an instance of a player's cache, you can access all of the benefits of MAUL and it's information without actually having to worry about modifying the actual database itself. Since I plan on adding events and other interfaces, I will create a new section for each API interface supported.

Reading / Writing Playerdata

Due to the nature of the API, your changes will not negatively affect MAUL, however it can have strong negative affects on the server. Thankfully, most of these changes can be reverted when a player disconnects, however there are some methods that will not be saved, and should be interfered with caution.

To save space on this wiki page, I've commented the interface class with as much detail as possible on each method available to you. Every setting has a setter, but just because it is there does not mean you should use it!

CpasPlayerCache Interface

Contributing

Unfortunately due to the nature of this project, I will not be able to accept many merges, however forks are welcome!

Clone this wiki locally