Skip to content

Latest commit

History

28 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Rson

This library is not a plugin, but a component you could include.

This is made to work between CraftBukkit, Spigot, and Sponge.

Gradle

First add JitPack to your repositories:

allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}

Now add Rson to your dependencies

dependencies {
compile 'com.github.redstone:Rson:1.0.0'
}

Usage

Create a class that you want to be saveable

publicclassConfigextendsRson<Config> {
// Singleton, you don't have to do this - organise your creation and// defining of path however you wantprivatestatictransientConfigi;
publicstaticConfigget() {
if (i == null) {
// Create an instancei = newConfig();
// Call setup to set the path and the charseti.setup(Paths.get(Plugin.get().getDataFolder().toString(), "config.json"), Charset.defaultCharset());
}
returni;
}
publicConfig() { }
publicBooleanconfigurationOption = true;
publicBooleanmoreConfigurationOptions = false;
publicDoublejustSomeMoreConfigurationOptions = 55.10;
}

So now you can grab this config and load/save it. If the json file doesn't exist on load it simply loads the defaults.

Config.get().load().save();

Now, we can access any of these fields:

if (Config.get().configurationOption) {
// .. do something
} else {
// we can modify and save whenever we wantConfig.get().configurationOption = true;
Config.get().save();
}

About

Gson wrapper that works between Sponge and Bukkit

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages