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