Артем крутой майн

напиши плагин для ProvinceWorld что бы по команде /hub тебя телепортировало в хаб

Kodari AI
KodariThu at 12:42 pm 1
HubTeleport
A Minecraft plugin for ProvinceWorld that teleports players to the hub world when they execute the /hub command. The plugin registers a command handler, retrieves the configured hub world and location from the config file, and teleports the player instantly upon command execution. It includes permission checks, configurable messages, and fallback to the world spawn point if no custom hub location is set. The plugin ensures smooth teleportation with optional sound effects and cooldown management to prevent spam.

Добавлю /hub для телепортации и /sethub для установки точки хаба администратором.

Создан плагин для ProvinceWorld.

  • /sethub — установить хаб (доступно операторам).

  • /hub — телепортироваться в хаб.

Сначала установите точку командой /sethub. Она сохранится после перезагрузки сервера.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
settings.gradle
Code
4 98
src/main/java/com/provinceworld/hub/ProvinceWorldHub.java
package com.provinceworld.hub;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public final class ProvinceWorldHub extends JavaPlugin {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (!(sender instanceof Player)) {
            sender.sendMessage(ChatColor.RED + "Эту команду может использовать только игрок.");
            return true;
        }

        Player player = (Player) sender;
        if (command.getName().equalsIgnoreCase("sethub")) {
            Location location = player.getLocation();
            getConfig().set("hub.world", location.getWorld().getName());
            getConfig().set("hub.x", location.getX());
            getConfig().set("hub.y", location.getY());
            getConfig().set("hub.z", location.getZ());
            getConfig().set("hub.yaw", location.getYaw());
            getConfig().set("hub.pitch", location.getPitch());
            saveConfig();
            player.sendMessage(ChatColor.GREEN + "Точка хаба установлена.");
            return true;
        }

        if (command.getName().equalsIgnoreCase("hub")) {
            String worldName = getConfig().getString("hub.world");
            if (worldName == null) {
                player.sendMessage(ChatColor.RED + "Точка хаба ещё не установлена.");
                return true;
            }
            World world = Bukkit.getWorld(worldName);
            if (world == null) {
                player.sendMessage(ChatColor.RED + "Мир хаба недоступен. Обратитесь к администратору.");
                return true;
            }
            Location location = new Location(world, getConfig().getDouble("hub.x"),
                    getConfig().getDouble("hub.y"), getConfig().getDouble("hub.z"),
                    (float) getConfig().getDouble("hub.yaw"), (float) getConfig().getDouble("hub.pitch"));
            if (player.teleport(location)) {
                player.sendMessage(ChatColor.GREEN + "Вы телепортированы в хаб.");
            } else {
                player.sendMessage(ChatColor.RED + "Не удалось телепортироваться в хаб.");
            }
            return true;
        }
        return false;
    }
}