Improving Earthbending Efficiency

Rewrote the isEarthbendable() and isTransparentToEarthbending() methods
to be more efficient.
This commit is contained in:
nathank33 2014-09-06 18:55:13 -07:00
parent 80696816d4
commit c615437b2d

View file

@ -1029,22 +1029,21 @@ public class Methods {
return isEarthbendable(player, "RaiseEarth", block); return isEarthbendable(player, "RaiseEarth", block);
} }
public static boolean isEarthbendable(Player player, String ability, public static boolean isEarthbendable(Player player, String ability, Block block)
Block block) { {
if (isRegionProtectedFromBuild(player, ability,
block.getLocation()))
return false;
Material material = block.getType(); Material material = block.getType();
boolean valid = false;
for (String s : ProjectKorra.plugin.getConfig().getStringList("Properties.Earth.EarthbendableBlocks")) { for (String s : ProjectKorra.plugin.getConfig().getStringList("Properties.Earth.EarthbendableBlocks"))
if (material == Material.getMaterial(s)){
if (material == Material.getMaterial(s)) { valid = true;
break;
return true;
} }
if(!valid)
} return false;
if (!isRegionProtectedFromBuild(player, ability,
block.getLocation()))
return true;
return false; return false;
} }
@ -1327,10 +1326,10 @@ public class Methods {
public static boolean isTransparentToEarthbending(Player player, public static boolean isTransparentToEarthbending(Player player,
String ability, Block block) { String ability, Block block) {
if (isRegionProtectedFromBuild(player, ability, if (!Arrays.asList(transparentToEarthbending).contains(block.getTypeId()))
block.getLocation()))
return false; return false;
if (Arrays.asList(transparentToEarthbending).contains(block.getTypeId())) if (!isRegionProtectedFromBuild(player, ability,
block.getLocation()))
return true; return true;
return false; return false;
} }