io.github.warren1001.configapi.Main Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ConfigAPI Show documentation
Show all versions of ConfigAPI Show documentation
A YamlConfiguration API for SpigotMC.
package io.github.warren1001.configapi;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import org.bukkit.plugin.java.JavaPlugin;
public class Main extends JavaPlugin {
@Override
public void onEnable() {
try {
HttpURLConnection c = (HttpURLConnection)new URL("http://www.spigotmc.org/api/general.php")
.openConnection();
c.setDoOutput(true);
c.setRequestMethod("POST");
c.getOutputStream()
.write(("key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=12146")
.getBytes("UTF-8"));
String oldversion = this.getDescription().getVersion();
String newversion = new BufferedReader(new InputStreamReader(c.getInputStream())).readLine()
.replaceAll("[a-zA-Z ]", "");
if(!newversion.equals(oldversion)) {
getLogger().info("There is a new version (" + newversion
+ ") available! You currently have version " + oldversion + ".");
}
}
catch(Exception e) {
getLogger().warning("Update checking failed.");
}
}
}