MartenM / RedirectPlus

A simple plugin that redirects player when they get kicked of a server.
MIT License
12 stars 5 forks source link

API Channel does not exist #36

Closed PixelPage-YT closed 2 years ago

PixelPage-YT commented 2 years ago

Hello, I'm using the API of RedirectPlus in my Spigot Server. (Not the bungeecord one). This is my Code:

p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_BELL,0.2f,1.2f);
ByteArrayDataOutput out = ByteStreams.newDataOutput();
out.writeUTF("execute-alias");
out.writeUTF(p.getDisplayName());
out.writeUTF("training");

// If you don't care about the player
// Player player = Iterables.getFirst(Bukkit.getOnlinePlayers(), null);
// Else, specify them
Player player = Bukkit.getPlayerExact(p.getDisplayName());

player.sendPluginMessage(Main.INSTANCE, "martenm:redirectplus", out.toByteArray());

But i get the error: Caused by: org.bukkit.plugin.messaging.ChannelNotRegisteredException: Attempted to send a plugin message through the unregistered channel `martenm:redirectplus'.

Do i have to register the channel, if so, how? or do i have to write a bungeecord plugin? Best regards, PixelPage

MartenM commented 2 years ago

Heyo,

I am pretty sure you need to register the outgoing channel on the Spigot server. Spigot servers don't know about channels by default.

As an example: the BungeeCord subchannel needs to be registered as well before using it: https://www.spigotmc.org/wiki/bukkit-bungee-plugin-messaging-channel/#the-bungeecord-plugin-channel

Obviously, you won't be receiving messages but you need to register the outgoing channel.

MartenM commented 2 years ago

Additionally don't use the p.getDisplayName() but make sure to get the actual username of the player p.getName().

MartenM commented 2 years ago

Closing this as resolved. Please comment if this is not the case.