KyoriPowered / adventure

A user-interface library, formerly known as text, for Minecraft: Java Edition
https://docs.advntr.dev/
MIT License
679 stars 104 forks source link

java.lang.IncompatibleClassChangeError when attempting to use player.sendMessage() #1028

Closed Wolvinny closed 5 months ago

Wolvinny commented 5 months ago

I've freshly installed this, and i'm trying with the most basic code in the docs Sender is a Player instance.

  MiniMessage mm = MiniMessage.miniMessage();
  Component parse = mm.deserialize("<green>test</green>");
                    Audience au = (Audience) sender;
                    au.sendMessage(parse);

The docs dont really explain what Audience should be, the example just shows Audience =.... Tried without casting, that threw a noSuchMethodError. This code produces the following error

Caused by: java.lang.IncompatibleClassChangeError: Class org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer does not implement the requested interface net.kyori.adventure.audience.Audience

Dependencies:

      <dependency>
          <groupId>net.kyori</groupId>
          <artifactId>adventure-text-minimessage</artifactId>
          <version>4.14.0</version>
      </dependency>
      <dependency>
          <groupId>net.kyori</groupId>
          <artifactId>text-adapter-bukkit</artifactId>
          <version>3.0.6</version>
          <scope>compile</scope>
      </dependency>

Server is running craftbukkit, 1.20.4, plain vanilla with no other plugins. I might be overlooking something but i've been stuck at this for a while now

kezz commented 5 months ago

You cannot just cast a player to an audience. You need to properly use an in-date and supported version of adventure-platform-bukkit. If you need more assistance I'd recommend jumping into our Discord or using our Discussions page.

Wolvinny commented 5 months ago

i must've skipped past that somehow. works now! thanks!