Search in sources :

Example 11 with Subcommand

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

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

the class StatsCommands method set.

@Subcommand("set")
@Description("Allows you to set the stats of another user")
@CommandPermission("%admin")
@CommandCompletion("@players @stats")
public void set(User sender, @Description("the user which stats should be changed") @Flags("other") User user, @Description("the stats type to change") Trackable type, @Description("the new amount") double amount) {
    StatInstance stat = user.getUserData().getStat(type);
    stat.setVal(amount);
    Lang.msg(sender, LangKey.STATS_SET, user.getDisplayName(), type.getDisplayName(), type.formatShort(stat.getVal()));
}
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 13 with Subcommand

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

the class StatsCommands method increment.

@Subcommand("increment")
@Description("Allows you to increment the stats of another user")
@CommandPermission("%admin")
@CommandCompletion("@players @stats")
public void increment(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 increment, defaults to 1") @Default("1") int amount) {
    StatInstance stat = user.getUserData().getStat(type);
    stat.increment(amount);
    Lang.msg(sender, LangKey.STATS_INCREMENT, 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 14 with Subcommand

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

the class TestCommands method chatmenu.

@Subcommand("chatmenu")
@CommandPermission("%admin")
public void chatmenu(@Nonnull User user) {
    ChatMenu menu = new ChatMenu().pauseChat(0, 0, ChatColor.RED + "[Close]");
    menu.add(new TextElement("Hello, world2!", 10, 10));
    IncrementalElement incr = new IncrementalElement(5, 5, 10);
    incr.value.setChangeCallback((s) -> System.out.println("IncrementalElement changed! " + s.getPrevious() + " -> " + s.getCurrent()));
    menu.add(incr);
    menu.openFor(user.getPlayer());
}
Also used : ChatMenu(me.tom.sparse.spigot.chat.menu.ChatMenu) TextElement(me.tom.sparse.spigot.chat.menu.element.TextElement) IncrementalElement(me.tom.sparse.spigot.chat.menu.element.IncrementalElement) Subcommand(co.aikar.commands.annotation.Subcommand) CommandPermission(co.aikar.commands.annotation.CommandPermission)

Example 15 with Subcommand

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

the class TextureCommands method getById.

@Subcommand("get")
@CommandPermission("%admin")
public void getById(@Nonnull User user, @Nonnull Integer id) {
    Lang.msg(user, LangKey.TEXTURE_FETCHING_TEXTURE);
    textureHandler.fetchSkin(id, skin -> {
        ItemStack skull = textureHandler.getSkull(skin);
        user.getPlayer().getInventory().addItem(skull);
        Lang.msg(user, LangKey.TEXTURE_TEXTURE_APPLIED);
    });
}
Also used : ItemStack(org.bukkit.inventory.ItemStack) 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