Add after-failure config flag checks for net/packet checks.

Obviously these have been forgotten, but are not marked with
@GlobalConfig. Using after-failure checking, because the raw config
getting and accessing might be slightly heavy-ish.
This commit is contained in:
asofold 2014-10-31 11:03:23 +01:00
parent 07bc7f6a90
commit 95763d35c8
3 changed files with 38 additions and 34 deletions

View File

@ -74,9 +74,12 @@ public class FlyingFrequency extends PacketAdapter implements JoinLeaveListener
final ActionFrequency freq = getFreq(event.getPlayer().getName());
freq.add(System.currentTimeMillis(), 1f);
if (freq.score(1f) > maxPackets) {
// TODO: Get from a NetConfig (optimized).
if (ConfigManager.getConfigFile(event.getPlayer().getWorld().getName()).getBoolean(ConfPaths.NET_FLYINGFREQUENCY_ACTIVE)) {
event.setCancelled(true);
counters.add(idSilent, 1); // Until it is sure if we can get these async.
}
}
}
}

View File

@ -35,9 +35,7 @@ public class ProtocolLibComponent implements DisableListener, INotifyReload{
}
private void register(Plugin plugin) {
// REgister Classes having a constructor with Plugin as argument.
// TODO: Config paths for activation flags ...
// TODO: @GlobalConfig simple setup at first.
// Register Classes having a constructor with Plugin as argument.
if (ConfigManager.isTrueForAnyConfig(ConfPaths.NET_FLYINGFREQUENCY_ACTIVE)) {
register(FlyingFrequency.class, plugin);
}

View File

@ -49,20 +49,23 @@ public class SoundDistance extends PacketAdapter {
@Override
public void onPacketSending(final PacketEvent event) {
final PacketContainer packetContainer = event.getPacket();
final Player player = event.getPlayer();
// Compare sound effect name.
if (!contains(packetContainer.getStrings().read(0))) {
return;
}
final Player player = event.getPlayer();
final Location loc = player.getLocation(); // TODO: Use getLocation(useLoc) [synced if async].
// Compare distance of player to the weather location.
final StructureModifier<Integer> ints = packetContainer.getIntegers();
if (TrigUtil.distanceSquared(ints.read(0) / 8, ints.read(2) / 8, loc.getX(), loc.getZ()) > distSq) {
// TODO: Get from a NetConfig (optimized).
if (ConfigManager.getConfigFile(player.getWorld().getName()).getBoolean(ConfPaths.NET_SOUNDDISTANCE_ACTIVE)) {
event.setCancelled(true);
}
}
}
}