Optimize move event

This commit is contained in:
boy0001 2015-04-09 22:25:09 +10:00
parent 635a4bd7a4
commit b0050dd2e8

View File

@ -197,26 +197,23 @@ public class WorldEditListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerMove(final PlayerMoveEvent e) { public void onPlayerMove(final PlayerMoveEvent e) {
final Location t = e.getTo(); final Location t = e.getTo();
final Location f = e.getFrom();
final com.intellectualcrafters.plot.object.Location locf = BukkitUtil.getLocation(f);
final com.intellectualcrafters.plot.object.Location loct = BukkitUtil.getLocation(t);
if ((locf.getX() != loct.getX()) || (locf.getZ() != loct.getZ())) {
final Player p = e.getPlayer();
final PlotPlayer pp = BukkitUtil.getPlayer(p);
if (!isPlotWorld(t)) { if (!isPlotWorld(t)) {
return; return;
} }
final Location f = e.getFrom(); final PlotId idF = MainUtil.getPlotId(locf);
if ((f.getX() == t.getX()) && (f.getZ() == t.getZ())) { final PlotId idT = MainUtil.getPlotId(loct);
return; if ((idT != null) && !(idF == idT)) {
}
final Player p = e.getPlayer();
final PlotPlayer pp = BukkitUtil.getPlayer(p);
if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) { if (Permissions.hasPermission(pp, "plots.worldedit.bypass")) {
if (!PWE.hasMask(pp)) { if (!PWE.hasMask(pp)) {
return; return;
} }
} }
final com.intellectualcrafters.plot.object.Location locf = BukkitUtil.getLocation(f);
final com.intellectualcrafters.plot.object.Location loct = BukkitUtil.getLocation(t);
if ((locf.getX() != loct.getX()) || (locf.getZ() != loct.getZ())) {
final PlotId idF = MainUtil.getPlotId(locf);
final PlotId idT = MainUtil.getPlotId(loct);
if ((idT != null) && !(idF == idT)) {
PWE.setMask(pp, loct, false); PWE.setMask(pp, loct, false);
} }
} }