Merge branch 'fix/forcefieldflag' of https://github.com/manuelgu/PlotSquared into manuelgu-fix/forcefieldflag

This commit is contained in:
MattBDev 2016-06-02 09:52:30 -04:00
commit 89c4ce24ef

View File

@ -5,15 +5,14 @@ import com.intellectualcrafters.plot.flag.Flags;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
import com.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.BukkitUtil;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -53,7 +52,7 @@ public class ForceFieldListener implements Listener {
return null; return null;
} }
public Vector calculateVelocity(PlotPlayer pp, PlotPlayer e) { private Vector calculateVelocity(PlotPlayer pp, PlotPlayer e) {
Location playerLocation = pp.getLocationFull(); Location playerLocation = pp.getLocationFull();
Location oPlayerLocation = e.getLocation(); Location oPlayerLocation = e.getLocation();
double playerX = playerLocation.getX(); double playerX = playerLocation.getX();
@ -84,16 +83,15 @@ public class ForceFieldListener implements Listener {
} }
@EventHandler @EventHandler
public void onPlotEntry(PlayerEnterPlotEvent event) { public void onPlotEntry(PlayerMoveEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player); PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = event.getPlot(); Plot plot = pp.getCurrentPlot();
if (plot == null) { if (plot == null) {
return; return;
} }
Optional<Boolean> forcefield = plot.getFlag(Flags.FORCEFIELD); Optional<Boolean> forcefield = plot.getFlag(Flags.FORCEFIELD);
if (forcefield.isPresent() && forcefield.get()) { if (forcefield.isPresent() && forcefield.get()) {
if (!plot.getFlag(Flags.FORCEFIELD).or(false)) {
UUID uuid = pp.getUUID(); UUID uuid = pp.getUUID();
if (plot.isAdded(uuid)) { if (plot.isAdded(uuid)) {
Set<PlotPlayer> players = getNearbyPlayers(player, plot); Set<PlotPlayer> players = getNearbyPlayers(player, plot);
@ -110,4 +108,3 @@ public class ForceFieldListener implements Listener {
} }
} }
} }
}