Search in sources :

Example 6 with Subcommand

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

the class EditMode method gui.

@Subcommand("gui")
@CommandPermission("%admin")
public void gui(@Nonnull User sender) {
    if (editMode.contains(sender.getUuid())) {
        // TODO implement paginated invs
        InventoryMenuBuilder builder = new InventoryMenuBuilder().withSize(9).withTitle(Lang.legacy(LangKey.INV_MARKER));
        for (int i = 0; i < mapHandler.getMarkerDefinitions().size(); i++) {
            MarkerDefinition markerDefinition = mapHandler.getMarkerDefinitions().get(i);
            ItemStack is = new ItemBuilder(Material.SKULL_ITEM).durability(3).name(markerDefinition.getPrefix()).meta((itemMeta -> {
                char prefix = markerDefinition.getPrefix().toUpperCase().charAt(0);
                Skin skin = textureHandler.getSkin(prefix + "").orElseThrow(() -> new VoxelGameLibException("Unknown skull " + prefix));
                ((SkullMeta) itemMeta).setPlayerProfile(textureHandler.getPlayerProfile(skin));
                ((SkullMeta) itemMeta).setOwner(markerDefinition.getPrefix());
            })).build();
            builder.withItem(i, is, (player, clickType, itemStack) -> sender.getPlayer().performCommand("editmode skull " + itemStack.getItemMeta().getDisplayName()), ClickType.LEFT);
        }
        builder.show(sender.getPlayer());
    } else {
        Lang.msg(sender, LangKey.EDITMODE_NOT_ENABLED);
    }
}
Also used : ItemBuilder(com.voxelgameslib.voxelgameslib.utils.ItemBuilder) InventoryMenuBuilder(org.inventivetalent.menubuilder.inventory.InventoryMenuBuilder) VoxelGameLibException(com.voxelgameslib.voxelgameslib.exception.VoxelGameLibException) Skin(org.mineskin.data.Skin) SkullMeta(org.bukkit.inventory.meta.SkullMeta) ItemStack(org.bukkit.inventory.ItemStack) MarkerDefinition(com.voxelgameslib.voxelgameslib.map.MarkerDefinition) Subcommand(co.aikar.commands.annotation.Subcommand) CommandPermission(co.aikar.commands.annotation.CommandPermission)

Example 7 with Subcommand

use of co.aikar.commands.annotation.Subcommand 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 8 with Subcommand

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

the class StatsCommands method decrement.

@Subcommand("decrement")
@Description("Allows you to decrement the stats of another user")
@CommandPermission("%admin")
@CommandCompletion("@players @stats")
public void decrement(User sender, @Description("the user which stats should be changed") @Flags("other") User user, @Description("the stats type to change") Trackable type, @Description("the amount to decrement, defaults to 1") @Default("1") int amount) {
    StatInstance stat = user.getUserData().getStat(type);
    stat.decrement(amount);
    Lang.msg(sender, LangKey.STATS_DECREMENT, user.getDisplayName(), type.getDisplayName(), type.formatLong(stat.getVal(), sender.getLocale()));
}
Also used : StatInstance(com.voxelgameslib.voxelgameslib.stats.StatInstance) Description(co.aikar.commands.annotation.Description) Subcommand(co.aikar.commands.annotation.Subcommand) CommandCompletion(co.aikar.commands.annotation.CommandCompletion) CommandPermission(co.aikar.commands.annotation.CommandPermission)

Example 9 with Subcommand

use of co.aikar.commands.annotation.Subcommand 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 10 with Subcommand

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

the class WorldCreator method world.

@Subcommand("world")
@CommandPermission("%admin")
public void world(@Nonnull User sender, @Nonnull String worldName) {
    if (step != 1) {
        Lang.msg(sender, LangKey.WORLD_CREATOR_WRONG_STEP, step, 1);
        return;
    }
    this.worldName = worldName;
    worldHandler.loadLocalWorld(worldName);
    Location spawnLoc = Bukkit.getWorld(worldName).getSpawnLocation();
    Vector3D spawn = new Vector3D(spawnLoc.getX(), spawnLoc.getY(), spawnLoc.getZ());
    sender.getPlayer().teleport(spawnLoc);
    game = gameHandler.startGame(EditModeGame.GAMEMODE);
    game.getActivePhase().getNextPhase().getFeature(SpawnFeature.class).addSpawn(spawn);
    Map map = new Map(null, worldName, spawn, 100);
    map.load(game.getUuid(), worldName);
    game.getActivePhase().getNextPhase().getFeature(MapFeature.class).setMap(map);
    game.join(editor);
    game.endPhase();
    Lang.msg(sender, LangKey.WORLD_CREATOR_ENTER_CENTER, "/worldcreator center");
    step = 2;
}
Also used : Vector3D(com.voxelgameslib.voxelgameslib.map.Vector3D) MapFeature(com.voxelgameslib.voxelgameslib.feature.features.MapFeature) SpawnFeature(com.voxelgameslib.voxelgameslib.feature.features.SpawnFeature) Map(com.voxelgameslib.voxelgameslib.map.Map) Location(org.bukkit.Location) Subcommand(co.aikar.commands.annotation.Subcommand) CommandPermission(co.aikar.commands.annotation.CommandPermission)

Aggregations

CommandPermission (co.aikar.commands.annotation.CommandPermission)17 Subcommand (co.aikar.commands.annotation.Subcommand)17 Syntax (co.aikar.commands.annotation.Syntax)6 Description (co.aikar.commands.annotation.Description)5 CommandCompletion (co.aikar.commands.annotation.CommandCompletion)4 Map (com.voxelgameslib.voxelgameslib.map.Map)4 ItemStack (org.bukkit.inventory.ItemStack)4 Vector3D (com.voxelgameslib.voxelgameslib.map.Vector3D)3 StatInstance (com.voxelgameslib.voxelgameslib.stats.StatInstance)3 ItemBuilder (com.voxelgameslib.voxelgameslib.utils.ItemBuilder)3 VoxelGameLibException (com.voxelgameslib.voxelgameslib.exception.VoxelGameLibException)2 MapFeature (com.voxelgameslib.voxelgameslib.feature.features.MapFeature)2 SpawnFeature (com.voxelgameslib.voxelgameslib.feature.features.SpawnFeature)2 Game (com.voxelgameslib.voxelgameslib.game.Game)2 SkullMeta (org.bukkit.inventory.meta.SkullMeta)2 Skin (org.mineskin.data.Skin)2 WorldException (com.voxelgameslib.voxelgameslib.exception.WorldException)1 GameMode (com.voxelgameslib.voxelgameslib.game.GameMode)1 MarkerDefinition (com.voxelgameslib.voxelgameslib.map.MarkerDefinition)1 File (java.io.File)1