DungeonsXL/core/src/main/java/de/erethon/dungeonsxl/command/ChatCommand.java

58 lines
2.0 KiB
Java
Raw Normal View History

2016-03-01 22:08:07 +01:00
/*
2022-01-08 23:02:57 +01:00
* Copyright (C) 2012-2022 Frank Baumann
2016-03-01 22:08:07 +01:00
*
* 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 <http://www.gnu.org/licenses/>.
*/
2018-05-03 21:54:25 +02:00
package de.erethon.dungeonsxl.command;
2016-03-01 22:08:07 +01:00
2018-05-03 21:54:25 +02:00
import de.erethon.dungeonsxl.DungeonsXL;
import de.erethon.dungeonsxl.api.player.GlobalPlayer;
2018-05-03 21:54:25 +02:00
import de.erethon.dungeonsxl.config.DMessage;
import de.erethon.dungeonsxl.player.DEditPlayer;
2018-05-03 21:54:25 +02:00
import de.erethon.dungeonsxl.player.DPermission;
2022-04-03 18:09:12 +02:00
import de.erethon.bedrock.chat.MessageUtil;
2016-03-01 22:08:07 +01:00
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
/**
* @author Frank Baumann, Daniel Saukel
*/
2018-08-18 16:52:51 +02:00
public class ChatCommand extends DCommand {
2016-03-01 22:08:07 +01:00
2018-08-18 16:52:51 +02:00
public ChatCommand(DungeonsXL plugin) {
super(plugin);
2016-03-01 22:08:07 +01:00
setCommand("chat");
setMinArgs(0);
setMaxArgs(0);
setHelp(DMessage.CMD_CHAT_HELP.getMessage());
2017-11-16 18:25:10 +01:00
setPermission(DPermission.CHAT.getNode());
2016-03-01 22:08:07 +01:00
setPlayerCommand(true);
}
@Override
public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender;
GlobalPlayer dPlayer = dPlayers.get(player);
2016-03-01 22:08:07 +01:00
if (plugin.getPlayerGroup(player) == null && !(dPlayer instanceof DEditPlayer)) {
2017-07-21 18:33:21 +02:00
MessageUtil.sendMessage(player, DMessage.ERROR_JOIN_GROUP.getMessage());
2016-03-01 22:08:07 +01:00
return;
}
2017-02-20 18:05:03 +01:00
dPlayer.setInGroupChat(!dPlayer.isInGroupChat());
2017-07-21 18:33:21 +02:00
MessageUtil.sendMessage(player, (dPlayer.isInGroupChat() ? DMessage.CMD_CHAT_DUNGEON_CHAT : DMessage.CMD_CHAT_NORMAL_CHAT).getMessage());
2016-03-01 22:08:07 +01:00
}
}