Remove direction correction, as it does not seem to be effective.

This commit is contained in:
asofold 2014-05-15 10:44:34 +02:00
parent 24bc2816e6
commit c93edcbbe9
17 changed files with 134 additions and 149 deletions

View File

@ -233,9 +233,9 @@ public class MCAccessBukkit implements MCAccess, BlockPropertiesSetup{
}
}
@Override
public void correctDirection(Player player) {
// TODO: Consider using reflection (detect CraftPlayer, access EntityPlayer + check if possible (!), use flags for if valid or invalid.)
}
// @Override
// public void correctDirection(Player player) {
// // TODO: Consider using reflection (detect CraftPlayer, access EntityPlayer + check if possible (!), use flags for if valid or invalid.)
// }
}

View File

@ -18,7 +18,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.moving.LocUtil;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
@ -163,13 +162,13 @@ public class MCAccessCB2512 implements MCAccess{
}
}
@Override
public void correctDirection(final Player player) {
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// Main direction.
mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// Consider setting the lastYaw here too.
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -18,7 +18,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.moving.LocUtil;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
@ -163,13 +162,13 @@ public class MCAccessCB2545 implements MCAccess{
}
}
@Override
public void correctDirection(final Player player) {
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// Main direction.
mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// Consider setting the lastYaw here too.
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -18,7 +18,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.moving.LocUtil;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
@ -165,13 +164,13 @@ public class MCAccessCB2602 implements MCAccess{
}
}
@Override
public void correctDirection(final Player player) {
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// Main direction.
mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// Consider setting the lastYaw here too.
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -18,7 +18,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.moving.LocUtil;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
@ -165,13 +164,13 @@ public class MCAccessCB2645 implements MCAccess{
}
}
@Override
public void correctDirection(final Player player) {
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// Main direction.
mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// Consider setting the lastYaw here too.
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -18,7 +18,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.moving.LocUtil;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
@ -167,13 +166,13 @@ public class MCAccessCB2691 implements MCAccess{
}
}
@Override
public void correctDirection(final Player player) {
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// Main direction.
mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// Consider setting the lastYaw here too.
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -18,7 +18,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.moving.LocUtil;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
@ -166,13 +165,13 @@ public class MCAccessCB2763 implements MCAccess{
}
}
@Override
public void correctDirection(final Player player) {
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// Main direction.
mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// Consider setting the lastYaw here too.
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -18,7 +18,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.moving.LocUtil;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
@ -160,13 +159,13 @@ public class MCAccessCB2794 implements MCAccess{
return mat.hasGravity();
}
@Override
public void correctDirection(final Player player) {
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// Main direction.
mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// Consider setting the lastYaw here too.
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -18,7 +18,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.moving.LocUtil;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
@ -161,13 +160,13 @@ public class MCAccessCB2808 implements MCAccess{
return mat.hasGravity();
}
@Override
public void correctDirection(final Player player) {
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// Main direction.
mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// Consider setting the lastYaw here too.
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -18,7 +18,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.moving.LocUtil;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
@ -162,13 +161,13 @@ public class MCAccessCB2882 implements MCAccess{
return mat.hasGravity();
}
@Override
public void correctDirection(final Player player) {
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// Main direction.
mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// Consider setting the lastYaw here too.
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -18,10 +18,8 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.moving.LocUtil;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.compat.cb2922.BlockCacheCB2922;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
import fr.neatmonster.nocheatplus.utilities.ReflectionUtil;
@ -163,13 +161,13 @@ public class MCAccessCB2922 implements MCAccess{
return mat.hasGravity();
}
@Override
public void correctDirection(final Player player) {
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// Main direction.
mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// Consider setting the lastYaw here too.
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -18,7 +18,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.moving.LocUtil;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
@ -162,13 +161,13 @@ public class MCAccessCB3026 implements MCAccess{
return mat.hasGravity();
}
@Override
public void correctDirection(final Player player) {
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// Main direction.
mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// Consider setting the lastYaw here too.
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -18,7 +18,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.checks.moving.LocUtil;
import fr.neatmonster.nocheatplus.compat.AlmostBoolean;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.BlockCache;
@ -181,13 +180,13 @@ public class MCAccessCBDev implements MCAccess{
return mat.hasGravity();
}
@Override
public void correctDirection(final Player player) {
final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// Main direction.
mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// Consider setting the lastYaw here too.
}
// @Override
// public void correctDirection(final Player player) {
// final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
// // Main direction.
// mcPlayer.yaw = LocUtil.correctYaw(mcPlayer.yaw);
// mcPlayer.pitch = LocUtil.correctPitch(mcPlayer.pitch);
// // Consider setting the lastYaw here too.
// }
}

View File

@ -115,11 +115,11 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
final boolean worldChanged = !worldName.equals(data.lastWorld);
final Location loc = player.getLocation(useLoc1);
// Bad pitch/yaw, just in case.
if (LocUtil.needsDirectionCorrection(useLoc1.getYaw(), useLoc1.getPitch())) {
mcAccess.correctDirection(player);
player.getLocation(useLoc1);
}
// // Bad pitch/yaw, just in case.
// if (LocUtil.needsDirectionCorrection(useLoc1.getYaw(), useLoc1.getPitch())) {
// mcAccess.correctDirection(player);
// player.getLocation(useLoc1);
// }
final Location damagedLoc = damaged.getLocation(useLoc2);
// final double targetDist = CheckUtils.distance(loc, targetLoc); // TODO: Calculate distance as is done in fight.reach !
final double targetMove;
@ -150,11 +150,11 @@ public class FightListener extends CheckListener implements JoinLeaveListener{
final Player damagedPlayer;
if (damaged instanceof Player){
damagedPlayer = (Player) damaged;
// Bad pitch/yaw, just in case.
if (LocUtil.needsDirectionCorrection(useLoc2.getYaw(), useLoc2.getPitch())) {
mcAccess.correctDirection(damagedPlayer);
damagedPlayer.getLocation(useLoc2);
}
// // Bad pitch/yaw, just in case.
// if (LocUtil.needsDirectionCorrection(useLoc2.getYaw(), useLoc2.getPitch())) {
// mcAccess.correctDirection(damagedPlayer);
// damagedPlayer.getLocation(useLoc2);
// }
// Log.
if (cc.debug && damagedPlayer.hasPermission(Permissions.ADMINISTRATION_DEBUG)){
damagedPlayer.sendMessage("Attacked by " + player.getName() + ": inv=" + mcAccess.getInvulnerableTicks(damagedPlayer) + " ndt=" + damagedPlayer.getNoDamageTicks());

View File

@ -366,11 +366,11 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
final Location to = event.getTo();
Location newTo = null;
// Check problematic yaw/pitch values.
if (LocUtil.needsDirectionCorrection(from.getYaw(), from.getPitch())
|| LocUtil.needsDirectionCorrection(to.getYaw(), to.getPitch())) {
DataManager.getPlayerData(player).task.correctDirection();
}
// // Check problematic yaw/pitch values.
// if (LocUtil.needsDirectionCorrection(from.getYaw(), from.getPitch())
// || LocUtil.needsDirectionCorrection(to.getYaw(), to.getPitch())) {
// DataManager.getPlayerData(player).task.correctDirection();
// }
// TODO: Check illegal moves here anyway (!).
// TODO: Check if vehicle move logs correctly (fake).
@ -1282,10 +1282,10 @@ public class MovingListener extends CheckListener implements TickListener, IRemo
// Hover.
initHover(player, data, cc, data.toWasReset); // isOnGroundOrResetCond
// Bad pitch/yaw, just in case.
if (LocUtil.needsDirectionCorrection(useLoc.getYaw(), useLoc.getPitch())) {
DataManager.getPlayerData(player).task.correctDirection();
}
// // Bad pitch/yaw, just in case.
// if (LocUtil.needsDirectionCorrection(useLoc.getYaw(), useLoc.getPitch())) {
// DataManager.getPlayerData(player).task.correctDirection();
// }
}
/**

View File

@ -136,11 +136,11 @@ public interface MCAccess {
*/
public boolean hasGravity(Material type);
/**
* Correct the direction (yaw + pitch). If this can't be done lightly it should just do nothing. Check pitch and yaw before calling, use auxiliary methods from LocUtil.
* @param player
*/
public void correctDirection(Player player);
// /**
// * Correct the direction (yaw + pitch). If this can't be done lightly it should just do nothing. Check pitch and yaw before calling, use auxiliary methods from LocUtil.
// * @param player
// */
// public void correctDirection(Player player);
}

View File

@ -2,8 +2,6 @@ package fr.neatmonster.nocheatplus.players;
import org.bukkit.entity.Player;
import fr.neatmonster.nocheatplus.NCPAPIProvider;
import fr.neatmonster.nocheatplus.compat.MCAccess;
import fr.neatmonster.nocheatplus.utilities.OnDemandTickListener;
/**
@ -19,7 +17,7 @@ public class PlayerTask extends OnDemandTickListener {
protected boolean updateInventory = false;
protected boolean correctDirection = false;
// protected boolean correctDirection = false;
/**
*
@ -36,10 +34,10 @@ public class PlayerTask extends OnDemandTickListener {
final Player player = DataManager.getPlayer(lcName);
if (player != null) {
if (player.isOnline()) {
if (correctDirection) {
final MCAccess access = NCPAPIProvider.getNoCheatPlusAPI().getMCAccess();
access.correctDirection(player);
}
// if (correctDirection) {
// final MCAccess access = NCPAPIProvider.getNoCheatPlusAPI().getMCAccess();
// access.correctDirection(player);
// }
if (updateInventory) {
player.updateInventory();
}
@ -47,7 +45,7 @@ public class PlayerTask extends OnDemandTickListener {
}
// Reset values (players logging back in should be fine or handled differently).
updateInventory = false;
correctDirection = false;
// correctDirection = false;
return false;
}
@ -57,10 +55,10 @@ public class PlayerTask extends OnDemandTickListener {
register();
}
public void correctDirection() {
correctDirection = true;
register();
}
// public void correctDirection() {
// correctDirection = true;
// register();
// }
// TODO: updateHunger