#Check if a head is legacy or modern

3 messages · Page 1 of 1 (latest)

shy valley
#

Hi! Im beginner programming in java, this is for a minecraft plugin

I need to compare if one head is legacy and another is modern, what do I mean? In current versions the head is represented by the id PLAYER_HEAD, but in older versions it is represented by SKULL_ITEM so I need to know how can I know if a head is legacy or not?

I am trying to make an event, where if the user places a special head, a message will appear in the chat.

I have some "examples" of the idea im trying to implement on events. is something like this

        try {
            // if both of these succeed, then we are running
            // in a legacy api, but on a modern (1.13+) server.
            Material.class.getDeclaredField("PLAYER_HEAD");
            Material.valueOf("SKULL");

            if (!warningPosted) {
                Bukkit.getLogger().warning("SKULLCREATOR API - Using the legacy bukkit API with 1.13+ bukkit versions is not supported!");
                warningPosted = true;
            }
        } catch (NoSuchFieldException | IllegalArgumentException ignored) {}
    }```


How can I determine the material and proceed with my event?
sinful pecanBOT
#

This post has been reserved for your question.

Hey @shy valley! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.