Fixed RB with exemption in NCP hooks.

This commit is contained in:
Jonathan Williams 2015-02-14 00:48:07 -08:00
parent beac0b4828
commit 6ff0928fbd

View File

@ -38,10 +38,14 @@ import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.event.player.PlayerVelocityEvent;
import org.bukkit.plugin.java.JavaPlugin;
import fr.neatmonster.nocheatplus.NCPAPIProvider;
import fr.neatmonster.nocheatplus.checks.CheckType;
import fr.neatmonster.nocheatplus.checks.access.IViolationInfo;
import fr.neatmonster.nocheatplus.checks.moving.MovingData;
import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager;
import fr.neatmonster.nocheatplus.hooks.NCPHook;
import fr.neatmonster.nocheatplus.hooks.NCPHookManager;
public class CustomTagFix extends MiniPlugin implements IPacketHandler
public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
{
private NautHashMap<String, NautHashMap<Integer, Integer>> _entityMap = new NautHashMap<String, NautHashMap<Integer, Integer>>();
private NautHashMap<String, NautHashMap<Integer, String>> _entityNameMap = new NautHashMap<String, NautHashMap<Integer, String>>();
@ -69,6 +73,9 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
System.out.println("Field exception in CustomTagFix : ");
exception.printStackTrace();
}
NCPHookManager.addHook(CheckType.MOVING_SURVIVALFLY, this);
NCPHookManager.addHook(CheckType.MOVING_PASSABLE, this);
}
@EventHandler
@ -83,9 +90,11 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
@EventHandler
public void ncpExempt(final PlayerToggleFlightEvent event)
{
long ignoreTime = System.currentTimeMillis() + 1500;
if (_exemptTimeMap.containsKey(event.getPlayer().getUniqueId()))
{
_exemptTimeMap.put(event.getPlayer().getUniqueId(), System.currentTimeMillis() + 1500);
_exemptTimeMap.put(event.getPlayer().getUniqueId(), Math.max(ignoreTime, _exemptTimeMap.get(event.getPlayer().getUniqueId())));
return;
}
@ -98,28 +107,20 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
}
_exemptTimeMap.put(event.getPlayer().getUniqueId(), System.currentTimeMillis() + 1500);
_exemptTimeMap.put(event.getPlayer().getUniqueId(), ignoreTime);
}
@EventHandler
public void ncpExemptVelocity(final PlayerVelocityEvent event)
{
long ignoreTime = System.currentTimeMillis() + (long)(event.getVelocity().length() * 2000);
if (_exemptTimeMap.containsKey(event.getPlayer().getUniqueId()))
{
_exemptTimeMap.put(event.getPlayer().getUniqueId(), System.currentTimeMillis() + 1500);
_exemptTimeMap.put(event.getPlayer().getUniqueId(), Math.max(ignoreTime, _exemptTimeMap.get(event.getPlayer().getUniqueId())));
return;
}
try
{
NCPExemptionManager.exemptPermanently(event.getPlayer());
}
catch (Exception exception)
{
}
_exemptTimeMap.put(event.getPlayer().getUniqueId(), System.currentTimeMillis() + 1500);
_exemptTimeMap.put(event.getPlayer().getUniqueId(), ignoreTime);
}
@EventHandler
@ -130,21 +131,11 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
for (Iterator<Entry<UUID, Long>> iterator = _exemptTimeMap.entrySet().iterator(); iterator.hasNext();)
{
Entry<UUID, Long> entry = iterator.next();
final Entry<UUID, Long> entry = iterator.next();
if (System.currentTimeMillis() > entry.getValue())
{
iterator.remove();
try
{
NCPExemptionManager.unexempt(entry.getKey());
}
catch (Exception exception)
{
}
}
}
}
@ -545,5 +536,28 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler
}
});
}
@Override
public String getHookName()
{
return "Mineplex Hook";
}
@Override
public String getHookVersion()
{
return "Latest";
}
@Override
public boolean onCheckFailure(CheckType checkType, Player player, IViolationInfo violationInfo)
{
boolean failure = _exemptTimeMap.containsKey(player.getUniqueId());
if (failure)
MovingData.getData(player).clearFlyData();
return failure;
}
}