ModsJava
[1.8-1.14] CoreData - A lightweight, centralized data solution for your plugins!
What is CoreData?
The majority of plugins in the Spigot resources section involve some level of data storage regarding the users who use the plugin. I often find myself creating new methods in each of my projects for storing data in regards to users. This plugin is designed to make the storage of data in regards to players fast and lightweight so your plugins do not take up precious storage space.
How is CoreData better than my current data solution?
CoreData's purpose is to save storage space by centralizing the location of all plugin data. Instead of each plugin creating their own files to store user data, our API creates a file for each user and allows your plugin to store data under a label in that user's file. This allows your plugins to not have to worry about file management or data storage.
Along with centralized data, our data solution is faster than traditional flat file data storage. Before, you would save all data in a file and traverse it to find the user's data. CoreData will find the user's file and directly access their data. This is very important as plugins that store data for thousands of users will see increases in the time it takes to find a user's data under traditional flat file methods while CoreData sees no change at all.
How do I use CoreData?
The first step is ensuring your plugin depends on CoreData.
Code (YAML):
depend
:
[ CoreData
]
Code (Java):
if ( ! this . getServer ( ) . getPluginManager ( ) . isPluginEnabled ( "CoreData" ) ) {
this . getLogger ( ) . severe ( "[Hook] CoreData not found. Disabling plugin..." ) ;
return ;
}
UserHandler userHandler = ( ( com. ethanpritchard . data . Main ) this . getServer ( ) . getPluginManager ( ) . getPlugin ( "CoreData" ) ) . getUserHandler ( ) ;
Code (Java):
userHandler.
createUserFile
( uuid
)
;
// Returns void
userHandler. setUserData ( uuid, label, data ) ; // Returns void
userHandler. getUserData ( uuid, label ) ; // Returns object
userHandler. getAllUsersData ( label ) ; // Returns Map<UUID, Object>
userHandler. setUserData ( uuid, label, data ) ; // Returns void
userHandler. getUserData ( uuid, label ) ; // Returns object
userHandler. getAllUsersData ( label ) ; // Returns Map<UUID, Object>
Code (Text):
balance = BAD
myPluginName.balance = GOOD
myPluginName.balance = GOOD
How do I transfer existing data to CoreData?
To transfer data to CoreData, you must have a method to get all of your users and their data as well as an iterator to navigate this data. Here is an example piece of code:
Code (Java):
private UserHandler coreDataUserHandler
;
@Override
public void onEnable ( ) {
if ( ! this . getServer ( ) . getPluginManager ( ) . isPluginEnabled ( "CoreData" ) ) {
this . getLogger ( ) . severe ( "[Hook] CoreData not found. Disabling plugin..." ) ;
return ;
}
this . coreDataUserHandler = ( ( com. ethanpritchard . data . Main ) this . getServer ( ) . getPluginManager ( ) . getPlugin ( "CoreData" ) ) . getUserHandler ( ) ;
}
public void transferToCoreData ( ) {
// Establish a data label
String label = "myPlugin.tokenbalance" ;
// Get the user data
Map < UUID, Double > balances = this . getUserBalance ( ) ;
// Iterate over the user data
for ( UUID uuid : balances. keySet ( ) ) {
// Get the user's data
double data = balances. get ( uuid ) ;
// Call the CoreData method
this . coreDataUserHandler . set ( uuid, label, data ) ;
}
}
@Override
public void onEnable ( ) {
if ( ! this . getServer ( ) . getPluginManager ( ) . isPluginEnabled ( "CoreData" ) ) {
this . getLogger ( ) . severe ( "[Hook] CoreData not found. Disabling plugin..." ) ;
return ;
}
this . coreDataUserHandler = ( ( com. ethanpritchard . data . Main ) this . getServer ( ) . getPluginManager ( ) . getPlugin ( "CoreData" ) ) . getUserHandler ( ) ;
}
public void transferToCoreData ( ) {
// Establish a data label
String label = "myPlugin.tokenbalance" ;
// Get the user data
Map < UUID, Double > balances = this . getUserBalance ( ) ;
// Iterate over the user data
for ( UUID uuid : balances. keySet ( ) ) {
// Get the user's data
double data = balances. get ( uuid ) ;
// Call the CoreData method
this . coreDataUserHandler . set ( uuid, label, data ) ;
}
}
CorePoints - A simple alternative currency plugin
CorePlaytime - The best plugin for rewarding players for playing!
Quick facts
- Edition: Minecraft Java
- File type: .jar
- Minecraft versions listed: 1.7, 1.8, 1.9
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Spigot — not every file is mirrored on our own servers.
Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.
[1.8-1.14] CoreData - A lightweight, centralized data solution for your plugins! is a free Minecraft Java mod. Compatible with Minecraft 1.7, 1.8, 1.9, 1.10 and newer. Downloaded 775 times (via Spigot). Download it and open it directly in the game.