K

Сделай плагин на 26.2 paper 25, который будет запускать музыку по ссылке в форматах mp3, ogg и mp4. Команды: /nmusic load <ссылка на видео или музыку(так же можно загрузить в папку nmusics)> /nmusic stop, /nmusic play. Название плагина: nMusic

Kodari AI
KodariJul 24 at 3:27 pm 3

I’ll build the nMusic plugin — a Paper plugin that plays music from URLs (mp3, ogg, mp4) with commands for loading, playing, and stopping music.

nMusic
A Paper plugin for playing music from URLs in mp3, ogg, and mp4 formats. Players can load music via links or from the local nmusics folder. Includes /nmusic load to download and prepare audio, /nmusic play to start playback, and /nmusic stop to halt. Uses dynamic resource pack generation with a built-in HTTP server to deliver custom sounds to players without external dependencies.

Let me plan the architecture:

  1. nMusic — main plugin class, registers command, starts/stops HTTP server

  2. MusicManager — manages loaded music state, handles play/stop logic

  3. MusicCommand — /nmusic command handler (load/play/stop)

  4. AudioConverter — converts mp3/mp4 to ogg format for Minecraft resource packs

  5. ResourcePackServer — built-in HTTP server to serve generated resource packs

A Paper plugin that plays music from URLs and local files in Minecraft. Supports mp3, ogg, and mp4 formats. Features include downloading music from URLs, converting audio to OGG format via ffmpeg, generating dynamic resource packs with an embedded HTTP server, and playing music through Minecraft's resource pack sound system. Commands: /nmusic load, /nmusic play, /nmusic stop.

I’ll create the nMusic plugin — a Paper plugin that downloads, converts, and plays music via Minecraft’s resource pack system.

Architecture:

  • nMusic — main plugin class, starts HTTP server, registers commands

  • MusicManager — tracks loaded music and player playback state

  • MusicCommand — /nmusic handler with load/play/stop subcommands

  • AudioConverter — downloads URLs, converts mp3/mp4 to ogg via ffmpeg

  • ResourcePackServer — embedded HTTP server that serves generated resource pack zips

I’ll create the nMusic plugin — a Paper plugin that downloads music/video from URLs, converts to ogg, and plays via Minecraft’s resource pack system.

A Paper plugin that plays music from external URLs in mp3, ogg, and mp4 formats using Minecraft's resource pack system. Features include loading music from direct URLs or the nmusics folder, converting audio to ogg format via ffmpeg, built-in HTTP server for serving resource packs, and commands for loading, playing, and stopping music. Supports multiple players with different music tracks simultaneously.

Let me create all filesI’ll build the nMusic plugin — a Paper plugin that downloads music/video from URLs (mp3, ogg, mp4), converts to ogg, and plays via Minecraft’s resource pack system.

A Paper plugin that plays music from URLs in Minecraft. Supports mp3, ogg, and mp4 formats. Features include loading music from URLs or the nmusics folder, built-in HTTP server for resource pack delivery, automatic audio conversion via ffmpeg/yt-dlp, and per-player music playback with stop/play controls. Commands: /nmusic load, /nmusic play, /nmusic stop, /nmusic list.

Now creating all files:

The plugin is complete. Here’s a summary of the architecture:

nMusic — a Paper plugin that plays music/video from URLs in Minecraft

Files created (8 total):

File
Purpose
build.gradle
Paper API 1.21.4, Java 21
plugin.yml
Command registration,
/nmusic
aliased to
/nm
config.yml
HTTP server port (8192) and IP
nMusic.java
Main class, event listener for resource pack status
MusicManager.java
Tracks loaded music, per-player playback state
MusicCommand.java
Handles
load
,
play
,
stop
,
list
subcommands
AudioConverter.java
Downloads URLs (yt-dlp → direct fallback), converts to ogg via ffmpeg
PackServer.java
Embedded HTTP server, resource pack generation + serving

How it works:

  1. /nmusic load <url> — downloads audio (yt-dlp for YouTube, direct for mp3 URLs), converts to ogg via ffmpeg

  2. /nmusic load <filename> — loads from the nmusics folder in the plugin data directory

  3. /nmusic play [track] — generates a resource pack zip with the ogg, serves it via HTTP, sends to player (auto-accepts), plays when loaded

  4. /nmusic stop — stops all sound categories

Requirements on server: ffmpeg (for conversion), yt-dlp (optional, for YouTube links).

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
8 750
src/main/java/com/nmusic/nMusic.java
package com.nmusic;

import org.bukkit.plugin.java.JavaPlugin;

public class nMusic extends JavaPlugin {

    private static nMusic instance;
    private MusicManager musicManager;
    private AudioConverter audioConverter;
    private PackServer packServer;

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

        saveDefaultConfig();

        this.musicManager = new MusicManager(this);
        this.audioConverter = new AudioConverter(this);
        this.packServer = new PackServer(this);

        // Register command executor
        MusicCommand command = new MusicCommand(this);
        getCommand("nmusic").setExecutor(command);
        getCommand("nmusic").setTabCompleter(command);

        // Start HTTP server
        getServer().getScheduler().runTaskAsynchronously(this, () -> {
            try {
                packServer.start();
                getLogger().info("Pack server started successfully.");
            } catch (Exception e) {
                getLogger().severe("Failed to start pack server: " + e.getMessage());
            }
        });

        getLogger().info("nMusic enabled!");
    }

    @Override
    public void onDisable() {
        if (packServer != null) {
            packServer.stop();
        }
        getLogger().info("nMusic disabled.");
    }

    public static nMusic getInstance() {
        return instance;
    }

    public MusicManager getMusicManager() {
        return musicManager;
    }

    public AudioConverter getAudioConverter() {
        return audioConverter;
    }

    public PackServer getPackServer() {
        return packServer;
    }
}