001/*
002 * PlotSquared, a land and world management plugin for Minecraft.
003 * Copyright (C) IntellectualSites <https://intellectualsites.com>
004 * Copyright (C) IntellectualSites team and contributors
005 *
006 * This program is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * This program is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
018 */
019package com.plotsquared.core.command;
020
021import com.plotsquared.core.configuration.caption.TranslatableCaption;
022import com.plotsquared.core.player.PlotPlayer;
023import com.plotsquared.core.plot.PlotArea;
024import net.kyori.adventure.text.minimessage.Template;
025
026/**
027 * @deprecated In favor of "/plot toggle chat" and
028 *         scheduled for removal within the next major release.
029 */
030@Deprecated(forRemoval = true, since = "6.0.0")
031@CommandDeclaration(command = "chat",
032        usage = "/plot chat",
033        permission = "plots.chat",
034        category = CommandCategory.CHAT,
035        requiredType = RequiredType.PLAYER)
036public class Chat extends SubCommand {
037
038    @Override
039    public boolean onCommand(PlotPlayer<?> player, String[] args) {
040        PlotArea area = player.getPlotAreaAbs();
041        check(area, TranslatableCaption.of("errors.not_in_plot_world"));
042        player.sendMessage(
043                TranslatableCaption.of("errors.deprecated_commands"),
044                Template.of("replacement", "/plot toggle chat")
045        );
046        if (player.getPlotAreaAbs().isForcingPlotChat()) {
047            player.sendMessage(TranslatableCaption.of("chat.plot_chat_forced"));
048            return true;
049        }
050        MainCommand.getInstance().toggle.chat(this, player, args, null, null);
051        return true;
052    }
053
054}