2021-12-27 19:03:08 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Kenshins Hide and Seek
|
|
|
|
*
|
|
|
|
* Copyright (c) 2021 Tyler Murphy.
|
|
|
|
*
|
|
|
|
* Kenshins Hide and Seek free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2021-12-27 19:14:32 +00:00
|
|
|
* he Free Software Foundation version 3.
|
2021-12-27 19:03:08 +00:00
|
|
|
*
|
|
|
|
* Kenshins Hide and Seek 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2021-10-11 15:52:56 +00:00
|
|
|
package net.tylermurphy.hideAndSeek.command;
|
|
|
|
|
2021-10-23 00:03:15 +00:00
|
|
|
import static net.tylermurphy.hideAndSeek.configuration.Config.*;
|
|
|
|
|
2021-12-26 22:58:18 +00:00
|
|
|
import net.tylermurphy.hideAndSeek.game.Board;
|
|
|
|
import net.tylermurphy.hideAndSeek.game.Game;
|
2021-10-11 15:52:56 +00:00
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
2021-10-23 00:03:15 +00:00
|
|
|
import static net.tylermurphy.hideAndSeek.configuration.Localization.*;
|
2021-10-11 15:52:56 +00:00
|
|
|
|
|
|
|
public class Join implements ICommand {
|
|
|
|
|
|
|
|
public void execute(CommandSender sender, String[] args) {
|
2021-12-26 22:58:18 +00:00
|
|
|
if(Game.isNotSetup()) {
|
2021-10-23 00:03:15 +00:00
|
|
|
sender.sendMessage(errorPrefix + message("GAME_SETUP"));
|
2021-10-11 15:52:56 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
Player player = Bukkit.getServer().getPlayer(sender.getName());
|
|
|
|
if(player == null) {
|
2021-10-23 00:03:15 +00:00
|
|
|
sender.sendMessage(errorPrefix + message("COMMAND_ERROR"));
|
2021-10-11 15:52:56 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-12-26 22:58:18 +00:00
|
|
|
if(Board.isPlayer(player)){
|
2021-10-23 00:03:15 +00:00
|
|
|
sender.sendMessage(errorPrefix + message("GAME_INGAME"));
|
2021-10-11 21:06:21 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-10-29 23:57:40 +00:00
|
|
|
|
2021-12-27 19:14:32 +00:00
|
|
|
Game.join(player);
|
2021-10-11 15:52:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getLabel() {
|
2021-10-11 21:06:21 +00:00
|
|
|
return "join";
|
2021-10-11 15:52:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getUsage() {
|
2021-10-11 21:06:21 +00:00
|
|
|
return "";
|
2021-10-11 15:52:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getDescription() {
|
2021-10-11 21:06:21 +00:00
|
|
|
return "Joins the lobby if game is set to manual join/leave";
|
2021-10-11 15:52:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|