Adding debug output to the protocol lib useage location to get more data.
This commit is contained in:
parent
148b09542d
commit
b00eb28834
@ -41,32 +41,42 @@ public class EntityPotionColorPacketAdapter extends PacketAdapter
|
|||||||
@Override
|
@Override
|
||||||
public void onPacketSending(PacketEvent event)
|
public void onPacketSending(PacketEvent event)
|
||||||
{
|
{
|
||||||
// If the server is sending a meta-data packet to a sendee player...
|
try
|
||||||
// NOTE: That must be the case. We are listening to no other situation.
|
|
||||||
final PacketContainer packet = event.getPacket();
|
|
||||||
final Player sendee = event.getPlayer();
|
|
||||||
|
|
||||||
// ... fetch the entity ...
|
|
||||||
// NOTE: MetaData packets are only sent to players in the same world.
|
|
||||||
final Entity entity = packet.getEntityModifier(sendee.getWorld()).read(0);
|
|
||||||
|
|
||||||
// ... fetch the metadata ...
|
|
||||||
final List<WrappedWatchableObject> metadata = packet.getWatchableCollectionModifier().read(0);
|
|
||||||
|
|
||||||
// ... for each watchable in the metadata ...
|
|
||||||
for (WrappedWatchableObject watchable : metadata)
|
|
||||||
{
|
{
|
||||||
// If the watchable is about potion effect color ...
|
// If the server is sending a meta-data packet to a sendee player...
|
||||||
if (watchable.getIndex() != 8) continue;
|
// NOTE: That must be the case. We are listening to no other situation.
|
||||||
|
final PacketContainer packet = event.getPacket();
|
||||||
|
final Player sendee = event.getPlayer();
|
||||||
|
|
||||||
// ... run our custom async event to allow changing it ...
|
// ... fetch the entity ...
|
||||||
int oldColor = (Integer) watchable.getValue();
|
// NOTE: MetaData packets are only sent to players in the same world.
|
||||||
MCoreEntityPotionColorEvent colorEvent = new MCoreEntityPotionColorEvent(sendee, entity, oldColor);
|
final Entity entity = packet.getEntityModifier(sendee.getWorld()).read(0);
|
||||||
colorEvent.run();
|
|
||||||
int newColor = colorEvent.getColor();
|
|
||||||
|
|
||||||
// ... alter if changed.
|
// ... fetch the metadata ...
|
||||||
if (newColor != oldColor) watchable.setValue(newColor, false);
|
final List<WrappedWatchableObject> metadata = packet.getWatchableCollectionModifier().read(0);
|
||||||
|
|
||||||
|
// ... for each watchable in the metadata ...
|
||||||
|
for (WrappedWatchableObject watchable : metadata)
|
||||||
|
{
|
||||||
|
// If the watchable is about potion effect color ...
|
||||||
|
if (watchable.getIndex() != 8) continue;
|
||||||
|
|
||||||
|
// ... run our custom async event to allow changing it ...
|
||||||
|
int oldColor = (Integer) watchable.getValue();
|
||||||
|
MCoreEntityPotionColorEvent colorEvent = new MCoreEntityPotionColorEvent(sendee, entity, oldColor);
|
||||||
|
colorEvent.run();
|
||||||
|
int newColor = colorEvent.getColor();
|
||||||
|
|
||||||
|
// ... alter if changed.
|
||||||
|
if (newColor != oldColor) watchable.setValue(newColor, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
System.out.println("Caught "+e.getClass().getName()+" exception in EntityPotionColorPacketAdapter#onPacketSending");
|
||||||
|
System.out.println("Message: "+e.getMessage());
|
||||||
|
System.out.println("Stack Trace:");
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user