Velocitab/src/main/java/net/william278/velocitab/packet/TeamsPacketAdapter.java
AlexDev_ 8ae25521dd
Fix encode error on 1.20.1 (#90)
* Added test debug

* Fix issue https://github.com/WiIIiam278/Velocitab/issues/89

* Removed ViaVersion problem message

* Re-Added final keyword on plugin parameter in UpdateTeamsPacket
2023-09-16 10:53:50 +01:00

47 lines
1.4 KiB
Java

/*
* This file is part of Velocitab, licensed under the Apache License 2.0.
*
* Copyright (c) William278 <will27528@gmail.com>
* Copyright (c) contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.william278.velocitab.packet;
import com.velocitypowered.api.network.ProtocolVersion;
import io.netty.buffer.ByteBuf;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import org.apache.commons.text.StringEscapeUtils;
import org.jetbrains.annotations.NotNull;
import java.util.Set;
@Getter
@RequiredArgsConstructor
public abstract class TeamsPacketAdapter {
private final Set<ProtocolVersion> protocolVersions;
public abstract void encode(@NotNull ByteBuf byteBuf, @NotNull UpdateTeamsPacket packet);
@NotNull
protected String getChatString(@NotNull String string) {
return String.format("{\"text\":\"%s\"}", StringEscapeUtils.escapeJson(string));
}
}