Skip to content

Commit

Permalink
chore: refactor packet registration
Browse files Browse the repository at this point in the history
  • Loading branch information
kashike committed Sep 5, 2024
1 parent 7848068 commit 7048cab
Show file tree
Hide file tree
Showing 4 changed files with 664 additions and 693 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (C) 2018-2023 Velocity 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 <https://www.gnu.org/licenses/>.
*/

package com.velocitypowered.proxy.protocol;

import com.velocitypowered.api.network.ProtocolVersion;
import org.jspecify.annotations.Nullable;

interface PacketMapper {
default void readWrite(final int id, final ProtocolVersion from) {
this.readWrite(id, from, null);
}

void readWrite(final int id, final ProtocolVersion from, final @Nullable ProtocolVersion to);

default void writeOnly(final int id, final ProtocolVersion from) {
this.writeOnly(id, from, null);
}

void writeOnly(final int id, final ProtocolVersion from, final @Nullable ProtocolVersion to);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (C) 2018-2023 Velocity 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 <https://www.gnu.org/licenses/>.
*/

package com.velocitypowered.proxy.protocol;

import com.velocitypowered.api.network.ProtocolVersion;
import org.jspecify.annotations.Nullable;

/**
* Packet mapping.
*/
public record PacketMapping(
int id,
ProtocolVersion from,
@Nullable ProtocolVersion to,
boolean writeOnly
) {
}
Loading

0 comments on commit 7048cab

Please sign in to comment.