zyxfpro

to jest moj skript minecraft i zrob mi plugin minecraft o nazwie rtp i ten plugin ma miec 1 do 1 takie same wiadomosci i ma dzialac prawie tak samo plugin ma miec config

📎 1 file 3,101 chars
📄
pasted-code-1791753997404.txt
txt 68 lines
▶
options:
    min-x: -3000
    max-x: 3000
    min-z: -3000
    max-z: 3000
    swiat: world
    
    # --- Konfiguracja wiadomości i kolorów ---
    prefix: [<#00D2FF>!]
    msg-start: Rozpoczynanie teleportacji...
    msg-success: Pomyślnie przeteleportowano w losowe miejsce!
    msg-cancelled: Teleportacja została anulowana z powodu poruszenia się!
    
    title-main: "ᴛᴇʟᴇᴘᴏʀᴛᴀᴄᴊᴀ"
    title-success-sub: "Pomyślnie przeteleportowano!"
    title-cancelled-sub: "Teleportacja anulowana!"

function getRandomLoc(xmin: integer=-3000, xmax: integer=3000, zmin: integer=-3000, zmax: integer=3000, world: text="world") :: location:
    while {_return} is not set:
        set {_x} to random integer between {_xmin} and {_xmax}
        set {_z} to random integer between {_zmin} and {_zmax}
        set {_loc} to highest solid block at location at {_x}, 0, {_z} in world ({_world} parsed as world)
        if block at {_loc} != lava or water:
            add 1 to y-loc of {_loc}
            if (block at {_loc}) and (block above block at {_loc}) != lava:
                set {_return} to {_loc}
    return {_return}

command /rtp:
    trigger:
        send "{@prefix} {@msg-start}" to player
        set {_startLoc} to location of player
        
        # --- Odliczanie 3 sekund na ekranie z weryfikacją ruchu ---
        loop 3 times:
            set {_secondsLeft} to 4 - loop-value
            
            # Sprawdzenie czy gracz się poruszył (ignorując rotację głowy)
            if distance between location of player and {_startLoc} > 0.1:
                send "{@prefix} {@msg-cancelled}" to player
                send title {@title-main} with subtitle {@title-cancelled-sub} to player for 2 seconds
                play sound "entity.villager.no" to player
                stop
                
            send title {@title-main} with subtitle "Zostaniesz przeteleportowany za <#00D2FF>%{_secondsLeft}%s" to player for 1.5 seconds
            play sound "ui.button.click" to player
            wait 1 second

        # Ostateczna weryfikacja pozycji przed samą teleportacją
        if distance between location of player and {_startLoc} > 0.1:
            send "{@prefix} {@msg-cancelled}" to player
            send title {@title-main} with subtitle {@title-cancelled-sub} to player for 2 seconds
            play sound "entity.villager.no" to player
            stop

        # --- Teleportacja ---
        set {_loc} to getRandomLoc({@min-x}, {@max-x}, {@min-z}, {@max-z}, "{@swiat}")
        teleport player to {_loc}
        
        # --- Ekran po przeteleportowaniu ---
        send "{@prefix} {@msg-success}" to player
        send title {@title-main} with subtitle {@title-success-sub} to player for 3 seconds
        play sound "entity.enderman.teleport" to player

on rightclick:
    if event-block is stone button:
        if block behind event-block is sponge:
            execute player command "/rtp"
Kodari AI
KodariOct 11 at 9:30 pm 1
RandomTeleportPlugin
A Minecraft Spigot plugin providing a /rtp command that teleports players to a random safe location within configurable world bounds. Features a 3-second countdown with movement cancellation detection, animated titles with gradient styling, sound effects, and full configurable messages, coordinates, and world settings. Also supports a right-click stone button on sponge trigger for RTP activation. All messages, titles, sounds, and coordinates are configurable in a YAML config file, mirroring the original Skript functionality exactly.
  1. Utworzę konfigurację z domyślnymi wiadomościami, kolorami, tytułami i granicami losowania z Twojego skryptu.

  2. Dodam komendę /rtp z odliczaniem, anulowaniem po ruchu i bezpiecznym losowaniem miejsca.

  3. Dodam obsługę kamiennego przycisku nad gąbką oraz pliki startowe pluginu Paper.

Utworzyłem plugin rtp. Komenda /rtp odlicza 3 sekundy i anuluje teleportację, jeśli gracz się poruszy. Losuje bezpieczne miejsce w skonfigurowanym świecie i zakresie, a kamienny przycisk przy gąbce uruchamia tę samą teleportację.

W config.yml możesz zmienić granice, świat, wiadomości, tytuły i kolory. сохраниłem domyślne польские сообщения ze skryptu.

zyxfpro

usun to ze jak jest guzik kamienny na gąbce to sie robi rtp

Kodari AI
KodariOct 11 at 9:32 pm 1

Usunąłem aktywowanie /rtp przez kamienny przycisk przy gąbce. Teleportację można teraz uruchomić tylko komendą /rtp.

zyxfpro

a nazwiesz to zyxfcodertp

Kodari AI
KodariOct 11 at 9:32 pm 1

Nazwa pluginu to teraz zyxfcodertp; komenda nadal działa jako /rtp.

zyxfpro

main: com.kodari.rtp.RtpPlugin ale czemu w plugin.yml jest napis kodari a nie zyxfrtp

Kodari AI
KodariOct 11 at 9:37 pm 1

main: com.kodari.rtp.RtpPlugin wskazuje na pakiet i klasę Java, w której znajduje się plugin — nie jest to jego nazwa. Nazwa pluginu widoczna w plugin.yml jest w polu name: i została ustawiona na zyxfcodertp.

kodari zostało w ścieżce klasy, bo tam znajduje się obecny plik Java. Nie trzeba tego zmieniać, żeby plugin nazywał się zyxfcodertp.

zyxfpro

to to zmien bo wole zeby nazywal sie zyxfcodertp

Kodari AI
KodariOct 11 at 9:38 pm 1

Zmieniam pakiet Java na com.zyxfcodertp.rtp i aktualizuję main w plugin.yml; nazwa pluginu pozostaje zyxfcodertp.

Zmienione: nazwa pluginu to zyxfcodertp, a główna klasa jest teraz pod adresem com.zyxfcodertp.rtp.RtpPlugin.

zyxfpro

moze zamiest com pl

Kodari AI
KodariOct 11 at 9:39 pm 1

Tak — zmieniam pakiet z com.zyxfcodertp.rtp na pl.zyxfcodertp.rtp, a wpis main w plugin.yml będzie wskazywał nową klasę.

zyxfpro

dodalem plugin na moj serwer 1.21.4 paper i nie dziala

Kodari AI
KodariOct 11 at 9:46 pm 1

Poprawiłem main w plugin.yml. Wskazywał na com.zyxfcodertp.rtp.RtpPlugin, ale klasa znajduje się w pakiecie pl.zyxfcodertp.rtp, więc Paper nie mógł jej załadować. Teraz wpis pasuje do faktycznej ścieżki klasy. Zbuduj plugin ponownie i podmień JAR na serwerze.

zyxfpro

i zrob mi skript na zyxfcodetpa i ma być komenda /tpa [nick gracza do ktorego chcesz wyslac prosbe o teleportacje] /tpdeny /tpaccept i /tpaccept * ta komenda ma akceptowac wszystkie prosby o teleportcaje na raz w configu niech mozna ustawic kiedy prosba o teleportacje ma wygasnąć uzyj napisy takie same jak z rtp podstawowo teleportacja ma trwac 5 sekund oczywiscie po poruszeniu sie teleportacja ma sie anulowac dodaj jakies opcje itp

Kodari AI
KodariOct 11 at 10:01 pm 1
  1. Ustawię nazwę pluginu na zyxfcodetpa i dodam konfigurację czasu wygaśnięcia, 5-sekundowego odliczania oraz wiadomości.

  2. Dodam /tpa, /tpaccept, /tpaccept * i /tpdeny, z anulowaniem teleportacji po ruchu.

Dodane komendy TPA do pluginu zyxfcodetpa:

  • /tpa <nick> wysyła prośbę o teleportację.

  • /tpaccept akceptuje ostatnią prośbę, a /tpaccept * akceptuje wszystkie.

  • /tpdeny odrzuca ostatnią prośbę.

Domyślnie prośba wygasa po 60 sekundach, a teleportacja trwa 5 sekund. Jeśli teleportujący się gracz się poruszy, zostanie anulowana. Czas wygaśnięcia i odliczanie zmienisz w sekcji tpa w config.yml; domyślne wiadomości i tytuły korzystają z tych samych ustawień co /rtp. /rtp nadal działa.

zyxfpro

i nazwij plugin na tpa ZyxfCode-Tpa i zablokuj teleportacje do samego siebie jezeli tego nie zablokowales i niech w configu bedzie pocja gdzie ma pokazywac ze ktos wyslal ci tpa ba byc opcja actionbar bossbar chat title i mozliwosc edycji prawie wszystkiego w configu

Kodari AI
KodariOct 14 at 10:30 am 1
  1. Zmieniam nazwę pluginu na ZyxfCode-Tpa i blokuję wysyłanie prośby do samego siebie.

  2. Dodaję konfigurowalny sposób powiadamiania o TPA (actionbar, bossbar, chat, title) oraz ustawienia wiadomości i czasu.

Nazwa pluginu w plugin.yml to teraz ZyxfCode-Tpa. Blokada wysłania /tpa do samego siebie już była w kodzie — zostawiłem ją.

Sposób wyświetlania otrzymanej prośby ustawisz w config.yml pod tpa.notification.mode: chat, actionbar, bossbar albo title. Możesz też zmieniać czas wyświetlania, tytuł oraz kolor i styl bossbara. Wiadomości, dźwięki, czas wygaśnięcia prośby i opóźnienia teleportacji również są konfigurowalne. Nowe ustawienia zostaną dopisane do istniejącego configu przy uruchomieniu pluginu.

zyxfpro

ale w zyxf tpa nie ma byc /rtp zyxf tpa to kompletnie inny plugin i daj komende /zyxftpa reload zeby przeladowac config i dodaj folder messages.yml

Kodari AI
KodariOct 14 at 10:41 am 2
  1. Usunę całą funkcjonalność /rtp, zostawiając plugin wyłącznie do TPA.

  2. Dodam /zyxftpa reload do przeładowania konfiguracji oraz osobny messages.yml na teksty pluginu.

Usunąłem /rtp i losową teleportację — plugin ZyxfCode-Tpa obsługuje teraz tylko TPA. Dodałem /zyxftpa reload, które przeładowuje config.yml i messages.yml. Komenda wymaga uprawnienia zyxfcodetpa.reload (domyślnie dla operatorów).

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
5 484
src/main/java/pl/zyxfcodertp/rtp/RtpPlugin.java
package pl.zyxfcodertp.rtp;

import com.cryptomorin.xseries.XSound;
import net.kyori.adventure.bossbar.BossBar;
import net.kyori.adventure.title.Title;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;

import java.io.File;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.UUID;

public final class RtpPlugin extends JavaPlugin implements CommandExecutor {
    private final MiniMessage miniMessage = MiniMessage.miniMessage();
    private final Map<UUID, BukkitTask> activeTeleports = new HashMap<>();
    private final Map<UUID, UUID> outgoingRequests = new HashMap<>();
    private final Map<UUID, LinkedHashMap<UUID, Long>> incomingRequests = new HashMap<>();
    private final Map<UUID, BukkitTask> requestExpiryTasks = new HashMap<>();
    private final Map<UUID, BossBar> activeNotificationBossBars = new HashMap<>();
    private final Map<UUID, BukkitTask> bossBarHideTasks = new HashMap<>();
    private File messagesFile;
    private YamlConfiguration messages;

    @Override
    public void onEnable() {
        saveDefaultConfig();
        getConfig().options().copyDefaults(true);
        saveConfig();
        saveResource("messages.yml", false);
        messagesFile = new File(getDataFolder(), "messages.yml");
        reloadMessages();
        getCommand("zyxftpa").setExecutor(this);
        getCommand("tpa").setExecutor(this);
        getCommand("tpaccept").setExecutor(this);
        getCommand("tpdeny").setExecutor(this);
    }

    @Override
    public void onDisable() {
        activeTeleports.values().forEach(BukkitTask::cancel);
        activeTeleports.clear();
        requestExpiryTasks.values().forEach(BukkitTask::cancel);
        requestExpiryTasks.clear();
        bossBarHideTasks.values().forEach(BukkitTask::cancel);
        bossBarHideTasks.clear();
        activeNotificationBossBars.forEach((playerId, bossBar) -> {
            Player player = Bukkit.getPlayer(playerId);
            if (player != null) {
                player.hideBossBar(bossBar);
            }
        });
        activeNotificationBossBars.clear();
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (command.getName().equalsIgnoreCase("zyxftpa")) {
            if (args.length != 1 || !args[0].equalsIgnoreCase("reload")) {
                sendMessage(sender, messages.getString("commands.reload-usage", "<red>Użycie: /zyxftpa reload"));
                return true;
            }
            if (!sender.hasPermission("zyxfcodetpa.reload")) {
                sendMessage(sender, messages.getString("commands.no-permission", "<red>Nie masz uprawnień."));
                return true;
            }
            reloadConfig();
            reloadMessages();
            sendMessage(sender, messages.getString("commands.reload-success", "<green>Przeładowano konfigurację i wiadomości."));
            return true;
        }

        if (!(sender instanceof Player player)) {
            sendMessage(sender, messages.getString("msg-player-only", "<red>Tej komendy może użyć tylko gracz."));
            return true;
        }

        switch (command.getName().toLowerCase(Locale.ROOT)) {
            case "tpa" -> sendTeleportRequest(player, args);
            case "tpaccept" -> acceptTeleportRequest(player, args);
            case "tpdeny" -> denyTeleportRequest(player);
            default -> { }
        }
        return true;
    }

    private void reloadMessages() {
        messages = YamlConfiguration.loadConfiguration(messagesFile);
    }

    private void sendTeleportRequest(Player sender, String[] args) {
        if (args.length != 1) {
            sendMessage(sender, messages.getString("tpa.msg-usage", ""));
            return;
        }

        Player target = Bukkit.getPlayerExact(args[0]);
        if (target == null) {
            sendMessage(sender, messages.getString("tpa.msg-player-not-found", ""));
            return;
        }
        if (target.equals(sender)) {
            sendMessage(sender, messages.getString("tpa.msg-self-request", ""));
            return;
        }
        if (outgoingRequests.containsKey(sender.getUniqueId())) {
            sendMessage(sender, messages.getString("tpa.msg-request-already-sent", ""));
            return;
        }

        UUID senderId = sender.getUniqueId();
        UUID targetId = target.getUniqueId();
        long expirySeconds = Math.max(1L, getConfig().getLong("tpa.request-expiry-seconds", 60L));
        outgoingRequests.put(senderId, targetId);
        incomingRequests.computeIfAbsent(targetId, ignored -> new LinkedHashMap<>())
                .put(senderId, System.currentTimeMillis() + expirySeconds * 1000L);
        requestExpiryTasks.put(senderId, Bukkit.getScheduler().runTaskLater(this,
                () -> expireRequest(senderId, targetId), expirySeconds * 20L));

        sendMessage(sender, messages.getString("tpa.msg-request-sent", "")
                .replace("%player%", target.getName()));
        String receivedMessage = messages.getString("tpa.msg-request-received", "")
                .replace("%player%", sender.getName());
        showRequestNotification(target, receivedMessage);
    }

    private void acceptTeleportRequest(Player target, String[] args) {
        if (args.length > 1 || (args.length == 1 && !args[0].equals("*"))) {
            sendMessage(target, messages.getString("tpa.msg-accept-usage", ""));
            return;
        }

        LinkedHashMap<UUID, Long> requests = incomingRequests.get(target.getUniqueId());
        if (requests == null || requests.isEmpty()) {
            sendMessage(target, messages.getString("tpa.msg-no-requests", ""));
            return;
        }

        if (args.length == 1) {
            List<UUID> requesters = new ArrayList<>(requests.keySet());
            for (UUID requesterId : requesters) {
                acceptRequest(target, requesterId);
            }
            return;
        }

        UUID requesterId = new ArrayList<>(requests.keySet()).get(requests.size() - 1);
        acceptRequest(target, requesterId);
    }

    private void acceptRequest(Player target, UUID requesterId) {
        UUID targetId = target.getUniqueId();
        if (activeTeleports.containsKey(requesterId)) {
            Player requester = Bukkit.getPlayer(requesterId);
            if (requester != null) {
                sendMessage(requester, messages.getString("tpa.msg-teleport-already-active", ""));
            }
            return;
        }

        Player requester = Bukkit.getPlayer(requesterId);
        removeRequest(requesterId, targetId);
        if (requester == null) {
            sendMessage(target, messages.getString("tpa.msg-player-not-online", ""));
            return;
        }

        sendMessage(target, messages.getString("tpa.msg-request-accepted-target", "")
                .replace("%player%", requester.getName()));
        sendMessage(requester, messages.getString("tpa.msg-request-accepted-sender", "")
                .replace("%player%", target.getName()));
        startPlayerTeleport(requester, target);
    }

    private void denyTeleportRequest(Player target) {
        LinkedHashMap<UUID, Long> requests = incomingRequests.get(target.getUniqueId());
        if (requests == null || requests.isEmpty()) {
            sendMessage(target, messages.getString("tpa.msg-no-requests", ""));
            return;
        }

        List<UUID> requesters = new ArrayList<>(requests.keySet());
        UUID requesterId = requesters.get(requesters.size() - 1);
        Player requester = Bukkit.getPlayer(requesterId);
        removeRequest(requesterId, target.getUniqueId());
        sendMessage(target, messages.getString("tpa.msg-request-denied-target", "")
                .replace("%player%", requester == null ? "" : requester.getName()));