Advertisement
killahtomato

TomatoPatch

Sep 7th, 2013
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.50 KB | None | 0 0
  1. package tomatoPatch;
  2.  
  3. import java.io.PrintStream;
  4. import java.util.HashMap;
  5. import java.util.Map.Entry;
  6. import java.util.logging.Logger;
  7. import org.bukkit.Bukkit;
  8. import org.bukkit.ChatColor;
  9. import org.bukkit.Server;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.event.EventHandler;
  12. import org.bukkit.event.Listener;
  13. import org.bukkit.event.player.PlayerJoinEvent;
  14. import org.bukkit.plugin.PluginManager;
  15. import org.bukkit.plugin.java.JavaPlugin;
  16. import org.bukkit.scheduler.BukkitScheduler;
  17.  
  18. public class TPatch extends JavaPlugin
  19.   implements Listener
  20. {
  21.   public final HashMap<String, Integer> exploit = new HashMap();
  22.  
  23.   public void onEnable() {
  24.     PluginManager pm = getServer().getPluginManager();
  25.     pm.registerEvents(this, this);
  26.     getLogger().info("TomatoPatch Enabled :)");
  27.     getLogger().info("-----__\\W//__-----");
  28.     getLogger().info("---.'.-'|'-.'.---");
  29.     getLogger().info("--//_-_-_-_-_-\\--");
  30.     getLogger().info("--|---Tomato--|--");
  31.     getLogger().info("--\\-_-_-_-_-_//--");
  32.     getLogger().info("---'-.____.-'---");
  33.     patch();
  34.   }
  35.  
  36.   public void onDisable()
  37.   {
  38.     getLogger().info("TomatoPatch Disabled!");
  39.   }
  40.   public void patch() {
  41.     Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
  42.       public void run() {
  43.         for (Map.Entry entry : TPatch.this.exploit.entrySet()) {
  44.           String playername = (String)entry.getKey();
  45.           int logs = ((Integer)entry.getValue()).intValue();
  46.           if (logs >= 25) {
  47.             Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
  48.               "tempban " + playername + " 1h");
  49.             for (Player p : Bukkit.getOnlinePlayers()) {
  50.               Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
  51.                 "deop " + playername);
  52.             }
  53.             TPatch.this.getLogger().info(TPatch.this.exploit.toString() + " Player looks like they are exploiting, temp banning for one hour");
  54.           } else if (logs >= 10) {
  55.             TPatch.this.getLogger().info(TPatch.this.exploit.toString());
  56.           }
  57.         }
  58.       }
  59.     }
  60.     , 20L);
  61.   }
  62.   @EventHandler
  63.   public void exploitPatchLI(PlayerJoinEvent e) {
  64.     Player p = e.getPlayer();
  65.     String n = p.getName().toString();
  66.     if (!this.exploit.containsKey(n)) {
  67.       this.exploit.put(n, Integer.valueOf(0));
  68.     }
  69.     int i = ((Integer)this.exploit.get(n)).intValue();
  70.     i++;
  71.     this.exploit.put(n, Integer.valueOf(i));
  72.     patch();
  73.   }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement