mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-09-16 08:57:32 +02:00
Potential fix(es) for flying after respawning
This commit is contained in:
parent
61d89d78d8
commit
a4bb515ee0
@ -3,7 +3,7 @@ name: NoCheat
|
|||||||
author: Evenprime
|
author: Evenprime
|
||||||
|
|
||||||
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
main: cc.co.evenprime.bukkit.nocheat.NoCheat
|
||||||
version: 1.06
|
version: 1.06a
|
||||||
|
|
||||||
softdepend: [ Permissions, CraftIRC ]
|
softdepend: [ Permissions, CraftIRC ]
|
||||||
|
|
||||||
|
@ -392,7 +392,7 @@ public class MovingCheck extends Check {
|
|||||||
final Location l = data.lastLocation;
|
final Location l = data.lastLocation;
|
||||||
|
|
||||||
// Player is currently changing worlds
|
// Player is currently changing worlds
|
||||||
if(l.getWorld() != from.getWorld()) {
|
if(!l.getWorld().equals(from.getWorld())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -462,7 +462,7 @@ public class MovingCheck extends Check {
|
|||||||
if(!event.isCancelled()) {
|
if(!event.isCancelled()) {
|
||||||
data.lastLocation = event.getTo();
|
data.lastLocation = event.getTo();
|
||||||
data.jumpPhase = 0;
|
data.jumpPhase = 0;
|
||||||
data.setBackPoint = event.getTo();
|
data.setBackPoint = event.getTo().clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -472,7 +472,8 @@ public class MovingCheck extends Check {
|
|||||||
*/
|
*/
|
||||||
public void respawned(PlayerRespawnEvent event) {
|
public void respawned(PlayerRespawnEvent event) {
|
||||||
MovingData data = MovingData.get(event.getPlayer());
|
MovingData data = MovingData.get(event.getPlayer());
|
||||||
data.lastLocation = event.getRespawnLocation(); // We expect the player to be there next
|
data.lastLocation = event.getRespawnLocation();
|
||||||
|
data.setBackPoint = event.getRespawnLocation().clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -525,12 +526,15 @@ public class MovingCheck extends Check {
|
|||||||
double y = data.setBackPoint.getY();
|
double y = data.setBackPoint.getY();
|
||||||
|
|
||||||
// search for the first solid block up to 5 blocks below the setbackpoint and teleport the player there
|
// search for the first solid block up to 5 blocks below the setbackpoint and teleport the player there
|
||||||
for(int i = 0; i < 20; i++) {
|
int i = 0;
|
||||||
|
for(; i < 20; i++) {
|
||||||
if(playerIsOnGround(data.setBackPoint, -0.5*i) != MovingData.NONSOLID) {
|
if(playerIsOnGround(data.setBackPoint, -0.5*i) != MovingData.NONSOLID) {
|
||||||
y -= 0.5*i;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
y -= 0.5*i;
|
||||||
|
|
||||||
|
data.setBackPoint.setY(y);
|
||||||
|
|
||||||
// Remember the location we send the player to, to identify teleports that were started by us
|
// Remember the location we send the player to, to identify teleports that were started by us
|
||||||
data.teleportTo = new Location(data.setBackPoint.getWorld(), data.setBackPoint.getX(), y, data.setBackPoint.getZ(), event.getTo().getYaw(), event.getTo().getPitch());
|
data.teleportTo = new Location(data.setBackPoint.getWorld(), data.setBackPoint.getX(), y, data.setBackPoint.getZ(), event.getTo().getYaw(), event.getTo().getPitch());
|
||||||
|
@ -16,11 +16,11 @@ public class MovingData {
|
|||||||
public double horizFreedom = 0.0D;
|
public double horizFreedom = 0.0D;
|
||||||
public double vertFreedom = 0.0D;
|
public double vertFreedom = 0.0D;
|
||||||
public int vertFreedomCounter = 0;
|
public int vertFreedomCounter = 0;
|
||||||
|
|
||||||
// setbackpoint is a recommendation - try to teleport to first solid block below it
|
// setbackpoint is a recommendation - try to teleport to first solid block below it
|
||||||
// for better effect
|
// for better effect
|
||||||
public Location setBackPoint = null;
|
public Location setBackPoint = null;
|
||||||
|
|
||||||
public int summaryTask = -1;
|
public int summaryTask = -1;
|
||||||
public Level highestLogLevel = null;
|
public Level highestLogLevel = null;
|
||||||
public double maxYVelocity = 0.0D;
|
public double maxYVelocity = 0.0D;
|
||||||
@ -46,18 +46,18 @@ public class MovingData {
|
|||||||
public static final int LADDER = 4; // 0x00000100
|
public static final int LADDER = 4; // 0x00000100
|
||||||
public static final int FENCE = 8; // 0x00001000
|
public static final int FENCE = 8; // 0x00001000
|
||||||
|
|
||||||
|
|
||||||
// Until I can think of a better way to determine if a block is solid or not, this is what I'll do
|
// Until I can think of a better way to determine if a block is solid or not, this is what I'll do
|
||||||
public static final int types[] = new int[256];
|
public static final int types[] = new int[256];
|
||||||
|
|
||||||
static {
|
static {
|
||||||
|
|
||||||
// Find and define properties of all blocks
|
// Find and define properties of all blocks
|
||||||
for(int i = 0; i < types.length; i++) {
|
for(int i = 0; i < types.length; i++) {
|
||||||
|
|
||||||
// Everything is considered nonsolid at first
|
// Everything is considered nonsolid at first
|
||||||
types[i] = NONSOLID;
|
types[i] = NONSOLID;
|
||||||
|
|
||||||
if(Block.byId[i] != null) {
|
if(Block.byId[i] != null) {
|
||||||
if(Block.byId[i].material.isSolid()) {
|
if(Block.byId[i].material.isSolid()) {
|
||||||
// solid blocks like STONE, CAKE, TRAPDOORS
|
// solid blocks like STONE, CAKE, TRAPDOORS
|
||||||
@ -69,12 +69,12 @@ public class MovingData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Special types just for me
|
// Special types just for me
|
||||||
types[Material.LADDER.getId()]= LADDER | SOLID;
|
types[Material.LADDER.getId()]= LADDER | SOLID;
|
||||||
types[Material.FENCE.getId()]= FENCE | SOLID;
|
types[Material.FENCE.getId()]= FENCE | SOLID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MovingData get(final Player p) {
|
public static MovingData get(final Player p) {
|
||||||
|
|
||||||
final NoCheatData data = NoCheatData.getPlayerData(p);
|
final NoCheatData data = NoCheatData.getPlayerData(p);
|
||||||
@ -86,5 +86,4 @@ public class MovingData {
|
|||||||
|
|
||||||
return data.moving;
|
return data.moving;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user