Skip to content

Commit

Permalink
Added "/superLMS forceStart" subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan923 committed Sep 22, 2020
1 parent e79dc40 commit 0c83e84
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
public class CommandManager implements CommandExecutor, MessageUtils {

private static final List<AbstractCommand> commands = new ArrayList<>();
private SuperLMS plugin;
private TabManager tabManager;
private final SuperLMS plugin;

public CommandManager(SuperLMS plugin) {
this.plugin = plugin;
this.tabManager = new TabManager(this);
TabManager tabManager = new TabManager(this);

FileConfiguration settings = plugin.getSettingsManager().getConfig();

plugin.getCommand("superlms").setExecutor(this);
AbstractCommand commandSuperLMS = addCommand(new CommandSuperLMS());

addCommand(new CommandExit(commandSuperLMS));
addCommand(new CommandForceStart(commandSuperLMS));
addCommand(new CommandJoin(commandSuperLMS));
addCommand(new CommandPrepare(commandSuperLMS));
addCommand(new CommandReload(commandSuperLMS));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package me.stefan923.superlms.commands.type;

import me.stefan923.superlms.SuperLMS;
import me.stefan923.superlms.game.GameStatus;
import me.stefan923.superlms.utils.MessageUtils;
import me.stefan923.superlms.commands.AbstractCommand;
import me.stefan923.superlms.utils.SerializationUtils;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;

import java.util.List;

public class CommandForceStart extends AbstractCommand implements MessageUtils, SerializationUtils {

public CommandForceStart(AbstractCommand abstractCommand) {
super(abstractCommand, false, "forcestart");
}

@Override
protected ReturnType runCommand(SuperLMS instance, CommandSender sender, String... args) {
FileConfiguration language = instance.getLanguageManager().getConfig();
GameStatus gameStatus = instance.getGameManager().getStatus();

if (instance.getGameManager().getStatus().equals(GameStatus.IDLE)) {
sender.sendMessage(formatAll(language.getString("Command.ForceStart.Game Not Available")));
return ReturnType.SUCCESS;
}

if (gameStatus.equals(GameStatus.GRACE) || gameStatus.equals(GameStatus.STARTED)) {
sender.sendMessage(formatAll(language.getString("Command.ForceStart.Game Already Started")));
return ReturnType.SUCCESS;
}

if (instance.getPlayers().size() < 2) {
sender.sendMessage(formatAll(language.getString("Command.ForceStart.Not Enough Players")));
return ReturnType.SUCCESS;
}

instance.getGameManager().startGame();
sender.sendMessage(formatAll(language.getString("Command.ForceStart.Success")));

return ReturnType.SUCCESS;
}

@Override
protected List<String> onTab(SuperLMS instance, CommandSender sender, String... args) {
return null;
}

@Override
public String getPermissionNode() {
return "superlms.admin";
}

@Override
public String getSyntax() {
return "/superlms forceStart";
}

@Override
public String getDescription() {
return "Forces a game to start.";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public void setup(SuperLMS instance) {

config.options().header("SuperLMS by Stefan923\n");
config.addDefault("Command.Exit.Not In Game", "&8(&3!&8) &cYou aren't in a Last Man Standing game.");
config.addDefault("Command.ForceStart.Game Already Started", "&8(&3!&8) &cThe game has already started.");
config.addDefault("Command.ForceStart.Game Not Available", "&8(&3!&8) &cThere is no arena available.");
config.addDefault("Command.ForceStart.Not Enough Players", "&8(&3!&8) &cThere must be at least &42 players &cto start the game.");
config.addDefault("Command.ForceStart.Success", "&8(&3!&8) &fThe game has been &bforced&f to start.");
config.addDefault("Command.Join.Already Joined", "&8(&3!&8) &cYou have already joined the game.");
config.addDefault("Command.Join.Game Already Started", "&8(&3!&8) &cThe game has already started.");
config.addDefault("Command.Join.Game Is Full", "&8(&3!&8) &cThe game is full.");
Expand Down

0 comments on commit 0c83e84

Please sign in to comment.