소스 검색

Sweet berry bush exploit fix

nossr50 4 년 전
부모
커밋
ae538d8c72
2개의 변경된 파일23개의 추가작업 그리고 20개의 파일을 삭제
  1. 1 0
      Changelog.txt
  2. 22 20
      src/main/java/com/gmail/nossr50/listeners/PlayerListener.java

+ 1 - 0
Changelog.txt

@@ -2,6 +2,7 @@ Version 2.1.183
     Updated Russian locale (thanks ImDaniX)
     Added Donkeys to beat lore (thanks QuantumToasted)
     Alchemy guide now correctly labels Rabbit's foot for potion of leaping (thanks mldriscoll)
+    Fixed a bug where sweet berry bushes would give XP in situations where they shouldn't
 
 Version 2.1.182
     Players now receive XP from harvesting Sweet Berry bushes (double XP for harvesting fully grown berries)

+ 22 - 20
src/main/java/com/gmail/nossr50/listeners/PlayerListener.java

@@ -824,30 +824,32 @@ public class PlayerListener implements Listener {
                     }
                 }
 
-                FakePlayerAnimationEvent fakeSwing = new FakePlayerAnimationEvent(event.getPlayer()); //PlayerAnimationEvent compat        
-                if (herbalismManager.canGreenThumbBlock(blockState)) {
-                    //call event for Green Thumb Block
-                    if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_GREEN_THUMB, block).isCancelled()) {
-                        Bukkit.getPluginManager().callEvent(fakeSwing);
-                        player.getInventory().getItemInMainHand().setAmount(heldItem.getAmount() - 1);
-                        player.updateInventory();
-                        if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
-                            blockState.update(true);
+                FakePlayerAnimationEvent fakeSwing = new FakePlayerAnimationEvent(event.getPlayer()); //PlayerAnimationEvent compat
+                if(!event.isCancelled() || event.useInteractedBlock() != Event.Result.DENY) {
+                    if (herbalismManager.canGreenThumbBlock(blockState)) {
+                        //call event for Green Thumb Block
+                        if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_GREEN_THUMB, block).isCancelled()) {
+                            Bukkit.getPluginManager().callEvent(fakeSwing);
+                            player.getInventory().getItemInMainHand().setAmount(heldItem.getAmount() - 1);
+                            player.updateInventory();
+                            if (herbalismManager.processGreenThumbBlocks(blockState) && EventUtils.simulateBlockBreak(block, player, false)) {
+                                blockState.update(true);
+                            }
                         }
                     }
-                }
-                /* SHROOM THUMB CHECK */
-                else if (herbalismManager.canUseShroomThumb(blockState)) {
-                    if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_SHROOM_THUMB, block).isCancelled()) {
-                        Bukkit.getPluginManager().callEvent(fakeSwing);
-                        event.setCancelled(true);
-                        if (herbalismManager.processShroomThumb(blockState)
-                                && EventUtils.simulateBlockBreak(block, player, false)) {
-                            blockState.update(true);
+                    /* SHROOM THUMB CHECK */
+                    else if (herbalismManager.canUseShroomThumb(blockState)) {
+                        if(!EventUtils.callSubSkillBlockEvent(player, SubSkillType.HERBALISM_SHROOM_THUMB, block).isCancelled()) {
+                            Bukkit.getPluginManager().callEvent(fakeSwing);
+                            event.setCancelled(true);
+                            if (herbalismManager.processShroomThumb(blockState)
+                                    && EventUtils.simulateBlockBreak(block, player, false)) {
+                                blockState.update(true);
+                            }
                         }
+                    } else {
+                        herbalismManager.processBerryBushHarvesting(blockState);
                     }
-                } else {
-                    herbalismManager.processBerryBushHarvesting(blockState);
                 }
                 break;