yannicklamprecht / WorldBorderAPI

A world border api that allows it to define a world border per player
MIT License
125 stars 13 forks source link

NMS 1.18 is being imported; causing issues if shaded #133

Closed opd02 closed 2 months ago

opd02 commented 2 months ago

Describe the bug I am attempting to shade the API into my plugin so the server doesn't need the API jar in the plugins folder. The shading works and I was able to get its service registered. When I try to access my static WorldBorderAPI variable, I get the error in console Caused by: java.lang.ClassNotFoundException: org.bukkit.craftbukkit.v1_18_R1.CraftWorld. After looking into the code, is seem in com.github.yannicklamprecht.worldborder.impl.WorldBorder you're importing 1.18 NMS. To Reproduce Steps to reproduce the behavior: In my onEnable(), I have this: worldBorderApi = new PersistenceWrapper(this, new Border()); this.getServer().getServicesManager().register(WorldBorderApi.class, worldBorderApi, this, ServicePriority.High); RegisteredServiceProvider<WorldBorderApi> worldBorderApiRegisteredServiceProvider = getServer().getServicesManager().getRegistration(WorldBorderApi.class); which provides a non-null version of the API. Then when I try and do the following, I get an error: GambitRemastered.worldBorderApi.resetWorldBorderToGlobal(player);

Expected behavior I expect it to reset the player's world border.

yannicklamprecht commented 2 months ago

You need to shade the right version for your Minecraft version. It is not recommended to shade the API as it removes the flexibility of downloading the right API for your Minecraft version. Shading binds your plugin to one version of the game.

Seems like you clearly shaded a 1.18 version of the api into your plugin and ran it with another Minecraft version.