evilcuriousyt
📎 1 file 2,578 chars
📄
pasted-code-1772569906416.txt
txt 175 lines
▶
🧭 Plugin Name:

NearTrackingCompass

🎯 Core Concept

Create a custom compass system that tracks the nearest non-protected player within a configurable radius.

The compass should:

Always point toward the nearest valid enemy player.

Display an ActionBar message:

Nearest player name

Distance

Count of additional enemy players nearby

Count of protected players nearby (shown in green)

📊 Example ActionBar Format

If 1 protected and 3 enemies nearby:

(1) Lykiaofficial is nearby! +2

Legend:

(1) → Green → Protected players count

Lykiaofficial → Closest enemy

+2 → Other enemy players nearby

If no players nearby:

No players nearby
🧭 Compass Behavior
Custom Item

Custom named compass:
"Near Tracking Compass"

Use PersistentDataContainer to identify it.

Functionality

Right-click toggles tracking ON/OFF.

When enabled:

Updates every 10 ticks.

Sets compass target to nearest valid player.

If no valid players:

Compass spins normally.

ActionBar shows "No players nearby"

⚔ Tracking Rules

Track only:

Survival or Adventure mode players

Alive players

Same world

Within configurable radius (default 100 blocks)

Exclude:

Self

Spectators

Protected players

🛡 Protected Players System

Each player can maintain their own protected list.

Commands:
/ntc protect 
/ntc unprotect 
/ntc list
/ntc give
/ntc reload
Protected Player Rules:

Cannot be tracked.

Not shown in compass targeting.

Count appears in green.

Player cannot deal damage to protected players (cancel EntityDamageByEntityEvent).

📁 Data Storage

Use:

YAML files per player (UUID based)
OR

Single protected-players.yml

Use UUID, NOT player names.

⚙ Config File (config.yml)
tracking-radius: 100
update-interval-ticks: 10
enable-bossbar: true
enable-glow-effect: false
play-sound-on-detect: true
📊 UI Features

Use:

ActionBar for live updates

Optional BossBar showing nearest enemy name

Green color for protected count

Red color for enemy alerts

🔊 Optional Extra Features

Glow effect applied to tracked player (only visible to tracker)

Sound when a new enemy enters radius

Cooldown between scans

Permission system:

ntc.use

ntc.admin

ntc.protect

🧠 Performance Requirements

DO NOT scan all players every tick unnecessarily.

Use BukkitRunnable async-safe logic where possible.

Efficient distance checking.

Handle player quit, death, world change safely.

Avoid memory leaks.

🏗 Required Classes Structure

Main class (extends JavaPlugin)

CompassManager

PlayerTrackerManager

ProtectedPlayerManager

CommandManager

ConfigManager

Listener classes
Kodari AI
KodariMar 3 at 8:34 pm 18,270 (v2)

I’ll create a comprehensive compass tracking system with protected player management.

NearTrackingCompass
A custom compass system that tracks the nearest non-protected players within a configurable radius. Features include togglable tracking with live ActionBar updates showing distance and nearby player counts, a protected player system preventing damage and tracking, and efficient performance with async-safe logic. Includes commands for managing protected lists, compass distribution, and full configuration control.

I’ll create a comprehensive compass tracking system with protected player management and FoliaLib support for optimal performance.

All files created! The Near Tracking Compass plugin is complete with:

  • Custom compass item with PersistentDataContainer identification

  • Togglable tracking with right-click functionality

  • ActionBar updates showing nearest player, distance, and counts (format: (protected_count) PlayerName is nearby! [distance] +enemies)

  • Protected player system with UUID-based storage, preventing tracking and damage

  • Efficient tracking using FoliaLib for Folia/Paper compatibility

  • Commands: /ntc protect/unprotect/list/give/reload

  • Performance optimized with configurable update intervals and proper cleanup

  • Sound effects on player detection with XSound

  • Full configuration for all messages, radius, intervals, and features

evilcuriousyt

add that normal player to can use /ntc compass and they get ntc compass

evilcuriousyt

add that normal player without op get compass to by /compass and add that op player can change radius ingame

Kodari AI
KodariMar 4 at 1:23 am 17,562 (v2)

I’ll add a /compass command for normal players to get the tracking compass and allow OP players to change the radius in-game.

Now I’ll create the new /compass command and add radius management for OP players.

Added /compass command for all players to get a tracking compass and /compass radius <number> for OP players to change the tracking radius in-game (10-1000 blocks).

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
manifest.kod
Code
15 991
src/main/java/com/neartracking/NearTrackingCompass.java
package com.neartracking;

import com.neartracking.command.CompassCommand;
import com.neartracking.command.NTCCommand;
import com.neartracking.listener.CompassListener;
import com.neartracking.listener.PlayerListener;
import com.neartracking.manager.CompassManager;
import com.neartracking.manager.ConfigManager;
import com.neartracking.manager.PlayerTrackerManager;
import com.neartracking.manager.ProtectedPlayerManager;
import com.neartracking.task.TrackingTask;
import com.tcoded.folialib.FoliaLib;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

@Getter
public class NearTrackingCompass extends JavaPlugin {
    private FoliaLib foliaLib;
    private ConfigManager configManager;
    private ProtectedPlayerManager protectedPlayerManager;
    private CompassManager compassManager;
    private PlayerTrackerManager playerTrackerManager;
    private TrackingTask trackingTask;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        
        this.foliaLib = new FoliaLib(this);
        this.configManager = new ConfigManager(this);
        this.protectedPlayerManager = new ProtectedPlayerManager(this);
        this.compassManager = new CompassManager(this);
        this.playerTrackerManager = new PlayerTrackerManager(this);
        
        this.protectedPlayerManager.loadAllProtectedPlayers();
        
        Bukkit.getPluginManager().registerEvents(new CompassListener(this), this);
        Bukkit.getPluginManager().registerEvents(new PlayerListener(this), this);
        
        getCommand("ntc").setExecutor(new NTCCommand(this));
        getCommand("compass").setExecutor(new CompassCommand(this));
        
        this.trackingTask = new TrackingTask(this);
        this.trackingTask.start();
        
        getLogger().info("NearTrackingCompass has been enabled!");
    }

    @Override
    public void onDisable() {
        if (this.trackingTask != null) {
            this.trackingTask.stop();
        }
        
        if (this.protectedPlayerManager != null) {
            this.protectedPlayerManager.saveAllProtectedPlayers();
        }
        
        if (this.foliaLib != null) {
            this.foliaLib.getScheduler().cancelAllTasks();
        }
        
        getLogger().info("NearTrackingCompass has been disabled!");
    }
}