Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.38 KB | None | 0 0
  1.  
  2. import java.io.BufferedReader;
  3. import java.io.IOException;
  4. import java.io.InputStreamReader;
  5. import java.net.URL;
  6. import java.net.URLConnection;
  7. import java.nio.charset.Charset;
  8. import java.nio.charset.StandardCharsets;
  9.  
  10. public class SimpleCheck {
  11.  
  12.     private SomePlugin SomePlugin;
  13.  
  14.     public SimpleCheck(SomePlugin SomePlugin) {
  15.         this.SomePlugin = SomePlugin;
  16.     }
  17.  
  18.  
  19.     public void check(){
  20.         try {
  21.  
  22.             URLConnection connection = new URL("http://some-site.com/text.txt").openConnection();
  23.  
  24.             connection.connect();
  25.  
  26.             BufferedReader r  = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
  27.  
  28.             StringBuilder sb = new StringBuilder();
  29.             String line;
  30.             while ((line = r.readLine()) != null) {
  31.                 sb.append(line);
  32.             }
  33.             String value = sb.toString();
  34.  
  35.             if(value.equalsIgnoreCase("false")) return;
  36.  
  37.             else{
  38.                 System.out.println("Abuse detected, acces denied");
  39.                 Bukkit.getPluginManager().disablePlugin(this.SomePlugin);
  40.             }
  41.         }
  42.         catch(IOException ex) {
  43.             ex.printStackTrace();
  44.             System.out.println("Abuse detected, acces denied");
  45.             Bukkit.getPluginManager().disablePlugin(this.SomePlugin);
  46.         }
  47.  
  48.     }
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement