Kaan

Convert this into a JAR file plugin that I can use on my server.

📎 1 file 5,796 chars
📄
Kontrol.sk
sk 154 lines
▶
options:
    p: &6[&bHavensmp&6] &r
    perm: haven.yetkili

# --- OYUNCU HAREKET VE KOMUT ENGELLEYİCİLERİ ---

on player move:
    {kontrolde::%player%} is true:
        cancel event

on command:
    {kontrolde::%player%} is true:
        cancel event
        send "{@p} &cKontroldeyken komut kullanamazsın! Sadece chate yazabilirsin." to player

# --- KONTROLDEN KAÇMA (BAN) SİSTEMİ ---

on quit:
    {kontrolde::%player%} is true:
        delete {kontrolde::%player%}
        delete {kontchat::%player%}

        if {kontyetkili::%player%} is set:
            set {_yetkiliadi} to {kontyetkili::%player%}
            if player named {_yetkiliadi} is online:
                if {eskikonum.yetkili::%player%} is set:
                    teleport (player named {_yetkiliadi}) to {eskikonum.yetkili::%player%}
                    send "{@p} &7%player% kontrolden kaçtığı için eski konumunuza döndürüldünüz." to (player named {_yetkiliadi})
            delete {kontyetkili::%player%}

        delete {eskikonum.oyuncu::%player%}
        delete {eskikonum.yetkili::%player%}

        # Kendi Türkçe Ban Komutumuz Çalışır
        execute console command "ban %player% 7g Kontrolden Kacma!"
        broadcast "{@p} &c%player% &7kontrolden kaçtığı için &47 gün &7yasaklandı!"

# --- ÖZEL KONT CHAT SİSTEMİ ---

on chat:
    {kontrolde::%player%} is true:
        cancel event
        loop all players:
            if loop-player has permission "{@perm}":
                send "&4[KONT CHAT] &e%player%: &f%message%" to loop-player
        send "&4[KONT CHAT] &e%player%: &f%message%" to player
        stop

    {kontchat::%player%} is true:
        cancel event
        loop all players:
            if loop-player has permission "{@perm}":
                send "&4[KONT CHAT] &a[Yetkili] %player%: &f%message%" to loop-player
            else if {kontrolde::%loop-player%} is true:
                send "&4[KONT CHAT] &a[Yetkili] %player%: &f%message%" to loop-player

# --- KOMUTLAR ---

command /kont [] []:
    permission: {@perm}
    permission message: {@p} &cBu komutu kullanmak için yetkiniz yok.
    trigger:
        if arg-1 is not set:
            send "{@p} &eKullanım rehberi:"
            send "&7/kontal  &e- Oyuncuyu dondurur ve kontrole alır."
            send "&7/kontçıkar  &e- Oyuncuyu kontrol modundan çıkarır."
            send "&7/kontset1 &e- Bulunduğun yeri Kontrol Noktası 1 yapar."
            send "&7/kontset2 &e- Bulunduğun yeri Kontrol Noktası 2 yapar."
            send "&7/kontchat &e- Yetkililer için kont chatini açar/kapatır."
            stop

command /kontset1:
    permission: {@perm}
    trigger:
        set {kont.loc1} to player's location
        send "{@p} &aKontrol Noktası 1 başarıyla ayarlandı!" to player

command /kontset2:
    permission: {@perm}
    trigger:
        set {kont.loc2} to player's location
        send "{@p} &aKontrol Noktası 2 başarıyla ayarlandı!" to player

command /kontal []:
    permission: {@perm}
    trigger:
        if arg-1 is not set:
            send "{@p} &cLütfen bir oyuncu adı girin. &7(/kontal oyuncu)" to player
            stop
        if {kontrolde::%arg-1%} is true:
            send "{@p} &cBu oyuncu zaten kontrolde!" to player
            stop
        
        if {kont.loc1} is not set:
            send "{@p} &cÖnce /kontset1 ile kontrol noktasını ayarlamalısınız!" to player
            stop

        set {kontrolde::%arg-1%} to true
        set {eskikonum.oyuncu::%arg-1%} to arg-1's location
        set {eskikonum.yetkili::%arg-1%} to player's location
        set {kontyetkili::%arg-1%} to player's name
        teleport arg-1 to {kont.loc1}
        if {kont.loc2} is set:
            teleport player to {kont.loc2}

        send "{@p} &a%arg-1% &7isimli oyuncu başarıyla kontrole alındı ve donduruldu!" to player
        
        send " " to arg-1
        send "&c&l=== HAVEN KONTROL ===" to arg-1
        send "&eHile şüphesiyle kontrole alındınız!" to arg-1
        send "&eHareket edemez ve komut kullanamazsınız." to arg-1
        send "&bOyundan çıkarsanız otomatik olarak &47 GÜN &bbanlanacaksınız!" to arg-1
        send "&aLütfen sadece chati kullanarak yetkili ile konuşun." to arg-1
        send "&c&l==========================" to arg-1
        send " " to arg-1

command /kontçıkar []:
    permission: {@perm}
    trigger:
        if arg-1 is not set:
            send "{@p} &cLütfen bir oyuncu adı girin. &7(/kontçıkar oyuncu)" to player
            stop
        if {kontrolde::%arg-1%} is not set:
            send "{@p} &cBu oyuncu zaten kontrolde değil." to player
            stop
        
        delete {kontrolde::%arg-1%}

        if {eskikonum.oyuncu::%arg-1%} is set:
            teleport arg-1 to {eskikonum.oyuncu::%arg-1%}
            delete {eskikonum.oyuncu::%arg-1%}

        if {kontyetkili::%arg-1%} is set:
            set {_yetkiliadi} to {kontyetkili::%arg-1%}
            if player named {_yetkiliadi} is online:
                if {eskikonum.yetkili::%arg-1%} is set:
                    teleport (player named {_yetkiliadi}) to {eskikonum.yetkili::%arg-1%}
            delete {kontyetkili::%arg-1%}
        delete {eskikonum.yetkili::%arg-1%}

        send "{@p} &a%arg-1% &7kontrolden çıkarıldı, artık hareket edebilir." to player
        send "{@p} &aKontrolünüz bitmiştir. Temizsiniz, iyi oyunlar!" to arg-1

command /kontchat:
    permission: {@perm}
    trigger:
        if {kontchat::%player%} is not set:
            set {kontchat::%player%} to true
            send "{@p} &aKont Chat modu aktif! Yazdıklarınızı sadece kontroldeki oyuncu ve yetkililer görecek." to player
        else:
            delete {kontchat::%player%}
            send "{@p} &cKont Chat modu kapatıldı. Normal chate döndünüz." to player

Kodari AI
KodariSep 26 at 11:21 pm 1
HavenControlSystem
Anti-cheat staff control plugin that freezes suspected players in place, blocks their movement and commands, and enables private staff chat. Staff can set two control points, teleport suspects to a designated location, and monitor them via a dedicated chat channel. If a controlled player disconnects, they are automatically banned for 7 days and staff are returned to their original positions. Includes commands for starting/ending control sessions, setting control locations, and toggling staff chat mode.
  1. Set up a Gradle project targeting Paper/Spigot with the required plugin metadata.

  2. Port the freeze, inspection teleport, staff chat, and quit-ban behavior into the plugin.

  3. Add persistent inspection locations and register the Skript commands, including /kontçıkar.

Created the Gradle plugin project with the inspection freeze and teleport flow, staff-only Kont Chat, and the configured 7-day quit-ban command. It includes /kont, /kontset1, /kontset2, /kontal, /kontçıkar (also /kontcikar), and /kontchat.

Build with gradle build; the JAR will be at build/libs/HavenKontrol-1.0.0.jar. The default quit-ban command expects a server ban plugin that supports ban <player> 7g ....

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
5 344
src/main/java/com/havensmp/kontrol/KontrolPlugin.java
package com.havensmp.kontrol;

import java.util.ArrayList;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;

public final class KontrolPlugin extends JavaPlugin implements Listener, CommandExecutor {
    private static final String PERMISSION = "haven.yetkili";
    private final Map<UUID, InspectionSession> inspections = new ConcurrentHashMap<>();
    private final Set<UUID> staffChat = ConcurrentHashMap.newKeySet();
    private final Set<UUID> pluginTeleports = ConcurrentHashMap.newKeySet();

    @Override
    public void onEnable() {
        saveDefaultConfig();
        getServer().getPluginManager().registerEvents(this, this);
        for (String name : new String[]{"kont", "kontset1", "kontset2", "kontal", "kontçıkar", "kontchat"}) {
            PluginCommand command = getCommand(name);
            if (command != null) {
                command.setExecutor(this);
            }
        }
    }

    @Override
    public void onDisable() {
        for (Map.Entry<UUID, InspectionSession> entry : new ArrayList<>(inspections.entrySet())) {
            Player target = Bukkit.getPlayer(entry.getKey());
            if (target != null && target.isOnline()) {
                teleport(target, entry.getValue().playerLocation);
            }
        }
        inspections.clear();
        staffChat.clear();
    }

    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    public void onPlayerMove(PlayerMoveEvent event) {
        if (inspections.containsKey(event.getPlayer().getUniqueId())
                && !pluginTeleports.contains(event.getPlayer().getUniqueId())
                && event.getTo() != null
                && (event.getFrom().getX() != event.getTo().getX()
                || event.getFrom().getY() != event.getTo().getY()
                || event.getFrom().getZ() != event.getTo().getZ())) {
            event.setTo(event.getFrom());
        }
    }

    @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
    public void onPlayerCommand(PlayerCommandPreprocessEvent event) {
        if (inspections.containsKey(event.getPlayer().getUniqueId())) {
            event.setCancelled(true);
            event.getPlayer().sendMessage(message("&cKontroldeyken komut kullanamazsın! Sadece chate yazabilirsin."));
        }
    }

