From c615437b2d8ef61cd7c481f69b894d76ec3a40f4 Mon Sep 17 00:00:00 2001 From: nathank33 Date: Sat, 6 Sep 2014 18:55:13 -0700 Subject: [PATCH] Improving Earthbending Efficiency Rewrote the isEarthbendable() and isTransparentToEarthbending() methods to be more efficient. --- .../projectkorra/ProjectKorra/Methods.java | 33 +++++++++---------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/com/projectkorra/ProjectKorra/Methods.java b/src/com/projectkorra/ProjectKorra/Methods.java index e5cdfb7b..b27c13ae 100644 --- a/src/com/projectkorra/ProjectKorra/Methods.java +++ b/src/com/projectkorra/ProjectKorra/Methods.java @@ -1029,22 +1029,21 @@ public class Methods { return isEarthbendable(player, "RaiseEarth", block); } - public static boolean isEarthbendable(Player player, String ability, - Block block) { - if (isRegionProtectedFromBuild(player, ability, - block.getLocation())) - return false; + public static boolean isEarthbendable(Player player, String ability, Block block) + { Material material = block.getType(); - - for (String s : ProjectKorra.plugin.getConfig().getStringList("Properties.Earth.EarthbendableBlocks")) { - - if (material == Material.getMaterial(s)) { - - return true; - + boolean valid = false; + for (String s : ProjectKorra.plugin.getConfig().getStringList("Properties.Earth.EarthbendableBlocks")) + if (material == Material.getMaterial(s)){ + valid = true; + break; } - - } + if(!valid) + return false; + + if (!isRegionProtectedFromBuild(player, ability, + block.getLocation())) + return true; return false; } @@ -1327,10 +1326,10 @@ public class Methods { public static boolean isTransparentToEarthbending(Player player, String ability, Block block) { - if (isRegionProtectedFromBuild(player, ability, - block.getLocation())) + if (!Arrays.asList(transparentToEarthbending).contains(block.getTypeId())) return false; - if (Arrays.asList(transparentToEarthbending).contains(block.getTypeId())) + if (!isRegionProtectedFromBuild(player, ability, + block.getLocation())) return true; return false; }