Created
April 5, 2013 14:51
-
-
Save roblabla/5319891 to your computer and use it in GitHub Desktop.
BungeeYAML downloader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.craftminecraft.bungee.bungeeyaml; | |
import java.io.File; | |
import java.io.FileOutputStream; | |
import java.io.IOException; | |
import java.util.concurrent.ExecutionException; | |
import java.util.concurrent.Future; | |
import java.util.logging.Level; | |
import com.ning.http.client.AsyncCompletionHandler; | |
import com.ning.http.client.AsyncHandler; | |
import com.ning.http.client.Request; | |
import com.ning.http.client.Response; | |
import net.md_5.bungee.api.plugin.Plugin; | |
public class BungeeYAMLDownloader { | |
private static final String link = "http://repo.craftminecraft.net/service/local/artifact/maven/contentg=net.craftminecraft.bungee&a=bungeeyaml&v=RELEASE&r=releases"; | |
public static void download(final Plugin plug) throws Exception { | |
if (plug.getProxy().getPluginManager().getPlugin("BungeeYAML") == null) { | |
Future<Response> fresponse = plug.getProxy().getHttpClient().prepareGet(link).execute(); | |
Response res = fresponse.get(); | |
File bungeeyamlfile = new File(plug.getProxy().getPluginsFolder(), "BungeeYAML.jar"); | |
FileOutputStream bungeeyamlstream = new FileOutputStream(bungeeyamlfile); | |
bungeeyamlstream.write(res.getResponseBodyAsBytes()); | |
bungeeyamlstream.close(); | |
plug.getProxy().getPluginManager().loadPlugin(bungeeyamlfile); | |
Plugin bungeeyaml = plug.getProxy().getPluginManager().getPlugin("BungeeYAML"); | |
bungeeyaml.onEnable(); | |
plug.getProxy().getLogger().log( Level.INFO, "Enabled plugin {0} version {1} by {2}", new Object[] | |
{ | |
bungeeyaml.getDescription().getName(), bungeeyaml.getDescription().getVersion(), bungeeyaml.getDescription().getAuthor() | |
}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment