Search in sources :

Example 1 with Syntax

use of co.aikar.commands.annotation.Syntax in project VoxelGamesLibv2 by VoxelGamesLib.

the class GameCommands method gameStart.

@Subcommand("start")
@CommandCompletion("@gamemodes")
@Syntax("<mode> - the mode you want to start")
@CommandPermission("%premium")
public void gameStart(@Nonnull User sender, @Nonnull GameMode mode) {
    if (handleGameLeaving(sender))
        return;
    Game game = gameHandler.startGame(mode);
    if (game.getActivePhase().isRunning()) {
        game.join(sender);
        Lang.msg(sender, LangKey.GAME_GAME_STARTED);
        if (config.announceNewGame) {
            // TODO figure out which command to enter
            Lang.broadcast(LangKey.GAME_ANNOUNCE_GAME_STARTED, "/game joinuuid " + game.getUuid().toString(), sender.getDisplayName(), mode.getName());
        }
    } else {
        Lang.msg(sender, LangKey.GAME_COULD_NOT_START);
    }
}
Also used : Game(com.voxelgameslib.voxelgameslib.game.Game) Subcommand(co.aikar.commands.annotation.Subcommand) CommandCompletion(co.aikar.commands.annotation.CommandCompletion) Syntax(co.aikar.commands.annotation.Syntax) CommandPermission(co.aikar.commands.annotation.CommandPermission)

Example 2 with Syntax

use of co.aikar.commands.annotation.Syntax in project VoxelGamesLibv2 by VoxelGamesLib.

the class EditMode method skull.

@Subcommand("skull")
@CommandPermission("%admin")
@Syntax("<name> - the name of the skull")
public void skull(@Nonnull User sender, @Nonnull String name) {
    if (editMode.contains(sender.getUuid())) {
        ItemStack skull = new ItemBuilder(Material.SKULL_ITEM).durability(3).name(name).meta((itemMeta -> {
            char prefix = name.toUpperCase().charAt(0);
            Skin skin = textureHandler.getSkin(prefix + "").orElseThrow(() -> new VoxelGameLibException("Unknown skull " + prefix));
            ((SkullMeta) itemMeta).setPlayerProfile(textureHandler.getPlayerProfile(skin));
            ((SkullMeta) itemMeta).setOwner(name);
        })).build();
        sender.getPlayer().getInventory().setItemInMainHand(skull);
    } else {
        Lang.msg(sender, LangKey.EDITMODE_NOT_ENABLED);
    }
}
Also used : ItemBuilder(com.voxelgameslib.voxelgameslib.utils.ItemBuilder) VoxelGameLibException(com.voxelgameslib.voxelgameslib.exception.VoxelGameLibException) Skin(org.mineskin.data.Skin) SkullMeta(org.bukkit.inventory.meta.SkullMeta) ItemStack(org.bukkit.inventory.ItemStack) Subcommand(co.aikar.commands.annotation.Subcommand) Syntax(co.aikar.commands.annotation.Syntax) CommandPermission(co.aikar.commands.annotation.CommandPermission)

Example 3 with Syntax

use of co.aikar.commands.annotation.Syntax in project VoxelGamesLibv2 by VoxelGamesLib.

the class WorldCommands method load.

@Subcommand("load")
@CommandPermission("%admin")
@Syntax("<mapname> - the name of the map to load")
@Description("Loads a map onto the server")
public void load(@Nonnull User sender, @Nonnull String mapName) {
    Optional<Map> o = handler.getMap(mapName);
    Map map = o.orElseGet(() -> handler.loadMap(mapName));
    handler.loadWorld(map, sender.getUuid(), false);
}
Also used : Map(com.voxelgameslib.voxelgameslib.map.Map) Description(co.aikar.commands.annotation.Description) Subcommand(co.aikar.commands.annotation.Subcommand) Syntax(co.aikar.commands.annotation.Syntax) CommandPermission(co.aikar.commands.annotation.CommandPermission)

Example 4 with Syntax

use of co.aikar.commands.annotation.Syntax in project VoxelGamesLibv2 by VoxelGamesLib.

the class WorldModifyCommands method start.

@Subcommand("start")
@CommandPermission("%admin")
@Syntax("<world> - the name of the map you want to modify")
public void start(@Nonnull User user, @Nonnull String world) {
    if (editor != null) {
        Lang.msg(user, LangKey.WORLD_CREATOR_IN_USE, editor.getDisplayName());
        return;
    }
    editor = user;
    // load data
    Optional<Map> o = worldHandler.getMap(world);
    this.map = o.orElseGet(() -> worldHandler.loadMap(world));
    // load world
    map.load(editor.getUuid(), map.getWorldName());
    File file = new File(worldHandler.getWorldContainer(), map.getLoadedName(editor.getUuid()));
    try {
        ZipFile zip = new ZipFile(new File(worldHandler.getWorldsFolder(), map.getWorldName() + ".zip"));
        zip.extractAll(file.getAbsolutePath());
        FileUtils.delete(new File(file, "uid.dat"));
    } catch (ZipException e) {
        throw new WorldException("Could not unzip world " + map.getInfo().getName() + ".", e);
    }
    worldHandler.loadLocalWorld(map.getLoadedName(editor.getUuid()));
    // tp
    user.getPlayer().teleport(map.getCenter().toLocation(map.getLoadedName(user.getUuid())));
    if (gameHandler.getDefaultGame().isParticipating(editor.getUuid())) {
        gameHandler.getDefaultGame().leave(editor);
    }
    game = gameHandler.startGame(EditModeGame.GAMEMODE);
    game.getActivePhase().getNextPhase().getFeature(SpawnFeature.class).addSpawn(map.getCenter());
    game.getActivePhase().getNextPhase().getFeature(MapFeature.class).setMap(map);
    map.load(game.getUuid(), map.getWorldName());
    game.join(editor);
    game.endPhase();
    Lang.msg(user, LangKey.WORLD_MODIFY_START);
// TODO use inventory for world creator
}
Also used : ZipFile(net.lingala.zip4j.core.ZipFile) WorldException(com.voxelgameslib.voxelgameslib.exception.WorldException) MapFeature(com.voxelgameslib.voxelgameslib.feature.features.MapFeature) ZipException(net.lingala.zip4j.exception.ZipException) Map(com.voxelgameslib.voxelgameslib.map.Map) ZipFile(net.lingala.zip4j.core.ZipFile) File(java.io.File) SpawnFeature(com.voxelgameslib.voxelgameslib.feature.features.SpawnFeature) Subcommand(co.aikar.commands.annotation.Subcommand) Syntax(co.aikar.commands.annotation.Syntax) CommandPermission(co.aikar.commands.annotation.CommandPermission)

Example 5 with Syntax

use of co.aikar.commands.annotation.Syntax in project VoxelGamesLibv2 by VoxelGamesLib.

the class WorldCommands method tp.

@Subcommand("tp")
@CommandPermission("%admin")
@Syntax("<world> - the name of the world to tp to")
@Description("Teleports you to a world")
public void tp(@Nonnull User sender, @Nonnull String world) {
    Optional<Map> o = handler.getMap(world);
    if (o.isPresent()) {
        Map map = o.get();
        sender.getPlayer().teleport(map.getCenter().toLocation(map.getLoadedName(sender.getUuid())));
    } else {
        World w = Bukkit.getWorld(world);
        if (w != null) {
            sender.getPlayer().teleport(Bukkit.getWorld(world).getSpawnLocation());
        }
        Lang.msg(sender, LangKey.WORLD_UNKNOWN_MAP, world);
    }
}
Also used : World(org.bukkit.World) Map(com.voxelgameslib.voxelgameslib.map.Map) Description(co.aikar.commands.annotation.Description) Subcommand(co.aikar.commands.annotation.Subcommand) Syntax(co.aikar.commands.annotation.Syntax) CommandPermission(co.aikar.commands.annotation.CommandPermission)

Aggregations

CommandPermission (co.aikar.commands.annotation.CommandPermission)6 Subcommand (co.aikar.commands.annotation.Subcommand)6 Syntax (co.aikar.commands.annotation.Syntax)6 Map (com.voxelgameslib.voxelgameslib.map.Map)3 Description (co.aikar.commands.annotation.Description)2 ItemBuilder (com.voxelgameslib.voxelgameslib.utils.ItemBuilder)2 ItemStack (org.bukkit.inventory.ItemStack)2 CommandCompletion (co.aikar.commands.annotation.CommandCompletion)1 VoxelGameLibException (com.voxelgameslib.voxelgameslib.exception.VoxelGameLibException)1 WorldException (com.voxelgameslib.voxelgameslib.exception.WorldException)1 MapFeature (com.voxelgameslib.voxelgameslib.feature.features.MapFeature)1 SpawnFeature (com.voxelgameslib.voxelgameslib.feature.features.SpawnFeature)1 Game (com.voxelgameslib.voxelgameslib.game.Game)1 File (java.io.File)1 ZipFile (net.lingala.zip4j.core.ZipFile)1 ZipException (net.lingala.zip4j.exception.ZipException)1 World (org.bukkit.World)1 SkullMeta (org.bukkit.inventory.meta.SkullMeta)1 Skin (org.mineskin.data.Skin)1