Ejemplo n.º 1
0
	@Override
	public void execute(CommandSender sender, String[] args) {
		Player player = (Player)sender;
		if (GameManager.hasGame(args[0].toLowerCase())) {
			player.sendMessage(_("arenaAlreadyExists"));
			return;
		}
		
		if (args[1].equalsIgnoreCase("cylinder") || args[1].equalsIgnoreCase("cyl")) {
			//Create a new cylinder game
			if (args.length < 4) {
				player.sendMessage(getUsage());
				return;
			}
			
			try {
				int radius = Integer.parseInt(args[2]);
				int height = Integer.parseInt(args[3]);
				
				Location center = player.getLocation();
				
				int minY = center.getBlockY();
				int maxY = center.getBlockY() + height;
				
				RegionCylinder region = new RegionCylinder(-1, center, radius, minY, maxY);
				Game game = new GameCylinder(args[0], region);
				GameManager.addGame(game);
			} catch (NumberFormatException e) {
				player.sendMessage(_("notANumber", args[2]));
				return;
			}
			
			player.sendMessage(_("gameCreated"));
		} else if (args[1].equalsIgnoreCase("cuboid") || args[1].equalsIgnoreCase("cub")) {
			//Create a new cuboid game
			Selection s = HeavySpleef.getInstance().getSelectionManager().getSelection(player);
			if (!s.hasSelection()) {
				player.sendMessage(_("needSelection"));
				return;
			}
			if (s.isTroughWorlds()) {
				player.sendMessage(_("selectionCantTroughWorlds"));
				return;
			}
			
			RegionCuboid region = new RegionCuboid(-1, s.getFirst(), s.getSecond());
			Game game = new GameCuboid(args[0], region);
			
			GameManager.addGame(game);
			player.sendMessage(_("gameCreated"));
		} else {
			player.sendMessage(_("unknownSpleefType"));
		}
	}