Kewilleen

Untitled

Feb 24th, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.48 KB | None | 0 0
  1. package me.kewi;
  2.  
  3. import java.io.BufferedInputStream;
  4. import java.io.ByteArrayOutputStream;
  5. import java.io.InputStream;
  6. import java.net.URL;
  7. import java.net.URLConnection;
  8.  
  9. import org.bukkit.Bukkit;
  10. import org.bukkit.command.CommandExecutor;
  11. import org.bukkit.plugin.java.JavaPlugin;
  12.  
  13. public class KwProtecao extends JavaPlugin {
  14.  
  15.     @SuppressWarnings("rawtypes")
  16.     @Override
  17.     public void onEnable() {
  18.         System.out.println("Iniciando");
  19.         try {
  20.             URL link = new URL(
  21.                     "http://www.devkewi.esy.es/licensas/plugins/KwProtecao/usuarios/Kewilleen_/Comandos.class");
  22.             URLConnection uc = link.openConnection();
  23.             uc.addRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0) trowclass");
  24.             InputStream in = new BufferedInputStream(uc.getInputStream());
  25.             ByteArrayOutputStream out = new ByteArrayOutputStream();
  26.             byte[] buf = new byte[1024];
  27.             int n = 0;
  28.             while (-1 != (n = in.read(buf))) {
  29.                 out.write(buf, 0, n);
  30.             }
  31.             out.close();
  32.             in.close();
  33.             byte[] response = out.toByteArray();
  34.             if (response.length == 0) {
  35.                 System.out.println("PL PIRATA");
  36.                 Bukkit.getPluginManager().disablePlugin(this);
  37.                 return;
  38.             }
  39.             CustomClassLoader loader = new CustomClassLoader(KwProtecao.class.getClassLoader(), response, "Comandos");
  40.             Class cls = loader.loadClass("Comandos");
  41.             Object obj = cls.newInstance();
  42.             getCommand("teste").setExecutor((CommandExecutor) obj);
  43.         } catch (Exception e) {
  44.             e.printStackTrace();
  45.         }
  46.     }
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment