I'm currently trying to switch my plugin from 1.8 to 1.15. However, the console tells me to change something in the plugin.yml "api version:" but what exactly lol.
And now a few mistakes here:
if (e.getClickedInventory (). GetTitle (). Equals (GUI_NAME)) {
Here the getTitle () is underlined in red. Does anyone know how something was changed in the newer version?
Then it says "CraftPlayer can't be resolved to a type:
PlayerConnection con = ((CraftPlayer) p) .getHandle (). PlayerConnection;
What do I have to change here wtf xD
And what should be "wrong" here?:
If someone needs more code or something, please ask!
The API Docs are always very practical for something like this: https://hub.spigotmc.org/...mmary.html
The PlayerPickupItemEvent is out of date and has been replaced by the https://hub.spigotmc.org/...Event.html.
An inventory no longer has a .getTitle method. This method is now only available in "InventoryView". You can get to this InventoryView via the player (e.getWhoClicked) with the .getOpenInventory () method… I suppose at least.
I can't think of anything about the CraftPlayer and I don't think much about it, I've never worked with it before, I think.
Ah ok, but then you have to do this
Player p = e.getPlayer ();
now
Player p = (Player) e.getEntity ();
are called LoL
And what is plugin.yml all about? 🤔
True, the api version in the plugin.yml also seems familiar to me.
In your case, you can simply write "api-version: 1.15" into the file. In the end, of course, that depends on the version of the game you're developing for. It has something to do with backward compatibility, as I understand it. More about this is also here: https://www.spigotmc.org/...attributes
Ok, that's how I did it.
Aso, how would
meta.spigot (). SetUnbreakable (true);
In 1.15 are called? XD
I'm MAXIMUM FLASHED xD
It goes with
if (e.getWhoClicked (). GetOpenInventory (). GetTitle (). Equals (GUI_NAME)) {
RySry for all the "comments" on your answer xD
Looks like you could omit the .spigot () and use the ItemMeta.setUnbreakable () method directly.
All good. I'm glad that it seems to work.
Another question 😆 You surely know "Field", which one for
try {
Field headerfield = tabPacket.getClass (). GetDeclaredField ("a");
headerfield.setAccessible (true);
headerfield.set (tabPacket, tabHeader);
Field footerfield = tabPacket.getClass (). GetDeclaredField ("b");
footerfield.setAccessible (true);
footerfield.set (tabPacket, tabFooter);
} catch (exception e) {
e.printStackTrace ();
} finally {
((CraftPlayer) p) .getHandle (). PlayerConnection.sendPacket (tabPacket);
}
has still used. Only, it can be that the whole header / footer in 1.15 is written differently or how should I understand it🤔😆🤦♂️
Only when I started asking 1.8 back then and now
Unfortunately I have no idea, sorry. This looks a bit like NMS code (Net.Minecraft.Server, so no access to APIs from Spigot / Bukkit). You should normally avoid access to something like that because a lot changes with new versions.
Maybe the ProtocolLib will help you if you want to change packets so directly. Or any other API to change the tabliste (that's what it is about, isn't it?). Have not yet found a direct way for it from the Spigot API.
Hmm. OK🤔I just switched the plugin back to 1.16 xD