Bleeding: Adjust reset-conditions for set-back location and similar.

This commit is contained in:
asofold 2012-11-11 17:11:04 +01:00
parent cf99770902
commit c1bb11a725

View File

@ -209,9 +209,10 @@ public class MovingListener implements Listener {
* |___/
*/
final Player player = event.getPlayer();
if (!player.hasPermission(Permissions.MOVING_CREATIVEFLY) && survivalFly.isEnabled(player)) {
final MovingData data = MovingData.getData(player);
final MovingConfig cc = MovingConfig.getConfig(player);
if (shouldCheckSurvivalFly(player, data, cc)) {
// Check if the player has to be reset.
final Location target = survivalFly.checkBed(player, data);
// To cancel the event, we teleport the player.
@ -248,10 +249,13 @@ public class MovingListener implements Listener {
* |___/ |___/
*/
// Maybe this helps with people teleporting through Multiverse portals having problems?
final MovingData data = MovingData.getData(event.getPlayer());
final Player player = event.getPlayer();
final MovingData data = MovingData.getData(player);
data.teleported = null;
data.clearFlyData();
data.clearMorePacketsData();
// TODO: Might omit this if neither check is activated.
data.setBack = player.getLocation();
}
/**
@ -605,10 +609,8 @@ public class MovingListener implements Listener {
final MovingData data = MovingData.getData(player);
data.clearFlyData();
data.clearMorePacketsData();
if (survivalFly.isEnabled(player)) {
data.setBack = event.getRespawnLocation();
}
}
/**
* Clear fly data on death.
@ -783,11 +785,11 @@ public class MovingListener implements Listener {
if (!(entity instanceof Player)) return;
final Player player = (Player) entity;
final MovingData data = MovingData.getData(player);
if (event.isCancelled() || !survivalFly.isEnabled(player) || !noFall.isEnabled(player)){
final MovingConfig cc = MovingConfig.getConfig(player);
if (event.isCancelled() || !shouldCheckSurvivalFly(player, data, cc) || !noFall.isEnabled(player)){
data.clearNoFallData();
return;
}
final MovingConfig cc = MovingConfig.getConfig(player);
final float fallDistance = player.getFallDistance();
final int damage = event.getDamage();
final float yDiff = (float) (data.noFallMaxY - player.getLocation().getY());
@ -806,7 +808,6 @@ public class MovingListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(final PlayerJoinEvent event) {
final Player player = event.getPlayer();
if (survivalFly.isEnabled(player)){
final MovingData data = MovingData.getData(player);
// TODO: on existing set back: detect world changes and loss of world on join (+ set up some paradigm).
if (data.setBack == null){
@ -817,7 +818,6 @@ public class MovingListener implements Listener {
data.resetPositions(data.setBack);
}
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerQuit(final PlayerQuitEvent event){
@ -839,4 +839,20 @@ public class MovingListener implements Listener {
return 1D + mcPlayer.getEffect(MobEffectList.JUMP).getAmplifier();
} else return 0D;
}
/**
* Heavier check, but convenient for seldom events (not for use in the player-move check).
* @param player
* @param data
* @param cc
* @return
*/
public final boolean shouldCheckSurvivalFly(final Player player, final MovingData data, final MovingConfig cc){
if (player.hasPermission(Permissions.MOVING_CREATIVEFLY)) return false;
else if (!survivalFly.isEnabled(player)) return false;
else if ((cc.ignoreCreative || player.getGameMode() != GameMode.CREATIVE) && (cc.ignoreAllowFlight || !player.getAllowFlight())){
return true;
}
else return false;
}
}