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
}
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()));
}
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()));
}
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());
}
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);
});
}
Aggregations