-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
97cc106
commit b11de54
Showing
5 changed files
with
108 additions
and
31 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
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
43 changes: 43 additions & 0 deletions
43
src/main/kotlin/one/oktw/galaxy/network/ProxyAPIPayload.kt
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,43 @@ | ||
/* | ||
* OKTW Galaxy Project | ||
* Copyright (C) 2018-2024 | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* 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 Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package one.oktw.galaxy.network | ||
|
||
import io.netty.buffer.Unpooled.wrappedBuffer | ||
import net.minecraft.network.PacketByteBuf | ||
import net.minecraft.network.codec.PacketCodec | ||
import net.minecraft.network.packet.CustomPayload | ||
import net.minecraft.util.Identifier | ||
import one.oktw.galaxy.proxy.api.ProxyAPI | ||
import one.oktw.galaxy.proxy.api.ProxyAPI.encode | ||
import one.oktw.galaxy.proxy.api.packet.Packet | ||
|
||
@JvmRecord | ||
data class ProxyAPIPayload(val packet: Packet) : CustomPayload { | ||
companion object { | ||
private val PROXY_IDENTIFIER = Identifier("galaxy", "proxy") | ||
val ID = CustomPayload.Id<ProxyAPIPayload>(PROXY_IDENTIFIER) | ||
val CODEC: PacketCodec<PacketByteBuf, ProxyAPIPayload> = PacketCodec.of( | ||
{ value, buf -> buf.writeBytes(wrappedBuffer(encode(value.packet))) }, | ||
{ buf -> ProxyAPI.decode(buf.nioBuffer()) }) | ||
} | ||
|
||
override fun getId(): CustomPayload.Id<out CustomPayload> { | ||
return ID | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/kotlin/one/oktw/galaxy/network/ProxyChatPayload.kt
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,43 @@ | ||
/* | ||
* OKTW Galaxy Project | ||
* Copyright (C) 2018-2024 | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* 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 Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package one.oktw.galaxy.network | ||
|
||
import io.netty.buffer.Unpooled.wrappedBuffer | ||
import net.minecraft.network.PacketByteBuf | ||
import net.minecraft.network.codec.PacketCodec | ||
import net.minecraft.network.packet.CustomPayload | ||
import net.minecraft.util.Identifier | ||
import one.oktw.galaxy.proxy.api.ProxyAPI | ||
import one.oktw.galaxy.proxy.api.ProxyAPI.encode | ||
import one.oktw.galaxy.proxy.api.packet.Packet | ||
|
||
@JvmRecord | ||
data class ProxyChatPayload(val packet: Packet) : CustomPayload { | ||
companion object { | ||
private val PROXY_CHAT_IDENTIFIER = Identifier("galaxy", "proxy-chat") | ||
val ID = CustomPayload.Id<ProxyChatPayload>(PROXY_CHAT_IDENTIFIER) | ||
val CODEC: PacketCodec<PacketByteBuf, ProxyChatPayload> = PacketCodec.of( | ||
{ value, buf -> buf.writeBytes(wrappedBuffer(encode(value.packet))) }, | ||
{ buf -> ProxyAPI.decode(buf.nioBuffer()) }) | ||
} | ||
|
||
override fun getId(): CustomPayload.Id<out CustomPayload> { | ||
return ID | ||
} | ||
} |