From 560c3860b4d6976157606de75926e001d9dee94f Mon Sep 17 00:00:00 2001 From: TfT_02 Date: Sat, 17 Aug 2013 10:11:46 +0200 Subject: [PATCH] Fixed bug which allowed players to bypass fishing's exploit prevention Fixes #1319 --- Changelog.txt | 1 + .../gmail/nossr50/skills/fishing/FishingManager.java | 3 ++- src/main/java/com/gmail/nossr50/util/BlockUtils.java | 12 ++++++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index 66b53568f..71b744929 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -14,6 +14,7 @@ Version 1.4.07-dev + Added a 5 second cooldown after teleporting before Acrobatics XP can be earned. + Config option to disable + Added new API methods to ExperienceAPI to get a players rank on the leaderboards + Added new McMMOPlayerDeathPenaltyEvent, fired when a player dies and would lose levels + = Fixed bug which allowed players to bypass fishing's exploit prevention = Fixed bug with Skull Splitter not finding the locale string = Fixed issue where locale strings could cause the scoreboard header to be longer than 16 characters. = Fixed a bug with Beast Lore when the entity had no owner but was tamed. diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java index ce9f57f9a..54ca47528 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/FishingManager.java @@ -47,6 +47,7 @@ import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.runnables.skills.KrakenAttackTask; import com.gmail.nossr50.skills.SkillManager; import com.gmail.nossr50.skills.fishing.Fishing.Tier; +import com.gmail.nossr50.util.BlockUtils; import com.gmail.nossr50.util.ItemUtils; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -151,7 +152,7 @@ public class FishingManager extends SkillManager { return false; } - Block targetBlock = getPlayer().getTargetBlock(null, 100); + Block targetBlock = getPlayer().getTargetBlock(BlockUtils.getTransparentBlocks(), 100); if (!targetBlock.isLiquid()) { return false; diff --git a/src/main/java/com/gmail/nossr50/util/BlockUtils.java b/src/main/java/com/gmail/nossr50/util/BlockUtils.java index f816f86ff..7a10cfe2f 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockUtils.java +++ b/src/main/java/com/gmail/nossr50/util/BlockUtils.java @@ -1,5 +1,8 @@ package com.gmail.nossr50.util; +import java.util.Arrays; +import java.util.HashSet; + import org.bukkit.CropState; import org.bukkit.NetherWartsState; import org.bukkit.block.BlockState; @@ -313,4 +316,13 @@ public final class BlockUtils { return blockId == Repair.repairAnvilId || blockId == Repair.salvageAnvilId; } + + /** + * Get a HashSet containing every transparent block + * + * @return HashSet with the IDs of every transparent block + */ + public static HashSet getTransparentBlocks() { + return new HashSet(Arrays.asList((byte) 0, (byte) 6, (byte) 18, (byte) 20, (byte) 27, (byte) 28, (byte) 31, (byte) 32, (byte) 32, (byte) 34, (byte) 37, (byte) 38, (byte) 39, (byte) 40, (byte) 50, (byte) 51, (byte) 52, (byte) 53, (byte) 55, (byte) 59, (byte) 63, (byte) 64, (byte) 65, (byte) 66, (byte) 67, (byte) 68, (byte) 69, (byte) 70, (byte) 71, (byte) 72, (byte) 75, (byte) 76, (byte) 77, (byte) 78, (byte) 79, (byte) 81, (byte) 83, (byte) 85, (byte) 92, (byte) 93, (byte) 94, (byte) 96, (byte) 101, (byte) 102, (byte) 104, (byte) 105, (byte) 106, (byte) 107, (byte) 108, (byte) 109, (byte) 111, (byte) 113, (byte) 114, (byte) 115, (byte) 119, (byte) 126, (byte) 128, (byte) 131, (byte) 132, (byte) 134, (byte) 135, (byte) 136, (byte) 139, (byte) 141, (byte) 142, (byte) 143, (byte) 145, (byte) 147, (byte) 148, (byte) 149, (byte) 150, (byte) 151, (byte) 156, (byte) 157, (byte) 171)); + } }