Search in sources :

Example 6 with CommandPermission

use of co.aikar.commands.annotation.CommandPermission 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 CommandPermission

use of co.aikar.commands.annotation.CommandPermission 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 CommandPermission

use of co.aikar.commands.annotation.CommandPermission 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 CommandPermission

use of co.aikar.commands.annotation.CommandPermission 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 CommandPermission

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

the class LangCommands method lang.

@Default
@CommandPermission("%user")
public void lang(@Nonnull User sender) {
    StringBuilder sb = new StringBuilder();
    for (Locale loc : langHandler.getInstalledLocales()) {
        sb.append(loc.getTag()).append(" (").append(loc.getName()).append("), ");
    }
    sb.setLength(sb.length() - 1);
    Lang.msg(sender, LangKey.LANG_INSTALLED, sb.toString());
    Lang.msg(sender, LangKey.LANG_CURRENT, sender.getLocale().getName());
    Lang.msg(sender, LangKey.TRANSLATED_BY);
}
Also used : Locale(com.voxelgameslib.voxelgameslib.lang.Locale) Default(co.aikar.commands.annotation.Default) CommandPermission(co.aikar.commands.annotation.CommandPermission)

Aggregations

CommandPermission (co.aikar.commands.annotation.CommandPermission)18 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 Default (co.aikar.commands.annotation.Default)1 WorldException (com.voxelgameslib.voxelgameslib.exception.WorldException)1 GameMode (com.voxelgameslib.voxelgameslib.game.GameMode)1 Locale (com.voxelgameslib.voxelgameslib.lang.Locale)1