No longer using switch statement in WorldEditPlayerListener. <.<

This commit is contained in:
zml2008 2011-12-24 20:46:35 -08:00
parent 479253821e
commit 4a95d03230

View File

@ -22,6 +22,7 @@ package com.sk89q.worldedit.bukkit;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerListener;
@ -104,8 +105,8 @@ public class WorldEditPlayerListener extends PlayerListener {
final LocalWorld world = player.getWorld(); final LocalWorld world = player.getWorld();
final WorldEdit we = plugin.getWorldEdit(); final WorldEdit we = plugin.getWorldEdit();
switch (event.getAction()) { Action action = event.getAction();
case LEFT_CLICK_BLOCK: { if (action == Action.LEFT_CLICK_BLOCK) {
final Block clickedBlock = event.getClickedBlock(); final Block clickedBlock = event.getClickedBlock();
final WorldVector pos = new WorldVector(world, clickedBlock.getX(), final WorldVector pos = new WorldVector(world, clickedBlock.getX(),
clickedBlock.getY(), clickedBlock.getZ()); clickedBlock.getY(), clickedBlock.getZ());
@ -129,22 +130,17 @@ public class WorldEditPlayerListener extends PlayerListener {
ignoreLeftClickAir = true; ignoreLeftClickAir = true;
} }
} }
} else if (action == Action.LEFT_CLICK_AIR) {
break;
}
case LEFT_CLICK_AIR:
if (ignoreLeftClickAir) { if (ignoreLeftClickAir) {
break; return;
} }
if (we.handleArmSwing(player)) { if (we.handleArmSwing(player)) {
event.setCancelled(true); event.setCancelled(true);
} }
break;
case RIGHT_CLICK_BLOCK: { } else if (action == Action.RIGHT_CLICK_BLOCK) {
final Block clickedBlock = event.getClickedBlock(); final Block clickedBlock = event.getClickedBlock();
final WorldVector pos = new WorldVector(world, clickedBlock.getX(), final WorldVector pos = new WorldVector(world, clickedBlock.getX(),
clickedBlock.getY(), clickedBlock.getZ()); clickedBlock.getY(), clickedBlock.getZ());
@ -156,14 +152,10 @@ public class WorldEditPlayerListener extends PlayerListener {
if (we.handleRightClick(player)) { if (we.handleRightClick(player)) {
event.setCancelled(true); event.setCancelled(true);
} }
break; } else if (action == Action.RIGHT_CLICK_AIR) {
}
case RIGHT_CLICK_AIR:
if (we.handleRightClick(player)) { if (we.handleRightClick(player)) {
event.setCancelled(true); event.setCancelled(true);
} }
break;
} }
} }
} }