-
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue with netty, receive and send event were mixed
- Loading branch information
purplexdev
committed
Jun 25, 2020
1 parent
c73d88a
commit b753a98
Showing
7 changed files
with
90 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 26 additions & 2 deletions
28
src/main/java/io/github/retrooper/packetevents/example/MainExample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,45 @@ | ||
package io.github.retrooper.packetevents.example; | ||
|
||
import io.github.retrooper.packetevents.PacketEvents; | ||
import io.github.retrooper.packetevents.annotations.PacketHandler; | ||
import io.github.retrooper.packetevents.event.PacketEvent; | ||
import io.github.retrooper.packetevents.event.PacketListener; | ||
import io.github.retrooper.packetevents.event.impl.PacketReceiveEvent; | ||
import io.github.retrooper.packetevents.event.impl.PacketSendEvent; | ||
import io.github.retrooper.packetevents.packet.PacketType; | ||
import io.github.retrooper.packetevents.packetwrappers.in.flying.WrappedPacketInFlying; | ||
import io.github.retrooper.packetevents.packetwrappers.in.useentity.WrappedPacketInUseEntity; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public class MainExample extends JavaPlugin { | ||
public class MainExample extends JavaPlugin implements PacketListener { | ||
|
||
@Override | ||
public void onEnable() { | ||
PacketEvents.start(this); | ||
|
||
PacketEvents.getServerTickTask().cancel(); | ||
|
||
PacketEvents.getEventManager().registerListener(this); | ||
} | ||
|
||
@Override | ||
public void onDisable() { | ||
PacketEvents.stop(); | ||
} | ||
|
||
@PacketHandler | ||
public void onPacketReceive(PacketEvent event) { | ||
if (event instanceof PacketReceiveEvent) { | ||
PacketReceiveEvent e = (PacketReceiveEvent) event; | ||
System.out.println(e.getPacketName() + " is NAME"); | ||
if (PacketType.Util.isInstanceOfFlyingPacket(e.getNMSPacket())) { | ||
WrappedPacketInFlying flying = new WrappedPacketInFlying(e.getNMSPacket()); | ||
System.out.println(flying.isOnGround() + " and " + flying.isPosition() + " and " + flying.isLook() + " and " + flying.getX() + flying.getZ() + flying.getYaw()); | ||
} else if (PacketType.Util.isInstanceOfUseEntity(e.getNMSPacket())) { | ||
WrappedPacketInUseEntity useEntity = new WrappedPacketInUseEntity(e.getNMSPacket()); | ||
System.out.println("a" + useEntity.getAction().name() + " and " + useEntity.getEntityId()); | ||
} | ||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.