Skip to content

Instantly share code, notes, and snippets.

@xaviablaza-zz
Created March 21, 2012 10:24
Show Gist options
  • Save xaviablaza-zz/2146027 to your computer and use it in GitHub Desktop.
Save xaviablaza-zz/2146027 to your computer and use it in GitHub Desktop.
Main Plugin Method Essentials
private void checkConfig() {
String name = "config.yml";
File actual = new File(getDataFolder(), name);
if (!actual.exists()) {
getDataFolder().mkdir();
InputStream input = this.getClass().getResourceAsStream("/defaults/config.yml");
if (input != null) {
FileOutputStream output = null;
try {
output = new FileOutputStream(actual);
byte[] buf = new byte[4096]; //[8192]?
int length = 0;
while ((length = input.read(buf)) > 0) {
output.write(buf, 0, length);
}
this.logger.info("[LoyaltyPoints] Default configuration file written: " + name);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (input != null)
input.close();
} catch (IOException e) {}
try {
if (output != null)
output.close();
} catch (IOException e) {}
}
}
}
}
public String colorize(String message) {
return message.replaceAll("&([a-f0-9])", ChatColor.COLOR_CHAR + "$1");
}
public final Logger logger = Logger.getLogger("Minecraft");
public void info(String status) {
PluginDescriptionFile pdf = this.getDescription();
this.logger.info("[LoyaltyPoints] version " + pdf.getVersion() + " by MeneXia is now " + status + "!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment