SGM/src/main/java/xyz/twovb/sgm/commands/impl/GameCommand.java
2vb dca1320275
Some checks are pending
Build plugin / build (push) Waiting to run
probably riddled with bugs but i think it works
2024-07-02 21:58:05 -07:00

62 lines
2.1 KiB
Java

package xyz.twovb.sgm.commands.impl;
/*
* Created by 2vb - 2/7/2024
*/
import dev.rollczi.litecommands.annotations.argument.Arg;
import dev.rollczi.litecommands.annotations.command.Command;
import dev.rollczi.litecommands.annotations.context.Context;
import dev.rollczi.litecommands.annotations.execute.Execute;
import dev.rollczi.litecommands.annotations.permission.Permission;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import xyz.twovb.sgm.SGM;
import xyz.twovb.sgm.games.Minigame;
import xyz.twovb.sgm.games.impl.TestGame;
import xyz.twovb.toolbox.api.CustomPlayer;
import xyz.twovb.toolbox.utils.ChatUtils;
import java.util.UUID;
@Command(name = "game")
public class GameCommand {
@Execute()
void execute(@Context CommandSender sender) {
StringBuilder builder = new StringBuilder();
builder.insert(0, "&7Enabled games:");
builder.append("\n");
for (int i = 0; i < SGM.getInstance().getGameManager().getRegisteredGames().size(); i++) {
String game = SGM.getInstance().getGameManager().getRegisteredGames().get(i);
builder.append(game);
if (i < SGM.getInstance().getGameManager().getRegisteredGames().size() - 1) {
builder.append(", ");
}
}
sender.sendMessage(ChatUtils.translate(builder.toString()));
}
@Execute(name = "init")
@Permission("sgm.games.init")
void init(@Context Player player, @Arg("name") String name) {
CustomPlayer cPlayer = new CustomPlayer(player);
SGM.getInstance().getGameManager().initGame(new TestGame(), player, name);
}
@Execute(name = "start")
@Permission("sgm.games.start")
void start(@Context Player player) {
CustomPlayer cPlayer = new CustomPlayer(player);
Minigame game = SGM.getInstance().getGameManager().findGame(player);
game.start();
}
@Execute(name = "join")
void join(@Context Player player, @Arg("id") String id) {
CustomPlayer cPlayer = new CustomPlayer(player);
SGM.getInstance().getGameManager().addPlayerToGame(player, UUID.fromString(id));
}
}