mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-01 13:27:44 +01:00
Preparations for new Bukkit version
This commit is contained in:
parent
3e92d0b9a2
commit
8b8e5c2267
@ -3,7 +3,7 @@ name: NoCheatPlugin
|
|||||||
author: Evenprime
|
author: Evenprime
|
||||||
|
|
||||||
main: cc.co.evenprime.bukkit.nocheat.NoCheatPlugin
|
main: cc.co.evenprime.bukkit.nocheat.NoCheatPlugin
|
||||||
version: 0.7.6
|
version: 0.7.7a
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
nocheat:
|
nocheat:
|
||||||
|
@ -38,7 +38,7 @@ public class NoCheatConfiguration {
|
|||||||
|
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
this.config(configurationFile);
|
config(configurationFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -157,7 +157,7 @@ public class NoCheatPlugin extends JavaPlugin {
|
|||||||
pm.registerEvent(Event.Type.PLAYER_MOVE, new SpeedhackListener(speedhackCheck), Priority.High, this);
|
pm.registerEvent(Event.Type.PLAYER_MOVE, new SpeedhackListener(speedhackCheck), Priority.High, this);
|
||||||
|
|
||||||
// Register listeners for airbuild check
|
// Register listeners for airbuild check
|
||||||
pm.registerEvent(Event.Type.BLOCK_PLACED, new AirbuildListener(airbuildCheck), Priority.Low, this);
|
pm.registerEvent(Event.Type.BLOCK_PLACE, new AirbuildListener(airbuildCheck), Priority.Low, this);
|
||||||
|
|
||||||
// Register listeners for bedteleport check
|
// Register listeners for bedteleport check
|
||||||
pm.registerEvent(Event.Type.PLAYER_TELEPORT, new BedteleportListener(bedteleportCheck), Priority.Lowest, this);
|
pm.registerEvent(Event.Type.PLAYER_TELEPORT, new BedteleportListener(bedteleportCheck), Priority.Lowest, this);
|
||||||
|
@ -32,7 +32,7 @@ public class MovingCheck extends Check {
|
|||||||
private double stepHeight = 0.501D;
|
private double stepHeight = 0.501D;
|
||||||
|
|
||||||
// Limits
|
// Limits
|
||||||
public final double moveLimits[] = { 0.1D, 2.0D, 5.0D };
|
public final double moveLimits[] = { 0.0D, 0.5D, 2.0D };
|
||||||
|
|
||||||
public final double heightLimits[] = { 0.0D, 0.5D, 2.0D };
|
public final double heightLimits[] = { 0.0D, 0.5D, 2.0D };
|
||||||
|
|
||||||
@ -201,13 +201,14 @@ public class MovingCheck extends Check {
|
|||||||
|
|
||||||
// First check the distance the player has moved horizontally
|
// First check the distance the player has moved horizontally
|
||||||
// TODO: Make this check much more precise
|
// TODO: Make this check much more precise
|
||||||
double xDistance = Math.abs(from.getX() - to.getX());
|
double xDistance = from.getX()-to.getX();
|
||||||
double zDistance = Math.abs(from.getZ() - to.getZ());
|
double zDistance = from.getZ()-to.getZ();
|
||||||
double combined = xDistance * xDistance + zDistance * zDistance;
|
double combined = Math.sqrt((xDistance*xDistance + zDistance*zDistance)) - 0.6D;
|
||||||
|
|
||||||
|
System.out.println(combined);
|
||||||
// If the target is a bed and distance not too big, allow it
|
// If the target is a bed and distance not too big, allow it
|
||||||
if(to.getWorld().getBlockTypeIdAt(to) == Material.BED_BLOCK.getId() && xDistance < 5.0D && zDistance < 5.0D) {
|
if(to.getWorld().getBlockTypeIdAt(to) == Material.BED_BLOCK.getId() && xDistance < 8.0D && zDistance < 8.0D) {
|
||||||
return; // players are allowed to "teleport" into a bed over short distances
|
return; // players are allowed to "teleport" into a bed over "short" distances
|
||||||
}
|
}
|
||||||
|
|
||||||
int vl = -1;
|
int vl = -1;
|
||||||
@ -231,8 +232,8 @@ public class MovingCheck extends Check {
|
|||||||
|
|
||||||
// pre-calculate boundary values that are needed multiple times in the following checks
|
// pre-calculate boundary values that are needed multiple times in the following checks
|
||||||
// the array each contains [lowerX, higherX, Y, lowerZ, higherZ]
|
// the array each contains [lowerX, higherX, Y, lowerZ, higherZ]
|
||||||
int fromValues[] = {lowerBorder(from.getX()), upperBorder(from.getX()), from.getBlockY(), lowerBorder(from.getZ()),upperBorder(from.getZ()) };
|
int fromValues[] = {lowerBorder(from.getX()), upperBorder(from.getX()), (int)Math.floor(from.getY()+0.5D), lowerBorder(from.getZ()),upperBorder(from.getZ()) };
|
||||||
int toValues[] = {lowerBorder(to.getX()), upperBorder(to.getX()), to.getBlockY(), lowerBorder(to.getZ()), upperBorder(to.getZ()) };
|
int toValues[] = {lowerBorder(to.getX()), upperBorder(to.getX()), (int)Math.floor(to.getY()+0.5D), lowerBorder(to.getZ()), upperBorder(to.getZ()) };
|
||||||
|
|
||||||
// compare locations to the world to guess if the player is standing on the ground, a half-block or next to a ladder
|
// compare locations to the world to guess if the player is standing on the ground, a half-block or next to a ladder
|
||||||
boolean onGroundFrom = playerIsOnGround(from.getWorld(), fromValues, from);
|
boolean onGroundFrom = playerIsOnGround(from.getWorld(), fromValues, from);
|
||||||
@ -250,7 +251,7 @@ public class MovingCheck extends Check {
|
|||||||
// Walk
|
// Walk
|
||||||
if(onGroundFrom && onGroundTo)
|
if(onGroundFrom && onGroundTo)
|
||||||
{
|
{
|
||||||
double limit = stepHeight;
|
double limit = jumpHeight;
|
||||||
double distance = to.getY() - from.getY();
|
double distance = to.getY() - from.getY();
|
||||||
|
|
||||||
vl = max(vl, heightLimitCheck(limit, distance));
|
vl = max(vl, heightLimitCheck(limit, distance));
|
||||||
@ -459,13 +460,13 @@ public class MovingCheck extends Check {
|
|||||||
// Lets try it that way. Maybe now people don't "disappear" any longer
|
// Lets try it that way. Maybe now people don't "disappear" any longer
|
||||||
event.setFrom(l.clone());
|
event.setFrom(l.clone());
|
||||||
event.setTo(l.clone());
|
event.setTo(l.clone());
|
||||||
event.getPlayer().teleportTo(l.clone());
|
event.getPlayer().teleport(l.clone());
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Lets try it that way. Maybe now people don't "disappear" any longer
|
// Lets try it that way. Maybe now people don't "disappear" any longer
|
||||||
event.setTo(event.getFrom().clone());
|
event.setTo(event.getFrom().clone());
|
||||||
event.getPlayer().teleportTo(event.getFrom().clone());
|
event.getPlayer().teleport(event.getFrom().clone());
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -113,13 +113,13 @@ public class SpeedhackCheck extends Check {
|
|||||||
event.setFrom(l);
|
event.setFrom(l);
|
||||||
event.setTo(l);
|
event.setTo(l);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().teleportTo(l);
|
event.getPlayer().teleport(l);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
event.setFrom(event.getFrom());
|
event.setFrom(event.getFrom());
|
||||||
event.setTo(event.getFrom().clone());
|
event.setTo(event.getFrom().clone());
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().teleportTo(event.getFrom());
|
event.getPlayer().teleport(event.getFrom());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.listeners;
|
package cc.co.evenprime.bukkit.nocheat.listeners;
|
||||||
|
|
||||||
import org.bukkit.event.player.PlayerListener;
|
import org.bukkit.event.player.PlayerListener;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.checks.BedteleportCheck;
|
import cc.co.evenprime.bukkit.nocheat.checks.BedteleportCheck;
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ public class BedteleportListener extends PlayerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerTeleport(PlayerMoveEvent event) {
|
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||||
|
|
||||||
if(!event.isCancelled() && check.isActive()) {
|
if(!event.isCancelled() && check.isActive()) {
|
||||||
check.check(event);
|
check.check(event);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package cc.co.evenprime.bukkit.nocheat.listeners;
|
package cc.co.evenprime.bukkit.nocheat.listeners;
|
||||||
|
|
||||||
import org.bukkit.event.player.PlayerListener;
|
import org.bukkit.event.player.PlayerListener;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
|
||||||
import cc.co.evenprime.bukkit.nocheat.checks.MovingCheck;
|
import cc.co.evenprime.bukkit.nocheat.checks.MovingCheck;
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ public class MovingMonitor extends PlayerListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerTeleport(PlayerMoveEvent event) {
|
public void onPlayerTeleport(PlayerTeleportEvent event) {
|
||||||
|
|
||||||
check.teleported(event);
|
check.teleported(event);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user