imlunaa___

can you add this check inside inside sentinelalso make a system so we have to set different alert message per check in config.yml also make a option in config to disable or enable any check make command to reload all config and messages /sentinel reload (keep ml command as it is) make a command to toggle alerts

๐Ÿ“Ž 1 file 3,128 chars
๐Ÿ“„
pasted-code-1773741069614.txt
txt 109 lines
โ–ถ
package dev.afonso.galleryac.check.combat;

import dev.afonso.galleryac.GalleryAC;
import dev.afonso.galleryac.check.AbstractCheck;
import dev.afonso.galleryac.check.CheckType;
import dev.afonso.galleryac.data.PlayerData;
import org.bukkit.GameMode;
import org.bukkit.Material;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.inventory.ItemStack;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;

public class AutoFirework extends AbstractCheck implements Listener {

    private static final ConcurrentHashMap> rocketHistory =
            new ConcurrentHashMap<>();

    public AutoFirework(GalleryAC plugin, PlayerData playerData) {
        super(plugin, playerData, CheckType.AUTO_FIREWORK_A);

        plugin.getServer()
                .getPluginManager()
                .registerEvents(this, plugin);
    }

    @EventHandler
    public void onFireworkLaunch(ProjectileLaunchEvent event) {

        if (!(event.getEntity() instanceof Firework firework)) return;
        if (!(firework.getShooter() instanceof Player player)) return;

        if (!player.getUniqueId().equals(playerData.getUuid())) return;

        if (player.getGameMode() == GameMode.CREATIVE) return;
        if (!player.isGliding()) return;

        recordRocket(player);

        plugin.getServer().getScheduler().runTaskLater(
                plugin,
                () -> check(player),
                1L
        );
    }

    private void recordRocket(Player player) {

        long now = System.currentTimeMillis();

        Deque list =
                rocketHistory.computeIfAbsent(
                        player.getUniqueId(),
                        k -> new ArrayDeque<>()
                );

        list.addLast(now);

        while (!list.isEmpty()
                && now - list.peekFirst() > 1000) {
            list.removeFirst();
        }
    }

    private void check(Player player) {

        Deque list =
                rocketHistory.get(player.getUniqueId());

        if (list != null && list.size() >= 4) {
            decrease(0.25);
            return;
        }

        ItemStack main =
                player.getInventory().getItemInMainHand();

        ItemStack off =
                player.getInventory().getItemInOffHand();

        boolean holdingRocket =
                (main != null && main.getType() == Material.FIREWORK_ROCKET)
                        ||
                        (off != null && off.getType() == Material.FIREWORK_ROCKET);

        if (holdingRocket) {
            decrease(0.15);
            return;
        }

        fail(
                "Boost without rocket in hand",
                getBanVL(),
                500L
        );
    }

    @Override
    public void handle() {
        // Not packet based
    }
}
Kodari AI
KodariMar 17 at 9:52 am 15,584 (v2)

Iโ€™ll read the existing Sentinel files to understand the current structure, then add the AutoFirework check system with configurable alerts.

Iโ€™ll add the AutoFirework check system with configurable per-check alerts, enable/disable options, and new commands.

Done! Iโ€™ve added a complete check system to Sentinel with the following features:

New Features:

  • โœ… AutoFirework check integrated (detects using firework rockets without holding them)

  • โœ… Per-check configuration (enable/disable individually)

  • โœ… Per-check alert messages with placeholders (%player%, %check%, %vl%, %info%)

  • โœ… /sentinel reload - Reloads all configuration

  • โœ… /sentinel alerts - Toggle personal alerts on/off

  • โœ… VL (violation level) system with decay

  • โœ… Configurable commands per check with VL thresholds

New Commands:

  • /sentinel - Shows help menu

  • /sentinel reload - Reloads config (requires sentinel.reload)

  • /sentinel alerts - Toggles alerts (requires sentinel.alerts)

  • /sentinel ml ... - ML commands (unchanged)

Config Structure: Each check has its own section with full customization including alerts, permissions, VL thresholds, and commands to execute.

Kodari can make mistakes. Review important code before using.
Files
src
dependency-reduced-pom.xml
pom.xml
Code
21 1,317
src/main/java/com/rise/sentinel/Sentinel.java
package com.rise.sentinel;

import com.rise.sentinel.check.CheckManager;
import com.rise.sentinel.command.SentinelCommand;
import com.rise.sentinel.command.SentinelTabComplete;
import com.rise.sentinel.ml.*;
import org.bukkit.plugin.java.JavaPlugin;

public class Sentinel extends JavaPlugin {

    private static Sentinel instance;
    private MLManager mlManager;
    private CheckManager checkManager;

    public static Sentinel getInstance() {
        return instance;
    }

    public MLManager getMLManager() {
        return mlManager;
    }

    public CheckManager getCheckManager() {
        return checkManager;
    }

    @Override
    public void onEnable() {
        instance = this;

        saveDefaultConfig();

        DatasetManager.loadDatasets();

        checkManager = new CheckManager(this);
        mlManager = new MLManager(this);

        getServer().getPluginManager().registerEvents(new RotationTracker(), this);
        getServer().getPluginManager().registerEvents(new MLListener(mlManager), this);

        getCommand("sentinel").setExecutor(new SentinelCommand(this));
        getCommand("sentinel").setTabCompleter(new SentinelTabComplete());

        getLogger().info("Sentinel enabled.");
    }

    public void reloadAll() {
        reloadConfig();
        getLogger().info("Configuration reloaded.");
    }
}