From 4aceadd777d0c22756bdf07061d7379f0aa0e65b Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 4 Feb 2013 11:35:52 -0500 Subject: [PATCH] == is faster than .equals() for enums. --- .../java/com/gmail/nossr50/listeners/BlockListener.java | 6 +++--- .../java/com/gmail/nossr50/listeners/EntityListener.java | 2 +- .../java/com/gmail/nossr50/skills/herbalism/Herbalism.java | 2 +- .../nossr50/skills/mining/SuperBreakerEventHandler.java | 2 +- .../java/com/gmail/nossr50/skills/utilities/ToolType.java | 2 +- src/main/java/com/gmail/nossr50/util/BlockChecks.java | 4 ++-- src/main/java/com/gmail/nossr50/util/ChimaeraWing.java | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java index 6aa13611a..0c17d8522 100644 --- a/src/main/java/com/gmail/nossr50/listeners/BlockListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/BlockListener.java @@ -286,7 +286,7 @@ public class BlockListener implements Listener { else if (profile.getToolPreparationMode(ToolType.SHOVEL) && ItemChecks.isShovel(heldItem) && BlockChecks.canBeGigaDrillBroken(block) && Permissions.gigaDrillBreaker(player)) { SkillTools.abilityCheck(player, SkillType.EXCAVATION); } - else if (profile.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockChecks.canBeGigaDrillBroken(block) || block.getType().equals(Material.SNOW)) && Permissions.berserk(player)) { + else if (profile.getToolPreparationMode(ToolType.FISTS) && heldItem.getType() == Material.AIR && (BlockChecks.canBeGigaDrillBroken(block) || block.getType() == Material.SNOW) && Permissions.berserk(player)) { SkillTools.abilityCheck(player, SkillType.UNARMED); } } @@ -344,7 +344,7 @@ public class BlockListener implements Listener { } } else if (profile.getAbilityMode(AbilityType.BERSERK) && SkillTools.triggerCheck(player, block, AbilityType.BERSERK)) { - if (heldItem.getType().equals(Material.AIR)) { + if (heldItem.getType() == Material.AIR) { FakePlayerAnimationEvent armswing = new FakePlayerAnimationEvent(player); plugin.getServer().getPluginManager().callEvent(armswing); @@ -375,7 +375,7 @@ public class BlockListener implements Listener { Woodcutting.beginLeafBlower(player, block); } } - else if (!heldItem.getType().equals(Material.SHEARS)) { + else if (!(heldItem.getType() == Material.SHEARS)) { event.setInstaBreak(true); Woodcutting.beginLeafBlower(player, block); } diff --git a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java index cf18e1002..bc9fdf379 100644 --- a/src/main/java/com/gmail/nossr50/listeners/EntityListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/EntityListener.java @@ -221,7 +221,7 @@ public class EntityListener implements Listener { SpawnReason reason = event.getSpawnReason(); - if (reason.equals(SpawnReason.SPAWNER) || reason.equals(SpawnReason.SPAWNER_EGG)) { + if (reason == SpawnReason.SPAWNER || reason == SpawnReason.SPAWNER_EGG) { mcMMO.placeStore.addSpawnedMob(event.getEntity()); } } diff --git a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java index 4e999a7fb..2ca9d561f 100644 --- a/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java +++ b/src/main/java/com/gmail/nossr50/skills/herbalism/Herbalism.java @@ -130,7 +130,7 @@ public class Herbalism { for (int y = 0; y <= 2; y++) { Block relativeBlock = block.getRelative(BlockFace.UP, y); - if (relativeBlock.getType().equals(blockType) && !mcMMO.placeStore.isTrue(relativeBlock)) { + if (relativeBlock.getType() == blockType && !mcMMO.placeStore.isTrue(relativeBlock)) { dropAmount++; } } diff --git a/src/main/java/com/gmail/nossr50/skills/mining/SuperBreakerEventHandler.java b/src/main/java/com/gmail/nossr50/skills/mining/SuperBreakerEventHandler.java index 4f9ba2116..8b3bf9cc9 100644 --- a/src/main/java/com/gmail/nossr50/skills/mining/SuperBreakerEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/mining/SuperBreakerEventHandler.java @@ -106,7 +106,7 @@ public class SuperBreakerEventHandler { private void calculateDurabilityLoss() { this.durabilityLoss = Misc.toolDurabilityLoss; - if (blockType.equals(Material.OBSIDIAN)) { + if (blockType == Material.OBSIDIAN) { durabilityLoss = durabilityLoss * 5; } } diff --git a/src/main/java/com/gmail/nossr50/skills/utilities/ToolType.java b/src/main/java/com/gmail/nossr50/skills/utilities/ToolType.java index a11e82159..2940d0142 100644 --- a/src/main/java/com/gmail/nossr50/skills/utilities/ToolType.java +++ b/src/main/java/com/gmail/nossr50/skills/utilities/ToolType.java @@ -42,7 +42,7 @@ public enum ToolType { return ItemChecks.isAxe(is); case FISTS: - return is.getType().equals(Material.AIR); + return is.getType() == Material.AIR; case HOE: return ItemChecks.isHoe(is); diff --git a/src/main/java/com/gmail/nossr50/util/BlockChecks.java b/src/main/java/com/gmail/nossr50/util/BlockChecks.java index 54f764f77..e942b471a 100644 --- a/src/main/java/com/gmail/nossr50/util/BlockChecks.java +++ b/src/main/java/com/gmail/nossr50/util/BlockChecks.java @@ -312,7 +312,7 @@ public final class BlockChecks { } public static boolean isLog(Block block) { - if (block.getType().equals(Material.LOG) || (configInstance.getBlockModsEnabled() && ModChecks.isCustomLogBlock(block))) { + if (block.getType() == Material.LOG || (configInstance.getBlockModsEnabled() && ModChecks.isCustomLogBlock(block))) { return true; } @@ -320,7 +320,7 @@ public final class BlockChecks { } public static boolean isLeaves(Block block) { - if (block.getType().equals(Material.LEAVES) || (configInstance.getBlockModsEnabled() && ModChecks.isCustomLeafBlock(block))) { + if (block.getType() == Material.LEAVES || (configInstance.getBlockModsEnabled() && ModChecks.isCustomLeafBlock(block))) { return true; } diff --git a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java index 277874018..9b01b9c67 100644 --- a/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java +++ b/src/main/java/com/gmail/nossr50/util/ChimaeraWing.java @@ -35,14 +35,14 @@ public final class ChimaeraWing { player.setItemInHand(new ItemStack(Config.getInstance().getChimaeraItemId(), amount - Config.getInstance().getChimaeraCost())); for (int y = 1; block.getY() + y < player.getWorld().getMaxHeight(); y++) { - if (!block.getRelative(0, y, 0).getType().equals(Material.AIR)) { + if (!(block.getRelative(0, y, 0).getType() == Material.AIR)) { player.sendMessage(LocaleLoader.getString("Item.ChimaeraWing.Fail")); player.teleport(block.getRelative(0, y - 1, 0).getLocation()); return; } } - if (player.getBedSpawnLocation() != null && player.getBedSpawnLocation().getBlock().getType().equals(Material.BED_BLOCK)) { + if (player.getBedSpawnLocation() != null && player.getBedSpawnLocation().getBlock().getType() == Material.BED_BLOCK) { player.teleport(player.getBedSpawnLocation()); } else {