/*
 *   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 com.velocitypowered.proxy.protocol.packet;

import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.proxy.connection.MinecraftSessionHandler;
import com.velocitypowered.proxy.protocol.MinecraftPacket;
import com.velocitypowered.proxy.protocol.ProtocolUtils;
import io.netty.buffer.ByteBuf;
import net.kyori.adventure.text.Component;

import java.util.List;

public class UpdateTeamsPacket implements MinecraftPacket {
    protected String name;
    protected Mode mode;

    protected Component displayName;
    protected Component prefix;
    protected Component suffix;
    protected NameTagVisibility nameTagVisibility;
    protected CollisionRule collisionRule;
    protected int color;
    protected byte friendlyFlags;

    protected List<String> players;

    public UpdateTeamsPacket(String name, Mode mode, Component displayName, Component prefix, Component suffix, NameTagVisibility nameTagVisibility, CollisionRule collisionRule, int color, byte friendlyFlags, List<String> players) {
        this.name = name;
        this.mode = mode;
        this.displayName = displayName;
        this.prefix = prefix;
        this.suffix = suffix;
        this.nameTagVisibility = nameTagVisibility;
        this.collisionRule = collisionRule;
        this.color = color;
        this.friendlyFlags = friendlyFlags;
        this.players = players;
    }

    public UpdateTeamsPacket() {
    }

    @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) {
        throw new UnsupportedOperationException("Packet is not implemented");
    }

    public enum Mode {
        CREATE,
        REMOVE,
        UPDATE,
        ADD_PLAYER,
        REMOVE_PLAYER,
    }

    public enum NameTagVisibility {
        ALWAYS("always"),
        NEVER("never"),
        HIDE_FOR_OTHER_TEAMS("hideForOtherTeams"),
        HIDE_FOR_OWN_TEAM("hideForOwnTeam");

        private final String value;

        NameTagVisibility(String value) {
            this.value = value;
        }

        public String getValue() {
            return value;
        }
    }

    public enum CollisionRule {
        ALWAYS("always"),
        NEVER("never"),
        PUSH_OTHER_TEAMS("pushOtherTeams"),
        PUSH_OWN_TEAM("pushOwnTeam");

        private final String value;

        CollisionRule(String value) {
            this.value = value;
        }

        public String getValue() {
            return value;
        }
    }

    public String getName() {
        return name;
    }

    public Mode getMode() {
        return mode;
    }

    public Component getDisplayName() {
        return displayName;
    }

    public Component getPrefix() {
        return prefix;
    }

    public Component getSuffix() {
        return suffix;
    }

    public NameTagVisibility getNameTagVisibility() {
        return nameTagVisibility;
    }

    public CollisionRule getCollisionRule() {
        return collisionRule;
    }

    public int getColor() {
        return color;
    }

    public byte getFriendlyFlags() {
        return friendlyFlags;
    }

    public List<String> getPlayers() {
        return players;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setMode(Mode mode) {
        this.mode = mode;
    }

    public void setDisplayName(Component displayName) {
        this.displayName = displayName;
    }

    public void setPrefix(Component prefix) {
        this.prefix = prefix;
    }

    public void setSuffix(Component suffix) {
        this.suffix = suffix;
    }

    public void setNameTagVisibility(NameTagVisibility nameTagVisibility) {
        this.nameTagVisibility = nameTagVisibility;
    }

    public void setCollisionRule(CollisionRule collisionRule) {
        this.collisionRule = collisionRule;
    }

    public void setColor(int color) {
        this.color = color;
    }

    public void setFriendlyFlags(byte friendlyFlags) {
        this.friendlyFlags = friendlyFlags;
    }

    public void setPlayers(List<String> players) {
        this.players = players;
    }
}
