use of co.aikar.commands.annotation.CommandPermission 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;
}
use of co.aikar.commands.annotation.CommandPermission 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.CommandPermission 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.CommandPermission 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.CommandPermission 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());
}
Aggregations