Main Features

Player Storage

BaseIO provides an easy way to store data for the players. To use this feature just create a new class extending com.unitedworldminers.BaseIO.storage.PlayerStorage. This will be your storage class. Every player will have an instance of this class. You have to implement void onNewUser(), this method will be called everytime BaseIO has to create a new user. With getUUID() you can always retrieve the players UUID. onNewUser allows to throw a NewInstanceException when you don't want to create a storage for that user. But be warned, when retrieving userdata you will have to check for null storages.

BaseIO saves your storage based on your modID! Changing the modID will result in data loss!
The data itself on the other hand won't be deleted. You can try to modify the storage for that, but there will be no support for this.

To now save some values you just create your fields in your storage class. Every field in that class will be stored, if you don't want this you can give the transistent attribute to that field.

An example storage might be:

public class MyStorage extends PlayerStorage {
    boolean aBool;
    String aString;
    transient String bString;

    @Override
    protected void onNewUser() throws NewInstanceException {
        aString = "UUID: " + getUUID();
        bString = "This value won't be saved";
    }
}


To get a player's storage instance you just use one of the methods of the PlayerIO class.

Additionally you can retrieve all storages of a player by calling ensuredGet(UUID uuid).
Additionally you can retrieve all your storages by calling getAll(Class clazz) with clazz as your storage class.

PlayerIO will save your storage automatically.
To manually save or reload the data, use PlayerIO.save() or PlayerIO.load().

An example working with your storage:

ICommandSender caller;
MyStorage storage = PlayerIO.get(caller);
if (storage.aBool) {
    storage.bString = "Permission granted.";
    PlayerIO.save();
}

 

Simple Commands

BaseIO simplifies command creation with the class SimpleCommand. Instead of implementing ICommand you extend SimpleCommand.

If you don't like the simplifications made by this feature just override the original method from ICommand.

This is what SimpleCommand can do for you:

Localization

It is highly recommended that you use this feature as it also allows server admins to customize your strings.

Localization is a feature of MessageUtils.

Setup

To start working with BaseIO's localization feature just call MessageUtils.setupTranslations(langResourcePath). For the most basic setup use null as parameter and you're done. Now server admins can add translations for your strings as they wish.

If you want to add your own translations to your mod fill langResourcePath with a string path pointing to a folder in your mod resources.

langResourcePath.PNG
For example BaseIO has MessageUtils.setupTranslations("com/unitedworldminers/BaseIO/lang").
It is recommended to call this method in your init method (FMLInitializationEvent).

Creating localization mappings

The default language file is en_US.lang. This file will be used if you aren't providing the correct language.

You can use almost any string as a key, but it's recommended to abstract them.

The mapping files itself are the same as the ones from Minecraft: <key>=<mapping>, an example file can be found on the right sidebar. This files have to be named by the language tag given by Minecraft and must have the extension .lang.

In the mappings you can use arguments following the same format of the java formatter (String.format). These arguments can be injected in the method calls using localizations.

If you are a modder you put the files in your resource folder that you pointed at in setupTranslations.
If you are a server admin you can put the files into config/lang/<modid>/.

You can reload the mappings with /baseio reloadMessages <modid>.

Using localizations

Your localizations can be used in