Discussion in 'Resources' started by zombiekiller753, Nov 16, 2013.
In my opinion it does not make any sense to pull your plugin into obc/nms dependency (unless it already is depending on those).
Deprecation reason is: @deprecated This method should not be relied upon as it is a temporary work-around for a larger, more complicated issue.
So it does not look like the method is going to be removed any time soon, and your method does the same as the (Craft)Player method does, so i rather see downs than ups here. In fact you should rather rely on Player.updateInventory, because that is less likely to change.
I suggest always checking the Bukkit code for deprecation reasons, and CraftBukkit for the implementation. If you are using a proper IDE you should be able to clone the repositories and directly search / look into the code in a very convenient way (unless you find GitHub more convenient).
Why not just use @SupressWarnings("deprecation"). Who cares if there is a line right through one snippet of code (apparently you do xD). I would much rather have that than to make my plugin depend on OBC or NMS. Now, if you could put up some reflection there, I will take your method into consideration
Update inventory is not needed. Normal addItem and setItem should work fine.
Don't use something worse to get rid of the yellow lining - use the answer suggested by BungeeTheCookie , that is how you most likely get a more reliable and much more simple solution, it should even be available vie "quick fix" features with Eclipse and similar IDEs.
That only goes for using one of the both. But it is most agreeable to ask for the reason of using updateInventory in the first place...
EDIT by Moderator: merged posts, please use the edit button instead of double posting.
I wooonder where you got this from..
Doing stuff like cancelling fire placing and other such things will require a update of the player's inventory.
The API exists for a reason. You should NOT do what you did! Just add the simple suppress warnings annotation. Seriously you shouldn't make your plugin version dependant for such a reason.
Sometimes you make something that causes the inventory not to update properly and you have to use updateInventory().
Garris0n xTrollxDudex for example when you cancel the PlayerDropItemEvent you'd have to update the players' inventory, because otherwise the item will be invisible!
I would just like to note 2 things:
This has been deprecated for YEARS now, it's not new.
The code snippet in the OP is exactly what updateInventory() already does. (see: https://github.com/Bukkit/CraftBukk...kkit/craftbukkit/entity/CraftPlayer.java#L437 )
I generally only skim previous posts unless I feel like reading
Separate names with a comma.