Skip to content

Instantly share code, notes, and snippets.

@TheMasteredPanda
Created November 3, 2017 18:40
Show Gist options
  • Save TheMasteredPanda/cb3c2f481b3882c459413789bfda2245 to your computer and use it in GitHub Desktop.
Save TheMasteredPanda/cb3c2f481b3882c459413789bfda2245 to your computer and use it in GitHub Desktop.
@Override @SneakyThrows
public synchronized void load()
{
if (!this.getInstance().getDataFolder().exists()) {
this.getInstance().getDataFolder().mkdir();
}
if (this.getInstance().getResourceAsStream(this.getName()) != null && !this.getFile().exists()) {
InputStream is = this.getInstance().getResourceAsStream(this.getName());
OutputStream os = new FileOutputStream(this.getFile());
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = is.read()) != -1) {
os.write(buffer, 0, bytesRead);
}
is.close();
os.close();
}
if (this.getConfiguration() == null) {
this.configuration = ConfigurationProvider.getProvider(this.getProvider()).load(this.getFile());
}
this.PLUGIN_PREFIX = this.getMessage("Plugin.Prefix");
this.PLUGIN_MESSAGE_FORMAT = this.getMessage("Plugin.PluginMessageFormat");
this.LIST_HEADER_FORMAT = this.getMessage("Plugin.ListHeaderFormat");
this.LIST_FOOTER_FORMAT = this.getMessage("Plugin.ListFooterFormat");
this.PAGE_INDEX_FORMAT = this.getMessage("Plugin.PageIndexFormat");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment