All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.warren1001.configapi.Main Maven / Gradle / Ivy

There is a newer version: 3.0.1
Show newest version
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.");
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy