mirror of
https://github.com/NoCheatPlus/NoCheatPlus.git
synced 2025-01-20 06:21:23 +01:00
Removed the packets workaround: too much troubles. Changed reach
distance, less false positives should be thrown now. Added a nice message when an operator joins if an update is available.
This commit is contained in:
parent
664fdd1374
commit
4633fee6a5
@ -1,9 +1,13 @@
|
||||
package fr.neatmonster.nocheatplus;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -29,7 +33,6 @@ import fr.neatmonster.nocheatplus.metrics.Metrics.Graph;
|
||||
import fr.neatmonster.nocheatplus.metrics.Metrics.Plotter;
|
||||
import fr.neatmonster.nocheatplus.metrics.MetricsData;
|
||||
import fr.neatmonster.nocheatplus.metrics.MetricsData.TicksPlotter;
|
||||
import fr.neatmonster.nocheatplus.packets.PacketsWorkaround;
|
||||
import fr.neatmonster.nocheatplus.players.Permissions;
|
||||
import fr.neatmonster.nocheatplus.utilities.LagMeasureTask;
|
||||
|
||||
@ -53,6 +56,9 @@ public class NoCheatPlus extends JavaPlugin implements Listener {
|
||||
/** The listeners. */
|
||||
private final List<Listener> listeners = new ArrayList<Listener>();
|
||||
|
||||
/** The new version build number. */
|
||||
private int newVersion = 0;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.bukkit.plugin.java.JavaPlugin#onDisable()
|
||||
*/
|
||||
@ -63,9 +69,6 @@ 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();
|
||||
|
||||
@ -94,9 +97,6 @@ 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);
|
||||
|
||||
@ -152,6 +152,21 @@ public class NoCheatPlus extends JavaPlugin implements Listener {
|
||||
|
||||
// Tell the server administrator that we finished loading NoCheatPlus now.
|
||||
System.out.println("[NoCheatPlus] Version " + getDescription().getVersion() + " is enabled.");
|
||||
|
||||
// Check for updates.
|
||||
try {
|
||||
final Integer oldVersion = Integer.parseInt(getDescription().getVersion().split("-b")[1]);
|
||||
final URL url = new URL("http://nocheatplus.org:8080/job/NoCheatPlus/lastSuccessfulBuild/api/json");
|
||||
final BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(url.openConnection()
|
||||
.getInputStream()));
|
||||
String content = "", inputLine = "";
|
||||
while ((inputLine = bufferedReader.readLine()) != null)
|
||||
content += inputLine;
|
||||
bufferedReader.close();
|
||||
final Integer newVersion = Integer.parseInt(content.split("\"number\":")[1].split(",")[0]);
|
||||
if (oldVersion < newVersion)
|
||||
this.newVersion = newVersion;
|
||||
} catch (final Exception e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -177,82 +192,92 @@ public class NoCheatPlus extends JavaPlugin implements Listener {
|
||||
public void onPlayerJoin(final PlayerJoinEvent event) {
|
||||
final Player player = event.getPlayer();
|
||||
|
||||
String message = "";
|
||||
|
||||
// Display a message about the new version if relevant.
|
||||
if (newVersion > 0 && player.hasPermission(Permissions.ADMINISTRATION_NOTIFY))
|
||||
message += ChatColor.RED + "NCP: " + ChatColor.WHITE + "A new version is available! (Build #" + newVersion
|
||||
+ ".)";
|
||||
|
||||
// Check if we allow all the client mods.
|
||||
final boolean allowAll = ConfigManager.getConfigFile().getBoolean(ConfPaths.MISCELLANEOUS_ALLOWCLIENTMODS);
|
||||
String message = "";
|
||||
|
||||
// Allow Rei's Minimap's cave mode.
|
||||
if (allowAll || player.hasPermission(Permissions.REI_CAVE))
|
||||
message = message + "§0§0§1§e§f";
|
||||
message += "§0§0§1§e§f";
|
||||
|
||||
// Allow Rei's Minimap's radar.
|
||||
if (allowAll || player.hasPermission(Permissions.REI_RADAR))
|
||||
message = message + "§0§0§2§3§4§5§6§7§e§f";
|
||||
message += "§0§0§2§3§4§5§6§7§e§f";
|
||||
|
||||
// If all the client mods are allowed, no need to go any further.
|
||||
if (allowAll)
|
||||
if (allowAll) {
|
||||
if (!message.equals(""))
|
||||
player.sendMessage(message);
|
||||
return;
|
||||
}
|
||||
|
||||
// Disable Zombe's fly mod.
|
||||
if (!player.hasPermission(Permissions.ZOMBE_FLY))
|
||||
message = message + "§f §f §1 §0 §2 §4";
|
||||
message += "§f §f §1 §0 §2 §4";
|
||||
|
||||
// Disable Zombe's noclip.
|
||||
if (!player.hasPermission(Permissions.ZOMBE_NOCLIP))
|
||||
message = message + "§f §f §4 §0 §9 §6";
|
||||
message += "§f §f §4 §0 §9 §6";
|
||||
|
||||
// Disable Zombe's cheat.
|
||||
if (!player.hasPermission(Permissions.ZOMBE_CHEAT))
|
||||
message = message + "§f §f §2 §0 §4 §8";
|
||||
message += "§f §f §2 §0 §4 §8";
|
||||
|
||||
// Disable CJB's fly mod.
|
||||
if (!player.hasPermission(Permissions.CJB_FLY))
|
||||
message = message + "§3 §9 §2 §0 §0 §1";
|
||||
message += "§3 §9 §2 §0 §0 §1";
|
||||
|
||||
// Disable CJB's xray.
|
||||
if (!player.hasPermission(Permissions.CJB_XRAY))
|
||||
message = message + "§3 §9 §2 §0 §0 §2";
|
||||
message += "§3 §9 §2 §0 §0 §2";
|
||||
|
||||
// Disable CJB's radar.
|
||||
if (!player.hasPermission(Permissions.CJB_RADAR))
|
||||
message = message + "§3 §9 §2 §0 §0 §3";
|
||||
message += "§3 §9 §2 §0 §0 §3";
|
||||
|
||||
// Disable Minecraft AutoMap's ores.
|
||||
if (!player.hasPermission(Permissions.MINECRAFTAUTOMAP_ORES))
|
||||
message = message + "§0§0§1§f§e";
|
||||
message += "§0§0§1§f§e";
|
||||
|
||||
// Disable Minecraft AutoMap's cave mode.
|
||||
if (!player.hasPermission(Permissions.MINECRAFTAUTOMAP_CAVE))
|
||||
message = message + "§0§0§2§f§e";
|
||||
message += "§0§0§2§f§e";
|
||||
|
||||
// Disable Minecraft AutoMap's radar.
|
||||
if (!player.hasPermission(Permissions.MINECRAFTAUTOMAP_RADAR))
|
||||
message = message + "§0§0§3§4§5§6§7§8§f§e";
|
||||
message += "§0§0§3§4§5§6§7§8§f§e";
|
||||
|
||||
// Disable Smart Moving's climbing.
|
||||
if (!player.hasPermission(Permissions.SMARTMOVING_CLIMBING))
|
||||
message = message + "§0§1§0§1§2§f§f";
|
||||
message += "§0§1§0§1§2§f§f";
|
||||
|
||||
// Disable Smart Moving's climbing.
|
||||
if (!player.hasPermission(Permissions.SMARTMOVING_SWIMMING))
|
||||
message = message + "§0§1§3§4§f§f";
|
||||
message += "§0§1§3§4§f§f";
|
||||
|
||||
// Disable Smart Moving's climbing.
|
||||
if (!player.hasPermission(Permissions.SMARTMOVING_CRAWLING))
|
||||
message = message + "§0§1§5§f§f";
|
||||
message += "§0§1§5§f§f";
|
||||
|
||||
// Disable Smart Moving's climbing.
|
||||
if (!player.hasPermission(Permissions.SMARTMOVING_SLIDING))
|
||||
message = message + "§0§1§6§f§f";
|
||||
message += "§0§1§6§f§f";
|
||||
|
||||
// Disable Smart Moving's climbing.
|
||||
if (!player.hasPermission(Permissions.SMARTMOVING_JUMPING))
|
||||
message = message + "§0§1§8§9§a§b§f§f";
|
||||
message += "§0§1§8§9§a§b§f§f";
|
||||
|
||||
// Disable Smart Moving's climbing.
|
||||
if (!player.hasPermission(Permissions.SMARTMOVING_FLYING))
|
||||
message = message + "§0§1§7§f§f";
|
||||
message += "§0§1§7§f§f";
|
||||
|
||||
if (!message.equals(""))
|
||||
player.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class BlockBreakData implements CheckData {
|
||||
public long fastBreakDamageTime = System.currentTimeMillis();
|
||||
|
||||
// Data of the no swing check.
|
||||
public boolean noSwingArmSwung;
|
||||
public boolean noSwingArmSwung = true;
|
||||
|
||||
// Data of the reach check.
|
||||
public double reachDistance;
|
||||
|
@ -29,7 +29,7 @@ public class Reach extends Check {
|
||||
public final double CREATIVE_DISTANCE = 5.6D;
|
||||
|
||||
/** The maximum distance allowed to interact with a block in survival mode. */
|
||||
public final double SURVIVAL_DISTANCE = 5.1D;
|
||||
public final double SURVIVAL_DISTANCE = 5.2D;
|
||||
|
||||
/**
|
||||
* Instantiates a new reach check.
|
||||
|
@ -29,7 +29,7 @@ public class Reach extends Check {
|
||||
public final double CREATIVE_DISTANCE = 5.6D;
|
||||
|
||||
/** The maximum distance allowed to interact with a block in survival mode. */
|
||||
public final double SURVIVAL_DISTANCE = 5.1D;
|
||||
public final double SURVIVAL_DISTANCE = 5.2D;
|
||||
|
||||
/**
|
||||
* Instantiates a new reach check.
|
||||
|
@ -66,7 +66,7 @@ public class BlockPlaceData implements CheckData {
|
||||
public boolean fastPlaceLastRefused;
|
||||
|
||||
// Data of the no swing check.
|
||||
public boolean noSwingArmSwung;
|
||||
public boolean noSwingArmSwung = true;
|
||||
|
||||
// Data of the reach check.
|
||||
public double reachDistance;
|
||||
|
@ -29,7 +29,7 @@ public class Reach extends Check {
|
||||
public final double CREATIVE_DISTANCE = 5.6D;
|
||||
|
||||
/** The maximum distance allowed to interact with a block in survival mode. */
|
||||
public final double SURVIVAL_DISTANCE = 5.1D;
|
||||
public final double SURVIVAL_DISTANCE = 5.2D;
|
||||
|
||||
/**
|
||||
* Instantiates a new reach check.
|
||||
|
@ -16,7 +16,8 @@ import fr.neatmonster.nocheatplus.metrics.MetricsData;
|
||||
* MMMM MMMMMMMMMMMM
|
||||
*/
|
||||
/**
|
||||
* The InstantHeal check should find out if a player tried to artificially accelerate the health regeneration by food.
|
||||
* The InstantHeal check should find out if a player has tried to artificially accelerate the health regeneration by
|
||||
* food.
|
||||
*/
|
||||
public class InstantHeal extends Check {
|
||||
|
||||
|
@ -29,7 +29,7 @@ public class Reach extends Check {
|
||||
public final double CREATIVE_DISTANCE = 6D;
|
||||
|
||||
/** The maximum distance allowed to interact with an entity in survival mode. */
|
||||
public final double SURVIVAL_DISTANCE = 4D;
|
||||
public final double SURVIVAL_DISTANCE = 4.25D;
|
||||
|
||||
/**
|
||||
* Instantiates a new reach check.
|
||||
|
@ -1,26 +0,0 @@
|
||||
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 {}
|
@ -1,49 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,26 +0,0 @@
|
||||
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 {}
|
@ -1,49 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user