Skip to content

Commit 9a3b164

Browse files
committed
chore: refactor packet registration
1 parent 1228f14 commit 9a3b164

File tree

4 files changed

+658
-655
lines changed

4 files changed

+658
-655
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (C) 2018-2023 Velocity Contributors
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.velocitypowered.proxy.protocol;
19+
20+
import com.velocitypowered.api.network.ProtocolVersion;
21+
import org.jspecify.annotations.Nullable;
22+
23+
interface PacketMapper {
24+
default void readWrite(final int id, final ProtocolVersion from) {
25+
this.readWrite(id, from, null);
26+
}
27+
28+
void readWrite(final int id, final ProtocolVersion from, final @Nullable ProtocolVersion to);
29+
30+
default void writeOnly(final int id, final ProtocolVersion from) {
31+
this.writeOnly(id, from, null);
32+
}
33+
34+
void writeOnly(final int id, final ProtocolVersion from, final @Nullable ProtocolVersion to);
35+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (C) 2018-2023 Velocity Contributors
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.velocitypowered.proxy.protocol;
19+
20+
import com.velocitypowered.api.network.ProtocolVersion;
21+
import org.jspecify.annotations.Nullable;
22+
23+
/**
24+
* Packet mapping.
25+
*/
26+
public record PacketMapping(
27+
int id,
28+
ProtocolVersion from,
29+
@Nullable ProtocolVersion to,
30+
boolean writeOnly
31+
) {
32+
}

0 commit comments

Comments
 (0)