koca2000 / NoteBlockAPI

https://www.spigotmc.org/resources/noteblockapi.19287/
GNU Lesser General Public License v3.0
120 stars 40 forks source link

1.13 support, general refactor #11

Closed drewdorris closed 6 years ago

drewdorris commented 6 years ago

Added 1.13 support and refactored much of the project. Little of the core code was changed; instead, mainly appearance & usability was adjusted for easier usage of the API

koca2000 commented 6 years ago

I will take a look at it at end of July. I have to check backward compatibility.

drewdorris commented 6 years ago

Missed that, fixed

koca2000 commented 6 years ago

I have just take a deeper look. Why are you using getInstrumentName in InstrumentUtils? It will cost much more time to proceed. Also why are you using getFromBukkitName and not the enum itself?

drewdorris commented 6 years ago

I was experiencing issues with using NoteBlockAPI with one version and another plugin that relies on the API with a different version -- the plugin would use getInstrument to get the Sound enum for an instrument, but the enum would not exist in the shaded Bukkit API for the other plugin, instead being a version ahead. I added the getInstrumentName method so that it would be possible to receive the name of a Sound enum without actually retrieving a potentially non-existent Sound enum. With that, I'm able to parse the name and retrieve the Sound enum for the other plugin. I found the method was needed for myself, and I imagine others may need it as well in certain situations. There shouldn't be any noticeable performance difference using getInstrumentName in getInstrument, as it only enters a short loop to retrieve the value, which should be virtually instant.

I used getFromBukkitName in getInstrumentName because the name of the enum in the local Sound class is not necessarily the latest updated name of the org.bukkit.Sound enum name, it's just one of the ones in the past. getFromBukkitName retrieves the one relevant for the latest version