Use predefined packet types, add comments.

This commit is contained in:
asofold 2014-07-16 13:28:26 +02:00
parent bb8b8fc1f2
commit 288950edd4
3 changed files with 6 additions and 10 deletions

View File

@ -30,20 +30,11 @@ public class MoveFrequency extends PacketAdapter implements Listener, JoinLeaveL
// TODO: Optimized options (receive only, other?).
// TODO: Async version ?
// private static Collection<PacketType> getPacketTypes() {
// final Collection<PacketType> packetTypes = PacketType.fromName("C03PacketPlayer");
// if (packetTypes.isEmpty()) {
// throw new RuntimeException("Packet types not available.");
// }
// return packetTypes;
// }
private Map<String, ActionFrequency> freqMap = new LinkedHashMap<String, ActionFrequency>();
public MoveFrequency(Plugin plugin) {
// PacketPlayInFlying[3, legacy: 10]
super(plugin, PacketType.findCurrent(Protocol.PLAY, Sender.CLIENT, 3)); //getPacketTypes());
// TODO: Try to get packet by name first + legacy first.
super(plugin, PacketType.Play.Client.FLYING); // TODO: How does POS and POS_LOOK relate/translate?
}
private ActionFrequency addName(String name) {

View File

@ -31,6 +31,7 @@ public class ProtocolLibComponent implements DisableListener{
MoveFrequency.class,
WeatherDistance.class
);
// TODO: Configurability.
for (Class<? extends PacketAdapter> clazz : adapterClasses) {
try {
// Construct a new instance using reflection.

View File

@ -14,6 +14,9 @@ import fr.neatmonster.nocheatplus.utilities.TrigUtil;
public class WeatherDistance extends PacketAdapter {
// TODO: Will not be effective with 512 radius, if they add the patch by @Amranth.
// TODO: For lower distances more packets might need to be intercepted.
/** Maximum distance for thunder effects (squared). */
private static final double distSq = 512.0 * 512.0; // TODO: Maybe configurable.
@ -27,6 +30,7 @@ public class WeatherDistance extends PacketAdapter {
final Player player = event.getPlayer();
// Compare sound effect name.
// TODO: wither-spawn-sound-radius, dragon-death-sound-radius, other ?
if (!packetContainer.getStrings().read(0).equals("ambient.weather.thunder")) {
return;
}