@EventHandler public void onInteract(PlayerInteractEvent event) { Player player = event.getPlayer(); Action action = event.getAction(); ItemStack item = event.getItem(); FileConfiguration config = this.plugin.getConfig(); if (action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK) { if (config.getBoolean("cps." + player.getUniqueId() + ".enabled")) { int currentCounter = config.getInt("cps." + player.getUniqueId() + ".counter"); config.set("cps." + player.getUniqueId() + ".counter", currentCounter + 1); plugin.saveConfig(); } } if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) { if (config.getBoolean("cps." + player.getUniqueId() + ".enabled")) { int currentCounter = config.getInt("cps." + player.getUniqueId() + ".right_counter"); config.set("cps." + player.getUniqueId() + ".right_counter", currentCounter + 1); plugin.saveConfig(); } } } @EventHandler public void onEntityDamagedEntity(EntityDamageByEntityEvent event) { FileConfiguration config = this.plugin.getConfig(); if (event.getDamager() instanceof Player player) { if (config.getBoolean("cps." + player.getUniqueId() + ".enabled")) { int currentCounter = config.getInt("cps." + player.getUniqueId() + ".counter"); config.set("cps." + player.getUniqueId() + ".counter", currentCounter + 1); plugin.saveConfig(); } } } @EventHandler public void onPlaceBlock(BlockPlaceEvent event) { Player player = event.getPlayer(); FileConfiguration config = this.plugin.getConfig(); if (config.getBoolean("cps." + player.getUniqueId() + ".enabled")) { int currentCounter = config.getInt("cps." + player.getUniqueId() + ".right_counter"); config.set("cps." + player.getUniqueId() + ".right_counter", currentCounter + 1); plugin.saveConfig(); } }