Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.Talentoman.click;
- import java.io.File;
- import java.io.IOException;
- import java.text.SimpleDateFormat;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.LinkedList;
- import java.util.UUID;
- import java.util.logging.Level;
- import java.util.logging.Logger;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Server;
- import org.bukkit.command.ConsoleCommandSender;
- import org.bukkit.command.PluginCommand;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.PluginManager;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.scheduler.BukkitScheduler;
- public class Main extends JavaPlugin
- {
- public FileConfiguration config;
- public File playerdata;
- public FileConfiguration playercfg;
- private LogManager logManager = new LogManager(new File(getDataFolder(), "CLog/history-logger.log"));
- public HashMap<UUID, Double> clickRate = new HashMap();
- public HashMap<UUID, Integer> clickCount = new HashMap();
- private static Date dt = new Date();
- private static SimpleDateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
- private static String time = df.format(dt);
- ConsoleCommandSender console = Bukkit.getConsoleSender();
- public void savePlayerData()
- {
- try
- {
- this.playercfg.save(this.playerdata);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- public static void log(Level level, String msg)
- {
- Bukkit.getLogger().log(level, time + msg);
- }
- public LogManager getLogManager()
- {
- return this.logManager;
- }
- public void onEnable()
- {
- this.playerdata = new File(getDataFolder(), "playerdata.yml");
- this.playercfg = YamlConfiguration.loadConfiguration(this.playerdata);
- this.config = getConfig();
- Commands clicker = new Commands(this);
- getCommand("aac-reload").setExecutor(clicker);
- Bukkit.getServer().getPluginManager().registerEvents(new Events(this), this);
- getRate();
- saveDefaultConfig();
- savePlayerData();
- Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[Talentoman]" + ChatColor.GREEN + " Online");
- Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[Talentoman]" + ChatColor.GREEN + " Autoclicker detection activated!");
- }
- public void getRate()
- {
- Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
- LinkedList<Double> ll = new LinkedList();
- double sum = 0.0D;
- double total = 0.0D;
- public void run() {
- for (Player p : Bukkit.getOnlinePlayers())
- {
- if (Main.this.clickCount.containsKey(p.getUniqueId())) {
- double count = ((Integer)Main.this.clickCount.get(p.getUniqueId())).intValue();
- if (count > Main.this.playercfg.getDouble("Clicks.Maximum." + p.getUniqueId())) {
- Main.this.playercfg.set("Clicks.Maximum." + p.getUniqueId(), Double.valueOf(count));
- Main.this.savePlayerData();
- }
- if (count > Main.this.config.getInt("ClickPerSecound-Limit")) {
- for (Player on : Bukkit.getOnlinePlayers()) {
- if (Permissions.NOTIFICATION.hasPerms(on)) {
- on.sendMessage(ChatColor.translateAlternateColorCodes('&', Main.this.config.getString("NotificationAtLimit").replace("%PLAYER%", p.getName()).replace("%CLICKS%", String.valueOf(count))));
- Main.this.getLogManager().log(String.format("[" + Main.time + "]" + " <" + p.getUniqueId() + "> " + "<" + p.getName() + "> " + " Has reached " + count + " clicks", new Object[0]));
- Main.this.getServer().dispatchCommand(Main.this.getServer().getConsoleSender(), ChatColor.translateAlternateColorCodes('&', Main.this.config.getString("Command").replace("%PLAYER%", p.getName()).replace("%CLICKS%", String.valueOf(count))));
- }
- if (Permissions.REPORT.hasPerms(on)) {
- p.sendMessage(ChatColor.translateAlternateColorCodes('&', Main.this.config.getString("StaffAlertMessage").replace("%PLAYER%", p.getName()).replace("%CLICKS%", String.valueOf(count))));
- }
- }
- }
- if (count > 0.0D) {
- this.ll.add(Double.valueOf(count));
- for (Iterator localIterator = this.ll.iterator(); localIterator.hasNext(); ) { double x = ((Double)localIterator.next()).doubleValue();
- x = count;
- this.total = (this.sum + x);
- }
- }
- this.total = 0.0D;
- try {
- this.ll.remove(); } catch (Exception localException) {
- }
- Main.this.clickCount.put(p.getUniqueId(), Integer.valueOf(0));
- }
- }
- }
- }
- , 0L, 20L);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement