Example
If shading MilkGUI, be sure to register your plugin during onEnable:
@Override
public void onEnable() {
MilkGUI.INSTANCE.register(this);
}Saving any type of GUI is easy! Here's an example of saving to a Bukkit YAML file:
Plugin plugin; // Instantiate your plugin
public void saveGuiData(final BasicGUI gui, final String fileName) throws Exception {
final FileConfiguration data = new YamlConfiguration();
data.options().header("File must stay in UTF-8 encoding!");
data.set(plugin.getName(), gui);
final File file = new File(plugin.getDataFolder()
+ File.separator + "gui", fileName);
try {
if (file != null) {
data.save(file);
}
} catch (final Exception e) {
e.printStackTrace();
}
}Loading from the same file is a walk in the park:
Last updated
Was this helpful?