Signed-off-by: Lixfel <git-5w3l@lixfel.de>
Dieser Commit ist enthalten in:
Ursprung
2f4290e2fe
Commit
73b89256f0
@ -1,131 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2024 SteamWar.de-Serverteam
|
|
||||||
*
|
|
||||||
* 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
|
|
||||||
* (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 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 de.steamwar.bungeecore.protocol.packet;
|
|
||||||
|
|
||||||
import com.velocitypowered.api.network.ProtocolVersion;
|
|
||||||
import com.velocitypowered.api.proxy.Player;
|
|
||||||
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
|
|
||||||
import com.velocitypowered.proxy.protocol.MinecraftPacket;
|
|
||||||
import com.velocitypowered.proxy.protocol.ProtocolUtils;
|
|
||||||
import com.velocitypowered.proxy.protocol.packet.chat.ComponentHolder;
|
|
||||||
import io.netty.buffer.ByteBuf;
|
|
||||||
import lombok.*;
|
|
||||||
import net.kyori.adventure.text.Component;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Builder
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
public class UpdateTeamsPacket implements MinecraftPacket {
|
|
||||||
private String name;
|
|
||||||
private Mode mode;
|
|
||||||
|
|
||||||
private Component displayName;
|
|
||||||
private Component prefix;
|
|
||||||
private Component suffix;
|
|
||||||
private NameTagVisibility nameTagVisibility;
|
|
||||||
private CollisionRule collisionRule;
|
|
||||||
private int color;
|
|
||||||
private byte friendlyFlags;
|
|
||||||
|
|
||||||
private List<Player> players;
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void decode(ByteBuf byteBuf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) {
|
|
||||||
throw new UnsupportedOperationException("Packet is not implemented");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handle(MinecraftSessionHandler minecraftSessionHandler) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void encode(ByteBuf byteBuf, ProtocolUtils.Direction direction, ProtocolVersion protocolVersion) {
|
|
||||||
ProtocolUtils.writeString(byteBuf, name);
|
|
||||||
byteBuf.writeByte(mode.ordinal());
|
|
||||||
|
|
||||||
switch (mode) {
|
|
||||||
case CREATE, UPDATE:
|
|
||||||
new ComponentHolder(protocolVersion, displayName).write(byteBuf);
|
|
||||||
if (protocolVersion.lessThan(ProtocolVersion.MINECRAFT_1_13)) {
|
|
||||||
new ComponentHolder(protocolVersion, prefix).write(byteBuf);
|
|
||||||
new ComponentHolder(protocolVersion, suffix).write(byteBuf);
|
|
||||||
}
|
|
||||||
byteBuf.writeByte(friendlyFlags);
|
|
||||||
ProtocolUtils.writeString(byteBuf, nameTagVisibility.getValue());
|
|
||||||
ProtocolUtils.writeString(byteBuf, collisionRule.getValue());
|
|
||||||
if (protocolVersion.greaterThan(ProtocolVersion.MINECRAFT_1_12_2)) {
|
|
||||||
ProtocolUtils.writeVarInt(byteBuf, color);
|
|
||||||
new ComponentHolder(protocolVersion, prefix).write(byteBuf);
|
|
||||||
new ComponentHolder(protocolVersion, suffix).write(byteBuf);
|
|
||||||
} else {
|
|
||||||
byteBuf.writeByte((byte) color);
|
|
||||||
}
|
|
||||||
ProtocolUtils.writeVarInt(byteBuf, players.size());
|
|
||||||
for (Player player : players) {
|
|
||||||
ProtocolUtils.writeString(byteBuf, player.getUsername());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case ADD_PLAYER, REMOVE_PLAYER:
|
|
||||||
ProtocolUtils.writeVarInt(byteBuf, players.size());
|
|
||||||
for (Player player : players) {
|
|
||||||
ProtocolUtils.writeString(byteBuf, player.getUsername());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case REMOVE:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum Mode {
|
|
||||||
CREATE,
|
|
||||||
REMOVE,
|
|
||||||
UPDATE,
|
|
||||||
ADD_PLAYER,
|
|
||||||
REMOVE_PLAYER,
|
|
||||||
}
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
enum NameTagVisibility {
|
|
||||||
ALWAYS("always"),
|
|
||||||
NEVER("never"),
|
|
||||||
HIDE_FOR_OTHER_TEAMS("hideForOtherTeams"),
|
|
||||||
HIDE_FOR_OWN_TEAM("hideForOwnTeam");
|
|
||||||
|
|
||||||
private final String value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
|
||||||
enum CollisionRule {
|
|
||||||
ALWAYS("always"),
|
|
||||||
NEVER("never"),
|
|
||||||
PUSH_OTHER_TEAMS("pushOtherTeams"),
|
|
||||||
PUSH_OWN_TEAM("pushOwnTeam");
|
|
||||||
|
|
||||||
private final String value;
|
|
||||||
}
|
|
||||||
}
|
|
In neuem Issue referenzieren
Einen Benutzer sperren