FancyMcPlugins / FancyNpcs

FancyNpcs is a simple, lightweight and fast npc plugin using packets
https://modrinth.com/plugin/fancynpcs
MIT License
102 stars 23 forks source link

SendServer command #31

Closed DormantCat closed 11 months ago

DormantCat commented 11 months ago

Please add commands for working with Proxy servers (BungeeCord / Velocity)

for example, /npc sendServer {NPC name} {Proxy-Server}

( Of course, it is possible to create similar functionality at the expense of other plugins, to do a kind of casting, but it would be much easier and more convenient to implement this function. )


/**
* @p - The player to move
* @s - Server which to move to
*/
public void connect(Player p, String s) {
        ByteArrayDataOutput out = ByteStreams.newDataOutput();
        out.writeUTF("Connect");
        out.writeUTF(s);
        p.sendPluginMessage(plugin, "BungeeCord", out.toByteArray());
    }

This is a very simple solution that will allow you to move the player to another server.

DormantCat commented 11 months ago

Well, add the BungeeCord channel registration to OnEnable

the simplest function in my opinion.

    @Override
    public void onEnable() {
        getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
        //Other code
    }
OliverSchlueter commented 11 months ago

You can use /npc playerCommand (npc name) server (server name)

The server command is already hardcoded into the playerCommand