Permalink
Browse files

Added an NSH hook to make sure exiting fly mode is smooth.

  • Loading branch information...
1 parent 08871c5 commit 65e050911792f8275c06b5cd97e8685bbfffb865 @gravitylow committed May 22, 2012
@@ -185,6 +185,7 @@ public int getValue()
{
String name = player.getName();
manager.getPlayerManager().setLevel(player,config.getLevel(name));
+ manager.getBackend().addNSH(player);
}
}
@@ -153,17 +153,19 @@ public void onPlayerAnimation(PlayerAnimationEvent event)
public void onPlayerJoin(PlayerJoinEvent event)
{
Player player = event.getPlayer();
+ backend.addNSH(player);
+ String section = "\u00a7";
if(checkManager.willCheck(player, CheckType.ZOMBE_FLY))
{
- player.sendMessage("§f §f §1 §0 §2 §4");
+ player.sendMessage(section+"f "+section+"f "+section+"1 "+section+"0 "+section+"2 "+section+"4");
}
if(checkManager.willCheck(player, CheckType.ZOMBE_CHEAT))
{
- player.sendMessage("§f §f §2 §0 §4 §8");
+ player.sendMessage(section+"f "+section+"f "+section+"2 "+section+"0 "+section+"4 "+section+"8");
}
if(checkManager.willCheck(player, CheckType.ZOMBE_NOCLIP))
{
- player.sendMessage("§f §f §4 §0 §9 §6");
+ player.sendMessage(section+"f "+section+"f "+section+"4 "+section+"0 "+section+"9 "+section+"6");
}
backend.logJoin(event.getPlayer());
if(!getPlayerManager().hasLevel(player))
@@ -22,19 +22,23 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import net.minecraft.server.EntityPlayer;
import org.bukkit.ChatColor;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
+import org.bukkit.craftbukkit.CraftServer;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerToggleSprintEvent;
public class Backend
{
public static final int ENTERED_EXTITED_TIME = 20;
+ public static final int EXIT_FLY_TIME = 40;
public static final int INSTANT_BREAK_TIME = 20;
public static final int JOIN_TIME = 40;
public static final int DROPPED_ITEM_TIME = 2;
@@ -539,6 +543,11 @@ public void logEnterExit(final Player player)
logEvent(movingExempt,player,ENTERED_EXTITED_TIME);
}
+ public void logExitFly(final Player player)
+ {
+ logEvent(movingExempt,player,EXIT_FLY_TIME);
+ }
+
public void logJoin(final Player player)
{
logEvent(movingExempt,player,JOIN_TIME);
@@ -619,5 +628,14 @@ private void checkChatLevel(Player player, int amount)
micromanage.getPlugin().getServer().broadcastMessage(ChatColor.RED+player.getName()+" was banned for spamming.");
}
}
- }
+ }
+
+ public void addNSH(Player player)
+ {
+ EntityPlayer ePlayer = ((CraftPlayer)player).getHandle();
+ NSH nsh = new NSH(((CraftServer)player.getServer()).getHandle().server, ePlayer.netServerHandler.networkManager, ePlayer);
+ ((CraftPlayer)player).getHandle().netServerHandler = nsh;
+ ((CraftPlayer)player).getHandle().netServerHandler.networkManager.a(nsh);
+ ((CraftServer)player.getServer()).getServer().networkListenThread.a(nsh);
+ }
}
@@ -0,0 +1,30 @@
+package net.h31ix.anticheat.manage;
+
+import net.h31ix.anticheat.api.AnticheatAPI;
+import net.minecraft.server.EntityPlayer;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.NetServerHandler;
+import net.minecraft.server.NetworkManager;
+import net.minecraft.server.Packet202Abilities;
+
+public class NSH extends NetServerHandler
+{
+
+ public NSH(MinecraftServer server, NetworkManager manager, EntityPlayer player)
+ {
+ super(server, manager, player);
+ }
+
+ @Override
+ public void a(Packet202Abilities packet202abilities)
+ {
+ if(this.player.abilities.isFlying)
+ {
+ if(!packet202abilities.b && this.player.abilities.canFly)
+ {
+ AnticheatAPI.getManager().getBackend().logExitFly(player.getBukkitEntity().getPlayer());
+ }
+ }
+ this.player.abilities.isFlying = packet202abilities.b && this.player.abilities.canFly;
+ }
+}

9 comments on commit 65e0509

md-5 replied May 24, 2012

And now you wait for some guy to want Spout support. Trust me it happens. Maybe some people will also want my NoClip support :P I can be responsible for that.

Contributor

SuperSpyTX replied May 24, 2012

@md-5 Spout is something i barf in my sink at home.

md-5 replied May 24, 2012

True dat :P

Owner

gravitylow replied May 24, 2012

The way I see it, this is a bukkit plugin, not spout. If people want spout they can fork and re-code :D

md-5 replied May 25, 2012

I meant SpoutPlugin :P

Contributor

SuperSpyTX replied May 25, 2012

@md-5 well then I have to add detection for spout then in my AntiBot plugin lololol.

Owner

gravitylow replied May 25, 2012

@md-5 yeah I know, and I don't mean to be all like "EVERYTHING THAT EVER WILL CONFLICT WITH ANTICHEAT SHOULD JUST GO AWAY" but spout/spoutplugin make such radically different changes to the system (and I don't really like the spout API and don't want to have it as a dependency) that it's a bit hard to be using it and expect everything to work as well as it does on bukkit

md-5 replied May 25, 2012

I only said it because people nagged me to do it for my NoclipPlugin

Owner

gravitylow replied May 25, 2012

Fair enough :P

Please sign in to comment.