yapzhenyie / GadgetsMenu

Feature-rich cosmetics plugin that provide players with the most powerful features.
http://bit.ly/GadgetsMenu
66 stars 24 forks source link

Grappling Hook activates for everyone on the server if anyone equips #915

Closed ks-hl closed 2 years ago

ks-hl commented 2 years ago

Describe the bug A clear and concise description of what the bug is.

To Reproduce Steps to reproduce the behavior: 1) Anyone on the server equips the grappling hook gadget. 2) Anyone else on the server trys to fish, they are shot across the water like they're using a grappling hook.

Expected behavior Fishing rods don't turn into grappling hooks

Further Information (please complete the following information):

Screenshots If applicable, add screenshots to help explain your problem.

Additional Information Any other information that you would like to provide that may be relevant to the issue? GadgetGrapplingHook#onPlayerHook(PlayerFishEvent) uses "getPlayer().getItemInHand()" to check the fishing rod to see if it's a grappling hook, if it is, it does what grappling hook things. getPlayer() is not the player that fired the event. It's the player stored in the GadgetGrapplingHook object, which means if anyone has the grappling hook equipped, this check will be satisfied and everyone will be able to grapple with a regular fishing rod.

To fix, just replace line 97

"ItemStack itemStack = getPlayer().getItemInHand();" with "ItemStack itemStack = player.getItemInHand();"

Same typo exists in GadgetGrapplingHook#onPlayerGrapple(PlayerGrappleEvent), line 79

Alternatively, put a check to see if the player in the event is the same as GadgetGrapplingHook#getPlayer()

yapzhenyie commented 2 years ago

This issue will be fixed in the next update.

yapzhenyie commented 2 years ago

This issue has been fixed. Please check for the new update.