    @EventHandler(priority = EventPriority.HIGHEST)
    public void onPlayerChat(AsyncPlayerChatEvent event) {
        UUID playerId = event.getPlayer().getUniqueId();
        boolean beingInspected = inspections.containsKey(playerId);
        boolean usingStaffChat = staffChat.contains(playerId);
        if (!beingInspected && !usingStaffChat) {
            return;
        }

        event.setCancelled(true);
        String playerName = event.getPlayer().getName();
        String text = event.getMessage();
        Bukkit.getScheduler().runTask(this, () -> {
            if (beingInspected) {
                String chatLine = color("&4[KONT CHAT] &e" + playerName + ": &f" + text);
                for (Player online : Bukkit.getOnlinePlayers()) {
                    if (online.hasPermission(PERMISSION)) {
                        online.sendMessage(chatLine);
                    }
                }
                Player sender = Bukkit.getPlayer(playerId);
                if (sender != null && sender.isOnline() && !sender.hasPermission(PERMISSION)) {
                    sender.sendMessage(chatLine);
                }
            } else {
                String chatLine = color("&4[KONT CHAT] &a[Yetkili] " + playerName + ": &f" + text);
                for (Player online : Bukkit.getOnlinePlayers()) {
                    if (online.hasPermission(PERMISSION) || inspections.containsKey(online.getUniqueId())) {
                        online.sendMessage(chatLine);
                    }
                }
            }
        });
    }

    @EventHandler
    public void onPlayerQuit(PlayerQuitEvent event) {
        Player player = event.getPlayer();
        InspectionSession session = inspections.remove(player.getUniqueId());
        if (session == null) {
            return;
        }

        Player staff = Bukkit.getPlayer(session.staffId);
        if (staff != null && staff.isOnline()) {
            teleport(staff, session.staffLocation);
            staff.sendMessage(message("&7" + player.getName() + " kontrolden kaçtığı için eski konumunuza döndürüldünüz."));
        }

        String banCommand = getConfig().getString("quit-ban-command", "ban {player} 7g Kontrolden Kacma!")
                .replace("{player}", player.getName());
        Bukkit.dispatchCommand(Bukkit.getConsoleSender(), banCommand);
        Bukkit.broadcastMessage(message("&c" + player.getName() + " &7kontrolden kaçtığı için &47 gün &7yasaklandı!"));
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player player)) {
            sender.sendMessage("Bu komut sadece oyuncular tarafından kullanılabilir.");
            return true;
        }
        if (!player.hasPermission(PERMISSION)) {
            player.sendMessage(message("&cBu komutu kullanmak için yetkiniz yok."));
            return true;
        }

        switch (command.getName().toLowerCase(java.util.Locale.ROOT)) {
            case "kont" -> sendHelp(player);
            case "kontset1" -> setControlPoint(player, "locations.point-1", "Kontrol Noktası 1");
            case "kontset2" -> setControlPoint(player, "locations.point-2", "Kontrol Noktası 2");
            case "kontal" -> startInspection(player, args);
            case "kontçıkar" -> endInspection(player, args);
            case "kontchat" -> toggleStaffChat(player);
            default -> {
                return false;
            }
        }
        return true;
    }

    private void sendHelp(Player player) {
        player.sendMessage(message("&eKullanım rehberi:"));
        player.sendMessage(color("&7/kontal <oyuncu> &e- Oyuncuyu dondurur ve kontrole alır."));
        player.sendMessage(color("&7/kontçıkar <oyuncu> &e- Oyuncuyu kontrol modundan çıkarır."));
        player.sendMessage(color("&7/kontset1 &e- Bulunduğun yeri Kontrol Noktası 1 yapar."));
        player.sendMessage(color("&7/kontset2 &e- Bulunduğun yeri Kontrol Noktası 2 yapar."));
        player.sendMessage(color("&7/kontchat &e- Yetkililer için kont chatini açar/kapatır."));
    }

    private void setControlPoint(Player player, String path, String pointName) {
        getConfig().set(path, player.getLocation());
        saveConfig();
        player.sendMessage(message("&a" + pointName + " başarıyla ayarlandı!"));
    }

    private void startInspection(Player staff, String[] args) {
        if (args.length == 0) {
            staff.sendMessage(message("&cLütfen bir oyuncu adı girin. &7(/kontal oyuncu)"));
            return;
        }

        Player target = Bukkit.getPlayerExact(args[0]);
        if (target == null) {
            staff.sendMessage(message("&cBu oyuncu çevrimiçi değil."));
            return;
        }
        if (inspections.containsKey(target.getUniqueId())) {
            staff.sendMessage(message("&cBu oyuncu zaten kontrolde!"));
            return;
        }

        Location point1 = getConfig().getLocation("locations.point-1");
        if (point1 == null || point1.getWorld() == null) {
            staff.sendMessage(message("&cÖnce /kontset1 ile kontrol noktasını ayarlamalısınız!"));
            return;
        }

        Location point2 = getConfig().getLocation("locations.point-2");
        inspections.put(target.getUniqueId(), new InspectionSession(
                target.getLocation().clone(), staff.getUniqueId(), staff.getLocation().clone()));
        teleport(target, point1);
        if (point2 != null && point2.getWorld() != null) {
            teleport(staff, point2);
        }

        staff.sendMessage(message("&a" + target.getName() + " &7isimli oyuncu başarıyla kontrole alındı ve donduruldu!"));