-
-
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.
Fix WrappedPacketInCustomPayload and added CONFIG packet event
- Loading branch information
Showing
10 changed files
with
222 additions
and
7 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
44 changes: 44 additions & 0 deletions
44
src/main/java/io/github/retrooper/packetevents/event/impl/PacketConfigReceiveEvent.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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* This file is part of packetevents - https://github.com/retrooper/packetevents | ||
* Copyright (C) 2021 retrooper and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.github.retrooper.packetevents.event.impl; | ||
|
||
import io.github.retrooper.packetevents.event.PacketListenerAbstract; | ||
import io.github.retrooper.packetevents.event.eventtypes.CancellableNMSPacketEvent; | ||
import io.github.retrooper.packetevents.packetwrappers.NMSPacket; | ||
|
||
/** | ||
* The {@code PacketConfigReceiveEvent} event is fired whenever the a CONFIG packet is received from a client. | ||
* Use the {@link #getSocketAddress()} to identify who sends the packet. | ||
* | ||
* @author retrooper | ||
* @see <a href="https://wiki.vg/Protocol#Configuration">https://wiki.vg/Protocol#Configuration</a> | ||
* @since 1.8 | ||
*/ | ||
public class PacketConfigReceiveEvent extends CancellableNMSPacketEvent { | ||
public PacketConfigReceiveEvent(Object channel, NMSPacket packet) { | ||
super(channel, packet); | ||
} | ||
|
||
@Override | ||
public void call(PacketListenerAbstract listener) { | ||
if (listener.clientSidedLoginAllowance == null || listener.clientSidedLoginAllowance.contains(getPacketId())) { | ||
listener.onPacketConfigReceive(this); | ||
} | ||
} | ||
} |
62 changes: 62 additions & 0 deletions
62
src/main/java/io/github/retrooper/packetevents/event/impl/PacketConfigSendEvent.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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* This file is part of packetevents - https://github.com/retrooper/packetevents | ||
* Copyright (C) 2021 retrooper and contributors | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.github.retrooper.packetevents.event.impl; | ||
|
||
import io.github.retrooper.packetevents.event.PacketListenerAbstract; | ||
import io.github.retrooper.packetevents.event.eventtypes.CancellableNMSPacketEvent; | ||
import io.github.retrooper.packetevents.event.eventtypes.PostTaskEvent; | ||
import io.github.retrooper.packetevents.packetwrappers.NMSPacket; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* The {@code PacketConfigSendEvent} event is fired whenever the a LOGIN packet is being planned to be sent to the client. | ||
* Use the {@link #getSocketAddress()} to identify who sends the packet. | ||
* | ||
* @author retrooper | ||
* @see <a href="https://wiki.vg/Protocol#Configuration">https://wiki.vg/Protocol#Configuration</a> | ||
* @since 1.8 | ||
*/ | ||
public class PacketConfigSendEvent extends CancellableNMSPacketEvent implements PostTaskEvent { | ||
private Runnable postTask; | ||
public PacketConfigSendEvent(Object channel, NMSPacket packet) { | ||
super(channel, packet); | ||
} | ||
|
||
@Override | ||
public boolean isPostTaskAvailable() { | ||
return postTask != null; | ||
} | ||
|
||
@Override | ||
public Runnable getPostTask() { | ||
return postTask; | ||
} | ||
|
||
@Override | ||
public void setPostTask(@NotNull Runnable postTask) { | ||
this.postTask = postTask; | ||
} | ||
|
||
@Override | ||
public void call(PacketListenerAbstract listener) { | ||
if (listener.serverSidedLoginAllowance == null || listener.serverSidedLoginAllowance.contains(getPacketId())) { | ||
listener.onPacketConfigSend(this); | ||
} | ||
} | ||
} |
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
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