From 4a95d03230497fdd271e40e3b37295fc9dfe681e Mon Sep 17 00:00:00 2001 From: zml2008 Date: Sat, 24 Dec 2011 20:46:35 -0800 Subject: [PATCH] No longer using switch statement in WorldEditPlayerListener. <.< --- .../bukkit/WorldEditPlayerListener.java | 22 ++++++------------- 1 file changed, 7 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlayerListener.java b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlayerListener.java index a69fbdb05..3440d4920 100644 --- a/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlayerListener.java +++ b/src/main/java/com/sk89q/worldedit/bukkit/WorldEditPlayerListener.java @@ -22,6 +22,7 @@ package com.sk89q.worldedit.bukkit; import org.bukkit.Bukkit; import org.bukkit.block.Block; import org.bukkit.event.Event; +import org.bukkit.event.block.Action; import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerListener; @@ -104,8 +105,8 @@ public class WorldEditPlayerListener extends PlayerListener { final LocalWorld world = player.getWorld(); final WorldEdit we = plugin.getWorldEdit(); - switch (event.getAction()) { - case LEFT_CLICK_BLOCK: { + Action action = event.getAction(); + if (action == Action.LEFT_CLICK_BLOCK) { final Block clickedBlock = event.getClickedBlock(); final WorldVector pos = new WorldVector(world, clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ()); @@ -129,22 +130,17 @@ public class WorldEditPlayerListener extends PlayerListener { ignoreLeftClickAir = true; } } - - break; - } - - case LEFT_CLICK_AIR: + } else if (action == Action.LEFT_CLICK_AIR) { if (ignoreLeftClickAir) { - break; + return; } if (we.handleArmSwing(player)) { event.setCancelled(true); } - break; - case RIGHT_CLICK_BLOCK: { + } else if (action == Action.RIGHT_CLICK_BLOCK) { final Block clickedBlock = event.getClickedBlock(); final WorldVector pos = new WorldVector(world, clickedBlock.getX(), clickedBlock.getY(), clickedBlock.getZ()); @@ -156,14 +152,10 @@ public class WorldEditPlayerListener extends PlayerListener { if (we.handleRightClick(player)) { event.setCancelled(true); } - break; - } - - case RIGHT_CLICK_AIR: + } else if (action == Action.RIGHT_CLICK_AIR) { if (we.handleRightClick(player)) { event.setCancelled(true); } - break; } } }