Added NoCheatPlus hook for double jump fly hack prevention.

This commit is contained in:
Jonathan Williams 2015-02-04 21:52:14 -08:00
parent fabf385a57
commit 44bab01e33
3 changed files with 48 additions and 0 deletions

Binary file not shown.

View File

@ -13,5 +13,6 @@
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/jooq-3.4.2.jar"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/craftbukkit.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/Mineplex.Core.Common"/>
<classpathentry kind="var" path="REPO_DIR/Plugins/Libraries/NoCheatPlus.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>

View File

@ -4,6 +4,8 @@ import java.lang.reflect.Field;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
import mineplex.core.common.DummyEntity;
import mineplex.core.common.util.NautHashMap;
@ -32,8 +34,12 @@ import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.plugin.java.JavaPlugin;
import fr.neatmonster.nocheatplus.NCPAPIProvider;
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
public class CustomTagFix extends MiniPlugin implements IPacketHandler
{
private NautHashMap<String, NautHashMap<Integer, Integer>> _entityMap = new NautHashMap<String, NautHashMap<Integer, Integer>>();
@ -42,6 +48,8 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
private HashSet<String> _loggedIn = new HashSet<String>();
private HashSet<Integer> _ignoreSkulls = new HashSet<Integer>();
private NautHashMap<UUID, Long> _exemptTimeMap = new NautHashMap<UUID, Long>();
private Field _destroyId;
public CustomTagFix(JavaPlugin plugin, PacketHandler packetHandler)
@ -71,6 +79,45 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
_loggedIn.remove(event.getPlayer());
}
@EventHandler
public void ncpExempt(final PlayerToggleFlightEvent event)
{
if (_exemptTimeMap.containsKey(event.getPlayer().getUniqueId()))
{
_exemptTimeMap.put(event.getPlayer().getUniqueId(), System.currentTimeMillis() + 1500);
return;
}
NCPExemptionManager.exemptPermanently(event.getPlayer());
_exemptTimeMap.put(event.getPlayer().getUniqueId(), System.currentTimeMillis() + 1500);
event.getPlayer().sendMessage(event.getPlayer().getName() + " ignored.");
}
@EventHandler
public void unexempt(UpdateEvent event)
{
if (event.getType() != UpdateType.TICK)
return;
for (Iterator<Entry<UUID, Long>> iterator = _exemptTimeMap.entrySet().iterator(); iterator.hasNext();)
{
Entry<UUID, Long> entry = iterator.next();
if (System.currentTimeMillis() > entry.getValue())
{
iterator.remove();
NCPExemptionManager.unexempt(entry.getKey());
Player player = Bukkit.getPlayer(entry.getKey());
if (player != null)
{
player.sendMessage(player.getName() + " not ignored.");
}
}
}
}
@EventHandler
public void cleanMap(UpdateEvent event)
{