mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2024-11-02 08:40:01 +01:00
Removed the NetServerHandler proxy, now overriding packets instead.
Reverted the changes about plugins protection, now if enabled in the configuration, the /plugins and /versions commands will be OP-only.
This commit is contained in:
parent
963c363c7d
commit
e585e918fd
@ -1,617 +0,0 @@
|
||||
package fr.neatmonster.nocheatplus;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
import net.minecraft.server.AxisAlignedBB;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.NetServerHandler;
|
||||
import net.minecraft.server.Packet;
|
||||
import net.minecraft.server.Packet0KeepAlive;
|
||||
import net.minecraft.server.Packet101CloseWindow;
|
||||
import net.minecraft.server.Packet102WindowClick;
|
||||
import net.minecraft.server.Packet106Transaction;
|
||||
import net.minecraft.server.Packet107SetCreativeSlot;
|
||||
import net.minecraft.server.Packet108ButtonClick;
|
||||
import net.minecraft.server.Packet10Flying;
|
||||
import net.minecraft.server.Packet130UpdateSign;
|
||||
import net.minecraft.server.Packet13PlayerLookMove;
|
||||
import net.minecraft.server.Packet14BlockDig;
|
||||
import net.minecraft.server.Packet15Place;
|
||||
import net.minecraft.server.Packet16BlockItemSwitch;
|
||||
import net.minecraft.server.Packet18ArmAnimation;
|
||||
import net.minecraft.server.Packet19EntityAction;
|
||||
import net.minecraft.server.Packet202Abilities;
|
||||
import net.minecraft.server.Packet203TabComplete;
|
||||
import net.minecraft.server.Packet204LocaleAndViewDistance;
|
||||
import net.minecraft.server.Packet205ClientCommand;
|
||||
import net.minecraft.server.Packet250CustomPayload;
|
||||
import net.minecraft.server.Packet255KickDisconnect;
|
||||
import net.minecraft.server.Packet3Chat;
|
||||
import net.minecraft.server.Packet7UseEntity;
|
||||
import net.minecraft.server.Packet9Respawn;
|
||||
import net.minecraft.server.WorldServer;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
import fr.neatmonster.nocheatplus.players.Permissions;
|
||||
|
||||
/*
|
||||
* M"""""""`YM dP MP""""""`MM
|
||||
* M mmmm. M 88 M mmmmm..M
|
||||
* M MMMMM M .d8888b. d8888P M. `YM .d8888b. 88d888b. dP .dP .d8888b. 88d888b.
|
||||
* M MMMMM M 88ooood8 88 MMMMMMM. M 88ooood8 88' `88 88 d8' 88ooood8 88' `88
|
||||
* M MMMMM M 88. ... 88 M. .MMM' M 88. ... 88 88 .88' 88. ... 88
|
||||
* M MMMMM M `88888P' dP Mb. .dM `88888P' dP 8888P' `88888P' dP
|
||||
* MMMMMMMMMMM MMMMMMMMMMM
|
||||
*
|
||||
* M""MMMMM""MM dP dP MM"""""""`YM
|
||||
* M MMMMM MM 88 88 MM mmmmm M
|
||||
* M `M .d8888b. 88d888b. .d888b88 88 .d8888b. 88d888b. M' .M 88d888b. .d8888b. dP. .dP dP dP
|
||||
* M MMMMM MM 88' `88 88' `88 88' `88 88 88ooood8 88' `88 MM MMMMMMMM 88' `88 88' `88 `8bd8' 88 88
|
||||
* M MMMMM MM 88. .88 88 88 88. .88 88 88. ... 88 MM MMMMMMMM 88 88. .88 .d88b. 88. .88
|
||||
* M MMMMM MM `88888P8 dP dP `88888P8 dP `88888P' dP MM MMMMMMMM dP `88888P' dP' `dP `8888P88
|
||||
* MMMMMMMMMMMM MMMMMMMMMMMM .88
|
||||
* d8888P
|
||||
*/
|
||||
/**
|
||||
* A proxy used to fix Bukkit preventing players from using fly mods.
|
||||
*/
|
||||
public class NetServerHandlerProxy extends NetServerHandler {
|
||||
/** The default stance of a player. */
|
||||
private static final double STANCE = 1.6200000047683716D;
|
||||
|
||||
private Field hField;
|
||||
private final MinecraftServer minecraftServer;
|
||||
private final NetServerHandler netServerHandler;
|
||||
|
||||
private double bukkitX = Double.MAX_VALUE;
|
||||
private double bukkitY = Double.MAX_VALUE;
|
||||
private double bukkitZ = Double.MAX_VALUE;
|
||||
private float bukkitPitch = Float.MAX_VALUE;
|
||||
private float bukkitYaw = Float.MAX_VALUE;
|
||||
private boolean checkMovement;
|
||||
private int flying;
|
||||
private boolean justTeleported = false;
|
||||
private double vanillaX;
|
||||
private double vanillaY;
|
||||
private double vanillaZ;
|
||||
|
||||
/**
|
||||
* Instantiates a new net server handler proxy.
|
||||
*
|
||||
* @param minecraftServer
|
||||
* the minecraft server
|
||||
* @param netServerHandler
|
||||
* the net server handler
|
||||
*/
|
||||
public NetServerHandlerProxy(final MinecraftServer minecraftServer, final NetServerHandler netServerHandler) {
|
||||
super(minecraftServer, netServerHandler.networkManager, netServerHandler.player);
|
||||
this.minecraftServer = minecraftServer;
|
||||
this.netServerHandler = netServerHandler;
|
||||
try {
|
||||
hField = NetServerHandler.class.getDeclaredField("h");
|
||||
hField.setAccessible(true);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a()
|
||||
*/
|
||||
@Override
|
||||
public boolean a() {
|
||||
return netServerHandler.a();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(double, double, double, float, float)
|
||||
*/
|
||||
@Override
|
||||
public void a(final double x, final double y, final double z, final float yaw, final float pitch) {
|
||||
netServerHandler.a(x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet0KeepAlive)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet0KeepAlive packet0keepalive) {
|
||||
netServerHandler.a(packet0keepalive);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet102WindowClick)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet102WindowClick packet102windowclick) {
|
||||
netServerHandler.a(packet102windowclick);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet106Transaction)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet106Transaction packet106transaction) {
|
||||
netServerHandler.a(packet106transaction);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet107SetCreativeSlot)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet107SetCreativeSlot packet107setcreativeslot) {
|
||||
netServerHandler.a(packet107setcreativeslot);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet108ButtonClick)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet108ButtonClick packet108buttonclick) {
|
||||
netServerHandler.a(packet108buttonclick);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet10Flying)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet10Flying packet10flying) {
|
||||
if (player.getBukkitEntity().hasPermission(Permissions.MOVING_OVERRIDEBUKKIT)) {
|
||||
final WorldServer worldserver = minecraftServer.getWorldServer(player.dimension);
|
||||
|
||||
try {
|
||||
hField.set(netServerHandler, true);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (!player.viewingCredits) {
|
||||
double d0;
|
||||
|
||||
if (!checkMovement) {
|
||||
d0 = packet10flying.y - vanillaY;
|
||||
if (packet10flying.x == vanillaX && d0 * d0 < 0.01D && packet10flying.z == vanillaZ)
|
||||
checkMovement = true;
|
||||
}
|
||||
|
||||
final Player bPlayer = getPlayer();
|
||||
final Location from = new Location(bPlayer.getWorld(), bukkitX, bukkitY, bukkitZ, bukkitYaw,
|
||||
bukkitPitch);
|
||||
final Location to = bPlayer.getLocation().clone();
|
||||
|
||||
if (packet10flying.hasPos && (packet10flying.y != -999.0D || packet10flying.stance != -999.0D)) {
|
||||
to.setX(packet10flying.x);
|
||||
to.setY(packet10flying.y);
|
||||
to.setZ(packet10flying.z);
|
||||
}
|
||||
|
||||
if (packet10flying.hasLook) {
|
||||
to.setYaw(packet10flying.yaw);
|
||||
to.setPitch(packet10flying.pitch);
|
||||
}
|
||||
|
||||
final double delta = Math.pow(bukkitX - to.getX(), 2) + Math.pow(bukkitY - to.getY(), 2)
|
||||
+ Math.pow(bukkitZ - to.getZ(), 2);
|
||||
final float deltaAngle = Math.abs(bukkitYaw - to.getYaw()) + Math.abs(bukkitPitch - to.getPitch());
|
||||
|
||||
if ((delta > 1f / 256 || deltaAngle > 10f) && checkMovement && !player.dead) {
|
||||
bukkitX = to.getX();
|
||||
bukkitY = to.getY();
|
||||
bukkitZ = to.getZ();
|
||||
bukkitYaw = to.getYaw();
|
||||
bukkitPitch = to.getPitch();
|
||||
|
||||
if (from.getX() != Double.MAX_VALUE) {
|
||||
final PlayerMoveEvent event = new PlayerMoveEvent(bPlayer, from, to);
|
||||
minecraftServer.server.getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
netServerHandler.sendPacket(new Packet13PlayerLookMove(from.getX(), from.getY() + STANCE,
|
||||
from.getY(), from.getZ(), from.getYaw(), from.getPitch(), false));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!to.equals(event.getTo()) && !event.isCancelled()) {
|
||||
player.getBukkitEntity().teleport(event.getTo(), PlayerTeleportEvent.TeleportCause.UNKNOWN);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!from.equals(getPlayer().getLocation()) && justTeleported) {
|
||||
justTeleported = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Double.isNaN(packet10flying.x) || Double.isNaN(packet10flying.y) || Double.isNaN(packet10flying.z)
|
||||
|| Double.isNaN(packet10flying.stance)) {
|
||||
bPlayer.teleport(bPlayer.getWorld().getSpawnLocation(), PlayerTeleportEvent.TeleportCause.UNKNOWN);
|
||||
System.err.println(bPlayer.getName()
|
||||
+ " was caught trying to crash the server with an invalid position.");
|
||||
bPlayer.kickPlayer("Nope!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (checkMovement && !player.dead) {
|
||||
double d1;
|
||||
double d2;
|
||||
double d3;
|
||||
double d4;
|
||||
|
||||
if (player.vehicle != null) {
|
||||
float f = player.yaw;
|
||||
float f1 = player.pitch;
|
||||
|
||||
player.vehicle.V();
|
||||
d1 = player.locX;
|
||||
d2 = player.locY;
|
||||
d3 = player.locZ;
|
||||
double d5 = 0.0D;
|
||||
|
||||
d4 = 0.0D;
|
||||
if (packet10flying.hasLook) {
|
||||
f = packet10flying.yaw;
|
||||
f1 = packet10flying.pitch;
|
||||
}
|
||||
|
||||
if (packet10flying.hasPos && packet10flying.y == -999.0D && packet10flying.stance == -999.0D) {
|
||||
if (Math.abs(packet10flying.x) > 1 || Math.abs(packet10flying.z) > 1) {
|
||||
System.err.println(bPlayer.getName()
|
||||
+ " was caught trying to crash the server with an invalid position.");
|
||||
bPlayer.kickPlayer("Nope!");
|
||||
return;
|
||||
}
|
||||
|
||||
d5 = packet10flying.x;
|
||||
d4 = packet10flying.z;
|
||||
}
|
||||
|
||||
player.onGround = packet10flying.g;
|
||||
player.g();
|
||||
player.move(d5, 0.0D, d4);
|
||||
player.setLocation(d1, d2, d3, f, f1);
|
||||
player.motX = d5;
|
||||
player.motZ = d4;
|
||||
if (player.vehicle != null)
|
||||
worldserver.vehicleEnteredWorld(player.vehicle, true);
|
||||
|
||||
if (player.vehicle != null)
|
||||
player.vehicle.V();
|
||||
|
||||
minecraftServer.getServerConfigurationManager().d(player);
|
||||
vanillaX = player.locX;
|
||||
vanillaY = player.locY;
|
||||
vanillaZ = player.locZ;
|
||||
worldserver.playerJoinedWorld(player);
|
||||
return;
|
||||
}
|
||||
|
||||
if (player.isSleeping()) {
|
||||
player.g();
|
||||
player.setLocation(vanillaX, vanillaY, vanillaZ, player.yaw, player.pitch);
|
||||
worldserver.playerJoinedWorld(player);
|
||||
return;
|
||||
}
|
||||
|
||||
d0 = player.locY;
|
||||
vanillaX = player.locX;
|
||||
vanillaY = player.locY;
|
||||
vanillaZ = player.locZ;
|
||||
d1 = player.locX;
|
||||
d2 = player.locY;
|
||||
d3 = player.locZ;
|
||||
float f2 = player.yaw;
|
||||
float f3 = player.pitch;
|
||||
|
||||
if (packet10flying.hasPos && packet10flying.y == -999.0D && packet10flying.stance == -999.0D)
|
||||
packet10flying.hasPos = false;
|
||||
|
||||
if (packet10flying.hasPos) {
|
||||
d1 = packet10flying.x;
|
||||
d2 = packet10flying.y;
|
||||
d3 = packet10flying.z;
|
||||
d4 = packet10flying.stance - packet10flying.y;
|
||||
if (!player.isSleeping() && (d4 > 1.65D || d4 < 0.1D)) {
|
||||
disconnect("Illegal stance");
|
||||
logger.warning(player.name + " had an illegal stance: " + d4);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Math.abs(packet10flying.x) > 3.2E7D || Math.abs(packet10flying.z) > 3.2E7D) {
|
||||
disconnect("Illegal position");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (packet10flying.hasLook) {
|
||||
f2 = packet10flying.yaw;
|
||||
f3 = packet10flying.pitch;
|
||||
}
|
||||
|
||||
player.g();
|
||||
player.V = 0.0F;
|
||||
player.setLocation(vanillaX, vanillaY, vanillaZ, f2, f3);
|
||||
if (!checkMovement)
|
||||
return;
|
||||
|
||||
d4 = d1 - player.locX;
|
||||
double d6 = d2 - player.locY;
|
||||
double d7 = d3 - player.locZ;
|
||||
|
||||
final float f4 = 0.0625F;
|
||||
final boolean flag = worldserver.getCubes(player, player.boundingBox.clone().shrink(f4, f4, f4))
|
||||
.isEmpty();
|
||||
|
||||
if (player.onGround && !packet10flying.g && d6 > 0.0D)
|
||||
player.j(0.2F);
|
||||
|
||||
player.move(d4, d6, d7);
|
||||
player.onGround = packet10flying.g;
|
||||
player.checkMovement(d4, d6, d7);
|
||||
final double d12 = d6;
|
||||
|
||||
d4 = d1 - player.locX;
|
||||
d6 = d2 - player.locY;
|
||||
if (d6 > -0.5D || d6 < 0.5D)
|
||||
d6 = 0.0D;
|
||||
|
||||
d7 = d3 - player.locZ;
|
||||
|
||||
player.setLocation(d1, d2, d3, f2, f3);
|
||||
final boolean flag2 = worldserver.getCubes(player, player.boundingBox.clone().shrink(f4, f4, f4))
|
||||
.isEmpty();
|
||||
|
||||
if (flag && !flag2 && !player.isSleeping()) {
|
||||
this.a(vanillaX, vanillaY, vanillaZ, f2, f3);
|
||||
return;
|
||||
}
|
||||
|
||||
final AxisAlignedBB axisalignedbb = player.boundingBox.clone().grow(f4, f4, f4)
|
||||
.a(0.0D, -0.55D, 0.0D);
|
||||
|
||||
if (!minecraftServer.getAllowFlight() && !player.abilities.canFly && !worldserver.c(axisalignedbb)) {
|
||||
if (d12 >= -0.03125D) {
|
||||
flying++;
|
||||
if (flying > 80) {
|
||||
logger.warning(player.name + " was kicked for floating too long!");
|
||||
disconnect("Flying is not enabled on this server");
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else
|
||||
flying = 0;
|
||||
|
||||
player.onGround = packet10flying.g;
|
||||
minecraftServer.getServerConfigurationManager().d(player);
|
||||
if (player.itemInWorldManager.isCreative())
|
||||
return;
|
||||
player.b(player.locY - d0, packet10flying.g);
|
||||
}
|
||||
}
|
||||
} else
|
||||
netServerHandler.a(packet10flying);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet130UpdateSign)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet130UpdateSign packet130updatesign) {
|
||||
netServerHandler.a(packet130updatesign);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet14BlockDig)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet14BlockDig packet14blockdig) {
|
||||
netServerHandler.a(packet14blockdig);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet15Place)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet15Place packet15place) {
|
||||
netServerHandler.a(packet15place);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet16BlockItemSwitch)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet16BlockItemSwitch packet16blockitemswitch) {
|
||||
netServerHandler.a(packet16blockitemswitch);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet18ArmAnimation)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet18ArmAnimation packet18armanimation) {
|
||||
netServerHandler.a(packet18armanimation);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet19EntityAction)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet19EntityAction packet19entityaction) {
|
||||
netServerHandler.a(packet19entityaction);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet202Abilities)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet202Abilities packet202abilities) {
|
||||
netServerHandler.a(packet202abilities);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet203TabComplete)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet203TabComplete packet203tabcomplete) {
|
||||
netServerHandler.a(packet203tabcomplete);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet204LocaleAndViewDistance)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet204LocaleAndViewDistance packet204localeandviewdistance) {
|
||||
netServerHandler.a(packet204localeandviewdistance);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet205ClientCommand)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet205ClientCommand packet205clientcommand) {
|
||||
netServerHandler.a(packet205clientcommand);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet250CustomPayload)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet250CustomPayload packet250custompayload) {
|
||||
netServerHandler.a(packet250custompayload);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet255KickDisconnect)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet255KickDisconnect packet255kickdisconnect) {
|
||||
netServerHandler.a(packet255kickdisconnect);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet3Chat)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet3Chat packet3chat) {
|
||||
netServerHandler.a(packet3chat);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet7UseEntity)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet7UseEntity packet7useentity) {
|
||||
netServerHandler.a(packet7useentity);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(net.minecraft.server.Packet9Respawn)
|
||||
*/
|
||||
@Override
|
||||
public void a(final Packet9Respawn packet9respawn) {
|
||||
netServerHandler.a(packet9respawn);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#a(java.lang.String, java.lang.Object[])
|
||||
*/
|
||||
@Override
|
||||
public void a(final String s, final Object[] aobject) {
|
||||
netServerHandler.a(s, aobject);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#b()
|
||||
*/
|
||||
@Override
|
||||
public boolean b() {
|
||||
return netServerHandler.b();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#chat(java.lang.String, boolean)
|
||||
*/
|
||||
@Override
|
||||
public void chat(final String s, final boolean async) {
|
||||
netServerHandler.chat(s, async);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#d()
|
||||
*/
|
||||
@Override
|
||||
public void d() {
|
||||
netServerHandler.d();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#disconnect(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void disconnect(final String s) {
|
||||
netServerHandler.disconnect(s);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#getPlayer()
|
||||
*/
|
||||
@Override
|
||||
public CraftPlayer getPlayer() {
|
||||
return netServerHandler.getPlayer();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#handleContainerClose(net.minecraft.server.Packet101CloseWindow)
|
||||
*/
|
||||
@Override
|
||||
public void handleContainerClose(final Packet101CloseWindow packet101closewindow) {
|
||||
netServerHandler.handleContainerClose(packet101closewindow);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#lowPriorityCount()
|
||||
*/
|
||||
@Override
|
||||
public int lowPriorityCount() {
|
||||
return netServerHandler.lowPriorityCount();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#onUnhandledPacket(net.minecraft.server.Packet)
|
||||
*/
|
||||
@Override
|
||||
public void onUnhandledPacket(final Packet packet) {
|
||||
netServerHandler.onUnhandledPacket(packet);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#sendPacket(net.minecraft.server.Packet)
|
||||
*/
|
||||
@Override
|
||||
public void sendPacket(final Packet packet) {
|
||||
netServerHandler.sendPacket(packet);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.NetServerHandler#teleport(org.bukkit.Location)
|
||||
*/
|
||||
@Override
|
||||
public void teleport(final Location destination) {
|
||||
if (player.getBukkitEntity().hasPermission(Permissions.MOVING_OVERRIDEBUKKIT)) {
|
||||
final double x = bukkitX = vanillaX = destination.getX();
|
||||
final double y = bukkitY = vanillaY = destination.getY();
|
||||
final double z = bukkitZ = vanillaZ = destination.getZ();
|
||||
final float yaw = bukkitYaw = Float.isNaN(destination.getYaw()) ? 0f : destination.getYaw();
|
||||
final float pitch = bukkitPitch = Float.isNaN(destination.getPitch()) ? 0f : destination.getPitch();
|
||||
checkMovement = !(justTeleported = true);
|
||||
player.setLocation(x, y, z, yaw, pitch);
|
||||
netServerHandler.sendPacket(new Packet13PlayerLookMove(x, y + STANCE, y, z, yaw, pitch, false));
|
||||
} else
|
||||
netServerHandler.teleport(destination);
|
||||
}
|
||||
}
|
@ -1,17 +1,9 @@
|
||||
package fr.neatmonster.nocheatplus;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraft.server.NetServerHandler;
|
||||
import net.minecraft.server.NetworkManager;
|
||||
import net.minecraft.server.ServerConnection;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -31,6 +23,7 @@ import fr.neatmonster.nocheatplus.checks.inventory.InventoryListener;
|
||||
import fr.neatmonster.nocheatplus.checks.moving.MovingListener;
|
||||
import fr.neatmonster.nocheatplus.config.ConfPaths;
|
||||
import fr.neatmonster.nocheatplus.config.ConfigManager;
|
||||
import fr.neatmonster.nocheatplus.packets.PacketsWorkaround;
|
||||
import fr.neatmonster.nocheatplus.players.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.LagMeasureTask;
|
||||
|
||||
@ -49,10 +42,10 @@ import fr.neatmonster.nocheatplus.utilities.LagMeasureTask;
|
||||
public class NoCheatPlus extends JavaPlugin implements Listener {
|
||||
|
||||
/** The time it was when NoCheatPlus has been activated. */
|
||||
public static long time = System.currentTimeMillis();
|
||||
public static final long time = System.currentTimeMillis();
|
||||
|
||||
/** The listeners. */
|
||||
private List<Listener> listeners;
|
||||
private final List<Listener> listeners = new ArrayList<Listener>();
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.bukkit.plugin.java.JavaPlugin#onDisable()
|
||||
@ -64,6 +57,9 @@ public class NoCheatPlus extends JavaPlugin implements Listener {
|
||||
// Stop the lag measuring task.
|
||||
LagMeasureTask.cancel();
|
||||
|
||||
// Disable the packets workaround.
|
||||
PacketsWorkaround.disable();
|
||||
|
||||
// Cleanup the configuration manager.
|
||||
ConfigManager.cleanup();
|
||||
|
||||
@ -83,7 +79,6 @@ public class NoCheatPlus extends JavaPlugin implements Listener {
|
||||
ConfigManager.init(this);
|
||||
|
||||
// List the events listeners.
|
||||
listeners = new ArrayList<Listener>();
|
||||
listeners.add(new BlockBreakListener());
|
||||
listeners.add(new BlockInteractListener());
|
||||
listeners.add(new BlockPlaceListener());
|
||||
@ -93,6 +88,9 @@ public class NoCheatPlus extends JavaPlugin implements Listener {
|
||||
listeners.add(new MovingListener());
|
||||
listeners.add(new Workarounds());
|
||||
|
||||
// Enable the packets workaround.
|
||||
PacketsWorkaround.enable();
|
||||
|
||||
// Set up a task to monitor server lag.
|
||||
LagMeasureTask.start(this);
|
||||
|
||||
@ -126,31 +124,9 @@ public class NoCheatPlus extends JavaPlugin implements Listener {
|
||||
* @param event
|
||||
* the event handled
|
||||
*/
|
||||
@SuppressWarnings({"unchecked", "rawtypes"})
|
||||
@EventHandler(
|
||||
priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event) {
|
||||
|
||||
// Set the proxy of the player if enabled.
|
||||
if (ConfigManager.getConfigFile().getBoolean(ConfPaths.MISCELLANEOUS_USEPROXY)) {
|
||||
final EntityPlayer player = ((CraftPlayer) event.getPlayer()).getHandle();
|
||||
final NetServerHandler nsh = player.netServerHandler;
|
||||
final NetServerHandlerProxy proxy = new NetServerHandlerProxy(MinecraftServer.getServer(), nsh);
|
||||
player.netServerHandler = proxy;
|
||||
try {
|
||||
final Field packetListener = NetworkManager.class.getDeclaredField("packetListener");
|
||||
packetListener.setAccessible(true);
|
||||
packetListener.set(nsh.networkManager, proxy);
|
||||
final Field d = ServerConnection.class.getDeclaredField("d");
|
||||
d.setAccessible(true);
|
||||
final List handlerList = (List) d.get(MinecraftServer.getServer().ac());
|
||||
handlerList.remove(nsh);
|
||||
handlerList.add(proxy);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
// Check if we allow all the client mods.
|
||||
|
@ -11,7 +11,6 @@ import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import fr.neatmonster.nocheatplus.players.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.CheckUtils;
|
||||
|
||||
/*
|
||||
@ -91,12 +90,8 @@ public class ChatListener implements Listener {
|
||||
|
||||
// Protect some commands to prevent players for seeing which plugins are installed.
|
||||
if (ChatConfig.getConfig(player).protectPlugins)
|
||||
if ((command.equalsIgnoreCase("help") || command.equalsIgnoreCase("?"))
|
||||
&& !player.hasPermission(Permissions.ADMINISTRATION_BUKKIT_HELP)
|
||||
|| (command.equalsIgnoreCase("plugins") || command.equalsIgnoreCase("pl"))
|
||||
&& !player.hasPermission(Permissions.ADMINISTRATION_BUKKIT_PLUGINS)
|
||||
|| (command.equalsIgnoreCase("version") || command.equalsIgnoreCase("ver"))
|
||||
&& !player.hasPermission(Permissions.ADMINISTRATION_BUKKIT_VERSION)) {
|
||||
if ((command.equalsIgnoreCase("plugins") || command.equalsIgnoreCase("pl")) && !player.isOp()
|
||||
|| (command.equalsIgnoreCase("version") || command.equalsIgnoreCase("ver")) && !player.isOp()) {
|
||||
event.getPlayer().sendMessage(
|
||||
ChatColor.RED + "I'm sorry, but you do not have permission to perform this command. "
|
||||
+ "Please contact the server administrators if you believe that this is in error.");
|
||||
|
@ -42,7 +42,6 @@ public abstract class ConfPaths {
|
||||
public static final String MISCELLANEOUS_ALLOWCLIENTMODS = MISCELLANEOUS + "allowclientmods";
|
||||
public static final String MISCELLANEOUS_OPINCONSOLEONLY = MISCELLANEOUS + "opinconsoleonly";
|
||||
public static final String MISCELLANEOUS_PROTECTPLUGINS = MISCELLANEOUS + "protectplugins";
|
||||
public static final String MISCELLANEOUS_USEPROXY = MISCELLANEOUS + "useproxy";
|
||||
|
||||
private static final String CHECKS = "checks.";
|
||||
|
||||
|
@ -54,7 +54,6 @@ public class DefaultConfig extends ConfigFile {
|
||||
set(ConfPaths.MISCELLANEOUS_ALLOWCLIENTMODS, false);
|
||||
set(ConfPaths.MISCELLANEOUS_OPINCONSOLEONLY, false);
|
||||
set(ConfPaths.MISCELLANEOUS_PROTECTPLUGINS, true);
|
||||
set(ConfPaths.MISCELLANEOUS_USEPROXY, true);
|
||||
|
||||
/*
|
||||
* 888 88b, 888 888 888 88b, 888
|
||||
|
@ -0,0 +1,26 @@
|
||||
package fr.neatmonster.nocheatplus.packets;
|
||||
|
||||
import net.minecraft.server.Packet10Flying;
|
||||
|
||||
/*
|
||||
* M"""""""`YM MM'""""'YMM MM"""""""`YM MM"""""""`YM dP dP d88 a8888a
|
||||
* M mmmm. M M' .mmm. `M MM mmmmm M MM mmmmm M 88 88 88 d8' ..8b
|
||||
* M MMMMM M M MMMMMooM M' .M M' .M .d8888b. .d8888b. 88 .dP .d8888b. d8888P 88 88 .P 88
|
||||
* M MMMMM M M MMMMMMMM MM MMMMMMMM MM MMMMMMMM 88' `88 88' `"" 88888" 88ooood8 88 88 88 d' 88
|
||||
* M MMMMM M M. `MMM' .M MM MMMMMMMM MM MMMMMMMM 88. .88 88. ... 88 `8b. 88. ... 88 88 Y8'' .8P
|
||||
* M MMMMM M MM. .dM MM MMMMMMMM MM MMMMMMMM `88888P8 `88888P' dP `YP `88888P' dP d88P Y8888P
|
||||
* MMMMMMMMMMM MMMMMMMMMMM MMMMMMMMMMMM MMMMMMMMMMMM
|
||||
*
|
||||
* MM""""""""`M dP oo
|
||||
* MM mmmmmmmM 88
|
||||
* M' MMMM 88 dP dP dP 88d888b. .d8888b.
|
||||
* MM MMMMMMMM 88 88 88 88 88' `88 88' `88
|
||||
* MM MMMMMMMM 88 88. .88 88 88 88 88. .88
|
||||
* MM MMMMMMMM dP `8888P88 dP dP dP `8888P88
|
||||
* MMMMMMMMMMMM .88 .88
|
||||
* d8888P d8888P
|
||||
*/
|
||||
/**
|
||||
* A custom Packet10Flying.
|
||||
*/
|
||||
public class NCPPacket10Flying extends Packet10Flying {}
|
@ -0,0 +1,49 @@
|
||||
package fr.neatmonster.nocheatplus.packets;
|
||||
|
||||
import net.minecraft.server.NetHandler;
|
||||
import net.minecraft.server.NetServerHandler;
|
||||
import net.minecraft.server.Packet11PlayerPosition;
|
||||
|
||||
/*
|
||||
* M"""""""`YM MM'""""'YMM MM"""""""`YM MM"""""""`YM dP dP d88 d88
|
||||
* M mmmm. M M' .mmm. `M MM mmmmm M MM mmmmm M 88 88 88 88
|
||||
* M MMMMM M M MMMMMooM M' .M M' .M .d8888b. .d8888b. 88 .dP .d8888b. d8888P 88 88
|
||||
* M MMMMM M M MMMMMMMM MM MMMMMMMM MM MMMMMMMM 88' `88 88' `"" 88888" 88ooood8 88 88 88
|
||||
* M MMMMM M M. `MMM' .M MM MMMMMMMM MM MMMMMMMM 88. .88 88. ... 88 `8b. 88. ... 88 88 88
|
||||
* M MMMMM M MM. .dM MM MMMMMMMM MM MMMMMMMM `88888P8 `88888P' dP `YP `88888P' dP d88P d88P
|
||||
* MMMMMMMMMMM MMMMMMMMMMM MMMMMMMMMMMM MMMMMMMMMMMM
|
||||
*
|
||||
* MM"""""""`YM dP MM"""""""`YM oo dP oo
|
||||
* MM mmmmm M 88 MM mmmmm M 88
|
||||
* M' .M 88 .d8888b. dP dP .d8888b. 88d888b. M' .M .d8888b. .d8888b. dP d8888P dP .d8888b. 88d888b.
|
||||
* MM MMMMMMMM 88 88' `88 88 88 88ooood8 88' `88 MM MMMMMMMM 88' `88 Y8ooooo. 88 88 88 88' `88 88' `88
|
||||
* MM MMMMMMMM 88 88. .88 88. .88 88. ... 88 MM MMMMMMMM 88. .88 88 88 88 88 88. .88 88 88
|
||||
* MM MMMMMMMM dP `88888P8 `8888P88 `88888P' dP MM MMMMMMMM `88888P' `88888P' dP dP dP `88888P' dP dP
|
||||
* MMMMMMMMMMMM .88 MMMMMMMMMMMM
|
||||
* d8888P
|
||||
*/
|
||||
/**
|
||||
* A custom Packet11PlayerPosition.
|
||||
*/
|
||||
public class NCPPacket11PlayerPosition extends Packet11PlayerPosition {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.Packet10Flying#handle(net.minecraft.server.NetHandler)
|
||||
*/
|
||||
@Override
|
||||
public void handle(final NetHandler netHandler) {
|
||||
if (netHandler instanceof NetServerHandler && hasPos) {
|
||||
final NetServerHandler nsh = (NetServerHandler) netHandler;
|
||||
final double deltaX = Math.max(Math.abs(x), Math.abs(nsh.player.motX));
|
||||
final double deltaY = Math.max(Math.abs(y), Math.abs(nsh.player.motY));
|
||||
final double deltaZ = Math.max(Math.abs(z), Math.abs(nsh.player.motZ));
|
||||
final double delta = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;
|
||||
if (delta > 100D) {
|
||||
nsh.player.locX = x;
|
||||
nsh.player.locY = y;
|
||||
nsh.player.locZ = z;
|
||||
}
|
||||
}
|
||||
super.handle(netHandler);
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package fr.neatmonster.nocheatplus.packets;
|
||||
|
||||
import net.minecraft.server.Packet12PlayerLook;
|
||||
|
||||
/*
|
||||
* """""""`YM MM'""""'YMM MM"""""""`YM MM"""""""`YM dP dP d88 d8888b.
|
||||
* M mmmm. M M' .mmm. `M MM mmmmm M MM mmmmm M 88 88 88 `88
|
||||
* M MMMMM M M MMMMMooM M' .M M' .M .d8888b. .d8888b. 88 .dP .d8888b. d8888P 88 .aaadP'
|
||||
* M MMMMM M M MMMMMMMM MM MMMMMMMM MM MMMMMMMM 88' `88 88' `"" 88888" 88ooood8 88 88 88'
|
||||
* M MMMMM M M. `MMM' .M MM MMMMMMMM MM MMMMMMMM 88. .88 88. ... 88 `8b. 88. ... 88 88 88.
|
||||
* M MMMMM M MM. .dM MM MMMMMMMM MM MMMMMMMM `88888P8 `88888P' dP `YP `88888P' dP d88P Y88888P
|
||||
* MMMMMMMMMMM MMMMMMMMMMM MMMMMMMMMMMM MMMMMMMMMMMM
|
||||
*
|
||||
* MM"""""""`YM dP M""MMMMMMMM dP
|
||||
* MM mmmmm M 88 M MMMMMMMM 88
|
||||
* M' .M 88 .d8888b. dP dP .d8888b. 88d888b. M MMMMMMMM .d8888b. .d8888b. 88 .dP
|
||||
* MM MMMMMMMM 88 88' `88 88 88 88ooood8 88' `88 M MMMMMMMM 88' `88 88' `88 88888"
|
||||
* MM MMMMMMMM 88 88. .88 88. .88 88. ... 88 M MMMMMMMM 88. .88 88. .88 88 `8b.
|
||||
* MM MMMMMMMM dP `88888P8 `8888P88 `88888P' dP M M `88888P' `88888P' dP `YP
|
||||
* MMMMMMMMMMMM .88 MMMMMMMMMMM
|
||||
* d8888P
|
||||
*/
|
||||
/**
|
||||
* A custom Packet12PlayerLook.
|
||||
*/
|
||||
public class NCPPacket12PlayerLook extends Packet12PlayerLook {}
|
@ -0,0 +1,49 @@
|
||||
package fr.neatmonster.nocheatplus.packets;
|
||||
|
||||
import net.minecraft.server.NetHandler;
|
||||
import net.minecraft.server.NetServerHandler;
|
||||
import net.minecraft.server.Packet13PlayerLookMove;
|
||||
|
||||
/*
|
||||
* M"""""""`YM MM'""""'YMM MM"""""""`YM MM"""""""`YM dP dP d88 d8888b.
|
||||
* M mmmm. M M' .mmm. `M MM mmmmm M MM mmmmm M 88 88 88 `88
|
||||
* M MMMMM M M MMMMMooM M' .M M' .M .d8888b. .d8888b. 88 .dP .d8888b. d8888P 88 aaad8'
|
||||
* M MMMMM M M MMMMMMMM MM MMMMMMMM MM MMMMMMMM 88' `88 88' `"" 88888" 88ooood8 88 88 `88
|
||||
* M MMMMM M M. `MMM' .M MM MMMMMMMM MM MMMMMMMM 88. .88 88. ... 88 `8b. 88. ... 88 88 .88
|
||||
* M MMMMM M MM. .dM MM MMMMMMMM MM MMMMMMMM `88888P8 `88888P' dP `YP `88888P' dP d88P d88888P
|
||||
* MMMMMMMMMMM MMMMMMMMMMM MMMMMMMMMMMM MMMMMMMMMMMM
|
||||
*
|
||||
* MM"""""""`YM dP M""MMMMMMMM dP M"""""`'"""`YM
|
||||
* MM mmmmm M 88 M MMMMMMMM 88 M mm. mm. M
|
||||
* M' .M 88 .d8888b. dP dP .d8888b. 88d888b. M MMMMMMMM .d8888b. .d8888b. 88 .dP M MMM MMM M .d8888b. dP .dP .d8888b.
|
||||
* MM MMMMMMMM 88 88' `88 88 88 88ooood8 88' `88 M MMMMMMMM 88' `88 88' `88 88888" M MMM MMM M 88' `88 88 d8' 88ooood8
|
||||
* MM MMMMMMMM 88 88. .88 88. .88 88. ... 88 M MMMMMMMM 88. .88 88. .88 88 `8b. M MMM MMM M 88. .88 88 .88' 88. ...
|
||||
* MM MMMMMMMM dP `88888P8 `8888P88 `88888P' dP M M `88888P' `88888P' dP `YP M MMM MMM M `88888P' 8888P' `88888P'
|
||||
* MMMMMMMMMMMM .88 MMMMMMMMMMM MMMMMMMMMMMMMM
|
||||
* d8888P
|
||||
*/
|
||||
/**
|
||||
* A custom NCPPacket13PlayerLookMove.
|
||||
*/
|
||||
public class NCPPacket13PlayerLookMove extends Packet13PlayerLookMove {
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see net.minecraft.server.Packet10Flying#handle(net.minecraft.server.NetHandler)
|
||||
*/
|
||||
@Override
|
||||
public void handle(final NetHandler netHandler) {
|
||||
if (netHandler instanceof NetServerHandler && hasPos) {
|
||||
final NetServerHandler nsh = (NetServerHandler) netHandler;
|
||||
final double deltaX = Math.max(Math.abs(x), Math.abs(nsh.player.motX));
|
||||
final double deltaY = Math.max(Math.abs(y), Math.abs(nsh.player.motY));
|
||||
final double deltaZ = Math.max(Math.abs(z), Math.abs(nsh.player.motZ));
|
||||
final double delta = deltaX * deltaX + deltaY * deltaY + deltaZ * deltaZ;
|
||||
if (delta > 100D) {
|
||||
nsh.player.locX = x;
|
||||
nsh.player.locY = y;
|
||||
nsh.player.locZ = z;
|
||||
}
|
||||
}
|
||||
super.handle(netHandler);
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package fr.neatmonster.nocheatplus.packets;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.server.Packet;
|
||||
|
||||
/*
|
||||
* MM"""""""`YM dP dP
|
||||
* MM mmmmm M 88 88
|
||||
* M' .M .d8888b. .d8888b. 88 .dP .d8888b. d8888P .d8888b.
|
||||
* MM MMMMMMMM 88' `88 88' `"" 88888" 88ooood8 88 Y8ooooo.
|
||||
* MM MMMMMMMM 88. .88 88. ... 88 `8b. 88. ... 88 88
|
||||
* MM MMMMMMMM `88888P8 `88888P' dP `YP `88888P' dP `88888P'
|
||||
* MMMMMMMMMMMM
|
||||
*
|
||||
* M""MMM""MMM""M dP dP
|
||||
* M MMM MMM M 88 88
|
||||
* M MMP MMP M .d8888b. 88d888b. 88 .dP .d8888b. 88d888b. .d8888b. dP dP 88d888b. .d888b88
|
||||
* M MM' MM' .M 88' `88 88' `88 88888" 88' `88 88' `88 88' `88 88 88 88' `88 88' `88
|
||||
* M `' . '' .MM 88. .88 88 88 `8b. 88. .88 88 88. .88 88. .88 88 88 88. .88
|
||||
* M .d .dMMM `88888P' dP dP `YP `88888P8 dP `88888P' `88888P' dP dP `88888P8
|
||||
* MMMMMMMMMMMMMM
|
||||
*/
|
||||
/**
|
||||
* The packets workaround.
|
||||
*/
|
||||
public class PacketsWorkaround {
|
||||
|
||||
/** The old classes. */
|
||||
private static Map<Integer, Class<?>> oldClasses = new HashMap<Integer, Class<?>>();
|
||||
|
||||
/**
|
||||
* Disable the packets workaround.
|
||||
*/
|
||||
public static void disable() {
|
||||
for (final int packetId : oldClasses.keySet())
|
||||
replace(packetId, oldClasses.get(packetId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the packets workaround.
|
||||
*/
|
||||
public static void enable() {
|
||||
oldClasses.put(10, replace(10, NCPPacket10Flying.class));
|
||||
oldClasses.put(11, replace(11, NCPPacket11PlayerPosition.class));
|
||||
oldClasses.put(12, replace(12, NCPPacket12PlayerLook.class));
|
||||
oldClasses.put(13, replace(13, NCPPacket13PlayerLookMove.class));
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace a packet class.
|
||||
*
|
||||
* @param packetId
|
||||
* the packet id
|
||||
* @param newClass
|
||||
* the new class
|
||||
* @return the class
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
private static Class<?> replace(final int packetId, final Class<?> newClass) {
|
||||
final Class<?> oldClass = (Class<?>) Packet.l.d(packetId);
|
||||
Packet.l.a(packetId, newClass);
|
||||
try {
|
||||
final Field aField = Packet.class.getDeclaredField("a");
|
||||
aField.setAccessible(true);
|
||||
final Map a = (Map) aField.get(null);
|
||||
a.put(newClass, packetId);
|
||||
} catch (final Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return oldClass;
|
||||
}
|
||||
}
|
@ -13,7 +13,7 @@ package fr.neatmonster.nocheatplus.players;
|
||||
* The various permission nodes used by NoCheatPlus.
|
||||
*/
|
||||
public class Permissions {
|
||||
private static final String NOCHEATPLUS = "nocheatplus";
|
||||
private static final String NOCHEATPLUS = "nocheatplus";
|
||||
|
||||
/*
|
||||
* e Y8b 888 ,e, ,e, d8 d8 ,e,
|
||||
@ -22,18 +22,13 @@ public class Permissions {
|
||||
* d888888888b Y888 888 888 888 888 888 888 888 888 Y88D 888 888 ,ee 888 888 888 Y888 888P 888 888
|
||||
* d8888888b Y8b "88 888 888 888 888 888 888 888 888 d,dP 888 888 "88 888 888 888 "88 88" 888 888
|
||||
*/
|
||||
private static final String ADMINISTRATION = NOCHEATPLUS + ".admin";
|
||||
private static final String ADMINISTRATION = NOCHEATPLUS + ".admin";
|
||||
|
||||
private static final String ADMINISTRATION_BUKKIT = ADMINISTRATION + ".bukkit";
|
||||
public static final String ADMINISTRATION_BUKKIT_HELP = ADMINISTRATION_BUKKIT + ".help";
|
||||
public static final String ADMINISTRATION_BUKKIT_PLUGINS = ADMINISTRATION_BUKKIT + ".plugins";
|
||||
public static final String ADMINISTRATION_BUKKIT_VERSION = ADMINISTRATION_BUKKIT + ".version";
|
||||
public static final String ADMINISTRATION_INFO = ADMINISTRATION + ".info";
|
||||
public static final String ADMINISTRATION_NOTIFY = ADMINISTRATION + ".notify";
|
||||
public static final String ADMINISTRATION_RELOAD = ADMINISTRATION + ".reload";
|
||||
|
||||
public static final String ADMINISTRATION_INFO = ADMINISTRATION + ".info";
|
||||
public static final String ADMINISTRATION_NOTIFY = ADMINISTRATION + ".notify";
|
||||
public static final String ADMINISTRATION_RELOAD = ADMINISTRATION + ".reload";
|
||||
|
||||
private static final String CHECKS = NOCHEATPLUS + ".checks";
|
||||
private static final String CHECKS = NOCHEATPLUS + ".checks";
|
||||
|
||||
/*
|
||||
* 888 88b, 888 888 888 88b, 888
|
||||
@ -42,11 +37,11 @@ public class Permissions {
|
||||
* 888 88b, 888 Y888 888P Y888 , 888 b 888 88b, 888 888 , ,ee 888 888 b
|
||||
* 888 88P' 888 "88 88" "88,e8' 888 8b 888 88P' 888 "YeeP" "88 888 888 8b
|
||||
*/
|
||||
private static final String BLOCKBREAK = CHECKS + ".blockbreak";
|
||||
public static final String BLOCKBREAK_DIRECTION = BLOCKBREAK + ".direction";
|
||||
public static final String BLOCKBREAK_FASTBREAK = BLOCKBREAK + ".fastbreak";
|
||||
public static final String BLOCKBREAK_NOSWING = BLOCKBREAK + ".noswing";
|
||||
public static final String BLOCKBREAK_REACH = BLOCKBREAK + ".reach";
|
||||
private static final String BLOCKBREAK = CHECKS + ".blockbreak";
|
||||
public static final String BLOCKBREAK_DIRECTION = BLOCKBREAK + ".direction";
|
||||
public static final String BLOCKBREAK_FASTBREAK = BLOCKBREAK + ".fastbreak";
|
||||
public static final String BLOCKBREAK_NOSWING = BLOCKBREAK + ".noswing";
|
||||
public static final String BLOCKBREAK_REACH = BLOCKBREAK + ".reach";
|
||||
|
||||
/*
|
||||
* 888 88b, 888 888 888 d8 d8
|
||||
@ -55,9 +50,9 @@ public class Permissions {
|
||||
* 888 88b, 888 Y888 888P Y888 , 888 b 888 888 888 888 888 , 888 ,ee 888 Y888 , 888
|
||||
* 888 88P' 888 "88 88" "88,e8' 888 8b 888 888 888 888 "YeeP" 888 "88 888 "88,e8' 888
|
||||
*/
|
||||
private static final String BLOCKINTERACT = CHECKS + ".blockinteract";
|
||||
public static final String BLOCKINTERACT_DIRECTION = BLOCKINTERACT + ".direction";
|
||||
public static final String BLOCKINTERACT_REACH = BLOCKINTERACT + ".reach";
|
||||
private static final String BLOCKINTERACT = CHECKS + ".blockinteract";
|
||||
public static final String BLOCKINTERACT_DIRECTION = BLOCKINTERACT + ".direction";
|
||||
public static final String BLOCKINTERACT_REACH = BLOCKINTERACT + ".reach";
|
||||
|
||||
/*
|
||||
* 888 88b, 888 888 888 88e 888
|
||||
@ -66,12 +61,12 @@ public class Permissions {
|
||||
* 888 88b, 888 Y888 888P Y888 , 888 b 888 888 ,ee 888 Y888 , 888 ,
|
||||
* 888 88P' 888 "88 88" "88,e8' 888 8b 888 888 "88 888 "88,e8' "YeeP"
|
||||
*/
|
||||
private static final String BLOCKPLACE = CHECKS + ".blockplace";
|
||||
public static final String BLOCKPLACE_DIRECTION = BLOCKPLACE + ".direction";
|
||||
public static final String BLOCKPLACE_FASTPLACE = BLOCKPLACE + ".fastplace";
|
||||
public static final String BLOCKPLACE_NOSWING = BLOCKPLACE + ".noswing";
|
||||
public static final String BLOCKPLACE_REACH = BLOCKPLACE + ".reach";
|
||||
public static final String BLOCKPLACE_SPEED = BLOCKPLACE + ".speed";
|
||||
private static final String BLOCKPLACE = CHECKS + ".blockplace";
|
||||
public static final String BLOCKPLACE_DIRECTION = BLOCKPLACE + ".direction";
|
||||
public static final String BLOCKPLACE_FASTPLACE = BLOCKPLACE + ".fastplace";
|
||||
public static final String BLOCKPLACE_NOSWING = BLOCKPLACE + ".noswing";
|
||||
public static final String BLOCKPLACE_REACH = BLOCKPLACE + ".reach";
|
||||
public static final String BLOCKPLACE_SPEED = BLOCKPLACE + ".speed";
|
||||
|
||||
/*
|
||||
* e88'Y88 888 d8
|
||||
@ -80,9 +75,9 @@ public class Permissions {
|
||||
* Y888 ,d 888 888 ,ee 888 888
|
||||
* "88,d88 888 888 "88 888 888
|
||||
*/
|
||||
private static final String CHAT = CHECKS + ".chat";
|
||||
public static final String CHAT_COLOR = CHAT + ".color";
|
||||
public static final String CHAT_NOPWNAGE = CHAT + ".nopwnage";
|
||||
private static final String CHAT = CHECKS + ".chat";
|
||||
public static final String CHAT_COLOR = CHAT + ".color";
|
||||
public static final String CHAT_NOPWNAGE = CHAT + ".nopwnage";
|
||||
|
||||
/*
|
||||
* 888'Y88 ,e, 888 d8
|
||||
@ -93,16 +88,16 @@ public class Permissions {
|
||||
* , 88P
|
||||
* "8",P"
|
||||
*/
|
||||
private static final String FIGHT = CHECKS + ".fight";
|
||||
public static final String FIGHT_ANGLE = FIGHT + ".angle";
|
||||
public static final String FIGHT_CRITICAL = FIGHT + ".critical";
|
||||
public static final String FIGHT_DIRECTION = FIGHT + ".direction";
|
||||
public static final String FIGHT_GODMODE = FIGHT + ".godmode";
|
||||
public static final String FIGHT_INSTANTHEAL = FIGHT + ".instantheal";
|
||||
public static final String FIGHT_KNOCKBACK = FIGHT + ".knockback";
|
||||
public static final String FIGHT_NOSWING = FIGHT + ".noswing";
|
||||
public static final String FIGHT_REACH = FIGHT + ".reach";
|
||||
public static final String FIGHT_SPEED = FIGHT + ".speed";
|
||||
private static final String FIGHT = CHECKS + ".fight";
|
||||
public static final String FIGHT_ANGLE = FIGHT + ".angle";
|
||||
public static final String FIGHT_CRITICAL = FIGHT + ".critical";
|
||||
public static final String FIGHT_DIRECTION = FIGHT + ".direction";
|
||||
public static final String FIGHT_GODMODE = FIGHT + ".godmode";
|
||||
public static final String FIGHT_INSTANTHEAL = FIGHT + ".instantheal";
|
||||
public static final String FIGHT_KNOCKBACK = FIGHT + ".knockback";
|
||||
public static final String FIGHT_NOSWING = FIGHT + ".noswing";
|
||||
public static final String FIGHT_REACH = FIGHT + ".reach";
|
||||
public static final String FIGHT_SPEED = FIGHT + ".speed";
|
||||
|
||||
/*
|
||||
* 888 d8
|
||||
@ -113,10 +108,10 @@ public class Permissions {
|
||||
* 888
|
||||
* 888
|
||||
*/
|
||||
private static final String INVENTORY = CHECKS + ".inventory";
|
||||
public static final String INVENTORY_DROP = INVENTORY + ".drop";
|
||||
public static final String INVENTORY_INSTANTBOW = INVENTORY + ".instantbow";
|
||||
public static final String INVENTORY_INSTANTEAT = INVENTORY + ".instanteat";
|
||||
private static final String INVENTORY = CHECKS + ".inventory";
|
||||
public static final String INVENTORY_DROP = INVENTORY + ".drop";
|
||||
public static final String INVENTORY_INSTANTBOW = INVENTORY + ".instantbow";
|
||||
public static final String INVENTORY_INSTANTEAT = INVENTORY + ".instanteat";
|
||||
|
||||
/*
|
||||
* e e ,e,
|
||||
@ -127,17 +122,17 @@ public class Permissions {
|
||||
* , 88P
|
||||
* "8",P"
|
||||
*/
|
||||
private static final String MOVING = CHECKS + ".moving";
|
||||
public static final String MOVING_BOATSANYWHERE = MOVING + ".boatsanywhere";
|
||||
public static final String MOVING_CREATIVEFLY = MOVING + ".creativefly";
|
||||
public static final String MOVING_MOREPACKETS = MOVING + ".morepackets";
|
||||
public static final String MOVING_MOREPACKETSVEHICLE = MOVING + ".morepacketsvehicle";
|
||||
public static final String MOVING_NOFALL = MOVING + ".nofall";
|
||||
public static final String MOVING_OVERRIDEBUKKIT = MOVING + ".overridebukkit";
|
||||
public static final String MOVING_SURVIVALFLY = MOVING + ".survivalfly";
|
||||
public static final String MOVING_SURVIVALFLY_BLOCKING = MOVING_SURVIVALFLY + ".blocking";
|
||||
public static final String MOVING_SURVIVALFLY_SNEAKING = MOVING_SURVIVALFLY + ".sneaking";
|
||||
public static final String MOVING_SURVIVALFLY_SPRINTING = MOVING_SURVIVALFLY + ".sprinting";
|
||||
private static final String MOVING = CHECKS + ".moving";
|
||||
public static final String MOVING_BOATSANYWHERE = MOVING + ".boatsanywhere";
|
||||
public static final String MOVING_CREATIVEFLY = MOVING + ".creativefly";
|
||||
public static final String MOVING_MOREPACKETS = MOVING + ".morepackets";
|
||||
public static final String MOVING_MOREPACKETSVEHICLE = MOVING + ".morepacketsvehicle";
|
||||
public static final String MOVING_NOFALL = MOVING + ".nofall";
|
||||
public static final String MOVING_OVERRIDEBUKKIT = MOVING + ".overridebukkit";
|
||||
public static final String MOVING_SURVIVALFLY = MOVING + ".survivalfly";
|
||||
public static final String MOVING_SURVIVALFLY_BLOCKING = MOVING_SURVIVALFLY + ".blocking";
|
||||
public static final String MOVING_SURVIVALFLY_SNEAKING = MOVING_SURVIVALFLY + ".sneaking";
|
||||
public static final String MOVING_SURVIVALFLY_SPRINTING = MOVING_SURVIVALFLY + ".sprinting";
|
||||
|
||||
/*
|
||||
* e e 888 ,e, dP,e, ,e, d8 ,e,
|
||||
@ -146,32 +141,32 @@ public class Permissions {
|
||||
* d8b Y8b Y8b Y888 888P Y888 888 888 888 888 Y888 , ,ee 888 888 888 Y888 888P 888 888 Y88D
|
||||
* d888b Y8b Y8b "88 88" "88 888 888 888 888 "88,e8' "88 888 888 888 "88 88" 888 888 d,dP
|
||||
*/
|
||||
private static final String MODS = NOCHEATPLUS + ".mods";
|
||||
private static final String MODS = NOCHEATPLUS + ".mods";
|
||||
|
||||
private static final String CJB = MODS + ".cjb";
|
||||
public static final String CJB_FLY = CJB + ".fly";
|
||||
public static final String CJB_RADAR = CJB + ".radar";
|
||||
public static final String CJB_XRAY = CJB + ".xray";
|
||||
private static final String CJB = MODS + ".cjb";
|
||||
public static final String CJB_FLY = CJB + ".fly";
|
||||
public static final String CJB_RADAR = CJB + ".radar";
|
||||
public static final String CJB_XRAY = CJB + ".xray";
|
||||
|
||||
private static final String MINECRAFTAUTOMAP = MODS + ".minecraftautomap";
|
||||
public static final String MINECRAFTAUTOMAP_CAVE = MINECRAFTAUTOMAP + ".cave";
|
||||
public static final String MINECRAFTAUTOMAP_ORES = MINECRAFTAUTOMAP + ".ores";
|
||||
public static final String MINECRAFTAUTOMAP_RADAR = MINECRAFTAUTOMAP + ".radar";
|
||||
private static final String MINECRAFTAUTOMAP = MODS + ".minecraftautomap";
|
||||
public static final String MINECRAFTAUTOMAP_CAVE = MINECRAFTAUTOMAP + ".cave";
|
||||
public static final String MINECRAFTAUTOMAP_ORES = MINECRAFTAUTOMAP + ".ores";
|
||||
public static final String MINECRAFTAUTOMAP_RADAR = MINECRAFTAUTOMAP + ".radar";
|
||||
|
||||
private static final String REI = MODS + ".rei";
|
||||
public static final String REI_CAVE = REI + ".cave";
|
||||
public static final String REI_RADAR = REI + ".radar";
|
||||
private static final String REI = MODS + ".rei";
|
||||
public static final String REI_CAVE = REI + ".cave";
|
||||
public static final String REI_RADAR = REI + ".radar";
|
||||
|
||||
private static final String SMARTMOVING = MODS + ".smartmoving";
|
||||
public static final String SMARTMOVING_CLIMBING = SMARTMOVING + ".climbing";
|
||||
public static final String SMARTMOVING_CRAWLING = SMARTMOVING + ".crawling";
|
||||
public static final String SMARTMOVING_FLYING = SMARTMOVING + ".flying";
|
||||
public static final String SMARTMOVING_JUMPING = SMARTMOVING + ".jumping";
|
||||
public static final String SMARTMOVING_SLIDING = SMARTMOVING + ".sliding";
|
||||
public static final String SMARTMOVING_SWIMMING = SMARTMOVING + ".swimming";
|
||||
private static final String SMARTMOVING = MODS + ".smartmoving";
|
||||
public static final String SMARTMOVING_CLIMBING = SMARTMOVING + ".climbing";
|
||||
public static final String SMARTMOVING_CRAWLING = SMARTMOVING + ".crawling";
|
||||
public static final String SMARTMOVING_FLYING = SMARTMOVING + ".flying";
|
||||
public static final String SMARTMOVING_JUMPING = SMARTMOVING + ".jumping";
|
||||
public static final String SMARTMOVING_SLIDING = SMARTMOVING + ".sliding";
|
||||
public static final String SMARTMOVING_SWIMMING = SMARTMOVING + ".swimming";
|
||||
|
||||
private static final String ZOMBE = MODS + ".zombe";
|
||||
public static final String ZOMBE_FLY = ZOMBE + ".fly";
|
||||
public static final String ZOMBE_NOCLIP = ZOMBE + ".noclip";
|
||||
public static final String ZOMBE_CHEAT = ZOMBE + ".cheat";
|
||||
private static final String ZOMBE = MODS + ".zombe";
|
||||
public static final String ZOMBE_FLY = ZOMBE + ".fly";
|
||||
public static final String ZOMBE_NOCLIP = ZOMBE + ".noclip";
|
||||
public static final String ZOMBE_CHEAT = ZOMBE + ".cheat";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user