Andavin / Images

A custom image loading plugin for Spigot.
71 stars 33 forks source link

update to minecraft 1.19 #43

Closed KeyboardKobold closed 2 years ago

KeyboardKobold commented 2 years ago

Updated to work with Minecraft 1.19

bumped version to 2.2.6
adapted dependencies to target new spigot release
TextComponent and ClientboundChatPacket don't exist anymore, code now just uses sendMessage method
ClientboundAddEntityPacket changed available parameters, now omitting EntityType.ITEM_FRAME
Added explanation on how to build dependencies to README.md, as those came up in the last pull request

I just tried to get this up and running for our server quickly and it seems to work, however the message prompt to place the image is now being sent multiple times. Not sure on how to fix it, open to any input!

Bugdwoid commented 2 years ago

I just did the same update myself too and saw that you opened this PR 3 hours ago, lol

The issue with the message prompt is that you seem to be using the wrong method in ActionBarUtil.java, the one you're using sends a message in the chat but this class's sendMessage method is meant to show a message over the hotbar and repeats itself to prevent the message to disappear until the player placed the image.

Here's a working version of this class :

class ActionBarUtil extends com.andavin.util.ActionBarUtil {
    @Override
    protected void sendMessage(Player player, String message) {
        ((CraftPlayer) player).getHandle().connection.send(
                new ClientboundSystemChatPacket(Component.translatable(message), 2));
    }
}
KeyboardKobold commented 2 years ago

Thank you, I'll update this PR asap!

Bugdwoid commented 2 years ago

You can also remove the ID attribute and java.util.UUID import from that class as they are now unused.

KeyboardKobold commented 2 years ago

You can also remove the ID attribute and java.util.UUID import from that class as they are now unused.

Oh, good point! Completely forgot, usually I try to keep everything clean.

Also, may I ask how you figured out what Clientbound*Packet to use and how to use the Component factory? I tried looking at the Spigot API, but I can't seem to find it in there.

Bugdwoid commented 2 years ago

Also, may I ask how you figured out what Clientbound*Packet to use and how to use the Component factory? I tried looking at the Spigot API, but I can't seem to find it in there.

I used IntelliJ autocomplete to find ClientboundSystemChatPacket as ClientboundChatPacket was removed and I was trying to see if something else replaced it. For the Component factory, I found this thread on the Forge forums where it is suggested to use one of the factory methods in the Component class.

MJRLegends commented 2 years ago

Btw the main dev of this plugin has already made 1.19 support on the dev branch.