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

78 lines
3.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-08-18 16:52:51 +02:00
import de.erethon.dungeonsxl.DungeonsXL;
import de.erethon.dungeonsxl.api.player.PlayerGroup;
import de.erethon.dungeonsxl.api.world.GameWorld;
2018-05-03 21:54:25 +02:00
import de.erethon.dungeonsxl.config.DMessage;
import de.erethon.dungeonsxl.dungeon.DGame;
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 Daniel Saukel
*/
2018-08-18 16:52:51 +02:00
public class GameCommand extends DCommand {
2016-03-01 22:08:07 +01:00
2018-08-18 16:52:51 +02:00
public GameCommand(DungeonsXL plugin) {
super(plugin);
2016-03-01 22:08:07 +01:00
setCommand("game");
setMinArgs(0);
setMaxArgs(0);
setHelp(DMessage.CMD_GAME_HELP.getMessage());
2017-11-16 18:25:10 +01:00
setPermission(DPermission.GAME.getNode());
2016-03-01 22:08:07 +01:00
setPlayerCommand(true);
}
@Override
public void onExecute(String[] args, CommandSender sender) {
Player player = (Player) sender;
PlayerGroup dGroup = plugin.getPlayerGroup(player);
2016-03-01 22:08:07 +01:00
if (dGroup == null) {
2017-07-21 18:33:21 +02:00
MessageUtil.sendMessage(sender, DMessage.ERROR_JOIN_GROUP.getMessage());
2016-03-01 22:08:07 +01:00
return;
}
GameWorld gameWorld = dGroup.getGameWorld();
2016-03-01 22:08:07 +01:00
if (gameWorld == null) {
2017-07-21 18:33:21 +02:00
MessageUtil.sendMessage(sender, DMessage.ERROR_NO_GAME.getMessage());
2016-03-01 22:08:07 +01:00
return;
}
DGame game = (DGame) gameWorld.getGame();
2016-03-01 22:08:07 +01:00
if (game == null) {
2017-07-21 18:33:21 +02:00
MessageUtil.sendMessage(sender, DMessage.ERROR_NO_GAME.getMessage());
2016-03-01 22:08:07 +01:00
return;
}
MessageUtil.sendCenteredMessage(sender, "&4&l[ &6Game &4&l]");
String groups = "";
for (PlayerGroup group : game.getGroups()) {
groups += (group == game.getGroups().get(0) ? "" : "&b, &e") + group.getName();
2016-03-01 22:08:07 +01:00
}
MessageUtil.sendMessage(sender, "&bGroups: &e" + groups);
MessageUtil.sendMessage(sender, "&bDungeon: &e" + (dGroup.getDungeon().getName() == null ? "N/A" : dGroup.getDungeon().getName()));
MessageUtil.sendMessage(sender, "&bMap: &e" + (dGroup.getGameWorld() == null ? "N/A" : dGroup.getGameWorld().getName()));
MessageUtil.sendMessage(sender, "&bWaves finished: &e" + game.getWaveCount());
MessageUtil.sendMessage(sender, "&bKills: &e" + game.getGameKills() + " / Game; " + game.getWaveKills() + " / Wave");
2016-03-01 22:08:07 +01:00
}
}